use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
use tokio::fs::File as TokioFile;
use tokio_util::codec::{BytesCodec, FramedRead};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateFileError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateFileVersionError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteFileError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteFileVersionError {
Status400(models::Error),
Status500(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DownloadFileVersionError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FinishFileDataUploadError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdminAssetBundleError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetContentAgreementStatusError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFileError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFileAnalysisError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFileAnalysisSecurityError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFileAnalysisStandardError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFileDataUploadStatusError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFilesError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetGroupGalleryFileOrderError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StartFileDataUploadError {
Status400(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubmitContentAgreementError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAssetReviewNotesError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UploadGalleryImageError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UploadIconError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UploadImageError {
UnknownValue(serde_json::Value),
}
pub async fn create_file(
configuration: &configuration::Configuration,
create_file_request: Option<models::CreateFileRequest>,
) -> Result<models::File, Error<CreateFileError>> {
let p_body_create_file_request = create_file_request;
let uri_str = format!("{}/file", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_create_file_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn create_file_version(
configuration: &configuration::Configuration,
file_id: &str,
create_file_version_request: Option<models::CreateFileVersionRequest>,
) -> Result<models::File, Error<CreateFileVersionError>> {
let p_path_file_id = file_id;
let p_body_create_file_version_request = create_file_version_request;
let uri_str = format!(
"{}/file/{fileId}",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_create_file_version_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateFileVersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_file(
configuration: &configuration::Configuration,
file_id: &str,
) -> Result<models::File, Error<DeleteFileError>> {
let p_path_file_id = file_id;
let uri_str = format!(
"{}/file/{fileId}",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_file_version(
configuration: &configuration::Configuration,
file_id: &str,
version_id: i32,
) -> Result<models::File, Error<DeleteFileVersionError>> {
let p_path_file_id = file_id;
let p_path_version_id = version_id;
let uri_str = format!(
"{}/file/{fileId}/{versionId}",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id),
versionId = p_path_version_id
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteFileVersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn download_file_version(
configuration: &configuration::Configuration,
file_id: &str,
version_id: i32,
) -> Result<reqwest::Response, Error<DownloadFileVersionError>> {
let p_path_file_id = file_id;
let p_path_version_id = version_id;
let uri_str = format!(
"{}/file/{fileId}/{versionId}",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id),
versionId = p_path_version_id
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<DownloadFileVersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn finish_file_data_upload(
configuration: &configuration::Configuration,
file_id: &str,
version_id: i32,
file_type: &str,
finish_file_data_upload_request: Option<models::FinishFileDataUploadRequest>,
) -> Result<models::File, Error<FinishFileDataUploadError>> {
let p_path_file_id = file_id;
let p_path_version_id = version_id;
let p_path_file_type = file_type;
let p_body_finish_file_data_upload_request = finish_file_data_upload_request;
let uri_str = format!(
"{}/file/{fileId}/{versionId}/{fileType}/finish",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id),
versionId = p_path_version_id,
fileType = crate::apis::urlencode(p_path_file_type)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_finish_file_data_upload_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<FinishFileDataUploadError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_admin_asset_bundle(
configuration: &configuration::Configuration,
admin_asset_bundle_id: &str,
) -> Result<models::AdminAssetBundle, Error<GetAdminAssetBundleError>> {
let p_path_admin_asset_bundle_id = admin_asset_bundle_id;
let uri_str = format!(
"{}/adminassetbundles/{adminAssetBundleId}",
configuration.base_path,
adminAssetBundleId = crate::apis::urlencode(p_path_admin_asset_bundle_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdminAssetBundle`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AdminAssetBundle`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdminAssetBundleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_content_agreement_status(
configuration: &configuration::Configuration,
agreement_code: models::AgreementCode,
content_id: &str,
version: i32,
) -> Result<models::AgreementStatus, Error<GetContentAgreementStatusError>> {
let p_query_agreement_code = agreement_code;
let p_query_content_id = content_id;
let p_query_version = version;
let uri_str = format!("{}/agreement", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("agreementCode", &p_query_agreement_code.to_string())]);
req_builder = req_builder.query(&[("contentId", &p_query_content_id.to_string())]);
req_builder = req_builder.query(&[("version", &p_query_version.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgreementStatus`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AgreementStatus`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetContentAgreementStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_file(
configuration: &configuration::Configuration,
file_id: &str,
) -> Result<models::File, Error<GetFileError>> {
let p_path_file_id = file_id;
let uri_str = format!(
"{}/file/{fileId}",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_file_analysis(
configuration: &configuration::Configuration,
file_id: &str,
version_id: i32,
) -> Result<models::FileAnalysis, Error<GetFileAnalysisError>> {
let p_path_file_id = file_id;
let p_path_version_id = version_id;
let uri_str = format!(
"{}/analysis/{fileId}/{versionId}",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id),
versionId = p_path_version_id
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileAnalysis`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileAnalysis`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFileAnalysisError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_file_analysis_security(
configuration: &configuration::Configuration,
file_id: &str,
version_id: i32,
) -> Result<models::FileAnalysis, Error<GetFileAnalysisSecurityError>> {
let p_path_file_id = file_id;
let p_path_version_id = version_id;
let uri_str = format!(
"{}/analysis/{fileId}/{versionId}/security",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id),
versionId = p_path_version_id
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileAnalysis`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileAnalysis`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFileAnalysisSecurityError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_file_analysis_standard(
configuration: &configuration::Configuration,
file_id: &str,
version_id: i32,
) -> Result<models::FileAnalysis, Error<GetFileAnalysisStandardError>> {
let p_path_file_id = file_id;
let p_path_version_id = version_id;
let uri_str = format!(
"{}/analysis/{fileId}/{versionId}/standard",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id),
versionId = p_path_version_id
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileAnalysis`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileAnalysis`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFileAnalysisStandardError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_file_data_upload_status(
configuration: &configuration::Configuration,
file_id: &str,
version_id: i32,
file_type: &str,
) -> Result<models::FileVersionUploadStatus, Error<GetFileDataUploadStatusError>> {
let p_path_file_id = file_id;
let p_path_version_id = version_id;
let p_path_file_type = file_type;
let uri_str = format!(
"{}/file/{fileId}/{versionId}/{fileType}/status",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id),
versionId = p_path_version_id,
fileType = crate::apis::urlencode(p_path_file_type)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileVersionUploadStatus`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileVersionUploadStatus`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFileDataUploadStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_files(
configuration: &configuration::Configuration,
tag: Option<&str>,
user_id: Option<&str>,
n: Option<i32>,
offset: Option<i32>,
) -> Result<Vec<models::File>, Error<GetFilesError>> {
let p_query_tag = tag;
let p_query_user_id = user_id;
let p_query_n = n;
let p_query_offset = offset;
let uri_str = format!("{}/files", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_tag {
req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_user_id {
req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::File>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::File>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFilesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn set_group_gallery_file_order(
configuration: &configuration::Configuration,
group_gallery_file_order_request: Option<models::GroupGalleryFileOrderRequest>,
) -> Result<models::GroupGalleryFileOrder, Error<SetGroupGalleryFileOrderError>> {
let p_body_group_gallery_file_order_request = group_gallery_file_order_request;
let uri_str = format!("{}/files/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_group_gallery_file_order_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GroupGalleryFileOrder`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GroupGalleryFileOrder`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetGroupGalleryFileOrderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn start_file_data_upload(
configuration: &configuration::Configuration,
file_id: &str,
version_id: i32,
file_type: &str,
part_number: Option<i32>,
) -> Result<models::FileUploadUrl, Error<StartFileDataUploadError>> {
let p_path_file_id = file_id;
let p_path_version_id = version_id;
let p_path_file_type = file_type;
let p_query_part_number = part_number;
let uri_str = format!(
"{}/file/{fileId}/{versionId}/{fileType}/start",
configuration.base_path,
fileId = crate::apis::urlencode(p_path_file_id),
versionId = p_path_version_id,
fileType = crate::apis::urlencode(p_path_file_type)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_query_part_number {
req_builder = req_builder.query(&[("partNumber", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileUploadUrl`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileUploadUrl`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StartFileDataUploadError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn submit_content_agreement(
configuration: &configuration::Configuration,
agreement_request: Option<models::AgreementRequest>,
) -> Result<models::Agreement, Error<SubmitContentAgreementError>> {
let p_body_agreement_request = agreement_request;
let uri_str = format!("{}/agreement", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_agreement_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Agreement`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Agreement`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubmitContentAgreementError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_asset_review_notes(
configuration: &configuration::Configuration,
asset_review_id: &str,
update_asset_review_notes_request: Option<models::UpdateAssetReviewNotesRequest>,
) -> Result<(), Error<UpdateAssetReviewNotesError>> {
let p_path_asset_review_id = asset_review_id;
let p_body_update_asset_review_notes_request = update_asset_review_notes_request;
let uri_str = format!(
"{}/assetReview/{assetReviewId}/notes",
configuration.base_path,
assetReviewId = crate::apis::urlencode(p_path_asset_review_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_update_asset_review_notes_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<UpdateAssetReviewNotesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn upload_gallery_image(
configuration: &configuration::Configuration,
file: crate::patches::better_file_upload::File<'_>,
) -> Result<models::File, Error<UploadGalleryImageError>> {
let p_form_file = file;
let uri_str = format!("{}/gallery", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form = reqwest::multipart::Form::new();
multipart_form = multipart_form.part("file", p_form_file.get_multipart().await?);
req_builder = req_builder.multipart(multipart_form);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UploadGalleryImageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn upload_icon(
configuration: &configuration::Configuration,
file: crate::patches::better_file_upload::File<'_>,
) -> Result<models::File, Error<UploadIconError>> {
let p_form_file = file;
let uri_str = format!("{}/icon", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form = reqwest::multipart::Form::new();
multipart_form = multipart_form.part("file", p_form_file.get_multipart().await?);
req_builder = req_builder.multipart(multipart_form);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UploadIconError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn upload_image(
configuration: &configuration::Configuration,
file: crate::patches::better_file_upload::File<'_>,
tag: models::ImagePurpose,
animation_style: Option<models::ImageAnimationStyle>,
frames: Option<i32>,
frames_over_time: Option<i32>,
loop_style: Option<models::ImageLoopStyle>,
mask_tag: Option<models::ImageMask>,
) -> Result<models::File, Error<UploadImageError>> {
let p_form_file = file;
let p_form_tag = tag;
let p_form_animation_style = animation_style;
let p_form_frames = frames;
let p_form_frames_over_time = frames_over_time;
let p_form_loop_style = loop_style;
let p_form_mask_tag = mask_tag;
let uri_str = format!("{}/file/image", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form = reqwest::multipart::Form::new();
if let Some(param_value) = p_form_animation_style {
multipart_form =
multipart_form.text("animationStyle", serde_json::to_string(¶m_value)?);
}
multipart_form = multipart_form.part("file", p_form_file.get_multipart().await?);
if let Some(param_value) = p_form_frames {
multipart_form = multipart_form.text("frames", param_value.to_string());
}
if let Some(param_value) = p_form_frames_over_time {
multipart_form = multipart_form.text("framesOverTime", param_value.to_string());
}
if let Some(param_value) = p_form_loop_style {
multipart_form = multipart_form.text("loopStyle", serde_json::to_string(¶m_value)?);
}
if let Some(param_value) = p_form_mask_tag {
multipart_form = multipart_form.text("maskTag", serde_json::to_string(¶m_value)?);
}
macro_rules! serialize {
($form:ident, data, $data:ident) => {
$form = $form.text("data", serde_json::to_string(&$data)?);
};
($form:ident, $tag:ident, $data:ident) => {
$form = $form.text(stringify!($tag), $data.to_string());
};
}
serialize!(multipart_form, tag, p_form_tag);
req_builder = req_builder.multipart(multipart_form);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::File`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::File`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UploadImageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}