Skip to main content

bitwarden_api_api/apis/
counts_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 CountsApi: Send + Sync {
29    /// GET /organizations/{organizationId}/sm-counts
30    async fn get_by_organization<'a>(
31        &self,
32        organization_id: uuid::Uuid,
33    ) -> Result<models::OrganizationCountsResponseModel, Error<GetByOrganizationError>>;
34
35    /// GET /projects/{projectId}/sm-counts
36    async fn get_by_project<'a>(
37        &self,
38        project_id: uuid::Uuid,
39    ) -> Result<models::ProjectCountsResponseModel, Error<GetByProjectError>>;
40
41    /// GET /service-accounts/{serviceAccountId}/sm-counts
42    async fn get_by_service_account<'a>(
43        &self,
44        service_account_id: uuid::Uuid,
45    ) -> Result<models::ServiceAccountCountsResponseModel, Error<GetByServiceAccountError>>;
46}
47
48pub struct CountsApiClient {
49    configuration: Arc<configuration::Configuration>,
50}
51
52impl CountsApiClient {
53    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
54        Self { configuration }
55    }
56}
57
58#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
59#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
60impl CountsApi for CountsApiClient {
61    async fn get_by_organization<'a>(
62        &self,
63        organization_id: uuid::Uuid,
64    ) -> Result<models::OrganizationCountsResponseModel, Error<GetByOrganizationError>> {
65        let local_var_configuration = &self.configuration;
66
67        let local_var_client = &local_var_configuration.client;
68
69        let local_var_uri_str = format!(
70            "{}/organizations/{organizationId}/sm-counts",
71            local_var_configuration.base_path,
72            organizationId = organization_id
73        );
74        let mut local_var_req_builder =
75            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
76
77        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
78
79        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
80    }
81
82    async fn get_by_project<'a>(
83        &self,
84        project_id: uuid::Uuid,
85    ) -> Result<models::ProjectCountsResponseModel, Error<GetByProjectError>> {
86        let local_var_configuration = &self.configuration;
87
88        let local_var_client = &local_var_configuration.client;
89
90        let local_var_uri_str = format!(
91            "{}/projects/{projectId}/sm-counts",
92            local_var_configuration.base_path,
93            projectId = project_id
94        );
95        let mut local_var_req_builder =
96            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
97
98        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
99
100        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
101    }
102
103    async fn get_by_service_account<'a>(
104        &self,
105        service_account_id: uuid::Uuid,
106    ) -> Result<models::ServiceAccountCountsResponseModel, Error<GetByServiceAccountError>> {
107        let local_var_configuration = &self.configuration;
108
109        let local_var_client = &local_var_configuration.client;
110
111        let local_var_uri_str = format!(
112            "{}/service-accounts/{serviceAccountId}/sm-counts",
113            local_var_configuration.base_path,
114            serviceAccountId = service_account_id
115        );
116        let mut local_var_req_builder =
117            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
118
119        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
120
121        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
122    }
123}
124
125/// struct for typed errors of method [`CountsApi::get_by_organization`]
126#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum GetByOrganizationError {
129    UnknownValue(serde_json::Value),
130}
131/// struct for typed errors of method [`CountsApi::get_by_project`]
132#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum GetByProjectError {
135    UnknownValue(serde_json::Value),
136}
137/// struct for typed errors of method [`CountsApi::get_by_service_account`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum GetByServiceAccountError {
141    UnknownValue(serde_json::Value),
142}