jira_api_v2/apis/
issue_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;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`delete_issue_link`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteIssueLinkError {
22    Status400(),
23    Status401(),
24    Status404(),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`get_issue_link`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum GetIssueLinkError {
32    Status400(),
33    Status401(),
34    Status404(),
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`link_issues`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum LinkIssuesError {
42    Status400(),
43    Status401(),
44    Status404(),
45    UnknownValue(serde_json::Value),
46}
47
48
49/// Deletes an issue link.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  Browse project [project permission](https://confluence.atlassian.com/x/yodKLg) for all the projects containing the issues in the link.  *  *Link issues* [project permission](https://confluence.atlassian.com/x/yodKLg) for at least one of the projects containing issues in the link.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, permission to view both of the issues.
50pub async fn delete_issue_link(configuration: &configuration::Configuration, link_id: &str) -> Result<(), Error<DeleteIssueLinkError>> {
51    // add a prefix to parameters to efficiently prevent name collisions
52    let p_link_id = link_id;
53
54    let uri_str = format!("{}/rest/api/2/issueLink/{linkId}", configuration.base_path, linkId=crate::apis::urlencode(p_link_id));
55    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
56
57    if let Some(ref user_agent) = configuration.user_agent {
58        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
59    }
60    if let Some(ref token) = configuration.oauth_access_token {
61        req_builder = req_builder.bearer_auth(token.to_owned());
62    };
63    if let Some(ref auth_conf) = configuration.basic_auth {
64        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
65    };
66
67    let req = req_builder.build()?;
68    let resp = configuration.client.execute(req).await?;
69
70    let status = resp.status();
71
72    if !status.is_client_error() && !status.is_server_error() {
73        Ok(())
74    } else {
75        let content = resp.text().await?;
76        let entity: Option<DeleteIssueLinkError> = serde_json::from_str(&content).ok();
77        Err(Error::ResponseError(ResponseContent { status, content, entity }))
78    }
79}
80
81/// Returns an issue link.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse project* [project permission](https://confluence.atlassian.com/x/yodKLg) for all the projects containing the linked issues.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, permission to view both of the issues.
82pub async fn get_issue_link(configuration: &configuration::Configuration, link_id: &str) -> Result<models::IssueLink, Error<GetIssueLinkError>> {
83    // add a prefix to parameters to efficiently prevent name collisions
84    let p_link_id = link_id;
85
86    let uri_str = format!("{}/rest/api/2/issueLink/{linkId}", configuration.base_path, linkId=crate::apis::urlencode(p_link_id));
87    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
88
89    if let Some(ref user_agent) = configuration.user_agent {
90        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
91    }
92    if let Some(ref token) = configuration.oauth_access_token {
93        req_builder = req_builder.bearer_auth(token.to_owned());
94    };
95    if let Some(ref auth_conf) = configuration.basic_auth {
96        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
97    };
98
99    let req = req_builder.build()?;
100    let resp = configuration.client.execute(req).await?;
101
102    let status = resp.status();
103
104    if !status.is_client_error() && !status.is_server_error() {
105        let content = resp.text().await?;
106        serde_json::from_str(&content).map_err(Error::from)
107    } else {
108        let content = resp.text().await?;
109        let entity: Option<GetIssueLinkError> = serde_json::from_str(&content).ok();
110        Err(Error::ResponseError(ResponseContent { status, content, entity }))
111    }
112}
113
114/// Creates a link between two issues. Use this operation to indicate a relationship between two issues and optionally add a comment to the from (outward) issue. To use this resource the site must have [Issue Linking](https://confluence.atlassian.com/x/yoXKM) enabled.  This resource returns nothing on the creation of an issue link. To obtain the ID of the issue link, use `https://your-domain.atlassian.net/rest/api/2/issue/[linked issue key]?fields=issuelinks`.  If the link request duplicates a link, the response indicates that the issue link was created. If the request included a comment, the comment is added.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse project* [project permission](https://confluence.atlassian.com/x/yodKLg) for all the projects containing the issues to be linked,  *  *Link issues* [project permission](https://confluence.atlassian.com/x/yodKLg) on the project containing the from (outward) issue,  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.  *  If the comment has visibility restrictions, belongs to the group or has the role visibility is restricted to.
115pub async fn link_issues(configuration: &configuration::Configuration, link_issue_request_json_bean: models::LinkIssueRequestJsonBean) -> Result<serde_json::Value, Error<LinkIssuesError>> {
116    // add a prefix to parameters to efficiently prevent name collisions
117    let p_link_issue_request_json_bean = link_issue_request_json_bean;
118
119    let uri_str = format!("{}/rest/api/2/issueLink", configuration.base_path);
120    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
121
122    if let Some(ref user_agent) = configuration.user_agent {
123        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
124    }
125    if let Some(ref token) = configuration.oauth_access_token {
126        req_builder = req_builder.bearer_auth(token.to_owned());
127    };
128    if let Some(ref auth_conf) = configuration.basic_auth {
129        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
130    };
131    req_builder = req_builder.json(&p_link_issue_request_json_bean);
132
133    let req = req_builder.build()?;
134    let resp = configuration.client.execute(req).await?;
135
136    let status = resp.status();
137
138    if !status.is_client_error() && !status.is_server_error() {
139        let content = resp.text().await?;
140        serde_json::from_str(&content).map_err(Error::from)
141    } else {
142        let content = resp.text().await?;
143        let entity: Option<LinkIssuesError> = serde_json::from_str(&content).ok();
144        Err(Error::ResponseError(ResponseContent { status, content, entity }))
145    }
146}
147