Skip to main content

bitwarden_api_api/apis/
projects_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 ProjectsApi: Send + Sync {
29    /// POST /projects/delete
30    async fn bulk_delete<'a>(
31        &self,
32        uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
33    ) -> Result<models::BulkDeleteResponseModelListResponseModel, Error>;
34
35    /// POST /organizations/{organizationId}/projects
36    async fn create<'a>(
37        &self,
38        organization_id: uuid::Uuid,
39        project_create_request_model: Option<models::ProjectCreateRequestModel>,
40    ) -> Result<models::ProjectResponseModel, Error>;
41
42    /// GET /projects/{id}
43    async fn get<'a>(&self, id: uuid::Uuid) -> Result<models::ProjectResponseModel, Error>;
44
45    /// GET /organizations/{organizationId}/projects
46    async fn list_by_organization<'a>(
47        &self,
48        organization_id: uuid::Uuid,
49    ) -> Result<models::ProjectResponseModelListResponseModel, Error>;
50
51    /// PUT /projects/{id}
52    async fn update<'a>(
53        &self,
54        id: uuid::Uuid,
55        project_update_request_model: Option<models::ProjectUpdateRequestModel>,
56    ) -> Result<models::ProjectResponseModel, Error>;
57}
58
59pub struct ProjectsApiClient {
60    configuration: Arc<configuration::Configuration>,
61}
62
63impl ProjectsApiClient {
64    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
65        Self { configuration }
66    }
67}
68
69#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
70#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
71impl ProjectsApi for ProjectsApiClient {
72    async fn bulk_delete<'a>(
73        &self,
74        uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
75    ) -> Result<models::BulkDeleteResponseModelListResponseModel, Error> {
76        let local_var_configuration = &self.configuration;
77
78        let local_var_client = &local_var_configuration.client;
79
80        let local_var_uri_str = format!("{}/projects/delete", local_var_configuration.base_path);
81        let mut local_var_req_builder =
82            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
83
84        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
85        local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid);
86
87        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
88    }
89
90    async fn create<'a>(
91        &self,
92        organization_id: uuid::Uuid,
93        project_create_request_model: Option<models::ProjectCreateRequestModel>,
94    ) -> Result<models::ProjectResponseModel, Error> {
95        let local_var_configuration = &self.configuration;
96
97        let local_var_client = &local_var_configuration.client;
98
99        let local_var_uri_str = format!(
100            "{}/organizations/{organizationId}/projects",
101            local_var_configuration.base_path,
102            organizationId = organization_id
103        );
104        let mut local_var_req_builder =
105            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
106
107        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
108        local_var_req_builder = local_var_req_builder.json(&project_create_request_model);
109
110        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
111    }
112
113    async fn get<'a>(&self, id: uuid::Uuid) -> Result<models::ProjectResponseModel, Error> {
114        let local_var_configuration = &self.configuration;
115
116        let local_var_client = &local_var_configuration.client;
117
118        let local_var_uri_str = format!(
119            "{}/projects/{id}",
120            local_var_configuration.base_path,
121            id = id
122        );
123        let mut local_var_req_builder =
124            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
125
126        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
127
128        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
129    }
130
131    async fn list_by_organization<'a>(
132        &self,
133        organization_id: uuid::Uuid,
134    ) -> Result<models::ProjectResponseModelListResponseModel, Error> {
135        let local_var_configuration = &self.configuration;
136
137        let local_var_client = &local_var_configuration.client;
138
139        let local_var_uri_str = format!(
140            "{}/organizations/{organizationId}/projects",
141            local_var_configuration.base_path,
142            organizationId = organization_id
143        );
144        let mut local_var_req_builder =
145            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
146
147        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
148
149        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
150    }
151
152    async fn update<'a>(
153        &self,
154        id: uuid::Uuid,
155        project_update_request_model: Option<models::ProjectUpdateRequestModel>,
156    ) -> Result<models::ProjectResponseModel, Error> {
157        let local_var_configuration = &self.configuration;
158
159        let local_var_client = &local_var_configuration.client;
160
161        let local_var_uri_str = format!(
162            "{}/projects/{id}",
163            local_var_configuration.base_path,
164            id = id
165        );
166        let mut local_var_req_builder =
167            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
168
169        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
170        local_var_req_builder = local_var_req_builder.json(&project_update_request_model);
171
172        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
173    }
174}