use super::ResponseContent;
use super::{ContentType, Error, configuration};
use crate::models;
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSlurmSchedulerError {
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSlurmSchedulerError {
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSlurmSchedulersError {
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSlurmSchedulerError {
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSlurmSchedulersError {
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateSlurmSchedulerError {
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
pub fn create_slurm_scheduler(
configuration: &configuration::Configuration,
slurm_scheduler_model: models::SlurmSchedulerModel,
) -> Result<models::SlurmSchedulerModel, Error<CreateSlurmSchedulerError>> {
let p_body_slurm_scheduler_model = slurm_scheduler_model;
let uri_str = format!("{}/slurm_schedulers", 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 = configuration.apply_auth(req_builder);
req_builder = req_builder.json(&p_body_slurm_scheduler_model);
let req = req_builder.build()?;
let resp = configuration.client.execute(req)?;
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()?;
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::SlurmSchedulerModel`",
)));
}
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::SlurmSchedulerModel`"
))));
}
}
} else {
let content = resp.text()?;
let entity: Option<CreateSlurmSchedulerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn delete_slurm_scheduler(
configuration: &configuration::Configuration,
id: i64,
) -> Result<models::SlurmSchedulerModel, Error<DeleteSlurmSchedulerError>> {
let p_path_id = id;
let uri_str = format!(
"{}/slurm_schedulers/{id}",
configuration.base_path,
id = p_path_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());
}
req_builder = configuration.apply_auth(req_builder);
let req = req_builder.build()?;
let resp = configuration.client.execute(req)?;
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()?;
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::SlurmSchedulerModel`",
)));
}
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::SlurmSchedulerModel`"
))));
}
}
} else {
let content = resp.text()?;
let entity: Option<DeleteSlurmSchedulerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn delete_slurm_schedulers(
configuration: &configuration::Configuration,
workflow_id: i64,
) -> Result<models::DeleteCountResponse, Error<DeleteSlurmSchedulersError>> {
let p_query_workflow_id = workflow_id;
let uri_str = format!("{}/slurm_schedulers", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("workflow_id", &p_query_workflow_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = configuration.apply_auth(req_builder);
let req = req_builder.build()?;
let resp = configuration.client.execute(req)?;
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()?;
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::DeleteCountResponse`",
)));
}
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::DeleteCountResponse`"
))));
}
}
} else {
let content = resp.text()?;
let entity: Option<DeleteSlurmSchedulersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn get_slurm_scheduler(
configuration: &configuration::Configuration,
id: i64,
) -> Result<models::SlurmSchedulerModel, Error<GetSlurmSchedulerError>> {
let p_path_id = id;
let uri_str = format!(
"{}/slurm_schedulers/{id}",
configuration.base_path,
id = p_path_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());
}
req_builder = configuration.apply_auth(req_builder);
let req = req_builder.build()?;
let resp = configuration.client.execute(req)?;
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()?;
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::SlurmSchedulerModel`",
)));
}
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::SlurmSchedulerModel`"
))));
}
}
} else {
let content = resp.text()?;
let entity: Option<GetSlurmSchedulerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn list_slurm_schedulers(
configuration: &configuration::Configuration,
workflow_id: i64,
offset: Option<i64>,
limit: Option<i64>,
sort_by: Option<&str>,
reverse_sort: Option<bool>,
) -> Result<models::ListSlurmSchedulersResponse, Error<ListSlurmSchedulersError>> {
let p_query_workflow_id = workflow_id;
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort_by = sort_by;
let p_query_reverse_sort = reverse_sort;
let uri_str = format!("{}/slurm_schedulers", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("workflow_id", &p_query_workflow_id.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 param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort_by {
req_builder = req_builder.query(&[("sort_by", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_reverse_sort {
req_builder = req_builder.query(&[("reverse_sort", ¶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());
}
req_builder = configuration.apply_auth(req_builder);
let req = req_builder.build()?;
let resp = configuration.client.execute(req)?;
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()?;
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::ListSlurmSchedulersResponse`",
)));
}
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::ListSlurmSchedulersResponse`"
))));
}
}
} else {
let content = resp.text()?;
let entity: Option<ListSlurmSchedulersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn update_slurm_scheduler(
configuration: &configuration::Configuration,
id: i64,
slurm_scheduler_model: models::SlurmSchedulerModel,
) -> Result<models::SlurmSchedulerModel, Error<UpdateSlurmSchedulerError>> {
let p_path_id = id;
let p_body_slurm_scheduler_model = slurm_scheduler_model;
let uri_str = format!(
"{}/slurm_schedulers/{id}",
configuration.base_path,
id = p_path_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 = configuration.apply_auth(req_builder);
req_builder = req_builder.json(&p_body_slurm_scheduler_model);
let req = req_builder.build()?;
let resp = configuration.client.execute(req)?;
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()?;
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::SlurmSchedulerModel`",
)));
}
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::SlurmSchedulerModel`"
))));
}
}
} else {
let content = resp.text()?;
let entity: Option<UpdateSlurmSchedulerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}