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<BulkDeleteError>>;
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<CreateError>>;
41
42    /// GET /projects/{id}
43    async fn get<'a>(
44        &self,
45        id: uuid::Uuid,
46    ) -> Result<models::ProjectResponseModel, Error<GetError>>;
47
48    /// GET /organizations/{organizationId}/projects
49    async fn list_by_organization<'a>(
50        &self,
51        organization_id: uuid::Uuid,
52    ) -> Result<models::ProjectResponseModelListResponseModel, Error<ListByOrganizationError>>;
53
54    /// PUT /projects/{id}
55    async fn update<'a>(
56        &self,
57        id: uuid::Uuid,
58        project_update_request_model: Option<models::ProjectUpdateRequestModel>,
59    ) -> Result<models::ProjectResponseModel, Error<UpdateError>>;
60}
61
62pub struct ProjectsApiClient {
63    configuration: Arc<configuration::Configuration>,
64}
65
66impl ProjectsApiClient {
67    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
68        Self { configuration }
69    }
70}
71
72#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
73#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
74impl ProjectsApi for ProjectsApiClient {
75    async fn bulk_delete<'a>(
76        &self,
77        uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
78    ) -> Result<models::BulkDeleteResponseModelListResponseModel, Error<BulkDeleteError>> {
79        let local_var_configuration = &self.configuration;
80
81        let local_var_client = &local_var_configuration.client;
82
83        let local_var_uri_str = format!("{}/projects/delete", local_var_configuration.base_path);
84        let mut local_var_req_builder =
85            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
86
87        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
88        local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid);
89
90        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
91    }
92
93    async fn create<'a>(
94        &self,
95        organization_id: uuid::Uuid,
96        project_create_request_model: Option<models::ProjectCreateRequestModel>,
97    ) -> Result<models::ProjectResponseModel, Error<CreateError>> {
98        let local_var_configuration = &self.configuration;
99
100        let local_var_client = &local_var_configuration.client;
101
102        let local_var_uri_str = format!(
103            "{}/organizations/{organizationId}/projects",
104            local_var_configuration.base_path,
105            organizationId = organization_id
106        );
107        let mut local_var_req_builder =
108            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
109
110        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
111        local_var_req_builder = local_var_req_builder.json(&project_create_request_model);
112
113        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
114    }
115
116    async fn get<'a>(
117        &self,
118        id: uuid::Uuid,
119    ) -> Result<models::ProjectResponseModel, Error<GetError>> {
120        let local_var_configuration = &self.configuration;
121
122        let local_var_client = &local_var_configuration.client;
123
124        let local_var_uri_str = format!(
125            "{}/projects/{id}",
126            local_var_configuration.base_path,
127            id = id
128        );
129        let mut local_var_req_builder =
130            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
131
132        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
133
134        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
135    }
136
137    async fn list_by_organization<'a>(
138        &self,
139        organization_id: uuid::Uuid,
140    ) -> Result<models::ProjectResponseModelListResponseModel, Error<ListByOrganizationError>> {
141        let local_var_configuration = &self.configuration;
142
143        let local_var_client = &local_var_configuration.client;
144
145        let local_var_uri_str = format!(
146            "{}/organizations/{organizationId}/projects",
147            local_var_configuration.base_path,
148            organizationId = organization_id
149        );
150        let mut local_var_req_builder =
151            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
152
153        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
154
155        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
156    }
157
158    async fn update<'a>(
159        &self,
160        id: uuid::Uuid,
161        project_update_request_model: Option<models::ProjectUpdateRequestModel>,
162    ) -> Result<models::ProjectResponseModel, Error<UpdateError>> {
163        let local_var_configuration = &self.configuration;
164
165        let local_var_client = &local_var_configuration.client;
166
167        let local_var_uri_str = format!(
168            "{}/projects/{id}",
169            local_var_configuration.base_path,
170            id = id
171        );
172        let mut local_var_req_builder =
173            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
174
175        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
176        local_var_req_builder = local_var_req_builder.json(&project_update_request_model);
177
178        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
179    }
180}
181
182/// struct for typed errors of method [`ProjectsApi::bulk_delete`]
183#[derive(Debug, Clone, Serialize, Deserialize)]
184#[serde(untagged)]
185pub enum BulkDeleteError {
186    UnknownValue(serde_json::Value),
187}
188/// struct for typed errors of method [`ProjectsApi::create`]
189#[derive(Debug, Clone, Serialize, Deserialize)]
190#[serde(untagged)]
191pub enum CreateError {
192    UnknownValue(serde_json::Value),
193}
194/// struct for typed errors of method [`ProjectsApi::get`]
195#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum GetError {
198    UnknownValue(serde_json::Value),
199}
200/// struct for typed errors of method [`ProjectsApi::list_by_organization`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum ListByOrganizationError {
204    UnknownValue(serde_json::Value),
205}
206/// struct for typed errors of method [`ProjectsApi::update`]
207#[derive(Debug, Clone, Serialize, Deserialize)]
208#[serde(untagged)]
209pub enum UpdateError {
210    UnknownValue(serde_json::Value),
211}