1use 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 AssignFieldConfigurationSchemeToProjectError {
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 GetAllFieldConfigurationSchemesError {
33 Status400(),
34 Status401(),
35 Status403(),
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetAllFieldConfigurationsError {
43 Status401(),
44 Status403(),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetFieldConfigurationItemsError {
52 Status401(),
53 Status403(),
54 Status404(),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetFieldConfigurationSchemeMappingsError {
62 Status400(),
63 Status401(),
64 Status403(),
65 Status404(),
66 UnknownValue(serde_json::Value),
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetFieldConfigurationSchemeProjectMappingError {
73 Status400(),
74 Status401(),
75 Status403(),
76 UnknownValue(serde_json::Value),
77}
78
79
80pub async fn assign_field_configuration_scheme_to_project(configuration: &configuration::Configuration, field_configuration_scheme_project_association: models::FieldConfigurationSchemeProjectAssociation) -> Result<serde_json::Value, Error<AssignFieldConfigurationSchemeToProjectError>> {
82 let p_field_configuration_scheme_project_association = field_configuration_scheme_project_association;
84
85 let uri_str = format!("{}/rest/api/2/fieldconfigurationscheme/project", configuration.base_path);
86 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
87
88 if let Some(ref user_agent) = configuration.user_agent {
89 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
90 }
91 if let Some(ref token) = configuration.oauth_access_token {
92 req_builder = req_builder.bearer_auth(token.to_owned());
93 };
94 if let Some(ref auth_conf) = configuration.basic_auth {
95 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
96 };
97 req_builder = req_builder.json(&p_field_configuration_scheme_project_association);
98
99 let req = req_builder.build()?;
100 let resp = configuration.client.execute(req).await?;
101
102 let status = resp.status();
103
104 if !status.is_client_error() && !status.is_server_error() {
105 let content = resp.text().await?;
106 serde_json::from_str(&content).map_err(Error::from)
107 } else {
108 let content = resp.text().await?;
109 let entity: Option<AssignFieldConfigurationSchemeToProjectError> = serde_json::from_str(&content).ok();
110 Err(Error::ResponseError(ResponseContent { status, content, entity }))
111 }
112}
113
114pub async fn get_all_field_configuration_schemes(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, id: Option<Vec<i64>>) -> Result<models::PageBeanFieldConfigurationScheme, Error<GetAllFieldConfigurationSchemesError>> {
116 let p_start_at = start_at;
118 let p_max_results = max_results;
119 let p_id = id;
120
121 let uri_str = format!("{}/rest/api/2/fieldconfigurationscheme", configuration.base_path);
122 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
123
124 if let Some(ref param_value) = p_start_at {
125 req_builder = req_builder.query(&[("startAt", ¶m_value.to_string())]);
126 }
127 if let Some(ref param_value) = p_max_results {
128 req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
129 }
130 if let Some(ref param_value) = p_id {
131 req_builder = match "multi" {
132 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("id".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
133 _ => req_builder.query(&[("id", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
134 };
135 }
136 if let Some(ref user_agent) = configuration.user_agent {
137 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
138 }
139 if let Some(ref token) = configuration.oauth_access_token {
140 req_builder = req_builder.bearer_auth(token.to_owned());
141 };
142 if let Some(ref auth_conf) = configuration.basic_auth {
143 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
144 };
145
146 let req = req_builder.build()?;
147 let resp = configuration.client.execute(req).await?;
148
149 let status = resp.status();
150
151 if !status.is_client_error() && !status.is_server_error() {
152 let content = resp.text().await?;
153 serde_json::from_str(&content).map_err(Error::from)
154 } else {
155 let content = resp.text().await?;
156 let entity: Option<GetAllFieldConfigurationSchemesError> = serde_json::from_str(&content).ok();
157 Err(Error::ResponseError(ResponseContent { status, content, entity }))
158 }
159}
160
161pub async fn get_all_field_configurations(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, id: Option<Vec<i64>>, is_default: Option<bool>, query: Option<&str>) -> Result<models::PageBeanFieldConfiguration, Error<GetAllFieldConfigurationsError>> {
163 let p_start_at = start_at;
165 let p_max_results = max_results;
166 let p_id = id;
167 let p_is_default = is_default;
168 let p_query = query;
169
170 let uri_str = format!("{}/rest/api/2/fieldconfiguration", configuration.base_path);
171 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
172
173 if let Some(ref param_value) = p_start_at {
174 req_builder = req_builder.query(&[("startAt", ¶m_value.to_string())]);
175 }
176 if let Some(ref param_value) = p_max_results {
177 req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
178 }
179 if let Some(ref param_value) = p_id {
180 req_builder = match "multi" {
181 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("id".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
182 _ => req_builder.query(&[("id", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
183 };
184 }
185 if let Some(ref param_value) = p_is_default {
186 req_builder = req_builder.query(&[("isDefault", ¶m_value.to_string())]);
187 }
188 if let Some(ref param_value) = p_query {
189 req_builder = req_builder.query(&[("query", ¶m_value.to_string())]);
190 }
191 if let Some(ref user_agent) = configuration.user_agent {
192 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
193 }
194 if let Some(ref token) = configuration.oauth_access_token {
195 req_builder = req_builder.bearer_auth(token.to_owned());
196 };
197 if let Some(ref auth_conf) = configuration.basic_auth {
198 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
199 };
200
201 let req = req_builder.build()?;
202 let resp = configuration.client.execute(req).await?;
203
204 let status = resp.status();
205
206 if !status.is_client_error() && !status.is_server_error() {
207 let content = resp.text().await?;
208 serde_json::from_str(&content).map_err(Error::from)
209 } else {
210 let content = resp.text().await?;
211 let entity: Option<GetAllFieldConfigurationsError> = serde_json::from_str(&content).ok();
212 Err(Error::ResponseError(ResponseContent { status, content, entity }))
213 }
214}
215
216pub async fn get_field_configuration_items(configuration: &configuration::Configuration, id: i64, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanFieldConfigurationItem, Error<GetFieldConfigurationItemsError>> {
218 let p_id = id;
220 let p_start_at = start_at;
221 let p_max_results = max_results;
222
223 let uri_str = format!("{}/rest/api/2/fieldconfiguration/{id}/fields", configuration.base_path, id=p_id);
224 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
225
226 if let Some(ref param_value) = p_start_at {
227 req_builder = req_builder.query(&[("startAt", ¶m_value.to_string())]);
228 }
229 if let Some(ref param_value) = p_max_results {
230 req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
231 }
232 if let Some(ref user_agent) = configuration.user_agent {
233 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
234 }
235 if let Some(ref token) = configuration.oauth_access_token {
236 req_builder = req_builder.bearer_auth(token.to_owned());
237 };
238 if let Some(ref auth_conf) = configuration.basic_auth {
239 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
240 };
241
242 let req = req_builder.build()?;
243 let resp = configuration.client.execute(req).await?;
244
245 let status = resp.status();
246
247 if !status.is_client_error() && !status.is_server_error() {
248 let content = resp.text().await?;
249 serde_json::from_str(&content).map_err(Error::from)
250 } else {
251 let content = resp.text().await?;
252 let entity: Option<GetFieldConfigurationItemsError> = serde_json::from_str(&content).ok();
253 Err(Error::ResponseError(ResponseContent { status, content, entity }))
254 }
255}
256
257pub async fn get_field_configuration_scheme_mappings(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, field_configuration_scheme_id: Option<Vec<i64>>) -> Result<models::PageBeanFieldConfigurationIssueTypeItem, Error<GetFieldConfigurationSchemeMappingsError>> {
259 let p_start_at = start_at;
261 let p_max_results = max_results;
262 let p_field_configuration_scheme_id = field_configuration_scheme_id;
263
264 let uri_str = format!("{}/rest/api/2/fieldconfigurationscheme/mapping", configuration.base_path);
265 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
266
267 if let Some(ref param_value) = p_start_at {
268 req_builder = req_builder.query(&[("startAt", ¶m_value.to_string())]);
269 }
270 if let Some(ref param_value) = p_max_results {
271 req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
272 }
273 if let Some(ref param_value) = p_field_configuration_scheme_id {
274 req_builder = match "multi" {
275 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("fieldConfigurationSchemeId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
276 _ => req_builder.query(&[("fieldConfigurationSchemeId", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
277 };
278 }
279 if let Some(ref user_agent) = configuration.user_agent {
280 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
281 }
282 if let Some(ref token) = configuration.oauth_access_token {
283 req_builder = req_builder.bearer_auth(token.to_owned());
284 };
285 if let Some(ref auth_conf) = configuration.basic_auth {
286 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
287 };
288
289 let req = req_builder.build()?;
290 let resp = configuration.client.execute(req).await?;
291
292 let status = resp.status();
293
294 if !status.is_client_error() && !status.is_server_error() {
295 let content = resp.text().await?;
296 serde_json::from_str(&content).map_err(Error::from)
297 } else {
298 let content = resp.text().await?;
299 let entity: Option<GetFieldConfigurationSchemeMappingsError> = serde_json::from_str(&content).ok();
300 Err(Error::ResponseError(ResponseContent { status, content, entity }))
301 }
302}
303
304pub async fn get_field_configuration_scheme_project_mapping(configuration: &configuration::Configuration, project_id: Vec<i64>, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanFieldConfigurationSchemeProjects, Error<GetFieldConfigurationSchemeProjectMappingError>> {
306 let p_project_id = project_id;
308 let p_start_at = start_at;
309 let p_max_results = max_results;
310
311 let uri_str = format!("{}/rest/api/2/fieldconfigurationscheme/project", configuration.base_path);
312 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
313
314 if let Some(ref param_value) = p_start_at {
315 req_builder = req_builder.query(&[("startAt", ¶m_value.to_string())]);
316 }
317 if let Some(ref param_value) = p_max_results {
318 req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
319 }
320 req_builder = match "multi" {
321 "multi" => req_builder.query(&p_project_id.into_iter().map(|p| ("projectId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
322 _ => req_builder.query(&[("projectId", &p_project_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
323 };
324 if let Some(ref user_agent) = configuration.user_agent {
325 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
326 }
327 if let Some(ref token) = configuration.oauth_access_token {
328 req_builder = req_builder.bearer_auth(token.to_owned());
329 };
330 if let Some(ref auth_conf) = configuration.basic_auth {
331 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
332 };
333
334 let req = req_builder.build()?;
335 let resp = configuration.client.execute(req).await?;
336
337 let status = resp.status();
338
339 if !status.is_client_error() && !status.is_server_error() {
340 let content = resp.text().await?;
341 serde_json::from_str(&content).map_err(Error::from)
342 } else {
343 let content = resp.text().await?;
344 let entity: Option<GetFieldConfigurationSchemeProjectMappingError> = serde_json::from_str(&content).ok();
345 Err(Error::ResponseError(ResponseContent { status, content, entity }))
346 }
347}
348