jira_api_v2/apis/
workflow_transition_properties_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 [`create_workflow_transition_property`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateWorkflowTransitionPropertyError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`delete_workflow_transition_property`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum DeleteWorkflowTransitionPropertyError {
33    Status400(),
34    Status401(),
35    Status403(),
36    Status404(),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`get_workflow_transition_properties`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetWorkflowTransitionPropertiesError {
44    Status400(),
45    Status401(),
46    Status403(),
47    Status404(),
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`update_workflow_transition_property`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum UpdateWorkflowTransitionPropertyError {
55    Status400(),
56    Status401(),
57    Status403(),
58    Status404(),
59    UnknownValue(serde_json::Value),
60}
61
62
63/// 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).
64pub 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>> {
65    // add a prefix to parameters to efficiently prevent name collisions
66    let p_transition_id = transition_id;
67    let p_key = key;
68    let p_workflow_name = workflow_name;
69    let p_workflow_transition_property = workflow_transition_property;
70    let p_workflow_mode = workflow_mode;
71
72    let uri_str = format!("{}/rest/api/2/workflow/transitions/{transitionId}/properties", configuration.base_path, transitionId=p_transition_id);
73    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
74
75    req_builder = req_builder.query(&[("key", &p_key.to_string())]);
76    req_builder = req_builder.query(&[("workflowName", &p_workflow_name.to_string())]);
77    if let Some(ref param_value) = p_workflow_mode {
78        req_builder = req_builder.query(&[("workflowMode", &param_value.to_string())]);
79    }
80    if let Some(ref user_agent) = configuration.user_agent {
81        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
82    }
83    if let Some(ref token) = configuration.oauth_access_token {
84        req_builder = req_builder.bearer_auth(token.to_owned());
85    };
86    if let Some(ref auth_conf) = configuration.basic_auth {
87        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
88    };
89    req_builder = req_builder.json(&p_workflow_transition_property);
90
91    let req = req_builder.build()?;
92    let resp = configuration.client.execute(req).await?;
93
94    let status = resp.status();
95
96    if !status.is_client_error() && !status.is_server_error() {
97        let content = resp.text().await?;
98        serde_json::from_str(&content).map_err(Error::from)
99    } else {
100        let content = resp.text().await?;
101        let entity: Option<CreateWorkflowTransitionPropertyError> = serde_json::from_str(&content).ok();
102        Err(Error::ResponseError(ResponseContent { status, content, entity }))
103    }
104}
105
106/// 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).
107pub async fn delete_workflow_transition_property(configuration: &configuration::Configuration, transition_id: i64, key: &str, workflow_name: &str, workflow_mode: Option<&str>) -> Result<(), Error<DeleteWorkflowTransitionPropertyError>> {
108    // add a prefix to parameters to efficiently prevent name collisions
109    let p_transition_id = transition_id;
110    let p_key = key;
111    let p_workflow_name = workflow_name;
112    let p_workflow_mode = workflow_mode;
113
114    let uri_str = format!("{}/rest/api/2/workflow/transitions/{transitionId}/properties", configuration.base_path, transitionId=p_transition_id);
115    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
116
117    req_builder = req_builder.query(&[("key", &p_key.to_string())]);
118    req_builder = req_builder.query(&[("workflowName", &p_workflow_name.to_string())]);
119    if let Some(ref param_value) = p_workflow_mode {
120        req_builder = req_builder.query(&[("workflowMode", &param_value.to_string())]);
121    }
122    if let Some(ref user_agent) = configuration.user_agent {
123        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
124    }
125    if let Some(ref token) = configuration.oauth_access_token {
126        req_builder = req_builder.bearer_auth(token.to_owned());
127    };
128    if let Some(ref auth_conf) = configuration.basic_auth {
129        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
130    };
131
132    let req = req_builder.build()?;
133    let resp = configuration.client.execute(req).await?;
134
135    let status = resp.status();
136
137    if !status.is_client_error() && !status.is_server_error() {
138        Ok(())
139    } else {
140        let content = resp.text().await?;
141        let entity: Option<DeleteWorkflowTransitionPropertyError> = serde_json::from_str(&content).ok();
142        Err(Error::ResponseError(ResponseContent { status, content, entity }))
143    }
144}
145
146/// 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).
147pub 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>> {
148    // add a prefix to parameters to efficiently prevent name collisions
149    let p_transition_id = transition_id;
150    let p_workflow_name = workflow_name;
151    let p_include_reserved_keys = include_reserved_keys;
152    let p_key = key;
153    let p_workflow_mode = workflow_mode;
154
155    let uri_str = format!("{}/rest/api/2/workflow/transitions/{transitionId}/properties", configuration.base_path, transitionId=p_transition_id);
156    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
157
158    if let Some(ref param_value) = p_include_reserved_keys {
159        req_builder = req_builder.query(&[("includeReservedKeys", &param_value.to_string())]);
160    }
161    if let Some(ref param_value) = p_key {
162        req_builder = req_builder.query(&[("key", &param_value.to_string())]);
163    }
164    req_builder = req_builder.query(&[("workflowName", &p_workflow_name.to_string())]);
165    if let Some(ref param_value) = p_workflow_mode {
166        req_builder = req_builder.query(&[("workflowMode", &param_value.to_string())]);
167    }
168    if let Some(ref user_agent) = configuration.user_agent {
169        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
170    }
171    if let Some(ref token) = configuration.oauth_access_token {
172        req_builder = req_builder.bearer_auth(token.to_owned());
173    };
174    if let Some(ref auth_conf) = configuration.basic_auth {
175        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
176    };
177
178    let req = req_builder.build()?;
179    let resp = configuration.client.execute(req).await?;
180
181    let status = resp.status();
182
183    if !status.is_client_error() && !status.is_server_error() {
184        let content = resp.text().await?;
185        serde_json::from_str(&content).map_err(Error::from)
186    } else {
187        let content = resp.text().await?;
188        let entity: Option<GetWorkflowTransitionPropertiesError> = serde_json::from_str(&content).ok();
189        Err(Error::ResponseError(ResponseContent { status, content, entity }))
190    }
191}
192
193/// 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).
194pub 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>> {
195    // add a prefix to parameters to efficiently prevent name collisions
196    let p_transition_id = transition_id;
197    let p_key = key;
198    let p_workflow_name = workflow_name;
199    let p_workflow_transition_property = workflow_transition_property;
200    let p_workflow_mode = workflow_mode;
201
202    let uri_str = format!("{}/rest/api/2/workflow/transitions/{transitionId}/properties", configuration.base_path, transitionId=p_transition_id);
203    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
204
205    req_builder = req_builder.query(&[("key", &p_key.to_string())]);
206    req_builder = req_builder.query(&[("workflowName", &p_workflow_name.to_string())]);
207    if let Some(ref param_value) = p_workflow_mode {
208        req_builder = req_builder.query(&[("workflowMode", &param_value.to_string())]);
209    }
210    if let Some(ref user_agent) = configuration.user_agent {
211        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
212    }
213    if let Some(ref token) = configuration.oauth_access_token {
214        req_builder = req_builder.bearer_auth(token.to_owned());
215    };
216    if let Some(ref auth_conf) = configuration.basic_auth {
217        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
218    };
219    req_builder = req_builder.json(&p_workflow_transition_property);
220
221    let req = req_builder.build()?;
222    let resp = configuration.client.execute(req).await?;
223
224    let status = resp.status();
225
226    if !status.is_client_error() && !status.is_server_error() {
227        let content = resp.text().await?;
228        serde_json::from_str(&content).map_err(Error::from)
229    } else {
230        let content = resp.text().await?;
231        let entity: Option<UpdateWorkflowTransitionPropertyError> = serde_json::from_str(&content).ok();
232        Err(Error::ResponseError(ResponseContent { status, content, entity }))
233    }
234}
235