hi_jira2/apis/
issue_custom_field_options_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_option`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateCustomFieldOptionParams {
20    /// The ID of the custom field.
21    pub field_id: String,
22    /// The ID of the context.
23    pub context_id: i64,
24    pub bulk_custom_field_option_create_request: crate::models::BulkCustomFieldOptionCreateRequest
25}
26
27/// struct for passing parameters to the method [`delete_custom_field_option`]
28#[derive(Clone, Debug, Default)]
29pub struct DeleteCustomFieldOptionParams {
30    /// The ID of the custom field.
31    pub field_id: String,
32    /// The ID of the context from which an option should be deleted.
33    pub context_id: i64,
34    /// The ID of the option to delete.
35    pub option_id: i64
36}
37
38/// struct for passing parameters to the method [`get_custom_field_option`]
39#[derive(Clone, Debug, Default)]
40pub struct GetCustomFieldOptionParams {
41    /// The ID of the custom field option.
42    pub id: String
43}
44
45/// struct for passing parameters to the method [`get_options_for_context`]
46#[derive(Clone, Debug, Default)]
47pub struct GetOptionsForContextParams {
48    /// The ID of the custom field.
49    pub field_id: String,
50    /// The ID of the context.
51    pub context_id: i64,
52    /// The ID of the option.
53    pub option_id: Option<i64>,
54    /// Whether only options are returned.
55    pub only_options: Option<bool>,
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}
61
62/// struct for passing parameters to the method [`reorder_custom_field_options`]
63#[derive(Clone, Debug, Default)]
64pub struct ReorderCustomFieldOptionsParams {
65    /// The ID of the custom field.
66    pub field_id: String,
67    /// The ID of the context.
68    pub context_id: i64,
69    pub order_of_custom_field_options: crate::models::OrderOfCustomFieldOptions
70}
71
72/// struct for passing parameters to the method [`update_custom_field_option`]
73#[derive(Clone, Debug, Default)]
74pub struct UpdateCustomFieldOptionParams {
75    /// The ID of the custom field.
76    pub field_id: String,
77    /// The ID of the context.
78    pub context_id: i64,
79    pub bulk_custom_field_option_update_request: crate::models::BulkCustomFieldOptionUpdateRequest
80}
81
82
83/// struct for typed errors of method [`create_custom_field_option`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum CreateCustomFieldOptionError {
87    Status400(),
88    Status401(),
89    Status403(),
90    Status404(),
91    UnknownValue(serde_json::Value),
92}
93
94/// struct for typed errors of method [`delete_custom_field_option`]
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum DeleteCustomFieldOptionError {
98    Status400(),
99    Status401(),
100    Status403(),
101    Status404(),
102    UnknownValue(serde_json::Value),
103}
104
105/// struct for typed errors of method [`get_custom_field_option`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum GetCustomFieldOptionError {
109    Status401(),
110    Status404(),
111    UnknownValue(serde_json::Value),
112}
113
114/// struct for typed errors of method [`get_options_for_context`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum GetOptionsForContextError {
118    Status400(),
119    Status401(),
120    Status403(),
121    Status404(),
122    UnknownValue(serde_json::Value),
123}
124
125/// struct for typed errors of method [`reorder_custom_field_options`]
126#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum ReorderCustomFieldOptionsError {
129    Status400(),
130    Status401(),
131    Status403(),
132    Status404(),
133    UnknownValue(serde_json::Value),
134}
135
136/// struct for typed errors of method [`update_custom_field_option`]
137#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum UpdateCustomFieldOptionError {
140    Status400(),
141    Status401(),
142    Status403(),
143    Status404(),
144    UnknownValue(serde_json::Value),
145}
146
147
148/// Creates options and, where the custom select field is of the type Select List (cascading), cascading options for a custom select field. The options are added to a context of the field.  The maximum number of options that can be created per request is 1000 and each field can have a maximum of 10000 options.  This operation works for custom field options created in Jira or the operations from this resource. **To work with issue field select list options created for Connect apps use the [Issue custom field options (apps)](#api-group-issue-custom-field-options--apps-) operations.**  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
149pub async fn create_custom_field_option(configuration: &configuration::Configuration, params: CreateCustomFieldOptionParams) -> Result<crate::models::CustomFieldCreatedContextOptionsList, Error<CreateCustomFieldOptionError>> {
150    let local_var_configuration = configuration;
151
152    // unbox the parameters
153    let field_id = params.field_id;
154    let context_id = params.context_id;
155    let bulk_custom_field_option_create_request = params.bulk_custom_field_option_create_request;
156
157
158    let local_var_client = &local_var_configuration.client;
159
160    let local_var_uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/option", local_var_configuration.base_path, fieldId=crate::apis::urlencode(field_id), contextId=context_id);
161    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
162
163    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
164        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
165    }
166    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
167        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
168    };
169    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
170        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
171    };
172    local_var_req_builder = local_var_req_builder.json(&bulk_custom_field_option_create_request);
173
174    let local_var_req = local_var_req_builder.build()?;
175    let local_var_resp = local_var_client.execute(local_var_req).await?;
176
177    let local_var_status = local_var_resp.status();
178    let local_var_content = local_var_resp.text().await?;
179
180    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
181        serde_json::from_str(&local_var_content).map_err(Error::from)
182    } else {
183        let local_var_entity: Option<CreateCustomFieldOptionError> = serde_json::from_str(&local_var_content).ok();
184        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
185        Err(Error::ResponseError(local_var_error))
186    }
187}
188
189/// Deletes a custom field option.  Options with cascading options cannot be deleted without deleting the cascading options first.  This operation works for custom field options created in Jira or the operations from this resource. **To work with issue field select list options created for Connect apps use the [Issue custom field options (apps)](#api-group-issue-custom-field-options--apps-) operations.**  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
190pub async fn delete_custom_field_option(configuration: &configuration::Configuration, params: DeleteCustomFieldOptionParams) -> Result<(), Error<DeleteCustomFieldOptionError>> {
191    let local_var_configuration = configuration;
192
193    // unbox the parameters
194    let field_id = params.field_id;
195    let context_id = params.context_id;
196    let option_id = params.option_id;
197
198
199    let local_var_client = &local_var_configuration.client;
200
201    let local_var_uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/option/{optionId}", local_var_configuration.base_path, fieldId=crate::apis::urlencode(field_id), contextId=context_id, optionId=option_id);
202    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
203
204    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
205        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206    }
207    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
208        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209    };
210    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
211        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
212    };
213
214    let local_var_req = local_var_req_builder.build()?;
215    let local_var_resp = local_var_client.execute(local_var_req).await?;
216
217    let local_var_status = local_var_resp.status();
218    let local_var_content = local_var_resp.text().await?;
219
220    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
221        Ok(())
222    } else {
223        let local_var_entity: Option<DeleteCustomFieldOptionError> = serde_json::from_str(&local_var_content).ok();
224        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
225        Err(Error::ResponseError(local_var_error))
226    }
227}
228
229/// Returns a custom field option. For example, an option in a select list.  Note that this operation **only works for issue field select list options created in Jira or using operations from the [Issue custom field options](#api-group-Issue-custom-field-options) resource**, it cannot be used with issue field select list options created by Connect apps.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** The custom field option is returned as follows:   *  if the user has the *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).  *  if the user has the *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for at least one project the custom field is used in, and the field is visible in at least one layout the user has permission to view.
230pub async fn get_custom_field_option(configuration: &configuration::Configuration, params: GetCustomFieldOptionParams) -> Result<crate::models::CustomFieldOption, Error<GetCustomFieldOptionError>> {
231    let local_var_configuration = configuration;
232
233    // unbox the parameters
234    let id = params.id;
235
236
237    let local_var_client = &local_var_configuration.client;
238
239    let local_var_uri_str = format!("{}/rest/api/2/customFieldOption/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
240    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
241
242    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
243        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
244    }
245    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
246        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
247    };
248    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
249        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
250    };
251
252    let local_var_req = local_var_req_builder.build()?;
253    let local_var_resp = local_var_client.execute(local_var_req).await?;
254
255    let local_var_status = local_var_resp.status();
256    let local_var_content = local_var_resp.text().await?;
257
258    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
259        serde_json::from_str(&local_var_content).map_err(Error::from)
260    } else {
261        let local_var_entity: Option<GetCustomFieldOptionError> = serde_json::from_str(&local_var_content).ok();
262        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
263        Err(Error::ResponseError(local_var_error))
264    }
265}
266
267/// Returns a [paginated](#pagination) list of all custom field option for a context. Options are returned first then cascading options, in the order they display in Jira.  This operation works for custom field options created in Jira or the operations from this resource. **To work with issue field select list options created for Connect apps use the [Issue custom field options (apps)](#api-group-issue-custom-field-options--apps-) operations.**  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
268pub async fn get_options_for_context(configuration: &configuration::Configuration, params: GetOptionsForContextParams) -> Result<crate::models::PageBeanCustomFieldContextOption, Error<GetOptionsForContextError>> {
269    let local_var_configuration = configuration;
270
271    // unbox the parameters
272    let field_id = params.field_id;
273    let context_id = params.context_id;
274    let option_id = params.option_id;
275    let only_options = params.only_options;
276    let start_at = params.start_at;
277    let max_results = params.max_results;
278
279
280    let local_var_client = &local_var_configuration.client;
281
282    let local_var_uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/option", local_var_configuration.base_path, fieldId=crate::apis::urlencode(field_id), contextId=context_id);
283    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
284
285    if let Some(ref local_var_str) = option_id {
286        local_var_req_builder = local_var_req_builder.query(&[("optionId", &local_var_str.to_string())]);
287    }
288    if let Some(ref local_var_str) = only_options {
289        local_var_req_builder = local_var_req_builder.query(&[("onlyOptions", &local_var_str.to_string())]);
290    }
291    if let Some(ref local_var_str) = start_at {
292        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
293    }
294    if let Some(ref local_var_str) = max_results {
295        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
296    }
297    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
298        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
299    }
300    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
301        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
302    };
303    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
304        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
305    };
306
307    let local_var_req = local_var_req_builder.build()?;
308    let local_var_resp = local_var_client.execute(local_var_req).await?;
309
310    let local_var_status = local_var_resp.status();
311    let local_var_content = local_var_resp.text().await?;
312
313    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
314        serde_json::from_str(&local_var_content).map_err(Error::from)
315    } else {
316        let local_var_entity: Option<GetOptionsForContextError> = serde_json::from_str(&local_var_content).ok();
317        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
318        Err(Error::ResponseError(local_var_error))
319    }
320}
321
322/// Changes the order of custom field options or cascading options in a context.  This operation works for custom field options created in Jira or the operations from this resource. **To work with issue field select list options created for Connect apps use the [Issue custom field options (apps)](#api-group-issue-custom-field-options--apps-) operations.**  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
323pub async fn reorder_custom_field_options(configuration: &configuration::Configuration, params: ReorderCustomFieldOptionsParams) -> Result<serde_json::Value, Error<ReorderCustomFieldOptionsError>> {
324    let local_var_configuration = configuration;
325
326    // unbox the parameters
327    let field_id = params.field_id;
328    let context_id = params.context_id;
329    let order_of_custom_field_options = params.order_of_custom_field_options;
330
331
332    let local_var_client = &local_var_configuration.client;
333
334    let local_var_uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/option/move", local_var_configuration.base_path, fieldId=crate::apis::urlencode(field_id), contextId=context_id);
335    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
336
337    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
338        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
339    }
340    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
341        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
342    };
343    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
344        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
345    };
346    local_var_req_builder = local_var_req_builder.json(&order_of_custom_field_options);
347
348    let local_var_req = local_var_req_builder.build()?;
349    let local_var_resp = local_var_client.execute(local_var_req).await?;
350
351    let local_var_status = local_var_resp.status();
352    let local_var_content = local_var_resp.text().await?;
353
354    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
355        serde_json::from_str(&local_var_content).map_err(Error::from)
356    } else {
357        let local_var_entity: Option<ReorderCustomFieldOptionsError> = serde_json::from_str(&local_var_content).ok();
358        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
359        Err(Error::ResponseError(local_var_error))
360    }
361}
362
363/// Updates the options of a custom field.  If any of the options are not found, no options are updated. Options where the values in the request match the current values aren't updated and aren't reported in the response.  Note that this operation **only works for issue field select list options created in Jira or using operations from the [Issue custom field options](#api-group-Issue-custom-field-options) resource**, it cannot be used with issue field select list options created by Connect apps.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
364pub async fn update_custom_field_option(configuration: &configuration::Configuration, params: UpdateCustomFieldOptionParams) -> Result<crate::models::CustomFieldUpdatedContextOptionsList, Error<UpdateCustomFieldOptionError>> {
365    let local_var_configuration = configuration;
366
367    // unbox the parameters
368    let field_id = params.field_id;
369    let context_id = params.context_id;
370    let bulk_custom_field_option_update_request = params.bulk_custom_field_option_update_request;
371
372
373    let local_var_client = &local_var_configuration.client;
374
375    let local_var_uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/option", local_var_configuration.base_path, fieldId=crate::apis::urlencode(field_id), contextId=context_id);
376    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
377
378    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
379        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
380    }
381    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
382        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
383    };
384    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
385        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
386    };
387    local_var_req_builder = local_var_req_builder.json(&bulk_custom_field_option_update_request);
388
389    let local_var_req = local_var_req_builder.build()?;
390    let local_var_resp = local_var_client.execute(local_var_req).await?;
391
392    let local_var_status = local_var_resp.status();
393    let local_var_content = local_var_resp.text().await?;
394
395    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
396        serde_json::from_str(&local_var_content).map_err(Error::from)
397    } else {
398        let local_var_entity: Option<UpdateCustomFieldOptionError> = serde_json::from_str(&local_var_content).ok();
399        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
400        Err(Error::ResponseError(local_var_error))
401    }
402}
403