1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[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