jira_api_v2/apis/
projects_api.rs

1/*
2 * The Jira Cloud platform REST API
3 *
4 * Jira Cloud platform REST API documentation
5 *
6 * The version of the OpenAPI document: 1001.0.0-SNAPSHOT
7 * Contact: ecosystem@atlassian.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`archive_project`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ArchiveProjectError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`create_project`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum CreateProjectError {
33    Status400(),
34    Status401(),
35    Status403(),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`delete_project`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum DeleteProjectError {
43    Status401(),
44    Status404(),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`delete_project_asynchronously`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum DeleteProjectAsynchronouslyError {
52    Status400(),
53    Status401(),
54    Status404(),
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`get_all_projects`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetAllProjectsError {
62    Status401(),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`get_all_statuses`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum GetAllStatusesError {
70    Status401(),
71    Status404(),
72    UnknownValue(serde_json::Value),
73}
74
75/// struct for typed errors of method [`get_hierarchy`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum GetHierarchyError {
79    Status400(),
80    Status401(),
81    Status404(),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`get_notification_scheme_for_project`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum GetNotificationSchemeForProjectError {
89    Status400(),
90    Status401(),
91    Status404(),
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`get_project`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum GetProjectError {
99    Status401(),
100    Status404(),
101    UnknownValue(serde_json::Value),
102}
103
104/// struct for typed errors of method [`restore`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum RestoreError {
108    Status400(),
109    Status401(),
110    Status404(),
111    UnknownValue(serde_json::Value),
112}
113
114/// struct for typed errors of method [`search_projects`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum SearchProjectsError {
118    Status400(),
119    Status401(),
120    Status404(),
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`update_project`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum UpdateProjectError {
128    Status400(),
129    Status401(),
130    Status403(),
131    Status404(),
132    UnknownValue(serde_json::Value),
133}
134
135/// struct for typed errors of method [`update_project_type`]
136#[derive(Debug, Clone, Serialize, Deserialize)]
137#[serde(untagged)]
138pub enum UpdateProjectTypeError {
139    Status400(),
140    Status401(),
141    Status404(),
142    UnknownValue(serde_json::Value),
143}
144
145
146/// Archives a project. Archived projects cannot be deleted. To delete an archived project, restore the project and then delete it. To restore a project, use the Jira UI.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
147pub async fn archive_project(configuration: &configuration::Configuration, project_id_or_key: &str) -> Result<serde_json::Value, Error<ArchiveProjectError>> {
148    // add a prefix to parameters to efficiently prevent name collisions
149    let p_project_id_or_key = project_id_or_key;
150
151    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/archive", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
152    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
153
154    if let Some(ref user_agent) = configuration.user_agent {
155        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156    }
157    if let Some(ref token) = configuration.oauth_access_token {
158        req_builder = req_builder.bearer_auth(token.to_owned());
159    };
160    if let Some(ref auth_conf) = configuration.basic_auth {
161        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
162    };
163
164    let req = req_builder.build()?;
165    let resp = configuration.client.execute(req).await?;
166
167    let status = resp.status();
168
169    if !status.is_client_error() && !status.is_server_error() {
170        let content = resp.text().await?;
171        serde_json::from_str(&content).map_err(Error::from)
172    } else {
173        let content = resp.text().await?;
174        let entity: Option<ArchiveProjectError> = serde_json::from_str(&content).ok();
175        Err(Error::ResponseError(ResponseContent { status, content, entity }))
176    }
177}
178
179/// Creates a project based on a project type template, as shown in the following table:  | Project Type Key | Project Template Key |   |--|--|   | `business` | `com.atlassian.jira-core-project-templates:jira-core-simplified-content-management`, `com.atlassian.jira-core-project-templates:jira-core-simplified-document-approval`, `com.atlassian.jira-core-project-templates:jira-core-simplified-lead-tracking`, `com.atlassian.jira-core-project-templates:jira-core-simplified-process-control`, `com.atlassian.jira-core-project-templates:jira-core-simplified-procurement`, `com.atlassian.jira-core-project-templates:jira-core-simplified-project-management`, `com.atlassian.jira-core-project-templates:jira-core-simplified-recruitment`, `com.atlassian.jira-core-project-templates:jira-core-simplified-task-tracking` |   | `service_desk` | `com.atlassian.servicedesk:simplified-it-service-desk`, `com.atlassian.servicedesk:simplified-internal-service-desk`, `com.atlassian.servicedesk:simplified-external-service-desk` |   | `software` | `com.pyxis.greenhopper.jira:gh-simplified-agility-kanban`, `com.pyxis.greenhopper.jira:gh-simplified-agility-scrum`, `com.pyxis.greenhopper.jira:gh-simplified-basic`, `com.pyxis.greenhopper.jira:gh-simplified-kanban-classic`, `com.pyxis.greenhopper.jira:gh-simplified-scrum-classic` |   The project types are available according to the installed Jira features as follows:   *  Jira Core, the default, enables `business` projects.  *  Jira Service Management enables `service_desk` projects.  *  Jira Software enables `software` projects.  To determine which features are installed, go to **Jira settings** > **Apps** > **Manage apps** and review the System Apps list. To add Jira Software or Jira Service Management into a JIRA instance, use **Jira settings** > **Apps** > **Finding new apps**. For more information, see [ Managing add-ons](https://confluence.atlassian.com/x/S31NLg).  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
180pub async fn create_project(configuration: &configuration::Configuration, project_input_bean: models::ProjectInputBean) -> Result<models::ProjectIdentifiers, Error<CreateProjectError>> {
181    // add a prefix to parameters to efficiently prevent name collisions
182    let p_project_input_bean = project_input_bean;
183
184    let uri_str = format!("{}/rest/api/2/project", configuration.base_path);
185    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
186
187    if let Some(ref user_agent) = configuration.user_agent {
188        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
189    }
190    if let Some(ref token) = configuration.oauth_access_token {
191        req_builder = req_builder.bearer_auth(token.to_owned());
192    };
193    if let Some(ref auth_conf) = configuration.basic_auth {
194        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
195    };
196    req_builder = req_builder.json(&p_project_input_bean);
197
198    let req = req_builder.build()?;
199    let resp = configuration.client.execute(req).await?;
200
201    let status = resp.status();
202
203    if !status.is_client_error() && !status.is_server_error() {
204        let content = resp.text().await?;
205        serde_json::from_str(&content).map_err(Error::from)
206    } else {
207        let content = resp.text().await?;
208        let entity: Option<CreateProjectError> = serde_json::from_str(&content).ok();
209        Err(Error::ResponseError(ResponseContent { status, content, entity }))
210    }
211}
212
213/// Deletes a project.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
214pub async fn delete_project(configuration: &configuration::Configuration, project_id_or_key: &str, enable_undo: Option<bool>) -> Result<(), Error<DeleteProjectError>> {
215    // add a prefix to parameters to efficiently prevent name collisions
216    let p_project_id_or_key = project_id_or_key;
217    let p_enable_undo = enable_undo;
218
219    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
220    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
221
222    if let Some(ref param_value) = p_enable_undo {
223        req_builder = req_builder.query(&[("enableUndo", &param_value.to_string())]);
224    }
225    if let Some(ref user_agent) = configuration.user_agent {
226        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
227    }
228    if let Some(ref token) = configuration.oauth_access_token {
229        req_builder = req_builder.bearer_auth(token.to_owned());
230    };
231    if let Some(ref auth_conf) = configuration.basic_auth {
232        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
233    };
234
235    let req = req_builder.build()?;
236    let resp = configuration.client.execute(req).await?;
237
238    let status = resp.status();
239
240    if !status.is_client_error() && !status.is_server_error() {
241        Ok(())
242    } else {
243        let content = resp.text().await?;
244        let entity: Option<DeleteProjectError> = serde_json::from_str(&content).ok();
245        Err(Error::ResponseError(ResponseContent { status, content, entity }))
246    }
247}
248
249/// Deletes a project asynchronously.  This operation is:   *  transactional, that is, if part of the delete fails the project is not deleted.  *  [asynchronous](#async). Follow the `location` link in the response to determine the status of the task and use [Get task](#api-rest-api-2-task-taskId-get) to obtain subsequent updates.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
250pub async fn delete_project_asynchronously(configuration: &configuration::Configuration, project_id_or_key: &str) -> Result<(), Error<DeleteProjectAsynchronouslyError>> {
251    // add a prefix to parameters to efficiently prevent name collisions
252    let p_project_id_or_key = project_id_or_key;
253
254    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/delete", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
255    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
256
257    if let Some(ref user_agent) = configuration.user_agent {
258        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
259    }
260    if let Some(ref token) = configuration.oauth_access_token {
261        req_builder = req_builder.bearer_auth(token.to_owned());
262    };
263    if let Some(ref auth_conf) = configuration.basic_auth {
264        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
265    };
266
267    let req = req_builder.build()?;
268    let resp = configuration.client.execute(req).await?;
269
270    let status = resp.status();
271
272    if !status.is_client_error() && !status.is_server_error() {
273        Ok(())
274    } else {
275        let content = resp.text().await?;
276        let entity: Option<DeleteProjectAsynchronouslyError> = serde_json::from_str(&content).ok();
277        Err(Error::ResponseError(ResponseContent { status, content, entity }))
278    }
279}
280
281/// Returns all projects visible to the user. Deprecated, use [ Get projects paginated](#api-rest-api-2-project-search-get) that supports search and pagination.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** Projects are returned only where the user has *Browse Projects* or *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
282pub async fn get_all_projects(configuration: &configuration::Configuration, expand: Option<&str>, recent: Option<i32>, properties: Option<Vec<String>>) -> Result<Vec<models::Project>, Error<GetAllProjectsError>> {
283    // add a prefix to parameters to efficiently prevent name collisions
284    let p_expand = expand;
285    let p_recent = recent;
286    let p_properties = properties;
287
288    let uri_str = format!("{}/rest/api/2/project", configuration.base_path);
289    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
290
291    if let Some(ref param_value) = p_expand {
292        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
293    }
294    if let Some(ref param_value) = p_recent {
295        req_builder = req_builder.query(&[("recent", &param_value.to_string())]);
296    }
297    if let Some(ref param_value) = p_properties {
298        req_builder = match "multi" {
299            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("properties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
300            _ => req_builder.query(&[("properties", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
301        };
302    }
303    if let Some(ref user_agent) = configuration.user_agent {
304        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
305    }
306    if let Some(ref token) = configuration.oauth_access_token {
307        req_builder = req_builder.bearer_auth(token.to_owned());
308    };
309    if let Some(ref auth_conf) = configuration.basic_auth {
310        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
311    };
312
313    let req = req_builder.build()?;
314    let resp = configuration.client.execute(req).await?;
315
316    let status = resp.status();
317
318    if !status.is_client_error() && !status.is_server_error() {
319        let content = resp.text().await?;
320        serde_json::from_str(&content).map_err(Error::from)
321    } else {
322        let content = resp.text().await?;
323        let entity: Option<GetAllProjectsError> = serde_json::from_str(&content).ok();
324        Err(Error::ResponseError(ResponseContent { status, content, entity }))
325    }
326}
327
328/// Returns the valid statuses for a project. The statuses are grouped by issue type, as each project has a set of valid issue types and each issue type has a set of valid statuses.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
329pub async fn get_all_statuses(configuration: &configuration::Configuration, project_id_or_key: &str) -> Result<Vec<models::IssueTypeWithStatus>, Error<GetAllStatusesError>> {
330    // add a prefix to parameters to efficiently prevent name collisions
331    let p_project_id_or_key = project_id_or_key;
332
333    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/statuses", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
334    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
335
336    if let Some(ref user_agent) = configuration.user_agent {
337        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
338    }
339    if let Some(ref token) = configuration.oauth_access_token {
340        req_builder = req_builder.bearer_auth(token.to_owned());
341    };
342    if let Some(ref auth_conf) = configuration.basic_auth {
343        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
344    };
345
346    let req = req_builder.build()?;
347    let resp = configuration.client.execute(req).await?;
348
349    let status = resp.status();
350
351    if !status.is_client_error() && !status.is_server_error() {
352        let content = resp.text().await?;
353        serde_json::from_str(&content).map_err(Error::from)
354    } else {
355        let content = resp.text().await?;
356        let entity: Option<GetAllStatusesError> = serde_json::from_str(&content).ok();
357        Err(Error::ResponseError(ResponseContent { status, content, entity }))
358    }
359}
360
361/// Get the issue type hierarchy for a next-gen project.  The issue type hierarchy for a project consists of:   *  *Epic* at level 1 (optional).  *  One or more issue types at level 0 such as *Story*, *Task*, or *Bug*. Where the issue type *Epic* is defined, these issue types are used to break down the content of an epic.  *  *Subtask* at level -1 (optional). This issue type enables level 0 issue types to be broken down into components. Issues based on a level -1 issue type must have a parent issue.  **[Permissions](#permissions) required:** *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
362pub async fn get_hierarchy(configuration: &configuration::Configuration, project_id: i64) -> Result<models::ProjectIssueTypeHierarchy, Error<GetHierarchyError>> {
363    // add a prefix to parameters to efficiently prevent name collisions
364    let p_project_id = project_id;
365
366    let uri_str = format!("{}/rest/api/2/project/{projectId}/hierarchy", configuration.base_path, projectId=p_project_id);
367    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
368
369    if let Some(ref user_agent) = configuration.user_agent {
370        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
371    }
372    if let Some(ref token) = configuration.oauth_access_token {
373        req_builder = req_builder.bearer_auth(token.to_owned());
374    };
375    if let Some(ref auth_conf) = configuration.basic_auth {
376        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
377    };
378
379    let req = req_builder.build()?;
380    let resp = configuration.client.execute(req).await?;
381
382    let status = resp.status();
383
384    if !status.is_client_error() && !status.is_server_error() {
385        let content = resp.text().await?;
386        serde_json::from_str(&content).map_err(Error::from)
387    } else {
388        let content = resp.text().await?;
389        let entity: Option<GetHierarchyError> = serde_json::from_str(&content).ok();
390        Err(Error::ResponseError(ResponseContent { status, content, entity }))
391    }
392}
393
394/// Gets a [notification scheme](https://confluence.atlassian.com/x/8YdKLg) associated with the project. See the [Get notification scheme](#api-rest-api-2-notificationscheme-id-get) resource for more information about notification schemes.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg).
395pub async fn get_notification_scheme_for_project(configuration: &configuration::Configuration, project_key_or_id: &str, expand: Option<&str>) -> Result<models::NotificationScheme, Error<GetNotificationSchemeForProjectError>> {
396    // add a prefix to parameters to efficiently prevent name collisions
397    let p_project_key_or_id = project_key_or_id;
398    let p_expand = expand;
399
400    let uri_str = format!("{}/rest/api/2/project/{projectKeyOrId}/notificationscheme", configuration.base_path, projectKeyOrId=crate::apis::urlencode(p_project_key_or_id));
401    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
402
403    if let Some(ref param_value) = p_expand {
404        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
405    }
406    if let Some(ref user_agent) = configuration.user_agent {
407        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
408    }
409    if let Some(ref token) = configuration.oauth_access_token {
410        req_builder = req_builder.bearer_auth(token.to_owned());
411    };
412    if let Some(ref auth_conf) = configuration.basic_auth {
413        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
414    };
415
416    let req = req_builder.build()?;
417    let resp = configuration.client.execute(req).await?;
418
419    let status = resp.status();
420
421    if !status.is_client_error() && !status.is_server_error() {
422        let content = resp.text().await?;
423        serde_json::from_str(&content).map_err(Error::from)
424    } else {
425        let content = resp.text().await?;
426        let entity: Option<GetNotificationSchemeForProjectError> = serde_json::from_str(&content).ok();
427        Err(Error::ResponseError(ResponseContent { status, content, entity }))
428    }
429}
430
431/// Returns the [project details](https://confluence.atlassian.com/x/ahLpNw) for a project.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
432pub async fn get_project(configuration: &configuration::Configuration, project_id_or_key: &str, expand: Option<&str>, properties: Option<Vec<String>>) -> Result<models::Project, Error<GetProjectError>> {
433    // add a prefix to parameters to efficiently prevent name collisions
434    let p_project_id_or_key = project_id_or_key;
435    let p_expand = expand;
436    let p_properties = properties;
437
438    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
439    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
440
441    if let Some(ref param_value) = p_expand {
442        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
443    }
444    if let Some(ref param_value) = p_properties {
445        req_builder = match "multi" {
446            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("properties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
447            _ => req_builder.query(&[("properties", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
448        };
449    }
450    if let Some(ref user_agent) = configuration.user_agent {
451        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
452    }
453    if let Some(ref token) = configuration.oauth_access_token {
454        req_builder = req_builder.bearer_auth(token.to_owned());
455    };
456    if let Some(ref auth_conf) = configuration.basic_auth {
457        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
458    };
459
460    let req = req_builder.build()?;
461    let resp = configuration.client.execute(req).await?;
462
463    let status = resp.status();
464
465    if !status.is_client_error() && !status.is_server_error() {
466        let content = resp.text().await?;
467        serde_json::from_str(&content).map_err(Error::from)
468    } else {
469        let content = resp.text().await?;
470        let entity: Option<GetProjectError> = serde_json::from_str(&content).ok();
471        Err(Error::ResponseError(ResponseContent { status, content, entity }))
472    }
473}
474
475/// Restores a project from the Jira recycle bin.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
476pub async fn restore(configuration: &configuration::Configuration, project_id_or_key: &str) -> Result<models::Project, Error<RestoreError>> {
477    // add a prefix to parameters to efficiently prevent name collisions
478    let p_project_id_or_key = project_id_or_key;
479
480    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/restore", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
481    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
482
483    if let Some(ref user_agent) = configuration.user_agent {
484        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
485    }
486    if let Some(ref token) = configuration.oauth_access_token {
487        req_builder = req_builder.bearer_auth(token.to_owned());
488    };
489    if let Some(ref auth_conf) = configuration.basic_auth {
490        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
491    };
492
493    let req = req_builder.build()?;
494    let resp = configuration.client.execute(req).await?;
495
496    let status = resp.status();
497
498    if !status.is_client_error() && !status.is_server_error() {
499        let content = resp.text().await?;
500        serde_json::from_str(&content).map_err(Error::from)
501    } else {
502        let content = resp.text().await?;
503        let entity: Option<RestoreError> = serde_json::from_str(&content).ok();
504        Err(Error::ResponseError(ResponseContent { status, content, entity }))
505    }
506}
507
508/// Returns a [paginated](#pagination) list of projects visible to the user.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** Projects are returned only where the user has one of:   *  *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.  *  *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.  *  *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
509pub async fn search_projects(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, order_by: Option<&str>, query: Option<&str>, type_key: Option<&str>, category_id: Option<i64>, action: Option<&str>, expand: Option<&str>, status: Option<Vec<String>>, properties: Option<Vec<serde_json::Value>>, property_query: Option<&str>) -> Result<models::PageBeanProject, Error<SearchProjectsError>> {
510    // add a prefix to parameters to efficiently prevent name collisions
511    let p_start_at = start_at;
512    let p_max_results = max_results;
513    let p_order_by = order_by;
514    let p_query = query;
515    let p_type_key = type_key;
516    let p_category_id = category_id;
517    let p_action = action;
518    let p_expand = expand;
519    let p_status = status;
520    let p_properties = properties;
521    let p_property_query = property_query;
522
523    let uri_str = format!("{}/rest/api/2/project/search", configuration.base_path);
524    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
525
526    if let Some(ref param_value) = p_start_at {
527        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
528    }
529    if let Some(ref param_value) = p_max_results {
530        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
531    }
532    if let Some(ref param_value) = p_order_by {
533        req_builder = req_builder.query(&[("orderBy", &param_value.to_string())]);
534    }
535    if let Some(ref param_value) = p_query {
536        req_builder = req_builder.query(&[("query", &param_value.to_string())]);
537    }
538    if let Some(ref param_value) = p_type_key {
539        req_builder = req_builder.query(&[("typeKey", &param_value.to_string())]);
540    }
541    if let Some(ref param_value) = p_category_id {
542        req_builder = req_builder.query(&[("categoryId", &param_value.to_string())]);
543    }
544    if let Some(ref param_value) = p_action {
545        req_builder = req_builder.query(&[("action", &param_value.to_string())]);
546    }
547    if let Some(ref param_value) = p_expand {
548        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
549    }
550    if let Some(ref param_value) = p_status {
551        req_builder = match "multi" {
552            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
553            _ => req_builder.query(&[("status", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
554        };
555    }
556    if let Some(ref param_value) = p_properties {
557        req_builder = match "multi" {
558            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("properties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
559            _ => req_builder.query(&[("properties", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
560        };
561    }
562    if let Some(ref param_value) = p_property_query {
563        req_builder = req_builder.query(&[("propertyQuery", &param_value.to_string())]);
564    }
565    if let Some(ref user_agent) = configuration.user_agent {
566        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
567    }
568    if let Some(ref token) = configuration.oauth_access_token {
569        req_builder = req_builder.bearer_auth(token.to_owned());
570    };
571    if let Some(ref auth_conf) = configuration.basic_auth {
572        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
573    };
574
575    let req = req_builder.build()?;
576    let resp = configuration.client.execute(req).await?;
577
578    let status = resp.status();
579
580    if !status.is_client_error() && !status.is_server_error() {
581        let content = resp.text().await?;
582        serde_json::from_str(&content).map_err(Error::from)
583    } else {
584        let content = resp.text().await?;
585        let entity: Option<SearchProjectsError> = serde_json::from_str(&content).ok();
586        Err(Error::ResponseError(ResponseContent { status, content, entity }))
587    }
588}
589
590/// Updates the [project details](https://confluence.atlassian.com/x/ahLpNw) of a project.  All parameters are optional in the body of the request.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
591pub async fn update_project(configuration: &configuration::Configuration, project_id_or_key: &str, project_input_bean: models::ProjectInputBean, expand: Option<&str>) -> Result<models::Project, Error<UpdateProjectError>> {
592    // add a prefix to parameters to efficiently prevent name collisions
593    let p_project_id_or_key = project_id_or_key;
594    let p_project_input_bean = project_input_bean;
595    let p_expand = expand;
596
597    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
598    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
599
600    if let Some(ref param_value) = p_expand {
601        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
602    }
603    if let Some(ref user_agent) = configuration.user_agent {
604        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
605    }
606    if let Some(ref token) = configuration.oauth_access_token {
607        req_builder = req_builder.bearer_auth(token.to_owned());
608    };
609    if let Some(ref auth_conf) = configuration.basic_auth {
610        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
611    };
612    req_builder = req_builder.json(&p_project_input_bean);
613
614    let req = req_builder.build()?;
615    let resp = configuration.client.execute(req).await?;
616
617    let status = resp.status();
618
619    if !status.is_client_error() && !status.is_server_error() {
620        let content = resp.text().await?;
621        serde_json::from_str(&content).map_err(Error::from)
622    } else {
623        let content = resp.text().await?;
624        let entity: Option<UpdateProjectError> = serde_json::from_str(&content).ok();
625        Err(Error::ResponseError(ResponseContent { status, content, entity }))
626    }
627}
628
629/// Deprecated, this feature is no longer supported and no alternatives are available, see [Convert project to a different template or type](https://confluence.atlassian.com/x/yEKeOQ). Updates a [project type](https://confluence.atlassian.com/x/GwiiLQ). The project type can be updated for classic projects only, project type cannot be updated for next-gen projects.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
630pub async fn update_project_type(configuration: &configuration::Configuration, project_id_or_key: &str, new_project_type_key: &str) -> Result<models::Project, Error<UpdateProjectTypeError>> {
631    // add a prefix to parameters to efficiently prevent name collisions
632    let p_project_id_or_key = project_id_or_key;
633    let p_new_project_type_key = new_project_type_key;
634
635    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/type/{newProjectTypeKey}", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key), newProjectTypeKey=crate::apis::urlencode(p_new_project_type_key));
636    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
637
638    if let Some(ref user_agent) = configuration.user_agent {
639        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
640    }
641    if let Some(ref token) = configuration.oauth_access_token {
642        req_builder = req_builder.bearer_auth(token.to_owned());
643    };
644    if let Some(ref auth_conf) = configuration.basic_auth {
645        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
646    };
647
648    let req = req_builder.build()?;
649    let resp = configuration.client.execute(req).await?;
650
651    let status = resp.status();
652
653    if !status.is_client_error() && !status.is_server_error() {
654        let content = resp.text().await?;
655        serde_json::from_str(&content).map_err(Error::from)
656    } else {
657        let content = resp.text().await?;
658        let entity: Option<UpdateProjectTypeError> = serde_json::from_str(&content).ok();
659        Err(Error::ResponseError(ResponseContent { status, content, entity }))
660    }
661}
662