jira_api_v2/apis/
time_tracking_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 GetAvailableTimeTrackingImplementationsError {
22 Status401(),
23 Status403(),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum GetSelectedTimeTrackingImplementationError {
31 Status401(),
32 Status403(),
33 UnknownValue(serde_json::Value),
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum GetSharedTimeTrackingConfigurationError {
40 Status401(),
41 Status403(),
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum SelectTimeTrackingImplementationError {
49 Status400(),
50 Status401(),
51 Status403(),
52 UnknownValue(serde_json::Value),
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum SetSharedTimeTrackingConfigurationError {
59 Status400(),
60 Status401(),
61 Status403(),
62 UnknownValue(serde_json::Value),
63}
64
65
66pub async fn get_available_time_tracking_implementations(configuration: &configuration::Configuration, ) -> Result<Vec<models::TimeTrackingProvider>, Error<GetAvailableTimeTrackingImplementationsError>> {
68
69 let uri_str = format!("{}/rest/api/2/configuration/timetracking/list", configuration.base_path);
70 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
71
72 if let Some(ref user_agent) = configuration.user_agent {
73 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
74 }
75 if let Some(ref token) = configuration.oauth_access_token {
76 req_builder = req_builder.bearer_auth(token.to_owned());
77 };
78 if let Some(ref auth_conf) = configuration.basic_auth {
79 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
80 };
81
82 let req = req_builder.build()?;
83 let resp = configuration.client.execute(req).await?;
84
85 let status = resp.status();
86
87 if !status.is_client_error() && !status.is_server_error() {
88 let content = resp.text().await?;
89 serde_json::from_str(&content).map_err(Error::from)
90 } else {
91 let content = resp.text().await?;
92 let entity: Option<GetAvailableTimeTrackingImplementationsError> = serde_json::from_str(&content).ok();
93 Err(Error::ResponseError(ResponseContent { status, content, entity }))
94 }
95}
96
97pub async fn get_selected_time_tracking_implementation(configuration: &configuration::Configuration, ) -> Result<models::TimeTrackingProvider, Error<GetSelectedTimeTrackingImplementationError>> {
99
100 let uri_str = format!("{}/rest/api/2/configuration/timetracking", configuration.base_path);
101 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
102
103 if let Some(ref user_agent) = configuration.user_agent {
104 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
105 }
106 if let Some(ref token) = configuration.oauth_access_token {
107 req_builder = req_builder.bearer_auth(token.to_owned());
108 };
109 if let Some(ref auth_conf) = configuration.basic_auth {
110 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
111 };
112
113 let req = req_builder.build()?;
114 let resp = configuration.client.execute(req).await?;
115
116 let status = resp.status();
117
118 if !status.is_client_error() && !status.is_server_error() {
119 let content = resp.text().await?;
120 serde_json::from_str(&content).map_err(Error::from)
121 } else {
122 let content = resp.text().await?;
123 let entity: Option<GetSelectedTimeTrackingImplementationError> = serde_json::from_str(&content).ok();
124 Err(Error::ResponseError(ResponseContent { status, content, entity }))
125 }
126}
127
128pub async fn get_shared_time_tracking_configuration(configuration: &configuration::Configuration, ) -> Result<models::TimeTrackingConfiguration, Error<GetSharedTimeTrackingConfigurationError>> {
130
131 let uri_str = format!("{}/rest/api/2/configuration/timetracking/options", configuration.base_path);
132 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
133
134 if let Some(ref user_agent) = configuration.user_agent {
135 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
136 }
137 if let Some(ref token) = configuration.oauth_access_token {
138 req_builder = req_builder.bearer_auth(token.to_owned());
139 };
140 if let Some(ref auth_conf) = configuration.basic_auth {
141 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
142 };
143
144 let req = req_builder.build()?;
145 let resp = configuration.client.execute(req).await?;
146
147 let status = resp.status();
148
149 if !status.is_client_error() && !status.is_server_error() {
150 let content = resp.text().await?;
151 serde_json::from_str(&content).map_err(Error::from)
152 } else {
153 let content = resp.text().await?;
154 let entity: Option<GetSharedTimeTrackingConfigurationError> = serde_json::from_str(&content).ok();
155 Err(Error::ResponseError(ResponseContent { status, content, entity }))
156 }
157}
158
159pub async fn select_time_tracking_implementation(configuration: &configuration::Configuration, time_tracking_provider: models::TimeTrackingProvider) -> Result<serde_json::Value, Error<SelectTimeTrackingImplementationError>> {
161 let p_time_tracking_provider = time_tracking_provider;
163
164 let uri_str = format!("{}/rest/api/2/configuration/timetracking", configuration.base_path);
165 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
166
167 if let Some(ref user_agent) = configuration.user_agent {
168 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
169 }
170 if let Some(ref token) = configuration.oauth_access_token {
171 req_builder = req_builder.bearer_auth(token.to_owned());
172 };
173 if let Some(ref auth_conf) = configuration.basic_auth {
174 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
175 };
176 req_builder = req_builder.json(&p_time_tracking_provider);
177
178 let req = req_builder.build()?;
179 let resp = configuration.client.execute(req).await?;
180
181 let status = resp.status();
182
183 if !status.is_client_error() && !status.is_server_error() {
184 let content = resp.text().await?;
185 serde_json::from_str(&content).map_err(Error::from)
186 } else {
187 let content = resp.text().await?;
188 let entity: Option<SelectTimeTrackingImplementationError> = serde_json::from_str(&content).ok();
189 Err(Error::ResponseError(ResponseContent { status, content, entity }))
190 }
191}
192
193pub async fn set_shared_time_tracking_configuration(configuration: &configuration::Configuration, time_tracking_configuration: models::TimeTrackingConfiguration) -> Result<models::TimeTrackingConfiguration, Error<SetSharedTimeTrackingConfigurationError>> {
195 let p_time_tracking_configuration = time_tracking_configuration;
197
198 let uri_str = format!("{}/rest/api/2/configuration/timetracking/options", configuration.base_path);
199 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
200
201 if let Some(ref user_agent) = configuration.user_agent {
202 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
203 }
204 if let Some(ref token) = configuration.oauth_access_token {
205 req_builder = req_builder.bearer_auth(token.to_owned());
206 };
207 if let Some(ref auth_conf) = configuration.basic_auth {
208 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
209 };
210 req_builder = req_builder.json(&p_time_tracking_configuration);
211
212 let req = req_builder.build()?;
213 let resp = configuration.client.execute(req).await?;
214
215 let status = resp.status();
216
217 if !status.is_client_error() && !status.is_server_error() {
218 let content = resp.text().await?;
219 serde_json::from_str(&content).map_err(Error::from)
220 } else {
221 let content = resp.text().await?;
222 let entity: Option<SetSharedTimeTrackingConfigurationError> = serde_json::from_str(&content).ok();
223 Err(Error::ResponseError(ResponseContent { status, content, entity }))
224 }
225}
226