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 `privacy` management namespace (CONTRACT §27.1).
//!
//! GDPR self-service: the authenticated account's own export and erasure.
//! Scoped to the caller, never to another user.

#![allow(clippy::too_many_arguments)]

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

/// The `privacy` namespace handle.
///
/// GDPR self-service: the authenticated account's own export and erasure.
/// Scoped to the caller, never to another user.
///
/// 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 Privacy<'c> {
    pub(crate) client: &'c AxiamClient,
    pub(crate) scope: Scope,
}

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

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

    /// `POST /api/v1/account/export`
    /// 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 request_export(&self, body: &serde_json::Value) -> Result<(), AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "privacy.request_export",
            verb: Verb::Post,
            path_template: "/api/v1/account/export",
            path: "/api/v1/account/export".to_string(),
            query: &query,
        };
        self.client
            .management_send_no_content(call, Some(body))
            .await
    }

    /// `GET /api/v1/account/export/{token}`
    pub async fn download_export(&self, token: &str) -> Result<(), AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "privacy.download_export",
            verb: Verb::Get,
            path_template: "/api/v1/account/export/{token}",
            path: format!("/api/v1/account/export/{token}"),
            query: &query,
        };
        self.client
            .management_send_no_content(call, None::<&()>)
            .await
    }

    /// `POST /api/v1/account/delete`
    /// 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 request_delete(&self, body: &serde_json::Value) -> Result<(), AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "privacy.request_delete",
            verb: Verb::Post,
            path_template: "/api/v1/account/delete",
            path: "/api/v1/account/delete".to_string(),
            query: &query,
        };
        self.client
            .management_send_no_content(call, Some(body))
            .await
    }

    /// `GET /api/v1/auth/account/delete/cancel`
    pub async fn cancel_delete(&self, token: &str) -> Result<(), AxiamError> {
        let query: Vec<(&'static str, String)> = vec![("token", token.to_string())];
        let call = Call {
            operation: "privacy.cancel_delete",
            verb: Verb::Get,
            path_template: "/api/v1/auth/account/delete/cancel",
            path: "/api/v1/auth/account/delete/cancel".to_string(),
            query: &query,
        };
        self.client
            .management_send_no_content(call, None::<&()>)
            .await
    }

    /// `GET /api/v1/account/consents`
    pub async fn list_consents(&self) -> Result<Vec<models::ConsentView>, AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "privacy.list_consents",
            verb: Verb::Get,
            path_template: "/api/v1/account/consents",
            path: "/api/v1/account/consents".to_string(),
            query: &query,
        };
        self.client
            .management_send::<_, Vec<models::ConsentView>>(call, None::<&()>)
            .await
    }

    /// `POST /api/v1/account/consents/oidc-scopes`
    /// 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 grant_scope_consent(
        &self,
        body: &models::GrantScopeConsent,
    ) -> Result<(), AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "privacy.grant_scope_consent",
            verb: Verb::Post,
            path_template: "/api/v1/account/consents/oidc-scopes",
            path: "/api/v1/account/consents/oidc-scopes".to_string(),
            query: &query,
        };
        self.client
            .management_send_no_content(call, Some(body))
            .await
    }

    /// `DELETE /api/v1/account/consents/oidc-scopes/{client_id}`
    /// 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 withdraw_scope_consent(&self, client_id: &str) -> Result<(), AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "privacy.withdraw_scope_consent",
            verb: Verb::Delete,
            path_template: "/api/v1/account/consents/oidc-scopes/{client_id}",
            path: format!("/api/v1/account/consents/oidc-scopes/{client_id}"),
            query: &query,
        };
        self.client
            .management_send_no_content(call, None::<&()>)
            .await
    }
}