Skip to main content

bitwarden_api_api/apis/
import_ciphers_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 ImportCiphersApi: Send + Sync {
29    /// POST /ciphers/import
30    async fn post_import<'a>(
31        &self,
32        import_ciphers_request_model: Option<models::ImportCiphersRequestModel>,
33    ) -> Result<(), Error<PostImportError>>;
34
35    /// POST /ciphers/import-organization
36    async fn post_import_organization<'a>(
37        &self,
38        organization_id: Option<&'a str>,
39        import_organization_ciphers_request_model: Option<
40            models::ImportOrganizationCiphersRequestModel,
41        >,
42    ) -> Result<(), Error<PostImportOrganizationError>>;
43}
44
45pub struct ImportCiphersApiClient {
46    configuration: Arc<configuration::Configuration>,
47}
48
49impl ImportCiphersApiClient {
50    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
51        Self { configuration }
52    }
53}
54
55#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
56#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
57impl ImportCiphersApi for ImportCiphersApiClient {
58    async fn post_import<'a>(
59        &self,
60        import_ciphers_request_model: Option<models::ImportCiphersRequestModel>,
61    ) -> Result<(), Error<PostImportError>> {
62        let local_var_configuration = &self.configuration;
63
64        let local_var_client = &local_var_configuration.client;
65
66        let local_var_uri_str = format!("{}/ciphers/import", local_var_configuration.base_path);
67        let mut local_var_req_builder =
68            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
69
70        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
71        local_var_req_builder = local_var_req_builder.json(&import_ciphers_request_model);
72
73        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
74    }
75
76    async fn post_import_organization<'a>(
77        &self,
78        organization_id: Option<&'a str>,
79        import_organization_ciphers_request_model: Option<
80            models::ImportOrganizationCiphersRequestModel,
81        >,
82    ) -> Result<(), Error<PostImportOrganizationError>> {
83        let local_var_configuration = &self.configuration;
84
85        let local_var_client = &local_var_configuration.client;
86
87        let local_var_uri_str = format!(
88            "{}/ciphers/import-organization",
89            local_var_configuration.base_path
90        );
91        let mut local_var_req_builder =
92            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
93
94        if let Some(ref param_value) = organization_id {
95            local_var_req_builder =
96                local_var_req_builder.query(&[("organizationId", &param_value.to_string())]);
97        }
98        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
99        local_var_req_builder =
100            local_var_req_builder.json(&import_organization_ciphers_request_model);
101
102        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
103    }
104}
105
106/// struct for typed errors of method [`ImportCiphersApi::post_import`]
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum PostImportError {
110    UnknownValue(serde_json::Value),
111}
112/// struct for typed errors of method [`ImportCiphersApi::post_import_organization`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum PostImportOrganizationError {
116    UnknownValue(serde_json::Value),
117}