/*
* 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 [`deprecated_file_get_file_token_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeprecatedFileGetFileTokenRulesError {
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
Status500(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`deprecated_file_get_file_type_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeprecatedFileGetFileTypeRulesError {
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
Status500(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`file_create_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileCreateFileError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status401(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status406(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status422(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status429(models::AppExecuteAction429Response),
Status500(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`file_get_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileGetFileError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status401(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status422(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status429(models::AppExecuteAction429Response),
Status500(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`file_get_file_meta`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileGetFileMetaError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status401(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status422(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status429(models::AppExecuteAction429Response),
Status500(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`file_get_file_upload_token_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileGetFileUploadTokenRulesError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status429(models::AppExecuteAction429Response),
Status500(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`file_get_file_upload_type_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileGetFileUploadTypeRulesError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status500(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`file_get_file_with_name`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileGetFileWithNameError {
Status400(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status401(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status403(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status404(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
Status422(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodValidationErrors),
Status429(models::AppExecuteAction429Response),
Status500(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
DefaultResponse(models::DePeriodMittwaldPeriodV1PeriodCommonsPeriodError),
UnknownValue(serde_json::Value),
}
pub async fn deprecated_file_get_file_token_rules(configuration: &configuration::Configuration, token: &str) -> Result<models::DePeriodMittwaldPeriodV1PeriodFilePeriodFileUploadRules, Error<DeprecatedFileGetFileTokenRulesError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/file-token-rules/{token}", local_var_configuration.base_path, token=crate::apis::urlencode(token));
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<DeprecatedFileGetFileTokenRulesError> = 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 deprecated_file_get_file_type_rules(configuration: &configuration::Configuration, name: &str) -> Result<models::DePeriodMittwaldPeriodV1PeriodFilePeriodFileUploadRules, Error<DeprecatedFileGetFileTypeRulesError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/file-type-rules/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
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<DeprecatedFileGetFileTypeRulesError> = 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 file_create_file(configuration: &configuration::Configuration, token: &str, file_create_file_request: Option<models::FileCreateFileRequest>) -> Result<models::DePeriodMittwaldPeriodV1PeriodFilePeriodFileMeta, Error<FileCreateFileError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/files", local_var_configuration.base_path);
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());
}
local_var_req_builder = local_var_req_builder.header("Token", token.to_string());
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(&file_create_file_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<FileCreateFileError> = 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 file_get_file(configuration: &configuration::Configuration, file_id: &str, accept: Option<&str>, content_disposition: Option<&str>, token: Option<&str>) -> Result<String, Error<FileGetFileError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/files/{fileId}", local_var_configuration.base_path, fileId=crate::apis::urlencode(file_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(local_var_param_value) = accept {
local_var_req_builder = local_var_req_builder.header("Accept", local_var_param_value.to_string());
}
if let Some(local_var_param_value) = content_disposition {
local_var_req_builder = local_var_req_builder.header("Content-Disposition", local_var_param_value.to_string());
}
if let Some(local_var_param_value) = token {
local_var_req_builder = local_var_req_builder.header("Token", local_var_param_value.to_string());
}
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<FileGetFileError> = 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 file_get_file_meta(configuration: &configuration::Configuration, file_id: &str) -> Result<models::DePeriodMittwaldPeriodV1PeriodFilePeriodFileMeta, Error<FileGetFileMetaError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/files/{fileId}/meta", local_var_configuration.base_path, fileId=crate::apis::urlencode(file_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<FileGetFileMetaError> = 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 file_get_file_upload_token_rules(configuration: &configuration::Configuration, file_upload_token: &str) -> Result<models::DePeriodMittwaldPeriodV1PeriodFilePeriodFileUploadRules, Error<FileGetFileUploadTokenRulesError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/file-upload-tokens/{fileUploadToken}/rules", local_var_configuration.base_path, fileUploadToken=crate::apis::urlencode(file_upload_token));
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<FileGetFileUploadTokenRulesError> = 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 file_get_file_upload_type_rules(configuration: &configuration::Configuration, file_upload_type: &str) -> Result<models::DePeriodMittwaldPeriodV1PeriodFilePeriodFileUploadRules, Error<FileGetFileUploadTypeRulesError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/file-upload-types/{fileUploadType}/rules", local_var_configuration.base_path, fileUploadType=crate::apis::urlencode(file_upload_type));
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<FileGetFileUploadTypeRulesError> = 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 file_get_file_with_name(configuration: &configuration::Configuration, file_id: &str, file_name: &str, accept: Option<&str>, content_disposition: Option<&str>, token: Option<&str>) -> Result<String, Error<FileGetFileWithNameError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v2/files/{fileId}/{fileName}", local_var_configuration.base_path, fileId=crate::apis::urlencode(file_id), fileName=crate::apis::urlencode(file_name));
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(local_var_param_value) = accept {
local_var_req_builder = local_var_req_builder.header("Accept", local_var_param_value.to_string());
}
if let Some(local_var_param_value) = content_disposition {
local_var_req_builder = local_var_req_builder.header("Content-Disposition", local_var_param_value.to_string());
}
if let Some(local_var_param_value) = token {
local_var_req_builder = local_var_req_builder.header("Token", local_var_param_value.to_string());
}
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<FileGetFileWithNameError> = 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))
}
}