/*
* The Jira Cloud platform REST API
*
* Jira Cloud platform REST API documentation
*
* The version of the OpenAPI document: 1001.0.0-SNAPSHOT
* Contact: ecosystem@atlassian.com
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
/// struct for passing parameters to the method [`delete_issue_link`]
#[derive(Clone, Debug, Default)]
pub struct DeleteIssueLinkParams {
/// The ID of the issue link.
pub link_id: String
}
/// struct for passing parameters to the method [`get_issue_link`]
#[derive(Clone, Debug, Default)]
pub struct GetIssueLinkParams {
/// The ID of the issue link.
pub link_id: String
}
/// struct for passing parameters to the method [`link_issues`]
#[derive(Clone, Debug, Default)]
pub struct LinkIssuesParams {
/// The issue link request.
pub link_issue_request_json_bean: crate::models::LinkIssueRequestJsonBean
}
/// struct for typed successes of method [`delete_issue_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteIssueLinkSuccess {
Status200(),
Status204(),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_issue_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIssueLinkSuccess {
Status200(crate::models::IssueLink),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`link_issues`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LinkIssuesSuccess {
Status201(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_issue_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteIssueLinkError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_issue_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIssueLinkError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`link_issues`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LinkIssuesError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// 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.
pub async fn delete_issue_link(configuration: &configuration::Configuration, params: DeleteIssueLinkParams) -> Result<ResponseContent<DeleteIssueLinkSuccess>, Error<DeleteIssueLinkError>> {
let local_var_configuration = configuration;
// unbox the parameters
let link_id = params.link_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/issueLink/{linkId}", local_var_configuration.base_path, linkId=crate::apis::urlencode(link_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<DeleteIssueLinkSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<DeleteIssueLinkError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_issue_link(configuration: &configuration::Configuration, params: GetIssueLinkParams) -> Result<ResponseContent<GetIssueLinkSuccess>, Error<GetIssueLinkError>> {
let local_var_configuration = configuration;
// unbox the parameters
let link_id = params.link_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/issueLink/{linkId}", local_var_configuration.base_path, linkId=crate::apis::urlencode(link_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetIssueLinkSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetIssueLinkError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn link_issues(configuration: &configuration::Configuration, params: LinkIssuesParams) -> Result<ResponseContent<LinkIssuesSuccess>, Error<LinkIssuesError>> {
let local_var_configuration = configuration;
// unbox the parameters
let link_issue_request_json_bean = params.link_issue_request_json_bean;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/issueLink", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&link_issue_request_json_bean);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<LinkIssuesSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<LinkIssuesError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}