From d549ab232a9424e26eeec67b363eabe593488f23 Mon Sep 17 00:00:00 2001 From: Sylvain Wallez Date: Wed, 1 Sep 2021 15:08:51 +0200 Subject: [PATCH 1/5] Update build: download API spec artifacts, security on by default --- .cargo/config.toml | 2 + .ci/DockerFile | 1 + .ci/functions/imports.sh | 5 +- .ci/run-elasticsearch.sh | 25 ++- .gitignore | 4 +- Cargo.toml | 10 +- Makefile.toml | 15 +- api_generator/Cargo.toml | 2 +- api_generator/src/bin/run.rs | 110 ++-------- .../generator/code_gen/namespace_clients.rs | 2 +- .../src/generator/code_gen/params.rs | 2 +- api_generator/src/generator/code_gen/root.rs | 2 +- api_generator/src/generator/mod.rs | 24 +-- api_generator/src/generator/output.rs | 29 ++- api_generator/src/rest_spec/mod.rs | 4 +- xtask/Cargo.toml | 16 ++ xtask/README.md | 4 + xtask/src/artifacts.rs | 197 ++++++++++++++++++ xtask/src/main.rs | 85 ++++++++ yaml_test_runner/Cargo.toml | 1 + yaml_test_runner/skip.yml | 65 ++++-- yaml_test_runner/src/generator.rs | 12 +- yaml_test_runner/src/github.rs | 106 ---------- yaml_test_runner/src/main.rs | 83 +++----- 24 files changed, 489 insertions(+), 317 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 xtask/Cargo.toml create mode 100644 xtask/README.md create mode 100644 xtask/src/artifacts.rs create mode 100644 xtask/src/main.rs delete mode 100644 yaml_test_runner/src/github.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..d2637ff2 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[alias] +xtask = "run -q --package xtask --" diff --git a/.ci/DockerFile b/.ci/DockerFile index 22c3889e..b249df10 100644 --- a/.ci/DockerFile +++ b/.ci/DockerFile @@ -27,5 +27,6 @@ COPY elasticsearch/Cargo.toml ./elasticsearch/Cargo.toml COPY elasticsearch/src ./elasticsearch/src COPY elasticsearch/build.rs ./elasticsearch/build.rs COPY yaml_test_runner ./yaml_test_runner +COPY xtask ./xtask RUN cargo build --tests diff --git a/.ci/functions/imports.sh b/.ci/functions/imports.sh index 3fb28cc3..c05f3682 100644 --- a/.ci/functions/imports.sh +++ b/.ci/functions/imports.sh @@ -26,10 +26,11 @@ if [[ -z $es_node_name ]]; then export es_node_name=instance export elastic_password=changeme export elasticsearch_image=elasticsearch - export elasticsearch_url=https://elastic:${elastic_password}@${es_node_name}:9200 + export elasticsearch_scheme="https" if [[ $TEST_SUITE != "platinum" ]]; then - export elasticsearch_url=http://${es_node_name}:9200 + export elasticsearch_scheme="http" fi + export elasticsearch_url=${elasticsearch_scheme}://elastic:${elastic_password}@${es_node_name}:9200 export external_elasticsearch_url=${elasticsearch_url/$es_node_name/localhost} export elasticsearch_container="${elasticsearch_image}:${STACK_VERSION}" diff --git a/.ci/run-elasticsearch.sh b/.ci/run-elasticsearch.sh index d3cf6ba3..b781de75 100755 --- a/.ci/run-elasticsearch.sh +++ b/.ci/run-elasticsearch.sh @@ -7,13 +7,18 @@ # Export the TEST_SUITE variable, eg. 'free' or 'platinum' defaults to 'free'. # Export the NUMBER_OF_NODES variable to start more than 1 node -# Version 1.1.0 +# Version 1.5.0 # - Initial version of the run-elasticsearch.sh script # - Deleting the volume should not dependent on the container still running # - Fixed `ES_JAVA_OPTS` config # - Moved to STACK_VERSION and TEST_VERSION # - Refactored into functions and imports # - Support NUMBER_OF_NODES +# - Added 5 retries on docker pull for fixing transient network errors +# - Added flags to make local CCR configurations work +# - Added action.destructive_requires_name=false as the default will be true in v8 +# - Added ingest.geoip.downloader.enabled=false as it causes false positives in testing +# - Moved ELASTIC_PASSWORD to the base arguments for "Security On by default" script_path=$(dirname $(realpath -s $0)) source $script_path/functions/imports.sh @@ -27,6 +32,7 @@ cluster_name=${moniker}${suffix} declare -a volumes environment=($(cat <<-END + --env ELASTIC_PASSWORD=$elastic_password --env node.name=$es_node_name --env cluster.name=$cluster_name --env cluster.initial_master_nodes=$master_node_name @@ -36,6 +42,8 @@ environment=($(cat <<-END --env node.attr.testattr=test --env path.repo=/tmp --env repositories.url.allowed_urls=http://snapshot.test* + --env action.destructive_requires_name=false + --env ingest.geoip.downloader.enabled=false END )) if [[ "$TEST_SUITE" == "platinum" ]]; then @@ -49,6 +57,7 @@ if [[ "$TEST_SUITE" == "platinum" ]]; then --env xpack.security.http.ssl.certificate=certs/testnode.crt --env xpack.security.http.ssl.certificate_authorities=certs/ca.crt --env xpack.security.transport.ssl.enabled=true + --env xpack.security.transport.ssl.verification_mode=certificate --env xpack.security.transport.ssl.key=certs/testnode.key --env xpack.security.transport.ssl.certificate=certs/testnode.crt --env xpack.security.transport.ssl.certificate_authorities=certs/ca.crt @@ -67,6 +76,17 @@ if [[ "$TEST_SUITE" == "platinum" ]]; then cert_validation_flags="--insecure --cacert /usr/share/elasticsearch/config/certs/ca.crt --resolve ${es_node_name}:443:127.0.0.1" fi +# Pull the container, retry on failures up to 5 times with +# short delays between each attempt. Fixes most transient network errors. +docker_pull_attempts=0 +until [ "$docker_pull_attempts" -ge 5 ] +do + docker pull docker.elastic.co/elasticsearch/"$elasticsearch_container" && break + docker_pull_attempts=$((docker_pull_attempts+1)) + echo "Failed to pull image, retrying in 10 seconds (retry $docker_pull_attempts/5)..." + sleep 10 +done + NUMBER_OF_NODES=${NUMBER_OF_NODES-1} http_port=9200 for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do @@ -92,7 +112,7 @@ END docker run \ --name "$node_name" \ --network "$network_name" \ - --env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \ + --env "ES_JAVA_OPTS=-Xms1g -Xmx1g -da:org.elasticsearch.xpack.ccr.index.engine.FollowingEngineAssertions" \ "${environment[@]}" \ "${volumes[@]}" \ --publish "$http_port":9200 \ @@ -112,4 +132,3 @@ END fi done - diff --git a/.gitignore b/.gitignore index b2d991dc..f6e9c027 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ Cargo.lock *.iml .vscode/ *.log -yaml_test_runner/yaml/ -yaml_test_runner/tests/oss +yaml_test_runner/tests/free yaml_test_runner/tests/xpack yaml_test_runner/tests/mod.rs test_results/ +checkout/ diff --git a/Cargo.toml b/Cargo.toml index 1dccee9b..0eeec3b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,5 +2,11 @@ members = [ "api_generator", "elasticsearch", - "yaml_test_runner" -] \ No newline at end of file + "yaml_test_runner", + "xtask" +] + +# See https://jakedeichert.com/blog/reducing-rust-incremental-compilation-times-on-macos-by-70-percent/ +# and https://github.com/rust-lang/cargo/pull/9298 +[profile.dev] +split-debuginfo = "unpacked" diff --git a/Makefile.toml b/Makefile.toml index b7db9520..27bd0845 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -16,7 +16,7 @@ category = "Elasticsearch" description = "Sets ELASTICSEARCH_URL environment variable if not already set for later tasks when free test suite used" private = true condition = { env = { "TEST_SUITE" = "free" }, env_not_set = ["ELASTICSEARCH_URL"] } -env = { "ELASTICSEARCH_URL" = "http://localhost:9200" } +env = { "ELASTICSEARCH_URL" = "http://elastic:changeme@localhost:9200" } [tasks.set-platinum-env] category = "Elasticsearch" @@ -25,6 +25,16 @@ private = true condition = { env = { "TEST_SUITE" = "platinum" }, env_not_set = ["ELASTICSEARCH_URL"] } env = { "ELASTICSEARCH_URL" = "https://elastic:changeme@localhost:9200" } +[tasks.download-specs] +category = "Elasticsearch" +description = '''Donwload Rest API specs and YAML tests''' +private = true +command = "cargo" +# cargo-make insists on installing cargo-xtask and ignores .cargo/config.toml +#args = ["xtask", "download-specs", "--url", "${ELASTICSEARCH_URL}"] +args = ["run", "-q", "-p", "xtask", "--", "download-specs", "--url", "${ELASTICSEARCH_URL}"] +dependencies = ["start-elasticsearch"] + [tasks.run-yaml-test-runner] category = "Elasticsearch" description = ''' @@ -34,7 +44,7 @@ The commit to use is retrieved from the running Elasticsearch instance private = true command = "cargo" args = ["run", "-p", "yaml_test_runner", "--", "-u", "${ELASTICSEARCH_URL}"] -dependencies = ["start-elasticsearch"] +dependencies = ["download-specs"] [tasks.test-yaml-test-runner] category = "Elasticsearch" @@ -64,6 +74,7 @@ category = "Elasticsearch" private = true command = "cargo" args = ["run", "-p", "api_generator"] +dependencies = ["download-specs"] [tasks.create-test-results-dir] category = "Elasticsearch" diff --git a/api_generator/Cargo.toml b/api_generator/Cargo.toml index 3bdb7d3a..b5c0debb 100644 --- a/api_generator/Cargo.toml +++ b/api_generator/Cargo.toml @@ -9,9 +9,9 @@ edition = "2018" license = "Apache-2.0" [dependencies] +anyhow = "1.0" array_tool = "1.0.3" dialoguer = "0.3.0" -failure = "0.1.5" flate2 = "~1" globset = "~0.4" Inflector = "0.11.4" diff --git a/api_generator/src/bin/run.rs b/api_generator/src/bin/run.rs index ad4a5a98..143b6779 100644 --- a/api_generator/src/bin/run.rs +++ b/api_generator/src/bin/run.rs @@ -19,107 +19,43 @@ extern crate api_generator; extern crate dialoguer; -use api_generator::{generator, rest_spec}; -use dialoguer::Input; -use std::{ - fs::{self, File}, - io::Write, - path::PathBuf, -}; +use anyhow::{bail, Context}; +use api_generator::generator; +use std::{fs, path::PathBuf}; -fn main() -> Result<(), failure::Error> { +fn main() -> anyhow::Result<()> { simple_logger::SimpleLogger::new() .with_level(log::LevelFilter::Info) .init() .unwrap(); - // This must be run from the repo root directory, with cargo make generate-api - let download_dir = fs::canonicalize(PathBuf::from("./api_generator/rest_specs"))?; - let generated_dir = fs::canonicalize(PathBuf::from("./elasticsearch/src"))?; - let last_downloaded_version = - PathBuf::from("./api_generator/rest_specs/last_downloaded_version"); - - let mut download_specs = false; - let mut answer = String::new(); - let default_branch = if last_downloaded_version.exists() { - fs::read_to_string(&last_downloaded_version)? - } else { - String::from("master") - }; - let mut branch = default_branch.clone(); + let stack_version = std::env::var("STACK_VERSION").context("Missing STACK_VERSION env var")?; - while answer != "y" && answer != "n" { - answer = Input::new() - .default(String::from("n")) - .show_default(false) - .with_prompt("Download rest specifications [y/N]") - .interact() - .unwrap() - .to_lowercase(); - download_specs = answer == "y"; - } - - if download_specs { - branch = Input::new() - .default(default_branch.clone()) - .show_default(false) - .with_prompt( - format!( - "Branch to download specification from [default {}]", - default_branch - ) - .as_str(), - ) - .interact() - .unwrap(); + // This must be run from the repo root directory, with cargo make generate-api + let download_dir = PathBuf::from(&format!("./checkout/{}/rest-api-spec/api", stack_version)); - fs::remove_dir_all(&download_dir)?; - fs::create_dir_all(&download_dir)?; - rest_spec::download_specs(&branch, &download_dir)?; - File::create(&last_downloaded_version)?.write_all(branch.as_bytes())?; + if !download_dir.is_dir() { + bail!("No specs found at {:?}", download_dir); } - // only offer to generate if there are downloaded specs - if download_dir - .read_dir() - .map(|mut r| r.next().is_some()) - .unwrap_or(false) - { - let mut generate_code = true; - answer = String::new(); - while answer != "y" && answer != "n" { - answer = Input::new() - .default(String::from("y")) - .show_default(false) - .with_prompt( - format!("Generate code from rest specifications {} [Y/n]", branch).as_str(), - ) - .interact() - .unwrap() - .to_lowercase(); - generate_code = answer == "y"; - } - - if generate_code { - // Delete previously generated files - let mut generated = generated_dir.clone(); - generated.push(generator::GENERATED_TOML); - - if generated.exists() { - let files = - toml::from_str::(&fs::read_to_string(generated)?)?; + // let download_dir = fs::canonicalize(PathBuf::from("./api_generator/rest_specs"))?; + let generated_dir = fs::canonicalize(PathBuf::from("./elasticsearch/src"))?; - for f in files.written { - let mut generated_file = generated_dir.clone(); - generated_file.push(f); - let _ = fs::remove_file(generated_file); // ignore missing files - } - } + // Delete previously generated files + let mut generated = generated_dir.clone(); + generated.push(generator::GENERATED_TOML); + if generated.exists() { + let files = toml::from_str::(&fs::read_to_string(generated)?)?; - // and generate! - generator::generate(&branch, &download_dir, &generated_dir)?; + for f in files.written { + let mut generated_file = generated_dir.clone(); + generated_file.push(f); + let _ = fs::remove_file(generated_file); // ignore missing files } } + // and generate! + generator::generate(&download_dir, &generated_dir)?; + Ok(()) } diff --git a/api_generator/src/generator/code_gen/namespace_clients.rs b/api_generator/src/generator/code_gen/namespace_clients.rs index b27b26a1..4a69c996 100644 --- a/api_generator/src/generator/code_gen/namespace_clients.rs +++ b/api_generator/src/generator/code_gen/namespace_clients.rs @@ -25,7 +25,7 @@ use quote::Tokens; use std::path::PathBuf; /// Generates the source code for a namespaced client -pub fn generate(api: &Api, docs_dir: &PathBuf) -> Result, failure::Error> { +pub fn generate(api: &Api, docs_dir: &PathBuf) -> anyhow::Result> { let mut output = Vec::new(); for (namespace_name, namespace) in &api.namespaces { diff --git a/api_generator/src/generator/code_gen/params.rs b/api_generator/src/generator/code_gen/params.rs index 51491d77..bf02a5e9 100644 --- a/api_generator/src/generator/code_gen/params.rs +++ b/api_generator/src/generator/code_gen/params.rs @@ -22,7 +22,7 @@ use inflector::Inflector; use quote::Tokens; use regex::Regex; -pub fn generate(api: &Api) -> Result { +pub fn generate(api: &Api) -> anyhow::Result { let mut tokens = quote!( use serde::{Serialize, Deserialize}; ); diff --git a/api_generator/src/generator/code_gen/root.rs b/api_generator/src/generator/code_gen/root.rs index 635102de..476425b9 100644 --- a/api_generator/src/generator/code_gen/root.rs +++ b/api_generator/src/generator/code_gen/root.rs @@ -25,7 +25,7 @@ use quote::Tokens; use std::path::PathBuf; /// Generates the source code for the methods on the root of Elasticsearch -pub fn generate(api: &Api, docs_dir: &PathBuf) -> Result { +pub fn generate(api: &Api, docs_dir: &PathBuf) -> anyhow::Result { let mut tokens = Tokens::new(); tokens.append(use_declarations()); diff --git a/api_generator/src/generator/mod.rs b/api_generator/src/generator/mod.rs index 9c90f349..487cf20c 100644 --- a/api_generator/src/generator/mod.rs +++ b/api_generator/src/generator/mod.rs @@ -62,7 +62,6 @@ pub const GENERATED_TOML: &str = ".generated.toml"; /// A complete API specification parsed from the REST API specs pub struct Api { - pub commit: String, /// parameters that are common to all API methods pub common_params: BTreeMap, /// root API methods e.g. Search, Index @@ -513,18 +512,11 @@ impl PartialEq for ApiEnum { impl Eq for ApiEnum {} /// Generates all client source code from the REST API spec -pub fn generate( - branch: &str, - download_dir: &PathBuf, - generated_dir: &PathBuf, -) -> Result<(), failure::Error> { +pub fn generate(download_dir: &PathBuf, generated_dir: &PathBuf) -> anyhow::Result<()> { // read the Api from file - let api = read_api(branch, download_dir)?; + let api = read_api(download_dir)?; - let docs_dir = { - let d = download_dir.clone(); - d.parent().unwrap().join("docs") - }; + let docs_dir = PathBuf::from("./api_generator/docs"); // generated file tracking lists let mut tracker = GeneratedFiles::default(); @@ -597,7 +589,7 @@ pub use bulk::*; } /// Reads Api from a directory of REST Api specs -pub fn read_api(branch: &str, download_dir: &PathBuf) -> Result { +pub fn read_api(download_dir: &PathBuf) -> anyhow::Result { let paths = fs::read_dir(download_dir)?; let mut namespaces = BTreeMap::::new(); let mut enums: HashSet = HashSet::new(); @@ -677,7 +669,6 @@ pub fn read_api(branch: &str, download_dir: &PathBuf) -> Result Result( - name: String, - reader: &mut R, -) -> Result<(String, ApiEndpoint), failure::Error> +fn endpoint_from_file(name: String, reader: &mut R) -> anyhow::Result<(String, ApiEndpoint)> where R: Read, { @@ -728,7 +716,7 @@ where } /// deserializes Common from a file -fn common_params_from_file(name: String, reader: &mut R) -> Result +fn common_params_from_file(name: String, reader: &mut R) -> anyhow::Result where R: Read, { diff --git a/api_generator/src/generator/output.rs b/api_generator/src/generator/output.rs index 08697fed..c94106cd 100644 --- a/api_generator/src/generator/output.rs +++ b/api_generator/src/generator/output.rs @@ -1,4 +1,5 @@ use super::GeneratedFiles; +use anyhow::bail; use path_slash::*; use regex::Regex; use std::fs::File; @@ -14,7 +15,7 @@ pub fn write_file( dir: &PathBuf, file_name: &str, tracker: &mut GeneratedFiles, -) -> Result<(), failure::Error> { +) -> anyhow::Result<()> { let mut path = dir.clone(); path.push(PathBuf::from_slash(file_name)); @@ -105,7 +106,7 @@ pub fn merge_file( dir: &Path, file_name: &str, tracker: &mut GeneratedFiles, -) -> Result<(), failure::Error> { +) -> anyhow::Result<()> { let mut path = dir.to_owned(); path.push(PathBuf::from_slash(file_name)); @@ -119,11 +120,11 @@ pub fn merge_file( if let Some(captures) = START_REGEX.captures(&line) { if in_generated_section { - return Err(failure::format_err!( + bail!( "{}:{} - Previous generated section wasn't closed", file_name, line_no - )); + ); } // Output start marker @@ -139,20 +140,16 @@ pub fn merge_file( if let Some(text) = get_content(section) { output.push_str(&text); } else { - return Err(failure::format_err!( + bail!( "{}:{} - No content found to generate section '{}'", file_name, line_no, section - )); + ); } } else if END_REGEX.is_match(&line) { if !in_generated_section { - return Err(failure::format_err!( - "{}:{} - Missing GENERATED-START marker", - file_name, - line_no - )); + bail!("{}:{} - Missing GENERATED-START marker", file_name, line_no); } // Output end marker @@ -168,10 +165,10 @@ pub fn merge_file( } if in_generated_section { - return Err(failure::format_err!( + bail!( "{} - Missing GENERATED-END marker at end of file", file_name - )); + ); } std::fs::write(&path, output)?; @@ -188,7 +185,7 @@ mod test { use std::fs; #[test] - pub fn nominal_merge() -> Result<(), failure::Error> { + pub fn nominal_merge() -> anyhow::Result<()> { let dir = tempfile::tempdir()?; let dir_path = dir.path(); let file_name = "test_merge.rs"; @@ -252,7 +249,7 @@ Contents of section bar } #[test] - fn unbalanced_sections() -> Result<(), failure::Error> { + fn unbalanced_sections() -> anyhow::Result<()> { merge_should_fail( r#" // GENERATED-BEGIN:foo @@ -283,7 +280,7 @@ Contents of section bar Ok(()) } - fn merge_should_fail(input: &str) -> Result<(), failure::Error> { + fn merge_should_fail(input: &str) -> anyhow::Result<()> { let dir = tempfile::tempdir()?; let dir_path = dir.path(); let file_name = "test_merge.rs"; diff --git a/api_generator/src/rest_spec/mod.rs b/api_generator/src/rest_spec/mod.rs index 1508d177..a56e015d 100644 --- a/api_generator/src/rest_spec/mod.rs +++ b/api_generator/src/rest_spec/mod.rs @@ -24,7 +24,7 @@ use reqwest::Response; use std::{fs::File, io, path::PathBuf}; use tar::{Archive, Entry}; -pub fn download_specs(branch: &str, download_dir: &PathBuf) -> Result<(), failure::Error> { +pub fn download_specs(branch: &str, download_dir: &PathBuf) -> anyhow::Result<()> { let url = format!( "https://api.github.com/repos/elastic/elasticsearch/tarball/{}", branch @@ -63,7 +63,7 @@ pub fn download_specs(branch: &str, download_dir: &PathBuf) -> Result<(), failur fn write_spec_file( download_dir: &PathBuf, mut entry: Entry>, -) -> Result<(), failure::Error> { +) -> anyhow::Result<()> { let path = entry.path()?; let mut dir = download_dir.clone(); dir.push(path.file_name().unwrap()); diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml new file mode 100644 index 00000000..99d3bf8a --- /dev/null +++ b/xtask/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "xtask" +version = "0.0.0" +edition = "2018" +publish = false + +[dependencies] +structopt = "0.3" +reqwest = { version = "0.11", features = ["blocking", "json"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +anyhow = "1.0" +once_cell = "1.8" +chrono = { version = "0.4", features = ["serde"] } +zip = "0.5" +regex = "1.5.4" diff --git a/xtask/README.md b/xtask/README.md new file mode 100644 index 00000000..37112328 --- /dev/null +++ b/xtask/README.md @@ -0,0 +1,4 @@ +This package contains parts of the build system as a CLI tool. It follows the convention defined in https://github.com/matklad/cargo-xtask that were inspired by the [Make your own make](https://matklad.github.io/2018/01/03/make-your-own-make.html) +blog post. + +Over time we will move the script parts of `Make.toml` here, and maybe ultimately stop using `cargo-make` altogether. diff --git a/xtask/src/artifacts.rs b/xtask/src/artifacts.rs new file mode 100644 index 00000000..037d3dce --- /dev/null +++ b/xtask/src/artifacts.rs @@ -0,0 +1,197 @@ +/* + * 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. + */ + +use super::*; +use anyhow::Context; +use chrono::{DateTime, FixedOffset}; +use reqwest::blocking as reqwest; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use std::fs; +use std::io; + +pub fn download(commit_hash: Option, url: Option) -> anyhow::Result<()> { + // Get commit hash from ES if its URL has been provided + let commit_hash = if let Some(url) = url { + Some(super::get_es_commit_hash(url)?) + } else { + commit_hash + }; + + // Check if it's already there + if let Some(expected_hash) = &commit_hash { + if let Some(project) = read_local_project()? { + if &project.commit_hash == expected_hash { + println!("Specs were already downloaded."); + return Ok(()); + } + } + } + + let spec_dir = ROOT_DIR.join("checkout").join(STACK_VERSION.deref()); + + let artifacts_url = format!( + "https://artifacts-api.elastic.co/v1/versions/{}", + *STACK_VERSION + ); + println!("Downloading build info from {}", &artifacts_url); + + let artifacts = reqwest::get(&artifacts_url)?.json::()?; + + let project = match &commit_hash { + Some(hash) => artifacts + .version + .builds + .iter() + .find(|build| { + build + .projects + .get("elasticsearch") + .filter(|es| &es.commit_hash == hash) + .is_some() + }) + .with_context(|| format!("Cannot find commit hash {}", hash))? + .projects + .get("elasticsearch") + .unwrap(), // ES is guaranteed to be there + + None => artifacts + .version + .builds + .iter() + .max_by_key(|build| build.start_time) + .unwrap() + .projects + .get("elasticsearch") + .with_context(|| "Project 'elasticsearch' not found")?, + }; + + let specs_url = project + .packages + .get(&format!("rest-resources-zip-{}.zip", *STACK_VERSION)) + .with_context(|| "Package 'rest-resources-zip' not found")? + .url + .clone(); + + println!("Downloading specs and yaml tests from {}", &specs_url); + let zip_resp = reqwest::get(&specs_url)?.bytes()?; + + if spec_dir.exists() { + fs::remove_dir_all(&spec_dir).unwrap(); + } + fs::create_dir_all(&spec_dir).unwrap(); + zip::ZipArchive::new(io::Cursor::new(zip_resp))?.extract(&spec_dir)?; + + // Also write project metadata for reference + let project_path = &spec_dir.join("elasticsearch.json"); + let project_file = fs::File::create(&project_path)?; + serde_json::to_writer_pretty(project_file, &project)?; + + Ok(()) +} + +pub fn read_local_project() -> anyhow::Result> { + let spec_dir = ROOT_DIR.join("checkout").join(STACK_VERSION.deref()); + let project_path = &spec_dir.join("elasticsearch.json"); + + if project_path.exists() { + Ok(serde_json::from_reader(fs::File::open(project_path)?)?) + } else { + Ok(None) + } +} + +#[derive(Deserialize, Debug)] +pub struct Artifacts { + pub version: Version, + // manifests +} + +#[derive(Deserialize, Debug)] +pub struct Version { + pub version: String, + pub builds: Vec, +} + +#[derive(Deserialize, Debug)] +pub struct Build { + pub projects: HashMap, + #[serde(with = "rfc2822_format")] + pub start_time: DateTime, + pub release_branch: String, + pub version: String, + pub branch: String, + pub build_id: String, + // end_time: String, + // prefix: String, + // manifest_version: String, + // build_duration_seconds: u32 +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct Project { + pub branch: String, + pub commit_hash: String, + pub packages: HashMap, + // commit_url + // build_duration_seconds: u32 +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct Package { + pub url: String, + pub sha_url: String, + pub asc_url: String, + pub architecture: Option, + + #[serde(rename = "type")] + pub type_: String, + pub classifier: Option, + pub attributes: Option, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct Attributes { + pub internal: Option, + pub artifact_id: Option, + pub oss: Option, + pub group: Option, +} + +#[allow(dead_code)] +mod rfc2822_format { + use chrono::{DateTime, FixedOffset}; + use serde::{self, Deserialize, Deserializer, Serializer}; + + pub fn serialize(date: &DateTime, serializer: S) -> Result + where + S: Serializer, + { + let s = date.to_rfc2822(); + serializer.serialize_str(&s) + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + DateTime::parse_from_rfc2822(&s).map_err(serde::de::Error::custom) + } +} diff --git a/xtask/src/main.rs b/xtask/src/main.rs new file mode 100644 index 00000000..9679d0ed --- /dev/null +++ b/xtask/src/main.rs @@ -0,0 +1,85 @@ +/* + * 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. + */ + +use anyhow::bail; +use once_cell::sync::Lazy; +use std::env; +use std::ops::Deref; +use std::path; +use structopt::StructOpt; + +pub mod artifacts; + +/// elasticsearch-rs build helpers +#[derive(StructOpt, Debug)] +enum Cmd { + /// Download Elasticsearch Rest specs and YAML tests + DownloadSpecs { + /// Specific commit hash to download + #[structopt(long, short)] + commit_hash: Option, + /// Get the commit hash to download from a running ES server + #[structopt(long, short)] + url: Option, + }, + /// Get the commit hash of Elasticsearch running at + EsCommitHash { + /// URL of the Elasticsearch server + #[structopt(long, short)] + url: String, + }, +} + +fn main() -> anyhow::Result<()> { + let opt = Cmd::from_args(); + match opt { + Cmd::DownloadSpecs { commit_hash, url } => artifacts::download(commit_hash, url), + Cmd::EsCommitHash { url } => { + print!("{}", get_es_commit_hash(url)?); + Ok(()) + } + } +} + +pub static ROOT_DIR: Lazy = Lazy::new(|| { + let mf = env::var("CARGO_MANIFEST_DIR").expect("Should be run using 'cargo xtask ...'"); + path::Path::new(&mf).parent().unwrap().to_owned() +}); + +pub static STACK_VERSION: Lazy = + Lazy::new(|| env::var("STACK_VERSION").expect("Missing STACK_VERSION environment variable")); + +pub fn get_es_commit_hash(url: String) -> anyhow::Result { + let client = reqwest::blocking::ClientBuilder::new() + .danger_accept_invalid_certs(true) + .build()?; + + let response = client.get(url).send()?; + if response.status() != reqwest::StatusCode::OK { + bail!( + "Cannot fetch ES information - status code {}", + response.status() + ) + } + + let json: serde_json::Value = response.json()?; + let branch = json["version"]["build_hash"].as_str().unwrap().to_string(); + + Ok(branch) +} diff --git a/yaml_test_runner/Cargo.toml b/yaml_test_runner/Cargo.toml index 73faad45..21c8a40a 100644 --- a/yaml_test_runner/Cargo.toml +++ b/yaml_test_runner/Cargo.toml @@ -12,6 +12,7 @@ license = "Apache-2.0" elasticsearch = { path = "./../elasticsearch", features = ["experimental-apis"]} api_generator = { path = "./../api_generator" } +anyhow = "1.0" base64 = "^0.11" clap = "~2" failure = "0.1.6" diff --git a/yaml_test_runner/skip.yml b/yaml_test_runner/skip.yml index 034dfb43..3242ec94 100644 --- a/yaml_test_runner/skip.yml +++ b/yaml_test_runner/skip.yml @@ -12,66 +12,93 @@ features: # tests to skip generating and compiling a test for tests: - xpack/api_key/10_basic.yml: + platinum/api_key/10_basic.yml: # Regex contains variable substitutions that the test harness doesn't support yet - "Test invalidate api keys" - xpack/data_stream/40_supported_apis.yml: + platinum/analytics/histogram.yml: + # Regex doesn't match. Could be either the leading space or escaping of '[' + - "Histogram requires values in increasing order" + + platinum/data_stream/40_supported_apis.yml: # uses number as a key into object. serde_json::Value expects a string key - "Verify shard stores api" - xpack/data_stream/80_resolve_index_data_streams.yml: + platinum/data_stream/80_resolve_index_data_streams.yml: # Regex not properly interpreted by the test harness - "Resolve index with hidden and closed indices" # expected value json["indices"][0]["name"] to match String("test_index1") but was String(".security-7") - "Resolve index with indices, aliases, and data streams" - xpack/license/30_enterprise_license.yml: + platinum/license/30_enterprise_license.yml: # Warning "Including [accept_enterprise] in get license requests is deprecated" is no more present - "Installing enterprise license" - xpack/ml/filter_crud.yml: + platinum/ml/bucket_correlation_agg.yml: + # Expects true, got 0 (i.e. falsy) + - "Test correlation bucket agg simple" + + platinum/ml/filter_crud.yml: # Warning "this request accesses system indices..." to match is wrong on all tests - "*" - xpack/runtime_fields/20_long.yml: + platinum/ml/inference_crud.yml: + # expected response to be 404 but was 200 + # Missing cleanup as running on a fresh ES server succeeds + - "Test delete model alias with missing alias" + - "Test delete model alias where alias points to different model" + - "Test update model alias with model id referring to missing model" + + platinum/runtime_fields/20_long.yml: # expected value ... to match Number(40.0) but was Number(40) - "terms agg" - xpack/snapshot/20_operator_privileges_disabled.yml: + platinum/searchable_snapshots/10_usage.yml: + # 2nd test fails and causes subsequent tests to timeout. Need to see if some extra cleanup is needed. + - "*" + + platinum/service_accounts/10_basic.yml: + # expected value json["count"] to match 2 but was Number(1) + - "Test service account tokens" + + platinum/snapshot/10_basic.yml: + # Expect 1 but got 2 + - "Create a source only snapshot and then restore it" + + platinum/snapshot/20_operator_privileges_disabled.yml: # expected value json["persistent"]["xpack"]["security"]["http"]["filter"]["deny"] to match String("example.com") # but was String("tutorial.com") - "Operator only settings can be set and restored by non-operator user when operator privileges is disabled" - xpack/ssl/10_basic.yml: + platinum/ssl/10_basic.yml: # this test returns the CA cert before the cert, so always fails - "Test get SSL certificates" - xpack/transform/transforms_stats_continuous.yml: + platinum/transform/transforms_stats_continuous.yml: # this test always returns "exponential_avg_checkpoint_duration_ms": 0.0 . seems like it might be missing data in # the setup, fires quicker than any documents are processed, or the delay of 1m is too high? - "Test get continuous transform stats" - xpack/transform/transforms_update.yml: + platinum/transform/transforms_update.yml: # In setup: 409 Conflict - Cannot delete transform [airline-transform-stats-continuous] as the task is running. - "Test alias scenarios" # Test generator currently doesn't handle unsigned long values. # We skip all tests as even the setup code will fail to compile. - xpack/unsigned_long/10_basic.yml: + platinum/unsigned_long/10_basic.yml: - "*" - xpack/unsigned_long/20_null_value.yml: + platinum/unsigned_long/20_null_value.yml: - "*" - xpack/unsigned_long/30_multi_fields.yml: + platinum/unsigned_long/30_multi_fields.yml: - "*" - xpack/unsigned_long/40_different_numeric.yml: + platinum/unsigned_long/40_different_numeric.yml: - "*" - xpack/unsigned_long/50_script_values.yml: + platinum/unsigned_long/50_script_values.yml: - "*" - xpack/unsigned_long/60_collapse.yml: + platinum/unsigned_long/60_collapse.yml: - "*" - xpack/xpack/20_info.yml: + platinum/xpack/20_info.yml: # Expects "trial" license but gets "enterprise" - "XPack Info API" @@ -89,6 +116,10 @@ tests: # uses number as a key into object. serde_json::Value expects a string key - "basic segments test" + free/indices.get_alias/10_basic.yml: + # expected value at &json["test_index_2"] to be false but was Object({"aliases": Object({"test_alias": Object({})})}) + - "Get alias against closed indices" + free/indices.shard_stores/10_basic.yml: # uses number as a key into object. serde_json::Value expects a string key - "basic index test" diff --git a/yaml_test_runner/src/generator.rs b/yaml_test_runner/src/generator.rs index 276f42c3..0423ddbe 100644 --- a/yaml_test_runner/src/generator.rs +++ b/yaml_test_runner/src/generator.rs @@ -371,7 +371,7 @@ pub fn generate_tests_from_yaml( base_download_dir: &PathBuf, download_dir: &PathBuf, generated_dir: &PathBuf, -) -> Result<(), failure::Error> { +) -> anyhow::Result<()> { let skips = serde_yaml::from_str::(include_str!("./../skip.yml"))?; let paths = fs::read_dir(download_dir)?; for entry in paths { @@ -407,8 +407,8 @@ pub fn generate_tests_from_yaml( match top_dir.as_str() { "free" => TestSuite::Free, - "xpack" => TestSuite::XPack, - _ => panic!("Unknown test suite {:?}", path), + "xpack" | "platinum" => TestSuite::XPack, + dir => panic!("Unknown test suite '{}' {:?}", dir, path), } }; @@ -486,7 +486,7 @@ pub fn generate_tests_from_yaml( } /// Writes a mod.rs file in each generated directory -fn write_mod_files(generated_dir: &PathBuf, toplevel: bool) -> Result<(), failure::Error> { +fn write_mod_files(generated_dir: &PathBuf, toplevel: bool) -> anyhow::Result<()> { if !generated_dir.exists() { fs::create_dir(generated_dir)?; } @@ -531,7 +531,7 @@ fn write_mod_files(generated_dir: &PathBuf, toplevel: bool) -> Result<(), failur Ok(()) } -fn test_file_path(relative_path: &Path) -> Result { +fn test_file_path(relative_path: &Path) -> anyhow::Result { let mut relative = relative_path.to_path_buf(); relative.set_extension(""); // directories and files will form the module names so ensure they're valid module names @@ -555,7 +555,7 @@ fn write_test_file( test: YamlTests, relative_path: &Path, generated_dir: &PathBuf, -) -> Result<(), failure::Error> { +) -> anyhow::Result<()> { if test.skip_test("*") { info!( r#"skipping all tests in {} because it's included in skip.yml"#, diff --git a/yaml_test_runner/src/github.rs b/yaml_test_runner/src/github.rs deleted file mode 100644 index c4eaf9ec..00000000 --- a/yaml_test_runner/src/github.rs +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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. - */ -use flate2::read::GzDecoder; -use globset::Glob; -use io::Write; -use reqwest::{ - header::{HeaderMap, HeaderValue, USER_AGENT}, - Response, -}; -use std::{fs, fs::File, io, path::PathBuf}; -use tar::{Archive, Entry}; - -/// Downloads the yaml tests if not already downloaded -pub fn download_test_suites(branch: &str, download_dir: &PathBuf) -> Result<(), failure::Error> { - let mut last_downloaded_version = download_dir.clone(); - last_downloaded_version.push("last_downloaded_version"); - if last_downloaded_version.exists() { - let version = fs::read_to_string(&last_downloaded_version) - .expect("Unable to read last_downloaded_version of yaml tests"); - if version == branch { - info!("Already downloaded yaml tests from {}", branch); - return Ok(()); - } - } - - info!("Downloading yaml tests from {}", branch); - let url = format!( - "https://api.github.com/repos/elastic/elasticsearch/tarball/{}", - branch - ); - let mut headers = HeaderMap::new(); - headers.append( - USER_AGENT, - HeaderValue::from_str(&format!("elasticsearch-rs/{}", env!("CARGO_PKG_NAME")))?, - ); - let client = reqwest::ClientBuilder::new() - .default_headers(headers) - .build() - .unwrap(); - - let response = client.get(&url).send()?; - let tar = GzDecoder::new(response); - let mut archive = Archive::new(tar); - - let oss_test = Glob::new("**/rest-api-spec/src/main/resources/rest-api-spec/test/**/*.yml")? - .compile_matcher(); - let xpack_test = Glob::new("**/x-pack/plugin/src/test/resources/rest-api-spec/test/**/*.yml")? - .compile_matcher(); - - for entry in archive.entries()? { - let file = entry?; - let path = file.path()?; - if oss_test.is_match(&path) { - write_test_file(download_dir, "free", file)?; - } else if xpack_test.is_match(&path) { - write_test_file(download_dir, "xpack", file)?; - } - } - - info!("Downloaded yaml tests from {}", &branch); - File::create(last_downloaded_version) - .expect("failed to create last_downloaded_version file") - .write_all(branch.as_bytes()) - .expect("unable to write branch to last_downloaded_version file"); - - Ok(()) -} - -fn write_test_file( - download_dir: &PathBuf, - suite_dir: &str, - mut entry: Entry>, -) -> Result<(), failure::Error> { - let path = entry.path()?; - - let mut dir = { - let mut dir = download_dir.clone(); - dir.push(suite_dir); - let parent = path.parent().unwrap().file_name().unwrap(); - dir.push(parent); - dir - }; - - fs::create_dir_all(&dir)?; - dir.push(path.file_name().unwrap()); - let mut file = File::create(&dir)?; - io::copy(&mut entry, &mut file)?; - - Ok(()) -} diff --git a/yaml_test_runner/src/main.rs b/yaml_test_runner/src/main.rs index 161c9c70..f0f6e40e 100644 --- a/yaml_test_runner/src/main.rs +++ b/yaml_test_runner/src/main.rs @@ -28,19 +28,19 @@ extern crate quote; extern crate simple_logger; +use anyhow::bail; use clap::{App, Arg}; use log::LevelFilter; use serde_json::Value; use std::{fs, path::PathBuf, process::exit}; mod generator; -mod github; mod regex; mod step; use generator::TestSuite; -fn main() -> Result<(), failure::Error> { +fn main() -> anyhow::Result<()> { simple_logger::SimpleLogger::new() .with_level(LevelFilter::Info) .init() @@ -58,58 +58,41 @@ fn main() -> Result<(), failure::Error> { .get_matches(); let url = matches.value_of("url").expect("missing 'url' argument"); - let (branch, suite, version) = match branch_suite_and_version_from_elasticsearch(url) { - Ok(v) => v, - Err(e) => { - error!( - "Problem getting values from Elasticsearch at {}. {:?}", - url, e - ); - exit(1); - } - }; + let (branch, suite, version, sem_version) = + match branch_suite_and_version_from_elasticsearch(url) { + Ok(v) => v, + Err(e) => { + error!( + "Problem getting values from Elasticsearch at {}. {:?}", + url, e + ); + exit(1); + } + }; - info!("Using version {}", &version.to_string()); + info!("Using version {}", &version); info!("Using branch {}", &branch); info!("Using test_suite {:?}", &suite); - let rest_specs_dir = PathBuf::from("./api_generator/rest_specs"); - - if !rest_specs_dir.exists() - || rest_specs_dir - .read_dir() - .map(|mut e| e.next().is_none()) - .unwrap_or_else(|_| true) - { - error!( - "No rest specs found at {}. Run api_generator project to download rest specs", - rest_specs_dir.to_str().unwrap() + let stack_version = std::env::var("STACK_VERSION").expect("Missing STACK_VERSION env var"); + + if version != stack_version { + bail!( + "ES server version {} is inconsistent with STACK_VERSION={}", + version, + stack_version ); - exit(1); } - let last_downloaded_rest_spec_branch = { - let mut p = rest_specs_dir.clone(); - p.push("last_downloaded_version"); - p - }; - - if !last_downloaded_rest_spec_branch.exists() { - error!( - "No last downloaded rest version found at {}.", - last_downloaded_rest_spec_branch.to_str().unwrap() - ); - exit(1); + let rest_specs_dir = PathBuf::from(format!("./checkout/{}/rest-api-spec/api", stack_version)); + if !rest_specs_dir.is_dir() { + bail!("No specs found at {:?}", rest_specs_dir); } - let rest_spec_version = fs::read_to_string(last_downloaded_rest_spec_branch)?; - info!("Using rest specs from {}", &rest_spec_version); - let download_dir = PathBuf::from(format!("./{}/yaml", env!("CARGO_PKG_NAME"))); + let download_dir = PathBuf::from(format!("./checkout/{}/rest-api-spec/test", stack_version)); let generated_dir = PathBuf::from(format!("./{}/tests", env!("CARGO_PKG_NAME"))); - github::download_test_suites(&branch, &download_dir)?; - - let api = api_generator::generator::read_api(&branch, &rest_specs_dir)?; + let api = api_generator::generator::read_api(&rest_specs_dir)?; // delete everything under the generated_dir except common dir if generated_dir.exists() { @@ -132,7 +115,7 @@ fn main() -> Result<(), failure::Error> { generator::generate_tests_from_yaml( &api, &suite, - &version, + &sem_version, &download_dir, &download_dir, &generated_dir, @@ -143,7 +126,7 @@ fn main() -> Result<(), failure::Error> { fn branch_suite_and_version_from_elasticsearch( url: &str, -) -> Result<(String, TestSuite, semver::Version), failure::Error> { +) -> Result<(String, TestSuite, String, semver::Version), failure::Error> { let client = reqwest::ClientBuilder::new() .danger_accept_invalid_certs(true) .build()?; @@ -161,10 +144,10 @@ fn branch_suite_and_version_from_elasticsearch( // a version with a prerelease to match against predicates, if at least one predicate // has a prerelease. See // https://github.com/steveklabnik/semver/blob/afa5fc853cb4d6d2b1329579e5528f86f3b550f9/src/version_req.rs#L319-L331 - let version = json["version"]["number"] - .as_str() - .unwrap() - .trim_end_matches(|c: char| c.is_alphabetic() || c == '-'); + let version = json["version"]["number"].as_str().unwrap().to_string(); + + let sem_version = + semver::Version::parse(version.trim_end_matches(|c: char| c.is_alphabetic() || c == '-'))?; - Ok((branch, suite, semver::Version::parse(version)?)) + Ok((branch, suite, version, sem_version)) } From 7750612407811902d40a90332aefc3285b0cb5b3 Mon Sep 17 00:00:00 2001 From: Sylvain Wallez Date: Wed, 1 Sep 2021 15:20:11 +0200 Subject: [PATCH 2/5] Updage generated client code --- elasticsearch/src/.generated.toml | 3 + elasticsearch/src/cat.rs | 9 + elasticsearch/src/cluster.rs | 4 +- elasticsearch/src/features.rs | 336 ++ elasticsearch/src/fleet.rs | 238 ++ elasticsearch/src/ilm.rs | 149 + elasticsearch/src/indices.rs | 380 +++ elasticsearch/src/ingest.rs | 125 + elasticsearch/src/lib.rs | 3 + elasticsearch/src/logstash.rs | 2 +- elasticsearch/src/ml.rs | 1797 +++++++++-- elasticsearch/src/nodes.rs | 288 ++ elasticsearch/src/params.rs | 12 +- elasticsearch/src/rollup.rs | 17 +- elasticsearch/src/root/mod.rs | 393 ++- elasticsearch/src/searchable_snapshots.rs | 142 +- elasticsearch/src/security.rs | 3385 ++++++++++++++++----- elasticsearch/src/shutdown.rs | 489 +++ elasticsearch/src/snapshot.rs | 261 +- elasticsearch/src/sql.rs | 417 ++- elasticsearch/src/text_structure.rs | 13 - elasticsearch/src/transform.rs | 35 +- 22 files changed, 7428 insertions(+), 1070 deletions(-) create mode 100644 elasticsearch/src/features.rs create mode 100644 elasticsearch/src/fleet.rs create mode 100644 elasticsearch/src/shutdown.rs diff --git a/elasticsearch/src/.generated.toml b/elasticsearch/src/.generated.toml index 06ea6570..19879bad 100644 --- a/elasticsearch/src/.generated.toml +++ b/elasticsearch/src/.generated.toml @@ -7,6 +7,8 @@ written = [ 'dangling_indices.rs', 'enrich.rs', 'eql.rs', + 'features.rs', + 'fleet.rs', 'graph.rs', 'ilm.rs', 'indices.rs', @@ -21,6 +23,7 @@ written = [ 'root/mod.rs', 'searchable_snapshots.rs', 'security.rs', + 'shutdown.rs', 'slm.rs', 'snapshot.rs', 'sql.rs', diff --git a/elasticsearch/src/cat.rs b/elasticsearch/src/cat.rs index 77c12cae..534ca791 100644 --- a/elasticsearch/src/cat.rs +++ b/elasticsearch/src/cat.rs @@ -2640,6 +2640,7 @@ pub struct CatNodes<'a, 'b> { headers: HeaderMap, help: Option, human: Option, + include_unloaded_segments: Option, master_timeout: Option<&'b str>, pretty: Option, request_timeout: Option, @@ -2666,6 +2667,7 @@ impl<'a, 'b> CatNodes<'a, 'b> { h: None, help: None, human: None, + include_unloaded_segments: None, master_timeout: None, pretty: None, request_timeout: None, @@ -2720,6 +2722,11 @@ impl<'a, 'b> CatNodes<'a, 'b> { self.human = Some(human); self } + #[doc = "If set to true segment stats will include stats for segments that are not currently loaded into memory"] + pub fn include_unloaded_segments(mut self, include_unloaded_segments: bool) -> Self { + self.include_unloaded_segments = Some(include_unloaded_segments); + self + } #[doc = "Explicit operation timeout for connection to master node"] pub fn master_timeout(mut self, master_timeout: &'b str) -> Self { self.master_timeout = Some(master_timeout); @@ -2775,6 +2782,7 @@ impl<'a, 'b> CatNodes<'a, 'b> { h: Option<&'b [&'b str]>, help: Option, human: Option, + include_unloaded_segments: Option, master_timeout: Option<&'b str>, pretty: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] @@ -2792,6 +2800,7 @@ impl<'a, 'b> CatNodes<'a, 'b> { h: self.h, help: self.help, human: self.human, + include_unloaded_segments: self.include_unloaded_segments, master_timeout: self.master_timeout, pretty: self.pretty, s: self.s, diff --git a/elasticsearch/src/cluster.rs b/elasticsearch/src/cluster.rs index f4bc45d5..e7d3b47f 100644 --- a/elasticsearch/src/cluster.rs +++ b/elasticsearch/src/cluster.rs @@ -753,7 +753,7 @@ impl ClusterGetSettingsParts { } } } -#[doc = "Builder for the [Cluster Get Settings API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/cluster-update-settings.html)\n\nReturns cluster settings."] +#[doc = "Builder for the [Cluster Get Settings API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/cluster-get-settings.html)\n\nReturns cluster settings."] #[derive(Clone, Debug)] pub struct ClusterGetSettings<'a, 'b> { transport: &'a Transport, @@ -2451,7 +2451,7 @@ impl<'a> Cluster<'a> { ) -> ClusterGetComponentTemplate<'a, 'b> { ClusterGetComponentTemplate::new(self.transport(), parts) } - #[doc = "[Cluster Get Settings API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/cluster-update-settings.html)\n\nReturns cluster settings."] + #[doc = "[Cluster Get Settings API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/cluster-get-settings.html)\n\nReturns cluster settings."] pub fn get_settings<'b>(&'a self) -> ClusterGetSettings<'a, 'b> { ClusterGetSettings::new(self.transport()) } diff --git a/elasticsearch/src/features.rs b/elasticsearch/src/features.rs new file mode 100644 index 00000000..0510e901 --- /dev/null +++ b/elasticsearch/src/features.rs @@ -0,0 +1,336 @@ +/* + * 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 +// ----------------------------------------------- + +//! Features APIs +//! +//! Allows [introspecting and managing features](https://www.elastic.co/guide/en/elasticsearch/reference/current/features-apis.html) provided by Elasticsearch and Elasticsearch plugins. + +#![allow(unused_imports)] +use crate::{ + client::Elasticsearch, + 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)] +#[doc = "API parts for the Features Get Features API"] +pub enum FeaturesGetFeaturesParts { + #[doc = "No parts"] + None, +} +impl FeaturesGetFeaturesParts { + #[doc = "Builds a relative URL path to the Features Get Features API"] + pub fn url(self) -> Cow<'static, str> { + match self { + FeaturesGetFeaturesParts::None => "/_features".into(), + } + } +} +#[doc = "Builder for the [Features Get Features API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/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"] +#[derive(Clone, Debug)] +pub struct FeaturesGetFeatures<'a, 'b> { + transport: &'a Transport, + parts: FeaturesGetFeaturesParts, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + master_timeout: Option<&'b str>, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> FeaturesGetFeatures<'a, 'b> { + #[doc = "Creates a new instance of [FeaturesGetFeatures]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + FeaturesGetFeatures { + transport, + parts: FeaturesGetFeaturesParts::None, + headers, + error_trace: None, + filter_path: None, + human: None, + master_timeout: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Explicit operation timeout for connection to master node"] + 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 = "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 = "Creates an asynchronous call to the Features Get Features 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]>, + human: Option, + master_timeout: Option<&'b str>, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + master_timeout: self.master_timeout, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = Option::<()>::None; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Features Reset Features API"] +pub enum FeaturesResetFeaturesParts { + #[doc = "No parts"] + None, +} +#[cfg(feature = "experimental-apis")] +impl FeaturesResetFeaturesParts { + #[doc = "Builds a relative URL path to the Features Reset Features API"] + pub fn url(self) -> Cow<'static, str> { + match self { + FeaturesResetFeaturesParts::None => "/_features/_reset".into(), + } + } +} +#[doc = "Builder for the [Features Reset Features API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nResets the internal state of features, usually by deleting system indices"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct FeaturesResetFeatures<'a, 'b, B> { + transport: &'a Transport, + parts: FeaturesResetFeaturesParts, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b, B> FeaturesResetFeatures<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [FeaturesResetFeatures]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + FeaturesResetFeatures { + transport, + parts: FeaturesResetFeaturesParts::None, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> FeaturesResetFeatures<'a, 'b, JsonBody> + where + T: Serialize, + { + FeaturesResetFeatures { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Features Reset Features API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[doc = "Namespace client for Features APIs"] +pub struct Features<'a> { + transport: &'a Transport, +} +impl<'a> Features<'a> { + #[doc = "Creates a new instance of [Features]"] + pub fn new(transport: &'a Transport) -> Self { + Self { transport } + } + pub fn transport(&self) -> &Transport { + self.transport + } + #[doc = "[Features Get Features API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/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"] + pub fn get_features<'b>(&'a self) -> FeaturesGetFeatures<'a, 'b> { + FeaturesGetFeatures::new(self.transport()) + } + #[doc = "[Features Reset Features API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nResets the internal state of features, usually by deleting system indices"] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn reset_features<'b>(&'a self) -> FeaturesResetFeatures<'a, 'b, ()> { + FeaturesResetFeatures::new(self.transport()) + } +} +impl Elasticsearch { + #[doc = "Creates a namespace client for Features APIs"] + pub fn features(&self) -> Features { + Features::new(self.transport()) + } +} diff --git a/elasticsearch/src/fleet.rs b/elasticsearch/src/fleet.rs new file mode 100644 index 00000000..2038203f --- /dev/null +++ b/elasticsearch/src/fleet.rs @@ -0,0 +1,238 @@ +/* + * 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 +// ----------------------------------------------- + +#![cfg(feature = "experimental-apis")] +#![doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#![allow(unused_imports)] +use crate::{ + client::Elasticsearch, + 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}; +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Fleet Global Checkpoints API"] +pub enum FleetGlobalCheckpointsParts<'b> { + #[doc = "Index"] + Index(&'b str), +} +#[cfg(feature = "experimental-apis")] +impl<'b> FleetGlobalCheckpointsParts<'b> { + #[doc = "Builds a relative URL path to the Fleet Global Checkpoints API"] + pub fn url(self) -> Cow<'static, str> { + match self { + FleetGlobalCheckpointsParts::Index(ref index) => { + let encoded_index: Cow = + percent_encode(index.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(27usize + encoded_index.len()); + p.push_str("/"); + p.push_str(encoded_index.as_ref()); + p.push_str("/_fleet/global_checkpoints"); + p.into() + } + } + } +} +#[doc = "Builder for the Fleet Global Checkpoints API\n\nReturns the current global checkpoints for an index. This API is design for internal use by the fleet server project."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct FleetGlobalCheckpoints<'a, 'b> { + transport: &'a Transport, + parts: FleetGlobalCheckpointsParts<'b>, + checkpoints: Option<&'b [&'b str]>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, + timeout: Option<&'b str>, + wait_for_advance: Option, + wait_for_index: Option, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b> FleetGlobalCheckpoints<'a, 'b> { + #[doc = "Creates a new instance of [FleetGlobalCheckpoints] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: FleetGlobalCheckpointsParts<'b>) -> Self { + let headers = HeaderMap::new(); + FleetGlobalCheckpoints { + transport, + parts, + headers, + checkpoints: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + timeout: None, + wait_for_advance: None, + wait_for_index: None, + } + } + #[doc = "Comma separated list of checkpoints"] + pub fn checkpoints(mut self, checkpoints: &'b [&'b str]) -> Self { + self.checkpoints = Some(checkpoints); + 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Timeout to wait for global checkpoint to advance"] + pub fn timeout(mut self, timeout: &'b str) -> Self { + self.timeout = Some(timeout); + self + } + #[doc = "Whether to wait for the global checkpoint to advance past the specified current checkpoints"] + pub fn wait_for_advance(mut self, wait_for_advance: bool) -> Self { + self.wait_for_advance = Some(wait_for_advance); + self + } + #[doc = "Whether to wait for the target index to exist and all primary shards be active"] + pub fn wait_for_index(mut self, wait_for_index: bool) -> Self { + self.wait_for_index = Some(wait_for_index); + self + } + #[doc = "Creates an asynchronous call to the Fleet Global Checkpoints 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> { + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + checkpoints: Option<&'b [&'b str]>, + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + timeout: Option<&'b str>, + wait_for_advance: Option, + wait_for_index: Option, + } + let query_params = QueryParams { + checkpoints: self.checkpoints, + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + timeout: self.timeout, + wait_for_advance: self.wait_for_advance, + wait_for_index: self.wait_for_index, + }; + Some(query_params) + }; + let body = Option::<()>::None; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[doc = "Namespace client for Fleet APIs"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +pub struct Fleet<'a> { + transport: &'a Transport, +} +#[cfg(feature = "experimental-apis")] +impl<'a> Fleet<'a> { + #[doc = "Creates a new instance of [Fleet]"] + pub fn new(transport: &'a Transport) -> Self { + Self { transport } + } + pub fn transport(&self) -> &Transport { + self.transport + } + #[doc = "Fleet Global Checkpoints API\n\nReturns the current global checkpoints for an index. This API is design for internal use by the fleet server project."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn global_checkpoints<'b>( + &'a self, + parts: FleetGlobalCheckpointsParts<'b>, + ) -> FleetGlobalCheckpoints<'a, 'b> { + FleetGlobalCheckpoints::new(self.transport(), parts) + } +} +#[cfg(feature = "experimental-apis")] +impl Elasticsearch { + #[doc = "Creates a namespace client for Fleet APIs"] + pub fn fleet(&self) -> Fleet { + Fleet::new(self.transport()) + } +} diff --git a/elasticsearch/src/ilm.rs b/elasticsearch/src/ilm.rs index a5ee95f6..f03b3a89 100644 --- a/elasticsearch/src/ilm.rs +++ b/elasticsearch/src/ilm.rs @@ -542,6 +542,151 @@ impl<'a, 'b> IlmGetStatus<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ilm Migrate To Data Tiers API"] +pub enum IlmMigrateToDataTiersParts { + #[doc = "No parts"] + None, +} +impl IlmMigrateToDataTiersParts { + #[doc = "Builds a relative URL path to the Ilm Migrate To Data Tiers API"] + pub fn url(self) -> Cow<'static, str> { + match self { + IlmMigrateToDataTiersParts::None => "/_ilm/migrate_to_data_tiers".into(), + } + } +} +#[doc = "Builder for the [Ilm Migrate To Data Tiers API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ilm-migrate-to-data-tiers.html)\n\nMigrates the indices and ILM policies away from custom node attribute allocation routing to data tiers routing"] +#[derive(Clone, Debug)] +pub struct IlmMigrateToDataTiers<'a, 'b, B> { + transport: &'a Transport, + parts: IlmMigrateToDataTiersParts, + body: Option, + dry_run: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> IlmMigrateToDataTiers<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [IlmMigrateToDataTiers]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + IlmMigrateToDataTiers { + transport, + parts: IlmMigrateToDataTiersParts::None, + headers, + body: None, + dry_run: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> IlmMigrateToDataTiers<'a, 'b, JsonBody> + where + T: Serialize, + { + IlmMigrateToDataTiers { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + dry_run: self.dry_run, + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[doc = "If set to true it will simulate the migration, providing a way to retrieve the ILM policies and indices that need to be migrated. The default is false"] + pub fn dry_run(mut self, dry_run: bool) -> Self { + self.dry_run = Some(dry_run); + 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Ilm Migrate To Data Tiers API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + let headers = self.headers; + let timeout = self.request_timeout; + let query_string = { + #[serde_with::skip_serializing_none] + #[derive(Serialize)] + struct QueryParams<'b> { + dry_run: Option, + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + dry_run: self.dry_run, + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ilm Move To Step API"] pub enum IlmMoveToStepParts<'b> { #[doc = "Index"] @@ -1415,6 +1560,10 @@ impl<'a> Ilm<'a> { pub fn get_status<'b>(&'a self) -> IlmGetStatus<'a, 'b> { IlmGetStatus::new(self.transport()) } + #[doc = "[Ilm Migrate To Data Tiers API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ilm-migrate-to-data-tiers.html)\n\nMigrates the indices and ILM policies away from custom node attribute allocation routing to data tiers routing"] + pub fn migrate_to_data_tiers<'b>(&'a self) -> IlmMigrateToDataTiers<'a, 'b, ()> { + IlmMigrateToDataTiers::new(self.transport()) + } #[doc = "[Ilm Move To Step API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ilm-move-to-step.html)\n\nManually moves an index into the specified step and executes that step."] pub fn move_to_step<'b>(&'a self, parts: IlmMoveToStepParts<'b>) -> IlmMoveToStep<'a, 'b, ()> { IlmMoveToStep::new(self.transport(), parts) diff --git a/elasticsearch/src/indices.rs b/elasticsearch/src/indices.rs index 048b39ca..59938d7d 100644 --- a/elasticsearch/src/indices.rs +++ b/elasticsearch/src/indices.rs @@ -2164,6 +2164,205 @@ impl<'a, 'b> IndicesDeleteTemplate<'a, 'b> { Ok(response) } } +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Indices Disk Usage API"] +pub enum IndicesDiskUsageParts<'b> { + #[doc = "Index"] + Index(&'b str), +} +#[cfg(feature = "experimental-apis")] +impl<'b> IndicesDiskUsageParts<'b> { + #[doc = "Builds a relative URL path to the Indices Disk Usage API"] + pub fn url(self) -> Cow<'static, str> { + match self { + IndicesDiskUsageParts::Index(ref index) => { + let encoded_index: Cow = + percent_encode(index.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(13usize + encoded_index.len()); + p.push_str("/"); + p.push_str(encoded_index.as_ref()); + p.push_str("/_disk_usage"); + p.into() + } + } + } +} +#[doc = "Builder for the [Indices Disk Usage API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/indices-disk-usage.html)\n\nAnalyzes the disk usage of each field of an index or data stream"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct IndicesDiskUsage<'a, 'b, B> { + transport: &'a Transport, + parts: IndicesDiskUsageParts<'b>, + allow_no_indices: Option, + body: Option, + error_trace: Option, + expand_wildcards: Option<&'b [ExpandWildcards]>, + filter_path: Option<&'b [&'b str]>, + flush: Option, + headers: HeaderMap, + human: Option, + ignore_unavailable: Option, + pretty: Option, + request_timeout: Option, + run_expensive_tasks: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b, B> IndicesDiskUsage<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [IndicesDiskUsage] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: IndicesDiskUsageParts<'b>) -> Self { + let headers = HeaderMap::new(); + IndicesDiskUsage { + transport, + parts, + headers, + allow_no_indices: None, + body: None, + error_trace: None, + expand_wildcards: None, + filter_path: None, + flush: None, + human: None, + ignore_unavailable: None, + pretty: None, + request_timeout: None, + run_expensive_tasks: None, + source: None, + } + } + #[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)"] + pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self { + self.allow_no_indices = Some(allow_no_indices); + self + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> IndicesDiskUsage<'a, 'b, JsonBody> + where + T: Serialize, + { + IndicesDiskUsage { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + allow_no_indices: self.allow_no_indices, + error_trace: self.error_trace, + expand_wildcards: self.expand_wildcards, + filter_path: self.filter_path, + flush: self.flush, + headers: self.headers, + human: self.human, + ignore_unavailable: self.ignore_unavailable, + pretty: self.pretty, + request_timeout: self.request_timeout, + run_expensive_tasks: self.run_expensive_tasks, + source: self.source, + } + } + #[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 = "Whether flush or not before analyzing the index disk usage. Defaults to true"] + pub fn flush(mut self, flush: bool) -> Self { + self.flush = Some(flush); + self + } + #[doc = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"] + pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self { + self.ignore_unavailable = Some(ignore_unavailable); + 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 = "Must be set to [true] in order for the task to be performed. Defaults to false."] + pub fn run_expensive_tasks(mut self, run_expensive_tasks: bool) -> Self { + self.run_expensive_tasks = Some(run_expensive_tasks); + 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 = "Creates an asynchronous call to the Indices Disk Usage API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + let headers = self.headers; + let timeout = self.request_timeout; + let query_string = { + #[serde_with::skip_serializing_none] + #[derive(Serialize)] + struct QueryParams<'b> { + allow_no_indices: Option, + 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]>, + flush: Option, + human: Option, + ignore_unavailable: Option, + pretty: Option, + run_expensive_tasks: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + allow_no_indices: self.allow_no_indices, + error_trace: self.error_trace, + expand_wildcards: self.expand_wildcards, + filter_path: self.filter_path, + flush: self.flush, + human: self.human, + ignore_unavailable: self.ignore_unavailable, + pretty: self.pretty, + run_expensive_tasks: self.run_expensive_tasks, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Indices Exists API"] pub enum IndicesExistsParts<'b> { @@ -2966,6 +3165,169 @@ impl<'a, 'b> IndicesExistsType<'a, 'b> { Ok(response) } } +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Indices Field Usage Stats API"] +pub enum IndicesFieldUsageStatsParts<'b> { + #[doc = "Index"] + Index(&'b str), +} +#[cfg(feature = "experimental-apis")] +impl<'b> IndicesFieldUsageStatsParts<'b> { + #[doc = "Builds a relative URL path to the Indices Field Usage Stats API"] + pub fn url(self) -> Cow<'static, str> { + match self { + IndicesFieldUsageStatsParts::Index(ref index) => { + let encoded_index: Cow = + percent_encode(index.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(20usize + encoded_index.len()); + p.push_str("/"); + p.push_str(encoded_index.as_ref()); + p.push_str("/_field_usage_stats"); + p.into() + } + } + } +} +#[doc = "Builder for the [Indices Field Usage Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/field-usage-stats.html)\n\nReturns the field usage stats for each field of an index"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct IndicesFieldUsageStats<'a, 'b> { + transport: &'a Transport, + parts: IndicesFieldUsageStatsParts<'b>, + allow_no_indices: Option, + error_trace: Option, + expand_wildcards: Option<&'b [ExpandWildcards]>, + fields: Option<&'b [&'b str]>, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + ignore_unavailable: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b> IndicesFieldUsageStats<'a, 'b> { + #[doc = "Creates a new instance of [IndicesFieldUsageStats] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: IndicesFieldUsageStatsParts<'b>) -> Self { + let headers = HeaderMap::new(); + IndicesFieldUsageStats { + transport, + parts, + headers, + allow_no_indices: None, + error_trace: None, + expand_wildcards: None, + fields: None, + filter_path: None, + human: None, + ignore_unavailable: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[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)"] + pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self { + self.allow_no_indices = Some(allow_no_indices); + 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 = "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 fields to include in the stats if only a subset of fields should be returned (supports wildcards)"] + 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"] + pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self { + self.ignore_unavailable = Some(ignore_unavailable); + 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 = "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 = "Creates an asynchronous call to the Indices Field Usage Stats 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> { + allow_no_indices: Option, + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + expand_wildcards: Option<&'b [ExpandWildcards]>, + #[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]>, + human: Option, + ignore_unavailable: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + allow_no_indices: self.allow_no_indices, + error_trace: self.error_trace, + expand_wildcards: self.expand_wildcards, + fields: self.fields, + filter_path: self.filter_path, + human: self.human, + ignore_unavailable: self.ignore_unavailable, + pretty: self.pretty, + source: self.source, + }; + 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)] #[doc = "API parts for the Indices Flush API"] pub enum IndicesFlushParts<'b> { @@ -9208,6 +9570,15 @@ impl<'a> Indices<'a> { ) -> IndicesDeleteTemplate<'a, 'b> { IndicesDeleteTemplate::new(self.transport(), parts) } + #[doc = "[Indices Disk Usage API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/indices-disk-usage.html)\n\nAnalyzes the disk usage of each field of an index or data stream"] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn disk_usage<'b>( + &'a self, + parts: IndicesDiskUsageParts<'b>, + ) -> IndicesDiskUsage<'a, 'b, ()> { + IndicesDiskUsage::new(self.transport(), parts) + } #[doc = "[Indices Exists API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/indices-exists.html)\n\nReturns information about whether a particular index exists."] pub fn exists<'b>(&'a self, parts: IndicesExistsParts<'b>) -> IndicesExists<'a, 'b> { IndicesExists::new(self.transport(), parts) @@ -9240,6 +9611,15 @@ impl<'a> Indices<'a> { ) -> IndicesExistsType<'a, 'b> { IndicesExistsType::new(self.transport(), parts) } + #[doc = "[Indices Field Usage Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/field-usage-stats.html)\n\nReturns the field usage stats for each field of an index"] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn field_usage_stats<'b>( + &'a self, + parts: IndicesFieldUsageStatsParts<'b>, + ) -> IndicesFieldUsageStats<'a, 'b> { + IndicesFieldUsageStats::new(self.transport(), parts) + } #[doc = "[Indices Flush API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/indices-flush.html)\n\nPerforms the flush operation on one or more indices."] pub fn flush<'b>(&'a self, parts: IndicesFlushParts<'b>) -> IndicesFlush<'a, 'b, ()> { IndicesFlush::new(self.transport(), parts) diff --git a/elasticsearch/src/ingest.rs b/elasticsearch/src/ingest.rs index b226bb54..277e0f4b 100644 --- a/elasticsearch/src/ingest.rs +++ b/elasticsearch/src/ingest.rs @@ -195,6 +195,118 @@ impl<'a, 'b> IngestDeletePipeline<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ingest Geo Ip Stats API"] +pub enum IngestGeoIpStatsParts { + #[doc = "No parts"] + None, +} +impl IngestGeoIpStatsParts { + #[doc = "Builds a relative URL path to the Ingest Geo Ip Stats API"] + pub fn url(self) -> Cow<'static, str> { + match self { + IngestGeoIpStatsParts::None => "/_ingest/geoip/stats".into(), + } + } +} +#[doc = "Builder for the [Ingest Geo Ip Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/geoip-stats-api.html)\n\nReturns statistical information about geoip databases"] +#[derive(Clone, Debug)] +pub struct IngestGeoIpStats<'a, 'b> { + transport: &'a Transport, + parts: IngestGeoIpStatsParts, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> IngestGeoIpStats<'a, 'b> { + #[doc = "Creates a new instance of [IngestGeoIpStats]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + IngestGeoIpStats { + transport, + parts: IngestGeoIpStatsParts::None, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Ingest Geo Ip Stats 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] #[doc = "API parts for the Ingest Get Pipeline API"] pub enum IngestGetPipelineParts<'b> { #[doc = "No parts"] @@ -230,6 +342,7 @@ pub struct IngestGetPipeline<'a, 'b> { pretty: Option, request_timeout: Option, source: Option<&'b str>, + summary: Option, } impl<'a, 'b> IngestGetPipeline<'a, 'b> { #[doc = "Creates a new instance of [IngestGetPipeline] with the specified API parts"] @@ -246,6 +359,7 @@ impl<'a, 'b> IngestGetPipeline<'a, 'b> { pretty: None, request_timeout: None, source: None, + summary: None, } } #[doc = "Include the stack trace of returned errors."] @@ -288,6 +402,11 @@ impl<'a, 'b> IngestGetPipeline<'a, 'b> { self.source = Some(source); self } + #[doc = "Return pipelines without their definitions (default: false)"] + pub fn summary(mut self, summary: bool) -> Self { + self.summary = Some(summary); + self + } #[doc = "Creates an asynchronous call to the Ingest Get Pipeline API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); @@ -305,6 +424,7 @@ impl<'a, 'b> IngestGetPipeline<'a, 'b> { master_timeout: Option<&'b str>, pretty: Option, source: Option<&'b str>, + summary: Option, } let query_params = QueryParams { error_trace: self.error_trace, @@ -313,6 +433,7 @@ impl<'a, 'b> IngestGetPipeline<'a, 'b> { master_timeout: self.master_timeout, pretty: self.pretty, source: self.source, + summary: self.summary, }; Some(query_params) }; @@ -774,6 +895,10 @@ impl<'a> Ingest<'a> { ) -> IngestDeletePipeline<'a, 'b> { IngestDeletePipeline::new(self.transport(), parts) } + #[doc = "[Ingest Geo Ip Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/geoip-stats-api.html)\n\nReturns statistical information about geoip databases"] + pub fn geo_ip_stats<'b>(&'a self) -> IngestGeoIpStats<'a, 'b> { + IngestGeoIpStats::new(self.transport()) + } #[doc = "[Ingest Get Pipeline API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-pipeline-api.html)\n\nReturns a pipeline."] pub fn get_pipeline<'b>( &'a self, diff --git a/elasticsearch/src/lib.rs b/elasticsearch/src/lib.rs index 3810037d..99bf3f8c 100644 --- a/elasticsearch/src/lib.rs +++ b/elasticsearch/src/lib.rs @@ -385,6 +385,8 @@ pub mod cluster; pub mod dangling_indices; pub mod enrich; pub mod eql; +pub mod features; +pub mod fleet; pub mod graph; pub mod ilm; pub mod indices; @@ -398,6 +400,7 @@ pub mod nodes; pub mod rollup; pub mod searchable_snapshots; pub mod security; +pub mod shutdown; pub mod slm; pub mod snapshot; pub mod sql; diff --git a/elasticsearch/src/logstash.rs b/elasticsearch/src/logstash.rs index 9aa82d28..2dbc03b1 100644 --- a/elasticsearch/src/logstash.rs +++ b/elasticsearch/src/logstash.rs @@ -27,7 +27,7 @@ //! Logstash APIs //! //! The [Logstash APIs](https://www.elastic.co/guide/en/elasticsearch/reference/master/logstash-apis.html) are used to -//! manage Pipelines used by Logstash Central Management. +//! manage pipelines used by Logstash Central Management. #![allow(unused_imports)] use crate::{ diff --git a/elasticsearch/src/ml.rs b/elasticsearch/src/ml.rs index 9c75ecf4..cc77b27d 100644 --- a/elasticsearch/src/ml.rs +++ b/elasticsearch/src/ml.rs @@ -596,14 +596,12 @@ impl<'a, 'b> MlDeleteCalendarJob<'a, 'b> { Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Delete Data Frame Analytics API"] pub enum MlDeleteDataFrameAnalyticsParts<'b> { #[doc = "Id"] Id(&'b str), } -#[cfg(feature = "beta-apis")] impl<'b> MlDeleteDataFrameAnalyticsParts<'b> { #[doc = "Builds a relative URL path to the Ml Delete Data Frame Analytics API"] pub fn url(self) -> Cow<'static, str> { @@ -619,8 +617,6 @@ impl<'b> MlDeleteDataFrameAnalyticsParts<'b> { } } #[doc = "Builder for the [Ml Delete Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/delete-dfanalytics.html)\n\nDeletes an existing data frame analytics job."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlDeleteDataFrameAnalytics<'a, 'b> { transport: &'a Transport, @@ -635,7 +631,6 @@ pub struct MlDeleteDataFrameAnalytics<'a, 'b> { source: Option<&'b str>, timeout: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b> MlDeleteDataFrameAnalytics<'a, 'b> { #[doc = "Creates a new instance of [MlDeleteDataFrameAnalytics] with the specified API parts"] pub fn new(transport: &'a Transport, parts: MlDeleteDataFrameAnalyticsParts<'b>) -> Self { @@ -1565,14 +1560,12 @@ impl<'a, 'b> MlDeleteModelSnapshot<'a, 'b> { Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Delete Trained Model API"] pub enum MlDeleteTrainedModelParts<'b> { #[doc = "ModelId"] ModelId(&'b str), } -#[cfg(feature = "beta-apis")] impl<'b> MlDeleteTrainedModelParts<'b> { #[doc = "Builds a relative URL path to the Ml Delete Trained Model API"] pub fn url(self) -> Cow<'static, str> { @@ -1589,8 +1582,6 @@ impl<'b> MlDeleteTrainedModelParts<'b> { } } #[doc = "Builder for the [Ml Delete Trained Model API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/delete-trained-models.html)\n\nDeletes an existing trained inference model that is currently not referenced by an ingest pipeline."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlDeleteTrainedModel<'a, 'b> { transport: &'a Transport, @@ -1603,7 +1594,6 @@ pub struct MlDeleteTrainedModel<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b> MlDeleteTrainedModel<'a, 'b> { #[doc = "Creates a new instance of [MlDeleteTrainedModel] with the specified API parts"] pub fn new(transport: &'a Transport, parts: MlDeleteTrainedModelParts<'b>) -> Self { @@ -1690,6 +1680,131 @@ impl<'a, 'b> MlDeleteTrainedModel<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ml Delete Trained Model Alias API"] +pub enum MlDeleteTrainedModelAliasParts<'b> { + #[doc = "ModelId and ModelAlias"] + ModelIdModelAlias(&'b str, &'b str), +} +impl<'b> MlDeleteTrainedModelAliasParts<'b> { + #[doc = "Builds a relative URL path to the Ml Delete Trained Model Alias API"] + pub fn url(self) -> Cow<'static, str> { + match self { + MlDeleteTrainedModelAliasParts::ModelIdModelAlias(ref model_id, ref model_alias) => { + let encoded_model_id: Cow = + percent_encode(model_id.as_bytes(), PARTS_ENCODED).into(); + let encoded_model_alias: Cow = + percent_encode(model_alias.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 35usize + encoded_model_id.len() + encoded_model_alias.len(), + ); + p.push_str("/_ml/trained_models/"); + p.push_str(encoded_model_id.as_ref()); + p.push_str("/model_aliases/"); + p.push_str(encoded_model_alias.as_ref()); + p.into() + } + } + } +} +#[doc = "Builder for the [Ml Delete Trained Model Alias API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/delete-trained-models-aliases.html)\n\nDeletes a model alias that refers to the trained model"] +#[derive(Clone, Debug)] +pub struct MlDeleteTrainedModelAlias<'a, 'b> { + transport: &'a Transport, + parts: MlDeleteTrainedModelAliasParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> MlDeleteTrainedModelAlias<'a, 'b> { + #[doc = "Creates a new instance of [MlDeleteTrainedModelAlias] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlDeleteTrainedModelAliasParts<'b>) -> Self { + let headers = HeaderMap::new(); + MlDeleteTrainedModelAlias { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Ml Delete Trained Model Alias API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Delete; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] #[doc = "API parts for the Ml Estimate Model Memory API"] pub enum MlEstimateModelMemoryParts { #[doc = "No parts"] @@ -1826,14 +1941,12 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Evaluate Data Frame API"] pub enum MlEvaluateDataFrameParts { #[doc = "No parts"] None, } -#[cfg(feature = "beta-apis")] impl MlEvaluateDataFrameParts { #[doc = "Builds a relative URL path to the Ml Evaluate Data Frame API"] pub fn url(self) -> Cow<'static, str> { @@ -1843,8 +1956,6 @@ impl MlEvaluateDataFrameParts { } } #[doc = "Builder for the [Ml Evaluate Data Frame API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/evaluate-dfanalytics.html)\n\nEvaluates the data frame analytics for an annotated index."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlEvaluateDataFrame<'a, 'b, B> { transport: &'a Transport, @@ -1858,7 +1969,6 @@ pub struct MlEvaluateDataFrame<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b, B> MlEvaluateDataFrame<'a, 'b, B> where B: Body, @@ -1966,7 +2076,6 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Explain Data Frame Analytics API"] pub enum MlExplainDataFrameAnalyticsParts<'b> { @@ -1975,7 +2084,6 @@ pub enum MlExplainDataFrameAnalyticsParts<'b> { #[doc = "Id"] Id(&'b str), } -#[cfg(feature = "beta-apis")] impl<'b> MlExplainDataFrameAnalyticsParts<'b> { #[doc = "Builds a relative URL path to the Ml Explain Data Frame Analytics API"] pub fn url(self) -> Cow<'static, str> { @@ -1993,8 +2101,6 @@ impl<'b> MlExplainDataFrameAnalyticsParts<'b> { } } #[doc = "Builder for the [Ml Explain Data Frame Analytics API](http://www.elastic.co/guide/en/elasticsearch/reference/8.0/explain-dfanalytics.html)\n\nExplains a data frame analytics config."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlExplainDataFrameAnalytics<'a, 'b, B> { transport: &'a Transport, @@ -2008,7 +2114,6 @@ pub struct MlExplainDataFrameAnalytics<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b, B> MlExplainDataFrameAnalytics<'a, 'b, B> where B: Body, @@ -3262,7 +3367,6 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Get Data Frame Analytics API"] pub enum MlGetDataFrameAnalyticsParts<'b> { @@ -3271,7 +3375,6 @@ pub enum MlGetDataFrameAnalyticsParts<'b> { #[doc = "No parts"] None, } -#[cfg(feature = "beta-apis")] impl<'b> MlGetDataFrameAnalyticsParts<'b> { #[doc = "Builds a relative URL path to the Ml Get Data Frame Analytics API"] pub fn url(self) -> Cow<'static, str> { @@ -3288,8 +3391,6 @@ impl<'b> MlGetDataFrameAnalyticsParts<'b> { } } #[doc = "Builder for the [Ml Get Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-dfanalytics.html)\n\nRetrieves configuration information for data frame analytics jobs."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlGetDataFrameAnalytics<'a, 'b> { transport: &'a Transport, @@ -3306,7 +3407,6 @@ pub struct MlGetDataFrameAnalytics<'a, 'b> { size: Option, source: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b> MlGetDataFrameAnalytics<'a, 'b> { #[doc = "Creates a new instance of [MlGetDataFrameAnalytics] with the specified API parts"] pub fn new(transport: &'a Transport, parts: MlGetDataFrameAnalyticsParts<'b>) -> Self { @@ -3424,7 +3524,6 @@ impl<'a, 'b> MlGetDataFrameAnalytics<'a, 'b> { Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Get Data Frame Analytics Stats API"] pub enum MlGetDataFrameAnalyticsStatsParts<'b> { @@ -3433,7 +3532,6 @@ pub enum MlGetDataFrameAnalyticsStatsParts<'b> { #[doc = "Id"] Id(&'b str), } -#[cfg(feature = "beta-apis")] impl<'b> MlGetDataFrameAnalyticsStatsParts<'b> { #[doc = "Builds a relative URL path to the Ml Get Data Frame Analytics Stats API"] pub fn url(self) -> Cow<'static, str> { @@ -3451,8 +3549,6 @@ impl<'b> MlGetDataFrameAnalyticsStatsParts<'b> { } } #[doc = "Builder for the [Ml Get Data Frame Analytics Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-dfanalytics-stats.html)\n\nRetrieves usage information for data frame analytics jobs."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlGetDataFrameAnalyticsStats<'a, 'b> { transport: &'a Transport, @@ -3469,7 +3565,6 @@ pub struct MlGetDataFrameAnalyticsStats<'a, 'b> { source: Option<&'b str>, verbose: Option, } -#[cfg(feature = "beta-apis")] impl<'a, 'b> MlGetDataFrameAnalyticsStats<'a, 'b> { #[doc = "Creates a new instance of [MlGetDataFrameAnalyticsStats] with the specified API parts"] pub fn new(transport: &'a Transport, parts: MlGetDataFrameAnalyticsStatsParts<'b>) -> Self { @@ -5207,7 +5302,131 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ml Get Trained Model Deployment Stats API"] +pub enum MlGetTrainedModelDeploymentStatsParts<'b> { + #[doc = "ModelId"] + ModelId(&'b str), +} +#[cfg(feature = "experimental-apis")] +impl<'b> MlGetTrainedModelDeploymentStatsParts<'b> { + #[doc = "Builds a relative URL path to the Ml Get Trained Model Deployment Stats API"] + pub fn url(self) -> Cow<'static, str> { + match self { + MlGetTrainedModelDeploymentStatsParts::ModelId(ref model_id) => { + let encoded_model_id: Cow = + percent_encode(model_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(38usize + encoded_model_id.len()); + p.push_str("/_ml/trained_models/"); + p.push_str(encoded_model_id.as_ref()); + p.push_str("/deployment/_stats"); + p.into() + } + } + } +} +#[doc = "Builder for the [Ml Get Trained Model Deployment Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-get-trained-model-deployment-stats.html)\n\nGet information about trained model deployments."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct MlGetTrainedModelDeploymentStats<'a, 'b> { + transport: &'a Transport, + parts: MlGetTrainedModelDeploymentStatsParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b> MlGetTrainedModelDeploymentStats<'a, 'b> { + #[doc = "Creates a new instance of [MlGetTrainedModelDeploymentStats] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlGetTrainedModelDeploymentStatsParts<'b>) -> Self { + let headers = HeaderMap::new(); + MlGetTrainedModelDeploymentStats { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Ml Get Trained Model Deployment Stats 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] #[doc = "API parts for the Ml Get Trained Models API"] pub enum MlGetTrainedModelsParts<'b> { @@ -5216,7 +5435,6 @@ pub enum MlGetTrainedModelsParts<'b> { #[doc = "No parts"] None, } -#[cfg(feature = "beta-apis")] impl<'b> MlGetTrainedModelsParts<'b> { #[doc = "Builds a relative URL path to the Ml Get Trained Models API"] pub fn url(self) -> Cow<'static, str> { @@ -5234,8 +5452,6 @@ impl<'b> MlGetTrainedModelsParts<'b> { } } #[doc = "Builder for the [Ml Get Trained Models API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-trained-models.html)\n\nRetrieves configuration information for a trained inference model."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlGetTrainedModels<'a, 'b> { transport: &'a Transport, @@ -5256,7 +5472,6 @@ pub struct MlGetTrainedModels<'a, 'b> { source: Option<&'b str>, tags: Option<&'b [&'b str]>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b> MlGetTrainedModels<'a, 'b> { #[doc = "Creates a new instance of [MlGetTrainedModels] with the specified API parts"] pub fn new(transport: &'a Transport, parts: MlGetTrainedModelsParts<'b>) -> Self { @@ -5407,7 +5622,6 @@ impl<'a, 'b> MlGetTrainedModels<'a, 'b> { Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Get Trained Models Stats API"] pub enum MlGetTrainedModelsStatsParts<'b> { @@ -5416,7 +5630,6 @@ pub enum MlGetTrainedModelsStatsParts<'b> { #[doc = "No parts"] None, } -#[cfg(feature = "beta-apis")] impl<'b> MlGetTrainedModelsStatsParts<'b> { #[doc = "Builds a relative URL path to the Ml Get Trained Models Stats API"] pub fn url(self) -> Cow<'static, str> { @@ -5435,8 +5648,6 @@ impl<'b> MlGetTrainedModelsStatsParts<'b> { } } #[doc = "Builder for the [Ml Get Trained Models Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-trained-models-stats.html)\n\nRetrieves usage information for trained inference models."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlGetTrainedModelsStats<'a, 'b> { transport: &'a Transport, @@ -5452,7 +5663,6 @@ pub struct MlGetTrainedModelsStats<'a, 'b> { size: Option, source: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b> MlGetTrainedModelsStats<'a, 'b> { #[doc = "Creates a new instance of [MlGetTrainedModelsStats] with the specified API parts"] pub fn new(transport: &'a Transport, parts: MlGetTrainedModelsStatsParts<'b>) -> Self { @@ -5562,25 +5772,38 @@ impl<'a, 'b> MlGetTrainedModelsStats<'a, 'b> { Ok(response) } } +#[cfg(feature = "experimental-apis")] #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Ml Info API"] -pub enum MlInfoParts { - #[doc = "No parts"] - None, +#[doc = "API parts for the Ml Infer Trained Model Deployment API"] +pub enum MlInferTrainedModelDeploymentParts<'b> { + #[doc = "ModelId"] + ModelId(&'b str), } -impl MlInfoParts { - #[doc = "Builds a relative URL path to the Ml Info API"] +#[cfg(feature = "experimental-apis")] +impl<'b> MlInferTrainedModelDeploymentParts<'b> { + #[doc = "Builds a relative URL path to the Ml Infer Trained Model Deployment API"] pub fn url(self) -> Cow<'static, str> { match self { - MlInfoParts::None => "/_ml/info".into(), + MlInferTrainedModelDeploymentParts::ModelId(ref model_id) => { + let encoded_model_id: Cow = + percent_encode(model_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(38usize + encoded_model_id.len()); + p.push_str("/_ml/trained_models/"); + p.push_str(encoded_model_id.as_ref()); + p.push_str("/deployment/_infer"); + p.into() + } } } } -#[doc = "Builder for the [Ml Info API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-ml-info.html)\n\nReturns defaults and limits used by machine learning."] +#[doc = "Builder for the [Ml Infer Trained Model Deployment API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/infer-trained-model-deployment.html)\n\nEvaluate a trained model."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] #[derive(Clone, Debug)] -pub struct MlInfo<'a, 'b> { +pub struct MlInferTrainedModelDeployment<'a, 'b, B> { transport: &'a Transport, - parts: MlInfoParts, + parts: MlInferTrainedModelDeploymentParts<'b>, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -5588,38 +5811,183 @@ pub struct MlInfo<'a, 'b> { pretty: Option, request_timeout: Option, source: Option<&'b str>, + timeout: Option<&'b str>, } -impl<'a, 'b> MlInfo<'a, 'b> { - #[doc = "Creates a new instance of [MlInfo]"] - pub fn new(transport: &'a Transport) -> Self { +#[cfg(feature = "experimental-apis")] +impl<'a, 'b, B> MlInferTrainedModelDeployment<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [MlInferTrainedModelDeployment] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlInferTrainedModelDeploymentParts<'b>) -> Self { let headers = HeaderMap::new(); - MlInfo { + MlInferTrainedModelDeployment { transport, - parts: MlInfoParts::None, + parts, headers, + body: None, error_trace: None, filter_path: None, human: None, pretty: None, request_timeout: None, source: None, + timeout: 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 = "Adds a HTTP header"] - pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { - self.headers.insert(key, value); - self - } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> MlInferTrainedModelDeployment<'a, 'b, JsonBody> + where + T: Serialize, + { + MlInferTrainedModelDeployment { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + timeout: self.timeout, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Controls the amount of time to wait for inference results."] + pub fn timeout(mut self, timeout: &'b str) -> Self { + self.timeout = Some(timeout); + self + } + #[doc = "Creates an asynchronous call to the Ml Infer Trained Model Deployment API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + timeout: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + timeout: self.timeout, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ml Info API"] +pub enum MlInfoParts { + #[doc = "No parts"] + None, +} +impl MlInfoParts { + #[doc = "Builds a relative URL path to the Ml Info API"] + pub fn url(self) -> Cow<'static, str> { + match self { + MlInfoParts::None => "/_ml/info".into(), + } + } +} +#[doc = "Builder for the [Ml Info API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-ml-info.html)\n\nReturns defaults and limits used by machine learning."] +#[derive(Clone, Debug)] +pub struct MlInfo<'a, 'b> { + transport: &'a Transport, + parts: MlInfoParts, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> MlInfo<'a, 'b> { + #[doc = "Creates a new instance of [MlInfo]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + MlInfo { + transport, + parts: MlInfoParts::None, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } #[doc = "Return human readable values for statistics."] pub fn human(mut self, human: bool) -> Self { self.human = Some(human); @@ -6124,32 +6492,35 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Ml Preview Datafeed API"] -pub enum MlPreviewDatafeedParts<'b> { - #[doc = "DatafeedId"] - DatafeedId(&'b str), +#[doc = "API parts for the Ml Preview Data Frame Analytics API"] +pub enum MlPreviewDataFrameAnalyticsParts<'b> { + #[doc = "No parts"] + None, + #[doc = "Id"] + Id(&'b str), } -impl<'b> MlPreviewDatafeedParts<'b> { - #[doc = "Builds a relative URL path to the Ml Preview Datafeed API"] +impl<'b> MlPreviewDataFrameAnalyticsParts<'b> { + #[doc = "Builds a relative URL path to the Ml Preview Data Frame Analytics API"] pub fn url(self) -> Cow<'static, str> { match self { - MlPreviewDatafeedParts::DatafeedId(ref datafeed_id) => { - let encoded_datafeed_id: Cow = - percent_encode(datafeed_id.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(24usize + encoded_datafeed_id.len()); - p.push_str("/_ml/datafeeds/"); - p.push_str(encoded_datafeed_id.as_ref()); + MlPreviewDataFrameAnalyticsParts::None => "/_ml/data_frame/analytics/_preview".into(), + MlPreviewDataFrameAnalyticsParts::Id(ref id) => { + let encoded_id: Cow = percent_encode(id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(35usize + encoded_id.len()); + p.push_str("/_ml/data_frame/analytics/"); + p.push_str(encoded_id.as_ref()); p.push_str("/_preview"); p.into() } } } } -#[doc = "Builder for the [Ml Preview Datafeed API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-preview-datafeed.html)\n\nPreviews a datafeed."] +#[doc = "Builder for the [Ml Preview Data Frame Analytics API](http://www.elastic.co/guide/en/elasticsearch/reference/8.0/preview-dfanalytics.html)\n\nPreviews that will be analyzed given a data frame analytics config."] #[derive(Clone, Debug)] -pub struct MlPreviewDatafeed<'a, 'b> { +pub struct MlPreviewDataFrameAnalytics<'a, 'b, B> { transport: &'a Transport, - parts: MlPreviewDatafeedParts<'b>, + parts: MlPreviewDataFrameAnalyticsParts<'b>, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -6158,14 +6529,18 @@ pub struct MlPreviewDatafeed<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> MlPreviewDatafeed<'a, 'b> { - #[doc = "Creates a new instance of [MlPreviewDatafeed] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: MlPreviewDatafeedParts<'b>) -> Self { +impl<'a, 'b, B> MlPreviewDataFrameAnalytics<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [MlPreviewDataFrameAnalytics] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlPreviewDataFrameAnalyticsParts<'b>) -> Self { let headers = HeaderMap::new(); - MlPreviewDatafeed { + MlPreviewDataFrameAnalytics { transport, parts, headers, + body: None, error_trace: None, filter_path: None, human: None, @@ -6174,6 +6549,24 @@ impl<'a, 'b> MlPreviewDatafeed<'a, 'b> { source: None, } } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> MlPreviewDataFrameAnalytics<'a, 'b, JsonBody> + where + T: Serialize, + { + MlPreviewDataFrameAnalytics { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -6209,10 +6602,13 @@ impl<'a, 'b> MlPreviewDatafeed<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Ml Preview Datafeed API that can be awaited"] + #[doc = "Creates an asynchronous call to the Ml Preview Data Frame Analytics API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = match self.body { + Some(_) => Method::Post, + None => Method::Get, + }; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -6235,7 +6631,7 @@ impl<'a, 'b> MlPreviewDatafeed<'a, 'b> { }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -6244,31 +6640,35 @@ impl<'a, 'b> MlPreviewDatafeed<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Ml Put Calendar API"] -pub enum MlPutCalendarParts<'b> { - #[doc = "CalendarId"] - CalendarId(&'b str), +#[doc = "API parts for the Ml Preview Datafeed API"] +pub enum MlPreviewDatafeedParts<'b> { + #[doc = "DatafeedId"] + DatafeedId(&'b str), + #[doc = "No parts"] + None, } -impl<'b> MlPutCalendarParts<'b> { - #[doc = "Builds a relative URL path to the Ml Put Calendar API"] +impl<'b> MlPreviewDatafeedParts<'b> { + #[doc = "Builds a relative URL path to the Ml Preview Datafeed API"] pub fn url(self) -> Cow<'static, str> { match self { - MlPutCalendarParts::CalendarId(ref calendar_id) => { - let encoded_calendar_id: Cow = - percent_encode(calendar_id.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(15usize + encoded_calendar_id.len()); - p.push_str("/_ml/calendars/"); - p.push_str(encoded_calendar_id.as_ref()); + MlPreviewDatafeedParts::DatafeedId(ref datafeed_id) => { + let encoded_datafeed_id: Cow = + percent_encode(datafeed_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(24usize + encoded_datafeed_id.len()); + p.push_str("/_ml/datafeeds/"); + p.push_str(encoded_datafeed_id.as_ref()); + p.push_str("/_preview"); p.into() } + MlPreviewDatafeedParts::None => "/_ml/datafeeds/_preview".into(), } } } -#[doc = "Builder for the [Ml Put Calendar API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-put-calendar.html)\n\nInstantiates a calendar."] +#[doc = "Builder for the [Ml Preview Datafeed API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-preview-datafeed.html)\n\nPreviews a datafeed."] #[derive(Clone, Debug)] -pub struct MlPutCalendar<'a, 'b, B> { +pub struct MlPreviewDatafeed<'a, 'b, B> { transport: &'a Transport, - parts: MlPutCalendarParts<'b>, + parts: MlPreviewDatafeedParts<'b>, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, @@ -6278,14 +6678,14 @@ pub struct MlPutCalendar<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> MlPutCalendar<'a, 'b, B> +impl<'a, 'b, B> MlPreviewDatafeed<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [MlPutCalendar] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: MlPutCalendarParts<'b>) -> Self { + #[doc = "Creates a new instance of [MlPreviewDatafeed] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlPreviewDatafeedParts<'b>) -> Self { let headers = HeaderMap::new(); - MlPutCalendar { + MlPreviewDatafeed { transport, parts, headers, @@ -6299,11 +6699,11 @@ where } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> MlPutCalendar<'a, 'b, JsonBody> + pub fn body(self, body: T) -> MlPreviewDatafeed<'a, 'b, JsonBody> where T: Serialize, { - MlPutCalendar { + MlPreviewDatafeed { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -6351,10 +6751,13 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Ml Put Calendar API that can be awaited"] + #[doc = "Creates an asynchronous call to the Ml Preview Datafeed API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Put; + let method = match self.body { + Some(_) => Method::Post, + None => Method::Get, + }; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -6386,10 +6789,152 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Ml Put Calendar Job API"] -pub enum MlPutCalendarJobParts<'b> { - #[doc = "CalendarId and JobId"] - CalendarIdJobId(&'b str, &'b str), +#[doc = "API parts for the Ml Put Calendar API"] +pub enum MlPutCalendarParts<'b> { + #[doc = "CalendarId"] + CalendarId(&'b str), +} +impl<'b> MlPutCalendarParts<'b> { + #[doc = "Builds a relative URL path to the Ml Put Calendar API"] + pub fn url(self) -> Cow<'static, str> { + match self { + MlPutCalendarParts::CalendarId(ref calendar_id) => { + let encoded_calendar_id: Cow = + percent_encode(calendar_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(15usize + encoded_calendar_id.len()); + p.push_str("/_ml/calendars/"); + p.push_str(encoded_calendar_id.as_ref()); + p.into() + } + } + } +} +#[doc = "Builder for the [Ml Put Calendar API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-put-calendar.html)\n\nInstantiates a calendar."] +#[derive(Clone, Debug)] +pub struct MlPutCalendar<'a, 'b, B> { + transport: &'a Transport, + parts: MlPutCalendarParts<'b>, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> MlPutCalendar<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [MlPutCalendar] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlPutCalendarParts<'b>) -> Self { + let headers = HeaderMap::new(); + MlPutCalendar { + transport, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> MlPutCalendar<'a, 'b, JsonBody> + where + T: Serialize, + { + MlPutCalendar { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Ml Put Calendar API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Put; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ml Put Calendar Job API"] +pub enum MlPutCalendarJobParts<'b> { + #[doc = "CalendarId and JobId"] + CalendarIdJobId(&'b str, &'b str), } impl<'b> MlPutCalendarJobParts<'b> { #[doc = "Builds a relative URL path to the Ml Put Calendar Job API"] @@ -6533,14 +7078,12 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Put Data Frame Analytics API"] pub enum MlPutDataFrameAnalyticsParts<'b> { #[doc = "Id"] Id(&'b str), } -#[cfg(feature = "beta-apis")] impl<'b> MlPutDataFrameAnalyticsParts<'b> { #[doc = "Builds a relative URL path to the Ml Put Data Frame Analytics API"] pub fn url(self) -> Cow<'static, str> { @@ -6556,8 +7099,6 @@ impl<'b> MlPutDataFrameAnalyticsParts<'b> { } } #[doc = "Builder for the [Ml Put Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/put-dfanalytics.html)\n\nInstantiates a data frame analytics job."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlPutDataFrameAnalytics<'a, 'b, B> { transport: &'a Transport, @@ -6571,7 +7112,6 @@ pub struct MlPutDataFrameAnalytics<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b, B> MlPutDataFrameAnalytics<'a, 'b, B> where B: Body, @@ -7030,11 +7570,15 @@ impl<'b> MlPutJobParts<'b> { pub struct MlPutJob<'a, 'b, B> { transport: &'a Transport, parts: MlPutJobParts<'b>, + allow_no_indices: Option, body: Option, error_trace: Option, + expand_wildcards: Option<&'b [ExpandWildcards]>, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, + ignore_throttled: Option, + ignore_unavailable: Option, pretty: Option, request_timeout: Option, source: Option<&'b str>, @@ -7050,15 +7594,24 @@ where transport, parts, headers, + allow_no_indices: None, body: None, error_trace: None, + expand_wildcards: None, filter_path: None, human: None, + ignore_throttled: None, + ignore_unavailable: None, pretty: None, request_timeout: None, source: None, } } + #[doc = "Ignore if the source indices expressions resolves to no concrete indices (default: true). Only set if datafeed_config is provided."] + pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self { + self.allow_no_indices = Some(allow_no_indices); + self + } #[doc = "The body for the API call"] pub fn body(self, body: T) -> MlPutJob<'a, 'b, JsonBody> where @@ -7068,10 +7621,14 @@ where transport: self.transport, parts: self.parts, body: Some(body.into()), + allow_no_indices: self.allow_no_indices, error_trace: self.error_trace, + expand_wildcards: self.expand_wildcards, filter_path: self.filter_path, headers: self.headers, human: self.human, + ignore_throttled: self.ignore_throttled, + ignore_unavailable: self.ignore_unavailable, pretty: self.pretty, request_timeout: self.request_timeout, source: self.source, @@ -7082,6 +7639,11 @@ where self.error_trace = Some(error_trace); self } + #[doc = "Whether source index expressions should get expanded to open or closed indices (default: open). Only set if datafeed_config is provided."] + 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); @@ -7097,6 +7659,16 @@ where self.human = Some(human); self } + #[doc = "Ignore indices that are marked as throttled (default: true). Only set if datafeed_config is provided."] + pub fn ignore_throttled(mut self, ignore_throttled: bool) -> Self { + self.ignore_throttled = Some(ignore_throttled); + self + } + #[doc = "Ignore unavailable indexes (default: false). Only set if datafeed_config is provided."] + pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self { + self.ignore_unavailable = Some(ignore_unavailable); + self + } #[doc = "Pretty format the returned JSON response."] pub fn pretty(mut self, pretty: bool) -> Self { self.pretty = Some(pretty); @@ -7122,17 +7694,26 @@ where #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { + allow_no_indices: Option, 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]>, human: Option, + ignore_throttled: Option, + ignore_unavailable: Option, pretty: Option, source: Option<&'b str>, } let query_params = QueryParams { + allow_no_indices: self.allow_no_indices, error_trace: self.error_trace, + expand_wildcards: self.expand_wildcards, filter_path: self.filter_path, human: self.human, + ignore_throttled: self.ignore_throttled, + ignore_unavailable: self.ignore_unavailable, pretty: self.pretty, source: self.source, }; @@ -7146,14 +7727,12 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Put Trained Model API"] pub enum MlPutTrainedModelParts<'b> { #[doc = "ModelId"] ModelId(&'b str), } -#[cfg(feature = "beta-apis")] impl<'b> MlPutTrainedModelParts<'b> { #[doc = "Builds a relative URL path to the Ml Put Trained Model API"] pub fn url(self) -> Cow<'static, str> { @@ -7170,8 +7749,6 @@ impl<'b> MlPutTrainedModelParts<'b> { } } #[doc = "Builder for the [Ml Put Trained Model API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/put-trained-models.html)\n\nCreates an inference trained model."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlPutTrainedModel<'a, 'b, B> { transport: &'a Transport, @@ -7185,7 +7762,6 @@ pub struct MlPutTrainedModel<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b, B> MlPutTrainedModel<'a, 'b, B> where B: Body, @@ -7294,93 +7870,87 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Ml Revert Model Snapshot API"] -pub enum MlRevertModelSnapshotParts<'b> { - #[doc = "JobId and SnapshotId"] - JobIdSnapshotId(&'b str, &'b str), +#[doc = "API parts for the Ml Put Trained Model Alias API"] +pub enum MlPutTrainedModelAliasParts<'b> { + #[doc = "ModelId and ModelAlias"] + ModelIdModelAlias(&'b str, &'b str), } -impl<'b> MlRevertModelSnapshotParts<'b> { - #[doc = "Builds a relative URL path to the Ml Revert Model Snapshot API"] +impl<'b> MlPutTrainedModelAliasParts<'b> { + #[doc = "Builds a relative URL path to the Ml Put Trained Model Alias API"] pub fn url(self) -> Cow<'static, str> { match self { - MlRevertModelSnapshotParts::JobIdSnapshotId(ref job_id, ref snapshot_id) => { - let encoded_job_id: Cow = - percent_encode(job_id.as_bytes(), PARTS_ENCODED).into(); - let encoded_snapshot_id: Cow = - percent_encode(snapshot_id.as_bytes(), PARTS_ENCODED).into(); + MlPutTrainedModelAliasParts::ModelIdModelAlias(ref model_id, ref model_alias) => { + let encoded_model_id: Cow = + percent_encode(model_id.as_bytes(), PARTS_ENCODED).into(); + let encoded_model_alias: Cow = + percent_encode(model_alias.as_bytes(), PARTS_ENCODED).into(); let mut p = String::with_capacity( - 48usize + encoded_job_id.len() + encoded_snapshot_id.len(), + 35usize + encoded_model_id.len() + encoded_model_alias.len(), ); - p.push_str("/_ml/anomaly_detectors/"); - p.push_str(encoded_job_id.as_ref()); - p.push_str("/model_snapshots/"); - p.push_str(encoded_snapshot_id.as_ref()); - p.push_str("/_revert"); + p.push_str("/_ml/trained_models/"); + p.push_str(encoded_model_id.as_ref()); + p.push_str("/model_aliases/"); + p.push_str(encoded_model_alias.as_ref()); p.into() } } } } -#[doc = "Builder for the [Ml Revert Model Snapshot API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-revert-snapshot.html)\n\nReverts to a specific snapshot."] +#[doc = "Builder for the [Ml Put Trained Model Alias API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/put-trained-models-aliases.html)\n\nCreates a new model alias (or reassigns an existing one) to refer to the trained model"] #[derive(Clone, Debug)] -pub struct MlRevertModelSnapshot<'a, 'b, B> { +pub struct MlPutTrainedModelAlias<'a, 'b, B> { transport: &'a Transport, - parts: MlRevertModelSnapshotParts<'b>, + parts: MlPutTrainedModelAliasParts<'b>, body: Option, - delete_intervening_results: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, + reassign: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> MlRevertModelSnapshot<'a, 'b, B> +impl<'a, 'b, B> MlPutTrainedModelAlias<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [MlRevertModelSnapshot] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: MlRevertModelSnapshotParts<'b>) -> Self { + #[doc = "Creates a new instance of [MlPutTrainedModelAlias] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlPutTrainedModelAliasParts<'b>) -> Self { let headers = HeaderMap::new(); - MlRevertModelSnapshot { + MlPutTrainedModelAlias { transport, parts, headers, body: None, - delete_intervening_results: None, error_trace: None, filter_path: None, human: None, pretty: None, + reassign: None, request_timeout: None, source: None, } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> MlRevertModelSnapshot<'a, 'b, JsonBody> + pub fn body(self, body: T) -> MlPutTrainedModelAlias<'a, 'b, JsonBody> where T: Serialize, { - MlRevertModelSnapshot { + MlPutTrainedModelAlias { transport: self.transport, parts: self.parts, body: Some(body.into()), - delete_intervening_results: self.delete_intervening_results, error_trace: self.error_trace, filter_path: self.filter_path, headers: self.headers, human: self.human, pretty: self.pretty, + reassign: self.reassign, request_timeout: self.request_timeout, source: self.source, } } - #[doc = "Should we reset the results back to the time of the snapshot?"] - pub fn delete_intervening_results(mut self, delete_intervening_results: bool) -> Self { - self.delete_intervening_results = Some(delete_intervening_results); - 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); @@ -7406,6 +7976,11 @@ where self.pretty = Some(pretty); self } + #[doc = "If the model_alias already exists and points to a separate model_id, this parameter must be true. Defaults to false."] + pub fn reassign(mut self, reassign: bool) -> Self { + self.reassign = Some(reassign); + 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); @@ -7416,30 +7991,30 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Ml Revert Model Snapshot API that can be awaited"] + #[doc = "Creates an asynchronous call to the Ml Put Trained Model Alias API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Post; + let method = Method::Put; let headers = self.headers; let timeout = self.request_timeout; let query_string = { #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { - delete_intervening_results: Option, error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, + reassign: Option, source: Option<&'b str>, } let query_params = QueryParams { - delete_intervening_results: self.delete_intervening_results, error_trace: self.error_trace, filter_path: self.filter_path, human: self.human, pretty: self.pretty, + reassign: self.reassign, source: self.source, }; Some(query_params) @@ -7453,26 +8028,33 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Ml Set Upgrade Mode API"] -pub enum MlSetUpgradeModeParts { - #[doc = "No parts"] - None, +#[doc = "API parts for the Ml Reset Job API"] +pub enum MlResetJobParts<'b> { + #[doc = "JobId"] + JobId(&'b str), } -impl MlSetUpgradeModeParts { - #[doc = "Builds a relative URL path to the Ml Set Upgrade Mode API"] +impl<'b> MlResetJobParts<'b> { + #[doc = "Builds a relative URL path to the Ml Reset Job API"] pub fn url(self) -> Cow<'static, str> { match self { - MlSetUpgradeModeParts::None => "/_ml/set_upgrade_mode".into(), + MlResetJobParts::JobId(ref job_id) => { + let encoded_job_id: Cow = + percent_encode(job_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(30usize + encoded_job_id.len()); + p.push_str("/_ml/anomaly_detectors/"); + p.push_str(encoded_job_id.as_ref()); + p.push_str("/_reset"); + p.into() + } } } } -#[doc = "Builder for the [Ml Set Upgrade Mode API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-set-upgrade-mode.html)\n\nSets a cluster wide upgrade_mode setting that prepares machine learning indices for an upgrade."] +#[doc = "Builder for the [Ml Reset Job API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-reset-job.html)\n\nResets an existing anomaly detection job."] #[derive(Clone, Debug)] -pub struct MlSetUpgradeMode<'a, 'b, B> { +pub struct MlResetJob<'a, 'b, B> { transport: &'a Transport, - parts: MlSetUpgradeModeParts, + parts: MlResetJobParts<'b>, body: Option, - enabled: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -7480,18 +8062,323 @@ pub struct MlSetUpgradeMode<'a, 'b, B> { pretty: Option, request_timeout: Option, source: Option<&'b str>, - timeout: Option<&'b str>, + wait_for_completion: Option, } -impl<'a, 'b, B> MlSetUpgradeMode<'a, 'b, B> +impl<'a, 'b, B> MlResetJob<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [MlSetUpgradeMode]"] - pub fn new(transport: &'a Transport) -> Self { + #[doc = "Creates a new instance of [MlResetJob] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlResetJobParts<'b>) -> Self { let headers = HeaderMap::new(); - MlSetUpgradeMode { + MlResetJob { transport, - parts: MlSetUpgradeModeParts::None, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + wait_for_completion: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> MlResetJob<'a, 'b, JsonBody> + where + T: Serialize, + { + MlResetJob { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + wait_for_completion: self.wait_for_completion, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Should this request wait until the operation has completed before returning"] + pub fn wait_for_completion(mut self, wait_for_completion: bool) -> Self { + self.wait_for_completion = Some(wait_for_completion); + self + } + #[doc = "Creates an asynchronous call to the Ml Reset Job API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + wait_for_completion: Option, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + wait_for_completion: self.wait_for_completion, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ml Revert Model Snapshot API"] +pub enum MlRevertModelSnapshotParts<'b> { + #[doc = "JobId and SnapshotId"] + JobIdSnapshotId(&'b str, &'b str), +} +impl<'b> MlRevertModelSnapshotParts<'b> { + #[doc = "Builds a relative URL path to the Ml Revert Model Snapshot API"] + pub fn url(self) -> Cow<'static, str> { + match self { + MlRevertModelSnapshotParts::JobIdSnapshotId(ref job_id, ref snapshot_id) => { + let encoded_job_id: Cow = + percent_encode(job_id.as_bytes(), PARTS_ENCODED).into(); + let encoded_snapshot_id: Cow = + percent_encode(snapshot_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 48usize + encoded_job_id.len() + encoded_snapshot_id.len(), + ); + p.push_str("/_ml/anomaly_detectors/"); + p.push_str(encoded_job_id.as_ref()); + p.push_str("/model_snapshots/"); + p.push_str(encoded_snapshot_id.as_ref()); + p.push_str("/_revert"); + p.into() + } + } + } +} +#[doc = "Builder for the [Ml Revert Model Snapshot API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-revert-snapshot.html)\n\nReverts to a specific snapshot."] +#[derive(Clone, Debug)] +pub struct MlRevertModelSnapshot<'a, 'b, B> { + transport: &'a Transport, + parts: MlRevertModelSnapshotParts<'b>, + body: Option, + delete_intervening_results: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> MlRevertModelSnapshot<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [MlRevertModelSnapshot] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlRevertModelSnapshotParts<'b>) -> Self { + let headers = HeaderMap::new(); + MlRevertModelSnapshot { + transport, + parts, + headers, + body: None, + delete_intervening_results: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> MlRevertModelSnapshot<'a, 'b, JsonBody> + where + T: Serialize, + { + MlRevertModelSnapshot { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + delete_intervening_results: self.delete_intervening_results, + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[doc = "Should we reset the results back to the time of the snapshot?"] + pub fn delete_intervening_results(mut self, delete_intervening_results: bool) -> Self { + self.delete_intervening_results = Some(delete_intervening_results); + 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Ml Revert Model Snapshot API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + let headers = self.headers; + let timeout = self.request_timeout; + let query_string = { + #[serde_with::skip_serializing_none] + #[derive(Serialize)] + struct QueryParams<'b> { + delete_intervening_results: Option, + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + delete_intervening_results: self.delete_intervening_results, + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ml Set Upgrade Mode API"] +pub enum MlSetUpgradeModeParts { + #[doc = "No parts"] + None, +} +impl MlSetUpgradeModeParts { + #[doc = "Builds a relative URL path to the Ml Set Upgrade Mode API"] + pub fn url(self) -> Cow<'static, str> { + match self { + MlSetUpgradeModeParts::None => "/_ml/set_upgrade_mode".into(), + } + } +} +#[doc = "Builder for the [Ml Set Upgrade Mode API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-set-upgrade-mode.html)\n\nSets a cluster wide upgrade_mode setting that prepares machine learning indices for an upgrade."] +#[derive(Clone, Debug)] +pub struct MlSetUpgradeMode<'a, 'b, B> { + transport: &'a Transport, + parts: MlSetUpgradeModeParts, + body: Option, + enabled: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, + timeout: Option<&'b str>, +} +impl<'a, 'b, B> MlSetUpgradeMode<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [MlSetUpgradeMode]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + MlSetUpgradeMode { + transport, + parts: MlSetUpgradeModeParts::None, headers, body: None, enabled: None, @@ -7607,37 +8494,187 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Ml Start Data Frame Analytics API"] -pub enum MlStartDataFrameAnalyticsParts<'b> { - #[doc = "Id"] - Id(&'b str), +#[doc = "API parts for the Ml Start Data Frame Analytics API"] +pub enum MlStartDataFrameAnalyticsParts<'b> { + #[doc = "Id"] + Id(&'b str), +} +impl<'b> MlStartDataFrameAnalyticsParts<'b> { + #[doc = "Builds a relative URL path to the Ml Start Data Frame Analytics API"] + pub fn url(self) -> Cow<'static, str> { + match self { + MlStartDataFrameAnalyticsParts::Id(ref id) => { + let encoded_id: Cow = percent_encode(id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(33usize + encoded_id.len()); + p.push_str("/_ml/data_frame/analytics/"); + p.push_str(encoded_id.as_ref()); + p.push_str("/_start"); + p.into() + } + } + } +} +#[doc = "Builder for the [Ml Start Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/start-dfanalytics.html)\n\nStarts a data frame analytics job."] +#[derive(Clone, Debug)] +pub struct MlStartDataFrameAnalytics<'a, 'b, B> { + transport: &'a Transport, + parts: MlStartDataFrameAnalyticsParts<'b>, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, + timeout: Option<&'b str>, +} +impl<'a, 'b, B> MlStartDataFrameAnalytics<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [MlStartDataFrameAnalytics] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlStartDataFrameAnalyticsParts<'b>) -> Self { + let headers = HeaderMap::new(); + MlStartDataFrameAnalytics { + transport, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + timeout: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> MlStartDataFrameAnalytics<'a, 'b, JsonBody> + where + T: Serialize, + { + MlStartDataFrameAnalytics { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + timeout: self.timeout, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Controls the time to wait until the task has started. Defaults to 20 seconds"] + pub fn timeout(mut self, timeout: &'b str) -> Self { + self.timeout = Some(timeout); + self + } + #[doc = "Creates an asynchronous call to the Ml Start Data Frame Analytics API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + timeout: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + timeout: self.timeout, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ml Start Datafeed API"] +pub enum MlStartDatafeedParts<'b> { + #[doc = "DatafeedId"] + DatafeedId(&'b str), } -#[cfg(feature = "beta-apis")] -impl<'b> MlStartDataFrameAnalyticsParts<'b> { - #[doc = "Builds a relative URL path to the Ml Start Data Frame Analytics API"] +impl<'b> MlStartDatafeedParts<'b> { + #[doc = "Builds a relative URL path to the Ml Start Datafeed API"] pub fn url(self) -> Cow<'static, str> { match self { - MlStartDataFrameAnalyticsParts::Id(ref id) => { - let encoded_id: Cow = percent_encode(id.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(33usize + encoded_id.len()); - p.push_str("/_ml/data_frame/analytics/"); - p.push_str(encoded_id.as_ref()); + MlStartDatafeedParts::DatafeedId(ref datafeed_id) => { + let encoded_datafeed_id: Cow = + percent_encode(datafeed_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(22usize + encoded_datafeed_id.len()); + p.push_str("/_ml/datafeeds/"); + p.push_str(encoded_datafeed_id.as_ref()); p.push_str("/_start"); p.into() } } } } -#[doc = "Builder for the [Ml Start Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/start-dfanalytics.html)\n\nStarts a data frame analytics job."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] +#[doc = "Builder for the [Ml Start Datafeed API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-start-datafeed.html)\n\nStarts one or more datafeeds."] #[derive(Clone, Debug)] -pub struct MlStartDataFrameAnalytics<'a, 'b, B> { +pub struct MlStartDatafeed<'a, 'b, B> { transport: &'a Transport, - parts: MlStartDataFrameAnalyticsParts<'b>, + parts: MlStartDatafeedParts<'b>, body: Option, + end: Option<&'b str>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -7645,39 +8682,42 @@ pub struct MlStartDataFrameAnalytics<'a, 'b, B> { pretty: Option, request_timeout: Option, source: Option<&'b str>, + start: Option<&'b str>, timeout: Option<&'b str>, } -#[cfg(feature = "beta-apis")] -impl<'a, 'b, B> MlStartDataFrameAnalytics<'a, 'b, B> +impl<'a, 'b, B> MlStartDatafeed<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [MlStartDataFrameAnalytics] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: MlStartDataFrameAnalyticsParts<'b>) -> Self { + #[doc = "Creates a new instance of [MlStartDatafeed] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlStartDatafeedParts<'b>) -> Self { let headers = HeaderMap::new(); - MlStartDataFrameAnalytics { + MlStartDatafeed { transport, parts, headers, body: None, + end: None, error_trace: None, filter_path: None, human: None, pretty: None, request_timeout: None, source: None, + start: None, timeout: None, } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> MlStartDataFrameAnalytics<'a, 'b, JsonBody> + pub fn body(self, body: T) -> MlStartDatafeed<'a, 'b, JsonBody> where T: Serialize, { - MlStartDataFrameAnalytics { + MlStartDatafeed { transport: self.transport, parts: self.parts, body: Some(body.into()), + end: self.end, error_trace: self.error_trace, filter_path: self.filter_path, headers: self.headers, @@ -7685,9 +8725,15 @@ where pretty: self.pretty, request_timeout: self.request_timeout, source: self.source, + start: self.start, timeout: self.timeout, } } + #[doc = "The end time when the datafeed should stop. When not set, the datafeed continues in real time"] + pub fn end(mut self, end: &'b str) -> Self { + self.end = Some(end); + 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); @@ -7723,12 +8769,17 @@ where self.source = Some(source); self } - #[doc = "Controls the time to wait until the task has started. Defaults to 20 seconds"] + #[doc = "The start time from where the datafeed should begin"] + pub fn start(mut self, start: &'b str) -> Self { + self.start = Some(start); + self + } + #[doc = "Controls the time to wait until a datafeed has started. Default to 20 seconds"] pub fn timeout(mut self, timeout: &'b str) -> Self { self.timeout = Some(timeout); self } - #[doc = "Creates an asynchronous call to the Ml Start Data Frame Analytics API that can be awaited"] + #[doc = "Creates an asynchronous call to the Ml Start Datafeed API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Post; @@ -7738,20 +8789,24 @@ where #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { + end: Option<&'b str>, error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, source: Option<&'b str>, + start: Option<&'b str>, timeout: Option<&'b str>, } let query_params = QueryParams { + end: self.end, error_trace: self.error_trace, filter_path: self.filter_path, human: self.human, pretty: self.pretty, source: self.source, + start: self.start, timeout: self.timeout, }; Some(query_params) @@ -7764,35 +8819,38 @@ where Ok(response) } } +#[cfg(feature = "experimental-apis")] #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Ml Start Datafeed API"] -pub enum MlStartDatafeedParts<'b> { - #[doc = "DatafeedId"] - DatafeedId(&'b str), +#[doc = "API parts for the Ml Start Trained Model Deployment API"] +pub enum MlStartTrainedModelDeploymentParts<'b> { + #[doc = "ModelId"] + ModelId(&'b str), } -impl<'b> MlStartDatafeedParts<'b> { - #[doc = "Builds a relative URL path to the Ml Start Datafeed API"] +#[cfg(feature = "experimental-apis")] +impl<'b> MlStartTrainedModelDeploymentParts<'b> { + #[doc = "Builds a relative URL path to the Ml Start Trained Model Deployment API"] pub fn url(self) -> Cow<'static, str> { match self { - MlStartDatafeedParts::DatafeedId(ref datafeed_id) => { - let encoded_datafeed_id: Cow = - percent_encode(datafeed_id.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(22usize + encoded_datafeed_id.len()); - p.push_str("/_ml/datafeeds/"); - p.push_str(encoded_datafeed_id.as_ref()); - p.push_str("/_start"); + MlStartTrainedModelDeploymentParts::ModelId(ref model_id) => { + let encoded_model_id: Cow = + percent_encode(model_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(38usize + encoded_model_id.len()); + p.push_str("/_ml/trained_models/"); + p.push_str(encoded_model_id.as_ref()); + p.push_str("/deployment/_start"); p.into() } } } } -#[doc = "Builder for the [Ml Start Datafeed API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-start-datafeed.html)\n\nStarts one or more datafeeds."] +#[doc = "Builder for the [Ml Start Trained Model Deployment API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/start-trained-model-deployment.html)\n\nStart a trained model deployment."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] #[derive(Clone, Debug)] -pub struct MlStartDatafeed<'a, 'b, B> { +pub struct MlStartTrainedModelDeployment<'a, 'b, B> { transport: &'a Transport, - parts: MlStartDatafeedParts<'b>, + parts: MlStartTrainedModelDeploymentParts<'b>, body: Option, - end: Option<&'b str>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -7800,42 +8858,39 @@ pub struct MlStartDatafeed<'a, 'b, B> { pretty: Option, request_timeout: Option, source: Option<&'b str>, - start: Option<&'b str>, timeout: Option<&'b str>, } -impl<'a, 'b, B> MlStartDatafeed<'a, 'b, B> +#[cfg(feature = "experimental-apis")] +impl<'a, 'b, B> MlStartTrainedModelDeployment<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [MlStartDatafeed] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: MlStartDatafeedParts<'b>) -> Self { + #[doc = "Creates a new instance of [MlStartTrainedModelDeployment] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlStartTrainedModelDeploymentParts<'b>) -> Self { let headers = HeaderMap::new(); - MlStartDatafeed { + MlStartTrainedModelDeployment { transport, parts, headers, body: None, - end: None, error_trace: None, filter_path: None, human: None, pretty: None, request_timeout: None, source: None, - start: None, timeout: None, } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> MlStartDatafeed<'a, 'b, JsonBody> + pub fn body(self, body: T) -> MlStartTrainedModelDeployment<'a, 'b, JsonBody> where T: Serialize, { - MlStartDatafeed { + MlStartTrainedModelDeployment { transport: self.transport, parts: self.parts, body: Some(body.into()), - end: self.end, error_trace: self.error_trace, filter_path: self.filter_path, headers: self.headers, @@ -7843,15 +8898,9 @@ where pretty: self.pretty, request_timeout: self.request_timeout, source: self.source, - start: self.start, timeout: self.timeout, } } - #[doc = "The end time when the datafeed should stop. When not set, the datafeed continues in real time"] - pub fn end(mut self, end: &'b str) -> Self { - self.end = Some(end); - 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); @@ -7887,17 +8936,12 @@ where self.source = Some(source); self } - #[doc = "The start time from where the datafeed should begin"] - pub fn start(mut self, start: &'b str) -> Self { - self.start = Some(start); - self - } - #[doc = "Controls the time to wait until a datafeed has started. Default to 20 seconds"] + #[doc = "Controls the amount of time to wait for the model to deploy."] pub fn timeout(mut self, timeout: &'b str) -> Self { self.timeout = Some(timeout); self } - #[doc = "Creates an asynchronous call to the Ml Start Datafeed API that can be awaited"] + #[doc = "Creates an asynchronous call to the Ml Start Trained Model Deployment API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Post; @@ -7907,24 +8951,20 @@ where #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { - end: Option<&'b str>, error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, source: Option<&'b str>, - start: Option<&'b str>, timeout: Option<&'b str>, } let query_params = QueryParams { - end: self.end, error_trace: self.error_trace, filter_path: self.filter_path, human: self.human, pretty: self.pretty, source: self.source, - start: self.start, timeout: self.timeout, }; Some(query_params) @@ -7937,14 +8977,12 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Stop Data Frame Analytics API"] pub enum MlStopDataFrameAnalyticsParts<'b> { #[doc = "Id"] Id(&'b str), } -#[cfg(feature = "beta-apis")] impl<'b> MlStopDataFrameAnalyticsParts<'b> { #[doc = "Builds a relative URL path to the Ml Stop Data Frame Analytics API"] pub fn url(self) -> Cow<'static, str> { @@ -7961,8 +8999,6 @@ impl<'b> MlStopDataFrameAnalyticsParts<'b> { } } #[doc = "Builder for the [Ml Stop Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/stop-dfanalytics.html)\n\nStops one or more data frame analytics jobs."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlStopDataFrameAnalytics<'a, 'b, B> { transport: &'a Transport, @@ -7979,7 +9015,6 @@ pub struct MlStopDataFrameAnalytics<'a, 'b, B> { source: Option<&'b str>, timeout: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b, B> MlStopDataFrameAnalytics<'a, 'b, B> where B: Body, @@ -8297,14 +9332,160 @@ where Ok(response) } } -#[cfg(feature = "beta-apis")] +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Ml Stop Trained Model Deployment API"] +pub enum MlStopTrainedModelDeploymentParts<'b> { + #[doc = "ModelId"] + ModelId(&'b str), +} +#[cfg(feature = "experimental-apis")] +impl<'b> MlStopTrainedModelDeploymentParts<'b> { + #[doc = "Builds a relative URL path to the Ml Stop Trained Model Deployment API"] + pub fn url(self) -> Cow<'static, str> { + match self { + MlStopTrainedModelDeploymentParts::ModelId(ref model_id) => { + let encoded_model_id: Cow = + percent_encode(model_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(37usize + encoded_model_id.len()); + p.push_str("/_ml/trained_models/"); + p.push_str(encoded_model_id.as_ref()); + p.push_str("/deployment/_stop"); + p.into() + } + } + } +} +#[doc = "Builder for the [Ml Stop Trained Model Deployment API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/stop-trained-model-deployment.html)\n\nStop a trained model deployment."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct MlStopTrainedModelDeployment<'a, 'b, B> { + transport: &'a Transport, + parts: MlStopTrainedModelDeploymentParts<'b>, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b, B> MlStopTrainedModelDeployment<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [MlStopTrainedModelDeployment] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: MlStopTrainedModelDeploymentParts<'b>) -> Self { + let headers = HeaderMap::new(); + MlStopTrainedModelDeployment { + transport, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> MlStopTrainedModelDeployment<'a, 'b, JsonBody> + where + T: Serialize, + { + MlStopTrainedModelDeployment { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Ml Stop Trained Model Deployment API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ml Update Data Frame Analytics API"] pub enum MlUpdateDataFrameAnalyticsParts<'b> { #[doc = "Id"] Id(&'b str), } -#[cfg(feature = "beta-apis")] impl<'b> MlUpdateDataFrameAnalyticsParts<'b> { #[doc = "Builds a relative URL path to the Ml Update Data Frame Analytics API"] pub fn url(self) -> Cow<'static, str> { @@ -8321,8 +9502,6 @@ impl<'b> MlUpdateDataFrameAnalyticsParts<'b> { } } #[doc = "Builder for the [Ml Update Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/update-dfanalytics.html)\n\nUpdates certain properties of a data frame analytics job."] -#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] -#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] pub struct MlUpdateDataFrameAnalytics<'a, 'b, B> { transport: &'a Transport, @@ -8336,7 +9515,6 @@ pub struct MlUpdateDataFrameAnalytics<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -#[cfg(feature = "beta-apis")] impl<'a, 'b, B> MlUpdateDataFrameAnalytics<'a, 'b, B> where B: Body, @@ -9540,8 +10718,6 @@ impl<'a> Ml<'a> { MlDeleteCalendarJob::new(self.transport(), parts) } #[doc = "[Ml Delete Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/delete-dfanalytics.html)\n\nDeletes an existing data frame analytics job."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn delete_data_frame_analytics<'b>( &'a self, parts: MlDeleteDataFrameAnalyticsParts<'b>, @@ -9585,27 +10761,28 @@ impl<'a> Ml<'a> { MlDeleteModelSnapshot::new(self.transport(), parts) } #[doc = "[Ml Delete Trained Model API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/delete-trained-models.html)\n\nDeletes an existing trained inference model that is currently not referenced by an ingest pipeline."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn delete_trained_model<'b>( &'a self, parts: MlDeleteTrainedModelParts<'b>, ) -> MlDeleteTrainedModel<'a, 'b> { MlDeleteTrainedModel::new(self.transport(), parts) } + #[doc = "[Ml Delete Trained Model Alias API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/delete-trained-models-aliases.html)\n\nDeletes a model alias that refers to the trained model"] + pub fn delete_trained_model_alias<'b>( + &'a self, + parts: MlDeleteTrainedModelAliasParts<'b>, + ) -> MlDeleteTrainedModelAlias<'a, 'b> { + MlDeleteTrainedModelAlias::new(self.transport(), parts) + } #[doc = "[Ml Estimate Model Memory API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-apis.html)\n\nEstimates the model memory"] pub fn estimate_model_memory<'b>(&'a self) -> MlEstimateModelMemory<'a, 'b, ()> { MlEstimateModelMemory::new(self.transport()) } #[doc = "[Ml Evaluate Data Frame API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/evaluate-dfanalytics.html)\n\nEvaluates the data frame analytics for an annotated index."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn evaluate_data_frame<'b>(&'a self) -> MlEvaluateDataFrame<'a, 'b, ()> { MlEvaluateDataFrame::new(self.transport()) } #[doc = "[Ml Explain Data Frame Analytics API](http://www.elastic.co/guide/en/elasticsearch/reference/8.0/explain-dfanalytics.html)\n\nExplains a data frame analytics config."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn explain_data_frame_analytics<'b>( &'a self, parts: MlExplainDataFrameAnalyticsParts<'b>, @@ -9646,8 +10823,6 @@ impl<'a> Ml<'a> { MlGetCategories::new(self.transport(), parts) } #[doc = "[Ml Get Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-dfanalytics.html)\n\nRetrieves configuration information for data frame analytics jobs."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn get_data_frame_analytics<'b>( &'a self, parts: MlGetDataFrameAnalyticsParts<'b>, @@ -9655,8 +10830,6 @@ impl<'a> Ml<'a> { MlGetDataFrameAnalytics::new(self.transport(), parts) } #[doc = "[Ml Get Data Frame Analytics Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-dfanalytics-stats.html)\n\nRetrieves usage information for data frame analytics jobs."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn get_data_frame_analytics_stats<'b>( &'a self, parts: MlGetDataFrameAnalyticsStatsParts<'b>, @@ -9711,9 +10884,16 @@ impl<'a> Ml<'a> { pub fn get_records<'b>(&'a self, parts: MlGetRecordsParts<'b>) -> MlGetRecords<'a, 'b, ()> { MlGetRecords::new(self.transport(), parts) } + #[doc = "[Ml Get Trained Model Deployment Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-get-trained-model-deployment-stats.html)\n\nGet information about trained model deployments."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn get_trained_model_deployment_stats<'b>( + &'a self, + parts: MlGetTrainedModelDeploymentStatsParts<'b>, + ) -> MlGetTrainedModelDeploymentStats<'a, 'b> { + MlGetTrainedModelDeploymentStats::new(self.transport(), parts) + } #[doc = "[Ml Get Trained Models API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-trained-models.html)\n\nRetrieves configuration information for a trained inference model."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn get_trained_models<'b>( &'a self, parts: MlGetTrainedModelsParts<'b>, @@ -9721,14 +10901,21 @@ impl<'a> Ml<'a> { MlGetTrainedModels::new(self.transport(), parts) } #[doc = "[Ml Get Trained Models Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-trained-models-stats.html)\n\nRetrieves usage information for trained inference models."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn get_trained_models_stats<'b>( &'a self, parts: MlGetTrainedModelsStatsParts<'b>, ) -> MlGetTrainedModelsStats<'a, 'b> { MlGetTrainedModelsStats::new(self.transport(), parts) } + #[doc = "[Ml Infer Trained Model Deployment API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/infer-trained-model-deployment.html)\n\nEvaluate a trained model."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn infer_trained_model_deployment<'b>( + &'a self, + parts: MlInferTrainedModelDeploymentParts<'b>, + ) -> MlInferTrainedModelDeployment<'a, 'b, ()> { + MlInferTrainedModelDeployment::new(self.transport(), parts) + } #[doc = "[Ml Info API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-ml-info.html)\n\nReturns defaults and limits used by machine learning."] pub fn info<'b>(&'a self) -> MlInfo<'a, 'b> { MlInfo::new(self.transport()) @@ -9748,11 +10935,18 @@ impl<'a> Ml<'a> { pub fn post_data<'b>(&'a self, parts: MlPostDataParts<'b>) -> MlPostData<'a, 'b, ()> { MlPostData::new(self.transport(), parts) } + #[doc = "[Ml Preview Data Frame Analytics API](http://www.elastic.co/guide/en/elasticsearch/reference/8.0/preview-dfanalytics.html)\n\nPreviews that will be analyzed given a data frame analytics config."] + pub fn preview_data_frame_analytics<'b>( + &'a self, + parts: MlPreviewDataFrameAnalyticsParts<'b>, + ) -> MlPreviewDataFrameAnalytics<'a, 'b, ()> { + MlPreviewDataFrameAnalytics::new(self.transport(), parts) + } #[doc = "[Ml Preview Datafeed API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-preview-datafeed.html)\n\nPreviews a datafeed."] pub fn preview_datafeed<'b>( &'a self, parts: MlPreviewDatafeedParts<'b>, - ) -> MlPreviewDatafeed<'a, 'b> { + ) -> MlPreviewDatafeed<'a, 'b, ()> { MlPreviewDatafeed::new(self.transport(), parts) } #[doc = "[Ml Put Calendar API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-put-calendar.html)\n\nInstantiates a calendar."] @@ -9767,8 +10961,6 @@ impl<'a> Ml<'a> { MlPutCalendarJob::new(self.transport(), parts) } #[doc = "[Ml Put Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/put-dfanalytics.html)\n\nInstantiates a data frame analytics job."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn put_data_frame_analytics<'b>( &'a self, parts: MlPutDataFrameAnalyticsParts<'b>, @@ -9788,14 +10980,23 @@ impl<'a> Ml<'a> { MlPutJob::new(self.transport(), parts) } #[doc = "[Ml Put Trained Model API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/put-trained-models.html)\n\nCreates an inference trained model."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn put_trained_model<'b>( &'a self, parts: MlPutTrainedModelParts<'b>, ) -> MlPutTrainedModel<'a, 'b, ()> { MlPutTrainedModel::new(self.transport(), parts) } + #[doc = "[Ml Put Trained Model Alias API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/put-trained-models-aliases.html)\n\nCreates a new model alias (or reassigns an existing one) to refer to the trained model"] + pub fn put_trained_model_alias<'b>( + &'a self, + parts: MlPutTrainedModelAliasParts<'b>, + ) -> MlPutTrainedModelAlias<'a, 'b, ()> { + MlPutTrainedModelAlias::new(self.transport(), parts) + } + #[doc = "[Ml Reset Job API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-reset-job.html)\n\nResets an existing anomaly detection job."] + pub fn reset_job<'b>(&'a self, parts: MlResetJobParts<'b>) -> MlResetJob<'a, 'b, ()> { + MlResetJob::new(self.transport(), parts) + } #[doc = "[Ml Revert Model Snapshot API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/ml-revert-snapshot.html)\n\nReverts to a specific snapshot."] pub fn revert_model_snapshot<'b>( &'a self, @@ -9808,8 +11009,6 @@ impl<'a> Ml<'a> { MlSetUpgradeMode::new(self.transport()) } #[doc = "[Ml Start Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/start-dfanalytics.html)\n\nStarts a data frame analytics job."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn start_data_frame_analytics<'b>( &'a self, parts: MlStartDataFrameAnalyticsParts<'b>, @@ -9823,9 +11022,16 @@ impl<'a> Ml<'a> { ) -> MlStartDatafeed<'a, 'b, ()> { MlStartDatafeed::new(self.transport(), parts) } + #[doc = "[Ml Start Trained Model Deployment API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/start-trained-model-deployment.html)\n\nStart a trained model deployment."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn start_trained_model_deployment<'b>( + &'a self, + parts: MlStartTrainedModelDeploymentParts<'b>, + ) -> MlStartTrainedModelDeployment<'a, 'b, ()> { + MlStartTrainedModelDeployment::new(self.transport(), parts) + } #[doc = "[Ml Stop Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/stop-dfanalytics.html)\n\nStops one or more data frame analytics jobs."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn stop_data_frame_analytics<'b>( &'a self, parts: MlStopDataFrameAnalyticsParts<'b>, @@ -9839,9 +11045,16 @@ impl<'a> Ml<'a> { ) -> MlStopDatafeed<'a, 'b, ()> { MlStopDatafeed::new(self.transport(), parts) } + #[doc = "[Ml Stop Trained Model Deployment API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/stop-trained-model-deployment.html)\n\nStop a trained model deployment."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn stop_trained_model_deployment<'b>( + &'a self, + parts: MlStopTrainedModelDeploymentParts<'b>, + ) -> MlStopTrainedModelDeployment<'a, 'b, ()> { + MlStopTrainedModelDeployment::new(self.transport(), parts) + } #[doc = "[Ml Update Data Frame Analytics API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/update-dfanalytics.html)\n\nUpdates certain properties of a data frame analytics job."] - #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] - #[cfg(feature = "beta-apis")] pub fn update_data_frame_analytics<'b>( &'a self, parts: MlUpdateDataFrameAnalyticsParts<'b>, diff --git a/elasticsearch/src/nodes.rs b/elasticsearch/src/nodes.rs index 1d56a453..809dab58 100644 --- a/elasticsearch/src/nodes.rs +++ b/elasticsearch/src/nodes.rs @@ -45,6 +45,267 @@ use crate::{ use percent_encoding::percent_encode; use serde::Serialize; use std::{borrow::Cow, time::Duration}; +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Nodes Clear Metering Archive API"] +pub enum NodesClearMeteringArchiveParts<'b> { + #[doc = "NodeId and MaxArchiveVersion"] + NodeIdMaxArchiveVersion(&'b [&'b str], i64), +} +#[cfg(feature = "experimental-apis")] +impl<'b> NodesClearMeteringArchiveParts<'b> { + #[doc = "Builds a relative URL path to the Nodes Clear Metering Archive API"] + pub fn url(self) -> Cow<'static, str> { + match self { + NodesClearMeteringArchiveParts::NodeIdMaxArchiveVersion( + ref node_id, + ref max_archive_version, + ) => { + let node_id_str = node_id.join(","); + let max_archive_version_str = max_archive_version.to_string(); + let encoded_node_id: Cow = + percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into(); + let encoded_max_archive_version: Cow = + percent_encode(max_archive_version_str.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 32usize + encoded_node_id.len() + encoded_max_archive_version.len(), + ); + p.push_str("/_nodes/"); + p.push_str(encoded_node_id.as_ref()); + p.push_str("/_repositories_metering/"); + p.push_str(encoded_max_archive_version.as_ref()); + p.into() + } + } + } +} +#[doc = "Builder for the [Nodes Clear Metering Archive API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/clear-repositories-metering-archive-api.html)\n\nRemoves the archived repositories metering information present in the cluster."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct NodesClearMeteringArchive<'a, 'b> { + transport: &'a Transport, + parts: NodesClearMeteringArchiveParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b> NodesClearMeteringArchive<'a, 'b> { + #[doc = "Creates a new instance of [NodesClearMeteringArchive] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: NodesClearMeteringArchiveParts<'b>) -> Self { + let headers = HeaderMap::new(); + NodesClearMeteringArchive { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Nodes Clear Metering Archive API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Delete; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = Option::<()>::None; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Nodes Get Metering Info API"] +pub enum NodesGetMeteringInfoParts<'b> { + #[doc = "NodeId"] + NodeId(&'b [&'b str]), +} +#[cfg(feature = "experimental-apis")] +impl<'b> NodesGetMeteringInfoParts<'b> { + #[doc = "Builds a relative URL path to the Nodes Get Metering Info API"] + pub fn url(self) -> Cow<'static, str> { + match self { + NodesGetMeteringInfoParts::NodeId(ref 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(31usize + encoded_node_id.len()); + p.push_str("/_nodes/"); + p.push_str(encoded_node_id.as_ref()); + p.push_str("/_repositories_metering"); + p.into() + } + } + } +} +#[doc = "Builder for the [Nodes Get Metering Info API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-repositories-metering-api.html)\n\nReturns cluster repositories metering information."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct NodesGetMeteringInfo<'a, 'b> { + transport: &'a Transport, + parts: NodesGetMeteringInfoParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b> NodesGetMeteringInfo<'a, 'b> { + #[doc = "Creates a new instance of [NodesGetMeteringInfo] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: NodesGetMeteringInfoParts<'b>) -> Self { + let headers = HeaderMap::new(); + NodesGetMeteringInfo { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Nodes Get Metering Info 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] #[doc = "API parts for the Nodes Hot Threads API"] pub enum NodesHotThreadsParts<'b> { @@ -662,6 +923,7 @@ pub struct NodesStats<'a, 'b> { headers: HeaderMap, human: Option, include_segment_file_sizes: Option, + include_unloaded_segments: Option, level: Option, pretty: Option, request_timeout: Option, @@ -685,6 +947,7 @@ impl<'a, 'b> NodesStats<'a, 'b> { groups: None, human: None, include_segment_file_sizes: None, + include_unloaded_segments: None, level: None, pretty: None, request_timeout: None, @@ -738,6 +1001,11 @@ impl<'a, 'b> NodesStats<'a, 'b> { self.include_segment_file_sizes = Some(include_segment_file_sizes); self } + #[doc = "If set to true segment stats will include stats for segments that are not currently loaded into memory"] + pub fn include_unloaded_segments(mut self, include_unloaded_segments: bool) -> Self { + self.include_unloaded_segments = Some(include_unloaded_segments); + self + } #[doc = "Return indices stats aggregated at index, node or shard level"] pub fn level(mut self, level: Level) -> Self { self.level = Some(level); @@ -790,6 +1058,7 @@ impl<'a, 'b> NodesStats<'a, 'b> { groups: Option, human: Option, include_segment_file_sizes: Option, + include_unloaded_segments: Option, level: Option, pretty: Option, source: Option<&'b str>, @@ -806,6 +1075,7 @@ impl<'a, 'b> NodesStats<'a, 'b> { groups: self.groups, human: self.human, include_segment_file_sizes: self.include_segment_file_sizes, + include_unloaded_segments: self.include_unloaded_segments, level: self.level, pretty: self.pretty, source: self.source, @@ -995,6 +1265,24 @@ impl<'a> Nodes<'a> { pub fn transport(&self) -> &Transport { self.transport } + #[doc = "[Nodes Clear Metering Archive API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/clear-repositories-metering-archive-api.html)\n\nRemoves the archived repositories metering information present in the cluster."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn clear_metering_archive<'b>( + &'a self, + parts: NodesClearMeteringArchiveParts<'b>, + ) -> NodesClearMeteringArchive<'a, 'b> { + NodesClearMeteringArchive::new(self.transport(), parts) + } + #[doc = "[Nodes Get Metering Info API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-repositories-metering-api.html)\n\nReturns cluster repositories metering information."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn get_metering_info<'b>( + &'a self, + parts: NodesGetMeteringInfoParts<'b>, + ) -> NodesGetMeteringInfo<'a, 'b> { + NodesGetMeteringInfo::new(self.transport(), parts) + } #[doc = "[Nodes Hot Threads API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/cluster-nodes-hot-threads.html)\n\nReturns information about hot threads on each node in the cluster."] pub fn hot_threads<'b>(&'a self, parts: NodesHotThreadsParts<'b>) -> NodesHotThreads<'a, 'b> { NodesHotThreads::new(self.transport(), parts) diff --git a/elasticsearch/src/params.rs b/elasticsearch/src/params.rs index 9057dd10..65adf30f 100644 --- a/elasticsearch/src/params.rs +++ b/elasticsearch/src/params.rs @@ -82,8 +82,6 @@ pub enum ExpandWildcards { All, } #[doc = "Optional parameter to specify the high level file format"] -#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] -#[cfg(feature = "experimental-apis")] #[derive(Debug, PartialEq, Deserialize, Serialize, Clone, Copy)] pub enum Format { #[serde(rename = "ndjson")] @@ -95,6 +93,16 @@ pub enum Format { #[serde(rename = "semi_structured_text")] SemiStructuredText, } +#[doc = "Determines the geometry type for features in the aggs layer."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Debug, PartialEq, Deserialize, Serialize, Clone, Copy)] +pub enum GridType { + #[serde(rename = "grid")] + Grid, + #[serde(rename = "point")] + Point, +} #[doc = "Group tasks by nodes or parent/child relationships"] #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] #[cfg(feature = "experimental-apis")] diff --git a/elasticsearch/src/rollup.rs b/elasticsearch/src/rollup.rs index 4c55b87b..661454cd 100644 --- a/elasticsearch/src/rollup.rs +++ b/elasticsearch/src/rollup.rs @@ -30,6 +30,8 @@ //! provide a means to summarize and store historical data so that it can still be used for analysis, but at a fraction of //! the storage cost of raw data. +#![cfg(feature = "experimental-apis")] +#![doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] #![allow(unused_imports)] use crate::{ client::Elasticsearch, @@ -692,12 +694,14 @@ where Ok(response) } } +#[cfg(feature = "experimental-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Rollup Rollup API"] pub enum RollupRollupParts<'b> { #[doc = "Index and RollupIndex"] IndexRollupIndex(&'b str, &'b str), } +#[cfg(feature = "experimental-apis")] impl<'b> RollupRollupParts<'b> { #[doc = "Builds a relative URL path to the Rollup Rollup API"] pub fn url(self) -> Cow<'static, str> { @@ -719,7 +723,9 @@ impl<'b> RollupRollupParts<'b> { } } } -#[doc = "Builder for the [Rollup Rollup API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/rollup-api.html)\n\nRollup an index"] +#[doc = "Builder for the [Rollup Rollup API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/xpack-rollup.html)\n\nRollup an index"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] #[derive(Clone, Debug)] pub struct RollupRollup<'a, 'b, B> { transport: &'a Transport, @@ -733,6 +739,7 @@ pub struct RollupRollup<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } +#[cfg(feature = "experimental-apis")] impl<'a, 'b, B> RollupRollup<'a, 'b, B> where B: Body, @@ -1342,9 +1349,12 @@ where } } #[doc = "Namespace client for Rollup APIs"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] pub struct Rollup<'a> { transport: &'a Transport, } +#[cfg(feature = "experimental-apis")] impl<'a> Rollup<'a> { #[doc = "Creates a new instance of [Rollup]"] pub fn new(transport: &'a Transport) -> Self { @@ -1389,7 +1399,9 @@ impl<'a> Rollup<'a> { pub fn put_job<'b>(&'a self, parts: RollupPutJobParts<'b>) -> RollupPutJob<'a, 'b, ()> { RollupPutJob::new(self.transport(), parts) } - #[doc = "[Rollup Rollup API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/rollup-api.html)\n\nRollup an index"] + #[doc = "[Rollup Rollup API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/xpack-rollup.html)\n\nRollup an index"] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] pub fn rollup<'b>(&'a self, parts: RollupRollupParts<'b>) -> RollupRollup<'a, 'b, ()> { RollupRollup::new(self.transport(), parts) } @@ -1415,6 +1427,7 @@ impl<'a> Rollup<'a> { RollupStopJob::new(self.transport(), parts) } } +#[cfg(feature = "experimental-apis")] impl Elasticsearch { #[doc = "Creates a namespace client for Rollup APIs"] pub fn rollup(&self) -> Rollup { diff --git a/elasticsearch/src/root/mod.rs b/elasticsearch/src/root/mod.rs index 862a3a34..31406533 100644 --- a/elasticsearch/src/root/mod.rs +++ b/elasticsearch/src/root/mod.rs @@ -6165,7 +6165,7 @@ impl<'b> RenderSearchTemplateParts<'b> { } } } -#[doc = "Builder for the [Render Search Template API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/search-template.html#_validating_templates)\n\nAllows to use the Mustache language to pre-render a search definition."] +#[doc = "Builder for the [Render Search Template API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/render-search-template-api.html)\n\nAllows to use the Mustache language to pre-render a search definition."] #[derive(Clone, Debug)] pub struct RenderSearchTemplate<'a, 'b, B> { transport: &'a Transport, @@ -7199,6 +7199,231 @@ where Ok(response) } } +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Search Mvt API"] +pub enum SearchMvtParts<'b> { + #[doc = "Index, Field, Zoom, X and Y"] + IndexFieldZoomXY(&'b [&'b str], &'b str, i32, i32, i32), +} +#[cfg(feature = "experimental-apis")] +impl<'b> SearchMvtParts<'b> { + #[doc = "Builds a relative URL path to the Search Mvt API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SearchMvtParts::IndexFieldZoomXY(ref index, ref field, ref zoom, ref x, ref y) => { + let index_str = index.join(","); + let zoom_str = zoom.to_string(); + let x_str = x.to_string(); + let y_str = y.to_string(); + let encoded_index: Cow = + percent_encode(index_str.as_bytes(), PARTS_ENCODED).into(); + let encoded_field: Cow = + percent_encode(field.as_bytes(), PARTS_ENCODED).into(); + let encoded_zoom: Cow = + percent_encode(zoom_str.as_bytes(), PARTS_ENCODED).into(); + let encoded_x: Cow = percent_encode(x_str.as_bytes(), PARTS_ENCODED).into(); + let encoded_y: Cow = percent_encode(y_str.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 10usize + + encoded_index.len() + + encoded_field.len() + + encoded_zoom.len() + + encoded_x.len() + + encoded_y.len(), + ); + p.push_str("/"); + p.push_str(encoded_index.as_ref()); + p.push_str("/_mvt/"); + p.push_str(encoded_field.as_ref()); + p.push_str("/"); + p.push_str(encoded_zoom.as_ref()); + p.push_str("/"); + p.push_str(encoded_x.as_ref()); + p.push_str("/"); + p.push_str(encoded_y.as_ref()); + p.into() + } + } + } +} +#[doc = "Builder for the [Search Mvt API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/search-vector-tile-api.html)\n\nSearches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct SearchMvt<'a, 'b, B> { + transport: &'a Transport, + parts: SearchMvtParts<'b>, + body: Option, + error_trace: Option, + exact_bounds: Option, + extent: Option, + filter_path: Option<&'b [&'b str]>, + grid_precision: Option, + grid_type: Option, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + size: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b, B> SearchMvt<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SearchMvt] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SearchMvtParts<'b>) -> Self { + let headers = HeaderMap::new(); + SearchMvt { + transport, + parts, + headers, + body: None, + error_trace: None, + exact_bounds: None, + extent: None, + filter_path: None, + grid_precision: None, + grid_type: None, + human: None, + pretty: None, + request_timeout: None, + size: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SearchMvt<'a, 'b, JsonBody> + where + T: Serialize, + { + SearchMvt { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + exact_bounds: self.exact_bounds, + extent: self.extent, + filter_path: self.filter_path, + grid_precision: self.grid_precision, + grid_type: self.grid_type, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + size: self.size, + source: self.source, + } + } + #[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 = "If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation."] + pub fn exact_bounds(mut self, exact_bounds: bool) -> Self { + self.exact_bounds = Some(exact_bounds); + self + } + #[doc = "Size, in pixels, of a side of the vector tile."] + pub fn extent(mut self, extent: i32) -> Self { + self.extent = Some(extent); + 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 = "Additional zoom levels available through the aggs layer. Accepts 0-8."] + pub fn grid_precision(mut self, grid_precision: i32) -> Self { + self.grid_precision = Some(grid_precision); + self + } + #[doc = "Determines the geometry type for features in the aggs layer."] + pub fn grid_type(mut self, grid_type: GridType) -> Self { + self.grid_type = Some(grid_type); + self + } + #[doc = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "Maximum number of features to return in the hits layer. Accepts 0-10000."] + pub fn size(mut self, size: i32) -> Self { + self.size = Some(size); + 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 = "Creates an asynchronous call to the Search Mvt API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = match self.body { + Some(_) => Method::Post, + None => 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, + exact_bounds: Option, + extent: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + grid_precision: Option, + grid_type: Option, + human: Option, + pretty: Option, + size: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + exact_bounds: self.exact_bounds, + extent: self.extent, + filter_path: self.filter_path, + grid_precision: self.grid_precision, + grid_type: self.grid_type, + human: self.human, + pretty: self.pretty, + size: self.size, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Search Shards API"] pub enum SearchShardsParts<'b> { @@ -7692,6 +7917,158 @@ where Ok(response) } } +#[cfg(feature = "beta-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Terms Enum API"] +pub enum TermsEnumParts<'b> { + #[doc = "Index"] + Index(&'b [&'b str]), +} +#[cfg(feature = "beta-apis")] +impl<'b> TermsEnumParts<'b> { + #[doc = "Builds a relative URL path to the Terms Enum API"] + pub fn url(self) -> Cow<'static, str> { + match self { + TermsEnumParts::Index(ref 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(13usize + encoded_index.len()); + p.push_str("/"); + p.push_str(encoded_index.as_ref()); + p.push_str("/_terms_enum"); + p.into() + } + } + } +} +#[doc = "Builder for the [Terms Enum API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/search-terms-enum.html)\n\nThe terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios."] +#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] +#[cfg(feature = "beta-apis")] +#[derive(Clone, Debug)] +pub struct TermsEnum<'a, 'b, B> { + transport: &'a Transport, + parts: TermsEnumParts<'b>, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "beta-apis")] +impl<'a, 'b, B> TermsEnum<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [TermsEnum] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: TermsEnumParts<'b>) -> Self { + let headers = HeaderMap::new(); + TermsEnum { + transport, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> TermsEnum<'a, 'b, JsonBody> + where + T: Serialize, + { + TermsEnum { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Terms Enum API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = match self.body { + Some(_) => Method::Post, + None => 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Termvectors API"] pub enum TermvectorsParts<'b> { @@ -9038,7 +9415,7 @@ impl Elasticsearch { ) -> ReindexRethrottle<'a, 'b, ()> { ReindexRethrottle::new(self.transport(), parts) } - #[doc = "[Render Search Template API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/search-template.html#_validating_templates)\n\nAllows to use the Mustache language to pre-render a search definition."] + #[doc = "[Render Search Template API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/render-search-template-api.html)\n\nAllows to use the Mustache language to pre-render a search definition."] pub fn render_search_template<'a, 'b>( &'a self, parts: RenderSearchTemplateParts<'b>, @@ -9059,6 +9436,12 @@ impl Elasticsearch { pub fn search<'a, 'b>(&'a self, parts: SearchParts<'b>) -> Search<'a, 'b, ()> { Search::new(self.transport(), parts) } + #[doc = "[Search Mvt API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/search-vector-tile-api.html)\n\nSearches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn search_mvt<'a, 'b>(&'a self, parts: SearchMvtParts<'b>) -> SearchMvt<'a, 'b, ()> { + SearchMvt::new(self.transport(), parts) + } #[doc = "[Search Shards API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/search-shards.html)\n\nReturns information about the indices and shards that a search request would be executed against."] pub fn search_shards<'a, 'b>( &'a self, @@ -9073,6 +9456,12 @@ impl Elasticsearch { ) -> SearchTemplate<'a, 'b, ()> { SearchTemplate::new(self.transport(), parts) } + #[doc = "[Terms Enum API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/search-terms-enum.html)\n\nThe terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios."] + #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] + #[cfg(feature = "beta-apis")] + pub fn terms_enum<'a, 'b>(&'a self, parts: TermsEnumParts<'b>) -> TermsEnum<'a, 'b, ()> { + TermsEnum::new(self.transport(), parts) + } #[doc = "[Termvectors API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/docs-termvectors.html)\n\nReturns information and statistics about terms in the fields of a particular document."] pub fn termvectors<'a, 'b>(&'a self, parts: TermvectorsParts<'b>) -> Termvectors<'a, 'b, ()> { Termvectors::new(self.transport(), parts) diff --git a/elasticsearch/src/searchable_snapshots.rs b/elasticsearch/src/searchable_snapshots.rs index 7f0912a0..b72eeb21 100644 --- a/elasticsearch/src/searchable_snapshots.rs +++ b/elasticsearch/src/searchable_snapshots.rs @@ -51,6 +51,135 @@ use serde::Serialize; use std::{borrow::Cow, time::Duration}; #[cfg(feature = "experimental-apis")] #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Searchable Snapshots Cache Stats API"] +pub enum SearchableSnapshotsCacheStatsParts<'b> { + #[doc = "No parts"] + None, + #[doc = "NodeId"] + NodeId(&'b [&'b str]), +} +#[cfg(feature = "experimental-apis")] +impl<'b> SearchableSnapshotsCacheStatsParts<'b> { + #[doc = "Builds a relative URL path to the Searchable Snapshots Cache Stats API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SearchableSnapshotsCacheStatsParts::None => "/_searchable_snapshots/cache/stats".into(), + SearchableSnapshotsCacheStatsParts::NodeId(ref 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(35usize + encoded_node_id.len()); + p.push_str("/_searchable_snapshots/"); + p.push_str(encoded_node_id.as_ref()); + p.push_str("/cache/stats"); + p.into() + } + } + } +} +#[doc = "Builder for the [Searchable Snapshots Cache Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/searchable-snapshots-apis.html)\n\nRetrieve node-level cache statistics about searchable snapshots."] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct SearchableSnapshotsCacheStats<'a, 'b> { + transport: &'a Transport, + parts: SearchableSnapshotsCacheStatsParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b> SearchableSnapshotsCacheStats<'a, 'b> { + #[doc = "Creates a new instance of [SearchableSnapshotsCacheStats] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SearchableSnapshotsCacheStatsParts<'b>) -> Self { + let headers = HeaderMap::new(); + SearchableSnapshotsCacheStats { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Searchable Snapshots Cache Stats 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = Option::<()>::None; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Searchable Snapshots Clear Cache API"] pub enum SearchableSnapshotsClearCacheParts<'b> { #[doc = "No parts"] @@ -455,7 +584,7 @@ impl<'b> SearchableSnapshotsStatsParts<'b> { } } } -#[doc = "Builder for the [Searchable Snapshots Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/searchable-snapshots-apis.html)\n\nRetrieve various statistics about searchable snapshots."] +#[doc = "Builder for the [Searchable Snapshots Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/searchable-snapshots-apis.html)\n\nRetrieve shard-level statistics about searchable snapshots."] #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] #[cfg(feature = "experimental-apis")] #[derive(Clone, Debug)] @@ -580,6 +709,15 @@ impl<'a> SearchableSnapshots<'a> { pub fn transport(&self) -> &Transport { self.transport } + #[doc = "[Searchable Snapshots Cache Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/searchable-snapshots-apis.html)\n\nRetrieve node-level cache statistics about searchable snapshots."] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn cache_stats<'b>( + &'a self, + parts: SearchableSnapshotsCacheStatsParts<'b>, + ) -> SearchableSnapshotsCacheStats<'a, 'b> { + SearchableSnapshotsCacheStats::new(self.transport(), parts) + } #[doc = "[Searchable Snapshots Clear Cache API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/searchable-snapshots-apis.html)\n\nClear the cache of searchable snapshots."] #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] #[cfg(feature = "experimental-apis")] @@ -598,7 +736,7 @@ impl<'a> SearchableSnapshots<'a> { ) -> SearchableSnapshotsMount<'a, 'b, ()> { SearchableSnapshotsMount::new(self.transport(), parts) } - #[doc = "[Searchable Snapshots Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/searchable-snapshots-apis.html)\n\nRetrieve various statistics about searchable snapshots."] + #[doc = "[Searchable Snapshots Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/searchable-snapshots-apis.html)\n\nRetrieve shard-level statistics about searchable snapshots."] #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] #[cfg(feature = "experimental-apis")] pub fn stats<'b>( diff --git a/elasticsearch/src/security.rs b/elasticsearch/src/security.rs index 244fe994..9eefaaee 100644 --- a/elasticsearch/src/security.rs +++ b/elasticsearch/src/security.rs @@ -908,62 +908,88 @@ where Ok(response) } } +#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Create Api Key API"] -pub enum SecurityCreateApiKeyParts { - #[doc = "No parts"] - None, +#[doc = "API parts for the Security Clear Cached Service Tokens API"] +pub enum SecurityClearCachedServiceTokensParts<'b> { + #[doc = "Namespace, Service and Name"] + NamespaceServiceName(&'b str, &'b str, &'b [&'b str]), } -impl SecurityCreateApiKeyParts { - #[doc = "Builds a relative URL path to the Security Create Api Key API"] +#[cfg(feature = "beta-apis")] +impl<'b> SecurityClearCachedServiceTokensParts<'b> { + #[doc = "Builds a relative URL path to the Security Clear Cached Service Tokens API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityCreateApiKeyParts::None => "/_security/api_key".into(), + SecurityClearCachedServiceTokensParts::NamespaceServiceName( + ref namespace, + ref service, + ref name, + ) => { + let name_str = name.join(","); + let encoded_namespace: Cow = + percent_encode(namespace.as_bytes(), PARTS_ENCODED).into(); + let encoded_service: Cow = + percent_encode(service.as_bytes(), PARTS_ENCODED).into(); + let encoded_name: Cow = + percent_encode(name_str.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 51usize + encoded_namespace.len() + encoded_service.len() + encoded_name.len(), + ); + p.push_str("/_security/service/"); + p.push_str(encoded_namespace.as_ref()); + p.push_str("/"); + p.push_str(encoded_service.as_ref()); + p.push_str("/credential/token/"); + p.push_str(encoded_name.as_ref()); + p.push_str("/_clear_cache"); + p.into() + } } } } -#[doc = "Builder for the [Security Create Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-create-api-key.html)\n\nCreates an API key for access without requiring basic authentication."] +#[doc = "Builder for the [Security Clear Cached Service Tokens API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-clear-service-token-caches.html)\n\nEvicts tokens from the service account token caches."] +#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] +#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] -pub struct SecurityCreateApiKey<'a, 'b, B> { +pub struct SecurityClearCachedServiceTokens<'a, 'b, B> { transport: &'a Transport, - parts: SecurityCreateApiKeyParts, + parts: SecurityClearCachedServiceTokensParts<'b>, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, - refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityCreateApiKey<'a, 'b, B> +#[cfg(feature = "beta-apis")] +impl<'a, 'b, B> SecurityClearCachedServiceTokens<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityCreateApiKey]"] - pub fn new(transport: &'a Transport) -> Self { + #[doc = "Creates a new instance of [SecurityClearCachedServiceTokens] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityClearCachedServiceTokensParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityCreateApiKey { + SecurityClearCachedServiceTokens { transport, - parts: SecurityCreateApiKeyParts::None, + parts, headers, body: None, error_trace: None, filter_path: None, human: None, pretty: None, - refresh: None, request_timeout: None, source: None, } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityCreateApiKey<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecurityClearCachedServiceTokens<'a, 'b, JsonBody> where T: Serialize, { - SecurityCreateApiKey { + SecurityClearCachedServiceTokens { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -972,7 +998,6 @@ where headers: self.headers, human: self.human, pretty: self.pretty, - refresh: self.refresh, request_timeout: self.request_timeout, source: self.source, } @@ -1002,11 +1027,6 @@ where self.pretty = Some(pretty); self } - #[doc = "If `true` (the default) 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` then do nothing with refreshes."] - pub fn refresh(mut self, refresh: Refresh) -> Self { - self.refresh = Some(refresh); - 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); @@ -1017,7 +1037,7 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Create Api Key API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Clear Cached Service Tokens API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Post; @@ -1032,7 +1052,6 @@ where filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, - refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -1040,7 +1059,6 @@ where filter_path: self.filter_path, human: self.human, pretty: self.pretty, - refresh: self.refresh, source: self.source, }; Some(query_params) @@ -1054,35 +1072,25 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Delete Privileges API"] -pub enum SecurityDeletePrivilegesParts<'b> { - #[doc = "Application and Name"] - ApplicationName(&'b str, &'b str), +#[doc = "API parts for the Security Create Api Key API"] +pub enum SecurityCreateApiKeyParts { + #[doc = "No parts"] + None, } -impl<'b> SecurityDeletePrivilegesParts<'b> { - #[doc = "Builds a relative URL path to the Security Delete Privileges API"] +impl SecurityCreateApiKeyParts { + #[doc = "Builds a relative URL path to the Security Create Api Key API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityDeletePrivilegesParts::ApplicationName(ref application, ref name) => { - let encoded_application: Cow = - percent_encode(application.as_bytes(), PARTS_ENCODED).into(); - let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); - let mut p = - String::with_capacity(22usize + encoded_application.len() + encoded_name.len()); - p.push_str("/_security/privilege/"); - p.push_str(encoded_application.as_ref()); - p.push_str("/"); - p.push_str(encoded_name.as_ref()); - p.into() - } + SecurityCreateApiKeyParts::None => "/_security/api_key".into(), } } } -#[doc = "Builder for the [Security Delete Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-privilege.html)\n\nRemoves application privileges."] +#[doc = "Builder for the [Security Create Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-create-api-key.html)\n\nCreates an API key for access without requiring basic authentication."] #[derive(Clone, Debug)] -pub struct SecurityDeletePrivileges<'a, 'b> { +pub struct SecurityCreateApiKey<'a, 'b, B> { transport: &'a Transport, - parts: SecurityDeletePrivilegesParts<'b>, + parts: SecurityCreateApiKeyParts, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -1092,14 +1100,18 @@ pub struct SecurityDeletePrivileges<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityDeletePrivileges<'a, 'b> { - #[doc = "Creates a new instance of [SecurityDeletePrivileges] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityDeletePrivilegesParts<'b>) -> Self { +impl<'a, 'b, B> SecurityCreateApiKey<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityCreateApiKey]"] + pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityDeletePrivileges { + SecurityCreateApiKey { transport, - parts, + parts: SecurityCreateApiKeyParts::None, headers, + body: None, error_trace: None, filter_path: None, human: None, @@ -1109,6 +1121,25 @@ impl<'a, 'b> SecurityDeletePrivileges<'a, 'b> { source: None, } } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityCreateApiKey<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityCreateApiKey { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + request_timeout: self.request_timeout, + source: self.source, + } + } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -1149,10 +1180,10 @@ impl<'a, 'b> SecurityDeletePrivileges<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Delete Privileges API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Create Api Key API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Delete; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -1177,7 +1208,7 @@ impl<'a, 'b> SecurityDeletePrivileges<'a, 'b> { }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -1185,31 +1216,67 @@ impl<'a, 'b> SecurityDeletePrivileges<'a, 'b> { Ok(response) } } +#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Delete Role API"] -pub enum SecurityDeleteRoleParts<'b> { - #[doc = "Name"] - Name(&'b str), +#[doc = "API parts for the Security Create Service Token API"] +pub enum SecurityCreateServiceTokenParts<'b> { + #[doc = "Namespace, Service and Name"] + NamespaceServiceName(&'b str, &'b str, &'b str), + #[doc = "Namespace and Service"] + NamespaceService(&'b str, &'b str), } -impl<'b> SecurityDeleteRoleParts<'b> { - #[doc = "Builds a relative URL path to the Security Delete Role API"] +#[cfg(feature = "beta-apis")] +impl<'b> SecurityCreateServiceTokenParts<'b> { + #[doc = "Builds a relative URL path to the Security Create Service Token API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityDeleteRoleParts::Name(ref name) => { + SecurityCreateServiceTokenParts::NamespaceServiceName( + ref namespace, + ref service, + ref name, + ) => { + let encoded_namespace: Cow = + percent_encode(namespace.as_bytes(), PARTS_ENCODED).into(); + let encoded_service: Cow = + percent_encode(service.as_bytes(), PARTS_ENCODED).into(); let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(16usize + encoded_name.len()); - p.push_str("/_security/role/"); + let mut p = String::with_capacity( + 38usize + encoded_namespace.len() + encoded_service.len() + encoded_name.len(), + ); + p.push_str("/_security/service/"); + p.push_str(encoded_namespace.as_ref()); + p.push_str("/"); + p.push_str(encoded_service.as_ref()); + p.push_str("/credential/token/"); p.push_str(encoded_name.as_ref()); p.into() } + SecurityCreateServiceTokenParts::NamespaceService(ref namespace, ref service) => { + let encoded_namespace: Cow = + percent_encode(namespace.as_bytes(), PARTS_ENCODED).into(); + let encoded_service: Cow = + percent_encode(service.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 37usize + encoded_namespace.len() + encoded_service.len(), + ); + p.push_str("/_security/service/"); + p.push_str(encoded_namespace.as_ref()); + p.push_str("/"); + p.push_str(encoded_service.as_ref()); + p.push_str("/credential/token"); + p.into() + } } } } -#[doc = "Builder for the [Security Delete Role API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-role.html)\n\nRemoves roles in the native realm."] +#[doc = "Builder for the [Security Create Service Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-create-service-token.html)\n\nCreates a service account token for access without requiring basic authentication."] +#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] +#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] -pub struct SecurityDeleteRole<'a, 'b> { +pub struct SecurityCreateServiceToken<'a, 'b, B> { transport: &'a Transport, - parts: SecurityDeleteRoleParts<'b>, + parts: SecurityCreateServiceTokenParts<'b>, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -1219,14 +1286,19 @@ pub struct SecurityDeleteRole<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityDeleteRole<'a, 'b> { - #[doc = "Creates a new instance of [SecurityDeleteRole] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityDeleteRoleParts<'b>) -> Self { +#[cfg(feature = "beta-apis")] +impl<'a, 'b, B> SecurityCreateServiceToken<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityCreateServiceToken] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityCreateServiceTokenParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityDeleteRole { + SecurityCreateServiceToken { transport, parts, headers, + body: None, error_trace: None, filter_path: None, human: None, @@ -1236,6 +1308,25 @@ impl<'a, 'b> SecurityDeleteRole<'a, 'b> { source: None, } } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityCreateServiceToken<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityCreateServiceToken { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + request_timeout: self.request_timeout, + source: self.source, + } + } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -1261,7 +1352,7 @@ impl<'a, 'b> SecurityDeleteRole<'a, 'b> { self.pretty = Some(pretty); self } - #[doc = "If `true` (the default) 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` then do nothing with refreshes."] + #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes."] pub fn refresh(mut self, refresh: Refresh) -> Self { self.refresh = Some(refresh); self @@ -1276,10 +1367,10 @@ impl<'a, 'b> SecurityDeleteRole<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Delete Role API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Create Service Token API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Delete; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -1304,7 +1395,7 @@ impl<'a, 'b> SecurityDeleteRole<'a, 'b> { }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -1313,30 +1404,35 @@ impl<'a, 'b> SecurityDeleteRole<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Delete Role Mapping API"] -pub enum SecurityDeleteRoleMappingParts<'b> { - #[doc = "Name"] - Name(&'b str), +#[doc = "API parts for the Security Delete Privileges API"] +pub enum SecurityDeletePrivilegesParts<'b> { + #[doc = "Application and Name"] + ApplicationName(&'b str, &'b str), } -impl<'b> SecurityDeleteRoleMappingParts<'b> { - #[doc = "Builds a relative URL path to the Security Delete Role Mapping API"] +impl<'b> SecurityDeletePrivilegesParts<'b> { + #[doc = "Builds a relative URL path to the Security Delete Privileges API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityDeleteRoleMappingParts::Name(ref name) => { + SecurityDeletePrivilegesParts::ApplicationName(ref application, ref name) => { + let encoded_application: Cow = + percent_encode(application.as_bytes(), PARTS_ENCODED).into(); let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(24usize + encoded_name.len()); - p.push_str("/_security/role_mapping/"); + let mut p = + String::with_capacity(22usize + encoded_application.len() + encoded_name.len()); + p.push_str("/_security/privilege/"); + p.push_str(encoded_application.as_ref()); + p.push_str("/"); p.push_str(encoded_name.as_ref()); p.into() } } } } -#[doc = "Builder for the [Security Delete Role Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-role-mapping.html)\n\nRemoves role mappings."] +#[doc = "Builder for the [Security Delete Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-privilege.html)\n\nRemoves application privileges."] #[derive(Clone, Debug)] -pub struct SecurityDeleteRoleMapping<'a, 'b> { +pub struct SecurityDeletePrivileges<'a, 'b> { transport: &'a Transport, - parts: SecurityDeleteRoleMappingParts<'b>, + parts: SecurityDeletePrivilegesParts<'b>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -1346,11 +1442,11 @@ pub struct SecurityDeleteRoleMapping<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityDeleteRoleMapping<'a, 'b> { - #[doc = "Creates a new instance of [SecurityDeleteRoleMapping] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityDeleteRoleMappingParts<'b>) -> Self { +impl<'a, 'b> SecurityDeletePrivileges<'a, 'b> { + #[doc = "Creates a new instance of [SecurityDeletePrivileges] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityDeletePrivilegesParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityDeleteRoleMapping { + SecurityDeletePrivileges { transport, parts, headers, @@ -1403,7 +1499,7 @@ impl<'a, 'b> SecurityDeleteRoleMapping<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Delete Role Mapping API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Delete Privileges API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Delete; @@ -1440,31 +1536,30 @@ impl<'a, 'b> SecurityDeleteRoleMapping<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Delete User API"] -pub enum SecurityDeleteUserParts<'b> { - #[doc = "Username"] - Username(&'b str), +#[doc = "API parts for the Security Delete Role API"] +pub enum SecurityDeleteRoleParts<'b> { + #[doc = "Name"] + Name(&'b str), } -impl<'b> SecurityDeleteUserParts<'b> { - #[doc = "Builds a relative URL path to the Security Delete User API"] +impl<'b> SecurityDeleteRoleParts<'b> { + #[doc = "Builds a relative URL path to the Security Delete Role API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityDeleteUserParts::Username(ref username) => { - let encoded_username: Cow = - percent_encode(username.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(16usize + encoded_username.len()); - p.push_str("/_security/user/"); - p.push_str(encoded_username.as_ref()); + SecurityDeleteRoleParts::Name(ref name) => { + let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(16usize + encoded_name.len()); + p.push_str("/_security/role/"); + p.push_str(encoded_name.as_ref()); p.into() } } } } -#[doc = "Builder for the [Security Delete User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-user.html)\n\nDeletes users from the native realm."] +#[doc = "Builder for the [Security Delete Role API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-role.html)\n\nRemoves roles in the native realm."] #[derive(Clone, Debug)] -pub struct SecurityDeleteUser<'a, 'b> { +pub struct SecurityDeleteRole<'a, 'b> { transport: &'a Transport, - parts: SecurityDeleteUserParts<'b>, + parts: SecurityDeleteRoleParts<'b>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -1474,11 +1569,11 @@ pub struct SecurityDeleteUser<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityDeleteUser<'a, 'b> { - #[doc = "Creates a new instance of [SecurityDeleteUser] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityDeleteUserParts<'b>) -> Self { +impl<'a, 'b> SecurityDeleteRole<'a, 'b> { + #[doc = "Creates a new instance of [SecurityDeleteRole] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityDeleteRoleParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityDeleteUser { + SecurityDeleteRole { transport, parts, headers, @@ -1531,7 +1626,7 @@ impl<'a, 'b> SecurityDeleteUser<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Delete User API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Delete Role API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Delete; @@ -1568,33 +1663,30 @@ impl<'a, 'b> SecurityDeleteUser<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Disable User API"] -pub enum SecurityDisableUserParts<'b> { - #[doc = "Username"] - Username(&'b str), +#[doc = "API parts for the Security Delete Role Mapping API"] +pub enum SecurityDeleteRoleMappingParts<'b> { + #[doc = "Name"] + Name(&'b str), } -impl<'b> SecurityDisableUserParts<'b> { - #[doc = "Builds a relative URL path to the Security Disable User API"] +impl<'b> SecurityDeleteRoleMappingParts<'b> { + #[doc = "Builds a relative URL path to the Security Delete Role Mapping API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityDisableUserParts::Username(ref username) => { - let encoded_username: Cow = - percent_encode(username.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(25usize + encoded_username.len()); - p.push_str("/_security/user/"); - p.push_str(encoded_username.as_ref()); - p.push_str("/_disable"); - p.into() - } - } + SecurityDeleteRoleMappingParts::Name(ref name) => { + let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(24usize + encoded_name.len()); + p.push_str("/_security/role_mapping/"); + p.push_str(encoded_name.as_ref()); + p.into() + } + } } } -#[doc = "Builder for the [Security Disable User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-disable-user.html)\n\nDisables users in the native realm."] +#[doc = "Builder for the [Security Delete Role Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-role-mapping.html)\n\nRemoves role mappings."] #[derive(Clone, Debug)] -pub struct SecurityDisableUser<'a, 'b, B> { +pub struct SecurityDeleteRoleMapping<'a, 'b> { transport: &'a Transport, - parts: SecurityDisableUserParts<'b>, - body: Option, + parts: SecurityDeleteRoleMappingParts<'b>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -1604,18 +1696,14 @@ pub struct SecurityDisableUser<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityDisableUser<'a, 'b, B> -where - B: Body, -{ - #[doc = "Creates a new instance of [SecurityDisableUser] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityDisableUserParts<'b>) -> Self { +impl<'a, 'b> SecurityDeleteRoleMapping<'a, 'b> { + #[doc = "Creates a new instance of [SecurityDeleteRoleMapping] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityDeleteRoleMappingParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityDisableUser { + SecurityDeleteRoleMapping { transport, parts, headers, - body: None, error_trace: None, filter_path: None, human: None, @@ -1625,25 +1713,6 @@ where source: None, } } - #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityDisableUser<'a, 'b, JsonBody> - where - T: Serialize, - { - SecurityDisableUser { - transport: self.transport, - parts: self.parts, - body: Some(body.into()), - error_trace: self.error_trace, - filter_path: self.filter_path, - headers: self.headers, - human: self.human, - pretty: self.pretty, - refresh: self.refresh, - request_timeout: self.request_timeout, - source: self.source, - } - } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -1684,10 +1753,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Disable User API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Delete Role Mapping API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Post; + let method = Method::Delete; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -1712,7 +1781,7 @@ where }; Some(query_params) }; - let body = self.body; + let body = Option::<()>::None; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -1720,34 +1789,49 @@ where Ok(response) } } +#[cfg(feature = "beta-apis")] #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Enable User API"] -pub enum SecurityEnableUserParts<'b> { - #[doc = "Username"] - Username(&'b str), +#[doc = "API parts for the Security Delete Service Token API"] +pub enum SecurityDeleteServiceTokenParts<'b> { + #[doc = "Namespace, Service and Name"] + NamespaceServiceName(&'b str, &'b str, &'b str), } -impl<'b> SecurityEnableUserParts<'b> { - #[doc = "Builds a relative URL path to the Security Enable User API"] +#[cfg(feature = "beta-apis")] +impl<'b> SecurityDeleteServiceTokenParts<'b> { + #[doc = "Builds a relative URL path to the Security Delete Service Token API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityEnableUserParts::Username(ref username) => { - let encoded_username: Cow = - percent_encode(username.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(24usize + encoded_username.len()); - p.push_str("/_security/user/"); - p.push_str(encoded_username.as_ref()); - p.push_str("/_enable"); + SecurityDeleteServiceTokenParts::NamespaceServiceName( + ref namespace, + ref service, + ref name, + ) => { + let encoded_namespace: Cow = + percent_encode(namespace.as_bytes(), PARTS_ENCODED).into(); + let encoded_service: Cow = + percent_encode(service.as_bytes(), PARTS_ENCODED).into(); + let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 38usize + encoded_namespace.len() + encoded_service.len() + encoded_name.len(), + ); + p.push_str("/_security/service/"); + p.push_str(encoded_namespace.as_ref()); + p.push_str("/"); + p.push_str(encoded_service.as_ref()); + p.push_str("/credential/token/"); + p.push_str(encoded_name.as_ref()); p.into() } } } } -#[doc = "Builder for the [Security Enable User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-enable-user.html)\n\nEnables users in the native realm."] +#[doc = "Builder for the [Security Delete Service Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-service-token.html)\n\nDeletes a service account token."] +#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] +#[cfg(feature = "beta-apis")] #[derive(Clone, Debug)] -pub struct SecurityEnableUser<'a, 'b, B> { +pub struct SecurityDeleteServiceToken<'a, 'b> { transport: &'a Transport, - parts: SecurityEnableUserParts<'b>, - body: Option, + parts: SecurityDeleteServiceTokenParts<'b>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -1757,18 +1841,15 @@ pub struct SecurityEnableUser<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityEnableUser<'a, 'b, B> -where - B: Body, -{ - #[doc = "Creates a new instance of [SecurityEnableUser] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityEnableUserParts<'b>) -> Self { +#[cfg(feature = "beta-apis")] +impl<'a, 'b> SecurityDeleteServiceToken<'a, 'b> { + #[doc = "Creates a new instance of [SecurityDeleteServiceToken] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityDeleteServiceTokenParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityEnableUser { + SecurityDeleteServiceToken { transport, parts, headers, - body: None, error_trace: None, filter_path: None, human: None, @@ -1778,25 +1859,6 @@ where source: None, } } - #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityEnableUser<'a, 'b, JsonBody> - where - T: Serialize, - { - SecurityEnableUser { - transport: self.transport, - parts: self.parts, - body: Some(body.into()), - error_trace: self.error_trace, - filter_path: self.filter_path, - headers: self.headers, - human: self.human, - pretty: self.pretty, - refresh: self.refresh, - request_timeout: self.request_timeout, - source: self.source, - } - } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -1822,7 +1884,7 @@ where self.pretty = Some(pretty); self } - #[doc = "If `true` (the default) 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` then do nothing with refreshes."] + #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes."] pub fn refresh(mut self, refresh: Refresh) -> Self { self.refresh = Some(refresh); self @@ -1837,10 +1899,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Enable User API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Delete Service Token API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Post; + let method = Method::Delete; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -1865,7 +1927,7 @@ where }; Some(query_params) }; - let body = self.body; + let body = Option::<()>::None; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -1874,56 +1936,55 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Get Api Key API"] -pub enum SecurityGetApiKeyParts { - #[doc = "No parts"] - None, +#[doc = "API parts for the Security Delete User API"] +pub enum SecurityDeleteUserParts<'b> { + #[doc = "Username"] + Username(&'b str), } -impl SecurityGetApiKeyParts { - #[doc = "Builds a relative URL path to the Security Get Api Key API"] +impl<'b> SecurityDeleteUserParts<'b> { + #[doc = "Builds a relative URL path to the Security Delete User API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGetApiKeyParts::None => "/_security/api_key".into(), + SecurityDeleteUserParts::Username(ref username) => { + let encoded_username: Cow = + percent_encode(username.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(16usize + encoded_username.len()); + p.push_str("/_security/user/"); + p.push_str(encoded_username.as_ref()); + p.into() + } } } } -#[doc = "Builder for the [Security Get Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-api-key.html)\n\nRetrieves information for one or more API keys."] +#[doc = "Builder for the [Security Delete User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-user.html)\n\nDeletes users from the native realm."] #[derive(Clone, Debug)] -pub struct SecurityGetApiKey<'a, 'b> { +pub struct SecurityDeleteUser<'a, 'b> { transport: &'a Transport, - parts: SecurityGetApiKeyParts, + parts: SecurityDeleteUserParts<'b>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, - id: Option<&'b str>, - name: Option<&'b str>, - owner: Option, pretty: Option, - realm_name: Option<&'b str>, + refresh: Option, request_timeout: Option, source: Option<&'b str>, - username: Option<&'b str>, } -impl<'a, 'b> SecurityGetApiKey<'a, 'b> { - #[doc = "Creates a new instance of [SecurityGetApiKey]"] - pub fn new(transport: &'a Transport) -> Self { +impl<'a, 'b> SecurityDeleteUser<'a, 'b> { + #[doc = "Creates a new instance of [SecurityDeleteUser] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityDeleteUserParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityGetApiKey { + SecurityDeleteUser { transport, - parts: SecurityGetApiKeyParts::None, + parts, headers, error_trace: None, filter_path: None, human: None, - id: None, - name: None, - owner: None, pretty: None, - realm_name: None, + refresh: None, request_timeout: None, source: None, - username: None, } } #[doc = "Include the stack trace of returned errors."] @@ -1946,29 +2007,14 @@ impl<'a, 'b> SecurityGetApiKey<'a, 'b> { self.human = Some(human); self } - #[doc = "API key id of the API key to be retrieved"] - pub fn id(mut self, id: &'b str) -> Self { - self.id = Some(id); - self - } - #[doc = "API key name of the API key to be retrieved"] - pub fn name(mut self, name: &'b str) -> Self { - self.name = Some(name); - self - } - #[doc = "flag to query API keys owned by the currently authenticated user"] - pub fn owner(mut self, owner: bool) -> Self { - self.owner = Some(owner); - self - } #[doc = "Pretty format the returned JSON response."] pub fn pretty(mut self, pretty: bool) -> Self { self.pretty = Some(pretty); self } - #[doc = "realm name of the user who created this API key to be retrieved"] - pub fn realm_name(mut self, realm_name: &'b str) -> Self { - self.realm_name = Some(realm_name); + #[doc = "If `true` (the default) 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` then do nothing with refreshes."] + pub fn refresh(mut self, refresh: Refresh) -> Self { + self.refresh = Some(refresh); 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."] @@ -1981,15 +2027,10 @@ impl<'a, 'b> SecurityGetApiKey<'a, 'b> { self.source = Some(source); self } - #[doc = "user name of the user who created this API key to be retrieved"] - pub fn username(mut self, username: &'b str) -> Self { - self.username = Some(username); - self - } - #[doc = "Creates an asynchronous call to the Security Get Api Key API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Delete User API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = Method::Delete; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -2000,25 +2041,17 @@ impl<'a, 'b> SecurityGetApiKey<'a, 'b> { #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, human: Option, - id: Option<&'b str>, - name: Option<&'b str>, - owner: Option, pretty: Option, - realm_name: Option<&'b str>, + refresh: Option, source: Option<&'b str>, - username: Option<&'b str>, } let query_params = QueryParams { error_trace: self.error_trace, filter_path: self.filter_path, human: self.human, - id: self.id, - name: self.name, - owner: self.owner, pretty: self.pretty, - realm_name: self.realm_name, + refresh: self.refresh, source: self.source, - username: self.username, }; Some(query_params) }; @@ -2031,63 +2064,1914 @@ impl<'a, 'b> SecurityGetApiKey<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Get Builtin Privileges API"] -pub enum SecurityGetBuiltinPrivilegesParts { - #[doc = "No parts"] - None, +#[doc = "API parts for the Security Disable User API"] +pub enum SecurityDisableUserParts<'b> { + #[doc = "Username"] + Username(&'b str), } -impl SecurityGetBuiltinPrivilegesParts { - #[doc = "Builds a relative URL path to the Security Get Builtin Privileges API"] +impl<'b> SecurityDisableUserParts<'b> { + #[doc = "Builds a relative URL path to the Security Disable User API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGetBuiltinPrivilegesParts::None => "/_security/privilege/_builtin".into(), + SecurityDisableUserParts::Username(ref username) => { + let encoded_username: Cow = + percent_encode(username.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(25usize + encoded_username.len()); + p.push_str("/_security/user/"); + p.push_str(encoded_username.as_ref()); + p.push_str("/_disable"); + p.into() + } } } } -#[doc = "Builder for the [Security Get Builtin Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-builtin-privileges.html)\n\nRetrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch."] +#[doc = "Builder for the [Security Disable User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-disable-user.html)\n\nDisables users in the native realm."] #[derive(Clone, Debug)] -pub struct SecurityGetBuiltinPrivileges<'a, 'b> { +pub struct SecurityDisableUser<'a, 'b, B> { transport: &'a Transport, - parts: SecurityGetBuiltinPrivilegesParts, + parts: SecurityDisableUserParts<'b>, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, + refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityGetBuiltinPrivileges<'a, 'b> { - #[doc = "Creates a new instance of [SecurityGetBuiltinPrivileges]"] - pub fn new(transport: &'a Transport) -> Self { +impl<'a, 'b, B> SecurityDisableUser<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityDisableUser] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityDisableUserParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityGetBuiltinPrivileges { + SecurityDisableUser { transport, - parts: SecurityGetBuiltinPrivilegesParts::None, + parts, headers, + body: None, error_trace: None, filter_path: None, human: None, pretty: None, + refresh: None, request_timeout: None, source: 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 = "Adds a HTTP header"] - pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { - self.headers.insert(key, value); - self - } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityDisableUser<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityDisableUser { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "If `true` (the default) 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` then do nothing with refreshes."] + pub fn refresh(mut self, refresh: Refresh) -> Self { + self.refresh = Some(refresh); + 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 = "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 = "Creates an asynchronous call to the Security Disable User API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + 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]>, + human: Option, + pretty: Option, + refresh: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Security Enable User API"] +pub enum SecurityEnableUserParts<'b> { + #[doc = "Username"] + Username(&'b str), +} +impl<'b> SecurityEnableUserParts<'b> { + #[doc = "Builds a relative URL path to the Security Enable User API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityEnableUserParts::Username(ref username) => { + let encoded_username: Cow = + percent_encode(username.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(24usize + encoded_username.len()); + p.push_str("/_security/user/"); + p.push_str(encoded_username.as_ref()); + p.push_str("/_enable"); + p.into() + } + } + } +} +#[doc = "Builder for the [Security Enable User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-enable-user.html)\n\nEnables users in the native realm."] +#[derive(Clone, Debug)] +pub struct SecurityEnableUser<'a, 'b, B> { + transport: &'a Transport, + parts: SecurityEnableUserParts<'b>, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + refresh: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> SecurityEnableUser<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityEnableUser] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityEnableUserParts<'b>) -> Self { + let headers = HeaderMap::new(); + SecurityEnableUser { + transport, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + refresh: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityEnableUser<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityEnableUser { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "If `true` (the default) 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` then do nothing with refreshes."] + pub fn refresh(mut self, refresh: Refresh) -> Self { + self.refresh = Some(refresh); + 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 = "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 = "Creates an asynchronous call to the Security Enable User API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + 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]>, + human: Option, + pretty: Option, + refresh: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Security Enroll Kibana API"] +pub enum SecurityEnrollKibanaParts { + #[doc = "No parts"] + None, +} +impl SecurityEnrollKibanaParts { + #[doc = "Builds a relative URL path to the Security Enroll Kibana API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityEnrollKibanaParts::None => "/_security/enroll/kibana".into(), + } + } +} +#[doc = "Builder for the [Security Enroll Kibana API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-kibana-enrollment.html)\n\nAllows a kibana instance to configure itself to communicate with a secured elasticsearch cluster."] +#[derive(Clone, Debug)] +pub struct SecurityEnrollKibana<'a, 'b> { + transport: &'a Transport, + parts: SecurityEnrollKibanaParts, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SecurityEnrollKibana<'a, 'b> { + #[doc = "Creates a new instance of [SecurityEnrollKibana]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + SecurityEnrollKibana { + transport, + parts: SecurityEnrollKibanaParts::None, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Enroll Kibana 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Security Enroll Node API"] +pub enum SecurityEnrollNodeParts { + #[doc = "No parts"] + None, +} +impl SecurityEnrollNodeParts { + #[doc = "Builds a relative URL path to the Security Enroll Node API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityEnrollNodeParts::None => "/_security/enroll/node".into(), + } + } +} +#[doc = "Builder for the [Security Enroll Node API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-node-enrollment.html)\n\nAllows a new node to enroll to an existing cluster with security enabled."] +#[derive(Clone, Debug)] +pub struct SecurityEnrollNode<'a, 'b> { + transport: &'a Transport, + parts: SecurityEnrollNodeParts, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SecurityEnrollNode<'a, 'b> { + #[doc = "Creates a new instance of [SecurityEnrollNode]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + SecurityEnrollNode { + transport, + parts: SecurityEnrollNodeParts::None, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Enroll Node 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Security Get Api Key API"] +pub enum SecurityGetApiKeyParts { + #[doc = "No parts"] + None, +} +impl SecurityGetApiKeyParts { + #[doc = "Builds a relative URL path to the Security Get Api Key API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetApiKeyParts::None => "/_security/api_key".into(), + } + } +} +#[doc = "Builder for the [Security Get Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-api-key.html)\n\nRetrieves information for one or more API keys."] +#[derive(Clone, Debug)] +pub struct SecurityGetApiKey<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetApiKeyParts, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + id: Option<&'b str>, + name: Option<&'b str>, + owner: Option, + pretty: Option, + realm_name: Option<&'b str>, + request_timeout: Option, + source: Option<&'b str>, + username: Option<&'b str>, +} +impl<'a, 'b> SecurityGetApiKey<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetApiKey]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + SecurityGetApiKey { + transport, + parts: SecurityGetApiKeyParts::None, + headers, + error_trace: None, + filter_path: None, + human: None, + id: None, + name: None, + owner: None, + pretty: None, + realm_name: None, + request_timeout: None, + source: None, + username: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "API key id of the API key to be retrieved"] + pub fn id(mut self, id: &'b str) -> Self { + self.id = Some(id); + self + } + #[doc = "API key name of the API key to be retrieved"] + pub fn name(mut self, name: &'b str) -> Self { + self.name = Some(name); + self + } + #[doc = "flag to query API keys owned by the currently authenticated user"] + pub fn owner(mut self, owner: bool) -> Self { + self.owner = Some(owner); + self + } + #[doc = "Pretty format the returned JSON response."] + pub fn pretty(mut self, pretty: bool) -> Self { + self.pretty = Some(pretty); + self + } + #[doc = "realm name of the user who created this API key to be retrieved"] + pub fn realm_name(mut self, realm_name: &'b str) -> Self { + self.realm_name = Some(realm_name); + 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 = "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 = "user name of the user who created this API key to be retrieved"] + pub fn username(mut self, username: &'b str) -> Self { + self.username = Some(username); + self + } + #[doc = "Creates an asynchronous call to the Security Get Api Key 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]>, + human: Option, + id: Option<&'b str>, + name: Option<&'b str>, + owner: Option, + pretty: Option, + realm_name: Option<&'b str>, + source: Option<&'b str>, + username: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + id: self.id, + name: self.name, + owner: self.owner, + pretty: self.pretty, + realm_name: self.realm_name, + source: self.source, + username: self.username, + }; + 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)] +#[doc = "API parts for the Security Get Builtin Privileges API"] +pub enum SecurityGetBuiltinPrivilegesParts { + #[doc = "No parts"] + None, +} +impl SecurityGetBuiltinPrivilegesParts { + #[doc = "Builds a relative URL path to the Security Get Builtin Privileges API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetBuiltinPrivilegesParts::None => "/_security/privilege/_builtin".into(), + } + } +} +#[doc = "Builder for the [Security Get Builtin Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-builtin-privileges.html)\n\nRetrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch."] +#[derive(Clone, Debug)] +pub struct SecurityGetBuiltinPrivileges<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetBuiltinPrivilegesParts, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SecurityGetBuiltinPrivileges<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetBuiltinPrivileges]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + SecurityGetBuiltinPrivileges { + transport, + parts: SecurityGetBuiltinPrivilegesParts::None, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get Builtin Privileges 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Security Get Privileges API"] +pub enum SecurityGetPrivilegesParts<'b> { + #[doc = "No parts"] + None, + #[doc = "Application"] + Application(&'b str), + #[doc = "Application and Name"] + ApplicationName(&'b str, &'b str), +} +impl<'b> SecurityGetPrivilegesParts<'b> { + #[doc = "Builds a relative URL path to the Security Get Privileges API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetPrivilegesParts::None => "/_security/privilege".into(), + SecurityGetPrivilegesParts::Application(ref application) => { + let encoded_application: Cow = + percent_encode(application.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(21usize + encoded_application.len()); + p.push_str("/_security/privilege/"); + p.push_str(encoded_application.as_ref()); + p.into() + } + SecurityGetPrivilegesParts::ApplicationName(ref application, ref name) => { + let encoded_application: Cow = + percent_encode(application.as_bytes(), PARTS_ENCODED).into(); + let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); + let mut p = + String::with_capacity(22usize + encoded_application.len() + encoded_name.len()); + p.push_str("/_security/privilege/"); + p.push_str(encoded_application.as_ref()); + p.push_str("/"); + p.push_str(encoded_name.as_ref()); + p.into() + } + } + } +} +#[doc = "Builder for the [Security Get Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-privileges.html)\n\nRetrieves application privileges."] +#[derive(Clone, Debug)] +pub struct SecurityGetPrivileges<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetPrivilegesParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SecurityGetPrivileges<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetPrivileges] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityGetPrivilegesParts<'b>) -> Self { + let headers = HeaderMap::new(); + SecurityGetPrivileges { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get Privileges 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Security Get Role API"] +pub enum SecurityGetRoleParts<'b> { + #[doc = "Name"] + Name(&'b [&'b str]), + #[doc = "No parts"] + None, +} +impl<'b> SecurityGetRoleParts<'b> { + #[doc = "Builds a relative URL path to the Security Get Role API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetRoleParts::Name(ref 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(16usize + encoded_name.len()); + p.push_str("/_security/role/"); + p.push_str(encoded_name.as_ref()); + p.into() + } + SecurityGetRoleParts::None => "/_security/role".into(), + } + } +} +#[doc = "Builder for the [Security Get Role API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-role.html)\n\nRetrieves roles in the native realm."] +#[derive(Clone, Debug)] +pub struct SecurityGetRole<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetRoleParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SecurityGetRole<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetRole] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityGetRoleParts<'b>) -> Self { + let headers = HeaderMap::new(); + SecurityGetRole { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get Role 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Security Get Role Mapping API"] +pub enum SecurityGetRoleMappingParts<'b> { + #[doc = "Name"] + Name(&'b [&'b str]), + #[doc = "No parts"] + None, +} +impl<'b> SecurityGetRoleMappingParts<'b> { + #[doc = "Builds a relative URL path to the Security Get Role Mapping API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetRoleMappingParts::Name(ref 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(24usize + encoded_name.len()); + p.push_str("/_security/role_mapping/"); + p.push_str(encoded_name.as_ref()); + p.into() + } + SecurityGetRoleMappingParts::None => "/_security/role_mapping".into(), + } + } +} +#[doc = "Builder for the [Security Get Role Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-role-mapping.html)\n\nRetrieves role mappings."] +#[derive(Clone, Debug)] +pub struct SecurityGetRoleMapping<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetRoleMappingParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SecurityGetRoleMapping<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetRoleMapping] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityGetRoleMappingParts<'b>) -> Self { + let headers = HeaderMap::new(); + SecurityGetRoleMapping { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get Role Mapping 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = Option::<()>::None; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[cfg(feature = "beta-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Security Get Service Accounts API"] +pub enum SecurityGetServiceAccountsParts<'b> { + #[doc = "Namespace and Service"] + NamespaceService(&'b str, &'b str), + #[doc = "Namespace"] + Namespace(&'b str), + #[doc = "No parts"] + None, +} +#[cfg(feature = "beta-apis")] +impl<'b> SecurityGetServiceAccountsParts<'b> { + #[doc = "Builds a relative URL path to the Security Get Service Accounts API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetServiceAccountsParts::NamespaceService(ref namespace, ref service) => { + let encoded_namespace: Cow = + percent_encode(namespace.as_bytes(), PARTS_ENCODED).into(); + let encoded_service: Cow = + percent_encode(service.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 20usize + encoded_namespace.len() + encoded_service.len(), + ); + p.push_str("/_security/service/"); + p.push_str(encoded_namespace.as_ref()); + p.push_str("/"); + p.push_str(encoded_service.as_ref()); + p.into() + } + SecurityGetServiceAccountsParts::Namespace(ref namespace) => { + let encoded_namespace: Cow = + percent_encode(namespace.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(19usize + encoded_namespace.len()); + p.push_str("/_security/service/"); + p.push_str(encoded_namespace.as_ref()); + p.into() + } + SecurityGetServiceAccountsParts::None => "/_security/service".into(), + } + } +} +#[doc = "Builder for the [Security Get Service Accounts API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-service-accounts.html)\n\nRetrieves information about service accounts."] +#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] +#[cfg(feature = "beta-apis")] +#[derive(Clone, Debug)] +pub struct SecurityGetServiceAccounts<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetServiceAccountsParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "beta-apis")] +impl<'a, 'b> SecurityGetServiceAccounts<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetServiceAccounts] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityGetServiceAccountsParts<'b>) -> Self { + let headers = HeaderMap::new(); + SecurityGetServiceAccounts { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get Service Accounts 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = Option::<()>::None; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[cfg(feature = "beta-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Security Get Service Credentials API"] +pub enum SecurityGetServiceCredentialsParts<'b> { + #[doc = "Namespace and Service"] + NamespaceService(&'b str, &'b str), +} +#[cfg(feature = "beta-apis")] +impl<'b> SecurityGetServiceCredentialsParts<'b> { + #[doc = "Builds a relative URL path to the Security Get Service Credentials API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetServiceCredentialsParts::NamespaceService(ref namespace, ref service) => { + let encoded_namespace: Cow = + percent_encode(namespace.as_bytes(), PARTS_ENCODED).into(); + let encoded_service: Cow = + percent_encode(service.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 31usize + encoded_namespace.len() + encoded_service.len(), + ); + p.push_str("/_security/service/"); + p.push_str(encoded_namespace.as_ref()); + p.push_str("/"); + p.push_str(encoded_service.as_ref()); + p.push_str("/credential"); + p.into() + } + } + } +} +#[doc = "Builder for the [Security Get Service Credentials API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-service-credentials.html)\n\nRetrieves information of all service credentials for a service account."] +#[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] +#[cfg(feature = "beta-apis")] +#[derive(Clone, Debug)] +pub struct SecurityGetServiceCredentials<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetServiceCredentialsParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "beta-apis")] +impl<'a, 'b> SecurityGetServiceCredentials<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetServiceCredentials] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityGetServiceCredentialsParts<'b>) -> Self { + let headers = HeaderMap::new(); + SecurityGetServiceCredentials { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get Service Credentials 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Security Get Token API"] +pub enum SecurityGetTokenParts { + #[doc = "No parts"] + None, +} +impl SecurityGetTokenParts { + #[doc = "Builds a relative URL path to the Security Get Token API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetTokenParts::None => "/_security/oauth2/token".into(), + } + } +} +#[doc = "Builder for the [Security Get Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-token.html)\n\nCreates a bearer token for access without requiring basic authentication."] +#[derive(Clone, Debug)] +pub struct SecurityGetToken<'a, 'b, B> { + transport: &'a Transport, + parts: SecurityGetTokenParts, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> SecurityGetToken<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityGetToken]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + SecurityGetToken { + transport, + parts: SecurityGetTokenParts::None, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityGetToken<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityGetToken { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get Token API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Security Get User API"] +pub enum SecurityGetUserParts<'b> { + #[doc = "Username"] + Username(&'b [&'b str]), + #[doc = "No parts"] + None, +} +impl<'b> SecurityGetUserParts<'b> { + #[doc = "Builds a relative URL path to the Security Get User API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetUserParts::Username(ref username) => { + let username_str = username.join(","); + let encoded_username: Cow = + percent_encode(username_str.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(16usize + encoded_username.len()); + p.push_str("/_security/user/"); + p.push_str(encoded_username.as_ref()); + p.into() + } + SecurityGetUserParts::None => "/_security/user".into(), + } + } +} +#[doc = "Builder for the [Security Get User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-user.html)\n\nRetrieves information about users in the native realm and built-in users."] +#[derive(Clone, Debug)] +pub struct SecurityGetUser<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetUserParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SecurityGetUser<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetUser] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityGetUserParts<'b>) -> Self { + let headers = HeaderMap::new(); + SecurityGetUser { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get User 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Security Get User Privileges API"] +pub enum SecurityGetUserPrivilegesParts { + #[doc = "No parts"] + None, +} +impl SecurityGetUserPrivilegesParts { + #[doc = "Builds a relative URL path to the Security Get User Privileges API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGetUserPrivilegesParts::None => "/_security/user/_privileges".into(), + } + } +} +#[doc = "Builder for the [Security Get User Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-user-privileges.html)\n\nRetrieves security privileges for the logged in user."] +#[derive(Clone, Debug)] +pub struct SecurityGetUserPrivileges<'a, 'b> { + transport: &'a Transport, + parts: SecurityGetUserPrivilegesParts, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SecurityGetUserPrivileges<'a, 'b> { + #[doc = "Creates a new instance of [SecurityGetUserPrivileges]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + SecurityGetUserPrivileges { + transport, + parts: SecurityGetUserPrivilegesParts::None, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Security Get User Privileges 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Security Grant Api Key API"] +pub enum SecurityGrantApiKeyParts { + #[doc = "No parts"] + None, +} +impl SecurityGrantApiKeyParts { + #[doc = "Builds a relative URL path to the Security Grant Api Key API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGrantApiKeyParts::None => "/_security/api_key/grant".into(), + } + } +} +#[doc = "Builder for the [Security Grant Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-grant-api-key.html)\n\nCreates an API key on behalf of another user."] +#[derive(Clone, Debug)] +pub struct SecurityGrantApiKey<'a, 'b, B> { + transport: &'a Transport, + parts: SecurityGrantApiKeyParts, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + refresh: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> SecurityGrantApiKey<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityGrantApiKey]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + SecurityGrantApiKey { + transport, + parts: SecurityGrantApiKeyParts::None, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + refresh: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityGrantApiKey<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityGrantApiKey { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } #[doc = "Return human readable values for statistics."] pub fn human(mut self, human: bool) -> Self { self.human = Some(human); @@ -2098,6 +3982,11 @@ impl<'a, 'b> SecurityGetBuiltinPrivileges<'a, 'b> { self.pretty = Some(pretty); self } + #[doc = "If `true` (the default) 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` then do nothing with refreshes."] + pub fn refresh(mut self, refresh: Refresh) -> Self { + self.refresh = Some(refresh); + 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); @@ -2108,10 +3997,10 @@ impl<'a, 'b> SecurityGetBuiltinPrivileges<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Get Builtin Privileges API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Grant Api Key API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -2123,6 +4012,7 @@ impl<'a, 'b> SecurityGetBuiltinPrivileges<'a, 'b> { filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, + refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -2130,11 +4020,12 @@ impl<'a, 'b> SecurityGetBuiltinPrivileges<'a, 'b> { filter_path: self.filter_path, human: self.human, pretty: self.pretty, + refresh: self.refresh, source: self.source, }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -2143,48 +4034,35 @@ impl<'a, 'b> SecurityGetBuiltinPrivileges<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Get Privileges API"] -pub enum SecurityGetPrivilegesParts<'b> { +#[doc = "API parts for the Security Has Privileges API"] +pub enum SecurityHasPrivilegesParts<'b> { #[doc = "No parts"] None, - #[doc = "Application"] - Application(&'b str), - #[doc = "Application and Name"] - ApplicationName(&'b str, &'b str), + #[doc = "User"] + User(&'b str), } -impl<'b> SecurityGetPrivilegesParts<'b> { - #[doc = "Builds a relative URL path to the Security Get Privileges API"] +impl<'b> SecurityHasPrivilegesParts<'b> { + #[doc = "Builds a relative URL path to the Security Has Privileges API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGetPrivilegesParts::None => "/_security/privilege".into(), - SecurityGetPrivilegesParts::Application(ref application) => { - let encoded_application: Cow = - percent_encode(application.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(21usize + encoded_application.len()); - p.push_str("/_security/privilege/"); - p.push_str(encoded_application.as_ref()); - p.into() - } - SecurityGetPrivilegesParts::ApplicationName(ref application, ref name) => { - let encoded_application: Cow = - percent_encode(application.as_bytes(), PARTS_ENCODED).into(); - let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); - let mut p = - String::with_capacity(22usize + encoded_application.len() + encoded_name.len()); - p.push_str("/_security/privilege/"); - p.push_str(encoded_application.as_ref()); - p.push_str("/"); - p.push_str(encoded_name.as_ref()); + SecurityHasPrivilegesParts::None => "/_security/user/_has_privileges".into(), + SecurityHasPrivilegesParts::User(ref user) => { + let encoded_user: Cow = percent_encode(user.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(32usize + encoded_user.len()); + p.push_str("/_security/user/"); + p.push_str(encoded_user.as_ref()); + p.push_str("/_has_privileges"); p.into() } } } } -#[doc = "Builder for the [Security Get Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-privileges.html)\n\nRetrieves application privileges."] +#[doc = "Builder for the [Security Has Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-has-privileges.html)\n\nDetermines whether the specified user has a specified list of privileges."] #[derive(Clone, Debug)] -pub struct SecurityGetPrivileges<'a, 'b> { +pub struct SecurityHasPrivileges<'a, 'b, B> { transport: &'a Transport, - parts: SecurityGetPrivilegesParts<'b>, + parts: SecurityHasPrivilegesParts<'b>, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -2193,14 +4071,18 @@ pub struct SecurityGetPrivileges<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityGetPrivileges<'a, 'b> { - #[doc = "Creates a new instance of [SecurityGetPrivileges] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityGetPrivilegesParts<'b>) -> Self { +impl<'a, 'b, B> SecurityHasPrivileges<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityHasPrivileges] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityHasPrivilegesParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityGetPrivileges { + SecurityHasPrivileges { transport, parts, headers, + body: None, error_trace: None, filter_path: None, human: None, @@ -2209,6 +4091,24 @@ impl<'a, 'b> SecurityGetPrivileges<'a, 'b> { source: None, } } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityHasPrivileges<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityHasPrivileges { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -2244,10 +4144,13 @@ impl<'a, 'b> SecurityGetPrivileges<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Get Privileges API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Has Privileges API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = match self.body { + Some(_) => Method::Post, + None => Method::Get, + }; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -2270,7 +4173,7 @@ impl<'a, 'b> SecurityGetPrivileges<'a, 'b> { }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -2279,35 +4182,25 @@ impl<'a, 'b> SecurityGetPrivileges<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Get Role API"] -pub enum SecurityGetRoleParts<'b> { - #[doc = "Name"] - Name(&'b [&'b str]), +#[doc = "API parts for the Security Invalidate Api Key API"] +pub enum SecurityInvalidateApiKeyParts { #[doc = "No parts"] None, } -impl<'b> SecurityGetRoleParts<'b> { - #[doc = "Builds a relative URL path to the Security Get Role API"] +impl SecurityInvalidateApiKeyParts { + #[doc = "Builds a relative URL path to the Security Invalidate Api Key API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGetRoleParts::Name(ref 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(16usize + encoded_name.len()); - p.push_str("/_security/role/"); - p.push_str(encoded_name.as_ref()); - p.into() - } - SecurityGetRoleParts::None => "/_security/role".into(), + SecurityInvalidateApiKeyParts::None => "/_security/api_key".into(), } } } -#[doc = "Builder for the [Security Get Role API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-role.html)\n\nRetrieves roles in the native realm."] +#[doc = "Builder for the [Security Invalidate Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-invalidate-api-key.html)\n\nInvalidates one or more API keys."] #[derive(Clone, Debug)] -pub struct SecurityGetRole<'a, 'b> { +pub struct SecurityInvalidateApiKey<'a, 'b, B> { transport: &'a Transport, - parts: SecurityGetRoleParts<'b>, + parts: SecurityInvalidateApiKeyParts, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -2316,14 +4209,18 @@ pub struct SecurityGetRole<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityGetRole<'a, 'b> { - #[doc = "Creates a new instance of [SecurityGetRole] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityGetRoleParts<'b>) -> Self { +impl<'a, 'b, B> SecurityInvalidateApiKey<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityInvalidateApiKey]"] + pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityGetRole { + SecurityInvalidateApiKey { transport, - parts, + parts: SecurityInvalidateApiKeyParts::None, headers, + body: None, error_trace: None, filter_path: None, human: None, @@ -2332,6 +4229,24 @@ impl<'a, 'b> SecurityGetRole<'a, 'b> { source: None, } } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityInvalidateApiKey<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityInvalidateApiKey { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -2367,10 +4282,10 @@ impl<'a, 'b> SecurityGetRole<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Get Role API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Invalidate Api Key API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = Method::Delete; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -2393,7 +4308,7 @@ impl<'a, 'b> SecurityGetRole<'a, 'b> { }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -2402,35 +4317,25 @@ impl<'a, 'b> SecurityGetRole<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Get Role Mapping API"] -pub enum SecurityGetRoleMappingParts<'b> { - #[doc = "Name"] - Name(&'b [&'b str]), +#[doc = "API parts for the Security Invalidate Token API"] +pub enum SecurityInvalidateTokenParts { #[doc = "No parts"] None, } -impl<'b> SecurityGetRoleMappingParts<'b> { - #[doc = "Builds a relative URL path to the Security Get Role Mapping API"] +impl SecurityInvalidateTokenParts { + #[doc = "Builds a relative URL path to the Security Invalidate Token API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGetRoleMappingParts::Name(ref 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(24usize + encoded_name.len()); - p.push_str("/_security/role_mapping/"); - p.push_str(encoded_name.as_ref()); - p.into() - } - SecurityGetRoleMappingParts::None => "/_security/role_mapping".into(), + SecurityInvalidateTokenParts::None => "/_security/oauth2/token".into(), } } } -#[doc = "Builder for the [Security Get Role Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-role-mapping.html)\n\nRetrieves role mappings."] +#[doc = "Builder for the [Security Invalidate Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-invalidate-token.html)\n\nInvalidates one or more access tokens or refresh tokens."] #[derive(Clone, Debug)] -pub struct SecurityGetRoleMapping<'a, 'b> { +pub struct SecurityInvalidateToken<'a, 'b, B> { transport: &'a Transport, - parts: SecurityGetRoleMappingParts<'b>, + parts: SecurityInvalidateTokenParts, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -2439,14 +4344,18 @@ pub struct SecurityGetRoleMapping<'a, 'b> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityGetRoleMapping<'a, 'b> { - #[doc = "Creates a new instance of [SecurityGetRoleMapping] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityGetRoleMappingParts<'b>) -> Self { +impl<'a, 'b, B> SecurityInvalidateToken<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityInvalidateToken]"] + pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityGetRoleMapping { + SecurityInvalidateToken { transport, - parts, + parts: SecurityInvalidateTokenParts::None, headers, + body: None, error_trace: None, filter_path: None, human: None, @@ -2455,6 +4364,24 @@ impl<'a, 'b> SecurityGetRoleMapping<'a, 'b> { source: None, } } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityInvalidateToken<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityInvalidateToken { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -2490,10 +4417,10 @@ impl<'a, 'b> SecurityGetRoleMapping<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Get Role Mapping API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Invalidate Token API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = Method::Delete; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -2516,7 +4443,7 @@ impl<'a, 'b> SecurityGetRoleMapping<'a, 'b> { }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -2525,59 +4452,61 @@ impl<'a, 'b> SecurityGetRoleMapping<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Get Token API"] -pub enum SecurityGetTokenParts { +#[doc = "API parts for the Security Put Privileges API"] +pub enum SecurityPutPrivilegesParts { #[doc = "No parts"] None, } -impl SecurityGetTokenParts { - #[doc = "Builds a relative URL path to the Security Get Token API"] +impl SecurityPutPrivilegesParts { + #[doc = "Builds a relative URL path to the Security Put Privileges API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGetTokenParts::None => "/_security/oauth2/token".into(), + SecurityPutPrivilegesParts::None => "/_security/privilege/".into(), } } } -#[doc = "Builder for the [Security Get Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-token.html)\n\nCreates a bearer token for access without requiring basic authentication."] +#[doc = "Builder for the [Security Put Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-put-privileges.html)\n\nAdds or updates application privileges."] #[derive(Clone, Debug)] -pub struct SecurityGetToken<'a, 'b, B> { +pub struct SecurityPutPrivileges<'a, 'b, B> { transport: &'a Transport, - parts: SecurityGetTokenParts, + parts: SecurityPutPrivilegesParts, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, + refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityGetToken<'a, 'b, B> +impl<'a, 'b, B> SecurityPutPrivileges<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityGetToken]"] + #[doc = "Creates a new instance of [SecurityPutPrivileges]"] pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityGetToken { + SecurityPutPrivileges { transport, - parts: SecurityGetTokenParts::None, + parts: SecurityPutPrivilegesParts::None, headers, body: None, error_trace: None, filter_path: None, human: None, pretty: None, + refresh: None, request_timeout: None, source: None, } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityGetToken<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecurityPutPrivileges<'a, 'b, JsonBody> where T: Serialize, { - SecurityGetToken { + SecurityPutPrivileges { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -2586,6 +4515,7 @@ where headers: self.headers, human: self.human, pretty: self.pretty, + refresh: self.refresh, request_timeout: self.request_timeout, source: self.source, } @@ -2615,6 +4545,11 @@ where self.pretty = Some(pretty); self } + #[doc = "If `true` (the default) 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` then do nothing with refreshes."] + pub fn refresh(mut self, refresh: Refresh) -> Self { + self.refresh = Some(refresh); + 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); @@ -2625,10 +4560,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Get Token API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Put Privileges API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Post; + let method = Method::Put; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -2640,6 +4575,7 @@ where filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, + refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -2647,6 +4583,7 @@ where filter_path: self.filter_path, human: self.human, pretty: self.pretty, + refresh: self.refresh, source: self.source, }; Some(query_params) @@ -2660,59 +4597,80 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Get User API"] -pub enum SecurityGetUserParts<'b> { - #[doc = "Username"] - Username(&'b [&'b str]), - #[doc = "No parts"] - None, +#[doc = "API parts for the Security Put Role API"] +pub enum SecurityPutRoleParts<'b> { + #[doc = "Name"] + Name(&'b str), } -impl<'b> SecurityGetUserParts<'b> { - #[doc = "Builds a relative URL path to the Security Get User API"] +impl<'b> SecurityPutRoleParts<'b> { + #[doc = "Builds a relative URL path to the Security Put Role API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGetUserParts::Username(ref username) => { - let username_str = username.join(","); - let encoded_username: Cow = - percent_encode(username_str.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(16usize + encoded_username.len()); - p.push_str("/_security/user/"); - p.push_str(encoded_username.as_ref()); + SecurityPutRoleParts::Name(ref name) => { + let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(16usize + encoded_name.len()); + p.push_str("/_security/role/"); + p.push_str(encoded_name.as_ref()); p.into() } - SecurityGetUserParts::None => "/_security/user".into(), } } } -#[doc = "Builder for the [Security Get User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-user.html)\n\nRetrieves information about users in the native realm and built-in users."] +#[doc = "Builder for the [Security Put Role API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-put-role.html)\n\nAdds and updates roles in the native realm."] #[derive(Clone, Debug)] -pub struct SecurityGetUser<'a, 'b> { +pub struct SecurityPutRole<'a, 'b, B> { transport: &'a Transport, - parts: SecurityGetUserParts<'b>, + parts: SecurityPutRoleParts<'b>, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, + refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityGetUser<'a, 'b> { - #[doc = "Creates a new instance of [SecurityGetUser] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityGetUserParts<'b>) -> Self { +impl<'a, 'b, B> SecurityPutRole<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityPutRole] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityPutRoleParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityGetUser { + SecurityPutRole { transport, parts, headers, + body: None, error_trace: None, filter_path: None, human: None, pretty: None, + refresh: None, request_timeout: None, source: None, } } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityPutRole<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityPutRole { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + request_timeout: self.request_timeout, + source: self.source, + } + } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -2738,6 +4696,11 @@ impl<'a, 'b> SecurityGetUser<'a, 'b> { self.pretty = Some(pretty); self } + #[doc = "If `true` (the default) 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` then do nothing with refreshes."] + pub fn refresh(mut self, refresh: Refresh) -> Self { + self.refresh = Some(refresh); + 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); @@ -2748,10 +4711,10 @@ impl<'a, 'b> SecurityGetUser<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Get User API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Put Role API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = Method::Put; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -2763,6 +4726,7 @@ impl<'a, 'b> SecurityGetUser<'a, 'b> { filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, + refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -2770,11 +4734,12 @@ impl<'a, 'b> SecurityGetUser<'a, 'b> { filter_path: self.filter_path, human: self.human, pretty: self.pretty, + refresh: self.refresh, source: self.source, }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -2783,48 +4748,80 @@ impl<'a, 'b> SecurityGetUser<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Get User Privileges API"] -pub enum SecurityGetUserPrivilegesParts { - #[doc = "No parts"] - None, +#[doc = "API parts for the Security Put Role Mapping API"] +pub enum SecurityPutRoleMappingParts<'b> { + #[doc = "Name"] + Name(&'b str), } -impl SecurityGetUserPrivilegesParts { - #[doc = "Builds a relative URL path to the Security Get User Privileges API"] +impl<'b> SecurityPutRoleMappingParts<'b> { + #[doc = "Builds a relative URL path to the Security Put Role Mapping API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGetUserPrivilegesParts::None => "/_security/user/_privileges".into(), + SecurityPutRoleMappingParts::Name(ref name) => { + let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(24usize + encoded_name.len()); + p.push_str("/_security/role_mapping/"); + p.push_str(encoded_name.as_ref()); + p.into() + } } } } -#[doc = "Builder for the [Security Get User Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-privileges.html)\n\nRetrieves application privileges."] +#[doc = "Builder for the [Security Put Role Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-put-role-mapping.html)\n\nCreates and updates role mappings."] #[derive(Clone, Debug)] -pub struct SecurityGetUserPrivileges<'a, 'b> { +pub struct SecurityPutRoleMapping<'a, 'b, B> { transport: &'a Transport, - parts: SecurityGetUserPrivilegesParts, + parts: SecurityPutRoleMappingParts<'b>, + body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, + refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SecurityGetUserPrivileges<'a, 'b> { - #[doc = "Creates a new instance of [SecurityGetUserPrivileges]"] - pub fn new(transport: &'a Transport) -> Self { +impl<'a, 'b, B> SecurityPutRoleMapping<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityPutRoleMapping] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityPutRoleMappingParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityGetUserPrivileges { + SecurityPutRoleMapping { transport, - parts: SecurityGetUserPrivilegesParts::None, + parts, headers, + body: None, error_trace: None, filter_path: None, human: None, pretty: None, + refresh: None, request_timeout: None, source: None, } } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityPutRoleMapping<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityPutRoleMapping { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + request_timeout: self.request_timeout, + source: self.source, + } + } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -2850,6 +4847,11 @@ impl<'a, 'b> SecurityGetUserPrivileges<'a, 'b> { self.pretty = Some(pretty); self } + #[doc = "If `true` (the default) 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` then do nothing with refreshes."] + pub fn refresh(mut self, refresh: Refresh) -> Self { + self.refresh = Some(refresh); + 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); @@ -2860,10 +4862,10 @@ impl<'a, 'b> SecurityGetUserPrivileges<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Get User Privileges API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Put Role Mapping API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = Method::Put; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -2875,6 +4877,7 @@ impl<'a, 'b> SecurityGetUserPrivileges<'a, 'b> { filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, + refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -2882,11 +4885,12 @@ impl<'a, 'b> SecurityGetUserPrivileges<'a, 'b> { filter_path: self.filter_path, human: self.human, pretty: self.pretty, + refresh: self.refresh, source: self.source, }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -2895,24 +4899,31 @@ impl<'a, 'b> SecurityGetUserPrivileges<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Grant Api Key API"] -pub enum SecurityGrantApiKeyParts { - #[doc = "No parts"] - None, +#[doc = "API parts for the Security Put User API"] +pub enum SecurityPutUserParts<'b> { + #[doc = "Username"] + Username(&'b str), } -impl SecurityGrantApiKeyParts { - #[doc = "Builds a relative URL path to the Security Grant Api Key API"] +impl<'b> SecurityPutUserParts<'b> { + #[doc = "Builds a relative URL path to the Security Put User API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityGrantApiKeyParts::None => "/_security/api_key/grant".into(), + SecurityPutUserParts::Username(ref username) => { + let encoded_username: Cow = + percent_encode(username.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(16usize + encoded_username.len()); + p.push_str("/_security/user/"); + p.push_str(encoded_username.as_ref()); + p.into() + } } } } -#[doc = "Builder for the [Security Grant Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-grant-api-key.html)\n\nCreates an API key on behalf of another user."] +#[doc = "Builder for the [Security Put User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-put-user.html)\n\nAdds and updates users in the native realm. These users are commonly referred to as native users."] #[derive(Clone, Debug)] -pub struct SecurityGrantApiKey<'a, 'b, B> { +pub struct SecurityPutUser<'a, 'b, B> { transport: &'a Transport, - parts: SecurityGrantApiKeyParts, + parts: SecurityPutUserParts<'b>, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, @@ -2923,16 +4934,16 @@ pub struct SecurityGrantApiKey<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityGrantApiKey<'a, 'b, B> +impl<'a, 'b, B> SecurityPutUser<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityGrantApiKey]"] - pub fn new(transport: &'a Transport) -> Self { + #[doc = "Creates a new instance of [SecurityPutUser] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityPutUserParts<'b>) -> Self { let headers = HeaderMap::new(); - SecurityGrantApiKey { + SecurityPutUser { transport, - parts: SecurityGrantApiKeyParts::None, + parts, headers, body: None, error_trace: None, @@ -2945,11 +4956,11 @@ where } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityGrantApiKey<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecurityPutUser<'a, 'b, JsonBody> where T: Serialize, { - SecurityGrantApiKey { + SecurityPutUser { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -3003,10 +5014,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Grant Api Key API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Put User API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Post; + let method = Method::Put; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -3040,34 +5051,24 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Has Privileges API"] -pub enum SecurityHasPrivilegesParts<'b> { +#[doc = "API parts for the Security Query Api Keys API"] +pub enum SecurityQueryApiKeysParts { #[doc = "No parts"] None, - #[doc = "User"] - User(&'b str), } -impl<'b> SecurityHasPrivilegesParts<'b> { - #[doc = "Builds a relative URL path to the Security Has Privileges API"] +impl SecurityQueryApiKeysParts { + #[doc = "Builds a relative URL path to the Security Query Api Keys API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityHasPrivilegesParts::None => "/_security/user/_has_privileges".into(), - SecurityHasPrivilegesParts::User(ref user) => { - let encoded_user: Cow = percent_encode(user.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(32usize + encoded_user.len()); - p.push_str("/_security/user/"); - p.push_str(encoded_user.as_ref()); - p.push_str("/_has_privileges"); - p.into() - } + SecurityQueryApiKeysParts::None => "/_security/_query/api_key".into(), } } } -#[doc = "Builder for the [Security Has Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-has-privileges.html)\n\nDetermines whether the specified user has a specified list of privileges."] +#[doc = "Builder for the [Security Query Api Keys API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-query-api-key.html)\n\nRetrieves information for API keys using a subset of query DSL"] #[derive(Clone, Debug)] -pub struct SecurityHasPrivileges<'a, 'b, B> { +pub struct SecurityQueryApiKeys<'a, 'b, B> { transport: &'a Transport, - parts: SecurityHasPrivilegesParts<'b>, + parts: SecurityQueryApiKeysParts, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, @@ -3077,16 +5078,16 @@ pub struct SecurityHasPrivileges<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityHasPrivileges<'a, 'b, B> +impl<'a, 'b, B> SecurityQueryApiKeys<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityHasPrivileges] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityHasPrivilegesParts<'b>) -> Self { + #[doc = "Creates a new instance of [SecurityQueryApiKeys]"] + pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityHasPrivileges { + SecurityQueryApiKeys { transport, - parts, + parts: SecurityQueryApiKeysParts::None, headers, body: None, error_trace: None, @@ -3098,11 +5099,11 @@ where } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityHasPrivileges<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecurityQueryApiKeys<'a, 'b, JsonBody> where T: Serialize, { - SecurityHasPrivileges { + SecurityQueryApiKeys { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -3150,7 +5151,7 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Has Privileges API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Query Api Keys API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = match self.body { @@ -3188,24 +5189,24 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Invalidate Api Key API"] -pub enum SecurityInvalidateApiKeyParts { +#[doc = "API parts for the Security Saml Authenticate API"] +pub enum SecuritySamlAuthenticateParts { #[doc = "No parts"] None, } -impl SecurityInvalidateApiKeyParts { - #[doc = "Builds a relative URL path to the Security Invalidate Api Key API"] +impl SecuritySamlAuthenticateParts { + #[doc = "Builds a relative URL path to the Security Saml Authenticate API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityInvalidateApiKeyParts::None => "/_security/api_key".into(), + SecuritySamlAuthenticateParts::None => "/_security/saml/authenticate".into(), } } } -#[doc = "Builder for the [Security Invalidate Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-invalidate-api-key.html)\n\nInvalidates one or more API keys."] +#[doc = "Builder for the [Security Saml Authenticate API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-authenticate.html)\n\nExchanges a SAML Response message for an Elasticsearch access token and refresh token pair"] #[derive(Clone, Debug)] -pub struct SecurityInvalidateApiKey<'a, 'b, B> { +pub struct SecuritySamlAuthenticate<'a, 'b, B> { transport: &'a Transport, - parts: SecurityInvalidateApiKeyParts, + parts: SecuritySamlAuthenticateParts, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, @@ -3215,16 +5216,16 @@ pub struct SecurityInvalidateApiKey<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityInvalidateApiKey<'a, 'b, B> +impl<'a, 'b, B> SecuritySamlAuthenticate<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityInvalidateApiKey]"] + #[doc = "Creates a new instance of [SecuritySamlAuthenticate]"] pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityInvalidateApiKey { + SecuritySamlAuthenticate { transport, - parts: SecurityInvalidateApiKeyParts::None, + parts: SecuritySamlAuthenticateParts::None, headers, body: None, error_trace: None, @@ -3236,11 +5237,11 @@ where } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityInvalidateApiKey<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecuritySamlAuthenticate<'a, 'b, JsonBody> where T: Serialize, { - SecurityInvalidateApiKey { + SecuritySamlAuthenticate { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -3288,10 +5289,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Invalidate Api Key API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Saml Authenticate API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Delete; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -3323,24 +5324,24 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Invalidate Token API"] -pub enum SecurityInvalidateTokenParts { +#[doc = "API parts for the Security Saml Complete Logout API"] +pub enum SecuritySamlCompleteLogoutParts { #[doc = "No parts"] None, } -impl SecurityInvalidateTokenParts { - #[doc = "Builds a relative URL path to the Security Invalidate Token API"] +impl SecuritySamlCompleteLogoutParts { + #[doc = "Builds a relative URL path to the Security Saml Complete Logout API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityInvalidateTokenParts::None => "/_security/oauth2/token".into(), + SecuritySamlCompleteLogoutParts::None => "/_security/saml/complete_logout".into(), } } } -#[doc = "Builder for the [Security Invalidate Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-invalidate-token.html)\n\nInvalidates one or more access tokens or refresh tokens."] +#[doc = "Builder for the [Security Saml Complete Logout API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-complete-logout.html)\n\nVerifies the logout response sent from the SAML IdP"] #[derive(Clone, Debug)] -pub struct SecurityInvalidateToken<'a, 'b, B> { +pub struct SecuritySamlCompleteLogout<'a, 'b, B> { transport: &'a Transport, - parts: SecurityInvalidateTokenParts, + parts: SecuritySamlCompleteLogoutParts, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, @@ -3350,16 +5351,16 @@ pub struct SecurityInvalidateToken<'a, 'b, B> { request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityInvalidateToken<'a, 'b, B> +impl<'a, 'b, B> SecuritySamlCompleteLogout<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityInvalidateToken]"] + #[doc = "Creates a new instance of [SecuritySamlCompleteLogout]"] pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityInvalidateToken { + SecuritySamlCompleteLogout { transport, - parts: SecurityInvalidateTokenParts::None, + parts: SecuritySamlCompleteLogoutParts::None, headers, body: None, error_trace: None, @@ -3371,11 +5372,11 @@ where } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityInvalidateToken<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecuritySamlCompleteLogout<'a, 'b, JsonBody> where T: Serialize, { - SecurityInvalidateToken { + SecuritySamlCompleteLogout { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -3423,10 +5424,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Invalidate Token API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Saml Complete Logout API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Delete; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -3458,61 +5459,59 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Put Privileges API"] -pub enum SecurityPutPrivilegesParts { +#[doc = "API parts for the Security Saml Invalidate API"] +pub enum SecuritySamlInvalidateParts { #[doc = "No parts"] None, } -impl SecurityPutPrivilegesParts { - #[doc = "Builds a relative URL path to the Security Put Privileges API"] +impl SecuritySamlInvalidateParts { + #[doc = "Builds a relative URL path to the Security Saml Invalidate API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityPutPrivilegesParts::None => "/_security/privilege/".into(), + SecuritySamlInvalidateParts::None => "/_security/saml/invalidate".into(), } } } -#[doc = "Builder for the [Security Put Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-put-privileges.html)\n\nAdds or updates application privileges."] +#[doc = "Builder for the [Security Saml Invalidate API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-invalidate.html)\n\nConsumes a SAML LogoutRequest"] #[derive(Clone, Debug)] -pub struct SecurityPutPrivileges<'a, 'b, B> { +pub struct SecuritySamlInvalidate<'a, 'b, B> { transport: &'a Transport, - parts: SecurityPutPrivilegesParts, + parts: SecuritySamlInvalidateParts, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, - refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityPutPrivileges<'a, 'b, B> +impl<'a, 'b, B> SecuritySamlInvalidate<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityPutPrivileges]"] + #[doc = "Creates a new instance of [SecuritySamlInvalidate]"] pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityPutPrivileges { + SecuritySamlInvalidate { transport, - parts: SecurityPutPrivilegesParts::None, + parts: SecuritySamlInvalidateParts::None, headers, body: None, error_trace: None, filter_path: None, human: None, pretty: None, - refresh: None, request_timeout: None, source: None, } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityPutPrivileges<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecuritySamlInvalidate<'a, 'b, JsonBody> where T: Serialize, { - SecurityPutPrivileges { + SecuritySamlInvalidate { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -3521,7 +5520,6 @@ where headers: self.headers, human: self.human, pretty: self.pretty, - refresh: self.refresh, request_timeout: self.request_timeout, source: self.source, } @@ -3551,11 +5549,6 @@ where self.pretty = Some(pretty); self } - #[doc = "If `true` (the default) 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` then do nothing with refreshes."] - pub fn refresh(mut self, refresh: Refresh) -> Self { - self.refresh = Some(refresh); - 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); @@ -3566,10 +5559,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Put Privileges API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Saml Invalidate API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Put; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -3581,7 +5574,6 @@ where filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, - refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -3589,7 +5581,6 @@ where filter_path: self.filter_path, human: self.human, pretty: self.pretty, - refresh: self.refresh, source: self.source, }; Some(query_params) @@ -3603,67 +5594,59 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Put Role API"] -pub enum SecurityPutRoleParts<'b> { - #[doc = "Name"] - Name(&'b str), +#[doc = "API parts for the Security Saml Logout API"] +pub enum SecuritySamlLogoutParts { + #[doc = "No parts"] + None, } -impl<'b> SecurityPutRoleParts<'b> { - #[doc = "Builds a relative URL path to the Security Put Role API"] +impl SecuritySamlLogoutParts { + #[doc = "Builds a relative URL path to the Security Saml Logout API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityPutRoleParts::Name(ref name) => { - let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(16usize + encoded_name.len()); - p.push_str("/_security/role/"); - p.push_str(encoded_name.as_ref()); - p.into() - } + SecuritySamlLogoutParts::None => "/_security/saml/logout".into(), } } } -#[doc = "Builder for the [Security Put Role API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-put-role.html)\n\nAdds and updates roles in the native realm."] +#[doc = "Builder for the [Security Saml Logout API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-logout.html)\n\nInvalidates an access token and a refresh token that were generated via the SAML Authenticate API"] #[derive(Clone, Debug)] -pub struct SecurityPutRole<'a, 'b, B> { +pub struct SecuritySamlLogout<'a, 'b, B> { transport: &'a Transport, - parts: SecurityPutRoleParts<'b>, + parts: SecuritySamlLogoutParts, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, - refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityPutRole<'a, 'b, B> +impl<'a, 'b, B> SecuritySamlLogout<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityPutRole] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityPutRoleParts<'b>) -> Self { + #[doc = "Creates a new instance of [SecuritySamlLogout]"] + pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityPutRole { + SecuritySamlLogout { transport, - parts, + parts: SecuritySamlLogoutParts::None, headers, body: None, error_trace: None, filter_path: None, human: None, pretty: None, - refresh: None, request_timeout: None, source: None, } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityPutRole<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecuritySamlLogout<'a, 'b, JsonBody> where T: Serialize, { - SecurityPutRole { + SecuritySamlLogout { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -3672,7 +5655,6 @@ where headers: self.headers, human: self.human, pretty: self.pretty, - refresh: self.refresh, request_timeout: self.request_timeout, source: self.source, } @@ -3702,11 +5684,6 @@ where self.pretty = Some(pretty); self } - #[doc = "If `true` (the default) 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` then do nothing with refreshes."] - pub fn refresh(mut self, refresh: Refresh) -> Self { - self.refresh = Some(refresh); - 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); @@ -3717,10 +5694,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Put Role API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Saml Logout API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Put; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -3732,7 +5709,6 @@ where filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, - refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -3740,7 +5716,6 @@ where filter_path: self.filter_path, human: self.human, pretty: self.pretty, - refresh: self.refresh, source: self.source, }; Some(query_params) @@ -3754,67 +5729,59 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Put Role Mapping API"] -pub enum SecurityPutRoleMappingParts<'b> { - #[doc = "Name"] - Name(&'b str), +#[doc = "API parts for the Security Saml Prepare Authentication API"] +pub enum SecuritySamlPrepareAuthenticationParts { + #[doc = "No parts"] + None, } -impl<'b> SecurityPutRoleMappingParts<'b> { - #[doc = "Builds a relative URL path to the Security Put Role Mapping API"] +impl SecuritySamlPrepareAuthenticationParts { + #[doc = "Builds a relative URL path to the Security Saml Prepare Authentication API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityPutRoleMappingParts::Name(ref name) => { - let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(24usize + encoded_name.len()); - p.push_str("/_security/role_mapping/"); - p.push_str(encoded_name.as_ref()); - p.into() - } + SecuritySamlPrepareAuthenticationParts::None => "/_security/saml/prepare".into(), } } } -#[doc = "Builder for the [Security Put Role Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-put-role-mapping.html)\n\nCreates and updates role mappings."] +#[doc = "Builder for the [Security Saml Prepare Authentication API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-prepare-authentication.html)\n\nCreates a SAML authentication request"] #[derive(Clone, Debug)] -pub struct SecurityPutRoleMapping<'a, 'b, B> { +pub struct SecuritySamlPrepareAuthentication<'a, 'b, B> { transport: &'a Transport, - parts: SecurityPutRoleMappingParts<'b>, + parts: SecuritySamlPrepareAuthenticationParts, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, - refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityPutRoleMapping<'a, 'b, B> +impl<'a, 'b, B> SecuritySamlPrepareAuthentication<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [SecurityPutRoleMapping] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityPutRoleMappingParts<'b>) -> Self { + #[doc = "Creates a new instance of [SecuritySamlPrepareAuthentication]"] + pub fn new(transport: &'a Transport) -> Self { let headers = HeaderMap::new(); - SecurityPutRoleMapping { + SecuritySamlPrepareAuthentication { transport, - parts, + parts: SecuritySamlPrepareAuthenticationParts::None, headers, body: None, error_trace: None, filter_path: None, human: None, pretty: None, - refresh: None, request_timeout: None, source: None, } } #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityPutRoleMapping<'a, 'b, JsonBody> + pub fn body(self, body: T) -> SecuritySamlPrepareAuthentication<'a, 'b, JsonBody> where T: Serialize, { - SecurityPutRoleMapping { + SecuritySamlPrepareAuthentication { transport: self.transport, parts: self.parts, body: Some(body.into()), @@ -3823,7 +5790,6 @@ where headers: self.headers, human: self.human, pretty: self.pretty, - refresh: self.refresh, request_timeout: self.request_timeout, source: self.source, } @@ -3853,11 +5819,6 @@ where self.pretty = Some(pretty); self } - #[doc = "If `true` (the default) 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` then do nothing with refreshes."] - pub fn refresh(mut self, refresh: Refresh) -> Self { - self.refresh = Some(refresh); - 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); @@ -3868,10 +5829,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Put Role Mapping API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Saml Prepare Authentication API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Put; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -3883,7 +5844,6 @@ where filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, - refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -3891,7 +5851,6 @@ where filter_path: self.filter_path, human: self.human, pretty: self.pretty, - refresh: self.refresh, source: self.source, }; Some(query_params) @@ -3905,81 +5864,58 @@ where } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Security Put User API"] -pub enum SecurityPutUserParts<'b> { - #[doc = "Username"] - Username(&'b str), +#[doc = "API parts for the Security Saml Service Provider Metadata API"] +pub enum SecuritySamlServiceProviderMetadataParts<'b> { + #[doc = "RealmName"] + RealmName(&'b str), } -impl<'b> SecurityPutUserParts<'b> { - #[doc = "Builds a relative URL path to the Security Put User API"] +impl<'b> SecuritySamlServiceProviderMetadataParts<'b> { + #[doc = "Builds a relative URL path to the Security Saml Service Provider Metadata API"] pub fn url(self) -> Cow<'static, str> { match self { - SecurityPutUserParts::Username(ref username) => { - let encoded_username: Cow = - percent_encode(username.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(16usize + encoded_username.len()); - p.push_str("/_security/user/"); - p.push_str(encoded_username.as_ref()); + SecuritySamlServiceProviderMetadataParts::RealmName(ref realm_name) => { + let encoded_realm_name: Cow = + percent_encode(realm_name.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(25usize + encoded_realm_name.len()); + p.push_str("/_security/saml/metadata/"); + p.push_str(encoded_realm_name.as_ref()); p.into() } } } } -#[doc = "Builder for the [Security Put User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-put-user.html)\n\nAdds and updates users in the native realm. These users are commonly referred to as native users."] +#[doc = "Builder for the [Security Saml Service Provider Metadata API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-sp-metadata.html)\n\nGenerates SAML metadata for the Elastic stack SAML 2.0 Service Provider"] #[derive(Clone, Debug)] -pub struct SecurityPutUser<'a, 'b, B> { +pub struct SecuritySamlServiceProviderMetadata<'a, 'b> { transport: &'a Transport, - parts: SecurityPutUserParts<'b>, - body: Option, + parts: SecuritySamlServiceProviderMetadataParts<'b>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, pretty: Option, - refresh: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b, B> SecurityPutUser<'a, 'b, B> -where - B: Body, -{ - #[doc = "Creates a new instance of [SecurityPutUser] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SecurityPutUserParts<'b>) -> Self { +impl<'a, 'b> SecuritySamlServiceProviderMetadata<'a, 'b> { + #[doc = "Creates a new instance of [SecuritySamlServiceProviderMetadata] with the specified API parts"] + pub fn new( + transport: &'a Transport, + parts: SecuritySamlServiceProviderMetadataParts<'b>, + ) -> Self { let headers = HeaderMap::new(); - SecurityPutUser { + SecuritySamlServiceProviderMetadata { transport, parts, headers, - body: None, error_trace: None, filter_path: None, human: None, pretty: None, - refresh: None, request_timeout: None, source: None, } } - #[doc = "The body for the API call"] - pub fn body(self, body: T) -> SecurityPutUser<'a, 'b, JsonBody> - where - T: Serialize, - { - SecurityPutUser { - transport: self.transport, - parts: self.parts, - body: Some(body.into()), - error_trace: self.error_trace, - filter_path: self.filter_path, - headers: self.headers, - human: self.human, - pretty: self.pretty, - refresh: self.refresh, - request_timeout: self.request_timeout, - source: self.source, - } - } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); @@ -4005,11 +5941,6 @@ where self.pretty = Some(pretty); self } - #[doc = "If `true` (the default) 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` then do nothing with refreshes."] - pub fn refresh(mut self, refresh: Refresh) -> Self { - self.refresh = Some(refresh); - 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); @@ -4020,10 +5951,10 @@ where self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Security Put User API that can be awaited"] + #[doc = "Creates an asynchronous call to the Security Saml Service Provider Metadata API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Put; + let method = Method::Get; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -4035,7 +5966,6 @@ where filter_path: Option<&'b [&'b str]>, human: Option, pretty: Option, - refresh: Option, source: Option<&'b str>, } let query_params = QueryParams { @@ -4043,12 +5973,11 @@ where filter_path: self.filter_path, human: self.human, pretty: self.pretty, - refresh: self.refresh, source: self.source, }; Some(query_params) }; - let body = self.body; + let body = Option::<()>::None; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -4107,10 +6036,28 @@ impl<'a> Security<'a> { ) -> SecurityClearCachedRoles<'a, 'b, ()> { SecurityClearCachedRoles::new(self.transport(), parts) } + #[doc = "[Security Clear Cached Service Tokens API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-clear-service-token-caches.html)\n\nEvicts tokens from the service account token caches."] + #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] + #[cfg(feature = "beta-apis")] + pub fn clear_cached_service_tokens<'b>( + &'a self, + parts: SecurityClearCachedServiceTokensParts<'b>, + ) -> SecurityClearCachedServiceTokens<'a, 'b, ()> { + SecurityClearCachedServiceTokens::new(self.transport(), parts) + } #[doc = "[Security Create Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-create-api-key.html)\n\nCreates an API key for access without requiring basic authentication."] pub fn create_api_key<'b>(&'a self) -> SecurityCreateApiKey<'a, 'b, ()> { SecurityCreateApiKey::new(self.transport()) } + #[doc = "[Security Create Service Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-create-service-token.html)\n\nCreates a service account token for access without requiring basic authentication."] + #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] + #[cfg(feature = "beta-apis")] + pub fn create_service_token<'b>( + &'a self, + parts: SecurityCreateServiceTokenParts<'b>, + ) -> SecurityCreateServiceToken<'a, 'b, ()> { + SecurityCreateServiceToken::new(self.transport(), parts) + } #[doc = "[Security Delete Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-privilege.html)\n\nRemoves application privileges."] pub fn delete_privileges<'b>( &'a self, @@ -4132,6 +6079,15 @@ impl<'a> Security<'a> { ) -> SecurityDeleteRoleMapping<'a, 'b> { SecurityDeleteRoleMapping::new(self.transport(), parts) } + #[doc = "[Security Delete Service Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-service-token.html)\n\nDeletes a service account token."] + #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] + #[cfg(feature = "beta-apis")] + pub fn delete_service_token<'b>( + &'a self, + parts: SecurityDeleteServiceTokenParts<'b>, + ) -> SecurityDeleteServiceToken<'a, 'b> { + SecurityDeleteServiceToken::new(self.transport(), parts) + } #[doc = "[Security Delete User API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-delete-user.html)\n\nDeletes users from the native realm."] pub fn delete_user<'b>( &'a self, @@ -4153,6 +6109,14 @@ impl<'a> Security<'a> { ) -> SecurityEnableUser<'a, 'b, ()> { SecurityEnableUser::new(self.transport(), parts) } + #[doc = "[Security Enroll Kibana API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-kibana-enrollment.html)\n\nAllows a kibana instance to configure itself to communicate with a secured elasticsearch cluster."] + pub fn enroll_kibana<'b>(&'a self) -> SecurityEnrollKibana<'a, 'b> { + SecurityEnrollKibana::new(self.transport()) + } + #[doc = "[Security Enroll Node API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-node-enrollment.html)\n\nAllows a new node to enroll to an existing cluster with security enabled."] + pub fn enroll_node<'b>(&'a self) -> SecurityEnrollNode<'a, 'b> { + SecurityEnrollNode::new(self.transport()) + } #[doc = "[Security Get Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-api-key.html)\n\nRetrieves information for one or more API keys."] pub fn get_api_key<'b>(&'a self) -> SecurityGetApiKey<'a, 'b> { SecurityGetApiKey::new(self.transport()) @@ -4179,6 +6143,24 @@ impl<'a> Security<'a> { ) -> SecurityGetRoleMapping<'a, 'b> { SecurityGetRoleMapping::new(self.transport(), parts) } + #[doc = "[Security Get Service Accounts API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-service-accounts.html)\n\nRetrieves information about service accounts."] + #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] + #[cfg(feature = "beta-apis")] + pub fn get_service_accounts<'b>( + &'a self, + parts: SecurityGetServiceAccountsParts<'b>, + ) -> SecurityGetServiceAccounts<'a, 'b> { + SecurityGetServiceAccounts::new(self.transport(), parts) + } + #[doc = "[Security Get Service Credentials API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-service-credentials.html)\n\nRetrieves information of all service credentials for a service account."] + #[doc = " \n# Optional, beta\nThis requires the `beta-apis` feature. On track to become stable but breaking changes can\nhappen in minor versions.\n "] + #[cfg(feature = "beta-apis")] + pub fn get_service_credentials<'b>( + &'a self, + parts: SecurityGetServiceCredentialsParts<'b>, + ) -> SecurityGetServiceCredentials<'a, 'b> { + SecurityGetServiceCredentials::new(self.transport(), parts) + } #[doc = "[Security Get Token API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-token.html)\n\nCreates a bearer token for access without requiring basic authentication."] pub fn get_token<'b>(&'a self) -> SecurityGetToken<'a, 'b, ()> { SecurityGetToken::new(self.transport()) @@ -4187,7 +6169,7 @@ impl<'a> Security<'a> { pub fn get_user<'b>(&'a self, parts: SecurityGetUserParts<'b>) -> SecurityGetUser<'a, 'b> { SecurityGetUser::new(self.transport(), parts) } - #[doc = "[Security Get User Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-privileges.html)\n\nRetrieves application privileges."] + #[doc = "[Security Get User Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-get-user-privileges.html)\n\nRetrieves security privileges for the logged in user."] pub fn get_user_privileges<'b>(&'a self) -> SecurityGetUserPrivileges<'a, 'b> { SecurityGetUserPrivileges::new(self.transport()) } @@ -4229,6 +6211,39 @@ impl<'a> Security<'a> { pub fn put_user<'b>(&'a self, parts: SecurityPutUserParts<'b>) -> SecurityPutUser<'a, 'b, ()> { SecurityPutUser::new(self.transport(), parts) } + #[doc = "[Security Query Api Keys API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-query-api-key.html)\n\nRetrieves information for API keys using a subset of query DSL"] + pub fn query_api_keys<'b>(&'a self) -> SecurityQueryApiKeys<'a, 'b, ()> { + SecurityQueryApiKeys::new(self.transport()) + } + #[doc = "[Security Saml Authenticate API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-authenticate.html)\n\nExchanges a SAML Response message for an Elasticsearch access token and refresh token pair"] + pub fn saml_authenticate<'b>(&'a self) -> SecuritySamlAuthenticate<'a, 'b, ()> { + SecuritySamlAuthenticate::new(self.transport()) + } + #[doc = "[Security Saml Complete Logout API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-complete-logout.html)\n\nVerifies the logout response sent from the SAML IdP"] + pub fn saml_complete_logout<'b>(&'a self) -> SecuritySamlCompleteLogout<'a, 'b, ()> { + SecuritySamlCompleteLogout::new(self.transport()) + } + #[doc = "[Security Saml Invalidate API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-invalidate.html)\n\nConsumes a SAML LogoutRequest"] + pub fn saml_invalidate<'b>(&'a self) -> SecuritySamlInvalidate<'a, 'b, ()> { + SecuritySamlInvalidate::new(self.transport()) + } + #[doc = "[Security Saml Logout API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-logout.html)\n\nInvalidates an access token and a refresh token that were generated via the SAML Authenticate API"] + pub fn saml_logout<'b>(&'a self) -> SecuritySamlLogout<'a, 'b, ()> { + SecuritySamlLogout::new(self.transport()) + } + #[doc = "[Security Saml Prepare Authentication API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-prepare-authentication.html)\n\nCreates a SAML authentication request"] + pub fn saml_prepare_authentication<'b>( + &'a self, + ) -> SecuritySamlPrepareAuthentication<'a, 'b, ()> { + SecuritySamlPrepareAuthentication::new(self.transport()) + } + #[doc = "[Security Saml Service Provider Metadata API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-api-saml-sp-metadata.html)\n\nGenerates SAML metadata for the Elastic stack SAML 2.0 Service Provider"] + pub fn saml_service_provider_metadata<'b>( + &'a self, + parts: SecuritySamlServiceProviderMetadataParts<'b>, + ) -> SecuritySamlServiceProviderMetadata<'a, 'b> { + SecuritySamlServiceProviderMetadata::new(self.transport(), parts) + } } impl Elasticsearch { #[doc = "Creates a namespace client for Security APIs"] diff --git a/elasticsearch/src/shutdown.rs b/elasticsearch/src/shutdown.rs new file mode 100644 index 00000000..610c7688 --- /dev/null +++ b/elasticsearch/src/shutdown.rs @@ -0,0 +1,489 @@ +/* + * 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 +// ----------------------------------------------- + +#![cfg(feature = "experimental-apis")] +#![doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#![allow(unused_imports)] +use crate::{ + client::Elasticsearch, + 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}; +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Shutdown Delete Node API"] +pub enum ShutdownDeleteNodeParts<'b> { + #[doc = "NodeId"] + NodeId(&'b str), +} +#[cfg(feature = "experimental-apis")] +impl<'b> ShutdownDeleteNodeParts<'b> { + #[doc = "Builds a relative URL path to the Shutdown Delete Node API"] + pub fn url(self) -> Cow<'static, str> { + match self { + ShutdownDeleteNodeParts::NodeId(ref node_id) => { + let encoded_node_id: Cow = + percent_encode(node_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(17usize + encoded_node_id.len()); + p.push_str("/_nodes/"); + p.push_str(encoded_node_id.as_ref()); + p.push_str("/shutdown"); + p.into() + } + } + } +} +#[doc = "Builder for the [Shutdown Delete Node API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0)\n\nRemoves a node from the shutdown list"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct ShutdownDeleteNode<'a, 'b> { + transport: &'a Transport, + parts: ShutdownDeleteNodeParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b> ShutdownDeleteNode<'a, 'b> { + #[doc = "Creates a new instance of [ShutdownDeleteNode] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: ShutdownDeleteNodeParts<'b>) -> Self { + let headers = HeaderMap::new(); + ShutdownDeleteNode { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Shutdown Delete Node API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Delete; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = Option::<()>::None; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Shutdown Get Node API"] +pub enum ShutdownGetNodeParts<'b> { + #[doc = "No parts"] + None, + #[doc = "NodeId"] + NodeId(&'b str), +} +#[cfg(feature = "experimental-apis")] +impl<'b> ShutdownGetNodeParts<'b> { + #[doc = "Builds a relative URL path to the Shutdown Get Node API"] + pub fn url(self) -> Cow<'static, str> { + match self { + ShutdownGetNodeParts::None => "/_nodes/shutdown".into(), + ShutdownGetNodeParts::NodeId(ref node_id) => { + let encoded_node_id: Cow = + percent_encode(node_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(17usize + encoded_node_id.len()); + p.push_str("/_nodes/"); + p.push_str(encoded_node_id.as_ref()); + p.push_str("/shutdown"); + p.into() + } + } + } +} +#[doc = "Builder for the [Shutdown Get Node API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0)\n\nRetrieve status of a node or nodes that are currently marked as shutting down"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct ShutdownGetNode<'a, 'b> { + transport: &'a Transport, + parts: ShutdownGetNodeParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b> ShutdownGetNode<'a, 'b> { + #[doc = "Creates a new instance of [ShutdownGetNode] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: ShutdownGetNodeParts<'b>) -> Self { + let headers = HeaderMap::new(); + ShutdownGetNode { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Shutdown Get Node 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = Option::<()>::None; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[cfg(feature = "experimental-apis")] +#[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Shutdown Put Node API"] +pub enum ShutdownPutNodeParts<'b> { + #[doc = "NodeId"] + NodeId(&'b str), +} +#[cfg(feature = "experimental-apis")] +impl<'b> ShutdownPutNodeParts<'b> { + #[doc = "Builds a relative URL path to the Shutdown Put Node API"] + pub fn url(self) -> Cow<'static, str> { + match self { + ShutdownPutNodeParts::NodeId(ref node_id) => { + let encoded_node_id: Cow = + percent_encode(node_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(17usize + encoded_node_id.len()); + p.push_str("/_nodes/"); + p.push_str(encoded_node_id.as_ref()); + p.push_str("/shutdown"); + p.into() + } + } + } +} +#[doc = "Builder for the [Shutdown Put Node API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0)\n\nAdds a node to be shut down"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +#[derive(Clone, Debug)] +pub struct ShutdownPutNode<'a, 'b, B> { + transport: &'a Transport, + parts: ShutdownPutNodeParts<'b>, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +#[cfg(feature = "experimental-apis")] +impl<'a, 'b, B> ShutdownPutNode<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [ShutdownPutNode] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: ShutdownPutNodeParts<'b>) -> Self { + let headers = HeaderMap::new(); + ShutdownPutNode { + transport, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> ShutdownPutNode<'a, 'b, JsonBody> + where + T: Serialize, + { + ShutdownPutNode { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Shutdown Put Node API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Put; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[doc = "Namespace client for Shutdown APIs"] +#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] +#[cfg(feature = "experimental-apis")] +pub struct Shutdown<'a> { + transport: &'a Transport, +} +#[cfg(feature = "experimental-apis")] +impl<'a> Shutdown<'a> { + #[doc = "Creates a new instance of [Shutdown]"] + pub fn new(transport: &'a Transport) -> Self { + Self { transport } + } + pub fn transport(&self) -> &Transport { + self.transport + } + #[doc = "[Shutdown Delete Node API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0)\n\nRemoves a node from the shutdown list"] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn delete_node<'b>( + &'a self, + parts: ShutdownDeleteNodeParts<'b>, + ) -> ShutdownDeleteNode<'a, 'b> { + ShutdownDeleteNode::new(self.transport(), parts) + } + #[doc = "[Shutdown Get Node API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0)\n\nRetrieve status of a node or nodes that are currently marked as shutting down"] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn get_node<'b>(&'a self, parts: ShutdownGetNodeParts<'b>) -> ShutdownGetNode<'a, 'b> { + ShutdownGetNode::new(self.transport(), parts) + } + #[doc = "[Shutdown Put Node API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0)\n\nAdds a node to be shut down"] + #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] + #[cfg(feature = "experimental-apis")] + pub fn put_node<'b>(&'a self, parts: ShutdownPutNodeParts<'b>) -> ShutdownPutNode<'a, 'b, ()> { + ShutdownPutNode::new(self.transport(), parts) + } +} +#[cfg(feature = "experimental-apis")] +impl Elasticsearch { + #[doc = "Creates a namespace client for Shutdown APIs"] + pub fn shutdown(&self) -> Shutdown { + Shutdown::new(self.transport()) + } +} diff --git a/elasticsearch/src/snapshot.rs b/elasticsearch/src/snapshot.rs index 58bfd71b..38aec6ea 100644 --- a/elasticsearch/src/snapshot.rs +++ b/elasticsearch/src/snapshot.rs @@ -1030,6 +1030,8 @@ pub struct SnapshotGet<'a, 'b> { headers: HeaderMap, human: Option, ignore_unavailable: Option, + include_repository: Option, + index_details: Option, master_timeout: Option<&'b str>, pretty: Option, request_timeout: Option, @@ -1048,6 +1050,8 @@ impl<'a, 'b> SnapshotGet<'a, 'b> { filter_path: None, human: None, ignore_unavailable: None, + include_repository: None, + index_details: None, master_timeout: None, pretty: None, request_timeout: None, @@ -1080,6 +1084,16 @@ impl<'a, 'b> SnapshotGet<'a, 'b> { self.ignore_unavailable = Some(ignore_unavailable); self } + #[doc = "Whether to include the repository name in the snapshot info. Defaults to true."] + pub fn include_repository(mut self, include_repository: bool) -> Self { + self.include_repository = Some(include_repository); + self + } + #[doc = "Whether to include details of each index in the snapshot, if those details are available. Defaults to false."] + pub fn index_details(mut self, index_details: bool) -> Self { + self.index_details = Some(index_details); + self + } #[doc = "Explicit operation timeout for connection to master node"] pub fn master_timeout(mut self, master_timeout: &'b str) -> Self { self.master_timeout = Some(master_timeout); @@ -1120,6 +1134,8 @@ impl<'a, 'b> SnapshotGet<'a, 'b> { filter_path: Option<&'b [&'b str]>, human: Option, ignore_unavailable: Option, + include_repository: Option, + index_details: Option, master_timeout: Option<&'b str>, pretty: Option, source: Option<&'b str>, @@ -1130,6 +1146,8 @@ impl<'a, 'b> SnapshotGet<'a, 'b> { filter_path: self.filter_path, human: self.human, ignore_unavailable: self.ignore_unavailable, + include_repository: self.include_repository, + index_details: self.index_details, master_timeout: self.master_timeout, pretty: self.pretty, source: self.source, @@ -1146,44 +1164,57 @@ impl<'a, 'b> SnapshotGet<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Snapshot Get Features API"] -pub enum SnapshotGetFeaturesParts { +#[doc = "API parts for the Snapshot Get Repository API"] +pub enum SnapshotGetRepositoryParts<'b> { #[doc = "No parts"] None, + #[doc = "Repository"] + Repository(&'b [&'b str]), } -impl SnapshotGetFeaturesParts { - #[doc = "Builds a relative URL path to the Snapshot Get Features API"] +impl<'b> SnapshotGetRepositoryParts<'b> { + #[doc = "Builds a relative URL path to the Snapshot Get Repository API"] pub fn url(self) -> Cow<'static, str> { match self { - SnapshotGetFeaturesParts::None => "/_snapshottable_features".into(), + SnapshotGetRepositoryParts::None => "/_snapshot".into(), + SnapshotGetRepositoryParts::Repository(ref repository) => { + let repository_str = repository.join(","); + let encoded_repository: Cow = + percent_encode(repository_str.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(11usize + encoded_repository.len()); + p.push_str("/_snapshot/"); + p.push_str(encoded_repository.as_ref()); + p.into() + } } } } -#[doc = "Builder for the [Snapshot Get Features API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nReturns a list of features which can be snapshotted in this cluster."] +#[doc = "Builder for the [Snapshot Get Repository API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nReturns information about a repository."] #[derive(Clone, Debug)] -pub struct SnapshotGetFeatures<'a, 'b> { +pub struct SnapshotGetRepository<'a, 'b> { transport: &'a Transport, - parts: SnapshotGetFeaturesParts, + parts: SnapshotGetRepositoryParts<'b>, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, + local: Option, master_timeout: Option<&'b str>, pretty: Option, request_timeout: Option, source: Option<&'b str>, } -impl<'a, 'b> SnapshotGetFeatures<'a, 'b> { - #[doc = "Creates a new instance of [SnapshotGetFeatures]"] - pub fn new(transport: &'a Transport) -> Self { +impl<'a, 'b> SnapshotGetRepository<'a, 'b> { + #[doc = "Creates a new instance of [SnapshotGetRepository] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SnapshotGetRepositoryParts<'b>) -> Self { let headers = HeaderMap::new(); - SnapshotGetFeatures { + SnapshotGetRepository { transport, - parts: SnapshotGetFeaturesParts::None, + parts, headers, error_trace: None, filter_path: None, human: None, + local: None, master_timeout: None, pretty: None, request_timeout: None, @@ -1210,6 +1241,11 @@ impl<'a, 'b> SnapshotGetFeatures<'a, 'b> { self.human = Some(human); self } + #[doc = "Return local information, do not retrieve the state from master node (default: false)"] + pub fn local(mut self, local: bool) -> Self { + self.local = Some(local); + self + } #[doc = "Explicit operation timeout for connection to master node"] pub fn master_timeout(mut self, master_timeout: &'b str) -> Self { self.master_timeout = Some(master_timeout); @@ -1230,7 +1266,7 @@ impl<'a, 'b> SnapshotGetFeatures<'a, 'b> { self.source = Some(source); self } - #[doc = "Creates an asynchronous call to the Snapshot Get Features API that can be awaited"] + #[doc = "Creates an asynchronous call to the Snapshot Get Repository API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Get; @@ -1244,6 +1280,7 @@ impl<'a, 'b> SnapshotGetFeatures<'a, 'b> { #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, human: Option, + local: Option, master_timeout: Option<&'b str>, pretty: Option, source: Option<&'b str>, @@ -1252,6 +1289,7 @@ impl<'a, 'b> SnapshotGetFeatures<'a, 'b> { error_trace: self.error_trace, filter_path: self.filter_path, human: self.human, + local: self.local, master_timeout: self.master_timeout, pretty: self.pretty, source: self.source, @@ -1267,63 +1305,132 @@ impl<'a, 'b> SnapshotGetFeatures<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] -#[doc = "API parts for the Snapshot Get Repository API"] -pub enum SnapshotGetRepositoryParts<'b> { - #[doc = "No parts"] - None, +#[doc = "API parts for the Snapshot Repository Analyze API"] +pub enum SnapshotRepositoryAnalyzeParts<'b> { #[doc = "Repository"] - Repository(&'b [&'b str]), + Repository(&'b str), } -impl<'b> SnapshotGetRepositoryParts<'b> { - #[doc = "Builds a relative URL path to the Snapshot Get Repository API"] +impl<'b> SnapshotRepositoryAnalyzeParts<'b> { + #[doc = "Builds a relative URL path to the Snapshot Repository Analyze API"] pub fn url(self) -> Cow<'static, str> { match self { - SnapshotGetRepositoryParts::None => "/_snapshot".into(), - SnapshotGetRepositoryParts::Repository(ref repository) => { - let repository_str = repository.join(","); + SnapshotRepositoryAnalyzeParts::Repository(ref repository) => { let encoded_repository: Cow = - percent_encode(repository_str.as_bytes(), PARTS_ENCODED).into(); - let mut p = String::with_capacity(11usize + encoded_repository.len()); + percent_encode(repository.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(20usize + encoded_repository.len()); p.push_str("/_snapshot/"); p.push_str(encoded_repository.as_ref()); + p.push_str("/_analyze"); p.into() } } } } -#[doc = "Builder for the [Snapshot Get Repository API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nReturns information about a repository."] +#[doc = "Builder for the [Snapshot Repository Analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nAnalyzes a repository for correctness and performance"] #[derive(Clone, Debug)] -pub struct SnapshotGetRepository<'a, 'b> { +pub struct SnapshotRepositoryAnalyze<'a, 'b, B> { transport: &'a Transport, - parts: SnapshotGetRepositoryParts<'b>, + parts: SnapshotRepositoryAnalyzeParts<'b>, + blob_count: Option, + body: Option, + concurrency: Option, + detailed: Option, + early_read_node_count: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, human: Option, - local: Option, - master_timeout: Option<&'b str>, + max_blob_size: Option<&'b str>, + max_total_data_size: Option<&'b str>, pretty: Option, + rare_action_probability: Option, + rarely_abort_writes: Option, + read_node_count: Option, request_timeout: Option, + seed: Option, source: Option<&'b str>, + timeout: Option<&'b str>, } -impl<'a, 'b> SnapshotGetRepository<'a, 'b> { - #[doc = "Creates a new instance of [SnapshotGetRepository] with the specified API parts"] - pub fn new(transport: &'a Transport, parts: SnapshotGetRepositoryParts<'b>) -> Self { +impl<'a, 'b, B> SnapshotRepositoryAnalyze<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SnapshotRepositoryAnalyze] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SnapshotRepositoryAnalyzeParts<'b>) -> Self { let headers = HeaderMap::new(); - SnapshotGetRepository { + SnapshotRepositoryAnalyze { transport, parts, headers, + blob_count: None, + body: None, + concurrency: None, + detailed: None, + early_read_node_count: None, error_trace: None, filter_path: None, human: None, - local: None, - master_timeout: None, + max_blob_size: None, + max_total_data_size: None, pretty: None, + rare_action_probability: None, + rarely_abort_writes: None, + read_node_count: None, request_timeout: None, + seed: None, source: None, + timeout: None, + } + } + #[doc = "Number of blobs to create during the test. Defaults to 100."] + pub fn blob_count(mut self, blob_count: i64) -> Self { + self.blob_count = Some(blob_count); + self + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SnapshotRepositoryAnalyze<'a, 'b, JsonBody> + where + T: Serialize, + { + SnapshotRepositoryAnalyze { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + blob_count: self.blob_count, + concurrency: self.concurrency, + detailed: self.detailed, + early_read_node_count: self.early_read_node_count, + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + max_blob_size: self.max_blob_size, + max_total_data_size: self.max_total_data_size, + pretty: self.pretty, + rare_action_probability: self.rare_action_probability, + rarely_abort_writes: self.rarely_abort_writes, + read_node_count: self.read_node_count, + request_timeout: self.request_timeout, + seed: self.seed, + source: self.source, + timeout: self.timeout, } } + #[doc = "Number of operations to run concurrently during the test. Defaults to 10."] + pub fn concurrency(mut self, concurrency: i64) -> Self { + self.concurrency = Some(concurrency); + self + } + #[doc = "Whether to return detailed results or a summary. Defaults to 'false' so that only the summary is returned."] + pub fn detailed(mut self, detailed: bool) -> Self { + self.detailed = Some(detailed); + self + } + #[doc = "Number of nodes on which to perform an early read on a blob, i.e. before writing has completed. Early reads are rare actions so the 'rare_action_probability' parameter is also relevant. Defaults to 2."] + pub fn early_read_node_count(mut self, early_read_node_count: i64) -> Self { + self.early_read_node_count = Some(early_read_node_count); + 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); @@ -1344,14 +1451,14 @@ impl<'a, 'b> SnapshotGetRepository<'a, 'b> { self.human = Some(human); self } - #[doc = "Return local information, do not retrieve the state from master node (default: false)"] - pub fn local(mut self, local: bool) -> Self { - self.local = Some(local); + #[doc = "Maximum size of a blob to create during the test, e.g '1gb' or '100mb'. Defaults to '10mb'."] + pub fn max_blob_size(mut self, max_blob_size: &'b str) -> Self { + self.max_blob_size = Some(max_blob_size); self } - #[doc = "Explicit operation timeout for connection to master node"] - pub fn master_timeout(mut self, master_timeout: &'b str) -> Self { - self.master_timeout = Some(master_timeout); + #[doc = "Maximum total size of all blobs to create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'."] + pub fn max_total_data_size(mut self, max_total_data_size: &'b str) -> Self { + self.max_total_data_size = Some(max_total_data_size); self } #[doc = "Pretty format the returned JSON response."] @@ -1359,47 +1466,90 @@ impl<'a, 'b> SnapshotGetRepository<'a, 'b> { self.pretty = Some(pretty); self } + #[doc = "Probability of taking a rare action such as an early read or an overwrite. Defaults to 0.02."] + pub fn rare_action_probability(mut self, rare_action_probability: i64) -> Self { + self.rare_action_probability = Some(rare_action_probability); + self + } + #[doc = "Whether to rarely abort writes before they complete. Defaults to 'true'."] + pub fn rarely_abort_writes(mut self, rarely_abort_writes: bool) -> Self { + self.rarely_abort_writes = Some(rarely_abort_writes); + self + } + #[doc = "Number of nodes on which to read a blob after writing. Defaults to 10."] + pub fn read_node_count(mut self, read_node_count: i64) -> Self { + self.read_node_count = Some(read_node_count); + 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 = "Seed for the random number generator used to create the test workload. Defaults to a random value."] + pub fn seed(mut self, seed: i64) -> Self { + self.seed = Some(seed); + 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 = "Creates an asynchronous call to the Snapshot Get Repository API that can be awaited"] + #[doc = "Explicit operation timeout. Defaults to '30s'."] + pub fn timeout(mut self, timeout: &'b str) -> Self { + self.timeout = Some(timeout); + self + } + #[doc = "Creates an asynchronous call to the Snapshot Repository Analyze API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Get; + let method = Method::Post; let headers = self.headers; let timeout = self.request_timeout; let query_string = { #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { + blob_count: Option, + concurrency: Option, + detailed: Option, + early_read_node_count: Option, error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, human: Option, - local: Option, - master_timeout: Option<&'b str>, + max_blob_size: Option<&'b str>, + max_total_data_size: Option<&'b str>, pretty: Option, + rare_action_probability: Option, + rarely_abort_writes: Option, + read_node_count: Option, + seed: Option, source: Option<&'b str>, + timeout: Option<&'b str>, } let query_params = QueryParams { + blob_count: self.blob_count, + concurrency: self.concurrency, + detailed: self.detailed, + early_read_node_count: self.early_read_node_count, error_trace: self.error_trace, filter_path: self.filter_path, human: self.human, - local: self.local, - master_timeout: self.master_timeout, + max_blob_size: self.max_blob_size, + max_total_data_size: self.max_total_data_size, pretty: self.pretty, + rare_action_probability: self.rare_action_probability, + rarely_abort_writes: self.rarely_abort_writes, + read_node_count: self.read_node_count, + seed: self.seed, source: self.source, + timeout: self.timeout, }; Some(query_params) }; - let body = Option::<()>::None; + let body = self.body; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) @@ -1947,10 +2097,6 @@ impl<'a> Snapshot<'a> { pub fn get<'b>(&'a self, parts: SnapshotGetParts<'b>) -> SnapshotGet<'a, 'b> { SnapshotGet::new(self.transport(), parts) } - #[doc = "[Snapshot Get Features API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nReturns a list of features which can be snapshotted in this cluster."] - pub fn get_features<'b>(&'a self) -> SnapshotGetFeatures<'a, 'b> { - SnapshotGetFeatures::new(self.transport()) - } #[doc = "[Snapshot Get Repository API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nReturns information about a repository."] pub fn get_repository<'b>( &'a self, @@ -1958,6 +2104,13 @@ impl<'a> Snapshot<'a> { ) -> SnapshotGetRepository<'a, 'b> { SnapshotGetRepository::new(self.transport(), parts) } + #[doc = "[Snapshot Repository Analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nAnalyzes a repository for correctness and performance"] + pub fn repository_analyze<'b>( + &'a self, + parts: SnapshotRepositoryAnalyzeParts<'b>, + ) -> SnapshotRepositoryAnalyze<'a, 'b, ()> { + SnapshotRepositoryAnalyze::new(self.transport(), parts) + } #[doc = "[Snapshot Restore API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/modules-snapshots.html)\n\nRestores a snapshot."] pub fn restore<'b>(&'a self, parts: SnapshotRestoreParts<'b>) -> SnapshotRestore<'a, 'b, ()> { SnapshotRestore::new(self.transport(), parts) diff --git a/elasticsearch/src/sql.rs b/elasticsearch/src/sql.rs index c05498fe..f5025279 100644 --- a/elasticsearch/src/sql.rs +++ b/elasticsearch/src/sql.rs @@ -58,7 +58,7 @@ impl SqlClearCursorParts { } } } -#[doc = "Builder for the [Sql Clear Cursor API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-pagination.html)\n\nClears the SQL cursor"] +#[doc = "Builder for the [Sql Clear Cursor API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/clear-sql-cursor-api.html)\n\nClears the SQL cursor"] #[derive(Clone, Debug)] pub struct SqlClearCursor<'a, 'b, B> { transport: &'a Transport, @@ -180,6 +180,396 @@ where } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Sql Delete Async API"] +pub enum SqlDeleteAsyncParts<'b> { + #[doc = "Id"] + Id(&'b str), +} +impl<'b> SqlDeleteAsyncParts<'b> { + #[doc = "Builds a relative URL path to the Sql Delete Async API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SqlDeleteAsyncParts::Id(ref id) => { + let encoded_id: Cow = percent_encode(id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(19usize + encoded_id.len()); + p.push_str("/_sql/async/delete/"); + p.push_str(encoded_id.as_ref()); + p.into() + } + } + } +} +#[doc = "Builder for the [Sql Delete Async API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/delete-async-sql-search-api.html)\n\nDeletes an async SQL search or a stored synchronous SQL search. If the search is still running, the API cancels it."] +#[derive(Clone, Debug)] +pub struct SqlDeleteAsync<'a, 'b> { + transport: &'a Transport, + parts: SqlDeleteAsyncParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SqlDeleteAsync<'a, 'b> { + #[doc = "Creates a new instance of [SqlDeleteAsync] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SqlDeleteAsyncParts<'b>) -> Self { + let headers = HeaderMap::new(); + SqlDeleteAsync { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Sql Delete Async API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Delete; + 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] +#[doc = "API parts for the Sql Get Async API"] +pub enum SqlGetAsyncParts<'b> { + #[doc = "Id"] + Id(&'b str), +} +impl<'b> SqlGetAsyncParts<'b> { + #[doc = "Builds a relative URL path to the Sql Get Async API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SqlGetAsyncParts::Id(ref id) => { + let encoded_id: Cow = percent_encode(id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(12usize + encoded_id.len()); + p.push_str("/_sql/async/"); + p.push_str(encoded_id.as_ref()); + p.into() + } + } + } +} +#[doc = "Builder for the [Sql Get Async API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-async-sql-search-api.html)\n\nReturns the current status and available results for an async SQL search or stored synchronous SQL search"] +#[derive(Clone, Debug)] +pub struct SqlGetAsync<'a, 'b> { + transport: &'a Transport, + parts: SqlGetAsyncParts<'b>, + delimiter: Option<&'b str>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + format: Option<&'b str>, + headers: HeaderMap, + human: Option, + keep_alive: Option<&'b str>, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, + wait_for_completion_timeout: Option<&'b str>, +} +impl<'a, 'b> SqlGetAsync<'a, 'b> { + #[doc = "Creates a new instance of [SqlGetAsync] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SqlGetAsyncParts<'b>) -> Self { + let headers = HeaderMap::new(); + SqlGetAsync { + transport, + parts, + headers, + delimiter: None, + error_trace: None, + filter_path: None, + format: None, + human: None, + keep_alive: None, + pretty: None, + request_timeout: None, + source: None, + wait_for_completion_timeout: None, + } + } + #[doc = "Separator for CSV results"] + pub fn delimiter(mut self, delimiter: &'b str) -> Self { + self.delimiter = Some(delimiter); + 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 = "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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Retention period for the search and its results"] + pub fn keep_alive(mut self, keep_alive: &'b str) -> Self { + self.keep_alive = Some(keep_alive); + 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 = "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 = "Duration to wait for complete results"] + pub fn wait_for_completion_timeout(mut self, wait_for_completion_timeout: &'b str) -> Self { + self.wait_for_completion_timeout = Some(wait_for_completion_timeout); + self + } + #[doc = "Creates an asynchronous call to the Sql Get Async 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> { + delimiter: Option<&'b str>, + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + format: Option<&'b str>, + human: Option, + keep_alive: Option<&'b str>, + pretty: Option, + source: Option<&'b str>, + wait_for_completion_timeout: Option<&'b str>, + } + let query_params = QueryParams { + delimiter: self.delimiter, + error_trace: self.error_trace, + filter_path: self.filter_path, + format: self.format, + human: self.human, + keep_alive: self.keep_alive, + pretty: self.pretty, + source: self.source, + wait_for_completion_timeout: self.wait_for_completion_timeout, + }; + 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)] +#[doc = "API parts for the Sql Get Async Status API"] +pub enum SqlGetAsyncStatusParts<'b> { + #[doc = "Id"] + Id(&'b str), +} +impl<'b> SqlGetAsyncStatusParts<'b> { + #[doc = "Builds a relative URL path to the Sql Get Async Status API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SqlGetAsyncStatusParts::Id(ref id) => { + let encoded_id: Cow = percent_encode(id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(19usize + encoded_id.len()); + p.push_str("/_sql/async/status/"); + p.push_str(encoded_id.as_ref()); + p.into() + } + } + } +} +#[doc = "Builder for the [Sql Get Async Status API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-async-sql-search-status-api.html)\n\nReturns the current status of an async SQL search or a stored synchronous SQL search"] +#[derive(Clone, Debug)] +pub struct SqlGetAsyncStatus<'a, 'b> { + transport: &'a Transport, + parts: SqlGetAsyncStatusParts<'b>, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b> SqlGetAsyncStatus<'a, 'b> { + #[doc = "Creates a new instance of [SqlGetAsyncStatus] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SqlGetAsyncStatusParts<'b>) -> Self { + let headers = HeaderMap::new(); + SqlGetAsyncStatus { + transport, + parts, + headers, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: 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 = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + 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 = "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 = "Creates an asynchronous call to the Sql Get Async Status 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]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + 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)] #[doc = "API parts for the Sql Query API"] pub enum SqlQueryParts { #[doc = "No parts"] @@ -193,7 +583,7 @@ impl SqlQueryParts { } } } -#[doc = "Builder for the [Sql Query API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-rest-overview.html)\n\nExecutes a SQL request"] +#[doc = "Builder for the [Sql Query API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-search-api.html)\n\nExecutes a SQL request"] #[derive(Clone, Debug)] pub struct SqlQuery<'a, 'b, B> { transport: &'a Transport, @@ -341,7 +731,7 @@ impl SqlTranslateParts { } } } -#[doc = "Builder for the [Sql Translate API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-translate.html)\n\nTranslates SQL into Elasticsearch queries"] +#[doc = "Builder for the [Sql Translate API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-translate-api.html)\n\nTranslates SQL into Elasticsearch queries"] #[derive(Clone, Debug)] pub struct SqlTranslate<'a, 'b, B> { transport: &'a Transport, @@ -477,15 +867,30 @@ impl<'a> Sql<'a> { pub fn transport(&self) -> &Transport { self.transport } - #[doc = "[Sql Clear Cursor API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-pagination.html)\n\nClears the SQL cursor"] + #[doc = "[Sql Clear Cursor API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/clear-sql-cursor-api.html)\n\nClears the SQL cursor"] pub fn clear_cursor<'b>(&'a self) -> SqlClearCursor<'a, 'b, ()> { SqlClearCursor::new(self.transport()) } - #[doc = "[Sql Query API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-rest-overview.html)\n\nExecutes a SQL request"] + #[doc = "[Sql Delete Async API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/delete-async-sql-search-api.html)\n\nDeletes an async SQL search or a stored synchronous SQL search. If the search is still running, the API cancels it."] + pub fn delete_async<'b>(&'a self, parts: SqlDeleteAsyncParts<'b>) -> SqlDeleteAsync<'a, 'b> { + SqlDeleteAsync::new(self.transport(), parts) + } + #[doc = "[Sql Get Async API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-async-sql-search-api.html)\n\nReturns the current status and available results for an async SQL search or stored synchronous SQL search"] + pub fn get_async<'b>(&'a self, parts: SqlGetAsyncParts<'b>) -> SqlGetAsync<'a, 'b> { + SqlGetAsync::new(self.transport(), parts) + } + #[doc = "[Sql Get Async Status API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/get-async-sql-search-status-api.html)\n\nReturns the current status of an async SQL search or a stored synchronous SQL search"] + pub fn get_async_status<'b>( + &'a self, + parts: SqlGetAsyncStatusParts<'b>, + ) -> SqlGetAsyncStatus<'a, 'b> { + SqlGetAsyncStatus::new(self.transport(), parts) + } + #[doc = "[Sql Query API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-search-api.html)\n\nExecutes a SQL request"] pub fn query<'b>(&'a self) -> SqlQuery<'a, 'b, ()> { SqlQuery::new(self.transport()) } - #[doc = "[Sql Translate API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-translate.html)\n\nTranslates SQL into Elasticsearch queries"] + #[doc = "[Sql Translate API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/sql-translate-api.html)\n\nTranslates SQL into Elasticsearch queries"] pub fn translate<'b>(&'a self) -> SqlTranslate<'a, 'b, ()> { SqlTranslate::new(self.transport()) } diff --git a/elasticsearch/src/text_structure.rs b/elasticsearch/src/text_structure.rs index 098ec6ac..0c88ad49 100644 --- a/elasticsearch/src/text_structure.rs +++ b/elasticsearch/src/text_structure.rs @@ -29,8 +29,6 @@ //! Determines the structure of text and other information that will be useful to import its contents to an Elasticsearch //! index. -#![cfg(feature = "experimental-apis")] -#![doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] #![allow(unused_imports)] use crate::{ client::Elasticsearch, @@ -47,14 +45,12 @@ use crate::{ use percent_encoding::percent_encode; use serde::Serialize; use std::{borrow::Cow, time::Duration}; -#[cfg(feature = "experimental-apis")] #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Text Structure Find Structure API"] pub enum TextStructureFindStructureParts { #[doc = "No parts"] None, } -#[cfg(feature = "experimental-apis")] impl TextStructureFindStructureParts { #[doc = "Builds a relative URL path to the Text Structure Find Structure API"] pub fn url(self) -> Cow<'static, str> { @@ -64,8 +60,6 @@ impl TextStructureFindStructureParts { } } #[doc = "Builder for the [Text Structure Find Structure API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/find-structure.html)\n\nFinds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch."] -#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] -#[cfg(feature = "experimental-apis")] #[derive(Clone, Debug)] pub struct TextStructureFindStructure<'a, 'b, B> { transport: &'a Transport, @@ -93,7 +87,6 @@ pub struct TextStructureFindStructure<'a, 'b, B> { timestamp_field: Option<&'b str>, timestamp_format: Option<&'b str>, } -#[cfg(feature = "experimental-apis")] impl<'a, 'b, B> TextStructureFindStructure<'a, 'b, B> where B: Body, @@ -329,12 +322,9 @@ where } } #[doc = "Namespace client for TextStructure APIs"] -#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] -#[cfg(feature = "experimental-apis")] pub struct TextStructure<'a> { transport: &'a Transport, } -#[cfg(feature = "experimental-apis")] impl<'a> TextStructure<'a> { #[doc = "Creates a new instance of [TextStructure]"] pub fn new(transport: &'a Transport) -> Self { @@ -344,13 +334,10 @@ impl<'a> TextStructure<'a> { self.transport } #[doc = "[Text Structure Find Structure API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/find-structure.html)\n\nFinds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch."] - #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] - #[cfg(feature = "experimental-apis")] pub fn find_structure<'b>(&'a self) -> TextStructureFindStructure<'a, 'b, ()> { TextStructureFindStructure::new(self.transport()) } } -#[cfg(feature = "experimental-apis")] impl Elasticsearch { #[doc = "Creates a namespace client for TextStructure APIs"] pub fn text_structure(&self) -> TextStructure { diff --git a/elasticsearch/src/transform.rs b/elasticsearch/src/transform.rs index d3180fee..e38343a8 100644 --- a/elasticsearch/src/transform.rs +++ b/elasticsearch/src/transform.rs @@ -481,14 +481,25 @@ impl<'a, 'b> TransformGetTransformStats<'a, 'b> { } #[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Transform Preview Transform API"] -pub enum TransformPreviewTransformParts { +pub enum TransformPreviewTransformParts<'b> { + #[doc = "TransformId"] + TransformId(&'b str), #[doc = "No parts"] None, } -impl TransformPreviewTransformParts { +impl<'b> TransformPreviewTransformParts<'b> { #[doc = "Builds a relative URL path to the Transform Preview Transform API"] pub fn url(self) -> Cow<'static, str> { match self { + TransformPreviewTransformParts::TransformId(ref transform_id) => { + let encoded_transform_id: Cow = + percent_encode(transform_id.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(21usize + encoded_transform_id.len()); + p.push_str("/_transform/"); + p.push_str(encoded_transform_id.as_ref()); + p.push_str("/_preview"); + p.into() + } TransformPreviewTransformParts::None => "/_transform/_preview".into(), } } @@ -497,7 +508,7 @@ impl TransformPreviewTransformParts { #[derive(Clone, Debug)] pub struct TransformPreviewTransform<'a, 'b, B> { transport: &'a Transport, - parts: TransformPreviewTransformParts, + parts: TransformPreviewTransformParts<'b>, body: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, @@ -511,12 +522,12 @@ impl<'a, 'b, B> TransformPreviewTransform<'a, 'b, B> where B: Body, { - #[doc = "Creates a new instance of [TransformPreviewTransform]"] - pub fn new(transport: &'a Transport) -> Self { + #[doc = "Creates a new instance of [TransformPreviewTransform] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: TransformPreviewTransformParts<'b>) -> Self { let headers = HeaderMap::new(); TransformPreviewTransform { transport, - parts: TransformPreviewTransformParts::None, + parts, headers, body: None, error_trace: None, @@ -583,7 +594,10 @@ where #[doc = "Creates an asynchronous call to the Transform Preview Transform API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); - let method = Method::Post; + let method = match self.body { + Some(_) => Method::Post, + None => Method::Get, + }; let headers = self.headers; let timeout = self.request_timeout; let query_string = { @@ -1299,8 +1313,11 @@ impl<'a> Transform<'a> { TransformGetTransformStats::new(self.transport(), parts) } #[doc = "[Transform Preview Transform API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/preview-transform.html)\n\nPreviews a transform."] - pub fn preview_transform<'b>(&'a self) -> TransformPreviewTransform<'a, 'b, ()> { - TransformPreviewTransform::new(self.transport()) + pub fn preview_transform<'b>( + &'a self, + parts: TransformPreviewTransformParts<'b>, + ) -> TransformPreviewTransform<'a, 'b, ()> { + TransformPreviewTransform::new(self.transport(), parts) } #[doc = "[Transform Put Transform API](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/put-transform.html)\n\nInstantiates a transform."] pub fn put_transform<'b>( From 9260b45ebbe6f7e49ed2c00933ba00e3c08f89ac Mon Sep 17 00:00:00 2001 From: Sylvain Wallez Date: Mon, 6 Sep 2021 16:55:41 +0200 Subject: [PATCH 3/5] Update Makefile.toml Co-authored-by: Russ Cam --- Makefile.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index 27bd0845..43af7d11 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -27,7 +27,7 @@ env = { "ELASTICSEARCH_URL" = "https://elastic:changeme@localhost:9200" } [tasks.download-specs] category = "Elasticsearch" -description = '''Donwload Rest API specs and YAML tests''' +description = '''Download Rest API specs and YAML tests''' private = true command = "cargo" # cargo-make insists on installing cargo-xtask and ignores .cargo/config.toml From de2296060338c8b703a49a092602eb576f89fd12 Mon Sep 17 00:00:00 2001 From: Sylvain Wallez Date: Mon, 6 Sep 2021 16:57:00 +0200 Subject: [PATCH 4/5] Add namespace docs for fleet and shutdown --- api_generator/docs/namespaces/fleet.md | 1 + api_generator/docs/namespaces/shutdown.md | 1 + 2 files changed, 2 insertions(+) create mode 100644 api_generator/docs/namespaces/fleet.md create mode 100644 api_generator/docs/namespaces/shutdown.md diff --git a/api_generator/docs/namespaces/fleet.md b/api_generator/docs/namespaces/fleet.md new file mode 100644 index 00000000..598c6898 --- /dev/null +++ b/api_generator/docs/namespaces/fleet.md @@ -0,0 +1 @@ +[The Fleet APIs](https://www.elastic.co/guide/en/elasticsearch/reference/master/fleet-apis.html) support the use of Elasticsearch as a data store for internal agent and action data. These APIs are experimental and for internal use by Fleet only. diff --git a/api_generator/docs/namespaces/shutdown.md b/api_generator/docs/namespaces/shutdown.md new file mode 100644 index 00000000..495279a0 --- /dev/null +++ b/api_generator/docs/namespaces/shutdown.md @@ -0,0 +1 @@ +The [shutdown APIs](https://www.elastic.co/guide/en/elasticsearch/reference/master/node-lifecycle-api.html) allows preparing nodes for temporary or permanent shutdown, monitor the shutdown status, and enable a previously shut-down node to resume normal operations. From 30f59843b939d1f28deae6b08f76ecb2b0dfb284 Mon Sep 17 00:00:00 2001 From: Sylvain Wallez Date: Mon, 6 Sep 2021 17:06:54 +0200 Subject: [PATCH 5/5] Update generated code --- elasticsearch/src/fleet.rs | 2 ++ elasticsearch/src/ml.rs | 10 ++++++++++ elasticsearch/src/shutdown.rs | 2 ++ 3 files changed, 14 insertions(+) diff --git a/elasticsearch/src/fleet.rs b/elasticsearch/src/fleet.rs index 2038203f..5e83980c 100644 --- a/elasticsearch/src/fleet.rs +++ b/elasticsearch/src/fleet.rs @@ -24,6 +24,8 @@ // cargo make generate-api // ----------------------------------------------- +//! [The Fleet APIs](https://www.elastic.co/guide/en/elasticsearch/reference/master/fleet-apis.html) support the use of Elasticsearch as a data store for internal agent and action data. These APIs are experimental and for internal use by Fleet only. + #![cfg(feature = "experimental-apis")] #![doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] #![allow(unused_imports)] diff --git a/elasticsearch/src/ml.rs b/elasticsearch/src/ml.rs index cc77b27d..99057b62 100644 --- a/elasticsearch/src/ml.rs +++ b/elasticsearch/src/ml.rs @@ -7754,6 +7754,7 @@ pub struct MlPutTrainedModel<'a, 'b, B> { transport: &'a Transport, parts: MlPutTrainedModelParts<'b>, body: Option, + defer_definition_decompression: Option, error_trace: Option, filter_path: Option<&'b [&'b str]>, headers: HeaderMap, @@ -7774,6 +7775,7 @@ where parts, headers, body: None, + defer_definition_decompression: None, error_trace: None, filter_path: None, human: None, @@ -7791,6 +7793,7 @@ where transport: self.transport, parts: self.parts, body: Some(body.into()), + defer_definition_decompression: self.defer_definition_decompression, error_trace: self.error_trace, filter_path: self.filter_path, headers: self.headers, @@ -7800,6 +7803,11 @@ where source: self.source, } } + #[doc = "If set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations."] + pub fn defer_definition_decompression(mut self, defer_definition_decompression: bool) -> Self { + self.defer_definition_decompression = Some(defer_definition_decompression); + 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); @@ -7845,6 +7853,7 @@ where #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { + defer_definition_decompression: Option, error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, @@ -7853,6 +7862,7 @@ where source: Option<&'b str>, } let query_params = QueryParams { + defer_definition_decompression: self.defer_definition_decompression, error_trace: self.error_trace, filter_path: self.filter_path, human: self.human, diff --git a/elasticsearch/src/shutdown.rs b/elasticsearch/src/shutdown.rs index 610c7688..114c256c 100644 --- a/elasticsearch/src/shutdown.rs +++ b/elasticsearch/src/shutdown.rs @@ -24,6 +24,8 @@ // cargo make generate-api // ----------------------------------------------- +//! The [shutdown APIs](https://www.elastic.co/guide/en/elasticsearch/reference/master/node-lifecycle-api.html) allows preparing nodes for temporary or permanent shutdown, monitor the shutdown status, and enable a previously shut-down node to resume normal operations. + #![cfg(feature = "experimental-apis")] #![doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "] #![allow(unused_imports)]