jira_api_v2/apis/
workflow_transition_rules_api.rs1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[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#[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
38pub 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 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", ¶m_value.to_string())]);
52 }
53 if let Some(ref param_value) = p_max_results {
54 req_builder = req_builder.query(&[("maxResults", ¶m_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(¶m_value.into_iter().map(|p| ("keys".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
63 _ => req_builder.query(&[("keys", ¶m_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", ¶m_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
91pub async fn update_workflow_transition_rule_configurations(configuration: &configuration::Configuration, workflow_transition_rules_update: models::WorkflowTransitionRulesUpdate) -> Result<models::WorkflowTransitionRulesUpdateErrors, Error<UpdateWorkflowTransitionRuleConfigurationsError>> {
93 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