jira_api_v2/apis/
application_roles_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 GetAllApplicationRolesError {
22 Status401(),
23 Status403(),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum GetApplicationRoleError {
31 Status401(),
32 Status403(),
33 Status404(),
34 UnknownValue(serde_json::Value),
35}
36
37
38pub async fn get_all_application_roles(configuration: &configuration::Configuration, ) -> Result<Vec<models::ApplicationRole>, Error<GetAllApplicationRolesError>> {
40
41 let uri_str = format!("{}/rest/api/2/applicationrole", configuration.base_path);
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 auth_conf) = configuration.basic_auth {
48 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
49 };
50
51 let req = req_builder.build()?;
52 let resp = configuration.client.execute(req).await?;
53
54 let status = resp.status();
55
56 if !status.is_client_error() && !status.is_server_error() {
57 let content = resp.text().await?;
58 serde_json::from_str(&content).map_err(Error::from)
59 } else {
60 let content = resp.text().await?;
61 let entity: Option<GetAllApplicationRolesError> = serde_json::from_str(&content).ok();
62 Err(Error::ResponseError(ResponseContent { status, content, entity }))
63 }
64}
65
66pub async fn get_application_role(configuration: &configuration::Configuration, key: &str) -> Result<models::ApplicationRole, Error<GetApplicationRoleError>> {
68 let p_key = key;
70
71 let uri_str = format!("{}/rest/api/2/applicationrole/{key}", configuration.base_path, key=crate::apis::urlencode(p_key));
72 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
73
74 if let Some(ref user_agent) = configuration.user_agent {
75 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
76 }
77 if let Some(ref auth_conf) = configuration.basic_auth {
78 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
79 };
80
81 let req = req_builder.build()?;
82 let resp = configuration.client.execute(req).await?;
83
84 let status = resp.status();
85
86 if !status.is_client_error() && !status.is_server_error() {
87 let content = resp.text().await?;
88 serde_json::from_str(&content).map_err(Error::from)
89 } else {
90 let content = resp.text().await?;
91 let entity: Option<GetApplicationRoleError> = serde_json::from_str(&content).ok();
92 Err(Error::ResponseError(ResponseContent { status, content, entity }))
93 }
94}
95