1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17#[derive(Clone, Debug, Default)]
19pub struct CreateOrUpdateRemoteIssueLinkParams {
20 pub issue_id_or_key: String,
22 pub request_body: ::std::collections::HashMap<String, serde_json::Value>
23}
24
25#[derive(Clone, Debug, Default)]
27pub struct DeleteRemoteIssueLinkByGlobalIdParams {
28 pub issue_id_or_key: String,
30 pub global_id: String
32}
33
34#[derive(Clone, Debug, Default)]
36pub struct DeleteRemoteIssueLinkByIdParams {
37 pub issue_id_or_key: String,
39 pub link_id: String
41}
42
43#[derive(Clone, Debug, Default)]
45pub struct GetRemoteIssueLinkByIdParams {
46 pub issue_id_or_key: String,
48 pub link_id: String
50}
51
52#[derive(Clone, Debug, Default)]
54pub struct GetRemoteIssueLinksParams {
55 pub issue_id_or_key: String,
57 pub global_id: Option<String>
59}
60
61#[derive(Clone, Debug, Default)]
63pub struct UpdateRemoteIssueLinkParams {
64 pub issue_id_or_key: String,
66 pub link_id: String,
68 pub request_body: ::std::collections::HashMap<String, serde_json::Value>
69}
70
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum CreateOrUpdateRemoteIssueLinkError {
76 Status400(),
77 Status401(),
78 Status403(),
79 Status404(),
80 UnknownValue(serde_json::Value),
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum DeleteRemoteIssueLinkByGlobalIdError {
87 Status400(),
88 Status401(),
89 Status403(),
90 Status404(),
91 UnknownValue(serde_json::Value),
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum DeleteRemoteIssueLinkByIdError {
98 Status400(),
99 Status401(),
100 Status403(),
101 Status404(),
102 UnknownValue(serde_json::Value),
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum GetRemoteIssueLinkByIdError {
109 Status400(),
110 Status401(),
111 Status403(),
112 Status404(),
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum GetRemoteIssueLinksError {
120 Status400(),
121 Status401(),
122 Status403(),
123 Status404(),
124 UnknownValue(serde_json::Value),
125}
126
127#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum UpdateRemoteIssueLinkError {
131 Status400(),
132 Status401(),
133 Status403(),
134 Status404(),
135 UnknownValue(serde_json::Value),
136}
137
138
139pub async fn create_or_update_remote_issue_link(configuration: &configuration::Configuration, params: CreateOrUpdateRemoteIssueLinkParams) -> Result<crate::models::RemoteIssueLinkIdentifies, Error<CreateOrUpdateRemoteIssueLinkError>> {
141 let local_var_configuration = configuration;
142
143 let issue_id_or_key = params.issue_id_or_key;
145 let request_body = params.request_body;
146
147
148 let local_var_client = &local_var_configuration.client;
149
150 let local_var_uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/remotelink", local_var_configuration.base_path, issueIdOrKey=crate::apis::urlencode(issue_id_or_key));
151 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
152
153 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
154 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
155 }
156 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
157 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
158 };
159 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
160 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
161 };
162 local_var_req_builder = local_var_req_builder.json(&request_body);
163
164 let local_var_req = local_var_req_builder.build()?;
165 let local_var_resp = local_var_client.execute(local_var_req).await?;
166
167 let local_var_status = local_var_resp.status();
168 let local_var_content = local_var_resp.text().await?;
169
170 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
171 serde_json::from_str(&local_var_content).map_err(Error::from)
172 } else {
173 let local_var_entity: Option<CreateOrUpdateRemoteIssueLinkError> = serde_json::from_str(&local_var_content).ok();
174 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
175 Err(Error::ResponseError(local_var_error))
176 }
177}
178
179pub async fn delete_remote_issue_link_by_global_id(configuration: &configuration::Configuration, params: DeleteRemoteIssueLinkByGlobalIdParams) -> Result<(), Error<DeleteRemoteIssueLinkByGlobalIdError>> {
181 let local_var_configuration = configuration;
182
183 let issue_id_or_key = params.issue_id_or_key;
185 let global_id = params.global_id;
186
187
188 let local_var_client = &local_var_configuration.client;
189
190 let local_var_uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/remotelink", local_var_configuration.base_path, issueIdOrKey=crate::apis::urlencode(issue_id_or_key));
191 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
192
193 local_var_req_builder = local_var_req_builder.query(&[("globalId", &global_id.to_string())]);
194 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
195 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
196 }
197 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
198 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
199 };
200 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
201 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
202 };
203
204 let local_var_req = local_var_req_builder.build()?;
205 let local_var_resp = local_var_client.execute(local_var_req).await?;
206
207 let local_var_status = local_var_resp.status();
208 let local_var_content = local_var_resp.text().await?;
209
210 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
211 Ok(())
212 } else {
213 let local_var_entity: Option<DeleteRemoteIssueLinkByGlobalIdError> = serde_json::from_str(&local_var_content).ok();
214 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
215 Err(Error::ResponseError(local_var_error))
216 }
217}
218
219pub async fn delete_remote_issue_link_by_id(configuration: &configuration::Configuration, params: DeleteRemoteIssueLinkByIdParams) -> Result<(), Error<DeleteRemoteIssueLinkByIdError>> {
221 let local_var_configuration = configuration;
222
223 let issue_id_or_key = params.issue_id_or_key;
225 let link_id = params.link_id;
226
227
228 let local_var_client = &local_var_configuration.client;
229
230 let local_var_uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/remotelink/{linkId}", local_var_configuration.base_path, issueIdOrKey=crate::apis::urlencode(issue_id_or_key), linkId=crate::apis::urlencode(link_id));
231 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
232
233 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
234 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
235 }
236 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
237 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
238 };
239 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
240 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
241 };
242
243 let local_var_req = local_var_req_builder.build()?;
244 let local_var_resp = local_var_client.execute(local_var_req).await?;
245
246 let local_var_status = local_var_resp.status();
247 let local_var_content = local_var_resp.text().await?;
248
249 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
250 Ok(())
251 } else {
252 let local_var_entity: Option<DeleteRemoteIssueLinkByIdError> = serde_json::from_str(&local_var_content).ok();
253 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
254 Err(Error::ResponseError(local_var_error))
255 }
256}
257
258pub async fn get_remote_issue_link_by_id(configuration: &configuration::Configuration, params: GetRemoteIssueLinkByIdParams) -> Result<crate::models::RemoteIssueLink, Error<GetRemoteIssueLinkByIdError>> {
260 let local_var_configuration = configuration;
261
262 let issue_id_or_key = params.issue_id_or_key;
264 let link_id = params.link_id;
265
266
267 let local_var_client = &local_var_configuration.client;
268
269 let local_var_uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/remotelink/{linkId}", local_var_configuration.base_path, issueIdOrKey=crate::apis::urlencode(issue_id_or_key), linkId=crate::apis::urlencode(link_id));
270 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
271
272 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
273 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
274 }
275 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
276 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
277 };
278 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
279 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
280 };
281
282 let local_var_req = local_var_req_builder.build()?;
283 let local_var_resp = local_var_client.execute(local_var_req).await?;
284
285 let local_var_status = local_var_resp.status();
286 let local_var_content = local_var_resp.text().await?;
287
288 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
289 serde_json::from_str(&local_var_content).map_err(Error::from)
290 } else {
291 let local_var_entity: Option<GetRemoteIssueLinkByIdError> = serde_json::from_str(&local_var_content).ok();
292 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
293 Err(Error::ResponseError(local_var_error))
294 }
295}
296
297pub async fn get_remote_issue_links(configuration: &configuration::Configuration, params: GetRemoteIssueLinksParams) -> Result<crate::models::RemoteIssueLink, Error<GetRemoteIssueLinksError>> {
299 let local_var_configuration = configuration;
300
301 let issue_id_or_key = params.issue_id_or_key;
303 let global_id = params.global_id;
304
305
306 let local_var_client = &local_var_configuration.client;
307
308 let local_var_uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/remotelink", local_var_configuration.base_path, issueIdOrKey=crate::apis::urlencode(issue_id_or_key));
309 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
310
311 if let Some(ref local_var_str) = global_id {
312 local_var_req_builder = local_var_req_builder.query(&[("globalId", &local_var_str.to_string())]);
313 }
314 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
315 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
316 }
317 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
318 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
319 };
320 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
321 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
322 };
323
324 let local_var_req = local_var_req_builder.build()?;
325 let local_var_resp = local_var_client.execute(local_var_req).await?;
326
327 let local_var_status = local_var_resp.status();
328 let local_var_content = local_var_resp.text().await?;
329
330 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
331 serde_json::from_str(&local_var_content).map_err(Error::from)
332 } else {
333 let local_var_entity: Option<GetRemoteIssueLinksError> = serde_json::from_str(&local_var_content).ok();
334 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
335 Err(Error::ResponseError(local_var_error))
336 }
337}
338
339pub async fn update_remote_issue_link(configuration: &configuration::Configuration, params: UpdateRemoteIssueLinkParams) -> Result<serde_json::Value, Error<UpdateRemoteIssueLinkError>> {
341 let local_var_configuration = configuration;
342
343 let issue_id_or_key = params.issue_id_or_key;
345 let link_id = params.link_id;
346 let request_body = params.request_body;
347
348
349 let local_var_client = &local_var_configuration.client;
350
351 let local_var_uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/remotelink/{linkId}", local_var_configuration.base_path, issueIdOrKey=crate::apis::urlencode(issue_id_or_key), linkId=crate::apis::urlencode(link_id));
352 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
353
354 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
355 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
356 }
357 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
358 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
359 };
360 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
361 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
362 };
363 local_var_req_builder = local_var_req_builder.json(&request_body);
364
365 let local_var_req = local_var_req_builder.build()?;
366 let local_var_resp = local_var_client.execute(local_var_req).await?;
367
368 let local_var_status = local_var_resp.status();
369 let local_var_content = local_var_resp.text().await?;
370
371 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
372 serde_json::from_str(&local_var_content).map_err(Error::from)
373 } else {
374 let local_var_entity: Option<UpdateRemoteIssueLinkError> = serde_json::from_str(&local_var_content).ok();
375 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
376 Err(Error::ResponseError(local_var_error))
377 }
378}
379