jira_api_v2/apis/
issue_comment_properties_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_comment_property`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteCommentPropertyError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`get_comment_property`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum GetCommentPropertyError {
33    Status400(),
34    Status401(),
35    Status403(),
36    Status404(),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`get_comment_property_keys`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetCommentPropertyKeysError {
44    Status400(),
45    Status401(),
46    Status403(),
47    Status404(),
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`set_comment_property`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum SetCommentPropertyError {
55    Status400(),
56    Status401(),
57    Status403(),
58    Status404(),
59    UnknownValue(serde_json::Value),
60}
61
62
63/// Deletes a comment property.  **[Permissions](#permissions) required:** either of:   *  *Edit All Comments* [project permission](https://confluence.atlassian.com/x/yodKLg) to delete a property from any comment.  *  *Edit Own Comments* [project permission](https://confluence.atlassian.com/x/yodKLg) to delete a property from a comment created by the user.  Also, when the visibility of a comment is restricted to a role or group the user must be a member of that role or group.
64pub async fn delete_comment_property(configuration: &configuration::Configuration, comment_id: &str, property_key: &str) -> Result<(), Error<DeleteCommentPropertyError>> {
65    // add a prefix to parameters to efficiently prevent name collisions
66    let p_comment_id = comment_id;
67    let p_property_key = property_key;
68
69    let uri_str = format!("{}/rest/api/2/comment/{commentId}/properties/{propertyKey}", configuration.base_path, commentId=crate::apis::urlencode(p_comment_id), propertyKey=crate::apis::urlencode(p_property_key));
70    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
71
72    if let Some(ref user_agent) = configuration.user_agent {
73        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
74    }
75    if let Some(ref token) = configuration.oauth_access_token {
76        req_builder = req_builder.bearer_auth(token.to_owned());
77    };
78    if let Some(ref auth_conf) = configuration.basic_auth {
79        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
80    };
81
82    let req = req_builder.build()?;
83    let resp = configuration.client.execute(req).await?;
84
85    let status = resp.status();
86
87    if !status.is_client_error() && !status.is_server_error() {
88        Ok(())
89    } else {
90        let content = resp.text().await?;
91        let entity: Option<DeleteCommentPropertyError> = serde_json::from_str(&content).ok();
92        Err(Error::ResponseError(ResponseContent { status, content, entity }))
93    }
94}
95
96/// Returns the value of a comment property.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.  *  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.
97pub async fn get_comment_property(configuration: &configuration::Configuration, comment_id: &str, property_key: &str) -> Result<models::EntityProperty, Error<GetCommentPropertyError>> {
98    // add a prefix to parameters to efficiently prevent name collisions
99    let p_comment_id = comment_id;
100    let p_property_key = property_key;
101
102    let uri_str = format!("{}/rest/api/2/comment/{commentId}/properties/{propertyKey}", configuration.base_path, commentId=crate::apis::urlencode(p_comment_id), propertyKey=crate::apis::urlencode(p_property_key));
103    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
104
105    if let Some(ref user_agent) = configuration.user_agent {
106        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
107    }
108    if let Some(ref token) = configuration.oauth_access_token {
109        req_builder = req_builder.bearer_auth(token.to_owned());
110    };
111    if let Some(ref auth_conf) = configuration.basic_auth {
112        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
113    };
114
115    let req = req_builder.build()?;
116    let resp = configuration.client.execute(req).await?;
117
118    let status = resp.status();
119
120    if !status.is_client_error() && !status.is_server_error() {
121        let content = resp.text().await?;
122        serde_json::from_str(&content).map_err(Error::from)
123    } else {
124        let content = resp.text().await?;
125        let entity: Option<GetCommentPropertyError> = serde_json::from_str(&content).ok();
126        Err(Error::ResponseError(ResponseContent { status, content, entity }))
127    }
128}
129
130/// Returns the keys of all the properties of a comment.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.  *  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.
131pub async fn get_comment_property_keys(configuration: &configuration::Configuration, comment_id: &str) -> Result<models::PropertyKeys, Error<GetCommentPropertyKeysError>> {
132    // add a prefix to parameters to efficiently prevent name collisions
133    let p_comment_id = comment_id;
134
135    let uri_str = format!("{}/rest/api/2/comment/{commentId}/properties", configuration.base_path, commentId=crate::apis::urlencode(p_comment_id));
136    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
137
138    if let Some(ref user_agent) = configuration.user_agent {
139        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
140    }
141    if let Some(ref token) = configuration.oauth_access_token {
142        req_builder = req_builder.bearer_auth(token.to_owned());
143    };
144    if let Some(ref auth_conf) = configuration.basic_auth {
145        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
146    };
147
148    let req = req_builder.build()?;
149    let resp = configuration.client.execute(req).await?;
150
151    let status = resp.status();
152
153    if !status.is_client_error() && !status.is_server_error() {
154        let content = resp.text().await?;
155        serde_json::from_str(&content).map_err(Error::from)
156    } else {
157        let content = resp.text().await?;
158        let entity: Option<GetCommentPropertyKeysError> = serde_json::from_str(&content).ok();
159        Err(Error::ResponseError(ResponseContent { status, content, entity }))
160    }
161}
162
163/// Creates or updates the value of a property for a comment. Use this resource to store custom data against a comment.  The value of the request body must be a [valid](http://tools.ietf.org/html/rfc4627), non-empty JSON blob. The maximum length is 32768 characters.  **[Permissions](#permissions) required:** either of:   *  *Edit All Comments* [project permission](https://confluence.atlassian.com/x/yodKLg) to create or update the value of a property on any comment.  *  *Edit Own Comments* [project permission](https://confluence.atlassian.com/x/yodKLg) to create or update the value of a property on a comment created by the user.  Also, when the visibility of a comment is restricted to a role or group the user must be a member of that role or group.
164pub async fn set_comment_property(configuration: &configuration::Configuration, comment_id: &str, property_key: &str, body: Option<serde_json::Value>) -> Result<serde_json::Value, Error<SetCommentPropertyError>> {
165    // add a prefix to parameters to efficiently prevent name collisions
166    let p_comment_id = comment_id;
167    let p_property_key = property_key;
168    let p_body = body;
169
170    let uri_str = format!("{}/rest/api/2/comment/{commentId}/properties/{propertyKey}", configuration.base_path, commentId=crate::apis::urlencode(p_comment_id), propertyKey=crate::apis::urlencode(p_property_key));
171    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
172
173    if let Some(ref user_agent) = configuration.user_agent {
174        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
175    }
176    if let Some(ref token) = configuration.oauth_access_token {
177        req_builder = req_builder.bearer_auth(token.to_owned());
178    };
179    if let Some(ref auth_conf) = configuration.basic_auth {
180        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
181    };
182    req_builder = req_builder.json(&p_body);
183
184    let req = req_builder.build()?;
185    let resp = configuration.client.execute(req).await?;
186
187    let status = resp.status();
188
189    if !status.is_client_error() && !status.is_server_error() {
190        let content = resp.text().await?;
191        serde_json::from_str(&content).map_err(Error::from)
192    } else {
193        let content = resp.text().await?;
194        let entity: Option<SetCommentPropertyError> = serde_json::from_str(&content).ok();
195        Err(Error::ResponseError(ResponseContent { status, content, entity }))
196    }
197}
198