hi_jira2/apis/
issue_remote_links_api.rs

1/*
2 * The Jira Cloud platform REST API
3 *
4 * Jira Cloud platform REST API documentation
5 *
6 * The version of the OpenAPI document: 1001.0.0-SNAPSHOT
7 * Contact: ecosystem@atlassian.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`create_or_update_remote_issue_link`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateOrUpdateRemoteIssueLinkParams {
20    /// The ID or key of the issue.
21    pub issue_id_or_key: String,
22    pub request_body: ::std::collections::HashMap<String, serde_json::Value>
23}
24
25/// struct for passing parameters to the method [`delete_remote_issue_link_by_global_id`]
26#[derive(Clone, Debug, Default)]
27pub struct DeleteRemoteIssueLinkByGlobalIdParams {
28    /// The ID or key of the issue.
29    pub issue_id_or_key: String,
30    /// The global ID of a remote issue link.
31    pub global_id: String
32}
33
34/// struct for passing parameters to the method [`delete_remote_issue_link_by_id`]
35#[derive(Clone, Debug, Default)]
36pub struct DeleteRemoteIssueLinkByIdParams {
37    /// The ID or key of the issue.
38    pub issue_id_or_key: String,
39    /// The ID of a remote issue link.
40    pub link_id: String
41}
42
43/// struct for passing parameters to the method [`get_remote_issue_link_by_id`]
44#[derive(Clone, Debug, Default)]
45pub struct GetRemoteIssueLinkByIdParams {
46    /// The ID or key of the issue.
47    pub issue_id_or_key: String,
48    /// The ID of the remote issue link.
49    pub link_id: String
50}
51
52/// struct for passing parameters to the method [`get_remote_issue_links`]
53#[derive(Clone, Debug, Default)]
54pub struct GetRemoteIssueLinksParams {
55    /// The ID or key of the issue.
56    pub issue_id_or_key: String,
57    /// The global ID of the remote issue link.
58    pub global_id: Option<String>
59}
60
61/// struct for passing parameters to the method [`update_remote_issue_link`]
62#[derive(Clone, Debug, Default)]
63pub struct UpdateRemoteIssueLinkParams {
64    /// The ID or key of the issue.
65    pub issue_id_or_key: String,
66    /// The ID of the remote issue link.
67    pub link_id: String,
68    pub request_body: ::std::collections::HashMap<String, serde_json::Value>
69}
70
71
72/// struct for typed errors of method [`create_or_update_remote_issue_link`]
73#[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/// struct for typed errors of method [`delete_remote_issue_link_by_global_id`]
84#[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/// struct for typed errors of method [`delete_remote_issue_link_by_id`]
95#[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/// struct for typed errors of method [`get_remote_issue_link_by_id`]
106#[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/// struct for typed errors of method [`get_remote_issue_links`]
117#[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/// struct for typed errors of method [`update_remote_issue_link`]
128#[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
139/// Creates or updates a remote issue link for an issue.  If a `globalId` is provided and a remote issue link with that global ID is found it is updated. Any fields without values in the request are set to null. Otherwise, the remote issue link is created.  This operation requires [issue linking to be active](https://confluence.atlassian.com/x/yoXKM).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* and *Link issues* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
140pub 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    // unbox the parameters
144    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
179/// Deletes the remote issue link from the issue using the link's global ID. Where the global ID includes reserved URL characters these must be escaped in the request. For example, pass `system=http://www.mycompany.com/support&id=1` as `system%3Dhttp%3A%2F%2Fwww.mycompany.com%2Fsupport%26id%3D1`.  This operation requires [issue linking to be active](https://confluence.atlassian.com/x/yoXKM).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* and *Link issues* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is implemented, issue-level security permission to view the issue.
180pub 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    // unbox the parameters
184    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
219/// Deletes a remote issue link from an issue.  This operation requires [issue linking to be active](https://confluence.atlassian.com/x/yoXKM).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects*, *Edit issues*, and *Link issues* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
220pub async fn delete_remote_issue_link_by_id(configuration: &configuration::Configuration, params: DeleteRemoteIssueLinkByIdParams) -> Result<(), Error<DeleteRemoteIssueLinkByIdError>> {
221    let local_var_configuration = configuration;
222
223    // unbox the parameters
224    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
258/// Returns a remote issue link for an issue.  This operation requires [issue linking to be active](https://confluence.atlassian.com/x/yoXKM).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
259pub 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    // unbox the parameters
263    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
297/// Returns the remote issue links for an issue. When a remote issue link global ID is provided the record with that global ID is returned, otherwise all remote issue links are returned. Where a global ID includes reserved URL characters these must be escaped in the request. For example, pass `system=http://www.mycompany.com/support&id=1` as `system%3Dhttp%3A%2F%2Fwww.mycompany.com%2Fsupport%26id%3D1`.  This operation requires [issue linking to be active](https://confluence.atlassian.com/x/yoXKM).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
298pub 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    // unbox the parameters
302    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
339/// Updates a remote issue link for an issue.  Note: Fields without values in the request are set to null.  This operation requires [issue linking to be active](https://confluence.atlassian.com/x/yoXKM).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* and *Link issues* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
340pub 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    // unbox the parameters
344    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