Skip to main content

bitwarden_api_api/apis/
users_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{AuthRequired, ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait UsersApi: Send + Sync {
29    /// GET /users/{id}/keys
30    async fn get_account_keys<'a>(
31        &self,
32        id: uuid::Uuid,
33    ) -> Result<models::PublicKeysResponseModel, Error<GetAccountKeysError>>;
34
35    /// GET /users/{id}/public-key
36    async fn get_public_key<'a>(
37        &self,
38        id: uuid::Uuid,
39    ) -> Result<models::UserKeyResponseModel, Error<GetPublicKeyError>>;
40}
41
42pub struct UsersApiClient {
43    configuration: Arc<configuration::Configuration>,
44}
45
46impl UsersApiClient {
47    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
48        Self { configuration }
49    }
50}
51
52#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
53#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
54impl UsersApi for UsersApiClient {
55    async fn get_account_keys<'a>(
56        &self,
57        id: uuid::Uuid,
58    ) -> Result<models::PublicKeysResponseModel, Error<GetAccountKeysError>> {
59        let local_var_configuration = &self.configuration;
60
61        let local_var_client = &local_var_configuration.client;
62
63        let local_var_uri_str = format!(
64            "{}/users/{id}/keys",
65            local_var_configuration.base_path,
66            id = id
67        );
68        let mut local_var_req_builder =
69            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
70
71        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
72
73        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
74    }
75
76    async fn get_public_key<'a>(
77        &self,
78        id: uuid::Uuid,
79    ) -> Result<models::UserKeyResponseModel, Error<GetPublicKeyError>> {
80        let local_var_configuration = &self.configuration;
81
82        let local_var_client = &local_var_configuration.client;
83
84        let local_var_uri_str = format!(
85            "{}/users/{id}/public-key",
86            local_var_configuration.base_path,
87            id = id
88        );
89        let mut local_var_req_builder =
90            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
91
92        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
93
94        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
95    }
96}
97
98/// struct for typed errors of method [`UsersApi::get_account_keys`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum GetAccountKeysError {
102    UnknownValue(serde_json::Value),
103}
104/// struct for typed errors of method [`UsersApi::get_public_key`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum GetPublicKeyError {
108    UnknownValue(serde_json::Value),
109}