github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/rust/src/apis/config_api.rs (about)

     1  /*
     2   * lakeFS API
     3   *
     4   * lakeFS HTTP API
     5   *
     6   * The version of the OpenAPI document: 1.0.0
     7   * Contact: services@treeverse.io
     8   * Generated by: https://openapi-generator.tech
     9   */
    10  
    11  
    12  use reqwest;
    13  
    14  use crate::{apis::ResponseContent, models};
    15  use super::{Error, configuration};
    16  
    17  
    18  /// struct for typed errors of method [`get_config`]
    19  #[derive(Debug, Clone, Serialize, Deserialize)]
    20  #[serde(untagged)]
    21  pub enum GetConfigError {
    22      Status401(models::Error),
    23      UnknownValue(serde_json::Value),
    24  }
    25  
    26  
    27  /// retrieve lakeFS configuration
    28  pub async fn get_config(configuration: &configuration::Configuration, ) -> Result<models::Config, Error<GetConfigError>> {
    29      let local_var_configuration = configuration;
    30  
    31      let local_var_client = &local_var_configuration.client;
    32  
    33      let local_var_uri_str = format!("{}/config", local_var_configuration.base_path);
    34      let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
    35  
    36      if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
    37          local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    38      }
    39      if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
    40          local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
    41      };
    42      if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
    43          local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    44      };
    45  
    46      let local_var_req = local_var_req_builder.build()?;
    47      let local_var_resp = local_var_client.execute(local_var_req).await?;
    48  
    49      let local_var_status = local_var_resp.status();
    50      let local_var_content = local_var_resp.text().await?;
    51  
    52      if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
    53          serde_json::from_str(&local_var_content).map_err(Error::from)
    54      } else {
    55          let local_var_entity: Option<GetConfigError> = serde_json::from_str(&local_var_content).ok();
    56          let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
    57          Err(Error::ResponseError(local_var_error))
    58      }
    59  }
    60