tembo_api_client/apis/
dataplane_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_dataplanes`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum GetAllDataplanesError {
20    Status401(models::ErrorResponseSchema),
21    Status403(models::ErrorResponseSchema),
22    UnknownValue(serde_json::Value),
23}
24
25pub async fn get_all_dataplanes(
26    configuration: &configuration::Configuration,
27    org_id: &str,
28) -> Result<Vec<models::DataPlane>, Error<GetAllDataplanesError>> {
29    // add a prefix to parameters to efficiently prevent name collisions
30    let p_org_id = org_id;
31
32    let uri_str = format!(
33        "{}/api/v1/orgs/{org_id}/dataplanes",
34        configuration.base_path,
35        org_id = crate::apis::urlencode(p_org_id)
36    );
37    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
38
39    if let Some(ref user_agent) = configuration.user_agent {
40        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
41    }
42    if let Some(ref token) = configuration.bearer_access_token {
43        req_builder = req_builder.bearer_auth(token.to_owned());
44    };
45
46    let req = req_builder.build()?;
47    let resp = configuration.client.execute(req).await?;
48
49    let status = resp.status();
50
51    if !status.is_client_error() && !status.is_server_error() {
52        let content = resp.text().await?;
53        serde_json::from_str(&content).map_err(Error::from)
54    } else {
55        let content = resp.text().await?;
56        let entity: Option<GetAllDataplanesError> = serde_json::from_str(&content).ok();
57        Err(Error::ResponseError(ResponseContent {
58            status,
59            content,
60            entity,
61        }))
62    }
63}