tembo_api_client/apis/
app_api.rs

1/*
2 * Tembo Cloud
3 *
4 * Platform API for Tembo Cloud             </br>             </br>             To find a Tembo Data API, please find it here:             </br>             </br>             [AWS US East 1](https://api.data-1.use1.tembo.io/swagger-ui/)
5 *
6 * The version of the OpenAPI document: v1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize};
15
16/// struct for typed errors of method [`get_all_apps`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum GetAllAppsError {
20    Status401(models::ErrorResponseSchema),
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`get_app`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum GetAppError {
28    Status400(serde_json::Value),
29    Status401(models::ErrorResponseSchema),
30    UnknownValue(serde_json::Value),
31}
32
33/// Attributes for all apps
34pub async fn get_all_apps(
35    configuration: &configuration::Configuration,
36) -> Result<Vec<serde_json::Value>, Error<GetAllAppsError>> {
37    let uri_str = format!("{}/api/v1/apps", configuration.base_path);
38    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
39
40    if let Some(ref user_agent) = configuration.user_agent {
41        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
42    }
43    if let Some(ref token) = configuration.bearer_access_token {
44        req_builder = req_builder.bearer_auth(token.to_owned());
45    };
46
47    let req = req_builder.build()?;
48    let resp = configuration.client.execute(req).await?;
49
50    let status = resp.status();
51
52    if !status.is_client_error() && !status.is_server_error() {
53        let content = resp.text().await?;
54        serde_json::from_str(&content).map_err(Error::from)
55    } else {
56        let content = resp.text().await?;
57        let entity: Option<GetAllAppsError> = serde_json::from_str(&content).ok();
58        Err(Error::ResponseError(ResponseContent {
59            status,
60            content,
61            entity,
62        }))
63    }
64}
65
66/// Get the attributes of a single App
67pub async fn get_app(
68    configuration: &configuration::Configuration,
69    r#type: &str,
70) -> Result<serde_json::Value, Error<GetAppError>> {
71    // add a prefix to parameters to efficiently prevent name collisions
72    let p_type = r#type;
73
74    let uri_str = format!("{}/api/v1/apps/{type}", configuration.base_path, type=crate::apis::urlencode(p_type));
75    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
76
77    if let Some(ref user_agent) = configuration.user_agent {
78        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
79    }
80    if let Some(ref token) = configuration.bearer_access_token {
81        req_builder = req_builder.bearer_auth(token.to_owned());
82    };
83
84    let req = req_builder.build()?;
85    let resp = configuration.client.execute(req).await?;
86
87    let status = resp.status();
88
89    if !status.is_client_error() && !status.is_server_error() {
90        let content = resp.text().await?;
91        serde_json::from_str(&content).map_err(Error::from)
92    } else {
93        let content = resp.text().await?;
94        let entity: Option<GetAppError> = serde_json::from_str(&content).ok();
95        Err(Error::ResponseError(ResponseContent {
96            status,
97            content,
98            entity,
99        }))
100    }
101}