use bon::bon;
use reqwest;
use std::sync::Arc;
use serde::{Deserialize, Serialize, de::Error as OtherError};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
use crate::apis::ContentType;
use crate::*;
#[async_trait]
pub trait SnapshotApi: Send + Sync {
async fn get(&self, params: GetParams) -> Result<crate::snapshot::GetResponse, Error>;
async fn clone(&self, params: CloneParams) -> Result<crate::common::AcknowledgedResponseBase, Error>;
async fn get_repository(&self, params: GetRepositoryParams) -> Result<crate::snapshot::GetRepositoryResponse, Error>;
async fn status(&self, params: StatusParams) -> Result<crate::snapshot::StatusResponse, Error>;
async fn create_repository(&self, params: CreateRepositoryParams) -> Result<crate::common::AcknowledgedResponseBase, Error>;
async fn delete(&self, params: DeleteParams) -> Result<crate::common::AcknowledgedResponseBase, Error>;
async fn verify_repository(&self, params: VerifyRepositoryParams) -> Result<crate::snapshot::VerifyRepositoryResponse, Error>;
async fn delete_repository(&self, params: DeleteRepositoryParams) -> Result<crate::common::AcknowledgedResponseBase, Error>;
async fn create(&self, params: CreateParams) -> Result<crate::snapshot::CreateResponse, Error>;
async fn restore(&self, params: RestoreParams) -> Result<crate::snapshot::RestoreResponse, Error>;
async fn cleanup_repository(&self, params: CleanupRepositoryParams) -> Result<crate::snapshot::CleanupRepositoryResponse, Error>;
}
pub struct SnapshotApiClient {
configuration: Arc<crate::Configuration>
}
impl SnapshotApiClient {
pub fn new(configuration: Arc<crate::Configuration>) -> Self {
Self { configuration }
}
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct GetParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub ignore_unavailable: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub snapshot: String,
pub source: Option<String>,
pub verbose: Option<bool>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct CloneParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub snapshot: String,
pub source: Option<String>,
pub target_snapshot: String,
pub clone: snapshot::Clone,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct GetRepositoryParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub local: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub source: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct StatusParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub ignore_unavailable: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub snapshot: String,
pub source: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct CreateRepositoryParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub source: Option<String>,
pub verify: Option<bool>,
pub create_repository: snapshot::CreateRepository,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct DeleteParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub snapshot: String,
pub source: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct VerifyRepositoryParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub source: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct DeleteRepositoryParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub source: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct CreateParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub snapshot: String,
pub source: Option<String>,
pub wait_for_completion: Option<bool>,
pub create: snapshot::Create,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct RestoreParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub restore: snapshot::Restore,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub snapshot: String,
pub source: Option<String>,
pub wait_for_completion: Option<bool>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct CleanupRepositoryParams {
pub cluster_manager_timeout: Option<String>,
pub master_timeout: Option<String>,
pub timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub repository: String,
pub source: Option<String>,
}
#[async_trait]
impl SnapshotApi for SnapshotApiClient {
async fn get(&self, params: GetParams) -> Result<crate::snapshot::GetResponse, Error> {
let GetParams {
cluster_manager_timeout,
master_timeout,
error_trace,
filter_path,
human,
ignore_unavailable,
pretty,
repository,
snapshot,
source,
verbose,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}/{snapshot}", local_var_configuration.base_path, snapshot=snapshot, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = verbose {
local_var_req_builder = local_var_req_builder.query(&[("verbose", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder = local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn clone(&self, params: CloneParams) -> Result<crate::common::AcknowledgedResponseBase, Error> {
let CloneParams {
cluster_manager_timeout,
master_timeout,
error_trace,
filter_path,
human,
pretty,
repository,
snapshot,
source,
target_snapshot,
clone,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}/{snapshot}/_clone/{target_snapshot}", local_var_configuration.base_path, repository=repository, snapshot=snapshot, target_snapshot=target_snapshot);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&clone);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn get_repository(&self, params: GetRepositoryParams) -> Result<crate::snapshot::GetRepositoryResponse, Error> {
let GetRepositoryParams {
cluster_manager_timeout,
master_timeout,
error_trace,
filter_path,
human,
local,
pretty,
repository,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}", local_var_configuration.base_path, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = local {
local_var_req_builder = local_var_req_builder.query(&[("local", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn status(&self, params: StatusParams) -> Result<crate::snapshot::StatusResponse, Error> {
let StatusParams {
cluster_manager_timeout,
master_timeout,
error_trace,
filter_path,
human,
ignore_unavailable,
pretty,
repository,
snapshot,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}/{snapshot}/_status", local_var_configuration.base_path, snapshot=snapshot, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder = local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn create_repository(&self, params: CreateRepositoryParams) -> Result<crate::common::AcknowledgedResponseBase, Error> {
let CreateRepositoryParams {
cluster_manager_timeout,
master_timeout,
timeout,
error_trace,
filter_path,
human,
pretty,
repository,
source,
verify,
create_repository,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}", local_var_configuration.base_path, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder = local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = verify {
local_var_req_builder = local_var_req_builder.query(&[("verify", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&create_repository);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn delete(&self, params: DeleteParams) -> Result<crate::common::AcknowledgedResponseBase, Error> {
let DeleteParams {
cluster_manager_timeout,
master_timeout,
error_trace,
filter_path,
human,
pretty,
repository,
snapshot,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}/{snapshot}", local_var_configuration.base_path, snapshot=snapshot, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn verify_repository(&self, params: VerifyRepositoryParams) -> Result<crate::snapshot::VerifyRepositoryResponse, Error> {
let VerifyRepositoryParams {
cluster_manager_timeout,
master_timeout,
timeout,
error_trace,
filter_path,
human,
pretty,
repository,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}/_verify", local_var_configuration.base_path, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder = local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn delete_repository(&self, params: DeleteRepositoryParams) -> Result<crate::common::AcknowledgedResponseBase, Error> {
let DeleteRepositoryParams {
cluster_manager_timeout,
master_timeout,
timeout,
error_trace,
filter_path,
human,
pretty,
repository,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}", local_var_configuration.base_path, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder = local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn create(&self, params: CreateParams) -> Result<crate::snapshot::CreateResponse, Error> {
let CreateParams {
cluster_manager_timeout,
master_timeout,
error_trace,
filter_path,
human,
pretty,
repository,
snapshot,
source,
wait_for_completion,
create,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}/{snapshot}", local_var_configuration.base_path, snapshot=snapshot, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_completion {
local_var_req_builder = local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&create);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn restore(&self, params: RestoreParams) -> Result<crate::snapshot::RestoreResponse, Error> {
let RestoreParams {
cluster_manager_timeout,
master_timeout,
restore,
error_trace,
filter_path,
human,
pretty,
repository,
snapshot,
source,
wait_for_completion,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}/{snapshot}/_restore", local_var_configuration.base_path, repository=repository, snapshot=snapshot);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = wait_for_completion {
local_var_req_builder = local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&restore);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn cleanup_repository(&self, params: CleanupRepositoryParams) -> Result<crate::snapshot::CleanupRepositoryResponse, Error> {
let CleanupRepositoryParams {
cluster_manager_timeout,
master_timeout,
timeout,
error_trace,
filter_path,
human,
pretty,
repository,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_snapshot/{repository}/_cleanup", local_var_configuration.base_path, repository=repository);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder = local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder = local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
}