jira_api_v2/apis/
labels_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 [`get_all_labels`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetAllLabelsError {
22    UnknownValue(serde_json::Value),
23}
24
25
26/// Returns a [paginated](#pagination) list of labels.
27pub async fn get_all_labels(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>) -> Result<models::PageBeanString, Error<GetAllLabelsError>> {
28    // add a prefix to parameters to efficiently prevent name collisions
29    let p_start_at = start_at;
30    let p_max_results = max_results;
31
32    let uri_str = format!("{}/rest/api/2/label", configuration.base_path);
33    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
34
35    if let Some(ref param_value) = p_start_at {
36        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
37    }
38    if let Some(ref param_value) = p_max_results {
39        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
40    }
41    if let Some(ref user_agent) = configuration.user_agent {
42        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
43    }
44    if let Some(ref token) = configuration.oauth_access_token {
45        req_builder = req_builder.bearer_auth(token.to_owned());
46    };
47    if let Some(ref auth_conf) = configuration.basic_auth {
48        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
49    };
50
51    let req = req_builder.build()?;
52    let resp = configuration.client.execute(req).await?;
53
54    let status = resp.status();
55
56    if !status.is_client_error() && !status.is_server_error() {
57        let content = resp.text().await?;
58        serde_json::from_str(&content).map_err(Error::from)
59    } else {
60        let content = resp.text().await?;
61        let entity: Option<GetAllLabelsError> = serde_json::from_str(&content).ok();
62        Err(Error::ResponseError(ResponseContent { status, content, entity }))
63    }
64}
65