jira_api_v2/apis/
server_info_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_server_info`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetServerInfoError {
22    Status401(),
23    UnknownValue(serde_json::Value),
24}
25
26
27/// Returns information about the Jira instance.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
28pub async fn get_server_info(configuration: &configuration::Configuration, ) -> Result<models::ServerInformation, Error<GetServerInfoError>> {
29
30    let uri_str = format!("{}/rest/api/2/serverInfo", configuration.base_path);
31    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
32
33    if let Some(ref user_agent) = configuration.user_agent {
34        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
35    }
36    if let Some(ref token) = configuration.oauth_access_token {
37        req_builder = req_builder.bearer_auth(token.to_owned());
38    };
39    if let Some(ref auth_conf) = configuration.basic_auth {
40        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
41    };
42
43    let req = req_builder.build()?;
44    let resp = configuration.client.execute(req).await?;
45
46    let status = resp.status();
47
48    if !status.is_client_error() && !status.is_server_error() {
49        let content = resp.text().await?;
50        serde_json::from_str(&content).map_err(Error::from)
51    } else {
52        let content = resp.text().await?;
53        let entity: Option<GetServerInfoError> = serde_json::from_str(&content).ok();
54        Err(Error::ResponseError(ResponseContent { status, content, entity }))
55    }
56}
57