use super::{ContentType, Error, configuration};
use crate::clients::rest::{apis::ResponseContent, models};
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum V1DagListTasksError {
Status400(models::V1TaskGet400Response),
Status403(models::V1TaskGet400Response),
Status501(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum V1TaskCancelError {
Status400(models::V1TaskGet400Response),
Status403(models::V1TaskGet400Response),
Status404(models::V1TaskGet400Response),
Status501(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum V1TaskEventListError {
Status400(models::V1TaskGet400Response),
Status403(models::V1TaskGet400Response),
Status404(models::V1TaskGet400Response),
Status501(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum V1TaskGetError {
Status400(models::V1TaskGet400Response),
Status403(models::V1TaskGet400Response),
Status404(models::V1TaskGet400Response),
Status501(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum V1TaskGetPointMetricsError {
Status400(models::V1TaskGet400Response),
Status403(models::V1TaskGet400Response),
Status501(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum V1TaskListStatusMetricsError {
Status400(models::V1TaskGet400Response),
Status403(models::V1TaskGet400Response),
Status501(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum V1TaskReplayError {
Status400(models::V1TaskGet400Response),
Status403(models::V1TaskGet400Response),
Status404(models::V1TaskGet400Response),
Status501(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
pub async fn v1_dag_list_tasks(
configuration: &configuration::Configuration,
dag_ids: Vec<uuid::Uuid>,
tenant: &str,
) -> Result<Vec<models::V1DagListTasks200ResponseInner>, Error<V1DagListTasksError>> {
let p_dag_ids = dag_ids;
let p_tenant = tenant;
let uri_str = format!("{}/api/v1/stable/dags/tasks", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = match "multi" {
"multi" => req_builder.query(
&p_dag_ids
.into_iter()
.map(|p| ("dag_ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"dag_ids",
&p_dag_ids
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
req_builder = req_builder.query(&[("tenant", &p_tenant.to_string())]);
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 `Vec<models::V1DagListTasks200ResponseInner>`",
)));
}
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::V1DagListTasks200ResponseInner>`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<V1DagListTasksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn v1_task_cancel(
configuration: &configuration::Configuration,
tenant: &str,
v1_task_cancel_request: models::V1TaskCancelRequest,
) -> Result<models::V1TaskCancel200Response, Error<V1TaskCancelError>> {
let p_tenant = tenant;
let p_v1_task_cancel_request = v1_task_cancel_request;
let uri_str = format!(
"{}/api/v1/stable/tenants/{tenant}/tasks/cancel",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant)
);
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_v1_task_cancel_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::V1TaskCancel200Response`",
)));
}
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::V1TaskCancel200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<V1TaskCancelError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn v1_task_event_list(
configuration: &configuration::Configuration,
task: &str,
offset: Option<i64>,
limit: Option<i64>,
) -> Result<models::V1TaskEventList200Response, Error<V1TaskEventListError>> {
let p_task = task;
let p_offset = offset;
let p_limit = limit;
let uri_str = format!(
"{}/api/v1/stable/tasks/{task}/task-events",
configuration.base_path,
task = crate::clients::rest::apis::urlencode(p_task)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_limit {
req_builder = req_builder.query(&[("limit", ¶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());
}
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::V1TaskEventList200Response`",
)));
}
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::V1TaskEventList200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<V1TaskEventListError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn v1_task_get(
configuration: &configuration::Configuration,
task: &str,
attempt: Option<i32>,
) -> Result<models::V1TaskGet200Response, Error<V1TaskGetError>> {
let p_task = task;
let p_attempt = attempt;
let uri_str = format!(
"{}/api/v1/stable/tasks/{task}",
configuration.base_path,
task = crate::clients::rest::apis::urlencode(p_task)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_attempt {
req_builder = req_builder.query(&[("attempt", ¶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());
}
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::V1TaskGet200Response`",
)));
}
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::V1TaskGet200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<V1TaskGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn v1_task_get_point_metrics(
configuration: &configuration::Configuration,
tenant: &str,
created_after: Option<String>,
finished_before: Option<String>,
) -> Result<models::V1TaskGetPointMetrics200Response, Error<V1TaskGetPointMetricsError>> {
let p_tenant = tenant;
let p_created_after = created_after;
let p_finished_before = finished_before;
let uri_str = format!(
"{}/api/v1/stable/tenants/{tenant}/task-point-metrics",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_created_after {
req_builder = req_builder.query(&[("createdAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_finished_before {
req_builder = req_builder.query(&[("finishedBefore", ¶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());
}
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::V1TaskGetPointMetrics200Response`",
)));
}
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::V1TaskGetPointMetrics200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<V1TaskGetPointMetricsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn v1_task_list_status_metrics(
configuration: &configuration::Configuration,
tenant: &str,
since: String,
until: Option<String>,
workflow_ids: Option<Vec<uuid::Uuid>>,
parent_task_external_id: Option<&str>,
triggering_event_external_id: Option<&str>,
) -> Result<Vec<models::V1TaskListStatusMetrics200ResponseInner>, Error<V1TaskListStatusMetricsError>>
{
let p_tenant = tenant;
let p_since = since;
let p_until = until;
let p_workflow_ids = workflow_ids;
let p_parent_task_external_id = parent_task_external_id;
let p_triggering_event_external_id = triggering_event_external_id;
let uri_str = format!(
"{}/api/v1/stable/tenants/{tenant}/task-metrics",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("since", &p_since.to_string())]);
if let Some(ref param_value) = p_until {
req_builder = req_builder.query(&[("until", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_workflow_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("workflow_ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"workflow_ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_parent_task_external_id {
req_builder = req_builder.query(&[("parent_task_external_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_triggering_event_external_id {
req_builder =
req_builder.query(&[("triggering_event_external_id", ¶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());
}
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 `Vec<models::V1TaskListStatusMetrics200ResponseInner>`",
)));
}
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::V1TaskListStatusMetrics200ResponseInner>`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<V1TaskListStatusMetricsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn v1_task_replay(
configuration: &configuration::Configuration,
tenant: &str,
v1_task_cancel_request: models::V1TaskCancelRequest,
) -> Result<models::V1TaskReplay200Response, Error<V1TaskReplayError>> {
let p_tenant = tenant;
let p_v1_task_cancel_request = v1_task_cancel_request;
let uri_str = format!(
"{}/api/v1/stable/tenants/{tenant}/tasks/replay",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant)
);
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_v1_task_cancel_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::V1TaskReplay200Response`",
)));
}
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::V1TaskReplay200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<V1TaskReplayError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}