jira2/apis/
issue_fields_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_custom_field`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateCustomFieldParams {
20    /// Definition of the custom field to be created
21    pub custom_field_definition_json_bean: crate::models::CustomFieldDefinitionJsonBean
22}
23
24/// struct for passing parameters to the method [`delete_custom_field`]
25#[derive(Clone, Debug, Default)]
26pub struct DeleteCustomFieldParams {
27    /// The ID of a custom field.
28    pub id: String
29}
30
31/// struct for passing parameters to the method [`get_contexts_for_field_deprecated`]
32#[derive(Clone, Debug, Default)]
33pub struct GetContextsForFieldDeprecatedParams {
34    /// The ID of the field to return contexts for.
35    pub field_id: String,
36    /// The index of the first item to return in a page of results (page offset).
37    pub start_at: Option<i64>,
38    /// The maximum number of items to return per page.
39    pub max_results: Option<i32>
40}
41
42/// struct for passing parameters to the method [`get_fields_paginated`]
43#[derive(Clone, Debug, Default)]
44pub struct GetFieldsPaginatedParams {
45    /// The index of the first item to return in a page of results (page offset).
46    pub start_at: Option<i64>,
47    /// The maximum number of items to return per page.
48    pub max_results: Option<i32>,
49    /// The type of fields to search.
50    pub _type: Option<Vec<String>>,
51    /// The IDs of the custom fields to return or, where `query` is specified, filter.
52    pub id: Option<Vec<String>>,
53    /// String used to perform a case-insensitive partial match with field names or descriptions.
54    pub query: Option<String>,
55    /// [Order](#ordering) the results by a field:   *  `contextsCount` Sorts by the number of contexts related to a field.  *  `lastUsed` Sorts by the date when the value of the field last changed.  *  `name` Sorts by the field name.  *  `screensCount` Sorts by the number of screens related to a field.
56    pub order_by: Option<String>,
57    /// Use [expand](#expansion) to include additional information in the response. This parameter accepts a comma-separated list. Expand options include:   *  `key` Returns the key for each field.  *  `lastUsed` Returns the date when the value of the field last changed.  *  `screensCount` Returns the number of screens related to a field.  *  `contextsCount` Returns the number of contexts related to a field.  *  `isLocked` Returns information about whether the field is [locked](https://confluence.atlassian.com/x/ZSN7Og).  *  `searcherKey` Returns the searcher key for each custom field.
58    pub expand: Option<String>
59}
60
61/// struct for passing parameters to the method [`restore_custom_field`]
62#[derive(Clone, Debug, Default)]
63pub struct RestoreCustomFieldParams {
64    /// The ID of a custom field.
65    pub id: String
66}
67
68/// struct for passing parameters to the method [`trash_custom_field`]
69#[derive(Clone, Debug, Default)]
70pub struct TrashCustomFieldParams {
71    /// The ID of a custom field.
72    pub id: String
73}
74
75/// struct for passing parameters to the method [`update_custom_field`]
76#[derive(Clone, Debug, Default)]
77pub struct UpdateCustomFieldParams {
78    /// The ID of the custom field.
79    pub field_id: String,
80    /// The custom field update details.
81    pub update_custom_field_details: crate::models::UpdateCustomFieldDetails
82}
83
84
85/// struct for typed errors of method [`create_custom_field`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum CreateCustomFieldError {
89    Status400(),
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed errors of method [`delete_custom_field`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum DeleteCustomFieldError {
97    Status400(crate::models::ErrorCollection),
98    Status401(crate::models::ErrorCollection),
99    Status403(crate::models::ErrorCollection),
100    Status404(crate::models::ErrorCollection),
101    Status409(crate::models::ErrorCollection),
102    UnknownValue(serde_json::Value),
103}
104
105/// struct for typed errors of method [`get_contexts_for_field_deprecated`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum GetContextsForFieldDeprecatedError {
109    Status401(),
110    Status403(),
111    UnknownValue(serde_json::Value),
112}
113
114/// struct for typed errors of method [`get_fields`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum GetFieldsError {
118    Status401(),
119    UnknownValue(serde_json::Value),
120}
121
122/// struct for typed errors of method [`get_fields_paginated`]
123#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum GetFieldsPaginatedError {
126    Status400(crate::models::ErrorCollection),
127    Status401(),
128    Status403(crate::models::ErrorCollection),
129    UnknownValue(serde_json::Value),
130}
131
132/// struct for typed errors of method [`restore_custom_field`]
133#[derive(Debug, Clone, Serialize, Deserialize)]
134#[serde(untagged)]
135pub enum RestoreCustomFieldError {
136    Status400(crate::models::ErrorCollection),
137    Status401(crate::models::ErrorCollection),
138    Status403(crate::models::ErrorCollection),
139    Status404(crate::models::ErrorCollection),
140    UnknownValue(serde_json::Value),
141}
142
143/// struct for typed errors of method [`trash_custom_field`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum TrashCustomFieldError {
147    Status400(crate::models::ErrorCollection),
148    Status401(crate::models::ErrorCollection),
149    Status403(crate::models::ErrorCollection),
150    Status404(crate::models::ErrorCollection),
151    UnknownValue(serde_json::Value),
152}
153
154/// struct for typed errors of method [`update_custom_field`]
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum UpdateCustomFieldError {
158    Status400(),
159    Status401(),
160    Status403(),
161    Status404(),
162    UnknownValue(serde_json::Value),
163}
164
165
166/// Creates a custom field.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
167pub async fn create_custom_field(configuration: &configuration::Configuration, params: CreateCustomFieldParams) -> Result<crate::models::FieldDetails, Error<CreateCustomFieldError>> {
168    let local_var_configuration = configuration;
169
170    // unbox the parameters
171    let custom_field_definition_json_bean = params.custom_field_definition_json_bean;
172
173
174    let local_var_client = &local_var_configuration.client;
175
176    let local_var_uri_str = format!("{}/rest/api/2/field", local_var_configuration.base_path);
177    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
178
179    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
180        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
181    }
182    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
183        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
184    };
185    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
186        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
187    };
188    local_var_req_builder = local_var_req_builder.json(&custom_field_definition_json_bean);
189
190    let local_var_req = local_var_req_builder.build()?;
191    let local_var_resp = local_var_client.execute(local_var_req).await?;
192
193    let local_var_status = local_var_resp.status();
194    let local_var_content = local_var_resp.text().await?;
195
196    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
197        serde_json::from_str(&local_var_content).map_err(Error::from)
198    } else {
199        let local_var_entity: Option<CreateCustomFieldError> = serde_json::from_str(&local_var_content).ok();
200        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
201        Err(Error::ResponseError(local_var_error))
202    }
203}
204
205/// Deletes a custom field. The custom field is deleted whether it is in the trash or not. See [Edit or delete a custom field](https://confluence.atlassian.com/x/Z44fOw) for more information on trashing and deleting custom fields.  This operation is [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).
206pub async fn delete_custom_field(configuration: &configuration::Configuration, params: DeleteCustomFieldParams) -> Result<(), Error<DeleteCustomFieldError>> {
207    let local_var_configuration = configuration;
208
209    // unbox the parameters
210    let id = params.id;
211
212
213    let local_var_client = &local_var_configuration.client;
214
215    let local_var_uri_str = format!("{}/rest/api/2/field/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
216    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
217
218    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
219        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
220    }
221    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
222        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
223    };
224    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
225        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
226    };
227
228    let local_var_req = local_var_req_builder.build()?;
229    let local_var_resp = local_var_client.execute(local_var_req).await?;
230
231    let local_var_status = local_var_resp.status();
232    let local_var_content = local_var_resp.text().await?;
233
234    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
235        Ok(())
236    } else {
237        let local_var_entity: Option<DeleteCustomFieldError> = serde_json::from_str(&local_var_content).ok();
238        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
239        Err(Error::ResponseError(local_var_error))
240    }
241}
242
243/// Returns a [paginated](#pagination) list of the contexts a field is used in. Deprecated, use [ Get custom field contexts](#api-rest-api-2-field-fieldId-context-get).  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
244pub async fn get_contexts_for_field_deprecated(configuration: &configuration::Configuration, params: GetContextsForFieldDeprecatedParams) -> Result<crate::models::PageBeanContext, Error<GetContextsForFieldDeprecatedError>> {
245    let local_var_configuration = configuration;
246
247    // unbox the parameters
248    let field_id = params.field_id;
249    let start_at = params.start_at;
250    let max_results = params.max_results;
251
252
253    let local_var_client = &local_var_configuration.client;
254
255    let local_var_uri_str = format!("{}/rest/api/2/field/{fieldId}/contexts", local_var_configuration.base_path, fieldId=crate::apis::urlencode(field_id));
256    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
257
258    if let Some(ref local_var_str) = start_at {
259        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
260    }
261    if let Some(ref local_var_str) = max_results {
262        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
263    }
264    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
265        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
266    }
267    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
268        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
269    };
270    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
271        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
272    };
273
274    let local_var_req = local_var_req_builder.build()?;
275    let local_var_resp = local_var_client.execute(local_var_req).await?;
276
277    let local_var_status = local_var_resp.status();
278    let local_var_content = local_var_resp.text().await?;
279
280    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
281        serde_json::from_str(&local_var_content).map_err(Error::from)
282    } else {
283        let local_var_entity: Option<GetContextsForFieldDeprecatedError> = serde_json::from_str(&local_var_content).ok();
284        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
285        Err(Error::ResponseError(local_var_error))
286    }
287}
288
289/// Returns system and custom issue fields according to the following rules:   *  Fields that cannot be added to the issue navigator are always returned.  *  Fields that cannot be placed on an issue screen are always returned.  *  Fields that depend on global Jira settings are only returned if the setting is enabled. That is, timetracking fields, subtasks, votes, and watches.  *  For all other fields, this operation only returns the fields that the user has permission to view (that is, the field is used in at least one project that the user has *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for.)  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
290pub async fn get_fields(configuration: &configuration::Configuration) -> Result<Vec<crate::models::FieldDetails>, Error<GetFieldsError>> {
291    let local_var_configuration = configuration;
292
293    // unbox the parameters
294
295
296    let local_var_client = &local_var_configuration.client;
297
298    let local_var_uri_str = format!("{}/rest/api/2/field", local_var_configuration.base_path);
299    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
300
301    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
302        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
303    }
304    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
305        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
306    };
307    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
308        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
309    };
310
311    let local_var_req = local_var_req_builder.build()?;
312    let local_var_resp = local_var_client.execute(local_var_req).await?;
313
314    let local_var_status = local_var_resp.status();
315    let local_var_content = local_var_resp.text().await?;
316
317    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
318        serde_json::from_str(&local_var_content).map_err(Error::from)
319    } else {
320        let local_var_entity: Option<GetFieldsError> = serde_json::from_str(&local_var_content).ok();
321        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
322        Err(Error::ResponseError(local_var_error))
323    }
324}
325
326/// Returns a [paginated](#pagination) list of fields for Classic Jira projects. The list can include:   *  all fields.  *  specific fields, by defining `id`.  *  fields that contain a string in the field name or description, by defining `query`.  *  specific fields that contain a string in the field name or description, by defining `id` and `query`.  Only custom fields can be queried, `type` must be set to `custom`.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
327pub async fn get_fields_paginated(configuration: &configuration::Configuration, params: GetFieldsPaginatedParams) -> Result<crate::models::PageBeanField, Error<GetFieldsPaginatedError>> {
328    let local_var_configuration = configuration;
329
330    // unbox the parameters
331    let start_at = params.start_at;
332    let max_results = params.max_results;
333    let _type = params._type;
334    let id = params.id;
335    let query = params.query;
336    let order_by = params.order_by;
337    let expand = params.expand;
338
339
340    let local_var_client = &local_var_configuration.client;
341
342    let local_var_uri_str = format!("{}/rest/api/2/field/search", local_var_configuration.base_path);
343    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
344
345    if let Some(ref local_var_str) = start_at {
346        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
347    }
348    if let Some(ref local_var_str) = max_results {
349        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
350    }
351    if let Some(ref local_var_str) = _type {
352        local_var_req_builder = match "multi" {
353            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("type".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
354            _ => local_var_req_builder.query(&[("type", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
355        };
356    }
357    if let Some(ref local_var_str) = id {
358        local_var_req_builder = match "multi" {
359            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("id".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
360            _ => local_var_req_builder.query(&[("id", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
361        };
362    }
363    if let Some(ref local_var_str) = query {
364        local_var_req_builder = local_var_req_builder.query(&[("query", &local_var_str.to_string())]);
365    }
366    if let Some(ref local_var_str) = order_by {
367        local_var_req_builder = local_var_req_builder.query(&[("orderBy", &local_var_str.to_string())]);
368    }
369    if let Some(ref local_var_str) = expand {
370        local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
371    }
372    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
373        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
374    }
375    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
376        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
377    };
378    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
379        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
380    };
381
382    let local_var_req = local_var_req_builder.build()?;
383    let local_var_resp = local_var_client.execute(local_var_req).await?;
384
385    let local_var_status = local_var_resp.status();
386    let local_var_content = local_var_resp.text().await?;
387
388    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
389        serde_json::from_str(&local_var_content).map_err(Error::from)
390    } else {
391        let local_var_entity: Option<GetFieldsPaginatedError> = serde_json::from_str(&local_var_content).ok();
392        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
393        Err(Error::ResponseError(local_var_error))
394    }
395}
396
397/// Restores a custom field from trash. See [Edit or delete a custom field](https://confluence.atlassian.com/x/Z44fOw) for more information on trashing and deleting custom fields.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
398pub async fn restore_custom_field(configuration: &configuration::Configuration, params: RestoreCustomFieldParams) -> Result<serde_json::Value, Error<RestoreCustomFieldError>> {
399    let local_var_configuration = configuration;
400
401    // unbox the parameters
402    let id = params.id;
403
404
405    let local_var_client = &local_var_configuration.client;
406
407    let local_var_uri_str = format!("{}/rest/api/2/field/{id}/restore", local_var_configuration.base_path, id=crate::apis::urlencode(id));
408    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
409
410    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
411        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
412    }
413    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
414        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
415    };
416    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
417        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
418    };
419
420    let local_var_req = local_var_req_builder.build()?;
421    let local_var_resp = local_var_client.execute(local_var_req).await?;
422
423    let local_var_status = local_var_resp.status();
424    let local_var_content = local_var_resp.text().await?;
425
426    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
427        serde_json::from_str(&local_var_content).map_err(Error::from)
428    } else {
429        let local_var_entity: Option<RestoreCustomFieldError> = serde_json::from_str(&local_var_content).ok();
430        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
431        Err(Error::ResponseError(local_var_error))
432    }
433}
434
435/// Moves a custom field to trash. See [Edit or delete a custom field](https://confluence.atlassian.com/x/Z44fOw) for more information on trashing and deleting custom fields.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
436pub async fn trash_custom_field(configuration: &configuration::Configuration, params: TrashCustomFieldParams) -> Result<serde_json::Value, Error<TrashCustomFieldError>> {
437    let local_var_configuration = configuration;
438
439    // unbox the parameters
440    let id = params.id;
441
442
443    let local_var_client = &local_var_configuration.client;
444
445    let local_var_uri_str = format!("{}/rest/api/2/field/{id}/trash", local_var_configuration.base_path, id=crate::apis::urlencode(id));
446    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
447
448    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
449        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
450    }
451    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
452        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
453    };
454    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
455        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
456    };
457
458    let local_var_req = local_var_req_builder.build()?;
459    let local_var_resp = local_var_client.execute(local_var_req).await?;
460
461    let local_var_status = local_var_resp.status();
462    let local_var_content = local_var_resp.text().await?;
463
464    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
465        serde_json::from_str(&local_var_content).map_err(Error::from)
466    } else {
467        let local_var_entity: Option<TrashCustomFieldError> = serde_json::from_str(&local_var_content).ok();
468        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
469        Err(Error::ResponseError(local_var_error))
470    }
471}
472
473/// Updates a custom field.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
474pub async fn update_custom_field(configuration: &configuration::Configuration, params: UpdateCustomFieldParams) -> Result<serde_json::Value, Error<UpdateCustomFieldError>> {
475    let local_var_configuration = configuration;
476
477    // unbox the parameters
478    let field_id = params.field_id;
479    let update_custom_field_details = params.update_custom_field_details;
480
481
482    let local_var_client = &local_var_configuration.client;
483
484    let local_var_uri_str = format!("{}/rest/api/2/field/{fieldId}", local_var_configuration.base_path, fieldId=crate::apis::urlencode(field_id));
485    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
486
487    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
488        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
489    }
490    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
491        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
492    };
493    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
494        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
495    };
496    local_var_req_builder = local_var_req_builder.json(&update_custom_field_details);
497
498    let local_var_req = local_var_req_builder.build()?;
499    let local_var_resp = local_var_client.execute(local_var_req).await?;
500
501    let local_var_status = local_var_resp.status();
502    let local_var_content = local_var_resp.text().await?;
503
504    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
505        serde_json::from_str(&local_var_content).map_err(Error::from)
506    } else {
507        let local_var_entity: Option<UpdateCustomFieldError> = serde_json::from_str(&local_var_content).ok();
508        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
509        Err(Error::ResponseError(local_var_error))
510    }
511}
512