netbox_openapi/apis/
authentication_check_api.rs1use reqwest;
12
13use super::{Error, configuration};
14use crate::apis::ResponseContent;
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum AuthenticationCheckRetrieveError {
20 UnknownValue(serde_json::Value),
21}
22
23pub async fn authentication_check_retrieve(
25 configuration: &configuration::Configuration,
26) -> Result<
27 ::std::collections::HashMap<String, serde_json::Value>,
28 Error<AuthenticationCheckRetrieveError>,
29> {
30 let local_var_configuration = configuration;
31
32 let local_var_client = &local_var_configuration.client;
33
34 let local_var_uri_str = format!(
35 "{}/api/authentication-check/",
36 local_var_configuration.base_path
37 );
38 let mut local_var_req_builder =
39 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
40
41 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
42 local_var_req_builder =
43 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
44 }
45 if let Some(ref local_var_apikey) = local_var_configuration.api_key {
46 let local_var_key = local_var_apikey.key.clone();
47 let local_var_value = match local_var_apikey.prefix {
48 Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
49 None => local_var_key,
50 };
51 local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
52 };
53
54 let local_var_req = local_var_req_builder.build()?;
55 let local_var_resp = local_var_client.execute(local_var_req).await?;
56
57 let local_var_status = local_var_resp.status();
58 let local_var_content = local_var_resp.text().await?;
59
60 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
61 serde_json::from_str(&local_var_content).map_err(Error::from)
62 } else {
63 let local_var_entity: Option<AuthenticationCheckRetrieveError> =
64 serde_json::from_str(&local_var_content).ok();
65 let local_var_error = ResponseContent {
66 status: local_var_status,
67 content: local_var_content,
68 entity: local_var_entity,
69 };
70 Err(Error::ResponseError(local_var_error))
71 }
72}