jira_api_v2/apis/
issue_notification_schemes_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 GetNotificationSchemeError {
22 Status400(),
23 Status401(),
24 Status404(),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum GetNotificationSchemesError {
32 Status401(),
33 UnknownValue(serde_json::Value),
34}
35
36
37pub async fn get_notification_scheme(configuration: &configuration::Configuration, id: i64, expand: Option<&str>) -> Result<models::NotificationScheme, Error<GetNotificationSchemeError>> {
39 let p_id = id;
41 let p_expand = expand;
42
43 let uri_str = format!("{}/rest/api/2/notificationscheme/{id}", configuration.base_path, id=p_id);
44 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
45
46 if let Some(ref param_value) = p_expand {
47 req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
48 }
49 if let Some(ref user_agent) = configuration.user_agent {
50 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
51 }
52 if let Some(ref token) = configuration.oauth_access_token {
53 req_builder = req_builder.bearer_auth(token.to_owned());
54 };
55 if let Some(ref auth_conf) = configuration.basic_auth {
56 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
57 };
58
59 let req = req_builder.build()?;
60 let resp = configuration.client.execute(req).await?;
61
62 let status = resp.status();
63
64 if !status.is_client_error() && !status.is_server_error() {
65 let content = resp.text().await?;
66 serde_json::from_str(&content).map_err(Error::from)
67 } else {
68 let content = resp.text().await?;
69 let entity: Option<GetNotificationSchemeError> = serde_json::from_str(&content).ok();
70 Err(Error::ResponseError(ResponseContent { status, content, entity }))
71 }
72}
73
74pub async fn get_notification_schemes(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, expand: Option<&str>) -> Result<models::PageBeanNotificationScheme, Error<GetNotificationSchemesError>> {
76 let p_start_at = start_at;
78 let p_max_results = max_results;
79 let p_expand = expand;
80
81 let uri_str = format!("{}/rest/api/2/notificationscheme", configuration.base_path);
82 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
83
84 if let Some(ref param_value) = p_start_at {
85 req_builder = req_builder.query(&[("startAt", ¶m_value.to_string())]);
86 }
87 if let Some(ref param_value) = p_max_results {
88 req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
89 }
90 if let Some(ref param_value) = p_expand {
91 req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
92 }
93 if let Some(ref user_agent) = configuration.user_agent {
94 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
95 }
96 if let Some(ref token) = configuration.oauth_access_token {
97 req_builder = req_builder.bearer_auth(token.to_owned());
98 };
99 if let Some(ref auth_conf) = configuration.basic_auth {
100 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
101 };
102
103 let req = req_builder.build()?;
104 let resp = configuration.client.execute(req).await?;
105
106 let status = resp.status();
107
108 if !status.is_client_error() && !status.is_server_error() {
109 let content = resp.text().await?;
110 serde_json::from_str(&content).map_err(Error::from)
111 } else {
112 let content = resp.text().await?;
113 let entity: Option<GetNotificationSchemesError> = serde_json::from_str(&content).ok();
114 Err(Error::ResponseError(ResponseContent { status, content, entity }))
115 }
116}
117