hi_jira2/apis/
workflow_schemes_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;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`create_workflow_scheme`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateWorkflowSchemeParams {
20    pub workflow_scheme: crate::models::WorkflowScheme
21}
22
23/// struct for passing parameters to the method [`delete_default_workflow`]
24#[derive(Clone, Debug, Default)]
25pub struct DeleteDefaultWorkflowParams {
26    /// The ID of the workflow scheme.
27    pub id: i64,
28    /// Set to true to create or update the draft of a workflow scheme and delete the mapping from the draft, when the workflow scheme cannot be edited. Defaults to `false`.
29    pub update_draft_if_needed: Option<bool>
30}
31
32/// struct for passing parameters to the method [`delete_workflow_mapping`]
33#[derive(Clone, Debug, Default)]
34pub struct DeleteWorkflowMappingParams {
35    /// The ID of the workflow scheme.
36    pub id: i64,
37    /// The name of the workflow.
38    pub workflow_name: String,
39    /// Set to true to create or update the draft of a workflow scheme and delete the mapping from the draft, when the workflow scheme cannot be edited. Defaults to `false`.
40    pub update_draft_if_needed: Option<bool>
41}
42
43/// struct for passing parameters to the method [`delete_workflow_scheme`]
44#[derive(Clone, Debug, Default)]
45pub struct DeleteWorkflowSchemeParams {
46    /// The ID of the workflow scheme. Find this ID by editing the desired workflow scheme in Jira. The ID is shown in the URL as `schemeId`. For example, *schemeId=10301*.
47    pub id: i64
48}
49
50/// struct for passing parameters to the method [`delete_workflow_scheme_issue_type`]
51#[derive(Clone, Debug, Default)]
52pub struct DeleteWorkflowSchemeIssueTypeParams {
53    /// The ID of the workflow scheme.
54    pub id: i64,
55    /// The ID of the issue type.
56    pub issue_type: String,
57    /// Set to true to create or update the draft of a workflow scheme and update the mapping in the draft, when the workflow scheme cannot be edited. Defaults to `false`.
58    pub update_draft_if_needed: Option<bool>
59}
60
61/// struct for passing parameters to the method [`get_all_workflow_schemes`]
62#[derive(Clone, Debug, Default)]
63pub struct GetAllWorkflowSchemesParams {
64    /// The index of the first item to return in a page of results (page offset).
65    pub start_at: Option<i64>,
66    /// The maximum number of items to return per page.
67    pub max_results: Option<i32>
68}
69
70/// struct for passing parameters to the method [`get_default_workflow`]
71#[derive(Clone, Debug, Default)]
72pub struct GetDefaultWorkflowParams {
73    /// The ID of the workflow scheme.
74    pub id: i64,
75    /// Set to `true` to return the default workflow for the workflow scheme's draft rather than scheme itself. If the workflow scheme does not have a draft, then the default workflow for the workflow scheme is returned.
76    pub return_draft_if_exists: Option<bool>
77}
78
79/// struct for passing parameters to the method [`get_workflow`]
80#[derive(Clone, Debug, Default)]
81pub struct GetWorkflowParams {
82    /// The ID of the workflow scheme.
83    pub id: i64,
84    /// The name of a workflow in the scheme. Limits the results to the workflow-issue type mapping for the specified workflow.
85    pub workflow_name: Option<String>,
86    /// Returns the mapping from the workflow scheme's draft rather than the workflow scheme, if set to true. If no draft exists, the mapping from the workflow scheme is returned.
87    pub return_draft_if_exists: Option<bool>
88}
89
90/// struct for passing parameters to the method [`get_workflow_scheme`]
91#[derive(Clone, Debug, Default)]
92pub struct GetWorkflowSchemeParams {
93    /// The ID of the workflow scheme. Find this ID by editing the desired workflow scheme in Jira. The ID is shown in the URL as `schemeId`. For example, *schemeId=10301*.
94    pub id: i64,
95    /// Returns the workflow scheme's draft rather than scheme itself, if set to true. If the workflow scheme does not have a draft, then the workflow scheme is returned.
96    pub return_draft_if_exists: Option<bool>
97}
98
99/// struct for passing parameters to the method [`get_workflow_scheme_issue_type`]
100#[derive(Clone, Debug, Default)]
101pub struct GetWorkflowSchemeIssueTypeParams {
102    /// The ID of the workflow scheme.
103    pub id: i64,
104    /// The ID of the issue type.
105    pub issue_type: String,
106    /// Returns the mapping from the workflow scheme's draft rather than the workflow scheme, if set to true. If no draft exists, the mapping from the workflow scheme is returned.
107    pub return_draft_if_exists: Option<bool>
108}
109
110/// struct for passing parameters to the method [`set_workflow_scheme_issue_type`]
111#[derive(Clone, Debug, Default)]
112pub struct SetWorkflowSchemeIssueTypeParams {
113    /// The ID of the workflow scheme.
114    pub id: i64,
115    /// The ID of the issue type.
116    pub issue_type: String,
117    /// The issue type-project mapping.
118    pub issue_type_workflow_mapping: crate::models::IssueTypeWorkflowMapping
119}
120
121/// struct for passing parameters to the method [`update_default_workflow`]
122#[derive(Clone, Debug, Default)]
123pub struct UpdateDefaultWorkflowParams {
124    /// The ID of the workflow scheme.
125    pub id: i64,
126    /// The new default workflow.
127    pub default_workflow: crate::models::DefaultWorkflow
128}
129
130/// struct for passing parameters to the method [`update_workflow_mapping`]
131#[derive(Clone, Debug, Default)]
132pub struct UpdateWorkflowMappingParams {
133    /// The ID of the workflow scheme.
134    pub id: i64,
135    /// The name of the workflow.
136    pub workflow_name: String,
137    pub issue_types_workflow_mapping: crate::models::IssueTypesWorkflowMapping
138}
139
140/// struct for passing parameters to the method [`update_workflow_scheme`]
141#[derive(Clone, Debug, Default)]
142pub struct UpdateWorkflowSchemeParams {
143    /// The ID of the workflow scheme. Find this ID by editing the desired workflow scheme in Jira. The ID is shown in the URL as `schemeId`. For example, *schemeId=10301*.
144    pub id: i64,
145    pub workflow_scheme: crate::models::WorkflowScheme
146}
147
148
149/// struct for typed errors of method [`create_workflow_scheme`]
150#[derive(Debug, Clone, Serialize, Deserialize)]
151#[serde(untagged)]
152pub enum CreateWorkflowSchemeError {
153    Status400(),
154    Status401(),
155    Status403(),
156    UnknownValue(serde_json::Value),
157}
158
159/// struct for typed errors of method [`delete_default_workflow`]
160#[derive(Debug, Clone, Serialize, Deserialize)]
161#[serde(untagged)]
162pub enum DeleteDefaultWorkflowError {
163    Status400(),
164    Status401(),
165    Status403(),
166    Status404(),
167    UnknownValue(serde_json::Value),
168}
169
170/// struct for typed errors of method [`delete_workflow_mapping`]
171#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum DeleteWorkflowMappingError {
174    Status400(),
175    Status401(),
176    Status403(),
177    Status404(),
178    UnknownValue(serde_json::Value),
179}
180
181/// struct for typed errors of method [`delete_workflow_scheme`]
182#[derive(Debug, Clone, Serialize, Deserialize)]
183#[serde(untagged)]
184pub enum DeleteWorkflowSchemeError {
185    Status400(),
186    Status401(),
187    Status403(),
188    Status404(),
189    UnknownValue(serde_json::Value),
190}
191
192/// struct for typed errors of method [`delete_workflow_scheme_issue_type`]
193#[derive(Debug, Clone, Serialize, Deserialize)]
194#[serde(untagged)]
195pub enum DeleteWorkflowSchemeIssueTypeError {
196    Status400(),
197    Status401(),
198    Status403(),
199    Status404(),
200    UnknownValue(serde_json::Value),
201}
202
203/// struct for typed errors of method [`get_all_workflow_schemes`]
204#[derive(Debug, Clone, Serialize, Deserialize)]
205#[serde(untagged)]
206pub enum GetAllWorkflowSchemesError {
207    Status401(),
208    Status403(),
209    UnknownValue(serde_json::Value),
210}
211
212/// struct for typed errors of method [`get_default_workflow`]
213#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum GetDefaultWorkflowError {
216    Status401(),
217    Status403(),
218    Status404(),
219    UnknownValue(serde_json::Value),
220}
221
222/// struct for typed errors of method [`get_workflow`]
223#[derive(Debug, Clone, Serialize, Deserialize)]
224#[serde(untagged)]
225pub enum GetWorkflowError {
226    Status401(),
227    Status403(),
228    Status404(),
229    UnknownValue(serde_json::Value),
230}
231
232/// struct for typed errors of method [`get_workflow_scheme`]
233#[derive(Debug, Clone, Serialize, Deserialize)]
234#[serde(untagged)]
235pub enum GetWorkflowSchemeError {
236    Status401(),
237    Status403(),
238    Status404(),
239    UnknownValue(serde_json::Value),
240}
241
242/// struct for typed errors of method [`get_workflow_scheme_issue_type`]
243#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum GetWorkflowSchemeIssueTypeError {
246    Status401(),
247    Status403(),
248    Status404(),
249    UnknownValue(serde_json::Value),
250}
251
252/// struct for typed errors of method [`set_workflow_scheme_issue_type`]
253#[derive(Debug, Clone, Serialize, Deserialize)]
254#[serde(untagged)]
255pub enum SetWorkflowSchemeIssueTypeError {
256    Status400(),
257    Status401(),
258    Status403(),
259    Status404(),
260    UnknownValue(serde_json::Value),
261}
262
263/// struct for typed errors of method [`update_default_workflow`]
264#[derive(Debug, Clone, Serialize, Deserialize)]
265#[serde(untagged)]
266pub enum UpdateDefaultWorkflowError {
267    Status400(),
268    Status401(),
269    Status403(),
270    Status404(),
271    UnknownValue(serde_json::Value),
272}
273
274/// struct for typed errors of method [`update_workflow_mapping`]
275#[derive(Debug, Clone, Serialize, Deserialize)]
276#[serde(untagged)]
277pub enum UpdateWorkflowMappingError {
278    Status400(),
279    Status401(),
280    Status403(),
281    Status404(),
282    UnknownValue(serde_json::Value),
283}
284
285/// struct for typed errors of method [`update_workflow_scheme`]
286#[derive(Debug, Clone, Serialize, Deserialize)]
287#[serde(untagged)]
288pub enum UpdateWorkflowSchemeError {
289    Status400(),
290    Status401(),
291    Status403(),
292    Status404(),
293    UnknownValue(serde_json::Value),
294}
295
296
297/// Creates a workflow scheme.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
298pub async fn create_workflow_scheme(configuration: &configuration::Configuration, params: CreateWorkflowSchemeParams) -> Result<crate::models::WorkflowScheme, Error<CreateWorkflowSchemeError>> {
299    let local_var_configuration = configuration;
300
301    // unbox the parameters
302    let workflow_scheme = params.workflow_scheme;
303
304
305    let local_var_client = &local_var_configuration.client;
306
307    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme", local_var_configuration.base_path);
308    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
309
310    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
311        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
312    }
313    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
314        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
315    };
316    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
317        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
318    };
319    local_var_req_builder = local_var_req_builder.json(&workflow_scheme);
320
321    let local_var_req = local_var_req_builder.build()?;
322    let local_var_resp = local_var_client.execute(local_var_req).await?;
323
324    let local_var_status = local_var_resp.status();
325    let local_var_content = local_var_resp.text().await?;
326
327    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
328        serde_json::from_str(&local_var_content).map_err(Error::from)
329    } else {
330        let local_var_entity: Option<CreateWorkflowSchemeError> = serde_json::from_str(&local_var_content).ok();
331        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
332        Err(Error::ResponseError(local_var_error))
333    }
334}
335
336/// Resets the default workflow for a workflow scheme. That is, the default workflow is set to Jira's system workflow (the *jira* workflow).  Note that active workflow schemes cannot be edited. If the workflow scheme is active, set `updateDraftIfNeeded` to `true` and a draft workflow scheme is created or updated with the default workflow reset. The draft workflow scheme can be published in Jira.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
337pub async fn delete_default_workflow(configuration: &configuration::Configuration, params: DeleteDefaultWorkflowParams) -> Result<crate::models::WorkflowScheme, Error<DeleteDefaultWorkflowError>> {
338    let local_var_configuration = configuration;
339
340    // unbox the parameters
341    let id = params.id;
342    let update_draft_if_needed = params.update_draft_if_needed;
343
344
345    let local_var_client = &local_var_configuration.client;
346
347    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/default", local_var_configuration.base_path, id=id);
348    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
349
350    if let Some(ref local_var_str) = update_draft_if_needed {
351        local_var_req_builder = local_var_req_builder.query(&[("updateDraftIfNeeded", &local_var_str.to_string())]);
352    }
353    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
354        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
355    }
356    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
357        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
358    };
359    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
360        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
361    };
362
363    let local_var_req = local_var_req_builder.build()?;
364    let local_var_resp = local_var_client.execute(local_var_req).await?;
365
366    let local_var_status = local_var_resp.status();
367    let local_var_content = local_var_resp.text().await?;
368
369    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
370        serde_json::from_str(&local_var_content).map_err(Error::from)
371    } else {
372        let local_var_entity: Option<DeleteDefaultWorkflowError> = serde_json::from_str(&local_var_content).ok();
373        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
374        Err(Error::ResponseError(local_var_error))
375    }
376}
377
378/// Deletes the workflow-issue type mapping for a workflow in a workflow scheme.  Note that active workflow schemes cannot be edited. If the workflow scheme is active, set `updateDraftIfNeeded` to `true` and a draft workflow scheme is created or updated with the workflow-issue type mapping deleted. The draft workflow scheme can be published in Jira.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
379pub async fn delete_workflow_mapping(configuration: &configuration::Configuration, params: DeleteWorkflowMappingParams) -> Result<(), Error<DeleteWorkflowMappingError>> {
380    let local_var_configuration = configuration;
381
382    // unbox the parameters
383    let id = params.id;
384    let workflow_name = params.workflow_name;
385    let update_draft_if_needed = params.update_draft_if_needed;
386
387
388    let local_var_client = &local_var_configuration.client;
389
390    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/workflow", local_var_configuration.base_path, id=id);
391    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
392
393    local_var_req_builder = local_var_req_builder.query(&[("workflowName", &workflow_name.to_string())]);
394    if let Some(ref local_var_str) = update_draft_if_needed {
395        local_var_req_builder = local_var_req_builder.query(&[("updateDraftIfNeeded", &local_var_str.to_string())]);
396    }
397    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
398        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
399    }
400    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
401        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
402    };
403    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
404        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
405    };
406
407    let local_var_req = local_var_req_builder.build()?;
408    let local_var_resp = local_var_client.execute(local_var_req).await?;
409
410    let local_var_status = local_var_resp.status();
411    let local_var_content = local_var_resp.text().await?;
412
413    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
414        Ok(())
415    } else {
416        let local_var_entity: Option<DeleteWorkflowMappingError> = serde_json::from_str(&local_var_content).ok();
417        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
418        Err(Error::ResponseError(local_var_error))
419    }
420}
421
422/// Deletes a workflow scheme. Note that a workflow scheme cannot be deleted if it is active (that is, being used by at least one project).  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
423pub async fn delete_workflow_scheme(configuration: &configuration::Configuration, params: DeleteWorkflowSchemeParams) -> Result<serde_json::Value, Error<DeleteWorkflowSchemeError>> {
424    let local_var_configuration = configuration;
425
426    // unbox the parameters
427    let id = params.id;
428
429
430    let local_var_client = &local_var_configuration.client;
431
432    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}", local_var_configuration.base_path, id=id);
433    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
434
435    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
436        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
437    }
438    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
439        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
440    };
441    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
442        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
443    };
444
445    let local_var_req = local_var_req_builder.build()?;
446    let local_var_resp = local_var_client.execute(local_var_req).await?;
447
448    let local_var_status = local_var_resp.status();
449    let local_var_content = local_var_resp.text().await?;
450
451    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
452        serde_json::from_str(&local_var_content).map_err(Error::from)
453    } else {
454        let local_var_entity: Option<DeleteWorkflowSchemeError> = serde_json::from_str(&local_var_content).ok();
455        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
456        Err(Error::ResponseError(local_var_error))
457    }
458}
459
460/// Deletes the issue type-workflow mapping for an issue type in a workflow scheme.  Note that active workflow schemes cannot be edited. If the workflow scheme is active, set `updateDraftIfNeeded` to `true` and a draft workflow scheme is created or updated with the issue type-workflow mapping deleted. The draft workflow scheme can be published in Jira.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
461pub async fn delete_workflow_scheme_issue_type(configuration: &configuration::Configuration, params: DeleteWorkflowSchemeIssueTypeParams) -> Result<crate::models::WorkflowScheme, Error<DeleteWorkflowSchemeIssueTypeError>> {
462    let local_var_configuration = configuration;
463
464    // unbox the parameters
465    let id = params.id;
466    let issue_type = params.issue_type;
467    let update_draft_if_needed = params.update_draft_if_needed;
468
469
470    let local_var_client = &local_var_configuration.client;
471
472    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/issuetype/{issueType}", local_var_configuration.base_path, id=id, issueType=crate::apis::urlencode(issue_type));
473    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
474
475    if let Some(ref local_var_str) = update_draft_if_needed {
476        local_var_req_builder = local_var_req_builder.query(&[("updateDraftIfNeeded", &local_var_str.to_string())]);
477    }
478    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
479        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
480    }
481    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
482        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
483    };
484    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
485        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
486    };
487
488    let local_var_req = local_var_req_builder.build()?;
489    let local_var_resp = local_var_client.execute(local_var_req).await?;
490
491    let local_var_status = local_var_resp.status();
492    let local_var_content = local_var_resp.text().await?;
493
494    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
495        serde_json::from_str(&local_var_content).map_err(Error::from)
496    } else {
497        let local_var_entity: Option<DeleteWorkflowSchemeIssueTypeError> = serde_json::from_str(&local_var_content).ok();
498        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
499        Err(Error::ResponseError(local_var_error))
500    }
501}
502
503/// Returns a [paginated](#pagination) list of all workflow schemes, not including draft workflow schemes.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
504pub async fn get_all_workflow_schemes(configuration: &configuration::Configuration, params: GetAllWorkflowSchemesParams) -> Result<crate::models::PageBeanWorkflowScheme, Error<GetAllWorkflowSchemesError>> {
505    let local_var_configuration = configuration;
506
507    // unbox the parameters
508    let start_at = params.start_at;
509    let max_results = params.max_results;
510
511
512    let local_var_client = &local_var_configuration.client;
513
514    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme", local_var_configuration.base_path);
515    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
516
517    if let Some(ref local_var_str) = start_at {
518        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
519    }
520    if let Some(ref local_var_str) = max_results {
521        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
522    }
523    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
524        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
525    }
526    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
527        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
528    };
529    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
530        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
531    };
532
533    let local_var_req = local_var_req_builder.build()?;
534    let local_var_resp = local_var_client.execute(local_var_req).await?;
535
536    let local_var_status = local_var_resp.status();
537    let local_var_content = local_var_resp.text().await?;
538
539    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
540        serde_json::from_str(&local_var_content).map_err(Error::from)
541    } else {
542        let local_var_entity: Option<GetAllWorkflowSchemesError> = serde_json::from_str(&local_var_content).ok();
543        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
544        Err(Error::ResponseError(local_var_error))
545    }
546}
547
548/// Returns the default workflow for a workflow scheme. The default workflow is the workflow that is assigned any issue types that have not been mapped to any other workflow. The default workflow has *All Unassigned Issue Types* listed in its issue types for the workflow scheme in Jira.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
549pub async fn get_default_workflow(configuration: &configuration::Configuration, params: GetDefaultWorkflowParams) -> Result<crate::models::DefaultWorkflow, Error<GetDefaultWorkflowError>> {
550    let local_var_configuration = configuration;
551
552    // unbox the parameters
553    let id = params.id;
554    let return_draft_if_exists = params.return_draft_if_exists;
555
556
557    let local_var_client = &local_var_configuration.client;
558
559    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/default", local_var_configuration.base_path, id=id);
560    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
561
562    if let Some(ref local_var_str) = return_draft_if_exists {
563        local_var_req_builder = local_var_req_builder.query(&[("returnDraftIfExists", &local_var_str.to_string())]);
564    }
565    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
566        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
567    }
568    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
569        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
570    };
571    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
572        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
573    };
574
575    let local_var_req = local_var_req_builder.build()?;
576    let local_var_resp = local_var_client.execute(local_var_req).await?;
577
578    let local_var_status = local_var_resp.status();
579    let local_var_content = local_var_resp.text().await?;
580
581    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
582        serde_json::from_str(&local_var_content).map_err(Error::from)
583    } else {
584        let local_var_entity: Option<GetDefaultWorkflowError> = serde_json::from_str(&local_var_content).ok();
585        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
586        Err(Error::ResponseError(local_var_error))
587    }
588}
589
590/// Returns the workflow-issue type mappings for a workflow scheme.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
591pub async fn get_workflow(configuration: &configuration::Configuration, params: GetWorkflowParams) -> Result<crate::models::IssueTypesWorkflowMapping, Error<GetWorkflowError>> {
592    let local_var_configuration = configuration;
593
594    // unbox the parameters
595    let id = params.id;
596    let workflow_name = params.workflow_name;
597    let return_draft_if_exists = params.return_draft_if_exists;
598
599
600    let local_var_client = &local_var_configuration.client;
601
602    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/workflow", local_var_configuration.base_path, id=id);
603    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
604
605    if let Some(ref local_var_str) = workflow_name {
606        local_var_req_builder = local_var_req_builder.query(&[("workflowName", &local_var_str.to_string())]);
607    }
608    if let Some(ref local_var_str) = return_draft_if_exists {
609        local_var_req_builder = local_var_req_builder.query(&[("returnDraftIfExists", &local_var_str.to_string())]);
610    }
611    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
612        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
613    }
614    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
615        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
616    };
617    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
618        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
619    };
620
621    let local_var_req = local_var_req_builder.build()?;
622    let local_var_resp = local_var_client.execute(local_var_req).await?;
623
624    let local_var_status = local_var_resp.status();
625    let local_var_content = local_var_resp.text().await?;
626
627    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
628        serde_json::from_str(&local_var_content).map_err(Error::from)
629    } else {
630        let local_var_entity: Option<GetWorkflowError> = serde_json::from_str(&local_var_content).ok();
631        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
632        Err(Error::ResponseError(local_var_error))
633    }
634}
635
636/// Returns a workflow scheme.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
637pub async fn get_workflow_scheme(configuration: &configuration::Configuration, params: GetWorkflowSchemeParams) -> Result<crate::models::WorkflowScheme, Error<GetWorkflowSchemeError>> {
638    let local_var_configuration = configuration;
639
640    // unbox the parameters
641    let id = params.id;
642    let return_draft_if_exists = params.return_draft_if_exists;
643
644
645    let local_var_client = &local_var_configuration.client;
646
647    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}", local_var_configuration.base_path, id=id);
648    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
649
650    if let Some(ref local_var_str) = return_draft_if_exists {
651        local_var_req_builder = local_var_req_builder.query(&[("returnDraftIfExists", &local_var_str.to_string())]);
652    }
653    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
654        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
655    }
656    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
657        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
658    };
659    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
660        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
661    };
662
663    let local_var_req = local_var_req_builder.build()?;
664    let local_var_resp = local_var_client.execute(local_var_req).await?;
665
666    let local_var_status = local_var_resp.status();
667    let local_var_content = local_var_resp.text().await?;
668
669    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
670        serde_json::from_str(&local_var_content).map_err(Error::from)
671    } else {
672        let local_var_entity: Option<GetWorkflowSchemeError> = serde_json::from_str(&local_var_content).ok();
673        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
674        Err(Error::ResponseError(local_var_error))
675    }
676}
677
678/// Returns the issue type-workflow mapping for an issue type in a workflow scheme.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
679pub async fn get_workflow_scheme_issue_type(configuration: &configuration::Configuration, params: GetWorkflowSchemeIssueTypeParams) -> Result<crate::models::IssueTypeWorkflowMapping, Error<GetWorkflowSchemeIssueTypeError>> {
680    let local_var_configuration = configuration;
681
682    // unbox the parameters
683    let id = params.id;
684    let issue_type = params.issue_type;
685    let return_draft_if_exists = params.return_draft_if_exists;
686
687
688    let local_var_client = &local_var_configuration.client;
689
690    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/issuetype/{issueType}", local_var_configuration.base_path, id=id, issueType=crate::apis::urlencode(issue_type));
691    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
692
693    if let Some(ref local_var_str) = return_draft_if_exists {
694        local_var_req_builder = local_var_req_builder.query(&[("returnDraftIfExists", &local_var_str.to_string())]);
695    }
696    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
697        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
698    }
699    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
700        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
701    };
702    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
703        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
704    };
705
706    let local_var_req = local_var_req_builder.build()?;
707    let local_var_resp = local_var_client.execute(local_var_req).await?;
708
709    let local_var_status = local_var_resp.status();
710    let local_var_content = local_var_resp.text().await?;
711
712    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
713        serde_json::from_str(&local_var_content).map_err(Error::from)
714    } else {
715        let local_var_entity: Option<GetWorkflowSchemeIssueTypeError> = serde_json::from_str(&local_var_content).ok();
716        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
717        Err(Error::ResponseError(local_var_error))
718    }
719}
720
721/// Sets the workflow for an issue type in a workflow scheme.  Note that active workflow schemes cannot be edited. If the workflow scheme is active, set `updateDraftIfNeeded` to `true` in the request body and a draft workflow scheme is created or updated with the new issue type-workflow mapping. The draft workflow scheme can be published in Jira.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
722pub async fn set_workflow_scheme_issue_type(configuration: &configuration::Configuration, params: SetWorkflowSchemeIssueTypeParams) -> Result<crate::models::WorkflowScheme, Error<SetWorkflowSchemeIssueTypeError>> {
723    let local_var_configuration = configuration;
724
725    // unbox the parameters
726    let id = params.id;
727    let issue_type = params.issue_type;
728    let issue_type_workflow_mapping = params.issue_type_workflow_mapping;
729
730
731    let local_var_client = &local_var_configuration.client;
732
733    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/issuetype/{issueType}", local_var_configuration.base_path, id=id, issueType=crate::apis::urlencode(issue_type));
734    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
735
736    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
737        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
738    }
739    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
740        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
741    };
742    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
743        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
744    };
745    local_var_req_builder = local_var_req_builder.json(&issue_type_workflow_mapping);
746
747    let local_var_req = local_var_req_builder.build()?;
748    let local_var_resp = local_var_client.execute(local_var_req).await?;
749
750    let local_var_status = local_var_resp.status();
751    let local_var_content = local_var_resp.text().await?;
752
753    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
754        serde_json::from_str(&local_var_content).map_err(Error::from)
755    } else {
756        let local_var_entity: Option<SetWorkflowSchemeIssueTypeError> = serde_json::from_str(&local_var_content).ok();
757        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
758        Err(Error::ResponseError(local_var_error))
759    }
760}
761
762/// Sets the default workflow for a workflow scheme.  Note that active workflow schemes cannot be edited. If the workflow scheme is active, set `updateDraftIfNeeded` to `true` in the request object and a draft workflow scheme is created or updated with the new default workflow. The draft workflow scheme can be published in Jira.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
763pub async fn update_default_workflow(configuration: &configuration::Configuration, params: UpdateDefaultWorkflowParams) -> Result<crate::models::WorkflowScheme, Error<UpdateDefaultWorkflowError>> {
764    let local_var_configuration = configuration;
765
766    // unbox the parameters
767    let id = params.id;
768    let default_workflow = params.default_workflow;
769
770
771    let local_var_client = &local_var_configuration.client;
772
773    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/default", local_var_configuration.base_path, id=id);
774    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
775
776    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
777        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
778    }
779    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
780        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
781    };
782    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
783        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
784    };
785    local_var_req_builder = local_var_req_builder.json(&default_workflow);
786
787    let local_var_req = local_var_req_builder.build()?;
788    let local_var_resp = local_var_client.execute(local_var_req).await?;
789
790    let local_var_status = local_var_resp.status();
791    let local_var_content = local_var_resp.text().await?;
792
793    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
794        serde_json::from_str(&local_var_content).map_err(Error::from)
795    } else {
796        let local_var_entity: Option<UpdateDefaultWorkflowError> = serde_json::from_str(&local_var_content).ok();
797        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
798        Err(Error::ResponseError(local_var_error))
799    }
800}
801
802/// Sets the issue types for a workflow in a workflow scheme. The workflow can also be set as the default workflow for the workflow scheme. Unmapped issues types are mapped to the default workflow.  Note that active workflow schemes cannot be edited. If the workflow scheme is active, set `updateDraftIfNeeded` to `true` in the request body and a draft workflow scheme is created or updated with the new workflow-issue types mappings. The draft workflow scheme can be published in Jira.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
803pub async fn update_workflow_mapping(configuration: &configuration::Configuration, params: UpdateWorkflowMappingParams) -> Result<crate::models::WorkflowScheme, Error<UpdateWorkflowMappingError>> {
804    let local_var_configuration = configuration;
805
806    // unbox the parameters
807    let id = params.id;
808    let workflow_name = params.workflow_name;
809    let issue_types_workflow_mapping = params.issue_types_workflow_mapping;
810
811
812    let local_var_client = &local_var_configuration.client;
813
814    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}/workflow", local_var_configuration.base_path, id=id);
815    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
816
817    local_var_req_builder = local_var_req_builder.query(&[("workflowName", &workflow_name.to_string())]);
818    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
819        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
820    }
821    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
822        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
823    };
824    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
825        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
826    };
827    local_var_req_builder = local_var_req_builder.json(&issue_types_workflow_mapping);
828
829    let local_var_req = local_var_req_builder.build()?;
830    let local_var_resp = local_var_client.execute(local_var_req).await?;
831
832    let local_var_status = local_var_resp.status();
833    let local_var_content = local_var_resp.text().await?;
834
835    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
836        serde_json::from_str(&local_var_content).map_err(Error::from)
837    } else {
838        let local_var_entity: Option<UpdateWorkflowMappingError> = serde_json::from_str(&local_var_content).ok();
839        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
840        Err(Error::ResponseError(local_var_error))
841    }
842}
843
844/// Updates a workflow scheme, including the name, default workflow, issue type to project mappings, and more. If the workflow scheme is active (that is, being used by at least one project), then a draft workflow scheme is created or updated instead, provided that `updateDraftIfNeeded` is set to `true`.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
845pub async fn update_workflow_scheme(configuration: &configuration::Configuration, params: UpdateWorkflowSchemeParams) -> Result<crate::models::WorkflowScheme, Error<UpdateWorkflowSchemeError>> {
846    let local_var_configuration = configuration;
847
848    // unbox the parameters
849    let id = params.id;
850    let workflow_scheme = params.workflow_scheme;
851
852
853    let local_var_client = &local_var_configuration.client;
854
855    let local_var_uri_str = format!("{}/rest/api/2/workflowscheme/{id}", local_var_configuration.base_path, id=id);
856    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
857
858    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
859        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
860    }
861    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
862        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
863    };
864    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
865        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
866    };
867    local_var_req_builder = local_var_req_builder.json(&workflow_scheme);
868
869    let local_var_req = local_var_req_builder.build()?;
870    let local_var_resp = local_var_client.execute(local_var_req).await?;
871
872    let local_var_status = local_var_resp.status();
873    let local_var_content = local_var_resp.text().await?;
874
875    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
876        serde_json::from_str(&local_var_content).map_err(Error::from)
877    } else {
878        let local_var_entity: Option<UpdateWorkflowSchemeError> = serde_json::from_str(&local_var_content).ok();
879        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
880        Err(Error::ResponseError(local_var_error))
881    }
882}
883