jira_api_v2/apis/
issue_comment_properties_api.rs1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[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#[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#[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#[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
63pub async fn delete_comment_property(configuration: &configuration::Configuration, comment_id: &str, property_key: &str) -> Result<(), Error<DeleteCommentPropertyError>> {
65 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
96pub async fn get_comment_property(configuration: &configuration::Configuration, comment_id: &str, property_key: &str) -> Result<models::EntityProperty, Error<GetCommentPropertyError>> {
98 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
130pub async fn get_comment_property_keys(configuration: &configuration::Configuration, comment_id: &str) -> Result<models::PropertyKeys, Error<GetCommentPropertyKeysError>> {
132 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
163pub 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 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