hi_jira2/apis/
issue_resolutions_api.rs1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17#[derive(Clone, Debug, Default)]
19pub struct GetResolutionParams {
20 pub id: String
22}
23
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetResolutionError {
29 Status401(),
30 Status404(),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum GetResolutionsError {
38 Status401(),
39 UnknownValue(serde_json::Value),
40}
41
42
43pub async fn get_resolution(configuration: &configuration::Configuration, params: GetResolutionParams) -> Result<crate::models::Resolution, Error<GetResolutionError>> {
45 let local_var_configuration = configuration;
46
47 let id = params.id;
49
50
51 let local_var_client = &local_var_configuration.client;
52
53 let local_var_uri_str = format!("{}/rest/api/2/resolution/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
54 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
55
56 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
57 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
58 }
59 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
60 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
61 };
62 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
63 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
64 };
65
66 let local_var_req = local_var_req_builder.build()?;
67 let local_var_resp = local_var_client.execute(local_var_req).await?;
68
69 let local_var_status = local_var_resp.status();
70 let local_var_content = local_var_resp.text().await?;
71
72 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
73 serde_json::from_str(&local_var_content).map_err(Error::from)
74 } else {
75 let local_var_entity: Option<GetResolutionError> = serde_json::from_str(&local_var_content).ok();
76 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
77 Err(Error::ResponseError(local_var_error))
78 }
79}
80
81pub async fn get_resolutions(configuration: &configuration::Configuration) -> Result<Vec<crate::models::Resolution>, Error<GetResolutionsError>> {
83 let local_var_configuration = configuration;
84
85 let local_var_client = &local_var_configuration.client;
89
90 let local_var_uri_str = format!("{}/rest/api/2/resolution", local_var_configuration.base_path);
91 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
92
93 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
94 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
95 }
96 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
97 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
98 };
99 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
100 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
101 };
102
103 let local_var_req = local_var_req_builder.build()?;
104 let local_var_resp = local_var_client.execute(local_var_req).await?;
105
106 let local_var_status = local_var_resp.status();
107 let local_var_content = local_var_resp.text().await?;
108
109 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
110 serde_json::from_str(&local_var_content).map_err(Error::from)
111 } else {
112 let local_var_entity: Option<GetResolutionsError> = serde_json::from_str(&local_var_content).ok();
113 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
114 Err(Error::ResponseError(local_var_error))
115 }
116}
117