jira_api_v2/apis/
issue_custom_field_contexts_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 [`add_issue_types_to_context`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddIssueTypesToContextError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    Status409(),
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`assign_projects_to_custom_field_context`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum AssignProjectsToCustomFieldContextError {
34    Status400(),
35    Status401(),
36    Status403(),
37    Status404(),
38    UnknownValue(serde_json::Value),
39}
40
41/// struct for typed errors of method [`create_custom_field_context`]
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum CreateCustomFieldContextError {
45    Status400(),
46    Status401(),
47    Status404(),
48    Status409(),
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`delete_custom_field_context`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum DeleteCustomFieldContextError {
56    Status400(),
57    Status401(),
58    Status403(),
59    Status404(),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`get_contexts_for_field`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum GetContextsForFieldError {
67    Status401(),
68    Status403(),
69    Status404(),
70    UnknownValue(serde_json::Value),
71}
72
73/// struct for typed errors of method [`get_custom_field_contexts_for_projects_and_issue_types`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum GetCustomFieldContextsForProjectsAndIssueTypesError {
77    Status400(),
78    Status401(),
79    Status403(),
80    Status404(),
81    UnknownValue(serde_json::Value),
82}
83
84/// struct for typed errors of method [`get_default_values`]
85#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum GetDefaultValuesError {
88    Status401(),
89    Status403(),
90    Status404(),
91    UnknownValue(serde_json::Value),
92}
93
94/// struct for typed errors of method [`get_issue_type_mappings_for_contexts`]
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum GetIssueTypeMappingsForContextsError {
98    Status401(),
99    Status403(),
100    UnknownValue(serde_json::Value),
101}
102
103/// struct for typed errors of method [`get_project_context_mapping`]
104#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum GetProjectContextMappingError {
107    Status401(),
108    Status403(),
109    Status404(),
110    UnknownValue(serde_json::Value),
111}
112
113/// struct for typed errors of method [`remove_custom_field_context_from_projects`]
114#[derive(Debug, Clone, Serialize, Deserialize)]
115#[serde(untagged)]
116pub enum RemoveCustomFieldContextFromProjectsError {
117    Status400(),
118    Status401(),
119    Status403(),
120    Status404(),
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`remove_issue_types_from_context`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum RemoveIssueTypesFromContextError {
128    Status400(),
129    Status401(),
130    Status403(),
131    Status404(),
132    UnknownValue(serde_json::Value),
133}
134
135/// struct for typed errors of method [`set_default_values`]
136#[derive(Debug, Clone, Serialize, Deserialize)]
137#[serde(untagged)]
138pub enum SetDefaultValuesError {
139    Status400(),
140    Status401(),
141    Status403(),
142    Status404(),
143    UnknownValue(serde_json::Value),
144}
145
146/// struct for typed errors of method [`update_custom_field_context`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum UpdateCustomFieldContextError {
150    Status400(),
151    Status401(),
152    Status403(),
153    Status404(),
154    UnknownValue(serde_json::Value),
155}
156
157
158/// Adds issue types to a custom field context, appending the issue types to the issue types list.  A custom field context without any issue types applies to all issue types. Adding issue types to such a custom field context would result in it applying to only the listed issue types.  If any of the issue types exists in the custom field context, the operation fails and no issue types are added.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
159pub async fn add_issue_types_to_context(configuration: &configuration::Configuration, field_id: &str, context_id: i64, issue_type_ids: models::IssueTypeIds) -> Result<serde_json::Value, Error<AddIssueTypesToContextError>> {
160    // add a prefix to parameters to efficiently prevent name collisions
161    let p_field_id = field_id;
162    let p_context_id = context_id;
163    let p_issue_type_ids = issue_type_ids;
164
165    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/issuetype", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id), contextId=p_context_id);
166    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
167
168    if let Some(ref user_agent) = configuration.user_agent {
169        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
170    }
171    if let Some(ref token) = configuration.oauth_access_token {
172        req_builder = req_builder.bearer_auth(token.to_owned());
173    };
174    if let Some(ref auth_conf) = configuration.basic_auth {
175        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
176    };
177    req_builder = req_builder.json(&p_issue_type_ids);
178
179    let req = req_builder.build()?;
180    let resp = configuration.client.execute(req).await?;
181
182    let status = resp.status();
183
184    if !status.is_client_error() && !status.is_server_error() {
185        let content = resp.text().await?;
186        serde_json::from_str(&content).map_err(Error::from)
187    } else {
188        let content = resp.text().await?;
189        let entity: Option<AddIssueTypesToContextError> = serde_json::from_str(&content).ok();
190        Err(Error::ResponseError(ResponseContent { status, content, entity }))
191    }
192}
193
194/// Assigns a custom field context to projects.  If any project in the request is assigned to any context of the custom field, the operation fails.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
195pub async fn assign_projects_to_custom_field_context(configuration: &configuration::Configuration, field_id: &str, context_id: i64, project_ids: models::ProjectIds) -> Result<serde_json::Value, Error<AssignProjectsToCustomFieldContextError>> {
196    // add a prefix to parameters to efficiently prevent name collisions
197    let p_field_id = field_id;
198    let p_context_id = context_id;
199    let p_project_ids = project_ids;
200
201    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/project", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id), contextId=p_context_id);
202    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
203
204    if let Some(ref user_agent) = configuration.user_agent {
205        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
206    }
207    if let Some(ref token) = configuration.oauth_access_token {
208        req_builder = req_builder.bearer_auth(token.to_owned());
209    };
210    if let Some(ref auth_conf) = configuration.basic_auth {
211        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
212    };
213    req_builder = req_builder.json(&p_project_ids);
214
215    let req = req_builder.build()?;
216    let resp = configuration.client.execute(req).await?;
217
218    let status = resp.status();
219
220    if !status.is_client_error() && !status.is_server_error() {
221        let content = resp.text().await?;
222        serde_json::from_str(&content).map_err(Error::from)
223    } else {
224        let content = resp.text().await?;
225        let entity: Option<AssignProjectsToCustomFieldContextError> = serde_json::from_str(&content).ok();
226        Err(Error::ResponseError(ResponseContent { status, content, entity }))
227    }
228}
229
230/// Creates a custom field context.  If `projectIds` is empty, a global context is created. A global context is one that applies to all project. If `issueTypeIds` is empty, the context applies to all issue types.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
231pub async fn create_custom_field_context(configuration: &configuration::Configuration, field_id: &str, create_custom_field_context: models::CreateCustomFieldContext) -> Result<models::CreateCustomFieldContext, Error<CreateCustomFieldContextError>> {
232    // add a prefix to parameters to efficiently prevent name collisions
233    let p_field_id = field_id;
234    let p_create_custom_field_context = create_custom_field_context;
235
236    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id));
237    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
238
239    if let Some(ref user_agent) = configuration.user_agent {
240        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
241    }
242    if let Some(ref token) = configuration.oauth_access_token {
243        req_builder = req_builder.bearer_auth(token.to_owned());
244    };
245    if let Some(ref auth_conf) = configuration.basic_auth {
246        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
247    };
248    req_builder = req_builder.json(&p_create_custom_field_context);
249
250    let req = req_builder.build()?;
251    let resp = configuration.client.execute(req).await?;
252
253    let status = resp.status();
254
255    if !status.is_client_error() && !status.is_server_error() {
256        let content = resp.text().await?;
257        serde_json::from_str(&content).map_err(Error::from)
258    } else {
259        let content = resp.text().await?;
260        let entity: Option<CreateCustomFieldContextError> = serde_json::from_str(&content).ok();
261        Err(Error::ResponseError(ResponseContent { status, content, entity }))
262    }
263}
264
265/// Deletes a [ custom field context](https://confluence.atlassian.com/adminjiracloud/what-are-custom-field-contexts-991923859.html).  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
266pub async fn delete_custom_field_context(configuration: &configuration::Configuration, field_id: &str, context_id: i64) -> Result<serde_json::Value, Error<DeleteCustomFieldContextError>> {
267    // add a prefix to parameters to efficiently prevent name collisions
268    let p_field_id = field_id;
269    let p_context_id = context_id;
270
271    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id), contextId=p_context_id);
272    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
273
274    if let Some(ref user_agent) = configuration.user_agent {
275        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
276    }
277    if let Some(ref token) = configuration.oauth_access_token {
278        req_builder = req_builder.bearer_auth(token.to_owned());
279    };
280    if let Some(ref auth_conf) = configuration.basic_auth {
281        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
282    };
283
284    let req = req_builder.build()?;
285    let resp = configuration.client.execute(req).await?;
286
287    let status = resp.status();
288
289    if !status.is_client_error() && !status.is_server_error() {
290        let content = resp.text().await?;
291        serde_json::from_str(&content).map_err(Error::from)
292    } else {
293        let content = resp.text().await?;
294        let entity: Option<DeleteCustomFieldContextError> = serde_json::from_str(&content).ok();
295        Err(Error::ResponseError(ResponseContent { status, content, entity }))
296    }
297}
298
299/// Returns a [paginated](#pagination) list of [ contexts](https://confluence.atlassian.com/adminjiracloud/what-are-custom-field-contexts-991923859.html) for a custom field. Contexts can be returned as follows:   *  With no other parameters set, all contexts.  *  By defining `id` only, all contexts from the list of IDs.  *  By defining `isAnyIssueType`, limit the list of contexts returned to either those that apply to all issue types (true) or those that apply to only a subset of issue types (false)  *  By defining `isGlobalContext`, limit the list of contexts return to either those that apply to all projects (global contexts) (true) or those that apply to only a subset of projects (false).  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
300pub async fn get_contexts_for_field(configuration: &configuration::Configuration, field_id: &str, is_any_issue_type: Option<bool>, is_global_context: Option<bool>, context_id: Option<Vec<i64>>, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanCustomFieldContext, Error<GetContextsForFieldError>> {
301    // add a prefix to parameters to efficiently prevent name collisions
302    let p_field_id = field_id;
303    let p_is_any_issue_type = is_any_issue_type;
304    let p_is_global_context = is_global_context;
305    let p_context_id = context_id;
306    let p_start_at = start_at;
307    let p_max_results = max_results;
308
309    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id));
310    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
311
312    if let Some(ref param_value) = p_is_any_issue_type {
313        req_builder = req_builder.query(&[("isAnyIssueType", &param_value.to_string())]);
314    }
315    if let Some(ref param_value) = p_is_global_context {
316        req_builder = req_builder.query(&[("isGlobalContext", &param_value.to_string())]);
317    }
318    if let Some(ref param_value) = p_context_id {
319        req_builder = match "multi" {
320            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("contextId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
321            _ => req_builder.query(&[("contextId", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
322        };
323    }
324    if let Some(ref param_value) = p_start_at {
325        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
326    }
327    if let Some(ref param_value) = p_max_results {
328        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
329    }
330    if let Some(ref user_agent) = configuration.user_agent {
331        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
332    }
333    if let Some(ref token) = configuration.oauth_access_token {
334        req_builder = req_builder.bearer_auth(token.to_owned());
335    };
336    if let Some(ref auth_conf) = configuration.basic_auth {
337        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
338    };
339
340    let req = req_builder.build()?;
341    let resp = configuration.client.execute(req).await?;
342
343    let status = resp.status();
344
345    if !status.is_client_error() && !status.is_server_error() {
346        let content = resp.text().await?;
347        serde_json::from_str(&content).map_err(Error::from)
348    } else {
349        let content = resp.text().await?;
350        let entity: Option<GetContextsForFieldError> = serde_json::from_str(&content).ok();
351        Err(Error::ResponseError(ResponseContent { status, content, entity }))
352    }
353}
354
355/// Returns a [paginated](#pagination) list of project and issue type mappings and, for each mapping, the ID of a [custom field context](https://confluence.atlassian.com/x/k44fOw) that applies to the project and issue type.  If there is no custom field context assigned to the project then, if present, the custom field context that applies to all projects is returned if it also applies to the issue type or all issue types. If a custom field context is not found, the returned custom field context ID is `null`.  Duplicate project and issue type mappings cannot be provided in the request.  The order of the returned values is the same as provided in the request.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
356pub async fn get_custom_field_contexts_for_projects_and_issue_types(configuration: &configuration::Configuration, field_id: &str, project_issue_type_mappings: models::ProjectIssueTypeMappings, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanContextForProjectAndIssueType, Error<GetCustomFieldContextsForProjectsAndIssueTypesError>> {
357    // add a prefix to parameters to efficiently prevent name collisions
358    let p_field_id = field_id;
359    let p_project_issue_type_mappings = project_issue_type_mappings;
360    let p_start_at = start_at;
361    let p_max_results = max_results;
362
363    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/mapping", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id));
364    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
365
366    if let Some(ref param_value) = p_start_at {
367        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
368    }
369    if let Some(ref param_value) = p_max_results {
370        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
371    }
372    if let Some(ref user_agent) = configuration.user_agent {
373        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
374    }
375    if let Some(ref token) = configuration.oauth_access_token {
376        req_builder = req_builder.bearer_auth(token.to_owned());
377    };
378    if let Some(ref auth_conf) = configuration.basic_auth {
379        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
380    };
381    req_builder = req_builder.json(&p_project_issue_type_mappings);
382
383    let req = req_builder.build()?;
384    let resp = configuration.client.execute(req).await?;
385
386    let status = resp.status();
387
388    if !status.is_client_error() && !status.is_server_error() {
389        let content = resp.text().await?;
390        serde_json::from_str(&content).map_err(Error::from)
391    } else {
392        let content = resp.text().await?;
393        let entity: Option<GetCustomFieldContextsForProjectsAndIssueTypesError> = serde_json::from_str(&content).ok();
394        Err(Error::ResponseError(ResponseContent { status, content, entity }))
395    }
396}
397
398/// Returns a [paginated](#pagination) list of defaults for a custom field. The results can be filtered by `contextId`, otherwise all values are returned. If no defaults are set for a context, nothing is returned.   The returned object depends on type of the custom field:   *  `CustomFieldContextDefaultValueSingleOption` (type `option.single`) for single choice select lists and radio buttons.  *  `CustomFieldContextDefaultValueMultipleOption` (type `option.multiple`) for multiple choice select lists and checkboxes.  *  `CustomFieldContextDefaultValueCascadingOption` (type `option.cascading`) for cascading select lists.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
399pub async fn get_default_values(configuration: &configuration::Configuration, field_id: &str, context_id: Option<Vec<i64>>, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanCustomFieldContextDefaultValue, Error<GetDefaultValuesError>> {
400    // add a prefix to parameters to efficiently prevent name collisions
401    let p_field_id = field_id;
402    let p_context_id = context_id;
403    let p_start_at = start_at;
404    let p_max_results = max_results;
405
406    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/defaultValue", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id));
407    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
408
409    if let Some(ref param_value) = p_context_id {
410        req_builder = match "multi" {
411            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("contextId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
412            _ => req_builder.query(&[("contextId", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
413        };
414    }
415    if let Some(ref param_value) = p_start_at {
416        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
417    }
418    if let Some(ref param_value) = p_max_results {
419        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
420    }
421    if let Some(ref user_agent) = configuration.user_agent {
422        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
423    }
424    if let Some(ref token) = configuration.oauth_access_token {
425        req_builder = req_builder.bearer_auth(token.to_owned());
426    };
427    if let Some(ref auth_conf) = configuration.basic_auth {
428        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
429    };
430
431    let req = req_builder.build()?;
432    let resp = configuration.client.execute(req).await?;
433
434    let status = resp.status();
435
436    if !status.is_client_error() && !status.is_server_error() {
437        let content = resp.text().await?;
438        serde_json::from_str(&content).map_err(Error::from)
439    } else {
440        let content = resp.text().await?;
441        let entity: Option<GetDefaultValuesError> = serde_json::from_str(&content).ok();
442        Err(Error::ResponseError(ResponseContent { status, content, entity }))
443    }
444}
445
446/// Returns a [paginated](#pagination) list of context to issue type mappings for a custom field. Mappings are returned for all contexts or a list of contexts. Mappings are ordered first by context ID and then by issue type ID.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
447pub async fn get_issue_type_mappings_for_contexts(configuration: &configuration::Configuration, field_id: &str, context_id: Option<Vec<i64>>, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanIssueTypeToContextMapping, Error<GetIssueTypeMappingsForContextsError>> {
448    // add a prefix to parameters to efficiently prevent name collisions
449    let p_field_id = field_id;
450    let p_context_id = context_id;
451    let p_start_at = start_at;
452    let p_max_results = max_results;
453
454    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/issuetypemapping", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id));
455    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
456
457    if let Some(ref param_value) = p_context_id {
458        req_builder = match "multi" {
459            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("contextId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
460            _ => req_builder.query(&[("contextId", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
461        };
462    }
463    if let Some(ref param_value) = p_start_at {
464        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
465    }
466    if let Some(ref param_value) = p_max_results {
467        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
468    }
469    if let Some(ref user_agent) = configuration.user_agent {
470        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
471    }
472    if let Some(ref token) = configuration.oauth_access_token {
473        req_builder = req_builder.bearer_auth(token.to_owned());
474    };
475    if let Some(ref auth_conf) = configuration.basic_auth {
476        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
477    };
478
479    let req = req_builder.build()?;
480    let resp = configuration.client.execute(req).await?;
481
482    let status = resp.status();
483
484    if !status.is_client_error() && !status.is_server_error() {
485        let content = resp.text().await?;
486        serde_json::from_str(&content).map_err(Error::from)
487    } else {
488        let content = resp.text().await?;
489        let entity: Option<GetIssueTypeMappingsForContextsError> = serde_json::from_str(&content).ok();
490        Err(Error::ResponseError(ResponseContent { status, content, entity }))
491    }
492}
493
494/// Returns a [paginated](#pagination) list of context to project mappings for a custom field. The result can be filtered by `contextId`, or otherwise all mappings are returned. Invalid IDs are ignored.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
495pub async fn get_project_context_mapping(configuration: &configuration::Configuration, field_id: &str, context_id: Option<Vec<i64>>, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanCustomFieldContextProjectMapping, Error<GetProjectContextMappingError>> {
496    // add a prefix to parameters to efficiently prevent name collisions
497    let p_field_id = field_id;
498    let p_context_id = context_id;
499    let p_start_at = start_at;
500    let p_max_results = max_results;
501
502    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/projectmapping", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id));
503    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
504
505    if let Some(ref param_value) = p_context_id {
506        req_builder = match "multi" {
507            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("contextId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
508            _ => req_builder.query(&[("contextId", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
509        };
510    }
511    if let Some(ref param_value) = p_start_at {
512        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
513    }
514    if let Some(ref param_value) = p_max_results {
515        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
516    }
517    if let Some(ref user_agent) = configuration.user_agent {
518        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
519    }
520    if let Some(ref token) = configuration.oauth_access_token {
521        req_builder = req_builder.bearer_auth(token.to_owned());
522    };
523    if let Some(ref auth_conf) = configuration.basic_auth {
524        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
525    };
526
527    let req = req_builder.build()?;
528    let resp = configuration.client.execute(req).await?;
529
530    let status = resp.status();
531
532    if !status.is_client_error() && !status.is_server_error() {
533        let content = resp.text().await?;
534        serde_json::from_str(&content).map_err(Error::from)
535    } else {
536        let content = resp.text().await?;
537        let entity: Option<GetProjectContextMappingError> = serde_json::from_str(&content).ok();
538        Err(Error::ResponseError(ResponseContent { status, content, entity }))
539    }
540}
541
542/// Removes a custom field context from projects.  A custom field context without any projects applies to all projects. Removing all projects from a custom field context would result in it applying to all projects.  If any project in the request is not assigned to the context, or the operation would result in two global contexts for the field, the operation fails.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
543pub async fn remove_custom_field_context_from_projects(configuration: &configuration::Configuration, field_id: &str, context_id: i64, project_ids: models::ProjectIds) -> Result<serde_json::Value, Error<RemoveCustomFieldContextFromProjectsError>> {
544    // add a prefix to parameters to efficiently prevent name collisions
545    let p_field_id = field_id;
546    let p_context_id = context_id;
547    let p_project_ids = project_ids;
548
549    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/project/remove", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id), contextId=p_context_id);
550    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
551
552    if let Some(ref user_agent) = configuration.user_agent {
553        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
554    }
555    if let Some(ref token) = configuration.oauth_access_token {
556        req_builder = req_builder.bearer_auth(token.to_owned());
557    };
558    if let Some(ref auth_conf) = configuration.basic_auth {
559        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
560    };
561    req_builder = req_builder.json(&p_project_ids);
562
563    let req = req_builder.build()?;
564    let resp = configuration.client.execute(req).await?;
565
566    let status = resp.status();
567
568    if !status.is_client_error() && !status.is_server_error() {
569        let content = resp.text().await?;
570        serde_json::from_str(&content).map_err(Error::from)
571    } else {
572        let content = resp.text().await?;
573        let entity: Option<RemoveCustomFieldContextFromProjectsError> = serde_json::from_str(&content).ok();
574        Err(Error::ResponseError(ResponseContent { status, content, entity }))
575    }
576}
577
578/// Removes issue types from a custom field context.  A custom field context without any issue types applies to all issue types.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
579pub async fn remove_issue_types_from_context(configuration: &configuration::Configuration, field_id: &str, context_id: i64, issue_type_ids: models::IssueTypeIds) -> Result<serde_json::Value, Error<RemoveIssueTypesFromContextError>> {
580    // add a prefix to parameters to efficiently prevent name collisions
581    let p_field_id = field_id;
582    let p_context_id = context_id;
583    let p_issue_type_ids = issue_type_ids;
584
585    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}/issuetype/remove", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id), contextId=p_context_id);
586    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
587
588    if let Some(ref user_agent) = configuration.user_agent {
589        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
590    }
591    if let Some(ref token) = configuration.oauth_access_token {
592        req_builder = req_builder.bearer_auth(token.to_owned());
593    };
594    if let Some(ref auth_conf) = configuration.basic_auth {
595        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
596    };
597    req_builder = req_builder.json(&p_issue_type_ids);
598
599    let req = req_builder.build()?;
600    let resp = configuration.client.execute(req).await?;
601
602    let status = resp.status();
603
604    if !status.is_client_error() && !status.is_server_error() {
605        let content = resp.text().await?;
606        serde_json::from_str(&content).map_err(Error::from)
607    } else {
608        let content = resp.text().await?;
609        let entity: Option<RemoveIssueTypesFromContextError> = serde_json::from_str(&content).ok();
610        Err(Error::ResponseError(ResponseContent { status, content, entity }))
611    }
612}
613
614/// Sets default for contexts of a custom field. Default are defined using these objects:   *  `CustomFieldContextDefaultValueSingleOption` (type `option.single`) for single choice select lists and radio buttons.  *  `CustomFieldContextDefaultValueMultipleOption` (type `option.multiple`) for multiple choice select lists and checkboxes.  *  `CustomFieldContextDefaultValueCascadingOption` (type `option.cascading`) for cascading select lists.  Only one type of default object can be included in a request. To remove a default for a context, set the default parameter to `null`.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
615pub async fn set_default_values(configuration: &configuration::Configuration, field_id: &str, custom_field_context_default_value_update: models::CustomFieldContextDefaultValueUpdate) -> Result<serde_json::Value, Error<SetDefaultValuesError>> {
616    // add a prefix to parameters to efficiently prevent name collisions
617    let p_field_id = field_id;
618    let p_custom_field_context_default_value_update = custom_field_context_default_value_update;
619
620    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/defaultValue", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id));
621    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
622
623    if let Some(ref user_agent) = configuration.user_agent {
624        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
625    }
626    if let Some(ref token) = configuration.oauth_access_token {
627        req_builder = req_builder.bearer_auth(token.to_owned());
628    };
629    if let Some(ref auth_conf) = configuration.basic_auth {
630        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
631    };
632    req_builder = req_builder.json(&p_custom_field_context_default_value_update);
633
634    let req = req_builder.build()?;
635    let resp = configuration.client.execute(req).await?;
636
637    let status = resp.status();
638
639    if !status.is_client_error() && !status.is_server_error() {
640        let content = resp.text().await?;
641        serde_json::from_str(&content).map_err(Error::from)
642    } else {
643        let content = resp.text().await?;
644        let entity: Option<SetDefaultValuesError> = serde_json::from_str(&content).ok();
645        Err(Error::ResponseError(ResponseContent { status, content, entity }))
646    }
647}
648
649/// Updates a [ custom field context](https://confluence.atlassian.com/adminjiracloud/what-are-custom-field-contexts-991923859.html).  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
650pub async fn update_custom_field_context(configuration: &configuration::Configuration, field_id: &str, context_id: i64, custom_field_context_update_details: models::CustomFieldContextUpdateDetails) -> Result<serde_json::Value, Error<UpdateCustomFieldContextError>> {
651    // add a prefix to parameters to efficiently prevent name collisions
652    let p_field_id = field_id;
653    let p_context_id = context_id;
654    let p_custom_field_context_update_details = custom_field_context_update_details;
655
656    let uri_str = format!("{}/rest/api/2/field/{fieldId}/context/{contextId}", configuration.base_path, fieldId=crate::apis::urlencode(p_field_id), contextId=p_context_id);
657    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
658
659    if let Some(ref user_agent) = configuration.user_agent {
660        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
661    }
662    if let Some(ref token) = configuration.oauth_access_token {
663        req_builder = req_builder.bearer_auth(token.to_owned());
664    };
665    if let Some(ref auth_conf) = configuration.basic_auth {
666        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
667    };
668    req_builder = req_builder.json(&p_custom_field_context_update_details);
669
670    let req = req_builder.build()?;
671    let resp = configuration.client.execute(req).await?;
672
673    let status = resp.status();
674
675    if !status.is_client_error() && !status.is_server_error() {
676        let content = resp.text().await?;
677        serde_json::from_str(&content).map_err(Error::from)
678    } else {
679        let content = resp.text().await?;
680        let entity: Option<UpdateCustomFieldContextError> = serde_json::from_str(&content).ok();
681        Err(Error::ResponseError(ResponseContent { status, content, entity }))
682    }
683}
684