jira_api_v2/apis/
issue_field_configurations_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 [`assign_field_configuration_scheme_to_project`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AssignFieldConfigurationSchemeToProjectError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`get_all_field_configuration_schemes`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum GetAllFieldConfigurationSchemesError {
33    Status400(),
34    Status401(),
35    Status403(),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_all_field_configurations`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetAllFieldConfigurationsError {
43    Status401(),
44    Status403(),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`get_field_configuration_items`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetFieldConfigurationItemsError {
52    Status401(),
53    Status403(),
54    Status404(),
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`get_field_configuration_scheme_mappings`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetFieldConfigurationSchemeMappingsError {
62    Status400(),
63    Status401(),
64    Status403(),
65    Status404(),
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`get_field_configuration_scheme_project_mapping`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetFieldConfigurationSchemeProjectMappingError {
73    Status400(),
74    Status401(),
75    Status403(),
76    UnknownValue(serde_json::Value),
77}
78
79
80/// Assigns a field configuration scheme to a project. If the field configuration scheme ID is `null`, the operation assigns the default field configuration scheme.  Field configuration schemes can only be assigned to classic projects.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
81pub async fn assign_field_configuration_scheme_to_project(configuration: &configuration::Configuration, field_configuration_scheme_project_association: models::FieldConfigurationSchemeProjectAssociation) -> Result<serde_json::Value, Error<AssignFieldConfigurationSchemeToProjectError>> {
82    // add a prefix to parameters to efficiently prevent name collisions
83    let p_field_configuration_scheme_project_association = field_configuration_scheme_project_association;
84
85    let uri_str = format!("{}/rest/api/2/fieldconfigurationscheme/project", configuration.base_path);
86    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
87
88    if let Some(ref user_agent) = configuration.user_agent {
89        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
90    }
91    if let Some(ref token) = configuration.oauth_access_token {
92        req_builder = req_builder.bearer_auth(token.to_owned());
93    };
94    if let Some(ref auth_conf) = configuration.basic_auth {
95        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
96    };
97    req_builder = req_builder.json(&p_field_configuration_scheme_project_association);
98
99    let req = req_builder.build()?;
100    let resp = configuration.client.execute(req).await?;
101
102    let status = resp.status();
103
104    if !status.is_client_error() && !status.is_server_error() {
105        let content = resp.text().await?;
106        serde_json::from_str(&content).map_err(Error::from)
107    } else {
108        let content = resp.text().await?;
109        let entity: Option<AssignFieldConfigurationSchemeToProjectError> = serde_json::from_str(&content).ok();
110        Err(Error::ResponseError(ResponseContent { status, content, entity }))
111    }
112}
113
114/// Returns a [paginated](#pagination) list of field configuration schemes.  Only field configuration schemes used in classic projects are returned.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
115pub async fn get_all_field_configuration_schemes(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, id: Option<Vec<i64>>) -> Result<models::PageBeanFieldConfigurationScheme, Error<GetAllFieldConfigurationSchemesError>> {
116    // add a prefix to parameters to efficiently prevent name collisions
117    let p_start_at = start_at;
118    let p_max_results = max_results;
119    let p_id = id;
120
121    let uri_str = format!("{}/rest/api/2/fieldconfigurationscheme", configuration.base_path);
122    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
123
124    if let Some(ref param_value) = p_start_at {
125        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
126    }
127    if let Some(ref param_value) = p_max_results {
128        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
129    }
130    if let Some(ref param_value) = p_id {
131        req_builder = match "multi" {
132            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("id".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
133            _ => req_builder.query(&[("id", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
134        };
135    }
136    if let Some(ref user_agent) = configuration.user_agent {
137        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
138    }
139    if let Some(ref token) = configuration.oauth_access_token {
140        req_builder = req_builder.bearer_auth(token.to_owned());
141    };
142    if let Some(ref auth_conf) = configuration.basic_auth {
143        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
144    };
145
146    let req = req_builder.build()?;
147    let resp = configuration.client.execute(req).await?;
148
149    let status = resp.status();
150
151    if !status.is_client_error() && !status.is_server_error() {
152        let content = resp.text().await?;
153        serde_json::from_str(&content).map_err(Error::from)
154    } else {
155        let content = resp.text().await?;
156        let entity: Option<GetAllFieldConfigurationSchemesError> = serde_json::from_str(&content).ok();
157        Err(Error::ResponseError(ResponseContent { status, content, entity }))
158    }
159}
160
161/// Returns a [paginated](#pagination) list of all field configurations.  Only field configurations used in classic projects are returned.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
162pub async fn get_all_field_configurations(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, id: Option<Vec<i64>>, is_default: Option<bool>, query: Option<&str>) -> Result<models::PageBeanFieldConfiguration, Error<GetAllFieldConfigurationsError>> {
163    // add a prefix to parameters to efficiently prevent name collisions
164    let p_start_at = start_at;
165    let p_max_results = max_results;
166    let p_id = id;
167    let p_is_default = is_default;
168    let p_query = query;
169
170    let uri_str = format!("{}/rest/api/2/fieldconfiguration", configuration.base_path);
171    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
172
173    if let Some(ref param_value) = p_start_at {
174        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
175    }
176    if let Some(ref param_value) = p_max_results {
177        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
178    }
179    if let Some(ref param_value) = p_id {
180        req_builder = match "multi" {
181            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("id".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
182            _ => req_builder.query(&[("id", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
183        };
184    }
185    if let Some(ref param_value) = p_is_default {
186        req_builder = req_builder.query(&[("isDefault", &param_value.to_string())]);
187    }
188    if let Some(ref param_value) = p_query {
189        req_builder = req_builder.query(&[("query", &param_value.to_string())]);
190    }
191    if let Some(ref user_agent) = configuration.user_agent {
192        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
193    }
194    if let Some(ref token) = configuration.oauth_access_token {
195        req_builder = req_builder.bearer_auth(token.to_owned());
196    };
197    if let Some(ref auth_conf) = configuration.basic_auth {
198        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
199    };
200
201    let req = req_builder.build()?;
202    let resp = configuration.client.execute(req).await?;
203
204    let status = resp.status();
205
206    if !status.is_client_error() && !status.is_server_error() {
207        let content = resp.text().await?;
208        serde_json::from_str(&content).map_err(Error::from)
209    } else {
210        let content = resp.text().await?;
211        let entity: Option<GetAllFieldConfigurationsError> = serde_json::from_str(&content).ok();
212        Err(Error::ResponseError(ResponseContent { status, content, entity }))
213    }
214}
215
216/// Returns a [paginated](#pagination) list of all fields for a configuration.  Only the fields from configurations used in classic projects are returned.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
217pub async fn get_field_configuration_items(configuration: &configuration::Configuration, id: i64, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanFieldConfigurationItem, Error<GetFieldConfigurationItemsError>> {
218    // add a prefix to parameters to efficiently prevent name collisions
219    let p_id = id;
220    let p_start_at = start_at;
221    let p_max_results = max_results;
222
223    let uri_str = format!("{}/rest/api/2/fieldconfiguration/{id}/fields", configuration.base_path, id=p_id);
224    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
225
226    if let Some(ref param_value) = p_start_at {
227        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
228    }
229    if let Some(ref param_value) = p_max_results {
230        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
231    }
232    if let Some(ref user_agent) = configuration.user_agent {
233        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
234    }
235    if let Some(ref token) = configuration.oauth_access_token {
236        req_builder = req_builder.bearer_auth(token.to_owned());
237    };
238    if let Some(ref auth_conf) = configuration.basic_auth {
239        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
240    };
241
242    let req = req_builder.build()?;
243    let resp = configuration.client.execute(req).await?;
244
245    let status = resp.status();
246
247    if !status.is_client_error() && !status.is_server_error() {
248        let content = resp.text().await?;
249        serde_json::from_str(&content).map_err(Error::from)
250    } else {
251        let content = resp.text().await?;
252        let entity: Option<GetFieldConfigurationItemsError> = serde_json::from_str(&content).ok();
253        Err(Error::ResponseError(ResponseContent { status, content, entity }))
254    }
255}
256
257/// Returns a [paginated](#pagination) list of field configuration issue type items.  Only items used in classic projects are returned.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
258pub async fn get_field_configuration_scheme_mappings(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, field_configuration_scheme_id: Option<Vec<i64>>) -> Result<models::PageBeanFieldConfigurationIssueTypeItem, Error<GetFieldConfigurationSchemeMappingsError>> {
259    // add a prefix to parameters to efficiently prevent name collisions
260    let p_start_at = start_at;
261    let p_max_results = max_results;
262    let p_field_configuration_scheme_id = field_configuration_scheme_id;
263
264    let uri_str = format!("{}/rest/api/2/fieldconfigurationscheme/mapping", configuration.base_path);
265    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
266
267    if let Some(ref param_value) = p_start_at {
268        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
269    }
270    if let Some(ref param_value) = p_max_results {
271        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
272    }
273    if let Some(ref param_value) = p_field_configuration_scheme_id {
274        req_builder = match "multi" {
275            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("fieldConfigurationSchemeId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
276            _ => req_builder.query(&[("fieldConfigurationSchemeId", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
277        };
278    }
279    if let Some(ref user_agent) = configuration.user_agent {
280        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
281    }
282    if let Some(ref token) = configuration.oauth_access_token {
283        req_builder = req_builder.bearer_auth(token.to_owned());
284    };
285    if let Some(ref auth_conf) = configuration.basic_auth {
286        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
287    };
288
289    let req = req_builder.build()?;
290    let resp = configuration.client.execute(req).await?;
291
292    let status = resp.status();
293
294    if !status.is_client_error() && !status.is_server_error() {
295        let content = resp.text().await?;
296        serde_json::from_str(&content).map_err(Error::from)
297    } else {
298        let content = resp.text().await?;
299        let entity: Option<GetFieldConfigurationSchemeMappingsError> = serde_json::from_str(&content).ok();
300        Err(Error::ResponseError(ResponseContent { status, content, entity }))
301    }
302}
303
304/// Returns a [paginated](#pagination) list of field configuration schemes and, for each scheme, a list of the projects that use it.  The list is sorted by field configuration scheme ID. The first item contains the list of project IDs assigned to the default field configuration scheme.  Only field configuration schemes used in classic projects are returned.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
305pub async fn get_field_configuration_scheme_project_mapping(configuration: &configuration::Configuration, project_id: Vec<i64>, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanFieldConfigurationSchemeProjects, Error<GetFieldConfigurationSchemeProjectMappingError>> {
306    // add a prefix to parameters to efficiently prevent name collisions
307    let p_project_id = project_id;
308    let p_start_at = start_at;
309    let p_max_results = max_results;
310
311    let uri_str = format!("{}/rest/api/2/fieldconfigurationscheme/project", configuration.base_path);
312    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
313
314    if let Some(ref param_value) = p_start_at {
315        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
316    }
317    if let Some(ref param_value) = p_max_results {
318        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
319    }
320    req_builder = match "multi" {
321        "multi" => req_builder.query(&p_project_id.into_iter().map(|p| ("projectId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
322        _ => req_builder.query(&[("projectId", &p_project_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
323    };
324    if let Some(ref user_agent) = configuration.user_agent {
325        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
326    }
327    if let Some(ref token) = configuration.oauth_access_token {
328        req_builder = req_builder.bearer_auth(token.to_owned());
329    };
330    if let Some(ref auth_conf) = configuration.basic_auth {
331        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
332    };
333
334    let req = req_builder.build()?;
335    let resp = configuration.client.execute(req).await?;
336
337    let status = resp.status();
338
339    if !status.is_client_error() && !status.is_server_error() {
340        let content = resp.text().await?;
341        serde_json::from_str(&content).map_err(Error::from)
342    } else {
343        let content = resp.text().await?;
344        let entity: Option<GetFieldConfigurationSchemeProjectMappingError> = serde_json::from_str(&content).ok();
345        Err(Error::ResponseError(ResponseContent { status, content, entity }))
346    }
347}
348