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 `webauthn_policy` management namespace (CONTRACT §27.1).
//!
//! Per-tenant attestation policy governing the §24 ceremonies, and the
//! compliance report over it.

#![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 `webauthn_policy` namespace handle.
///
/// Per-tenant attestation policy governing the §24 ceremonies, and the
/// compliance report over it.
///
/// 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 WebauthnPolicy<'c> {
    pub(crate) client: &'c AxiamClient,
    pub(crate) scope: Scope,
}

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

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

    /// 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/tenants/{tenant_id}/webauthn/attestation-policy`
    pub async fn get(&self) -> Result<models::PolicyResponse, AxiamError> {
        let tenant_id = self.scope.tenant(self.client, "webauthn_policy.get")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "webauthn_policy.get",
            verb: Verb::Get,
            path_template: "/api/v1/tenants/{tenant_id}/webauthn/attestation-policy",
            path: format!("/api/v1/tenants/{tenant_id}/webauthn/attestation-policy"),
            query: &query,
        };
        self.client
            .management_send::<_, models::PolicyResponse>(call, None::<&()>)
            .await
    }

    /// `PUT /api/v1/tenants/{tenant_id}/webauthn/attestation-policy`
    /// **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(
        &self,
        body: &models::WebauthnAttestationPolicy,
    ) -> Result<models::WebauthnAttestationPolicy, AxiamError> {
        let tenant_id = self.scope.tenant(self.client, "webauthn_policy.set")?;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "webauthn_policy.set",
            verb: Verb::Put,
            path_template: "/api/v1/tenants/{tenant_id}/webauthn/attestation-policy",
            path: format!("/api/v1/tenants/{tenant_id}/webauthn/attestation-policy"),
            query: &query,
        };
        self.client
            .management_send::<_, models::WebauthnAttestationPolicy>(call, Some(body))
            .await
    }

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