/*
* authentik
*
* Making authentication simple.
*
* The version of the OpenAPI document: 2024.2.1
* Contact: hello@goauthentik.io
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
/// struct for typed errors of method [`flows_bindings_create`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsBindingsCreateError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_bindings_destroy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsBindingsDestroyError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_bindings_list`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsBindingsListError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_bindings_partial_update`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsBindingsPartialUpdateError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_bindings_retrieve`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsBindingsRetrieveError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_bindings_update`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsBindingsUpdateError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_bindings_used_by_list`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsBindingsUsedByListError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_executor_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsExecutorGetError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_executor_solve`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsExecutorSolveError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_inspector_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInspectorGetError {
Status400(),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_cache_clear_create`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesCacheClearCreateError {
Status400(),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_cache_info_retrieve`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesCacheInfoRetrieveError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_create`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesCreateError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_destroy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesDestroyError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_diagram_retrieve`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesDiagramRetrieveError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_execute_retrieve`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesExecuteRetrieveError {
Status400(),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_export_retrieve`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesExportRetrieveError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_import_create`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesImportCreateError {
Status400(models::FlowImportResult),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_list`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesListError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_partial_update`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesPartialUpdateError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_retrieve`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesRetrieveError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_set_background_create`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesSetBackgroundCreateError {
Status400(),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_set_background_url_create`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesSetBackgroundUrlCreateError {
Status400(),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_update`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesUpdateError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`flows_instances_used_by_list`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FlowsInstancesUsedByListError {
Status400(models::ValidationError),
Status403(models::GenericError),
UnknownValue(serde_json::Value),
}
/// FlowStageBinding Viewset
pub async fn flows_bindings_create(configuration: &configuration::Configuration, flow_stage_binding_request: models::FlowStageBindingRequest) -> Result<models::FlowStageBinding, Error<FlowsBindingsCreateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/bindings/", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&flow_stage_binding_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsBindingsCreateError> = serde_json::from_str(&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))
}
}
/// FlowStageBinding Viewset
pub async fn flows_bindings_destroy(configuration: &configuration::Configuration, fsb_uuid: &str) -> Result<(), Error<FlowsBindingsDestroyError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/bindings/{fsb_uuid}/", local_var_configuration.base_path, fsb_uuid=crate::apis::urlencode(fsb_uuid));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<FlowsBindingsDestroyError> = serde_json::from_str(&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))
}
}
/// FlowStageBinding Viewset
pub async fn flows_bindings_list(configuration: &configuration::Configuration, evaluate_on_plan: Option<bool>, fsb_uuid: Option<&str>, invalid_response_action: Option<&str>, order: Option<i32>, ordering: Option<&str>, page: Option<i32>, page_size: Option<i32>, pbm_uuid: Option<&str>, policies: Option<Vec<uuid::Uuid>>, policy_engine_mode: Option<&str>, re_evaluate_policies: Option<bool>, search: Option<&str>, stage: Option<&str>, target: Option<&str>) -> Result<models::PaginatedFlowStageBindingList, Error<FlowsBindingsListError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/bindings/", 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_str) = evaluate_on_plan {
local_var_req_builder = local_var_req_builder.query(&[("evaluate_on_plan", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = fsb_uuid {
local_var_req_builder = local_var_req_builder.query(&[("fsb_uuid", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = invalid_response_action {
local_var_req_builder = local_var_req_builder.query(&[("invalid_response_action", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = order {
local_var_req_builder = local_var_req_builder.query(&[("order", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ordering {
local_var_req_builder = local_var_req_builder.query(&[("ordering", &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) = page_size {
local_var_req_builder = local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pbm_uuid {
local_var_req_builder = local_var_req_builder.query(&[("pbm_uuid", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = policies {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("policies".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("policies", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = policy_engine_mode {
local_var_req_builder = local_var_req_builder.query(&[("policy_engine_mode", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = re_evaluate_policies {
local_var_req_builder = local_var_req_builder.query(&[("re_evaluate_policies", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search {
local_var_req_builder = local_var_req_builder.query(&[("search", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stage {
local_var_req_builder = local_var_req_builder.query(&[("stage", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = target {
local_var_req_builder = local_var_req_builder.query(&[("target", &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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsBindingsListError> = serde_json::from_str(&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))
}
}
/// FlowStageBinding Viewset
pub async fn flows_bindings_partial_update(configuration: &configuration::Configuration, fsb_uuid: &str, patched_flow_stage_binding_request: Option<models::PatchedFlowStageBindingRequest>) -> Result<models::FlowStageBinding, Error<FlowsBindingsPartialUpdateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/bindings/{fsb_uuid}/", local_var_configuration.base_path, fsb_uuid=crate::apis::urlencode(fsb_uuid));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&patched_flow_stage_binding_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsBindingsPartialUpdateError> = serde_json::from_str(&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))
}
}
/// FlowStageBinding Viewset
pub async fn flows_bindings_retrieve(configuration: &configuration::Configuration, fsb_uuid: &str) -> Result<models::FlowStageBinding, Error<FlowsBindingsRetrieveError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/bindings/{fsb_uuid}/", local_var_configuration.base_path, fsb_uuid=crate::apis::urlencode(fsb_uuid));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsBindingsRetrieveError> = serde_json::from_str(&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))
}
}
/// FlowStageBinding Viewset
pub async fn flows_bindings_update(configuration: &configuration::Configuration, fsb_uuid: &str, flow_stage_binding_request: models::FlowStageBindingRequest) -> Result<models::FlowStageBinding, Error<FlowsBindingsUpdateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/bindings/{fsb_uuid}/", local_var_configuration.base_path, fsb_uuid=crate::apis::urlencode(fsb_uuid));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&flow_stage_binding_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsBindingsUpdateError> = serde_json::from_str(&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))
}
}
/// Get a list of all objects that use this object
pub async fn flows_bindings_used_by_list(configuration: &configuration::Configuration, fsb_uuid: &str) -> Result<Vec<models::UsedBy>, Error<FlowsBindingsUsedByListError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/bindings/{fsb_uuid}/used_by/", local_var_configuration.base_path, fsb_uuid=crate::apis::urlencode(fsb_uuid));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsBindingsUsedByListError> = serde_json::from_str(&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))
}
}
/// Get the next pending challenge from the currently active flow.
pub async fn flows_executor_get(configuration: &configuration::Configuration, flow_slug: &str, query: &str) -> Result<models::ChallengeTypes, Error<FlowsExecutorGetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/executor/{flow_slug}/", local_var_configuration.base_path, flow_slug=crate::apis::urlencode(flow_slug));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("query", &query.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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsExecutorGetError> = serde_json::from_str(&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))
}
}
/// Solve the previously retrieved challenge and advanced to the next stage.
pub async fn flows_executor_solve(configuration: &configuration::Configuration, flow_slug: &str, query: &str, flow_challenge_response_request: Option<models::FlowChallengeResponseRequest>) -> Result<models::ChallengeTypes, Error<FlowsExecutorSolveError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/executor/{flow_slug}/", local_var_configuration.base_path, flow_slug=crate::apis::urlencode(flow_slug));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("query", &query.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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&flow_challenge_response_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsExecutorSolveError> = serde_json::from_str(&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))
}
}
/// Get current flow state and record it
pub async fn flows_inspector_get(configuration: &configuration::Configuration, flow_slug: &str) -> Result<models::FlowInspection, Error<FlowsInspectorGetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/inspector/{flow_slug}/", local_var_configuration.base_path, flow_slug=crate::apis::urlencode(flow_slug));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInspectorGetError> = serde_json::from_str(&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))
}
}
/// Clear flow cache
pub async fn flows_instances_cache_clear_create(configuration: &configuration::Configuration, ) -> Result<(), Error<FlowsInstancesCacheClearCreateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/cache_clear/", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<FlowsInstancesCacheClearCreateError> = serde_json::from_str(&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))
}
}
/// Info about cached flows
pub async fn flows_instances_cache_info_retrieve(configuration: &configuration::Configuration, ) -> Result<models::Cache, Error<FlowsInstancesCacheInfoRetrieveError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/cache_info/", 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesCacheInfoRetrieveError> = serde_json::from_str(&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))
}
}
/// Flow Viewset
pub async fn flows_instances_create(configuration: &configuration::Configuration, flow_request: models::FlowRequest) -> Result<models::Flow, Error<FlowsInstancesCreateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&flow_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesCreateError> = serde_json::from_str(&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))
}
}
/// Flow Viewset
pub async fn flows_instances_destroy(configuration: &configuration::Configuration, slug: &str) -> Result<(), Error<FlowsInstancesDestroyError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<FlowsInstancesDestroyError> = serde_json::from_str(&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))
}
}
/// Return diagram for flow with slug `slug`, in the format used by flowchart.js
pub async fn flows_instances_diagram_retrieve(configuration: &configuration::Configuration, slug: &str) -> Result<models::FlowDiagram, Error<FlowsInstancesDiagramRetrieveError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/diagram/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesDiagramRetrieveError> = serde_json::from_str(&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))
}
}
/// Execute flow for current user
pub async fn flows_instances_execute_retrieve(configuration: &configuration::Configuration, slug: &str) -> Result<models::Link, Error<FlowsInstancesExecuteRetrieveError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/execute/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesExecuteRetrieveError> = serde_json::from_str(&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))
}
}
/// Export flow to .yaml file
pub async fn flows_instances_export_retrieve(configuration: &configuration::Configuration, slug: &str) -> Result<std::path::PathBuf, Error<FlowsInstancesExportRetrieveError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/export/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesExportRetrieveError> = serde_json::from_str(&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))
}
}
/// Import flow from .yaml file
pub async fn flows_instances_import_create(configuration: &configuration::Configuration, file: Option<std::path::PathBuf>, clear: Option<bool>) -> Result<models::FlowImportResult, Error<FlowsInstancesImportCreateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/import/", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
let mut local_var_form = reqwest::multipart::Form::new();
// TODO: support file upload for 'file' parameter
if let Some(local_var_param_value) = clear {
local_var_form = local_var_form.text("clear", local_var_param_value.to_string());
}
local_var_req_builder = local_var_req_builder.multipart(local_var_form);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesImportCreateError> = serde_json::from_str(&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))
}
}
/// Flow Viewset
pub async fn flows_instances_list(configuration: &configuration::Configuration, denied_action: Option<&str>, designation: Option<&str>, flow_uuid: Option<&str>, name: Option<&str>, ordering: Option<&str>, page: Option<i32>, page_size: Option<i32>, search: Option<&str>, slug: Option<&str>) -> Result<models::PaginatedFlowList, Error<FlowsInstancesListError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/", 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_str) = denied_action {
local_var_req_builder = local_var_req_builder.query(&[("denied_action", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = designation {
local_var_req_builder = local_var_req_builder.query(&[("designation", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = flow_uuid {
local_var_req_builder = local_var_req_builder.query(&[("flow_uuid", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = name {
local_var_req_builder = local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ordering {
local_var_req_builder = local_var_req_builder.query(&[("ordering", &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) = page_size {
local_var_req_builder = local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search {
local_var_req_builder = local_var_req_builder.query(&[("search", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = slug {
local_var_req_builder = local_var_req_builder.query(&[("slug", &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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesListError> = serde_json::from_str(&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))
}
}
/// Flow Viewset
pub async fn flows_instances_partial_update(configuration: &configuration::Configuration, slug: &str, patched_flow_request: Option<models::PatchedFlowRequest>) -> Result<models::Flow, Error<FlowsInstancesPartialUpdateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&patched_flow_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesPartialUpdateError> = serde_json::from_str(&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))
}
}
/// Flow Viewset
pub async fn flows_instances_retrieve(configuration: &configuration::Configuration, slug: &str) -> Result<models::Flow, Error<FlowsInstancesRetrieveError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesRetrieveError> = serde_json::from_str(&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))
}
}
/// Set Flow background
pub async fn flows_instances_set_background_create(configuration: &configuration::Configuration, slug: &str, file: Option<std::path::PathBuf>, clear: Option<bool>) -> Result<(), Error<FlowsInstancesSetBackgroundCreateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/set_background/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
let mut local_var_form = reqwest::multipart::Form::new();
// TODO: support file upload for 'file' parameter
if let Some(local_var_param_value) = clear {
local_var_form = local_var_form.text("clear", local_var_param_value.to_string());
}
local_var_req_builder = local_var_req_builder.multipart(local_var_form);
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() {
Ok(())
} else {
let local_var_entity: Option<FlowsInstancesSetBackgroundCreateError> = serde_json::from_str(&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))
}
}
/// Set Flow background (as URL)
pub async fn flows_instances_set_background_url_create(configuration: &configuration::Configuration, slug: &str, file_path_request: models::FilePathRequest) -> Result<(), Error<FlowsInstancesSetBackgroundUrlCreateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/set_background_url/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&file_path_request);
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() {
Ok(())
} else {
let local_var_entity: Option<FlowsInstancesSetBackgroundUrlCreateError> = serde_json::from_str(&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))
}
}
/// Flow Viewset
pub async fn flows_instances_update(configuration: &configuration::Configuration, slug: &str, flow_request: models::FlowRequest) -> Result<models::Flow, Error<FlowsInstancesUpdateError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, 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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&flow_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesUpdateError> = serde_json::from_str(&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))
}
}
/// Get a list of all objects that use this object
pub async fn flows_instances_used_by_list(configuration: &configuration::Configuration, slug: &str) -> Result<Vec<models::UsedBy>, Error<FlowsInstancesUsedByListError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/flows/instances/{slug}/used_by/", local_var_configuration.base_path, slug=crate::apis::urlencode(slug));
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_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FlowsInstancesUsedByListError> = serde_json::from_str(&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))
}
}