jira_api_v2/apis/
screen_tabs_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`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddScreenTabError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`delete_screen_tab`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum DeleteScreenTabError {
33    Status401(),
34    Status403(),
35    Status404(),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_all_screen_tabs`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetAllScreenTabsError {
43    Status400(),
44    Status401(),
45    Status403(),
46    Status404(),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`move_screen_tab`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum MoveScreenTabError {
54    Status400(),
55    Status401(),
56    Status403(),
57    Status404(),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`rename_screen_tab`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum RenameScreenTabError {
65    Status400(),
66    Status401(),
67    Status403(),
68    Status404(),
69    UnknownValue(serde_json::Value),
70}
71
72
73/// Creates a tab for a screen.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
74pub async fn add_screen_tab(configuration: &configuration::Configuration, screen_id: i64, screenable_tab: models::ScreenableTab) -> Result<models::ScreenableTab, Error<AddScreenTabError>> {
75    // add a prefix to parameters to efficiently prevent name collisions
76    let p_screen_id = screen_id;
77    let p_screenable_tab = screenable_tab;
78
79    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs", configuration.base_path, screenId=p_screen_id);
80    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
81
82    if let Some(ref user_agent) = configuration.user_agent {
83        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
84    }
85    if let Some(ref token) = configuration.oauth_access_token {
86        req_builder = req_builder.bearer_auth(token.to_owned());
87    };
88    if let Some(ref auth_conf) = configuration.basic_auth {
89        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
90    };
91    req_builder = req_builder.json(&p_screenable_tab);
92
93    let req = req_builder.build()?;
94    let resp = configuration.client.execute(req).await?;
95
96    let status = resp.status();
97
98    if !status.is_client_error() && !status.is_server_error() {
99        let content = resp.text().await?;
100        serde_json::from_str(&content).map_err(Error::from)
101    } else {
102        let content = resp.text().await?;
103        let entity: Option<AddScreenTabError> = serde_json::from_str(&content).ok();
104        Err(Error::ResponseError(ResponseContent { status, content, entity }))
105    }
106}
107
108/// Deletes a screen tab.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
109pub async fn delete_screen_tab(configuration: &configuration::Configuration, screen_id: i64, tab_id: i64) -> Result<(), Error<DeleteScreenTabError>> {
110    // add a prefix to parameters to efficiently prevent name collisions
111    let p_screen_id = screen_id;
112    let p_tab_id = tab_id;
113
114    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}", configuration.base_path, screenId=p_screen_id, tabId=p_tab_id);
115    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
116
117    if let Some(ref user_agent) = configuration.user_agent {
118        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
119    }
120    if let Some(ref token) = configuration.oauth_access_token {
121        req_builder = req_builder.bearer_auth(token.to_owned());
122    };
123    if let Some(ref auth_conf) = configuration.basic_auth {
124        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
125    };
126
127    let req = req_builder.build()?;
128    let resp = configuration.client.execute(req).await?;
129
130    let status = resp.status();
131
132    if !status.is_client_error() && !status.is_server_error() {
133        Ok(())
134    } else {
135        let content = resp.text().await?;
136        let entity: Option<DeleteScreenTabError> = serde_json::from_str(&content).ok();
137        Err(Error::ResponseError(ResponseContent { status, content, entity }))
138    }
139}
140
141/// Returns the list of tabs for a screen.  **[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.
142pub async fn get_all_screen_tabs(configuration: &configuration::Configuration, screen_id: i64, project_key: Option<&str>) -> Result<Vec<models::ScreenableTab>, Error<GetAllScreenTabsError>> {
143    // add a prefix to parameters to efficiently prevent name collisions
144    let p_screen_id = screen_id;
145    let p_project_key = project_key;
146
147    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs", configuration.base_path, screenId=p_screen_id);
148    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
149
150    if let Some(ref param_value) = p_project_key {
151        req_builder = req_builder.query(&[("projectKey", &param_value.to_string())]);
152    }
153    if let Some(ref user_agent) = configuration.user_agent {
154        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
155    }
156    if let Some(ref token) = configuration.oauth_access_token {
157        req_builder = req_builder.bearer_auth(token.to_owned());
158    };
159    if let Some(ref auth_conf) = configuration.basic_auth {
160        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
161    };
162
163    let req = req_builder.build()?;
164    let resp = configuration.client.execute(req).await?;
165
166    let status = resp.status();
167
168    if !status.is_client_error() && !status.is_server_error() {
169        let content = resp.text().await?;
170        serde_json::from_str(&content).map_err(Error::from)
171    } else {
172        let content = resp.text().await?;
173        let entity: Option<GetAllScreenTabsError> = serde_json::from_str(&content).ok();
174        Err(Error::ResponseError(ResponseContent { status, content, entity }))
175    }
176}
177
178/// Moves a screen tab.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
179pub async fn move_screen_tab(configuration: &configuration::Configuration, screen_id: i64, tab_id: i64, pos: i32) -> Result<serde_json::Value, Error<MoveScreenTabError>> {
180    // add a prefix to parameters to efficiently prevent name collisions
181    let p_screen_id = screen_id;
182    let p_tab_id = tab_id;
183    let p_pos = pos;
184
185    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/move/{pos}", configuration.base_path, screenId=p_screen_id, tabId=p_tab_id, pos=p_pos);
186    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
187
188    if let Some(ref user_agent) = configuration.user_agent {
189        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
190    }
191    if let Some(ref token) = configuration.oauth_access_token {
192        req_builder = req_builder.bearer_auth(token.to_owned());
193    };
194    if let Some(ref auth_conf) = configuration.basic_auth {
195        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
196    };
197
198    let req = req_builder.build()?;
199    let resp = configuration.client.execute(req).await?;
200
201    let status = resp.status();
202
203    if !status.is_client_error() && !status.is_server_error() {
204        let content = resp.text().await?;
205        serde_json::from_str(&content).map_err(Error::from)
206    } else {
207        let content = resp.text().await?;
208        let entity: Option<MoveScreenTabError> = serde_json::from_str(&content).ok();
209        Err(Error::ResponseError(ResponseContent { status, content, entity }))
210    }
211}
212
213/// Updates the name of a screen tab.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
214pub async fn rename_screen_tab(configuration: &configuration::Configuration, screen_id: i64, tab_id: i64, screenable_tab: models::ScreenableTab) -> Result<models::ScreenableTab, Error<RenameScreenTabError>> {
215    // add a prefix to parameters to efficiently prevent name collisions
216    let p_screen_id = screen_id;
217    let p_tab_id = tab_id;
218    let p_screenable_tab = screenable_tab;
219
220    let uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}", configuration.base_path, screenId=p_screen_id, tabId=p_tab_id);
221    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
222
223    if let Some(ref user_agent) = configuration.user_agent {
224        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
225    }
226    if let Some(ref token) = configuration.oauth_access_token {
227        req_builder = req_builder.bearer_auth(token.to_owned());
228    };
229    if let Some(ref auth_conf) = configuration.basic_auth {
230        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
231    };
232    req_builder = req_builder.json(&p_screenable_tab);
233
234    let req = req_builder.build()?;
235    let resp = configuration.client.execute(req).await?;
236
237    let status = resp.status();
238
239    if !status.is_client_error() && !status.is_server_error() {
240        let content = resp.text().await?;
241        serde_json::from_str(&content).map_err(Error::from)
242    } else {
243        let content = resp.text().await?;
244        let entity: Option<RenameScreenTabError> = serde_json::from_str(&content).ok();
245        Err(Error::ResponseError(ResponseContent { status, content, entity }))
246    }
247}
248