netlify_rust/apis/
user_api.rs

1/*
2 * Netlify's API documentation
3 *
4 * Netlify is a hosting service for the programmable web. It understands your documents and provides an API to handle atomic deploys of websites, manage form submissions, inject JavaScript snippets, and much more. This is a REST-style API that uses JSON for serialization and OAuth 2 for authentication.  This document is an OpenAPI reference for the Netlify API that you can explore. For more detailed instructions for common uses, please visit the [online documentation](https://www.netlify.com/docs/api/). Visit our Community forum to join the conversation about [understanding and using Netlify’s API](https://community.netlify.com/t/common-issue-understanding-and-using-netlifys-api/160).  Additionally, we have two API clients for your convenience: - [Go Client](https://github.com/netlify/open-api#go-client) - [JS Client](https://github.com/netlify/js-client)
5 *
6 * The version of the OpenAPI document: 2.5.0
7 * 
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 `get_current_user`
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetCurrentUserError {
22    DefaultResponse(crate::models::Error),
23    UnknownValue(serde_json::Value),
24}
25
26
27pub async fn get_current_user(configuration: &configuration::Configuration, ) -> Result<Vec<crate::models::User>, Error<GetCurrentUserError>> {
28
29    let local_var_client = &configuration.client;
30
31    let local_var_uri_str = format!("{}/user", configuration.base_path);
32    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
33
34    if let Some(ref local_var_user_agent) = configuration.user_agent {
35        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
36    }
37    if let Some(ref local_var_token) = configuration.oauth_access_token {
38        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
39    };
40
41    let local_var_req = local_var_req_builder.build()?;
42    let local_var_resp = local_var_client.execute(local_var_req).await?;
43
44    let local_var_status = local_var_resp.status();
45    let local_var_content = local_var_resp.text().await?;
46
47    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
48        serde_json::from_str(&local_var_content).map_err(Error::from)
49    } else {
50        let local_var_entity: Option<GetCurrentUserError> = serde_json::from_str(&local_var_content).ok();
51        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
52        Err(Error::ResponseError(local_var_error))
53    }
54}
55