1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17#[derive(Clone, Debug, Default)]
19pub struct ArchiveProjectParams {
20 pub project_id_or_key: String
22}
23
24#[derive(Clone, Debug, Default)]
26pub struct CreateProjectParams {
27 pub create_project_details: crate::models::CreateProjectDetails
29}
30
31#[derive(Clone, Debug, Default)]
33pub struct DeleteProjectParams {
34 pub project_id_or_key: String,
36 pub enable_undo: Option<bool>
38}
39
40#[derive(Clone, Debug, Default)]
42pub struct DeleteProjectAsynchronouslyParams {
43 pub project_id_or_key: String
45}
46
47#[derive(Clone, Debug, Default)]
49pub struct GetAllProjectsParams {
50 pub expand: Option<String>,
52 pub recent: Option<i32>,
54 pub properties: Option<Vec<String>>
56}
57
58#[derive(Clone, Debug, Default)]
60pub struct GetAllStatusesParams {
61 pub project_id_or_key: String
63}
64
65#[derive(Clone, Debug, Default)]
67pub struct GetHierarchyParams {
68 pub project_id: i64
70}
71
72#[derive(Clone, Debug, Default)]
74pub struct GetNotificationSchemeForProjectParams {
75 pub project_key_or_id: String,
77 pub expand: Option<String>
79}
80
81#[derive(Clone, Debug, Default)]
83pub struct GetProjectParams {
84 pub project_id_or_key: String,
86 pub expand: Option<String>,
88 pub properties: Option<Vec<String>>
90}
91
92#[derive(Clone, Debug, Default)]
94pub struct GetRecentParams {
95 pub expand: Option<String>,
97 pub properties: Option<Vec<serde_json::Value>>
99}
100
101#[derive(Clone, Debug, Default)]
103pub struct RestoreParams {
104 pub project_id_or_key: String
106}
107
108#[derive(Clone, Debug, Default)]
110pub struct SearchProjectsParams {
111 pub start_at: Option<i64>,
113 pub max_results: Option<i32>,
115 pub order_by: Option<String>,
117 pub id: Option<Vec<i64>>,
119 pub keys: Option<Vec<String>>,
121 pub query: Option<String>,
123 pub type_key: Option<String>,
125 pub category_id: Option<i64>,
127 pub action: Option<String>,
129 pub expand: Option<String>,
131 pub status: Option<Vec<String>>,
133 pub properties: Option<Vec<serde_json::Value>>,
135 pub property_query: Option<String>
137}
138
139#[derive(Clone, Debug, Default)]
141pub struct UpdateProjectParams {
142 pub project_id_or_key: String,
144 pub update_project_details: crate::models::UpdateProjectDetails,
146 pub expand: Option<String>
148}
149
150#[derive(Clone, Debug, Default)]
152pub struct UpdateProjectTypeParams {
153 pub project_id_or_key: String,
155 pub new_project_type_key: String
157}
158
159
160#[derive(Debug, Clone, Serialize, Deserialize)]
162#[serde(untagged)]
163pub enum ArchiveProjectError {
164 Status400(),
165 Status401(),
166 Status403(),
167 Status404(),
168 UnknownValue(serde_json::Value),
169}
170
171#[derive(Debug, Clone, Serialize, Deserialize)]
173#[serde(untagged)]
174pub enum CreateProjectError {
175 Status400(),
176 Status401(),
177 Status403(),
178 UnknownValue(serde_json::Value),
179}
180
181#[derive(Debug, Clone, Serialize, Deserialize)]
183#[serde(untagged)]
184pub enum DeleteProjectError {
185 Status401(),
186 Status404(),
187 UnknownValue(serde_json::Value),
188}
189
190#[derive(Debug, Clone, Serialize, Deserialize)]
192#[serde(untagged)]
193pub enum DeleteProjectAsynchronouslyError {
194 Status400(),
195 Status401(),
196 Status404(),
197 UnknownValue(serde_json::Value),
198}
199
200#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum GetAllProjectsError {
204 Status401(),
205 UnknownValue(serde_json::Value),
206}
207
208#[derive(Debug, Clone, Serialize, Deserialize)]
210#[serde(untagged)]
211pub enum GetAllStatusesError {
212 Status401(),
213 Status404(),
214 UnknownValue(serde_json::Value),
215}
216
217#[derive(Debug, Clone, Serialize, Deserialize)]
219#[serde(untagged)]
220pub enum GetHierarchyError {
221 Status400(),
222 Status401(),
223 Status404(),
224 UnknownValue(serde_json::Value),
225}
226
227#[derive(Debug, Clone, Serialize, Deserialize)]
229#[serde(untagged)]
230pub enum GetNotificationSchemeForProjectError {
231 Status400(),
232 Status401(),
233 Status404(),
234 UnknownValue(serde_json::Value),
235}
236
237#[derive(Debug, Clone, Serialize, Deserialize)]
239#[serde(untagged)]
240pub enum GetProjectError {
241 Status401(),
242 Status404(),
243 UnknownValue(serde_json::Value),
244}
245
246#[derive(Debug, Clone, Serialize, Deserialize)]
248#[serde(untagged)]
249pub enum GetRecentError {
250 Status400(),
251 Status401(),
252 UnknownValue(serde_json::Value),
253}
254
255#[derive(Debug, Clone, Serialize, Deserialize)]
257#[serde(untagged)]
258pub enum RestoreError {
259 Status400(),
260 Status401(),
261 Status404(),
262 UnknownValue(serde_json::Value),
263}
264
265#[derive(Debug, Clone, Serialize, Deserialize)]
267#[serde(untagged)]
268pub enum SearchProjectsError {
269 Status400(),
270 Status401(),
271 Status404(),
272 UnknownValue(serde_json::Value),
273}
274
275#[derive(Debug, Clone, Serialize, Deserialize)]
277#[serde(untagged)]
278pub enum UpdateProjectError {
279 Status400(),
280 Status401(),
281 Status403(),
282 Status404(),
283 UnknownValue(serde_json::Value),
284}
285
286#[derive(Debug, Clone, Serialize, Deserialize)]
288#[serde(untagged)]
289pub enum UpdateProjectTypeError {
290 Status400(),
291 Status401(),
292 Status404(),
293 UnknownValue(serde_json::Value),
294}
295
296
297pub async fn archive_project(configuration: &configuration::Configuration, params: ArchiveProjectParams) -> Result<serde_json::Value, Error<ArchiveProjectError>> {
299 let local_var_configuration = configuration;
300
301 let project_id_or_key = params.project_id_or_key;
303
304
305 let local_var_client = &local_var_configuration.client;
306
307 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/archive", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
308 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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<ArchiveProjectError> = 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 create_project(configuration: &configuration::Configuration, params: CreateProjectParams) -> Result<crate::models::ProjectIdentifiers, Error<CreateProjectError>> {
337 let local_var_configuration = configuration;
338
339 let create_project_details = params.create_project_details;
341
342
343 let local_var_client = &local_var_configuration.client;
344
345 let local_var_uri_str = format!("{}/rest/api/2/project", local_var_configuration.base_path);
346 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
347
348 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
349 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
350 }
351 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
352 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
353 };
354 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
355 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
356 };
357 local_var_req_builder = local_var_req_builder.json(&create_project_details);
358
359 let local_var_req = local_var_req_builder.build()?;
360 let local_var_resp = local_var_client.execute(local_var_req).await?;
361
362 let local_var_status = local_var_resp.status();
363 let local_var_content = local_var_resp.text().await?;
364
365 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
366 serde_json::from_str(&local_var_content).map_err(Error::from)
367 } else {
368 let local_var_entity: Option<CreateProjectError> = serde_json::from_str(&local_var_content).ok();
369 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
370 Err(Error::ResponseError(local_var_error))
371 }
372}
373
374pub async fn delete_project(configuration: &configuration::Configuration, params: DeleteProjectParams) -> Result<(), Error<DeleteProjectError>> {
376 let local_var_configuration = configuration;
377
378 let project_id_or_key = params.project_id_or_key;
380 let enable_undo = params.enable_undo;
381
382
383 let local_var_client = &local_var_configuration.client;
384
385 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
386 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
387
388 if let Some(ref local_var_str) = enable_undo {
389 local_var_req_builder = local_var_req_builder.query(&[("enableUndo", &local_var_str.to_string())]);
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 Ok(())
409 } else {
410 let local_var_entity: Option<DeleteProjectError> = 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 delete_project_asynchronously(configuration: &configuration::Configuration, params: DeleteProjectAsynchronouslyParams) -> Result<(), Error<DeleteProjectAsynchronouslyError>> {
418 let local_var_configuration = configuration;
419
420 let project_id_or_key = params.project_id_or_key;
422
423
424 let local_var_client = &local_var_configuration.client;
425
426 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/delete", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
427 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
428
429 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
430 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
431 }
432 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
433 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
434 };
435 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
436 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
437 };
438
439 let local_var_req = local_var_req_builder.build()?;
440 let local_var_resp = local_var_client.execute(local_var_req).await?;
441
442 let local_var_status = local_var_resp.status();
443 let local_var_content = local_var_resp.text().await?;
444
445 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
446 Ok(())
447 } else {
448 let local_var_entity: Option<DeleteProjectAsynchronouslyError> = serde_json::from_str(&local_var_content).ok();
449 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
450 Err(Error::ResponseError(local_var_error))
451 }
452}
453
454pub async fn get_all_projects(configuration: &configuration::Configuration, params: GetAllProjectsParams) -> Result<Vec<crate::models::Project>, Error<GetAllProjectsError>> {
456 let local_var_configuration = configuration;
457
458 let expand = params.expand;
460 let recent = params.recent;
461 let properties = params.properties;
462
463
464 let local_var_client = &local_var_configuration.client;
465
466 let local_var_uri_str = format!("{}/rest/api/2/project", local_var_configuration.base_path);
467 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
468
469 if let Some(ref local_var_str) = expand {
470 local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
471 }
472 if let Some(ref local_var_str) = recent {
473 local_var_req_builder = local_var_req_builder.query(&[("recent", &local_var_str.to_string())]);
474 }
475 if let Some(ref local_var_str) = properties {
476 local_var_req_builder = match "multi" {
477 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("properties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
478 _ => local_var_req_builder.query(&[("properties", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
479 };
480 }
481 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
482 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
483 }
484 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
485 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
486 };
487 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
488 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
489 };
490
491 let local_var_req = local_var_req_builder.build()?;
492 let local_var_resp = local_var_client.execute(local_var_req).await?;
493
494 let local_var_status = local_var_resp.status();
495 let local_var_content = local_var_resp.text().await?;
496
497 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
498 serde_json::from_str(&local_var_content).map_err(Error::from)
499 } else {
500 let local_var_entity: Option<GetAllProjectsError> = serde_json::from_str(&local_var_content).ok();
501 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
502 Err(Error::ResponseError(local_var_error))
503 }
504}
505
506pub async fn get_all_statuses(configuration: &configuration::Configuration, params: GetAllStatusesParams) -> Result<Vec<crate::models::IssueTypeWithStatus>, Error<GetAllStatusesError>> {
508 let local_var_configuration = configuration;
509
510 let project_id_or_key = params.project_id_or_key;
512
513
514 let local_var_client = &local_var_configuration.client;
515
516 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/statuses", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
517 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
518
519 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
520 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
521 }
522 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
523 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
524 };
525 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
526 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
527 };
528
529 let local_var_req = local_var_req_builder.build()?;
530 let local_var_resp = local_var_client.execute(local_var_req).await?;
531
532 let local_var_status = local_var_resp.status();
533 let local_var_content = local_var_resp.text().await?;
534
535 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
536 serde_json::from_str(&local_var_content).map_err(Error::from)
537 } else {
538 let local_var_entity: Option<GetAllStatusesError> = serde_json::from_str(&local_var_content).ok();
539 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
540 Err(Error::ResponseError(local_var_error))
541 }
542}
543
544pub async fn get_hierarchy(configuration: &configuration::Configuration, params: GetHierarchyParams) -> Result<crate::models::ProjectIssueTypeHierarchy, Error<GetHierarchyError>> {
546 let local_var_configuration = configuration;
547
548 let project_id = params.project_id;
550
551
552 let local_var_client = &local_var_configuration.client;
553
554 let local_var_uri_str = format!("{}/rest/api/2/project/{projectId}/hierarchy", local_var_configuration.base_path, projectId=project_id);
555 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
556
557 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
558 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
559 }
560 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
561 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
562 };
563 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
564 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
565 };
566
567 let local_var_req = local_var_req_builder.build()?;
568 let local_var_resp = local_var_client.execute(local_var_req).await?;
569
570 let local_var_status = local_var_resp.status();
571 let local_var_content = local_var_resp.text().await?;
572
573 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
574 serde_json::from_str(&local_var_content).map_err(Error::from)
575 } else {
576 let local_var_entity: Option<GetHierarchyError> = serde_json::from_str(&local_var_content).ok();
577 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
578 Err(Error::ResponseError(local_var_error))
579 }
580}
581
582pub async fn get_notification_scheme_for_project(configuration: &configuration::Configuration, params: GetNotificationSchemeForProjectParams) -> Result<crate::models::NotificationScheme, Error<GetNotificationSchemeForProjectError>> {
584 let local_var_configuration = configuration;
585
586 let project_key_or_id = params.project_key_or_id;
588 let expand = params.expand;
589
590
591 let local_var_client = &local_var_configuration.client;
592
593 let local_var_uri_str = format!("{}/rest/api/2/project/{projectKeyOrId}/notificationscheme", local_var_configuration.base_path, projectKeyOrId=crate::apis::urlencode(project_key_or_id));
594 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
595
596 if let Some(ref local_var_str) = expand {
597 local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
598 }
599 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
600 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
601 }
602 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
603 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
604 };
605 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
606 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
607 };
608
609 let local_var_req = local_var_req_builder.build()?;
610 let local_var_resp = local_var_client.execute(local_var_req).await?;
611
612 let local_var_status = local_var_resp.status();
613 let local_var_content = local_var_resp.text().await?;
614
615 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
616 serde_json::from_str(&local_var_content).map_err(Error::from)
617 } else {
618 let local_var_entity: Option<GetNotificationSchemeForProjectError> = serde_json::from_str(&local_var_content).ok();
619 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
620 Err(Error::ResponseError(local_var_error))
621 }
622}
623
624pub async fn get_project(configuration: &configuration::Configuration, params: GetProjectParams) -> Result<crate::models::Project, Error<GetProjectError>> {
626 let local_var_configuration = configuration;
627
628 let project_id_or_key = params.project_id_or_key;
630 let expand = params.expand;
631 let properties = params.properties;
632
633
634 let local_var_client = &local_var_configuration.client;
635
636 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
637 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
638
639 if let Some(ref local_var_str) = expand {
640 local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
641 }
642 if let Some(ref local_var_str) = properties {
643 local_var_req_builder = match "multi" {
644 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("properties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
645 _ => local_var_req_builder.query(&[("properties", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
646 };
647 }
648 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
649 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
650 }
651 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
652 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
653 };
654 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
655 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
656 };
657
658 let local_var_req = local_var_req_builder.build()?;
659 let local_var_resp = local_var_client.execute(local_var_req).await?;
660
661 let local_var_status = local_var_resp.status();
662 let local_var_content = local_var_resp.text().await?;
663
664 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
665 serde_json::from_str(&local_var_content).map_err(Error::from)
666 } else {
667 let local_var_entity: Option<GetProjectError> = serde_json::from_str(&local_var_content).ok();
668 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
669 Err(Error::ResponseError(local_var_error))
670 }
671}
672
673pub async fn get_recent(configuration: &configuration::Configuration, params: GetRecentParams) -> Result<Vec<crate::models::Project>, Error<GetRecentError>> {
675 let local_var_configuration = configuration;
676
677 let expand = params.expand;
679 let properties = params.properties;
680
681
682 let local_var_client = &local_var_configuration.client;
683
684 let local_var_uri_str = format!("{}/rest/api/2/project/recent", local_var_configuration.base_path);
685 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
686
687 if let Some(ref local_var_str) = expand {
688 local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
689 }
690 if let Some(ref local_var_str) = properties {
691 local_var_req_builder = match "multi" {
692 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("properties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
693 _ => local_var_req_builder.query(&[("properties", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
694 };
695 }
696 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
697 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
698 }
699 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
700 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
701 };
702 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
703 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
704 };
705
706 let local_var_req = local_var_req_builder.build()?;
707 let local_var_resp = local_var_client.execute(local_var_req).await?;
708
709 let local_var_status = local_var_resp.status();
710 let local_var_content = local_var_resp.text().await?;
711
712 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
713 serde_json::from_str(&local_var_content).map_err(Error::from)
714 } else {
715 let local_var_entity: Option<GetRecentError> = serde_json::from_str(&local_var_content).ok();
716 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
717 Err(Error::ResponseError(local_var_error))
718 }
719}
720
721pub async fn restore(configuration: &configuration::Configuration, params: RestoreParams) -> Result<crate::models::Project, Error<RestoreError>> {
723 let local_var_configuration = configuration;
724
725 let project_id_or_key = params.project_id_or_key;
727
728
729 let local_var_client = &local_var_configuration.client;
730
731 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/restore", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
732 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
733
734 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
735 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
736 }
737 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
738 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
739 };
740 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
741 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
742 };
743
744 let local_var_req = local_var_req_builder.build()?;
745 let local_var_resp = local_var_client.execute(local_var_req).await?;
746
747 let local_var_status = local_var_resp.status();
748 let local_var_content = local_var_resp.text().await?;
749
750 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
751 serde_json::from_str(&local_var_content).map_err(Error::from)
752 } else {
753 let local_var_entity: Option<RestoreError> = serde_json::from_str(&local_var_content).ok();
754 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
755 Err(Error::ResponseError(local_var_error))
756 }
757}
758
759pub async fn search_projects(configuration: &configuration::Configuration, params: SearchProjectsParams) -> Result<crate::models::PageBeanProject, Error<SearchProjectsError>> {
761 let local_var_configuration = configuration;
762
763 let start_at = params.start_at;
765 let max_results = params.max_results;
766 let order_by = params.order_by;
767 let id = params.id;
768 let keys = params.keys;
769 let query = params.query;
770 let type_key = params.type_key;
771 let category_id = params.category_id;
772 let action = params.action;
773 let expand = params.expand;
774 let status = params.status;
775 let properties = params.properties;
776 let property_query = params.property_query;
777
778
779 let local_var_client = &local_var_configuration.client;
780
781 let local_var_uri_str = format!("{}/rest/api/2/project/search", local_var_configuration.base_path);
782 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
783
784 if let Some(ref local_var_str) = start_at {
785 local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
786 }
787 if let Some(ref local_var_str) = max_results {
788 local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
789 }
790 if let Some(ref local_var_str) = order_by {
791 local_var_req_builder = local_var_req_builder.query(&[("orderBy", &local_var_str.to_string())]);
792 }
793 if let Some(ref local_var_str) = id {
794 local_var_req_builder = match "multi" {
795 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("id".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
796 _ => local_var_req_builder.query(&[("id", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
797 };
798 }
799 if let Some(ref local_var_str) = keys {
800 local_var_req_builder = match "multi" {
801 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("keys".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
802 _ => local_var_req_builder.query(&[("keys", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
803 };
804 }
805 if let Some(ref local_var_str) = query {
806 local_var_req_builder = local_var_req_builder.query(&[("query", &local_var_str.to_string())]);
807 }
808 if let Some(ref local_var_str) = type_key {
809 local_var_req_builder = local_var_req_builder.query(&[("typeKey", &local_var_str.to_string())]);
810 }
811 if let Some(ref local_var_str) = category_id {
812 local_var_req_builder = local_var_req_builder.query(&[("categoryId", &local_var_str.to_string())]);
813 }
814 if let Some(ref local_var_str) = action {
815 local_var_req_builder = local_var_req_builder.query(&[("action", &local_var_str.to_string())]);
816 }
817 if let Some(ref local_var_str) = expand {
818 local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
819 }
820 if let Some(ref local_var_str) = status {
821 local_var_req_builder = match "multi" {
822 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
823 _ => local_var_req_builder.query(&[("status", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
824 };
825 }
826 if let Some(ref local_var_str) = properties {
827 local_var_req_builder = match "multi" {
828 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("properties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
829 _ => local_var_req_builder.query(&[("properties", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
830 };
831 }
832 if let Some(ref local_var_str) = property_query {
833 local_var_req_builder = local_var_req_builder.query(&[("propertyQuery", &local_var_str.to_string())]);
834 }
835 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
836 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
837 }
838 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
839 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
840 };
841 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
842 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
843 };
844
845 let local_var_req = local_var_req_builder.build()?;
846 let local_var_resp = local_var_client.execute(local_var_req).await?;
847
848 let local_var_status = local_var_resp.status();
849 let local_var_content = local_var_resp.text().await?;
850
851 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
852 serde_json::from_str(&local_var_content).map_err(Error::from)
853 } else {
854 let local_var_entity: Option<SearchProjectsError> = serde_json::from_str(&local_var_content).ok();
855 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
856 Err(Error::ResponseError(local_var_error))
857 }
858}
859
860pub async fn update_project(configuration: &configuration::Configuration, params: UpdateProjectParams) -> Result<crate::models::Project, Error<UpdateProjectError>> {
862 let local_var_configuration = configuration;
863
864 let project_id_or_key = params.project_id_or_key;
866 let update_project_details = params.update_project_details;
867 let expand = params.expand;
868
869
870 let local_var_client = &local_var_configuration.client;
871
872 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
873 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
874
875 if let Some(ref local_var_str) = expand {
876 local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
877 }
878 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
879 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
880 }
881 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
882 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
883 };
884 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
885 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
886 };
887 local_var_req_builder = local_var_req_builder.json(&update_project_details);
888
889 let local_var_req = local_var_req_builder.build()?;
890 let local_var_resp = local_var_client.execute(local_var_req).await?;
891
892 let local_var_status = local_var_resp.status();
893 let local_var_content = local_var_resp.text().await?;
894
895 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
896 serde_json::from_str(&local_var_content).map_err(Error::from)
897 } else {
898 let local_var_entity: Option<UpdateProjectError> = serde_json::from_str(&local_var_content).ok();
899 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
900 Err(Error::ResponseError(local_var_error))
901 }
902}
903
904pub async fn update_project_type(configuration: &configuration::Configuration, params: UpdateProjectTypeParams) -> Result<crate::models::Project, Error<UpdateProjectTypeError>> {
906 let local_var_configuration = configuration;
907
908 let project_id_or_key = params.project_id_or_key;
910 let new_project_type_key = params.new_project_type_key;
911
912
913 let local_var_client = &local_var_configuration.client;
914
915 let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/type/{newProjectTypeKey}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key), newProjectTypeKey=crate::apis::urlencode(new_project_type_key));
916 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
917
918 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
919 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
920 }
921 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
922 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
923 };
924 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
925 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
926 };
927
928 let local_var_req = local_var_req_builder.build()?;
929 let local_var_resp = local_var_client.execute(local_var_req).await?;
930
931 let local_var_status = local_var_resp.status();
932 let local_var_content = local_var_resp.text().await?;
933
934 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
935 serde_json::from_str(&local_var_content).map_err(Error::from)
936 } else {
937 let local_var_entity: Option<UpdateProjectTypeError> = serde_json::from_str(&local_var_content).ok();
938 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
939 Err(Error::ResponseError(local_var_error))
940 }
941}
942