/*
* Mittwald API
*
* ## Introduction This OpenAPI spec documents the mittwald API. It follows the [OpenAPI 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0.html). ## Authentication You will need an API token to access the API. You can obtain one by logging into the [mStudio](https://studio.mittwald.de) and navigating to the [\"API Tokens\" section in the user menu](https://studio.mittwald.de/app/profile/api-tokens). When making requests to the API, you can authenticate by passing your API token in the `X-Access-Token` header or as a bearer token. ## Rate Limiting Please note that usage of the API is rate-limited to prevent abuse. You can inspect the rate limiting for your current user by observing the `X-Ratelimit-*` headers included in each response. ## mStudio A main consumer of the mittwald API is the management interface for our customers, the [mStudio](https://studio.mittwald.de). ## Contact and support For support, please use the [mStudio support area](https://studio.mittwald.de/app/support/conversations) or drop us an email at [support@mittwald.de](mailto:support@mittwald.de). For security issues, please report to [security@mittwald.de](mailto:security@mittwald.de).
*
* The version of the OpenAPI document: 2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
/// struct for typed errors of method [`backup_create_project_backup`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupCreateProjectBackupError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_create_project_backup_export`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupCreateProjectBackupExportError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_create_project_backup_schedule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupCreateProjectBackupScheduleError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_delete_project_backup`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupDeleteProjectBackupError {
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_delete_project_backup_export`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupDeleteProjectBackupExportError {
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_delete_project_backup_schedule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupDeleteProjectBackupScheduleError {
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_get_project_backup`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupGetProjectBackupError {
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_get_project_backup_schedule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupGetProjectBackupScheduleError {
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_list_project_backup_schedules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupListProjectBackupSchedulesError {
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_list_project_backups`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupListProjectBackupsError {
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_update_project_backup_description`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupUpdateProjectBackupDescriptionError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`backup_update_project_backup_schedule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BackupUpdateProjectBackupScheduleError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status412(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
pub async fn backup_create_project_backup(configuration: &configuration::Configuration, project_id: &str, backup_create_project_backup_request: models::BackupCreateProjectBackupRequest) -> Result<models::DePeriodMittwaldPeriodV1PeriodBackupPeriodProjectBackup, Error<BackupCreateProjectBackupError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/projects/{projectId}/backups", local_var_configuration.base_path, projectId=crate::apis::urlencode(project_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&backup_create_project_backup_request);
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_entity: Option<BackupCreateProjectBackupError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_create_project_backup_export(configuration: &configuration::Configuration, project_backup_id: &str, backup_create_project_backup_export_request: models::BackupCreateProjectBackupExportRequest) -> Result<(), Error<BackupCreateProjectBackupExportError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/project-backups/{projectBackupId}/export", local_var_configuration.base_path, projectBackupId=crate::apis::urlencode(project_backup_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&backup_create_project_backup_export_request);
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() {
Ok(())
} else {
let local_var_entity: Option<BackupCreateProjectBackupExportError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_create_project_backup_schedule(configuration: &configuration::Configuration, project_id: &str, backup_create_project_backup_schedule_request: models::BackupCreateProjectBackupScheduleRequest) -> Result<models::DePeriodMittwaldPeriodV1PeriodBackupPeriodProjectBackupSchedule, Error<BackupCreateProjectBackupScheduleError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/projects/{projectId}/backup-schedules", local_var_configuration.base_path, projectId=crate::apis::urlencode(project_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&backup_create_project_backup_schedule_request);
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_entity: Option<BackupCreateProjectBackupScheduleError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_delete_project_backup(configuration: &configuration::Configuration, project_backup_id: &str) -> Result<(), Error<BackupDeleteProjectBackupError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/project-backups/{projectBackupId}", local_var_configuration.base_path, projectBackupId=crate::apis::urlencode(project_backup_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<BackupDeleteProjectBackupError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_delete_project_backup_export(configuration: &configuration::Configuration, project_backup_id: &str) -> Result<(), Error<BackupDeleteProjectBackupExportError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/project-backups/{projectBackupId}/export", local_var_configuration.base_path, projectBackupId=crate::apis::urlencode(project_backup_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<BackupDeleteProjectBackupExportError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_delete_project_backup_schedule(configuration: &configuration::Configuration, project_backup_schedule_id: &str) -> Result<(), Error<BackupDeleteProjectBackupScheduleError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/project-backup-schedules/{projectBackupScheduleId}", local_var_configuration.base_path, projectBackupScheduleId=crate::apis::urlencode(project_backup_schedule_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<BackupDeleteProjectBackupScheduleError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_get_project_backup(configuration: &configuration::Configuration, project_backup_id: &str) -> Result<models::DePeriodMittwaldPeriodV1PeriodBackupPeriodProjectBackup, Error<BackupGetProjectBackupError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/project-backups/{projectBackupId}", local_var_configuration.base_path, projectBackupId=crate::apis::urlencode(project_backup_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
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_entity: Option<BackupGetProjectBackupError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_get_project_backup_schedule(configuration: &configuration::Configuration, project_backup_schedule_id: &str) -> Result<models::DePeriodMittwaldPeriodV1PeriodBackupPeriodProjectBackupSchedule, Error<BackupGetProjectBackupScheduleError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/project-backup-schedules/{projectBackupScheduleId}", local_var_configuration.base_path, projectBackupScheduleId=crate::apis::urlencode(project_backup_schedule_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
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_entity: Option<BackupGetProjectBackupScheduleError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_list_project_backup_schedules(configuration: &configuration::Configuration, project_id: &str) -> Result<Vec<models::DePeriodMittwaldPeriodV1PeriodBackupPeriodProjectBackupSchedule>, Error<BackupListProjectBackupSchedulesError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/projects/{projectId}/backup-schedules", local_var_configuration.base_path, projectId=crate::apis::urlencode(project_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
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_entity: Option<BackupListProjectBackupSchedulesError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_list_project_backups(configuration: &configuration::Configuration, project_id: &str) -> Result<Vec<models::DePeriodMittwaldPeriodV1PeriodBackupPeriodProjectBackup>, Error<BackupListProjectBackupsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/projects/{projectId}/backups", local_var_configuration.base_path, projectId=crate::apis::urlencode(project_id));
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_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
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_entity: Option<BackupListProjectBackupsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_update_project_backup_description(configuration: &configuration::Configuration, project_backup_id: &str, backup_update_project_backup_description_request: models::BackupUpdateProjectBackupDescriptionRequest) -> Result<(), Error<BackupUpdateProjectBackupDescriptionError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/project-backups/{projectBackupId}/description", local_var_configuration.base_path, projectBackupId=crate::apis::urlencode(project_backup_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&backup_update_project_backup_description_request);
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() {
Ok(())
} else {
let local_var_entity: Option<BackupUpdateProjectBackupDescriptionError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn backup_update_project_backup_schedule(configuration: &configuration::Configuration, project_backup_schedule_id: &str, backup_update_project_backup_schedule_request: Option<models::BackupUpdateProjectBackupScheduleRequest>) -> Result<(), Error<BackupUpdateProjectBackupScheduleError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/project-backup-schedules/{projectBackupScheduleId}", local_var_configuration.base_path, projectBackupScheduleId=crate::apis::urlencode(project_backup_schedule_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&backup_update_project_backup_schedule_request);
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() {
Ok(())
} else {
let local_var_entity: Option<BackupUpdateProjectBackupScheduleError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}