jira/gen/apis/
project_types_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
11use super::{configuration, Error};
12use crate::gen::apis::ResponseContent;
13use crate::gen::models;
14
15/// struct for passing parameters to the method `get_accessible_project_type_by_key`
16#[derive(Clone, Debug)]
17pub struct GetAccessibleProjectTypeByKeyParams {
18    /// The key of the project type.
19    pub project_type_key: String,
20}
21
22/// struct for passing parameters to the method `get_project_type_by_key`
23#[derive(Clone, Debug)]
24pub struct GetProjectTypeByKeyParams {
25    /// The key of the project type.
26    pub project_type_key: String,
27}
28
29/// struct for typed errors of method `get_accessible_project_type_by_key`
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum GetAccessibleProjectTypeByKeyError {
33    Status401(),
34    Status404(),
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method `get_all_accessible_project_types`
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum GetAllAccessibleProjectTypesError {
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method `get_all_project_types`
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum GetAllProjectTypesError {
49    Status401(),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method `get_project_type_by_key`
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetProjectTypeByKeyError {
57    Status401(),
58    Status404(),
59    UnknownValue(serde_json::Value),
60}
61
62/// Returns a [project type](https://confluence.atlassian.com/x/Var1Nw) if it is accessible to the user.  **[Permissions](#permissions) required:** Permission to access Jira.
63pub async fn get_accessible_project_type_by_key(
64    configuration: &configuration::Configuration,
65    params: GetAccessibleProjectTypeByKeyParams,
66) -> Result<models::ProjectType, Error<GetAccessibleProjectTypeByKeyError>> {
67    // unbox the parameters
68    let project_type_key = params.project_type_key;
69
70    let local_var_client = &configuration.client;
71
72    let local_var_uri_str = format!(
73        "{}/rest/api/3/project/type/{projectTypeKey}/accessible",
74        configuration.base_path,
75        projectTypeKey = crate::gen::apis::urlencode(project_type_key)
76    );
77    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
78
79    if let Some(ref local_var_user_agent) = configuration.user_agent {
80        local_var_req_builder =
81            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
82    }
83    if let Some(ref local_var_token) = configuration.oauth_access_token {
84        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
85    };
86    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
87        local_var_req_builder = local_var_req_builder.basic_auth(
88            local_var_auth_conf.0.to_owned(),
89            local_var_auth_conf.1.to_owned(),
90        );
91    };
92
93    let local_var_req = local_var_req_builder.build()?;
94    let local_var_resp = local_var_client.execute(local_var_req).await?;
95
96    let local_var_status = local_var_resp.status();
97    let local_var_content = local_var_resp.text().await?;
98
99    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
100        serde_json::from_str(&local_var_content).map_err(Error::from)
101    } else {
102        let local_var_entity: Option<GetAccessibleProjectTypeByKeyError> =
103            serde_json::from_str(&local_var_content).ok();
104        let local_var_error = ResponseContent {
105            status: local_var_status,
106            content: local_var_content,
107            entity: local_var_entity,
108        };
109        Err(Error::ResponseError(local_var_error))
110    }
111}
112
113/// Returns all [project types](https://confluence.atlassian.com/x/Var1Nw) with a valid license.
114pub async fn get_all_accessible_project_types(
115    configuration: &configuration::Configuration,
116) -> Result<Vec<models::ProjectType>, Error<GetAllAccessibleProjectTypesError>> {
117    // unbox the parameters
118
119    let local_var_client = &configuration.client;
120
121    let local_var_uri_str = format!(
122        "{}/rest/api/3/project/type/accessible",
123        configuration.base_path
124    );
125    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
126
127    if let Some(ref local_var_user_agent) = configuration.user_agent {
128        local_var_req_builder =
129            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
130    }
131    if let Some(ref local_var_token) = configuration.oauth_access_token {
132        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
133    };
134    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
135        local_var_req_builder = local_var_req_builder.basic_auth(
136            local_var_auth_conf.0.to_owned(),
137            local_var_auth_conf.1.to_owned(),
138        );
139    };
140
141    let local_var_req = local_var_req_builder.build()?;
142    let local_var_resp = local_var_client.execute(local_var_req).await?;
143
144    let local_var_status = local_var_resp.status();
145    let local_var_content = local_var_resp.text().await?;
146
147    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
148        serde_json::from_str(&local_var_content).map_err(Error::from)
149    } else {
150        let local_var_entity: Option<GetAllAccessibleProjectTypesError> =
151            serde_json::from_str(&local_var_content).ok();
152        let local_var_error = ResponseContent {
153            status: local_var_status,
154            content: local_var_content,
155            entity: local_var_entity,
156        };
157        Err(Error::ResponseError(local_var_error))
158    }
159}
160
161/// Returns all [project types](https://confluence.atlassian.com/x/Var1Nw), whether or not the instance has a valid license for each type.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
162pub async fn get_all_project_types(
163    configuration: &configuration::Configuration,
164) -> Result<Vec<models::ProjectType>, Error<GetAllProjectTypesError>> {
165    // unbox the parameters
166
167    let local_var_client = &configuration.client;
168
169    let local_var_uri_str = format!("{}/rest/api/3/project/type", configuration.base_path);
170    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
171
172    if let Some(ref local_var_user_agent) = configuration.user_agent {
173        local_var_req_builder =
174            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
175    }
176    if let Some(ref local_var_token) = configuration.oauth_access_token {
177        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
178    };
179    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
180        local_var_req_builder = local_var_req_builder.basic_auth(
181            local_var_auth_conf.0.to_owned(),
182            local_var_auth_conf.1.to_owned(),
183        );
184    };
185
186    let local_var_req = local_var_req_builder.build()?;
187    let local_var_resp = local_var_client.execute(local_var_req).await?;
188
189    let local_var_status = local_var_resp.status();
190    let local_var_content = local_var_resp.text().await?;
191
192    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
193        serde_json::from_str(&local_var_content).map_err(Error::from)
194    } else {
195        let local_var_entity: Option<GetAllProjectTypesError> =
196            serde_json::from_str(&local_var_content).ok();
197        let local_var_error = ResponseContent {
198            status: local_var_status,
199            content: local_var_content,
200            entity: local_var_entity,
201        };
202        Err(Error::ResponseError(local_var_error))
203    }
204}
205
206/// Returns a [project type](https://confluence.atlassian.com/x/Var1Nw).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
207pub async fn get_project_type_by_key(
208    configuration: &configuration::Configuration,
209    params: GetProjectTypeByKeyParams,
210) -> Result<models::ProjectType, Error<GetProjectTypeByKeyError>> {
211    // unbox the parameters
212    let project_type_key = params.project_type_key;
213
214    let local_var_client = &configuration.client;
215
216    let local_var_uri_str = format!(
217        "{}/rest/api/3/project/type/{projectTypeKey}",
218        configuration.base_path,
219        projectTypeKey = crate::gen::apis::urlencode(project_type_key)
220    );
221    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
222
223    if let Some(ref local_var_user_agent) = configuration.user_agent {
224        local_var_req_builder =
225            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
226    }
227    if let Some(ref local_var_token) = configuration.oauth_access_token {
228        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
229    };
230    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
231        local_var_req_builder = local_var_req_builder.basic_auth(
232            local_var_auth_conf.0.to_owned(),
233            local_var_auth_conf.1.to_owned(),
234        );
235    };
236
237    let local_var_req = local_var_req_builder.build()?;
238    let local_var_resp = local_var_client.execute(local_var_req).await?;
239
240    let local_var_status = local_var_resp.status();
241    let local_var_content = local_var_resp.text().await?;
242
243    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
244        serde_json::from_str(&local_var_content).map_err(Error::from)
245    } else {
246        let local_var_entity: Option<GetProjectTypeByKeyError> =
247            serde_json::from_str(&local_var_content).ok();
248        let local_var_error = ResponseContent {
249            status: local_var_status,
250            content: local_var_content,
251            entity: local_var_entity,
252        };
253        Err(Error::ResponseError(local_var_error))
254    }
255}