bitwarden-api-api 3.0.0

Api bindings for the Bitwarden API.
Documentation
/*
 * Bitwarden Internal API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: latest
 *
 * Generated by: https://openapi-generator.tech
 */

use std::sync::Arc;

use async_trait::async_trait;
#[cfg(feature = "mockall")]
use mockall::automock;
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};

use super::{Error, configuration};
use crate::{
    apis::{AuthRequired, ContentType, ResponseContent},
    models,
};

#[cfg_attr(feature = "mockall", automock)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait OrganizationAuthRequestsApi: Send + Sync {
    /// POST /organizations/{orgId}/auth-requests/deny
    async fn bulk_deny_requests<'a>(
        &self,
        org_id: uuid::Uuid,
        bulk_deny_admin_auth_request_request_model: Option<
            models::BulkDenyAdminAuthRequestRequestModel,
        >,
    ) -> Result<(), Error>;

    /// GET /organizations/{orgId}/auth-requests
    async fn get_pending_requests<'a>(
        &self,
        org_id: uuid::Uuid,
    ) -> Result<models::PendingOrganizationAuthRequestResponseModelListResponseModel, Error>;

    /// POST /organizations/{orgId}/auth-requests/{requestId}
    async fn update_auth_request<'a>(
        &self,
        org_id: uuid::Uuid,
        request_id: uuid::Uuid,
        admin_auth_request_update_request_model: Option<models::AdminAuthRequestUpdateRequestModel>,
    ) -> Result<(), Error>;

    /// POST /organizations/{orgId}/auth-requests
    async fn update_many_auth_requests<'a>(
        &self,
        org_id: uuid::Uuid,
        organization_auth_request_update_many_request_model: Option<
            Vec<models::OrganizationAuthRequestUpdateManyRequestModel>,
        >,
    ) -> Result<(), Error>;
}

pub struct OrganizationAuthRequestsApiClient {
    configuration: Arc<configuration::Configuration>,
}

impl OrganizationAuthRequestsApiClient {
    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
        Self { configuration }
    }
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl OrganizationAuthRequestsApi for OrganizationAuthRequestsApiClient {
    async fn bulk_deny_requests<'a>(
        &self,
        org_id: uuid::Uuid,
        bulk_deny_admin_auth_request_request_model: Option<
            models::BulkDenyAdminAuthRequestRequestModel,
        >,
    ) -> Result<(), Error> {
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!(
            "{}/organizations/{orgId}/auth-requests/deny",
            local_var_configuration.base_path,
            orgId = org_id
        );
        let mut local_var_req_builder =
            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
        local_var_req_builder =
            local_var_req_builder.json(&bulk_deny_admin_auth_request_request_model);

        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
    }

    async fn get_pending_requests<'a>(
        &self,
        org_id: uuid::Uuid,
    ) -> Result<models::PendingOrganizationAuthRequestResponseModelListResponseModel, Error> {
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!(
            "{}/organizations/{orgId}/auth-requests",
            local_var_configuration.base_path,
            orgId = org_id
        );
        let mut local_var_req_builder =
            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);

        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
    }

    async fn update_auth_request<'a>(
        &self,
        org_id: uuid::Uuid,
        request_id: uuid::Uuid,
        admin_auth_request_update_request_model: Option<models::AdminAuthRequestUpdateRequestModel>,
    ) -> Result<(), Error> {
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!(
            "{}/organizations/{orgId}/auth-requests/{requestId}",
            local_var_configuration.base_path,
            orgId = org_id,
            requestId = request_id
        );
        let mut local_var_req_builder =
            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
        local_var_req_builder =
            local_var_req_builder.json(&admin_auth_request_update_request_model);

        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
    }

    async fn update_many_auth_requests<'a>(
        &self,
        org_id: uuid::Uuid,
        organization_auth_request_update_many_request_model: Option<
            Vec<models::OrganizationAuthRequestUpdateManyRequestModel>,
        >,
    ) -> Result<(), Error> {
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!(
            "{}/organizations/{orgId}/auth-requests",
            local_var_configuration.base_path,
            orgId = org_id
        );
        let mut local_var_req_builder =
            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
        local_var_req_builder =
            local_var_req_builder.json(&organization_auth_request_update_many_request_model);

        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
    }
}