jira_api_v2/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;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`add_screen_tab_field`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddScreenTabFieldError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`get_all_screen_tab_fields`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum GetAllScreenTabFieldsError {
33    Status401(),
34    Status403(),
35    Status404(),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`move_screen_tab_field`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum MoveScreenTabFieldError {
43    Status400(),
44    Status401(),
45    Status403(),
46    Status404(),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`remove_screen_tab_field`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum RemoveScreenTabFieldError {
54    Status400(),
55    Status401(),
56    Status403(),
57    Status404(),
58    UnknownValue(serde_json::Value),
59}
60
61
62/// Adds a field to a screen tab.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
63pub async fn add_screen_tab_field(configuration: &configuration::Configuration, screen_id: i64, tab_id: i64, add_field_bean: models::AddFieldBean) -> Result<models::ScreenableField, Error<AddScreenTabFieldError>> {
64    // add a prefix to parameters to efficiently prevent name collisions
65    let p_screen_id = screen_id;
66    let p_tab_id = tab_id;
67    let p_add_field_bean = add_field_bean;
68
69    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields", configuration.base_path, screenId=p_screen_id, tabId=p_tab_id);
70    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
71
72    if let Some(ref user_agent) = configuration.user_agent {
73        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
74    }
75    if let Some(ref token) = configuration.oauth_access_token {
76        req_builder = req_builder.bearer_auth(token.to_owned());
77    };
78    if let Some(ref auth_conf) = configuration.basic_auth {
79        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
80    };
81    req_builder = req_builder.json(&p_add_field_bean);
82
83    let req = req_builder.build()?;
84    let resp = configuration.client.execute(req).await?;
85
86    let status = resp.status();
87
88    if !status.is_client_error() && !status.is_server_error() {
89        let content = resp.text().await?;
90        serde_json::from_str(&content).map_err(Error::from)
91    } else {
92        let content = resp.text().await?;
93        let entity: Option<AddScreenTabFieldError> = serde_json::from_str(&content).ok();
94        Err(Error::ResponseError(ResponseContent { status, content, entity }))
95    }
96}
97
98/// 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.
99pub async fn get_all_screen_tab_fields(configuration: &configuration::Configuration, screen_id: i64, tab_id: i64, project_key: Option<&str>) -> Result<Vec<models::ScreenableField>, Error<GetAllScreenTabFieldsError>> {
100    // add a prefix to parameters to efficiently prevent name collisions
101    let p_screen_id = screen_id;
102    let p_tab_id = tab_id;
103    let p_project_key = project_key;
104
105    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields", configuration.base_path, screenId=p_screen_id, tabId=p_tab_id);
106    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
107
108    if let Some(ref param_value) = p_project_key {
109        req_builder = req_builder.query(&[("projectKey", &param_value.to_string())]);
110    }
111    if let Some(ref user_agent) = configuration.user_agent {
112        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
113    }
114    if let Some(ref token) = configuration.oauth_access_token {
115        req_builder = req_builder.bearer_auth(token.to_owned());
116    };
117    if let Some(ref auth_conf) = configuration.basic_auth {
118        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
119    };
120
121    let req = req_builder.build()?;
122    let resp = configuration.client.execute(req).await?;
123
124    let status = resp.status();
125
126    if !status.is_client_error() && !status.is_server_error() {
127        let content = resp.text().await?;
128        serde_json::from_str(&content).map_err(Error::from)
129    } else {
130        let content = resp.text().await?;
131        let entity: Option<GetAllScreenTabFieldsError> = serde_json::from_str(&content).ok();
132        Err(Error::ResponseError(ResponseContent { status, content, entity }))
133    }
134}
135
136/// 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).
137pub async fn move_screen_tab_field(configuration: &configuration::Configuration, screen_id: i64, tab_id: i64, id: &str, move_field_bean: models::MoveFieldBean) -> Result<serde_json::Value, Error<MoveScreenTabFieldError>> {
138    // add a prefix to parameters to efficiently prevent name collisions
139    let p_screen_id = screen_id;
140    let p_tab_id = tab_id;
141    let p_id = id;
142    let p_move_field_bean = move_field_bean;
143
144    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields/{id}/move", configuration.base_path, screenId=p_screen_id, tabId=p_tab_id, id=crate::apis::urlencode(p_id));
145    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
146
147    if let Some(ref user_agent) = configuration.user_agent {
148        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149    }
150    if let Some(ref token) = configuration.oauth_access_token {
151        req_builder = req_builder.bearer_auth(token.to_owned());
152    };
153    if let Some(ref auth_conf) = configuration.basic_auth {
154        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
155    };
156    req_builder = req_builder.json(&p_move_field_bean);
157
158    let req = req_builder.build()?;
159    let resp = configuration.client.execute(req).await?;
160
161    let status = resp.status();
162
163    if !status.is_client_error() && !status.is_server_error() {
164        let content = resp.text().await?;
165        serde_json::from_str(&content).map_err(Error::from)
166    } else {
167        let content = resp.text().await?;
168        let entity: Option<MoveScreenTabFieldError> = serde_json::from_str(&content).ok();
169        Err(Error::ResponseError(ResponseContent { status, content, entity }))
170    }
171}
172
173/// Removes a field from a screen tab.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
174pub async fn remove_screen_tab_field(configuration: &configuration::Configuration, screen_id: i64, tab_id: i64, id: &str) -> Result<(), Error<RemoveScreenTabFieldError>> {
175    // add a prefix to parameters to efficiently prevent name collisions
176    let p_screen_id = screen_id;
177    let p_tab_id = tab_id;
178    let p_id = id;
179
180    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields/{id}", configuration.base_path, screenId=p_screen_id, tabId=p_tab_id, id=crate::apis::urlencode(p_id));
181    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
182
183    if let Some(ref user_agent) = configuration.user_agent {
184        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
185    }
186    if let Some(ref token) = configuration.oauth_access_token {
187        req_builder = req_builder.bearer_auth(token.to_owned());
188    };
189    if let Some(ref auth_conf) = configuration.basic_auth {
190        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
191    };
192
193    let req = req_builder.build()?;
194    let resp = configuration.client.execute(req).await?;
195
196    let status = resp.status();
197
198    if !status.is_client_error() && !status.is_server_error() {
199        Ok(())
200    } else {
201        let content = resp.text().await?;
202        let entity: Option<RemoveScreenTabFieldError> = serde_json::from_str(&content).ok();
203        Err(Error::ResponseError(ResponseContent { status, content, entity }))
204    }
205}
206