1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17#[derive(Clone, Debug, Default)]
19pub struct CreateProjectRoleParams {
20 pub create_update_role_request_bean: crate::models::CreateUpdateRoleRequestBean
21}
22
23#[derive(Clone, Debug, Default)]
25pub struct DeleteProjectRoleParams {
26 pub id: i64,
28 pub swap: Option<i64>
30}
31
32#[derive(Clone, Debug, Default)]
34pub struct FullyUpdateProjectRoleParams {
35 pub id: i64,
37 pub create_update_role_request_bean: crate::models::CreateUpdateRoleRequestBean
38}
39
40#[derive(Clone, Debug, Default)]
42pub struct GetProjectRoleParams {
43 pub project_id_or_key: String,
45 pub id: i64,
47 pub exclude_inactive_users: Option<bool>
49}
50
51#[derive(Clone, Debug, Default)]
53pub struct GetProjectRoleByIdParams {
54 pub id: i64
56}
57
58#[derive(Clone, Debug, Default)]
60pub struct GetProjectRoleDetailsParams {
61 pub project_id_or_key: String,
63 pub current_member: Option<bool>,
65 pub exclude_connect_addons: Option<bool>
66}
67
68#[derive(Clone, Debug, Default)]
70pub struct GetProjectRolesParams {
71 pub project_id_or_key: String
73}
74
75#[derive(Clone, Debug, Default)]
77pub struct PartialUpdateProjectRoleParams {
78 pub id: i64,
80 pub create_update_role_request_bean: crate::models::CreateUpdateRoleRequestBean
81}
82
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum CreateProjectRoleError {
88 Status400(),
89 Status401(),
90 Status403(),
91 Status409(),
92 UnknownValue(serde_json::Value),
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum DeleteProjectRoleError {
99 Status400(),
100 Status401(),
101 Status403(),
102 Status404(),
103 Status409(),
104 UnknownValue(serde_json::Value),
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum FullyUpdateProjectRoleError {
111 Status400(),
112 Status401(),
113 Status403(),
114 Status404(),
115 UnknownValue(serde_json::Value),
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum GetAllProjectRolesError {
122 Status401(),
123 Status403(),
124 UnknownValue(serde_json::Value),
125}
126
127#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum GetProjectRoleError {
131 Status400(),
132 Status401(),
133 Status404(),
134 UnknownValue(serde_json::Value),
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum GetProjectRoleByIdError {
141 Status401(),
142 Status403(),
143 Status404(),
144 UnknownValue(serde_json::Value),
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum GetProjectRoleDetailsError {
151 Status401(),
152 Status404(),
153 UnknownValue(serde_json::Value),
154}
155
156#[derive(Debug, Clone, Serialize, Deserialize)]
158#[serde(untagged)]
159pub enum GetProjectRolesError {
160 Status401(),
161 Status404(),
162 UnknownValue(serde_json::Value),
163}
164
165#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum PartialUpdateProjectRoleError {
169 Status400(),
170 Status401(),
171 Status403(),
172 Status404(),
173 UnknownValue(serde_json::Value),
174}
175
176
177pub async fn create_project_role(configuration: &configuration::Configuration, params: CreateProjectRoleParams) -> Result<crate::models::ProjectRole, Error<CreateProjectRoleError>> {
179 let local_var_configuration = configuration;
180
181 let create_update_role_request_bean = params.create_update_role_request_bean;
183
184
185 let local_var_client = &local_var_configuration.client;
186
187 let local_var_uri_str = format!("{}/rest/api/2/role", local_var_configuration.base_path);
188 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
189
190 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
191 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
192 }
193 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
194 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
195 };
196 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
197 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
198 };
199 local_var_req_builder = local_var_req_builder.json(&create_update_role_request_bean);
200
201 let local_var_req = local_var_req_builder.build()?;
202 let local_var_resp = local_var_client.execute(local_var_req).await?;
203
204 let local_var_status = local_var_resp.status();
205 let local_var_content = local_var_resp.text().await?;
206
207 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
208 serde_json::from_str(&local_var_content).map_err(Error::from)
209 } else {
210 let local_var_entity: Option<CreateProjectRoleError> = serde_json::from_str(&local_var_content).ok();
211 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
212 Err(Error::ResponseError(local_var_error))
213 }
214}
215
216pub async fn delete_project_role(configuration: &configuration::Configuration, params: DeleteProjectRoleParams) -> Result<(), Error<DeleteProjectRoleError>> {
218 let local_var_configuration = configuration;
219
220 let id = params.id;
222 let swap = params.swap;
223
224
225 let local_var_client = &local_var_configuration.client;
226
227 let local_var_uri_str = format!("{}/rest/api/2/role/{id}", local_var_configuration.base_path, id=id);
228 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
229
230 if let Some(ref local_var_str) = swap {
231 local_var_req_builder = local_var_req_builder.query(&[("swap", &local_var_str.to_string())]);
232 }
233 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
234 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
235 }
236 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
237 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
238 };
239 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
240 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
241 };
242
243 let local_var_req = local_var_req_builder.build()?;
244 let local_var_resp = local_var_client.execute(local_var_req).await?;
245
246 let local_var_status = local_var_resp.status();
247 let local_var_content = local_var_resp.text().await?;
248
249 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
250 Ok(())
251 } else {
252 let local_var_entity: Option<DeleteProjectRoleError> = serde_json::from_str(&local_var_content).ok();
253 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
254 Err(Error::ResponseError(local_var_error))
255 }
256}
257
258pub async fn fully_update_project_role(configuration: &configuration::Configuration, params: FullyUpdateProjectRoleParams) -> Result<crate::models::ProjectRole, Error<FullyUpdateProjectRoleError>> {
260 let local_var_configuration = configuration;
261
262 let id = params.id;
264 let create_update_role_request_bean = params.create_update_role_request_bean;
265
266
267 let local_var_client = &local_var_configuration.client;
268
269 let local_var_uri_str = format!("{}/rest/api/2/role/{id}", local_var_configuration.base_path, id=id);
270 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
271
272 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
273 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
274 }
275 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
276 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
277 };
278 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
279 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
280 };
281 local_var_req_builder = local_var_req_builder.json(&create_update_role_request_bean);
282
283 let local_var_req = local_var_req_builder.build()?;
284 let local_var_resp = local_var_client.execute(local_var_req).await?;
285
286 let local_var_status = local_var_resp.status();
287 let local_var_content = local_var_resp.text().await?;
288
289 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
290 serde_json::from_str(&local_var_content).map_err(Error::from)
291 } else {
292 let local_var_entity: Option<FullyUpdateProjectRoleError> = serde_json::from_str(&local_var_content).ok();
293 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
294 Err(Error::ResponseError(local_var_error))
295 }
296}
297
298pub async fn get_all_project_roles(configuration: &configuration::Configuration) -> Result<Vec<crate::models::ProjectRole>, Error<GetAllProjectRolesError>> {
300 let local_var_configuration = configuration;
301
302 let local_var_client = &local_var_configuration.client;
306
307 let local_var_uri_str = format!("{}/rest/api/2/role", local_var_configuration.base_path);
308 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
309
310 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
311 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
312 }
313 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
314 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
315 };
316 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
317 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
318 };
319
320 let local_var_req = local_var_req_builder.build()?;
321 let local_var_resp = local_var_client.execute(local_var_req).await?;
322
323 let local_var_status = local_var_resp.status();
324 let local_var_content = local_var_resp.text().await?;
325
326 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
327 serde_json::from_str(&local_var_content).map_err(Error::from)
328 } else {
329 let local_var_entity: Option<GetAllProjectRolesError> = serde_json::from_str(&local_var_content).ok();
330 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
331 Err(Error::ResponseError(local_var_error))
332 }
333}
334
335pub async fn get_project_role(configuration: &configuration::Configuration, params: GetProjectRoleParams) -> Result<crate::models::ProjectRole, Error<GetProjectRoleError>> {
337 let local_var_configuration = configuration;
338
339 let project_id_or_key = params.project_id_or_key;
341 let id = params.id;
342 let exclude_inactive_users = params.exclude_inactive_users;
343
344
345 let local_var_client = &local_var_configuration.client;
346
347 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/role/{id}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key), id=id);
348 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
349
350 if let Some(ref local_var_str) = exclude_inactive_users {
351 local_var_req_builder = local_var_req_builder.query(&[("excludeInactiveUsers", &local_var_str.to_string())]);
352 }
353 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
354 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
355 }
356 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
357 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
358 };
359 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
360 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
361 };
362
363 let local_var_req = local_var_req_builder.build()?;
364 let local_var_resp = local_var_client.execute(local_var_req).await?;
365
366 let local_var_status = local_var_resp.status();
367 let local_var_content = local_var_resp.text().await?;
368
369 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
370 serde_json::from_str(&local_var_content).map_err(Error::from)
371 } else {
372 let local_var_entity: Option<GetProjectRoleError> = serde_json::from_str(&local_var_content).ok();
373 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
374 Err(Error::ResponseError(local_var_error))
375 }
376}
377
378pub async fn get_project_role_by_id(configuration: &configuration::Configuration, params: GetProjectRoleByIdParams) -> Result<crate::models::ProjectRole, Error<GetProjectRoleByIdError>> {
380 let local_var_configuration = configuration;
381
382 let id = params.id;
384
385
386 let local_var_client = &local_var_configuration.client;
387
388 let local_var_uri_str = format!("{}/rest/api/2/role/{id}", local_var_configuration.base_path, id=id);
389 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
390
391 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
392 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
393 }
394 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
395 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
396 };
397 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
398 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
399 };
400
401 let local_var_req = local_var_req_builder.build()?;
402 let local_var_resp = local_var_client.execute(local_var_req).await?;
403
404 let local_var_status = local_var_resp.status();
405 let local_var_content = local_var_resp.text().await?;
406
407 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
408 serde_json::from_str(&local_var_content).map_err(Error::from)
409 } else {
410 let local_var_entity: Option<GetProjectRoleByIdError> = serde_json::from_str(&local_var_content).ok();
411 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
412 Err(Error::ResponseError(local_var_error))
413 }
414}
415
416pub async fn get_project_role_details(configuration: &configuration::Configuration, params: GetProjectRoleDetailsParams) -> Result<Vec<crate::models::ProjectRoleDetails>, Error<GetProjectRoleDetailsError>> {
418 let local_var_configuration = configuration;
419
420 let project_id_or_key = params.project_id_or_key;
422 let current_member = params.current_member;
423 let exclude_connect_addons = params.exclude_connect_addons;
424
425
426 let local_var_client = &local_var_configuration.client;
427
428 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/roledetails", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
429 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
430
431 if let Some(ref local_var_str) = current_member {
432 local_var_req_builder = local_var_req_builder.query(&[("currentMember", &local_var_str.to_string())]);
433 }
434 if let Some(ref local_var_str) = exclude_connect_addons {
435 local_var_req_builder = local_var_req_builder.query(&[("excludeConnectAddons", &local_var_str.to_string())]);
436 }
437 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
438 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
439 }
440 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
441 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
442 };
443 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
444 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
445 };
446
447 let local_var_req = local_var_req_builder.build()?;
448 let local_var_resp = local_var_client.execute(local_var_req).await?;
449
450 let local_var_status = local_var_resp.status();
451 let local_var_content = local_var_resp.text().await?;
452
453 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
454 serde_json::from_str(&local_var_content).map_err(Error::from)
455 } else {
456 let local_var_entity: Option<GetProjectRoleDetailsError> = serde_json::from_str(&local_var_content).ok();
457 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
458 Err(Error::ResponseError(local_var_error))
459 }
460}
461
462pub async fn get_project_roles(configuration: &configuration::Configuration, params: GetProjectRolesParams) -> Result<::std::collections::HashMap<String, String>, Error<GetProjectRolesError>> {
464 let local_var_configuration = configuration;
465
466 let project_id_or_key = params.project_id_or_key;
468
469
470 let local_var_client = &local_var_configuration.client;
471
472 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/role", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
473 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
474
475 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
476 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
477 }
478 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
479 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
480 };
481 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
482 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
483 };
484
485 let local_var_req = local_var_req_builder.build()?;
486 let local_var_resp = local_var_client.execute(local_var_req).await?;
487
488 let local_var_status = local_var_resp.status();
489 let local_var_content = local_var_resp.text().await?;
490
491 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
492 serde_json::from_str(&local_var_content).map_err(Error::from)
493 } else {
494 let local_var_entity: Option<GetProjectRolesError> = serde_json::from_str(&local_var_content).ok();
495 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
496 Err(Error::ResponseError(local_var_error))
497 }
498}
499
500pub async fn partial_update_project_role(configuration: &configuration::Configuration, params: PartialUpdateProjectRoleParams) -> Result<crate::models::ProjectRole, Error<PartialUpdateProjectRoleError>> {
502 let local_var_configuration = configuration;
503
504 let id = params.id;
506 let create_update_role_request_bean = params.create_update_role_request_bean;
507
508
509 let local_var_client = &local_var_configuration.client;
510
511 let local_var_uri_str = format!("{}/rest/api/2/role/{id}", local_var_configuration.base_path, id=id);
512 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
513
514 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
515 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
516 }
517 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
518 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
519 };
520 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
521 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
522 };
523 local_var_req_builder = local_var_req_builder.json(&create_update_role_request_bean);
524
525 let local_var_req = local_var_req_builder.build()?;
526 let local_var_resp = local_var_client.execute(local_var_req).await?;
527
528 let local_var_status = local_var_resp.status();
529 let local_var_content = local_var_resp.text().await?;
530
531 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
532 serde_json::from_str(&local_var_content).map_err(Error::from)
533 } else {
534 let local_var_entity: Option<PartialUpdateProjectRoleError> = serde_json::from_str(&local_var_content).ok();
535 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
536 Err(Error::ResponseError(local_var_error))
537 }
538}
539