1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! Issue Links API
//!
//! This module provides methods to manage links between Jira issues.
use crate::{CreateIssueLinkInput, IssueLink, Jira, Result};
/// Issue Links operations
pub struct IssueLinks {
jira: Jira,
}
impl IssueLinks {
pub(crate) fn new(jira: &Jira) -> Self {
Self { jira: jira.clone() }
}
/// Get an issue link by ID
///
/// Returns the details of a specific issue link.
///
/// # Arguments
///
/// * `link_id` - The ID of the issue link
///
/// # Examples
///
/// ```rust,no_run
/// # use gouqi::{Credentials, Jira};
/// # let jira = Jira::new("http://localhost", Credentials::Anonymous).unwrap();
/// let link = jira.issue_links().get("10001")?;
/// println!("Link type: {}", link.link_type.name);
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
pub fn get<L>(&self, link_id: L) -> Result<IssueLink>
where
L: Into<String>,
{
self.jira
.get("api", &format!("/issueLink/{}", link_id.into()))
}
/// Create a link between two issues
///
/// Creates a new link between two issues with the specified link type.
///
/// # Arguments
///
/// * `link` - The link data including type, inward and outward issues
///
/// # Examples
///
/// ```rust,no_run
/// # use gouqi::{Credentials, Jira, CreateIssueLinkInput};
/// # let jira = Jira::new("http://localhost", Credentials::Anonymous).unwrap();
/// let link = CreateIssueLinkInput::new("Blocks", "PROJ-1", "PROJ-2")
/// .with_comment("Blocking relationship");
///
/// jira.issue_links().create(link)?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
pub fn create(&self, link: CreateIssueLinkInput) -> Result<()> {
self.jira
.post::<(), CreateIssueLinkInput>("api", "/issueLink", link)
}
/// Delete an issue link
///
/// Removes the link between two issues.
///
/// # Arguments
///
/// * `link_id` - The ID of the issue link to delete
///
/// # Examples
///
/// ```rust,no_run
/// # use gouqi::{Credentials, Jira};
/// # let jira = Jira::new("http://localhost", Credentials::Anonymous).unwrap();
/// jira.issue_links().delete("10001")?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
pub fn delete<L>(&self, link_id: L) -> Result<()>
where
L: Into<String>,
{
self.jira
.delete::<crate::EmptyResponse>("api", &format!("/issueLink/{}", link_id.into()))?;
Ok(())
}
}
#[cfg(feature = "async")]
use crate::r#async::Jira as AsyncJira;
#[cfg(feature = "async")]
/// Async issue links operations
pub struct AsyncIssueLinks {
jira: AsyncJira,
}
#[cfg(feature = "async")]
impl AsyncIssueLinks {
pub(crate) fn new(jira: &AsyncJira) -> Self {
Self { jira: jira.clone() }
}
/// Get an issue link by ID (async)
pub async fn get<L>(&self, link_id: L) -> Result<IssueLink>
where
L: Into<String>,
{
self.jira
.get("api", &format!("/issueLink/{}", link_id.into()))
.await
}
/// Create a link between two issues (async)
pub async fn create(&self, link: CreateIssueLinkInput) -> Result<()> {
self.jira
.post::<(), CreateIssueLinkInput>("api", "/issueLink", link)
.await
}
/// Delete an issue link (async)
pub async fn delete<L>(&self, link_id: L) -> Result<()>
where
L: Into<String>,
{
self.jira
.delete::<crate::EmptyResponse>("api", &format!("/issueLink/{}", link_id.into()))
.await?;
Ok(())
}
}