axiam-sdk 1.2.2

Official Rust client SDK for AXIAM IAM
Documentation
// @generated by tools/gen_management.py from management-registry.json and
// openapi.json. DO NOT EDIT -- your changes will be overwritten. Regenerate
// with `tools/gen_management.py`; CI verifies the committed output is current.

//! The `email_config` management namespace (CONTRACT §27.1).
//!
//! Transactional-mail transport, configurable at organization level and
//! overridable per tenant.

#![allow(clippy::too_many_arguments)]

use uuid::Uuid;

use crate::AxiamError;
use crate::client::AxiamClient;
use crate::management::models;
use crate::management::request::{Call, Verb};
use crate::management::scope::Scope;

/// The `email_config` namespace handle.
///
/// Transactional-mail transport, configurable at organization level and
/// overridable per tenant.
///
/// Acquiring one performs no I/O and allocates nothing meaningful (§27.2 rule
/// 1); it borrows the client and cannot outlive it.
#[derive(Clone, Copy)]
pub struct EmailConfig<'c> {
    pub(crate) client: &'c AxiamClient,
    pub(crate) scope: Scope,
}

impl std::fmt::Debug for EmailConfig<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("EmailConfig")
            .field("scope", &self.scope)
            .finish()
    }
}

impl<'c> EmailConfig<'c> {
    pub(crate) fn new(client: &'c AxiamClient) -> Self {
        Self {
            client,
            scope: Scope::default(),
        }
    }

    /// Address a different organization than the client's own.
    ///
    /// §27.4 rule 3: the client's `org_id` is the default, and a platform-admin
    /// token legitimately overrides it.
    #[must_use]
    pub fn in_org(mut self, org_id: Uuid) -> Self {
        self.scope.org_id = Some(org_id);
        self
    }

    /// Address a different tenant than the client's own.
    ///
    /// §27.4 rule 3: the client's `tenant_id` is the default.
    #[must_use]
    pub fn for_tenant(mut self, tenant_id: Uuid) -> Self {
        self.scope.tenant_id = Some(tenant_id);
        self
    }

    /// `GET /api/v1/organizations/{org_id}/email-config`
    pub async fn get_org(&self) -> Result<models::EmailConfig, AxiamError> {
        let org_id = self.scope.org(self.client, "email_config.get_org")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "email_config.get_org",
            verb: Verb::Get,
            path_template: "/api/v1/organizations/{org_id}/email-config",
            path: format!("/api/v1/organizations/{org_id}/email-config"),
            query: &query,
        };
        self.client
            .management_send::<_, models::EmailConfig>(call, None::<&()>)
            .await
    }

    /// `PUT /api/v1/organizations/{org_id}/email-config`
    /// **This is a replacement, not a patch** (§27.4 rule 5). Its required fields
    /// must all be given, and what you do not carry over from a prior read is not
    /// preserved: an optional member left `None` is omitted, and the server
    /// applies that member's default rather than keeping the stored value --
    /// unless a note below says otherwise. Read first, change the field you mean,
    /// send the whole thing back.
    /// Not retried on failure (§27.4 rule 8): every write on this surface is
    /// issued exactly once, including the ones that look idempotent.
    pub async fn set_org(
        &self,
        body: &models::SetOrgEmailConfig,
    ) -> Result<models::EmailConfig, AxiamError> {
        let org_id = self.scope.org(self.client, "email_config.set_org")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "email_config.set_org",
            verb: Verb::Put,
            path_template: "/api/v1/organizations/{org_id}/email-config",
            path: format!("/api/v1/organizations/{org_id}/email-config"),
            query: &query,
        };
        self.client
            .management_send::<_, models::EmailConfig>(call, Some(body))
            .await
    }

    /// `DELETE /api/v1/organizations/{org_id}/email-config`
    /// Not retried on failure (§27.4 rule 8): every write on this surface is
    /// issued exactly once, including the ones that look idempotent.
    pub async fn delete_org(&self) -> Result<(), AxiamError> {
        let org_id = self.scope.org(self.client, "email_config.delete_org")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "email_config.delete_org",
            verb: Verb::Delete,
            path_template: "/api/v1/organizations/{org_id}/email-config",
            path: format!("/api/v1/organizations/{org_id}/email-config"),
            query: &query,
        };
        self.client
            .management_send_no_content(call, None::<&()>)
            .await
    }

    /// `POST /api/v1/organizations/{org_id}/email-config/test`
    /// Not retried on failure (§27.4 rule 8): every write on this surface is
    /// issued exactly once, including the ones that look idempotent.
    pub async fn test_org(&self) -> Result<models::EmailTestResult, AxiamError> {
        let org_id = self.scope.org(self.client, "email_config.test_org")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "email_config.test_org",
            verb: Verb::Post,
            path_template: "/api/v1/organizations/{org_id}/email-config/test",
            path: format!("/api/v1/organizations/{org_id}/email-config/test"),
            query: &query,
        };
        self.client
            .management_send::<_, models::EmailTestResult>(call, None::<&()>)
            .await
    }

    /// `GET /api/v1/tenants/{tenant_id}/email-config`
    pub async fn get_tenant(&self) -> Result<models::EmailConfigOverride, AxiamError> {
        let tenant_id = self.scope.tenant(self.client, "email_config.get_tenant")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "email_config.get_tenant",
            verb: Verb::Get,
            path_template: "/api/v1/tenants/{tenant_id}/email-config",
            path: format!("/api/v1/tenants/{tenant_id}/email-config"),
            query: &query,
        };
        self.client
            .management_send::<_, models::EmailConfigOverride>(call, None::<&()>)
            .await
    }

    /// `PUT /api/v1/tenants/{tenant_id}/email-config`
    /// Not retried on failure (§27.4 rule 8): every write on this surface is
    /// issued exactly once, including the ones that look idempotent.
    pub async fn set_tenant(
        &self,
        body: &models::EmailConfigOverride,
    ) -> Result<models::EmailConfigOverride, AxiamError> {
        let tenant_id = self.scope.tenant(self.client, "email_config.set_tenant")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "email_config.set_tenant",
            verb: Verb::Put,
            path_template: "/api/v1/tenants/{tenant_id}/email-config",
            path: format!("/api/v1/tenants/{tenant_id}/email-config"),
            query: &query,
        };
        self.client
            .management_send::<_, models::EmailConfigOverride>(call, Some(body))
            .await
    }

    /// `DELETE /api/v1/tenants/{tenant_id}/email-config`
    /// Not retried on failure (§27.4 rule 8): every write on this surface is
    /// issued exactly once, including the ones that look idempotent.
    pub async fn delete_tenant(&self) -> Result<(), AxiamError> {
        let tenant_id = self
            .scope
            .tenant(self.client, "email_config.delete_tenant")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "email_config.delete_tenant",
            verb: Verb::Delete,
            path_template: "/api/v1/tenants/{tenant_id}/email-config",
            path: format!("/api/v1/tenants/{tenant_id}/email-config"),
            query: &query,
        };
        self.client
            .management_send_no_content(call, None::<&()>)
            .await
    }

    /// `POST /api/v1/tenants/{tenant_id}/email-config/test`
    /// Not retried on failure (§27.4 rule 8): every write on this surface is
    /// issued exactly once, including the ones that look idempotent.
    pub async fn test_tenant(&self) -> Result<models::EmailTestResult, AxiamError> {
        let tenant_id = self.scope.tenant(self.client, "email_config.test_tenant")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "email_config.test_tenant",
            verb: Verb::Post,
            path_template: "/api/v1/tenants/{tenant_id}/email-config/test",
            path: format!("/api/v1/tenants/{tenant_id}/email-config/test"),
            query: &query,
        };
        self.client
            .management_send::<_, models::EmailTestResult>(call, None::<&()>)
            .await
    }
}