jira_api_v2/apis/
workflow_transition_rules_api.rs

1/*
2 * The Jira Cloud platform REST API
3 *
4 * Jira Cloud platform REST API documentation
5 *
6 * The version of the OpenAPI document: 1001.0.0-SNAPSHOT
7 * Contact: ecosystem@atlassian.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`get_workflow_transition_rule_configurations`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetWorkflowTransitionRuleConfigurationsError {
22    Status400(models::ErrorCollection),
23    Status403(models::ErrorCollection),
24    Status404(),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`update_workflow_transition_rule_configurations`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum UpdateWorkflowTransitionRuleConfigurationsError {
32    Status400(models::ErrorCollection),
33    Status403(models::ErrorCollection),
34    UnknownValue(serde_json::Value),
35}
36
37
38/// Returns a [paginated](#pagination) list of workflows with transition rules. The workflows can be filtered to return only those containing workflow transition rules:   *  of one or more transition rule types, such as [workflow post functions](https://developer.atlassian.com/cloud/jira/platform/modules/workflow-post-function/).  *  matching one or more transition rule keys.  Only workflows containing transition rules created by the calling Connect app are returned. However, if a workflow is returned all transition rules that match the filters are returned for that workflow.  Due to server-side optimizations, workflows with an empty list of rules may be returned; these workflows can be ignored.  **[Permissions](#permissions) required:** Only Connect apps can use this operation.
39pub async fn get_workflow_transition_rule_configurations(configuration: &configuration::Configuration, types: Vec<String>, start_at: Option<i64>, max_results: Option<i32>, keys: Option<Vec<String>>, expand: Option<&str>) -> Result<models::PageBeanWorkflowTransitionRules, Error<GetWorkflowTransitionRuleConfigurationsError>> {
40    // add a prefix to parameters to efficiently prevent name collisions
41    let p_types = types;
42    let p_start_at = start_at;
43    let p_max_results = max_results;
44    let p_keys = keys;
45    let p_expand = expand;
46
47    let uri_str = format!("{}/rest/api/2/workflow/rule/config", configuration.base_path);
48    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
49
50    if let Some(ref param_value) = p_start_at {
51        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
52    }
53    if let Some(ref param_value) = p_max_results {
54        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
55    }
56    req_builder = match "multi" {
57        "multi" => req_builder.query(&p_types.into_iter().map(|p| ("types".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
58        _ => req_builder.query(&[("types", &p_types.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
59    };
60    if let Some(ref param_value) = p_keys {
61        req_builder = match "multi" {
62            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("keys".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
63            _ => req_builder.query(&[("keys", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
64        };
65    }
66    if let Some(ref param_value) = p_expand {
67        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
68    }
69    if let Some(ref user_agent) = configuration.user_agent {
70        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
71    }
72    if let Some(ref auth_conf) = configuration.basic_auth {
73        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
74    };
75
76    let req = req_builder.build()?;
77    let resp = configuration.client.execute(req).await?;
78
79    let status = resp.status();
80
81    if !status.is_client_error() && !status.is_server_error() {
82        let content = resp.text().await?;
83        serde_json::from_str(&content).map_err(Error::from)
84    } else {
85        let content = resp.text().await?;
86        let entity: Option<GetWorkflowTransitionRuleConfigurationsError> = serde_json::from_str(&content).ok();
87        Err(Error::ResponseError(ResponseContent { status, content, entity }))
88    }
89}
90
91/// Updates configuration of workflow transition rules. The following rule types are supported:   *  [post functions](https://developer.atlassian.com/cloud/jira/platform/modules/workflow-post-function/)  *  [conditions](https://developer.atlassian.com/cloud/jira/platform/modules/workflow-condition/)  *  [validators](https://developer.atlassian.com/cloud/jira/platform/modules/workflow-validator/)  Only rules created by the calling Connect app can be updated.  **[Permissions](#permissions) required:** Only Connect apps can use this operation.
92pub async fn update_workflow_transition_rule_configurations(configuration: &configuration::Configuration, workflow_transition_rules_update: models::WorkflowTransitionRulesUpdate) -> Result<models::WorkflowTransitionRulesUpdateErrors, Error<UpdateWorkflowTransitionRuleConfigurationsError>> {
93    // add a prefix to parameters to efficiently prevent name collisions
94    let p_workflow_transition_rules_update = workflow_transition_rules_update;
95
96    let uri_str = format!("{}/rest/api/2/workflow/rule/config", configuration.base_path);
97    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
98
99    if let Some(ref user_agent) = configuration.user_agent {
100        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
101    }
102    if let Some(ref auth_conf) = configuration.basic_auth {
103        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
104    };
105    req_builder = req_builder.json(&p_workflow_transition_rules_update);
106
107    let req = req_builder.build()?;
108    let resp = configuration.client.execute(req).await?;
109
110    let status = resp.status();
111
112    if !status.is_client_error() && !status.is_server_error() {
113        let content = resp.text().await?;
114        serde_json::from_str(&content).map_err(Error::from)
115    } else {
116        let content = resp.text().await?;
117        let entity: Option<UpdateWorkflowTransitionRuleConfigurationsError> = serde_json::from_str(&content).ok();
118        Err(Error::ResponseError(ResponseContent { status, content, entity }))
119    }
120}
121