jira_api_v2/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;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`create_version`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateVersionError {
22    Status400(),
23    Status401(),
24    Status404(),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`delete_and_replace_version`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum DeleteAndReplaceVersionError {
32    Status400(),
33    Status401(),
34    Status404(),
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`delete_version`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum DeleteVersionError {
42    Status400(),
43    Status401(),
44    Status404(),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`get_project_versions`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetProjectVersionsError {
52    Status404(),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`get_project_versions_paginated`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum GetProjectVersionsPaginatedError {
60    Status404(),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`get_version`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum GetVersionError {
68    Status401(),
69    Status404(),
70    UnknownValue(serde_json::Value),
71}
72
73/// struct for typed errors of method [`get_version_related_issues`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum GetVersionRelatedIssuesError {
77    Status401(),
78    Status404(),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`get_version_unresolved_issues`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum GetVersionUnresolvedIssuesError {
86    Status401(),
87    Status404(),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`merge_versions`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum MergeVersionsError {
95    Status400(),
96    Status401(),
97    Status404(),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`move_version`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum MoveVersionError {
105    Status400(),
106    Status401(),
107    Status404(),
108    UnknownValue(serde_json::Value),
109}
110
111/// struct for typed errors of method [`update_version`]
112#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(untagged)]
114pub enum UpdateVersionError {
115    Status400(),
116    Status401(),
117    Status404(),
118    UnknownValue(serde_json::Value),
119}
120
121
122/// 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.
123pub async fn create_version(configuration: &configuration::Configuration, version: models::Version) -> Result<models::Version, Error<CreateVersionError>> {
124    // add a prefix to parameters to efficiently prevent name collisions
125    let p_version = version;
126
127    let uri_str = format!("{}/rest/api/2/version", configuration.base_path);
128    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
129
130    if let Some(ref user_agent) = configuration.user_agent {
131        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
132    }
133    if let Some(ref token) = configuration.oauth_access_token {
134        req_builder = req_builder.bearer_auth(token.to_owned());
135    };
136    if let Some(ref auth_conf) = configuration.basic_auth {
137        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
138    };
139    req_builder = req_builder.json(&p_version);
140
141    let req = req_builder.build()?;
142    let resp = configuration.client.execute(req).await?;
143
144    let status = resp.status();
145
146    if !status.is_client_error() && !status.is_server_error() {
147        let content = resp.text().await?;
148        serde_json::from_str(&content).map_err(Error::from)
149    } else {
150        let content = resp.text().await?;
151        let entity: Option<CreateVersionError> = serde_json::from_str(&content).ok();
152        Err(Error::ResponseError(ResponseContent { status, content, entity }))
153    }
154}
155
156/// 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.
157pub async fn delete_and_replace_version(configuration: &configuration::Configuration, id: &str, delete_and_replace_version_bean: models::DeleteAndReplaceVersionBean) -> Result<serde_json::Value, Error<DeleteAndReplaceVersionError>> {
158    // add a prefix to parameters to efficiently prevent name collisions
159    let p_id = id;
160    let p_delete_and_replace_version_bean = delete_and_replace_version_bean;
161
162    let uri_str = format!("{}/rest/api/2/version/{id}/removeAndSwap", configuration.base_path, id=crate::apis::urlencode(p_id));
163    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
164
165    if let Some(ref user_agent) = configuration.user_agent {
166        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
167    }
168    if let Some(ref token) = configuration.oauth_access_token {
169        req_builder = req_builder.bearer_auth(token.to_owned());
170    };
171    if let Some(ref auth_conf) = configuration.basic_auth {
172        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
173    };
174    req_builder = req_builder.json(&p_delete_and_replace_version_bean);
175
176    let req = req_builder.build()?;
177    let resp = configuration.client.execute(req).await?;
178
179    let status = resp.status();
180
181    if !status.is_client_error() && !status.is_server_error() {
182        let content = resp.text().await?;
183        serde_json::from_str(&content).map_err(Error::from)
184    } else {
185        let content = resp.text().await?;
186        let entity: Option<DeleteAndReplaceVersionError> = serde_json::from_str(&content).ok();
187        Err(Error::ResponseError(ResponseContent { status, content, entity }))
188    }
189}
190
191/// 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.
192pub async fn delete_version(configuration: &configuration::Configuration, id: &str, move_fix_issues_to: Option<&str>, move_affected_issues_to: Option<&str>) -> Result<(), Error<DeleteVersionError>> {
193    // add a prefix to parameters to efficiently prevent name collisions
194    let p_id = id;
195    let p_move_fix_issues_to = move_fix_issues_to;
196    let p_move_affected_issues_to = move_affected_issues_to;
197
198    let uri_str = format!("{}/rest/api/2/version/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
199    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
200
201    if let Some(ref param_value) = p_move_fix_issues_to {
202        req_builder = req_builder.query(&[("moveFixIssuesTo", &param_value.to_string())]);
203    }
204    if let Some(ref param_value) = p_move_affected_issues_to {
205        req_builder = req_builder.query(&[("moveAffectedIssuesTo", &param_value.to_string())]);
206    }
207    if let Some(ref user_agent) = configuration.user_agent {
208        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
209    }
210    if let Some(ref token) = configuration.oauth_access_token {
211        req_builder = req_builder.bearer_auth(token.to_owned());
212    };
213    if let Some(ref auth_conf) = configuration.basic_auth {
214        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
215    };
216
217    let req = req_builder.build()?;
218    let resp = configuration.client.execute(req).await?;
219
220    let status = resp.status();
221
222    if !status.is_client_error() && !status.is_server_error() {
223        Ok(())
224    } else {
225        let content = resp.text().await?;
226        let entity: Option<DeleteVersionError> = serde_json::from_str(&content).ok();
227        Err(Error::ResponseError(ResponseContent { status, content, entity }))
228    }
229}
230
231/// 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.
232pub async fn get_project_versions(configuration: &configuration::Configuration, project_id_or_key: &str, expand: Option<&str>) -> Result<Vec<models::Version>, Error<GetProjectVersionsError>> {
233    // add a prefix to parameters to efficiently prevent name collisions
234    let p_project_id_or_key = project_id_or_key;
235    let p_expand = expand;
236
237    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/versions", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
238    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
239
240    if let Some(ref param_value) = p_expand {
241        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
242    }
243    if let Some(ref user_agent) = configuration.user_agent {
244        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
245    }
246    if let Some(ref token) = configuration.oauth_access_token {
247        req_builder = req_builder.bearer_auth(token.to_owned());
248    };
249    if let Some(ref auth_conf) = configuration.basic_auth {
250        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
251    };
252
253    let req = req_builder.build()?;
254    let resp = configuration.client.execute(req).await?;
255
256    let status = resp.status();
257
258    if !status.is_client_error() && !status.is_server_error() {
259        let content = resp.text().await?;
260        serde_json::from_str(&content).map_err(Error::from)
261    } else {
262        let content = resp.text().await?;
263        let entity: Option<GetProjectVersionsError> = serde_json::from_str(&content).ok();
264        Err(Error::ResponseError(ResponseContent { status, content, entity }))
265    }
266}
267
268/// 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.
269pub async fn get_project_versions_paginated(configuration: &configuration::Configuration, project_id_or_key: &str, start_at: Option<i64>, max_results: Option<i32>, order_by: Option<&str>, query: Option<&str>, status: Option<&str>, expand: Option<&str>) -> Result<models::PageBeanVersion, Error<GetProjectVersionsPaginatedError>> {
270    // add a prefix to parameters to efficiently prevent name collisions
271    let p_project_id_or_key = project_id_or_key;
272    let p_start_at = start_at;
273    let p_max_results = max_results;
274    let p_order_by = order_by;
275    let p_query = query;
276    let p_status = status;
277    let p_expand = expand;
278
279    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/version", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
280    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
281
282    if let Some(ref param_value) = p_start_at {
283        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
284    }
285    if let Some(ref param_value) = p_max_results {
286        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
287    }
288    if let Some(ref param_value) = p_order_by {
289        req_builder = req_builder.query(&[("orderBy", &param_value.to_string())]);
290    }
291    if let Some(ref param_value) = p_query {
292        req_builder = req_builder.query(&[("query", &param_value.to_string())]);
293    }
294    if let Some(ref param_value) = p_status {
295        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
296    }
297    if let Some(ref param_value) = p_expand {
298        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
299    }
300    if let Some(ref user_agent) = configuration.user_agent {
301        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
302    }
303    if let Some(ref token) = configuration.oauth_access_token {
304        req_builder = req_builder.bearer_auth(token.to_owned());
305    };
306    if let Some(ref auth_conf) = configuration.basic_auth {
307        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
308    };
309
310    let req = req_builder.build()?;
311    let resp = configuration.client.execute(req).await?;
312
313    let status = resp.status();
314
315    if !status.is_client_error() && !status.is_server_error() {
316        let content = resp.text().await?;
317        serde_json::from_str(&content).map_err(Error::from)
318    } else {
319        let content = resp.text().await?;
320        let entity: Option<GetProjectVersionsPaginatedError> = serde_json::from_str(&content).ok();
321        Err(Error::ResponseError(ResponseContent { status, content, entity }))
322    }
323}
324
325/// 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.
326pub async fn get_version(configuration: &configuration::Configuration, id: &str, expand: Option<&str>) -> Result<models::Version, Error<GetVersionError>> {
327    // add a prefix to parameters to efficiently prevent name collisions
328    let p_id = id;
329    let p_expand = expand;
330
331    let uri_str = format!("{}/rest/api/2/version/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
332    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
333
334    if let Some(ref param_value) = p_expand {
335        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
336    }
337    if let Some(ref user_agent) = configuration.user_agent {
338        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
339    }
340    if let Some(ref token) = configuration.oauth_access_token {
341        req_builder = req_builder.bearer_auth(token.to_owned());
342    };
343    if let Some(ref auth_conf) = configuration.basic_auth {
344        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
345    };
346
347    let req = req_builder.build()?;
348    let resp = configuration.client.execute(req).await?;
349
350    let status = resp.status();
351
352    if !status.is_client_error() && !status.is_server_error() {
353        let content = resp.text().await?;
354        serde_json::from_str(&content).map_err(Error::from)
355    } else {
356        let content = resp.text().await?;
357        let entity: Option<GetVersionError> = serde_json::from_str(&content).ok();
358        Err(Error::ResponseError(ResponseContent { status, content, entity }))
359    }
360}
361
362/// 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.
363pub async fn get_version_related_issues(configuration: &configuration::Configuration, id: &str) -> Result<models::VersionIssueCounts, Error<GetVersionRelatedIssuesError>> {
364    // add a prefix to parameters to efficiently prevent name collisions
365    let p_id = id;
366
367    let uri_str = format!("{}/rest/api/2/version/{id}/relatedIssueCounts", configuration.base_path, id=crate::apis::urlencode(p_id));
368    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
369
370    if let Some(ref user_agent) = configuration.user_agent {
371        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
372    }
373    if let Some(ref token) = configuration.oauth_access_token {
374        req_builder = req_builder.bearer_auth(token.to_owned());
375    };
376    if let Some(ref auth_conf) = configuration.basic_auth {
377        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
378    };
379
380    let req = req_builder.build()?;
381    let resp = configuration.client.execute(req).await?;
382
383    let status = resp.status();
384
385    if !status.is_client_error() && !status.is_server_error() {
386        let content = resp.text().await?;
387        serde_json::from_str(&content).map_err(Error::from)
388    } else {
389        let content = resp.text().await?;
390        let entity: Option<GetVersionRelatedIssuesError> = serde_json::from_str(&content).ok();
391        Err(Error::ResponseError(ResponseContent { status, content, entity }))
392    }
393}
394
395/// 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.
396pub async fn get_version_unresolved_issues(configuration: &configuration::Configuration, id: &str) -> Result<models::VersionUnresolvedIssuesCount, Error<GetVersionUnresolvedIssuesError>> {
397    // add a prefix to parameters to efficiently prevent name collisions
398    let p_id = id;
399
400    let uri_str = format!("{}/rest/api/2/version/{id}/unresolvedIssueCount", configuration.base_path, id=crate::apis::urlencode(p_id));
401    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
402
403    if let Some(ref user_agent) = configuration.user_agent {
404        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
405    }
406    if let Some(ref token) = configuration.oauth_access_token {
407        req_builder = req_builder.bearer_auth(token.to_owned());
408    };
409    if let Some(ref auth_conf) = configuration.basic_auth {
410        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
411    };
412
413    let req = req_builder.build()?;
414    let resp = configuration.client.execute(req).await?;
415
416    let status = resp.status();
417
418    if !status.is_client_error() && !status.is_server_error() {
419        let content = resp.text().await?;
420        serde_json::from_str(&content).map_err(Error::from)
421    } else {
422        let content = resp.text().await?;
423        let entity: Option<GetVersionUnresolvedIssuesError> = serde_json::from_str(&content).ok();
424        Err(Error::ResponseError(ResponseContent { status, content, entity }))
425    }
426}
427
428/// 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.
429pub async fn merge_versions(configuration: &configuration::Configuration, id: &str, move_issues_to: &str) -> Result<serde_json::Value, Error<MergeVersionsError>> {
430    // add a prefix to parameters to efficiently prevent name collisions
431    let p_id = id;
432    let p_move_issues_to = move_issues_to;
433
434    let uri_str = format!("{}/rest/api/2/version/{id}/mergeto/{moveIssuesTo}", configuration.base_path, id=crate::apis::urlencode(p_id), moveIssuesTo=crate::apis::urlencode(p_move_issues_to));
435    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
436
437    if let Some(ref user_agent) = configuration.user_agent {
438        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
439    }
440    if let Some(ref token) = configuration.oauth_access_token {
441        req_builder = req_builder.bearer_auth(token.to_owned());
442    };
443    if let Some(ref auth_conf) = configuration.basic_auth {
444        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
445    };
446
447    let req = req_builder.build()?;
448    let resp = configuration.client.execute(req).await?;
449
450    let status = resp.status();
451
452    if !status.is_client_error() && !status.is_server_error() {
453        let content = resp.text().await?;
454        serde_json::from_str(&content).map_err(Error::from)
455    } else {
456        let content = resp.text().await?;
457        let entity: Option<MergeVersionsError> = serde_json::from_str(&content).ok();
458        Err(Error::ResponseError(ResponseContent { status, content, entity }))
459    }
460}
461
462/// 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.
463pub async fn move_version(configuration: &configuration::Configuration, id: &str, version_move_bean: models::VersionMoveBean) -> Result<models::Version, Error<MoveVersionError>> {
464    // add a prefix to parameters to efficiently prevent name collisions
465    let p_id = id;
466    let p_version_move_bean = version_move_bean;
467
468    let uri_str = format!("{}/rest/api/2/version/{id}/move", configuration.base_path, id=crate::apis::urlencode(p_id));
469    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
470
471    if let Some(ref user_agent) = configuration.user_agent {
472        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
473    }
474    if let Some(ref token) = configuration.oauth_access_token {
475        req_builder = req_builder.bearer_auth(token.to_owned());
476    };
477    if let Some(ref auth_conf) = configuration.basic_auth {
478        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
479    };
480    req_builder = req_builder.json(&p_version_move_bean);
481
482    let req = req_builder.build()?;
483    let resp = configuration.client.execute(req).await?;
484
485    let status = resp.status();
486
487    if !status.is_client_error() && !status.is_server_error() {
488        let content = resp.text().await?;
489        serde_json::from_str(&content).map_err(Error::from)
490    } else {
491        let content = resp.text().await?;
492        let entity: Option<MoveVersionError> = serde_json::from_str(&content).ok();
493        Err(Error::ResponseError(ResponseContent { status, content, entity }))
494    }
495}
496
497/// 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.
498pub async fn update_version(configuration: &configuration::Configuration, id: &str, version: models::Version) -> Result<models::Version, Error<UpdateVersionError>> {
499    // add a prefix to parameters to efficiently prevent name collisions
500    let p_id = id;
501    let p_version = version;
502
503    let uri_str = format!("{}/rest/api/2/version/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
504    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
505
506    if let Some(ref user_agent) = configuration.user_agent {
507        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
508    }
509    if let Some(ref token) = configuration.oauth_access_token {
510        req_builder = req_builder.bearer_auth(token.to_owned());
511    };
512    if let Some(ref auth_conf) = configuration.basic_auth {
513        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
514    };
515    req_builder = req_builder.json(&p_version);
516
517    let req = req_builder.build()?;
518    let resp = configuration.client.execute(req).await?;
519
520    let status = resp.status();
521
522    if !status.is_client_error() && !status.is_server_error() {
523        let content = resp.text().await?;
524        serde_json::from_str(&content).map_err(Error::from)
525    } else {
526        let content = resp.text().await?;
527        let entity: Option<UpdateVersionError> = serde_json::from_str(&content).ok();
528        Err(Error::ResponseError(ResponseContent { status, content, entity }))
529    }
530}
531