hi_jira2/apis/
screen_tab_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 [`add_screen_tab_field`]
18#[derive(Clone, Debug, Default)]
19pub struct AddScreenTabFieldParams {
20    /// The ID of the screen.
21    pub screen_id: i64,
22    /// The ID of the screen tab.
23    pub tab_id: i64,
24    pub add_field_bean: crate::models::AddFieldBean
25}
26
27/// struct for passing parameters to the method [`get_all_screen_tab_fields`]
28#[derive(Clone, Debug, Default)]
29pub struct GetAllScreenTabFieldsParams {
30    /// The ID of the screen.
31    pub screen_id: i64,
32    /// The ID of the screen tab.
33    pub tab_id: i64,
34    /// The key of the project.
35    pub project_key: Option<String>
36}
37
38/// struct for passing parameters to the method [`move_screen_tab_field`]
39#[derive(Clone, Debug, Default)]
40pub struct MoveScreenTabFieldParams {
41    /// The ID of the screen.
42    pub screen_id: i64,
43    /// The ID of the screen tab.
44    pub tab_id: i64,
45    /// The ID of the field.
46    pub id: String,
47    pub move_field_bean: crate::models::MoveFieldBean
48}
49
50/// struct for passing parameters to the method [`remove_screen_tab_field`]
51#[derive(Clone, Debug, Default)]
52pub struct RemoveScreenTabFieldParams {
53    /// The ID of the screen.
54    pub screen_id: i64,
55    /// The ID of the screen tab.
56    pub tab_id: i64,
57    /// The ID of the field.
58    pub id: String
59}
60
61
62/// struct for typed errors of method [`add_screen_tab_field`]
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum AddScreenTabFieldError {
66    Status400(),
67    Status401(),
68    Status403(),
69    Status404(),
70    UnknownValue(serde_json::Value),
71}
72
73/// struct for typed errors of method [`get_all_screen_tab_fields`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum GetAllScreenTabFieldsError {
77    Status401(),
78    Status403(),
79    Status404(),
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`move_screen_tab_field`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum MoveScreenTabFieldError {
87    Status400(),
88    Status401(),
89    Status403(),
90    Status404(),
91    UnknownValue(serde_json::Value),
92}
93
94/// struct for typed errors of method [`remove_screen_tab_field`]
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum RemoveScreenTabFieldError {
98    Status400(),
99    Status401(),
100    Status403(),
101    Status404(),
102    UnknownValue(serde_json::Value),
103}
104
105
106/// Adds a field to a screen tab.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
107pub async fn add_screen_tab_field(configuration: &configuration::Configuration, params: AddScreenTabFieldParams) -> Result<crate::models::ScreenableField, Error<AddScreenTabFieldError>> {
108    let local_var_configuration = configuration;
109
110    // unbox the parameters
111    let screen_id = params.screen_id;
112    let tab_id = params.tab_id;
113    let add_field_bean = params.add_field_bean;
114
115
116    let local_var_client = &local_var_configuration.client;
117
118    let local_var_uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields", local_var_configuration.base_path, screenId=screen_id, tabId=tab_id);
119    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
120
121    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
122        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
123    }
124    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
125        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
126    };
127    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
128        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
129    };
130    local_var_req_builder = local_var_req_builder.json(&add_field_bean);
131
132    let local_var_req = local_var_req_builder.build()?;
133    let local_var_resp = local_var_client.execute(local_var_req).await?;
134
135    let local_var_status = local_var_resp.status();
136    let local_var_content = local_var_resp.text().await?;
137
138    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
139        serde_json::from_str(&local_var_content).map_err(Error::from)
140    } else {
141        let local_var_entity: Option<AddScreenTabFieldError> = serde_json::from_str(&local_var_content).ok();
142        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
143        Err(Error::ResponseError(local_var_error))
144    }
145}
146
147/// Returns all fields for a screen tab.  **[Permissions](#permissions) required:**   *  *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).  *  *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) when the project key is specified, providing that the screen is associated with the project through a Screen Scheme and Issue Type Screen Scheme.
148pub async fn get_all_screen_tab_fields(configuration: &configuration::Configuration, params: GetAllScreenTabFieldsParams) -> Result<Vec<crate::models::ScreenableField>, Error<GetAllScreenTabFieldsError>> {
149    let local_var_configuration = configuration;
150
151    // unbox the parameters
152    let screen_id = params.screen_id;
153    let tab_id = params.tab_id;
154    let project_key = params.project_key;
155
156
157    let local_var_client = &local_var_configuration.client;
158
159    let local_var_uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields", local_var_configuration.base_path, screenId=screen_id, tabId=tab_id);
160    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
161
162    if let Some(ref local_var_str) = project_key {
163        local_var_req_builder = local_var_req_builder.query(&[("projectKey", &local_var_str.to_string())]);
164    }
165    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
166        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
167    }
168    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
169        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
170    };
171    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
172        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
173    };
174
175    let local_var_req = local_var_req_builder.build()?;
176    let local_var_resp = local_var_client.execute(local_var_req).await?;
177
178    let local_var_status = local_var_resp.status();
179    let local_var_content = local_var_resp.text().await?;
180
181    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182        serde_json::from_str(&local_var_content).map_err(Error::from)
183    } else {
184        let local_var_entity: Option<GetAllScreenTabFieldsError> = serde_json::from_str(&local_var_content).ok();
185        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
186        Err(Error::ResponseError(local_var_error))
187    }
188}
189
190/// Moves a screen tab field.  If `after` and `position` are provided in the request, `position` is ignored.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
191pub async fn move_screen_tab_field(configuration: &configuration::Configuration, params: MoveScreenTabFieldParams) -> Result<serde_json::Value, Error<MoveScreenTabFieldError>> {
192    let local_var_configuration = configuration;
193
194    // unbox the parameters
195    let screen_id = params.screen_id;
196    let tab_id = params.tab_id;
197    let id = params.id;
198    let move_field_bean = params.move_field_bean;
199
200
201    let local_var_client = &local_var_configuration.client;
202
203    let local_var_uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields/{id}/move", local_var_configuration.base_path, screenId=screen_id, tabId=tab_id, id=crate::apis::urlencode(id));
204    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
205
206    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
207        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
208    }
209    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
210        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
211    };
212    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
213        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
214    };
215    local_var_req_builder = local_var_req_builder.json(&move_field_bean);
216
217    let local_var_req = local_var_req_builder.build()?;
218    let local_var_resp = local_var_client.execute(local_var_req).await?;
219
220    let local_var_status = local_var_resp.status();
221    let local_var_content = local_var_resp.text().await?;
222
223    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
224        serde_json::from_str(&local_var_content).map_err(Error::from)
225    } else {
226        let local_var_entity: Option<MoveScreenTabFieldError> = serde_json::from_str(&local_var_content).ok();
227        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
228        Err(Error::ResponseError(local_var_error))
229    }
230}
231
232/// Removes a field from a screen tab.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
233pub async fn remove_screen_tab_field(configuration: &configuration::Configuration, params: RemoveScreenTabFieldParams) -> Result<(), Error<RemoveScreenTabFieldError>> {
234    let local_var_configuration = configuration;
235
236    // unbox the parameters
237    let screen_id = params.screen_id;
238    let tab_id = params.tab_id;
239    let id = params.id;
240
241
242    let local_var_client = &local_var_configuration.client;
243
244    let local_var_uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields/{id}", local_var_configuration.base_path, screenId=screen_id, tabId=tab_id, id=crate::apis::urlencode(id));
245    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
246
247    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
248        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
249    }
250    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
251        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
252    };
253    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
254        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
255    };
256
257    let local_var_req = local_var_req_builder.build()?;
258    let local_var_resp = local_var_client.execute(local_var_req).await?;
259
260    let local_var_status = local_var_resp.status();
261    let local_var_content = local_var_resp.text().await?;
262
263    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
264        Ok(())
265    } else {
266        let local_var_entity: Option<RemoveScreenTabFieldError> = serde_json::from_str(&local_var_content).ok();
267        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
268        Err(Error::ResponseError(local_var_error))
269    }
270}
271