/*
* Windmill API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.684.1
* Contact: contact@windmill.dev
* 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 [`delete_concurrency_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteConcurrencyGroupError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_concurrency_key`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetConcurrencyKeyError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_concurrency_groups`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListConcurrencyGroupsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_extended_jobs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListExtendedJobsError {
UnknownValue(serde_json::Value),
}
pub async fn delete_concurrency_group(configuration: &configuration::Configuration, concurrency_id: &str) -> Result<serde_json::Value, Error<DeleteConcurrencyGroupError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/concurrency_groups/prune/{concurrency_id}", local_var_configuration.base_path, concurrency_id=crate::apis::urlencode(concurrency_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, 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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
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() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DeleteConcurrencyGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&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 get_concurrency_key(configuration: &configuration::Configuration, id: &str) -> Result<String, Error<GetConcurrencyKeyError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/concurrency_groups/{id}/key", local_var_configuration.base_path, id=crate::apis::urlencode(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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
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() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetConcurrencyKeyError> = crate::from_str_patched/* Externally injected from /build.nu */(&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 list_concurrency_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ConcurrencyGroup>, Error<ListConcurrencyGroupsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/concurrency_groups/list", local_var_configuration.base_path);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
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() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListConcurrencyGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&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 list_extended_jobs(configuration: &configuration::Configuration, workspace: &str, concurrency_key: Option<&str>, row_limit: Option<f64>, created_by: Option<&str>, label: Option<&str>, parent_job: Option<&str>, script_path_exact: Option<&str>, script_path_start: Option<&str>, schedule_path: Option<&str>, script_hash: Option<&str>, started_before: Option<String>, started_after: Option<String>, running: Option<bool>, scheduled_for_before_now: Option<bool>, completed_before: Option<String>, completed_after: Option<String>, created_before_queue: Option<String>, created_after_queue: Option<String>, job_kinds: Option<&str>, args: Option<&str>, tag: Option<&str>, result: Option<&str>, allow_wildcards: Option<bool>, page: Option<i32>, per_page: Option<i32>, trigger_kind: Option<&str>, is_skipped: Option<bool>, is_flow_step: Option<bool>, has_null_parent: Option<bool>, success: Option<bool>, all_workspaces: Option<bool>, is_not_schedule: Option<bool>) -> Result<models::ExtendedJobs, Error<ListExtendedJobsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/w/{workspace}/concurrency_groups/list_jobs", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
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_str) = concurrency_key {
local_var_req_builder = local_var_req_builder.query(&[("concurrency_key", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = row_limit {
local_var_req_builder = local_var_req_builder.query(&[("row_limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = created_by {
local_var_req_builder = local_var_req_builder.query(&[("created_by", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = label {
local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = parent_job {
local_var_req_builder = local_var_req_builder.query(&[("parent_job", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = script_path_exact {
local_var_req_builder = local_var_req_builder.query(&[("script_path_exact", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = script_path_start {
local_var_req_builder = local_var_req_builder.query(&[("script_path_start", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = schedule_path {
local_var_req_builder = local_var_req_builder.query(&[("schedule_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = script_hash {
local_var_req_builder = local_var_req_builder.query(&[("script_hash", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = started_before {
local_var_req_builder = local_var_req_builder.query(&[("started_before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = started_after {
local_var_req_builder = local_var_req_builder.query(&[("started_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = running {
local_var_req_builder = local_var_req_builder.query(&[("running", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scheduled_for_before_now {
local_var_req_builder = local_var_req_builder.query(&[("scheduled_for_before_now", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = completed_before {
local_var_req_builder = local_var_req_builder.query(&[("completed_before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = completed_after {
local_var_req_builder = local_var_req_builder.query(&[("completed_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = created_before_queue {
local_var_req_builder = local_var_req_builder.query(&[("created_before_queue", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = created_after_queue {
local_var_req_builder = local_var_req_builder.query(&[("created_after_queue", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = job_kinds {
local_var_req_builder = local_var_req_builder.query(&[("job_kinds", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = args {
local_var_req_builder = local_var_req_builder.query(&[("args", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = tag {
local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = result {
local_var_req_builder = local_var_req_builder.query(&[("result", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_wildcards {
local_var_req_builder = local_var_req_builder.query(&[("allow_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = trigger_kind {
local_var_req_builder = local_var_req_builder.query(&[("trigger_kind", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = is_skipped {
local_var_req_builder = local_var_req_builder.query(&[("is_skipped", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = is_flow_step {
local_var_req_builder = local_var_req_builder.query(&[("is_flow_step", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = has_null_parent {
local_var_req_builder = local_var_req_builder.query(&[("has_null_parent", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = success {
local_var_req_builder = local_var_req_builder.query(&[("success", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = all_workspaces {
local_var_req_builder = local_var_req_builder.query(&[("all_workspaces", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = is_not_schedule {
local_var_req_builder = local_var_req_builder.query(&[("is_not_schedule", &local_var_str.to_string())]);
}
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
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() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListExtendedJobsError> = crate::from_str_patched/* Externally injected from /build.nu */(&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))
}
}