245 lines
10 KiB
Rust
245 lines
10 KiB
Rust
/*
|
|
* rfs
|
|
*
|
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
*
|
|
* The version of the OpenAPI document: 0.2.0
|
|
*
|
|
* Generated by: https://openapi-generator.tech
|
|
*/
|
|
|
|
|
|
use reqwest;
|
|
use serde::{Deserialize, Serialize, de::Error as _};
|
|
use crate::{apis::ResponseContent, models};
|
|
use super::{Error, configuration, ContentType};
|
|
|
|
|
|
/// struct for typed errors of method [`create_flist_handler`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum CreateFlistHandlerError {
|
|
Status401(models::ResponseError),
|
|
Status403(models::ResponseError),
|
|
Status409(models::ResponseError),
|
|
Status500(models::ResponseError),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`get_flist_state_handler`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum GetFlistStateHandlerError {
|
|
Status401(models::ResponseError),
|
|
Status403(models::ResponseError),
|
|
Status404(models::ResponseError),
|
|
Status500(models::ResponseError),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`list_flists_handler`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum ListFlistsHandlerError {
|
|
Status401(models::ResponseError),
|
|
Status403(models::ResponseError),
|
|
Status500(models::ResponseError),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`preview_flist_handler`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum PreviewFlistHandlerError {
|
|
Status400(models::ResponseError),
|
|
Status401(models::ResponseError),
|
|
Status403(models::ResponseError),
|
|
Status500(models::ResponseError),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
/// struct for typed errors of method [`serve_flists`]
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum ServeFlistsError {
|
|
Status404(models::ResponseError),
|
|
Status500(models::ResponseError),
|
|
UnknownValue(serde_json::Value),
|
|
}
|
|
|
|
|
|
pub async fn create_flist_handler(configuration: &configuration::Configuration, flist_body: models::FlistBody) -> Result<models::Job, Error<CreateFlistHandlerError>> {
|
|
// add a prefix to parameters to efficiently prevent name collisions
|
|
let p_flist_body = flist_body;
|
|
|
|
let uri_str = format!("{}/api/v1/fl", 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());
|
|
}
|
|
if let Some(ref token) = configuration.bearer_access_token {
|
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
|
};
|
|
req_builder = req_builder.json(&p_flist_body);
|
|
|
|
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::Job`"))),
|
|
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::Job`")))),
|
|
}
|
|
} else {
|
|
let content = resp.text().await?;
|
|
let entity: Option<CreateFlistHandlerError> = serde_json::from_str(&content).ok();
|
|
Err(Error::ResponseError(ResponseContent { status, content, entity }))
|
|
}
|
|
}
|
|
|
|
pub async fn get_flist_state_handler(configuration: &configuration::Configuration, job_id: &str) -> Result<models::FlistStateResponse, Error<GetFlistStateHandlerError>> {
|
|
// add a prefix to parameters to efficiently prevent name collisions
|
|
let p_job_id = job_id;
|
|
|
|
let uri_str = format!("{}/api/v1/fl/{job_id}", configuration.base_path, job_id=crate::apis::urlencode(p_job_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());
|
|
}
|
|
if let Some(ref token) = configuration.bearer_access_token {
|
|
req_builder = req_builder.bearer_auth(token.to_owned());
|
|
};
|
|
|
|
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::FlistStateResponse`"))),
|
|
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::FlistStateResponse`")))),
|
|
}
|
|
} else {
|
|
let content = resp.text().await?;
|
|
let entity: Option<GetFlistStateHandlerError> = serde_json::from_str(&content).ok();
|
|
Err(Error::ResponseError(ResponseContent { status, content, entity }))
|
|
}
|
|
}
|
|
|
|
pub async fn list_flists_handler(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, Vec<models::FileInfo>>, Error<ListFlistsHandlerError>> {
|
|
|
|
let uri_str = format!("{}/api/v1/fl", configuration.base_path);
|
|
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 `std::collections::HashMap<String, Vec<models::FileInfo>>`"))),
|
|
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, Vec<models::FileInfo>>`")))),
|
|
}
|
|
} else {
|
|
let content = resp.text().await?;
|
|
let entity: Option<ListFlistsHandlerError> = serde_json::from_str(&content).ok();
|
|
Err(Error::ResponseError(ResponseContent { status, content, entity }))
|
|
}
|
|
}
|
|
|
|
pub async fn preview_flist_handler(configuration: &configuration::Configuration, flist_path: &str) -> Result<models::PreviewResponse, Error<PreviewFlistHandlerError>> {
|
|
// add a prefix to parameters to efficiently prevent name collisions
|
|
let p_flist_path = flist_path;
|
|
|
|
let uri_str = format!("{}/api/v1/fl/preview/{flist_path}", configuration.base_path, flist_path=crate::apis::urlencode(p_flist_path));
|
|
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::PreviewResponse`"))),
|
|
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::PreviewResponse`")))),
|
|
}
|
|
} else {
|
|
let content = resp.text().await?;
|
|
let entity: Option<PreviewFlistHandlerError> = serde_json::from_str(&content).ok();
|
|
Err(Error::ResponseError(ResponseContent { status, content, entity }))
|
|
}
|
|
}
|
|
|
|
pub async fn serve_flists(configuration: &configuration::Configuration, path: &str) -> Result<reqwest::Response, Error<ServeFlistsError>> {
|
|
// add a prefix to parameters to efficiently prevent name collisions
|
|
let p_path = path;
|
|
|
|
let uri_str = format!("{}/{path}", configuration.base_path, path=crate::apis::urlencode(p_path));
|
|
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<ServeFlistsError> = serde_json::from_str(&content).ok();
|
|
Err(Error::ResponseError(ResponseContent { status, content, entity }))
|
|
}
|
|
}
|
|
|