jira_api_v2/apis/
workflow_statuses_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_status`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetStatusError {
22    Status401(),
23    Status404(),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`get_statuses`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum GetStatusesError {
31    Status401(),
32    UnknownValue(serde_json::Value),
33}
34
35
36/// Returns a status. The status must be associated with a workflow to be returned.  If a name is used on more than one status, only the status found first is returned. Therefore, identifying the status by its ID may be preferable.  This operation can be accessed anonymously.  [Permissions](#permissions) required: None.
37pub async fn get_status(configuration: &configuration::Configuration, id_or_name: &str) -> Result<models::StatusDetails, Error<GetStatusError>> {
38    // add a prefix to parameters to efficiently prevent name collisions
39    let p_id_or_name = id_or_name;
40
41    let uri_str = format!("{}/rest/api/2/status/{idOrName}", configuration.base_path, idOrName=crate::apis::urlencode(p_id_or_name));
42    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
43
44    if let Some(ref user_agent) = configuration.user_agent {
45        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
46    }
47    if let Some(ref token) = configuration.oauth_access_token {
48        req_builder = req_builder.bearer_auth(token.to_owned());
49    };
50    if let Some(ref auth_conf) = configuration.basic_auth {
51        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
52    };
53
54    let req = req_builder.build()?;
55    let resp = configuration.client.execute(req).await?;
56
57    let status = resp.status();
58
59    if !status.is_client_error() && !status.is_server_error() {
60        let content = resp.text().await?;
61        serde_json::from_str(&content).map_err(Error::from)
62    } else {
63        let content = resp.text().await?;
64        let entity: Option<GetStatusError> = serde_json::from_str(&content).ok();
65        Err(Error::ResponseError(ResponseContent { status, content, entity }))
66    }
67}
68
69/// Returns a list of all statuses associated with workflows.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
70pub async fn get_statuses(configuration: &configuration::Configuration, ) -> Result<Vec<models::StatusDetails>, Error<GetStatusesError>> {
71
72    let uri_str = format!("{}/rest/api/2/status", configuration.base_path);
73    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
74
75    if let Some(ref user_agent) = configuration.user_agent {
76        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
77    }
78    if let Some(ref token) = configuration.oauth_access_token {
79        req_builder = req_builder.bearer_auth(token.to_owned());
80    };
81    if let Some(ref auth_conf) = configuration.basic_auth {
82        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
83    };
84
85    let req = req_builder.build()?;
86    let resp = configuration.client.execute(req).await?;
87
88    let status = resp.status();
89
90    if !status.is_client_error() && !status.is_server_error() {
91        let content = resp.text().await?;
92        serde_json::from_str(&content).map_err(Error::from)
93    } else {
94        let content = resp.text().await?;
95        let entity: Option<GetStatusesError> = serde_json::from_str(&content).ok();
96        Err(Error::ResponseError(ResponseContent { status, content, entity }))
97    }
98}
99