hi_jira2/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;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`delete_comment_property`]
18#[derive(Clone, Debug, Default)]
19pub struct DeleteCommentPropertyParams {
20    /// The ID of the comment.
21    pub comment_id: String,
22    /// The key of the property.
23    pub property_key: String
24}
25
26/// struct for passing parameters to the method [`get_comment_property`]
27#[derive(Clone, Debug, Default)]
28pub struct GetCommentPropertyParams {
29    /// The ID of the comment.
30    pub comment_id: String,
31    /// The key of the property.
32    pub property_key: String
33}
34
35/// struct for passing parameters to the method [`get_comment_property_keys`]
36#[derive(Clone, Debug, Default)]
37pub struct GetCommentPropertyKeysParams {
38    /// The ID of the comment.
39    pub comment_id: String
40}
41
42/// struct for passing parameters to the method [`set_comment_property`]
43#[derive(Clone, Debug, Default)]
44pub struct SetCommentPropertyParams {
45    /// The ID of the comment.
46    pub comment_id: String,
47    /// The key of the property. The maximum length is 255 characters.
48    pub property_key: String,
49    pub body: Option<serde_json::Value>
50}
51
52
53/// struct for typed errors of method [`delete_comment_property`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum DeleteCommentPropertyError {
57    Status400(),
58    Status401(),
59    Status403(),
60    Status404(),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`get_comment_property`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum GetCommentPropertyError {
68    Status400(),
69    Status401(),
70    Status403(),
71    Status404(),
72    UnknownValue(serde_json::Value),
73}
74
75/// struct for typed errors of method [`get_comment_property_keys`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum GetCommentPropertyKeysError {
79    Status400(),
80    Status401(),
81    Status403(),
82    Status404(),
83    UnknownValue(serde_json::Value),
84}
85
86/// struct for typed errors of method [`set_comment_property`]
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum SetCommentPropertyError {
90    Status400(),
91    Status401(),
92    Status403(),
93    Status404(),
94    UnknownValue(serde_json::Value),
95}
96
97
98/// 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.
99pub async fn delete_comment_property(configuration: &configuration::Configuration, params: DeleteCommentPropertyParams) -> Result<(), Error<DeleteCommentPropertyError>> {
100    let local_var_configuration = configuration;
101
102    // unbox the parameters
103    let comment_id = params.comment_id;
104    let property_key = params.property_key;
105
106
107    let local_var_client = &local_var_configuration.client;
108
109    let local_var_uri_str = format!("{}/rest/api/2/comment/{commentId}/properties/{propertyKey}", local_var_configuration.base_path, commentId=crate::apis::urlencode(comment_id), propertyKey=crate::apis::urlencode(property_key));
110    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
111
112    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
113        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
114    }
115    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
116        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
117    };
118    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
119        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
120    };
121
122    let local_var_req = local_var_req_builder.build()?;
123    let local_var_resp = local_var_client.execute(local_var_req).await?;
124
125    let local_var_status = local_var_resp.status();
126    let local_var_content = local_var_resp.text().await?;
127
128    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
129        Ok(())
130    } else {
131        let local_var_entity: Option<DeleteCommentPropertyError> = serde_json::from_str(&local_var_content).ok();
132        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
133        Err(Error::ResponseError(local_var_error))
134    }
135}
136
137/// 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.
138pub async fn get_comment_property(configuration: &configuration::Configuration, params: GetCommentPropertyParams) -> Result<crate::models::EntityProperty, Error<GetCommentPropertyError>> {
139    let local_var_configuration = configuration;
140
141    // unbox the parameters
142    let comment_id = params.comment_id;
143    let property_key = params.property_key;
144
145
146    let local_var_client = &local_var_configuration.client;
147
148    let local_var_uri_str = format!("{}/rest/api/2/comment/{commentId}/properties/{propertyKey}", local_var_configuration.base_path, commentId=crate::apis::urlencode(comment_id), propertyKey=crate::apis::urlencode(property_key));
149    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
150
151    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
152        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
153    }
154    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
155        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
156    };
157    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
158        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
159    };
160
161    let local_var_req = local_var_req_builder.build()?;
162    let local_var_resp = local_var_client.execute(local_var_req).await?;
163
164    let local_var_status = local_var_resp.status();
165    let local_var_content = local_var_resp.text().await?;
166
167    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
168        serde_json::from_str(&local_var_content).map_err(Error::from)
169    } else {
170        let local_var_entity: Option<GetCommentPropertyError> = serde_json::from_str(&local_var_content).ok();
171        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
172        Err(Error::ResponseError(local_var_error))
173    }
174}
175
176/// 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.
177pub async fn get_comment_property_keys(configuration: &configuration::Configuration, params: GetCommentPropertyKeysParams) -> Result<crate::models::PropertyKeys, Error<GetCommentPropertyKeysError>> {
178    let local_var_configuration = configuration;
179
180    // unbox the parameters
181    let comment_id = params.comment_id;
182
183
184    let local_var_client = &local_var_configuration.client;
185
186    let local_var_uri_str = format!("{}/rest/api/2/comment/{commentId}/properties", local_var_configuration.base_path, commentId=crate::apis::urlencode(comment_id));
187    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
188
189    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
190        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
191    }
192    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
193        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
194    };
195    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
196        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
197    };
198
199    let local_var_req = local_var_req_builder.build()?;
200    let local_var_resp = local_var_client.execute(local_var_req).await?;
201
202    let local_var_status = local_var_resp.status();
203    let local_var_content = local_var_resp.text().await?;
204
205    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
206        serde_json::from_str(&local_var_content).map_err(Error::from)
207    } else {
208        let local_var_entity: Option<GetCommentPropertyKeysError> = serde_json::from_str(&local_var_content).ok();
209        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
210        Err(Error::ResponseError(local_var_error))
211    }
212}
213
214/// 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.
215pub async fn set_comment_property(configuration: &configuration::Configuration, params: SetCommentPropertyParams) -> Result<serde_json::Value, Error<SetCommentPropertyError>> {
216    let local_var_configuration = configuration;
217
218    // unbox the parameters
219    let comment_id = params.comment_id;
220    let property_key = params.property_key;
221    let body = params.body;
222
223
224    let local_var_client = &local_var_configuration.client;
225
226    let local_var_uri_str = format!("{}/rest/api/2/comment/{commentId}/properties/{propertyKey}", local_var_configuration.base_path, commentId=crate::apis::urlencode(comment_id), propertyKey=crate::apis::urlencode(property_key));
227    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
228
229    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
230        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
231    }
232    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
233        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
234    };
235    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
236        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
237    };
238    local_var_req_builder = local_var_req_builder.json(&body);
239
240    let local_var_req = local_var_req_builder.build()?;
241    let local_var_resp = local_var_client.execute(local_var_req).await?;
242
243    let local_var_status = local_var_resp.status();
244    let local_var_content = local_var_resp.text().await?;
245
246    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
247        serde_json::from_str(&local_var_content).map_err(Error::from)
248    } else {
249        let local_var_entity: Option<SetCommentPropertyError> = serde_json::from_str(&local_var_content).ok();
250        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
251        Err(Error::ResponseError(local_var_error))
252    }
253}
254