hi_jira2/apis/
issue_comment_properties_api.rs1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17#[derive(Clone, Debug, Default)]
19pub struct DeleteCommentPropertyParams {
20 pub comment_id: String,
22 pub property_key: String
24}
25
26#[derive(Clone, Debug, Default)]
28pub struct GetCommentPropertyParams {
29 pub comment_id: String,
31 pub property_key: String
33}
34
35#[derive(Clone, Debug, Default)]
37pub struct GetCommentPropertyKeysParams {
38 pub comment_id: String
40}
41
42#[derive(Clone, Debug, Default)]
44pub struct SetCommentPropertyParams {
45 pub comment_id: String,
47 pub property_key: String,
49 pub body: Option<serde_json::Value>
50}
51
52
53#[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#[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#[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#[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
98pub async fn delete_comment_property(configuration: &configuration::Configuration, params: DeleteCommentPropertyParams) -> Result<(), Error<DeleteCommentPropertyError>> {
100 let local_var_configuration = configuration;
101
102 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
137pub async fn get_comment_property(configuration: &configuration::Configuration, params: GetCommentPropertyParams) -> Result<crate::models::EntityProperty, Error<GetCommentPropertyError>> {
139 let local_var_configuration = configuration;
140
141 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
176pub 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 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
214pub async fn set_comment_property(configuration: &configuration::Configuration, params: SetCommentPropertyParams) -> Result<serde_json::Value, Error<SetCommentPropertyError>> {
216 let local_var_configuration = configuration;
217
218 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