/*
* The Jira Cloud platform REST API
*
* Jira Cloud platform REST API documentation
*
* The version of the OpenAPI document: 1001.0.0-SNAPSHOT
* Contact: ecosystem@atlassian.com
* 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 [`create_workflow_transition_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateWorkflowTransitionPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_workflow_transition_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteWorkflowTransitionPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_workflow_transition_properties`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWorkflowTransitionPropertiesError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_workflow_transition_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateWorkflowTransitionPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// Adds a property to a workflow transition. Transition properties are used to change the behavior of a transition. For more information, see [Transition properties](https://confluence.atlassian.com/x/zIhKLg#Advancedworkflowconfiguration-transitionproperties) and [Workflow properties](https://confluence.atlassian.com/x/JYlKLg). **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn create_workflow_transition_property(configuration: &configuration::Configuration, transition_id: i64, key: &str, workflow_name: &str, workflow_transition_property: models::WorkflowTransitionProperty, workflow_mode: Option<&str>) -> Result<models::WorkflowTransitionProperty, Error<CreateWorkflowTransitionPropertyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_transition_id = transition_id;
let p_key = key;
let p_workflow_name = workflow_name;
let p_workflow_transition_property = workflow_transition_property;
let p_workflow_mode = workflow_mode;
let uri_str = format!("{}/rest/api/2/workflow/transitions/{transitionId}/properties", configuration.base_path, transitionId=p_transition_id);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("key", &p_key.to_string())]);
req_builder = req_builder.query(&[("workflowName", &p_workflow_name.to_string())]);
if let Some(ref param_value) = p_workflow_mode {
req_builder = req_builder.query(&[("workflowMode", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_workflow_transition_property);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
serde_json::from_str(&content).map_err(Error::from)
} else {
let content = resp.text().await?;
let entity: Option<CreateWorkflowTransitionPropertyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deletes a property from a workflow transition. Transition properties are used to change the behavior of a transition. For more information, see [Transition properties](https://confluence.atlassian.com/x/zIhKLg#Advancedworkflowconfiguration-transitionproperties) and [Workflow properties](https://confluence.atlassian.com/x/JYlKLg). **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn delete_workflow_transition_property(configuration: &configuration::Configuration, transition_id: i64, key: &str, workflow_name: &str, workflow_mode: Option<&str>) -> Result<(), Error<DeleteWorkflowTransitionPropertyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_transition_id = transition_id;
let p_key = key;
let p_workflow_name = workflow_name;
let p_workflow_mode = workflow_mode;
let uri_str = format!("{}/rest/api/2/workflow/transitions/{transitionId}/properties", configuration.base_path, transitionId=p_transition_id);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("key", &p_key.to_string())]);
req_builder = req_builder.query(&[("workflowName", &p_workflow_name.to_string())]);
if let Some(ref param_value) = p_workflow_mode {
req_builder = req_builder.query(&[("workflowMode", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DeleteWorkflowTransitionPropertyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns the properties on a workflow transition. Transition properties are used to change the behavior of a transition. For more information, see [Transition properties](https://confluence.atlassian.com/x/zIhKLg#Advancedworkflowconfiguration-transitionproperties) and [Workflow properties](https://confluence.atlassian.com/x/JYlKLg). **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn get_workflow_transition_properties(configuration: &configuration::Configuration, transition_id: i64, workflow_name: &str, include_reserved_keys: Option<bool>, key: Option<&str>, workflow_mode: Option<&str>) -> Result<models::WorkflowTransitionProperty, Error<GetWorkflowTransitionPropertiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_transition_id = transition_id;
let p_workflow_name = workflow_name;
let p_include_reserved_keys = include_reserved_keys;
let p_key = key;
let p_workflow_mode = workflow_mode;
let uri_str = format!("{}/rest/api/2/workflow/transitions/{transitionId}/properties", configuration.base_path, transitionId=p_transition_id);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_include_reserved_keys {
req_builder = req_builder.query(&[("includeReservedKeys", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_key {
req_builder = req_builder.query(&[("key", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("workflowName", &p_workflow_name.to_string())]);
if let Some(ref param_value) = p_workflow_mode {
req_builder = req_builder.query(&[("workflowMode", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
serde_json::from_str(&content).map_err(Error::from)
} else {
let content = resp.text().await?;
let entity: Option<GetWorkflowTransitionPropertiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Updates a workflow transition by changing the property value. Trying to update a property that does not exist results in a new property being added to the transition. Transition properties are used to change the behavior of a transition. For more information, see [Transition properties](https://confluence.atlassian.com/x/zIhKLg#Advancedworkflowconfiguration-transitionproperties) and [Workflow properties](https://confluence.atlassian.com/x/JYlKLg). **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn update_workflow_transition_property(configuration: &configuration::Configuration, transition_id: i64, key: &str, workflow_name: &str, workflow_transition_property: models::WorkflowTransitionProperty, workflow_mode: Option<&str>) -> Result<models::WorkflowTransitionProperty, Error<UpdateWorkflowTransitionPropertyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_transition_id = transition_id;
let p_key = key;
let p_workflow_name = workflow_name;
let p_workflow_transition_property = workflow_transition_property;
let p_workflow_mode = workflow_mode;
let uri_str = format!("{}/rest/api/2/workflow/transitions/{transitionId}/properties", configuration.base_path, transitionId=p_transition_id);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
req_builder = req_builder.query(&[("key", &p_key.to_string())]);
req_builder = req_builder.query(&[("workflowName", &p_workflow_name.to_string())]);
if let Some(ref param_value) = p_workflow_mode {
req_builder = req_builder.query(&[("workflowMode", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_workflow_transition_property);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
serde_json::from_str(&content).map_err(Error::from)
} else {
let content = resp.text().await?;
let entity: Option<UpdateWorkflowTransitionPropertyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}