lethean/apis/
vpn_api.rs

1/*
2 * Lethean VPN
3 *
4 * Distributed Virtual Private Marketplace
5 *
6 * The version of the OpenAPI document: 1.2.1
7 * Contact: contact@lethean.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method `list_services`
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ListServicesError {
22    UnknownValue(serde_json::Value),
23}
24
25
26pub async fn list_services(configuration: &configuration::Configuration, ) -> Result<Vec<crate::models::ServiceEntity>, Error<ListServicesError>> {
27
28    let local_var_client = &configuration.client;
29
30    let local_var_uri_str = format!("{}/v1/services/public-nodes", configuration.base_path);
31    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
32
33    if let Some(ref local_var_user_agent) = configuration.user_agent {
34        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
35    }
36
37    let local_var_req = local_var_req_builder.build()?;
38    let local_var_resp = local_var_client.execute(local_var_req).await?;
39
40    let local_var_status = local_var_resp.status();
41    let local_var_content = local_var_resp.text().await?;
42
43    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
44        serde_json::from_str(&local_var_content).map_err(Error::from)
45    } else {
46        let local_var_entity: Option<ListServicesError> = serde_json::from_str(&local_var_content).ok();
47        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
48        Err(Error::ResponseError(local_var_error))
49    }
50}
51