Skip to main content

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