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 reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`secrets_organization_id_trash_empty_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum SecretsOrganizationIdTrashEmptyPostError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`secrets_organization_id_trash_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum SecretsOrganizationIdTrashGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`secrets_organization_id_trash_restore_post`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum SecretsOrganizationIdTrashRestorePostError {
35    UnknownValue(serde_json::Value),
36}
37
38pub async fn secrets_organization_id_trash_empty_post(
39    configuration: &configuration::Configuration,
40    organization_id: uuid::Uuid,
41    uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
42) -> Result<(), Error<SecretsOrganizationIdTrashEmptyPostError>> {
43    let local_var_configuration = configuration;
44
45    let local_var_client = &local_var_configuration.client;
46
47    let local_var_uri_str = format!(
48        "{}/secrets/{organizationId}/trash/empty",
49        local_var_configuration.base_path,
50        organizationId = crate::apis::urlencode(organization_id.to_string())
51    );
52    let mut local_var_req_builder =
53        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
54
55    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56        local_var_req_builder =
57            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
58    }
59    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
60        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
61    };
62    local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid);
63
64    let local_var_req = local_var_req_builder.build()?;
65    let local_var_resp = local_var_client.execute(local_var_req).await?;
66
67    let local_var_status = local_var_resp.status();
68    let local_var_content = local_var_resp.text().await?;
69
70    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
71        Ok(())
72    } else {
73        let local_var_entity: Option<SecretsOrganizationIdTrashEmptyPostError> =
74            serde_json::from_str(&local_var_content).ok();
75        let local_var_error = ResponseContent {
76            status: local_var_status,
77            content: local_var_content,
78            entity: local_var_entity,
79        };
80        Err(Error::ResponseError(local_var_error))
81    }
82}
83
84pub async fn secrets_organization_id_trash_get(
85    configuration: &configuration::Configuration,
86    organization_id: uuid::Uuid,
87) -> Result<models::SecretWithProjectsListResponseModel, Error<SecretsOrganizationIdTrashGetError>>
88{
89    let local_var_configuration = configuration;
90
91    let local_var_client = &local_var_configuration.client;
92
93    let local_var_uri_str = format!(
94        "{}/secrets/{organizationId}/trash",
95        local_var_configuration.base_path,
96        organizationId = crate::apis::urlencode(organization_id.to_string())
97    );
98    let mut local_var_req_builder =
99        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
100
101    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
102        local_var_req_builder =
103            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
104    }
105    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
106        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
107    };
108
109    let local_var_req = local_var_req_builder.build()?;
110    let local_var_resp = local_var_client.execute(local_var_req).await?;
111
112    let local_var_status = local_var_resp.status();
113    let local_var_content = local_var_resp.text().await?;
114
115    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
116        serde_json::from_str(&local_var_content).map_err(Error::from)
117    } else {
118        let local_var_entity: Option<SecretsOrganizationIdTrashGetError> =
119            serde_json::from_str(&local_var_content).ok();
120        let local_var_error = ResponseContent {
121            status: local_var_status,
122            content: local_var_content,
123            entity: local_var_entity,
124        };
125        Err(Error::ResponseError(local_var_error))
126    }
127}
128
129pub async fn secrets_organization_id_trash_restore_post(
130    configuration: &configuration::Configuration,
131    organization_id: uuid::Uuid,
132    uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
133) -> Result<(), Error<SecretsOrganizationIdTrashRestorePostError>> {
134    let local_var_configuration = configuration;
135
136    let local_var_client = &local_var_configuration.client;
137
138    let local_var_uri_str = format!(
139        "{}/secrets/{organizationId}/trash/restore",
140        local_var_configuration.base_path,
141        organizationId = crate::apis::urlencode(organization_id.to_string())
142    );
143    let mut local_var_req_builder =
144        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
145
146    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
147        local_var_req_builder =
148            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
149    }
150    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
151        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
152    };
153    local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid);
154
155    let local_var_req = local_var_req_builder.build()?;
156    let local_var_resp = local_var_client.execute(local_var_req).await?;
157
158    let local_var_status = local_var_resp.status();
159    let local_var_content = local_var_resp.text().await?;
160
161    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
162        Ok(())
163    } else {
164        let local_var_entity: Option<SecretsOrganizationIdTrashRestorePostError> =
165            serde_json::from_str(&local_var_content).ok();
166        let local_var_error = ResponseContent {
167            status: local_var_status,
168            content: local_var_content,
169            entity: local_var_entity,
170        };
171        Err(Error::ResponseError(local_var_error))
172    }
173}