Skip to main content

bitwarden_api_api/apis/
organization_keys_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 OrganizationKeysApi: Send + Sync {
29    /// POST /organizations/{orgId}/keys/organization-key-id
30    /// Reports the key id of the organization's current organization key, to backfill organizations
31    /// without one. Only Owners and Admins who hold the organization key can call this endpoint.
32    async fn set_organization_key_id<'a>(
33        &self,
34        org_id: uuid::Uuid,
35        set_organization_key_id_request: models::SetOrganizationKeyIdRequest,
36    ) -> Result<(), Error>;
37}
38
39pub struct OrganizationKeysApiClient {
40    configuration: Arc<configuration::Configuration>,
41}
42
43impl OrganizationKeysApiClient {
44    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
45        Self { configuration }
46    }
47}
48
49#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
50#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
51impl OrganizationKeysApi for OrganizationKeysApiClient {
52    /// Reports the key id of the organization's current organization key, to backfill organizations
53    /// without one. Only Owners and Admins who hold the organization key can call this endpoint.
54    async fn set_organization_key_id<'a>(
55        &self,
56        org_id: uuid::Uuid,
57        set_organization_key_id_request: models::SetOrganizationKeyIdRequest,
58    ) -> Result<(), Error> {
59        let local_var_configuration = &self.configuration;
60
61        let local_var_client = &local_var_configuration.client;
62
63        let local_var_uri_str = format!(
64            "{}/organizations/{orgId}/keys/organization-key-id",
65            local_var_configuration.base_path,
66            orgId = org_id
67        );
68        let mut local_var_req_builder =
69            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
70
71        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
72        local_var_req_builder = local_var_req_builder.json(&set_organization_key_id_request);
73
74        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
75    }
76}