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 `scim_tokens` management namespace (CONTRACT §27.1).
//!
//! Bearer tokens for the SCIM 2.0 provisioning endpoint.

#![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 `scim_tokens` namespace handle.
///
/// Bearer tokens for the SCIM 2.0 provisioning endpoint.
///
/// 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 ScimTokens<'c> {
    pub(crate) client: &'c AxiamClient,
    pub(crate) scope: Scope,
}

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

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

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

    /// `POST /api/v1/scim-tokens`
    /// **Returns secret material, once.** `provisioning_token` is returned by
    /// this call and by no other; no later `get` will return it again. Discarding
    /// the result destroys the credential (§27.5 rule 3).
    /// 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 create(
        &self,
        body: &models::CreateScimTokenRequest,
    ) -> Result<models::CreateScimTokenResponse, AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "scim_tokens.create",
            verb: Verb::Post,
            path_template: "/api/v1/scim-tokens",
            path: "/api/v1/scim-tokens".to_string(),
            query: &query,
        };
        let wire: models::CreateScimTokenResponseWire =
            self.client.management_send(call, Some(body)).await?;
        Ok(models::CreateScimTokenResponse::from(wire))
    }

    /// `DELETE /api/v1/scim-tokens/{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 revoke(&self, id: Uuid) -> Result<(), AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "scim_tokens.revoke",
            verb: Verb::Delete,
            path_template: "/api/v1/scim-tokens/{id}",
            path: format!("/api/v1/scim-tokens/{id}"),
            query: &query,
        };
        self.client
            .management_send_no_content(call, None::<&()>)
            .await
    }
}