hi_jira2/apis/
project_versions_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;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`create_version`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateVersionParams {
20    pub version: crate::models::Version
21}
22
23/// struct for passing parameters to the method [`delete_and_replace_version`]
24#[derive(Clone, Debug, Default)]
25pub struct DeleteAndReplaceVersionParams {
26    /// The ID of the version.
27    pub id: String,
28    pub delete_and_replace_version_bean: crate::models::DeleteAndReplaceVersionBean
29}
30
31/// struct for passing parameters to the method [`delete_version`]
32#[derive(Clone, Debug, Default)]
33pub struct DeleteVersionParams {
34    /// The ID of the version.
35    pub id: String,
36    /// The ID of the version to update `fixVersion` to when the field contains the deleted version. The replacement version must be in the same project as the version being deleted and cannot be the version being deleted.
37    pub move_fix_issues_to: Option<String>,
38    /// The ID of the version to update `affectedVersion` to when the field contains the deleted version. The replacement version must be in the same project as the version being deleted and cannot be the version being deleted.
39    pub move_affected_issues_to: Option<String>
40}
41
42/// struct for passing parameters to the method [`get_project_versions`]
43#[derive(Clone, Debug, Default)]
44pub struct GetProjectVersionsParams {
45    /// The project ID or project key (case sensitive).
46    pub project_id_or_key: String,
47    /// Use [expand](#expansion) to include additional information in the response. This parameter accepts `operations`, which returns actions that can be performed on the version.
48    pub expand: Option<String>
49}
50
51/// struct for passing parameters to the method [`get_project_versions_paginated`]
52#[derive(Clone, Debug, Default)]
53pub struct GetProjectVersionsPaginatedParams {
54    /// The project ID or project key (case sensitive).
55    pub project_id_or_key: String,
56    /// The index of the first item to return in a page of results (page offset).
57    pub start_at: Option<i64>,
58    /// The maximum number of items to return per page.
59    pub max_results: Option<i32>,
60    /// [Order](#ordering) the results by a field:   *  `description` Sorts by version description.  *  `name` Sorts by version name.  *  `releaseDate` Sorts by release date, starting with the oldest date. Versions with no release date are listed last.  *  `sequence` Sorts by the order of appearance in the user interface.  *  `startDate` Sorts by start date, starting with the oldest date. Versions with no start date are listed last.
61    pub order_by: Option<String>,
62    /// Filter the results using a literal string. Versions with matching `name` or `description` are returned (case insensitive).
63    pub query: Option<String>,
64    /// A list of status values used to filter the results by version status. This parameter accepts a comma-separated list. The status values are `released`, `unreleased`, and `archived`.
65    pub status: Option<String>,
66    /// Use [expand](#expansion) to include additional information in the response. This parameter accepts a comma-separated list. Expand options include:   *  `issuesstatus` Returns the number of issues in each status category for each version.  *  `operations` Returns actions that can be performed on the specified version.
67    pub expand: Option<String>
68}
69
70/// struct for passing parameters to the method [`get_version`]
71#[derive(Clone, Debug, Default)]
72pub struct GetVersionParams {
73    /// The ID of the version.
74    pub id: String,
75    /// Use [expand](#expansion) to include additional information about version in the response. This parameter accepts a comma-separated list. Expand options include:   *  `operations` Returns the list of operations available for this version.  *  `issuesstatus` Returns the count of issues in this version for each of the status categories *to do*, *in progress*, *done*, and *unmapped*. The *unmapped* property represents the number of issues with a status other than *to do*, *in progress*, and *done*.
76    pub expand: Option<String>
77}
78
79/// struct for passing parameters to the method [`get_version_related_issues`]
80#[derive(Clone, Debug, Default)]
81pub struct GetVersionRelatedIssuesParams {
82    /// The ID of the version.
83    pub id: String
84}
85
86/// struct for passing parameters to the method [`get_version_unresolved_issues`]
87#[derive(Clone, Debug, Default)]
88pub struct GetVersionUnresolvedIssuesParams {
89    /// The ID of the version.
90    pub id: String
91}
92
93/// struct for passing parameters to the method [`merge_versions`]
94#[derive(Clone, Debug, Default)]
95pub struct MergeVersionsParams {
96    /// The ID of the version to delete.
97    pub id: String,
98    /// The ID of the version to merge into.
99    pub move_issues_to: String
100}
101
102/// struct for passing parameters to the method [`move_version`]
103#[derive(Clone, Debug, Default)]
104pub struct MoveVersionParams {
105    /// The ID of the version to be moved.
106    pub id: String,
107    pub version_move_bean: crate::models::VersionMoveBean
108}
109
110/// struct for passing parameters to the method [`update_version`]
111#[derive(Clone, Debug, Default)]
112pub struct UpdateVersionParams {
113    /// The ID of the version.
114    pub id: String,
115    pub version: crate::models::Version
116}
117
118
119/// struct for typed errors of method [`create_version`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum CreateVersionError {
123    Status400(),
124    Status401(),
125    Status404(),
126    UnknownValue(serde_json::Value),
127}
128
129/// struct for typed errors of method [`delete_and_replace_version`]
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum DeleteAndReplaceVersionError {
133    Status400(),
134    Status401(),
135    Status404(),
136    UnknownValue(serde_json::Value),
137}
138
139/// struct for typed errors of method [`delete_version`]
140#[derive(Debug, Clone, Serialize, Deserialize)]
141#[serde(untagged)]
142pub enum DeleteVersionError {
143    Status400(),
144    Status401(),
145    Status404(),
146    UnknownValue(serde_json::Value),
147}
148
149/// struct for typed errors of method [`get_project_versions`]
150#[derive(Debug, Clone, Serialize, Deserialize)]
151#[serde(untagged)]
152pub enum GetProjectVersionsError {
153    Status404(),
154    UnknownValue(serde_json::Value),
155}
156
157/// struct for typed errors of method [`get_project_versions_paginated`]
158#[derive(Debug, Clone, Serialize, Deserialize)]
159#[serde(untagged)]
160pub enum GetProjectVersionsPaginatedError {
161    Status404(),
162    UnknownValue(serde_json::Value),
163}
164
165/// struct for typed errors of method [`get_version`]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum GetVersionError {
169    Status401(),
170    Status404(),
171    UnknownValue(serde_json::Value),
172}
173
174/// struct for typed errors of method [`get_version_related_issues`]
175#[derive(Debug, Clone, Serialize, Deserialize)]
176#[serde(untagged)]
177pub enum GetVersionRelatedIssuesError {
178    Status401(),
179    Status404(),
180    UnknownValue(serde_json::Value),
181}
182
183/// struct for typed errors of method [`get_version_unresolved_issues`]
184#[derive(Debug, Clone, Serialize, Deserialize)]
185#[serde(untagged)]
186pub enum GetVersionUnresolvedIssuesError {
187    Status401(),
188    Status404(),
189    UnknownValue(serde_json::Value),
190}
191
192/// struct for typed errors of method [`merge_versions`]
193#[derive(Debug, Clone, Serialize, Deserialize)]
194#[serde(untagged)]
195pub enum MergeVersionsError {
196    Status400(),
197    Status401(),
198    Status404(),
199    UnknownValue(serde_json::Value),
200}
201
202/// struct for typed errors of method [`move_version`]
203#[derive(Debug, Clone, Serialize, Deserialize)]
204#[serde(untagged)]
205pub enum MoveVersionError {
206    Status400(),
207    Status401(),
208    Status404(),
209    UnknownValue(serde_json::Value),
210}
211
212/// struct for typed errors of method [`update_version`]
213#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum UpdateVersionError {
216    Status400(),
217    Status401(),
218    Status404(),
219    UnknownValue(serde_json::Value),
220}
221
222
223/// Creates a project version.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project the version is added to.
224pub async fn create_version(configuration: &configuration::Configuration, params: CreateVersionParams) -> Result<crate::models::Version, Error<CreateVersionError>> {
225    let local_var_configuration = configuration;
226
227    // unbox the parameters
228    let version = params.version;
229
230
231    let local_var_client = &local_var_configuration.client;
232
233    let local_var_uri_str = format!("{}/rest/api/2/version", local_var_configuration.base_path);
234    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
235
236    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
237        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
238    }
239    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
240        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
241    };
242    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
243        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
244    };
245    local_var_req_builder = local_var_req_builder.json(&version);
246
247    let local_var_req = local_var_req_builder.build()?;
248    let local_var_resp = local_var_client.execute(local_var_req).await?;
249
250    let local_var_status = local_var_resp.status();
251    let local_var_content = local_var_resp.text().await?;
252
253    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
254        serde_json::from_str(&local_var_content).map_err(Error::from)
255    } else {
256        let local_var_entity: Option<CreateVersionError> = serde_json::from_str(&local_var_content).ok();
257        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
258        Err(Error::ResponseError(local_var_error))
259    }
260}
261
262/// Deletes a project version.  Alternative versions can be provided to update issues that use the deleted version in `fixVersion`, `affectedVersion`, or any version picker custom fields. If alternatives are not provided, occurrences of `fixVersion`, `affectedVersion`, and any version picker custom field, that contain the deleted version, are cleared. Any replacement version must be in the same project as the version being deleted and cannot be the version being deleted.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that contains the version.
263pub async fn delete_and_replace_version(configuration: &configuration::Configuration, params: DeleteAndReplaceVersionParams) -> Result<serde_json::Value, Error<DeleteAndReplaceVersionError>> {
264    let local_var_configuration = configuration;
265
266    // unbox the parameters
267    let id = params.id;
268    let delete_and_replace_version_bean = params.delete_and_replace_version_bean;
269
270
271    let local_var_client = &local_var_configuration.client;
272
273    let local_var_uri_str = format!("{}/rest/api/2/version/{id}/removeAndSwap", local_var_configuration.base_path, id=crate::apis::urlencode(id));
274    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
275
276    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
277        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
278    }
279    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
280        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
281    };
282    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
283        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
284    };
285    local_var_req_builder = local_var_req_builder.json(&delete_and_replace_version_bean);
286
287    let local_var_req = local_var_req_builder.build()?;
288    let local_var_resp = local_var_client.execute(local_var_req).await?;
289
290    let local_var_status = local_var_resp.status();
291    let local_var_content = local_var_resp.text().await?;
292
293    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
294        serde_json::from_str(&local_var_content).map_err(Error::from)
295    } else {
296        let local_var_entity: Option<DeleteAndReplaceVersionError> = serde_json::from_str(&local_var_content).ok();
297        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
298        Err(Error::ResponseError(local_var_error))
299    }
300}
301
302/// Deletes a project version.  Deprecated, use [ Delete and replace version](#api-rest-api-2-version-id-removeAndSwap-post) that supports swapping version values in custom fields, in addition to the swapping for `fixVersion` and `affectedVersion` provided in this resource.  Alternative versions can be provided to update issues that use the deleted version in `fixVersion` or `affectedVersion`. If alternatives are not provided, occurrences of `fixVersion` and `affectedVersion` that contain the deleted version are cleared.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that contains the version.
303pub async fn delete_version(configuration: &configuration::Configuration, params: DeleteVersionParams) -> Result<(), Error<DeleteVersionError>> {
304    let local_var_configuration = configuration;
305
306    // unbox the parameters
307    let id = params.id;
308    let move_fix_issues_to = params.move_fix_issues_to;
309    let move_affected_issues_to = params.move_affected_issues_to;
310
311
312    let local_var_client = &local_var_configuration.client;
313
314    let local_var_uri_str = format!("{}/rest/api/2/version/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
315    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
316
317    if let Some(ref local_var_str) = move_fix_issues_to {
318        local_var_req_builder = local_var_req_builder.query(&[("moveFixIssuesTo", &local_var_str.to_string())]);
319    }
320    if let Some(ref local_var_str) = move_affected_issues_to {
321        local_var_req_builder = local_var_req_builder.query(&[("moveAffectedIssuesTo", &local_var_str.to_string())]);
322    }
323    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
324        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
325    }
326    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
327        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
328    };
329    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
330        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
331    };
332
333    let local_var_req = local_var_req_builder.build()?;
334    let local_var_resp = local_var_client.execute(local_var_req).await?;
335
336    let local_var_status = local_var_resp.status();
337    let local_var_content = local_var_resp.text().await?;
338
339    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
340        Ok(())
341    } else {
342        let local_var_entity: Option<DeleteVersionError> = serde_json::from_str(&local_var_content).ok();
343        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
344        Err(Error::ResponseError(local_var_error))
345    }
346}
347
348/// Returns all versions in a project. The response is not paginated. Use [Get project versions paginated](#api-rest-api-2-project-projectIdOrKey-version-get) if you want to get the versions in a project with pagination.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
349pub async fn get_project_versions(configuration: &configuration::Configuration, params: GetProjectVersionsParams) -> Result<Vec<crate::models::Version>, Error<GetProjectVersionsError>> {
350    let local_var_configuration = configuration;
351
352    // unbox the parameters
353    let project_id_or_key = params.project_id_or_key;
354    let expand = params.expand;
355
356
357    let local_var_client = &local_var_configuration.client;
358
359    let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/versions", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
360    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
361
362    if let Some(ref local_var_str) = expand {
363        local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
364    }
365    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
366        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
367    }
368    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
369        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
370    };
371    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
372        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
373    };
374
375    let local_var_req = local_var_req_builder.build()?;
376    let local_var_resp = local_var_client.execute(local_var_req).await?;
377
378    let local_var_status = local_var_resp.status();
379    let local_var_content = local_var_resp.text().await?;
380
381    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
382        serde_json::from_str(&local_var_content).map_err(Error::from)
383    } else {
384        let local_var_entity: Option<GetProjectVersionsError> = serde_json::from_str(&local_var_content).ok();
385        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
386        Err(Error::ResponseError(local_var_error))
387    }
388}
389
390/// Returns a [paginated](#pagination) list of all versions in a project. See the [Get project versions](#api-rest-api-2-project-projectIdOrKey-versions-get) resource if you want to get a full list of versions without pagination.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
391pub async fn get_project_versions_paginated(configuration: &configuration::Configuration, params: GetProjectVersionsPaginatedParams) -> Result<crate::models::PageBeanVersion, Error<GetProjectVersionsPaginatedError>> {
392    let local_var_configuration = configuration;
393
394    // unbox the parameters
395    let project_id_or_key = params.project_id_or_key;
396    let start_at = params.start_at;
397    let max_results = params.max_results;
398    let order_by = params.order_by;
399    let query = params.query;
400    let status = params.status;
401    let expand = params.expand;
402
403
404    let local_var_client = &local_var_configuration.client;
405
406    let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/version", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
407    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
408
409    if let Some(ref local_var_str) = start_at {
410        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
411    }
412    if let Some(ref local_var_str) = max_results {
413        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
414    }
415    if let Some(ref local_var_str) = order_by {
416        local_var_req_builder = local_var_req_builder.query(&[("orderBy", &local_var_str.to_string())]);
417    }
418    if let Some(ref local_var_str) = query {
419        local_var_req_builder = local_var_req_builder.query(&[("query", &local_var_str.to_string())]);
420    }
421    if let Some(ref local_var_str) = status {
422        local_var_req_builder = local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
423    }
424    if let Some(ref local_var_str) = expand {
425        local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
426    }
427    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
428        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
429    }
430    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
431        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
432    };
433    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
434        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
435    };
436
437    let local_var_req = local_var_req_builder.build()?;
438    let local_var_resp = local_var_client.execute(local_var_req).await?;
439
440    let local_var_status = local_var_resp.status();
441    let local_var_content = local_var_resp.text().await?;
442
443    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
444        serde_json::from_str(&local_var_content).map_err(Error::from)
445    } else {
446        let local_var_entity: Option<GetProjectVersionsPaginatedError> = serde_json::from_str(&local_var_content).ok();
447        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
448        Err(Error::ResponseError(local_var_error))
449    }
450}
451
452/// Returns a project version.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the version.
453pub async fn get_version(configuration: &configuration::Configuration, params: GetVersionParams) -> Result<crate::models::Version, Error<GetVersionError>> {
454    let local_var_configuration = configuration;
455
456    // unbox the parameters
457    let id = params.id;
458    let expand = params.expand;
459
460
461    let local_var_client = &local_var_configuration.client;
462
463    let local_var_uri_str = format!("{}/rest/api/2/version/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
464    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
465
466    if let Some(ref local_var_str) = expand {
467        local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
468    }
469    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
470        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
471    }
472    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
473        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
474    };
475    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
476        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
477    };
478
479    let local_var_req = local_var_req_builder.build()?;
480    let local_var_resp = local_var_client.execute(local_var_req).await?;
481
482    let local_var_status = local_var_resp.status();
483    let local_var_content = local_var_resp.text().await?;
484
485    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
486        serde_json::from_str(&local_var_content).map_err(Error::from)
487    } else {
488        let local_var_entity: Option<GetVersionError> = serde_json::from_str(&local_var_content).ok();
489        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
490        Err(Error::ResponseError(local_var_error))
491    }
492}
493
494/// Returns the following counts for a version:   *  Number of issues where the `fixVersion` is set to the version.  *  Number of issues where the `affectedVersion` is set to the version.  *  Number of issues where a version custom field is set to the version.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse projects* project permission for the project that contains the version.
495pub async fn get_version_related_issues(configuration: &configuration::Configuration, params: GetVersionRelatedIssuesParams) -> Result<crate::models::VersionIssueCounts, Error<GetVersionRelatedIssuesError>> {
496    let local_var_configuration = configuration;
497
498    // unbox the parameters
499    let id = params.id;
500
501
502    let local_var_client = &local_var_configuration.client;
503
504    let local_var_uri_str = format!("{}/rest/api/2/version/{id}/relatedIssueCounts", local_var_configuration.base_path, id=crate::apis::urlencode(id));
505    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
506
507    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
508        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
509    }
510    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
511        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
512    };
513    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
514        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
515    };
516
517    let local_var_req = local_var_req_builder.build()?;
518    let local_var_resp = local_var_client.execute(local_var_req).await?;
519
520    let local_var_status = local_var_resp.status();
521    let local_var_content = local_var_resp.text().await?;
522
523    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
524        serde_json::from_str(&local_var_content).map_err(Error::from)
525    } else {
526        let local_var_entity: Option<GetVersionRelatedIssuesError> = serde_json::from_str(&local_var_content).ok();
527        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
528        Err(Error::ResponseError(local_var_error))
529    }
530}
531
532/// Returns counts of the issues and unresolved issues for the project version.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse projects* project permission for the project that contains the version.
533pub async fn get_version_unresolved_issues(configuration: &configuration::Configuration, params: GetVersionUnresolvedIssuesParams) -> Result<crate::models::VersionUnresolvedIssuesCount, Error<GetVersionUnresolvedIssuesError>> {
534    let local_var_configuration = configuration;
535
536    // unbox the parameters
537    let id = params.id;
538
539
540    let local_var_client = &local_var_configuration.client;
541
542    let local_var_uri_str = format!("{}/rest/api/2/version/{id}/unresolvedIssueCount", local_var_configuration.base_path, id=crate::apis::urlencode(id));
543    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
544
545    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
546        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
547    }
548    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
549        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
550    };
551    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
552        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
553    };
554
555    let local_var_req = local_var_req_builder.build()?;
556    let local_var_resp = local_var_client.execute(local_var_req).await?;
557
558    let local_var_status = local_var_resp.status();
559    let local_var_content = local_var_resp.text().await?;
560
561    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
562        serde_json::from_str(&local_var_content).map_err(Error::from)
563    } else {
564        let local_var_entity: Option<GetVersionUnresolvedIssuesError> = serde_json::from_str(&local_var_content).ok();
565        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
566        Err(Error::ResponseError(local_var_error))
567    }
568}
569
570/// Merges two project versions. The merge is completed by deleting the version specified in `id` and replacing any occurrences of its ID in `fixVersion` with the version ID specified in `moveIssuesTo`.  Consider using [ Delete and replace version](#api-rest-api-2-version-id-removeAndSwap-post) instead. This resource supports swapping version values in `fixVersion`, `affectedVersion`, and custom fields.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that contains the version.
571pub async fn merge_versions(configuration: &configuration::Configuration, params: MergeVersionsParams) -> Result<serde_json::Value, Error<MergeVersionsError>> {
572    let local_var_configuration = configuration;
573
574    // unbox the parameters
575    let id = params.id;
576    let move_issues_to = params.move_issues_to;
577
578
579    let local_var_client = &local_var_configuration.client;
580
581    let local_var_uri_str = format!("{}/rest/api/2/version/{id}/mergeto/{moveIssuesTo}", local_var_configuration.base_path, id=crate::apis::urlencode(id), moveIssuesTo=crate::apis::urlencode(move_issues_to));
582    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
583
584    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
585        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
586    }
587    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
588        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
589    };
590    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
591        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
592    };
593
594    let local_var_req = local_var_req_builder.build()?;
595    let local_var_resp = local_var_client.execute(local_var_req).await?;
596
597    let local_var_status = local_var_resp.status();
598    let local_var_content = local_var_resp.text().await?;
599
600    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
601        serde_json::from_str(&local_var_content).map_err(Error::from)
602    } else {
603        let local_var_entity: Option<MergeVersionsError> = serde_json::from_str(&local_var_content).ok();
604        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
605        Err(Error::ResponseError(local_var_error))
606    }
607}
608
609/// Modifies the version's sequence within the project, which affects the display order of the versions in Jira.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse projects* project permission for the project that contains the version.
610pub async fn move_version(configuration: &configuration::Configuration, params: MoveVersionParams) -> Result<crate::models::Version, Error<MoveVersionError>> {
611    let local_var_configuration = configuration;
612
613    // unbox the parameters
614    let id = params.id;
615    let version_move_bean = params.version_move_bean;
616
617
618    let local_var_client = &local_var_configuration.client;
619
620    let local_var_uri_str = format!("{}/rest/api/2/version/{id}/move", local_var_configuration.base_path, id=crate::apis::urlencode(id));
621    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
622
623    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
624        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
625    }
626    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
627        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
628    };
629    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
630        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
631    };
632    local_var_req_builder = local_var_req_builder.json(&version_move_bean);
633
634    let local_var_req = local_var_req_builder.build()?;
635    let local_var_resp = local_var_client.execute(local_var_req).await?;
636
637    let local_var_status = local_var_resp.status();
638    let local_var_content = local_var_resp.text().await?;
639
640    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
641        serde_json::from_str(&local_var_content).map_err(Error::from)
642    } else {
643        let local_var_entity: Option<MoveVersionError> = serde_json::from_str(&local_var_content).ok();
644        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
645        Err(Error::ResponseError(local_var_error))
646    }
647}
648
649/// Updates a project version.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that contains the version.
650pub async fn update_version(configuration: &configuration::Configuration, params: UpdateVersionParams) -> Result<crate::models::Version, Error<UpdateVersionError>> {
651    let local_var_configuration = configuration;
652
653    // unbox the parameters
654    let id = params.id;
655    let version = params.version;
656
657
658    let local_var_client = &local_var_configuration.client;
659
660    let local_var_uri_str = format!("{}/rest/api/2/version/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
661    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
662
663    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
664        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
665    }
666    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
667        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
668    };
669    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
670        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
671    };
672    local_var_req_builder = local_var_req_builder.json(&version);
673
674    let local_var_req = local_var_req_builder.build()?;
675    let local_var_resp = local_var_client.execute(local_var_req).await?;
676
677    let local_var_status = local_var_resp.status();
678    let local_var_content = local_var_resp.text().await?;
679
680    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
681        serde_json::from_str(&local_var_content).map_err(Error::from)
682    } else {
683        let local_var_entity: Option<UpdateVersionError> = serde_json::from_str(&local_var_content).ok();
684        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
685        Err(Error::ResponseError(local_var_error))
686    }
687}
688