jira/gen/apis/
issue_comments_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
11use super::{configuration, Error};
12use crate::gen::apis::ResponseContent;
13use crate::gen::models;
14
15/// struct for passing parameters to the method `add_comment`
16#[derive(Clone, Debug)]
17pub struct AddCommentParams {
18    /// The ID or key of the issue.
19    pub issue_id_or_key: String,
20    pub request_body: ::std::collections::HashMap<String, serde_json::Value>,
21    /// Use [expand](#expansion) to include additional information about comments in the response. This parameter accepts `renderedBody`, which returns the comment body rendered in HTML.
22    pub expand: Option<String>,
23}
24
25/// struct for passing parameters to the method `delete_comment`
26#[derive(Clone, Debug)]
27pub struct DeleteCommentParams {
28    /// The ID or key of the issue.
29    pub issue_id_or_key: String,
30    /// The ID of the comment.
31    pub id: String,
32}
33
34/// struct for passing parameters to the method `get_comment`
35#[derive(Clone, Debug)]
36pub struct GetCommentParams {
37    /// The ID or key of the issue.
38    pub issue_id_or_key: String,
39    /// The ID of the comment.
40    pub id: String,
41    /// Use [expand](#expansion) to include additional information about comments in the response. This parameter accepts `renderedBody`, which returns the comment body rendered in HTML.
42    pub expand: Option<String>,
43}
44
45/// struct for passing parameters to the method `get_comments`
46#[derive(Clone, Debug)]
47pub struct GetCommentsParams {
48    /// The ID or key of the issue.
49    pub issue_id_or_key: String,
50    /// The index of the first item to return in a page of results (page offset).
51    pub start_at: Option<i64>,
52    /// The maximum number of items to return per page.
53    pub max_results: Option<i32>,
54    /// [Order](#ordering) the results by a field. Accepts *created* to sort comments by their created date.
55    pub order_by: Option<String>,
56    /// Use [expand](#expansion) to include additional information about comments in the response. This parameter accepts `renderedBody`, which returns the comment body rendered in HTML.
57    pub expand: Option<String>,
58}
59
60/// struct for passing parameters to the method `get_comments_by_ids`
61#[derive(Clone, Debug)]
62pub struct GetCommentsByIdsParams {
63    /// The list of comment IDs.
64    pub issue_comment_list_request_bean: models::IssueCommentListRequestBean,
65    /// Use [expand](#expansion) to include additional information about comments in the response. This parameter accepts a comma-separated list. Expand options include:   *  `renderedBody` Returns the comment body rendered in HTML.  *  `properties` Returns the comment's properties.
66    pub expand: Option<String>,
67}
68
69/// struct for passing parameters to the method `update_comment`
70#[derive(Clone, Debug)]
71pub struct UpdateCommentParams {
72    /// The ID or key of the issue.
73    pub issue_id_or_key: String,
74    /// The ID of the comment.
75    pub id: String,
76    pub request_body: ::std::collections::HashMap<String, serde_json::Value>,
77    /// Use [expand](#expansion) to include additional information about comments in the response. This parameter accepts `renderedBody`, which returns the comment body rendered in HTML.
78    pub expand: Option<String>,
79}
80
81/// struct for typed errors of method `add_comment`
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum AddCommentError {
85    Status400(),
86    Status401(),
87    Status404(),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method `delete_comment`
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum DeleteCommentError {
95    Status400(),
96    Status401(),
97    Status404(),
98    Status405(),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method `get_comment`
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum GetCommentError {
106    Status401(),
107    Status404(),
108    UnknownValue(serde_json::Value),
109}
110
111/// struct for typed errors of method `get_comments`
112#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(untagged)]
114pub enum GetCommentsError {
115    Status400(),
116    Status401(),
117    Status404(),
118    UnknownValue(serde_json::Value),
119}
120
121/// struct for typed errors of method `get_comments_by_ids`
122#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum GetCommentsByIdsError {
125    Status400(),
126    UnknownValue(serde_json::Value),
127}
128
129/// struct for typed errors of method `update_comment`
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum UpdateCommentError {
133    Status400(),
134    Status401(),
135    Status404(),
136    UnknownValue(serde_json::Value),
137}
138
139/// Adds a comment to an issue.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* and *Add comments* [ project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue containing the comment 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 add_comment(
141    configuration: &configuration::Configuration,
142    params: AddCommentParams,
143) -> Result<models::Comment, Error<AddCommentError>> {
144    // unbox the parameters
145    let issue_id_or_key = params.issue_id_or_key;
146    let request_body = params.request_body;
147    let expand = params.expand;
148
149    let local_var_client = &configuration.client;
150
151    let local_var_uri_str = format!(
152        "{}/rest/api/3/issue/{issueIdOrKey}/comment",
153        configuration.base_path,
154        issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key)
155    );
156    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
157
158    if let Some(ref local_var_str) = expand {
159        local_var_req_builder =
160            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
161    }
162    if let Some(ref local_var_user_agent) = configuration.user_agent {
163        local_var_req_builder =
164            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
165    }
166    if let Some(ref local_var_token) = configuration.oauth_access_token {
167        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
168    };
169    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
170        local_var_req_builder = local_var_req_builder.basic_auth(
171            local_var_auth_conf.0.to_owned(),
172            local_var_auth_conf.1.to_owned(),
173        );
174    };
175    local_var_req_builder = local_var_req_builder.json(&request_body);
176
177    let local_var_req = local_var_req_builder.build()?;
178    let local_var_resp = local_var_client.execute(local_var_req).await?;
179
180    let local_var_status = local_var_resp.status();
181    let local_var_content = local_var_resp.text().await?;
182
183    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
184        serde_json::from_str(&local_var_content).map_err(Error::from)
185    } else {
186        let local_var_entity: Option<AddCommentError> =
187            serde_json::from_str(&local_var_content).ok();
188        let local_var_error = ResponseContent {
189            status: local_var_status,
190            content: local_var_content,
191            entity: local_var_entity,
192        };
193        Err(Error::ResponseError(local_var_error))
194    }
195}
196
197/// Deletes a comment.  **[Permissions](#permissions) required:**   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue containing the comment is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.  *  *Delete all comments*[ project permission](https://confluence.atlassian.com/x/yodKLg) to delete any comment or *Delete own comments* to delete comment created by the user,  *  If the comment has visibility restrictions, the user belongs to the group or has the role visibility is restricted to.
198pub async fn delete_comment(
199    configuration: &configuration::Configuration,
200    params: DeleteCommentParams,
201) -> Result<(), Error<DeleteCommentError>> {
202    // unbox the parameters
203    let issue_id_or_key = params.issue_id_or_key;
204    let id = params.id;
205
206    let local_var_client = &configuration.client;
207
208    let local_var_uri_str = format!(
209        "{}/rest/api/3/issue/{issueIdOrKey}/comment/{id}",
210        configuration.base_path,
211        issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key),
212        id = crate::gen::apis::urlencode(id)
213    );
214    let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
215
216    if let Some(ref local_var_user_agent) = configuration.user_agent {
217        local_var_req_builder =
218            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
219    }
220    if let Some(ref local_var_token) = configuration.oauth_access_token {
221        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
222    };
223    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
224        local_var_req_builder = local_var_req_builder.basic_auth(
225            local_var_auth_conf.0.to_owned(),
226            local_var_auth_conf.1.to_owned(),
227        );
228    };
229
230    let local_var_req = local_var_req_builder.build()?;
231    let local_var_resp = local_var_client.execute(local_var_req).await?;
232
233    let local_var_status = local_var_resp.status();
234    let local_var_content = local_var_resp.text().await?;
235
236    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
237        Ok(())
238    } else {
239        let local_var_entity: Option<DeleteCommentError> =
240            serde_json::from_str(&local_var_content).ok();
241        let local_var_error = ResponseContent {
242            status: local_var_status,
243            content: local_var_content,
244            entity: local_var_entity,
245        };
246        Err(Error::ResponseError(local_var_error))
247    }
248}
249
250/// Returns a comment.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the comment.  *  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, the user belongs to the group or has the role visibility is restricted to.
251pub async fn get_comment(
252    configuration: &configuration::Configuration,
253    params: GetCommentParams,
254) -> Result<models::Comment, Error<GetCommentError>> {
255    // unbox the parameters
256    let issue_id_or_key = params.issue_id_or_key;
257    let id = params.id;
258    let expand = params.expand;
259
260    let local_var_client = &configuration.client;
261
262    let local_var_uri_str = format!(
263        "{}/rest/api/3/issue/{issueIdOrKey}/comment/{id}",
264        configuration.base_path,
265        issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key),
266        id = crate::gen::apis::urlencode(id)
267    );
268    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
269
270    if let Some(ref local_var_str) = expand {
271        local_var_req_builder =
272            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
273    }
274    if let Some(ref local_var_user_agent) = configuration.user_agent {
275        local_var_req_builder =
276            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
277    }
278    if let Some(ref local_var_token) = configuration.oauth_access_token {
279        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
280    };
281    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
282        local_var_req_builder = local_var_req_builder.basic_auth(
283            local_var_auth_conf.0.to_owned(),
284            local_var_auth_conf.1.to_owned(),
285        );
286    };
287
288    let local_var_req = local_var_req_builder.build()?;
289    let local_var_resp = local_var_client.execute(local_var_req).await?;
290
291    let local_var_status = local_var_resp.status();
292    let local_var_content = local_var_resp.text().await?;
293
294    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
295        serde_json::from_str(&local_var_content).map_err(Error::from)
296    } else {
297        let local_var_entity: Option<GetCommentError> =
298            serde_json::from_str(&local_var_content).ok();
299        let local_var_error = ResponseContent {
300            status: local_var_status,
301            content: local_var_content,
302            entity: local_var_entity,
303        };
304        Err(Error::ResponseError(local_var_error))
305    }
306}
307
308/// Returns all comments for an issue.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** Comments are included in the response where the user has:   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the comment.  *  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 role visibility is restricted to.
309pub async fn get_comments(
310    configuration: &configuration::Configuration,
311    params: GetCommentsParams,
312) -> Result<models::PageOfComments, Error<GetCommentsError>> {
313    // unbox the parameters
314    let issue_id_or_key = params.issue_id_or_key;
315    let start_at = params.start_at;
316    let max_results = params.max_results;
317    let order_by = params.order_by;
318    let expand = params.expand;
319
320    let local_var_client = &configuration.client;
321
322    let local_var_uri_str = format!(
323        "{}/rest/api/3/issue/{issueIdOrKey}/comment",
324        configuration.base_path,
325        issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key)
326    );
327    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
328
329    if let Some(ref local_var_str) = start_at {
330        local_var_req_builder =
331            local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
332    }
333    if let Some(ref local_var_str) = max_results {
334        local_var_req_builder =
335            local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
336    }
337    if let Some(ref local_var_str) = order_by {
338        local_var_req_builder =
339            local_var_req_builder.query(&[("orderBy", &local_var_str.to_string())]);
340    }
341    if let Some(ref local_var_str) = expand {
342        local_var_req_builder =
343            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
344    }
345    if let Some(ref local_var_user_agent) = configuration.user_agent {
346        local_var_req_builder =
347            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
348    }
349    if let Some(ref local_var_token) = configuration.oauth_access_token {
350        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
351    };
352    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
353        local_var_req_builder = local_var_req_builder.basic_auth(
354            local_var_auth_conf.0.to_owned(),
355            local_var_auth_conf.1.to_owned(),
356        );
357    };
358
359    let local_var_req = local_var_req_builder.build()?;
360    let local_var_resp = local_var_client.execute(local_var_req).await?;
361
362    let local_var_status = local_var_resp.status();
363    let local_var_content = local_var_resp.text().await?;
364
365    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
366        serde_json::from_str(&local_var_content).map_err(Error::from)
367    } else {
368        let local_var_entity: Option<GetCommentsError> =
369            serde_json::from_str(&local_var_content).ok();
370        let local_var_error = ResponseContent {
371            status: local_var_status,
372            content: local_var_content,
373            entity: local_var_entity,
374        };
375        Err(Error::ResponseError(local_var_error))
376    }
377}
378
379/// Returns a [paginated](#pagination) list of just the comments for a list of comments specified by comment IDs.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** Comments are returned where the user:   *  has *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the comment.  *  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.
380pub async fn get_comments_by_ids(
381    configuration: &configuration::Configuration,
382    params: GetCommentsByIdsParams,
383) -> Result<models::PageBeanComment, Error<GetCommentsByIdsError>> {
384    // unbox the parameters
385    let issue_comment_list_request_bean = params.issue_comment_list_request_bean;
386    let expand = params.expand;
387
388    let local_var_client = &configuration.client;
389
390    let local_var_uri_str = format!("{}/rest/api/3/comment/list", configuration.base_path);
391    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
392
393    if let Some(ref local_var_str) = expand {
394        local_var_req_builder =
395            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
396    }
397    if let Some(ref local_var_user_agent) = configuration.user_agent {
398        local_var_req_builder =
399            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
400    }
401    if let Some(ref local_var_token) = configuration.oauth_access_token {
402        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
403    };
404    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
405        local_var_req_builder = local_var_req_builder.basic_auth(
406            local_var_auth_conf.0.to_owned(),
407            local_var_auth_conf.1.to_owned(),
408        );
409    };
410    local_var_req_builder = local_var_req_builder.json(&issue_comment_list_request_bean);
411
412    let local_var_req = local_var_req_builder.build()?;
413    let local_var_resp = local_var_client.execute(local_var_req).await?;
414
415    let local_var_status = local_var_resp.status();
416    let local_var_content = local_var_resp.text().await?;
417
418    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
419        serde_json::from_str(&local_var_content).map_err(Error::from)
420    } else {
421        let local_var_entity: Option<GetCommentsByIdsError> =
422            serde_json::from_str(&local_var_content).ok();
423        let local_var_error = ResponseContent {
424            status: local_var_status,
425            content: local_var_content,
426            entity: local_var_entity,
427        };
428        Err(Error::ResponseError(local_var_error))
429    }
430}
431
432/// Updates a comment.  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 containing the comment is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.  *  *Edit all comments*[ project permission](https://confluence.atlassian.com/x/yodKLg) to update any comment or *Edit own comments* to update comment created by the user.  *  If the comment has visibility restrictions, the user belongs to the group or has the role visibility is restricted to.
433pub async fn update_comment(
434    configuration: &configuration::Configuration,
435    params: UpdateCommentParams,
436) -> Result<models::Comment, Error<UpdateCommentError>> {
437    // unbox the parameters
438    let issue_id_or_key = params.issue_id_or_key;
439    let id = params.id;
440    let request_body = params.request_body;
441    let expand = params.expand;
442
443    let local_var_client = &configuration.client;
444
445    let local_var_uri_str = format!(
446        "{}/rest/api/3/issue/{issueIdOrKey}/comment/{id}",
447        configuration.base_path,
448        issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key),
449        id = crate::gen::apis::urlencode(id)
450    );
451    let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
452
453    if let Some(ref local_var_str) = expand {
454        local_var_req_builder =
455            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
456    }
457    if let Some(ref local_var_user_agent) = configuration.user_agent {
458        local_var_req_builder =
459            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
460    }
461    if let Some(ref local_var_token) = configuration.oauth_access_token {
462        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
463    };
464    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
465        local_var_req_builder = local_var_req_builder.basic_auth(
466            local_var_auth_conf.0.to_owned(),
467            local_var_auth_conf.1.to_owned(),
468        );
469    };
470    local_var_req_builder = local_var_req_builder.json(&request_body);
471
472    let local_var_req = local_var_req_builder.build()?;
473    let local_var_resp = local_var_client.execute(local_var_req).await?;
474
475    let local_var_status = local_var_resp.status();
476    let local_var_content = local_var_resp.text().await?;
477
478    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
479        serde_json::from_str(&local_var_content).map_err(Error::from)
480    } else {
481        let local_var_entity: Option<UpdateCommentError> =
482            serde_json::from_str(&local_var_content).ok();
483        let local_var_error = ResponseContent {
484            status: local_var_status,
485            content: local_var_content,
486            entity: local_var_entity,
487        };
488        Err(Error::ResponseError(local_var_error))
489    }
490}