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_targets` management namespace (CONTRACT §27.1).
//!
//! A tenant's outbound SCIM targets (CONTRACT §31): the downstream SCIM 2.0
//! service providers AXIAM pushes the tenant's users and groups to, each with
//! its delivery state. The credential AXIAM pushes with is write-only.
//! Deleting a target does not deprovision anything downstream.

#![allow(clippy::too_many_arguments)]

use uuid::Uuid;

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

/// The `scim_targets` namespace handle.
///
/// A tenant's outbound SCIM targets (CONTRACT §31): the downstream SCIM 2.0
/// service providers AXIAM pushes the tenant's users and groups to, each with
/// its delivery state. The credential AXIAM pushes with is write-only.
/// Deleting a target does not deprovision anything downstream.
///
/// 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 ScimTargets<'c> {
    pub(crate) client: &'c AxiamClient,
    pub(crate) scope: Scope,
}

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

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

    /// `GET /api/v1/scim-targets`
    pub async fn list(
        &self,
        page: PageRequest,
    ) -> Result<Page<models::ScimTargetResponse>, AxiamError> {
        let query = page.query();
        let call = Call {
            operation: "scim_targets.list",
            verb: Verb::Get,
            path_template: "/api/v1/scim-targets",
            path: "/api/v1/scim-targets".to_string(),
            query: &query,
        };
        self.client
            .management_send::<_, Page<models::ScimTargetResponse>>(call, None::<&()>)
            .await
    }

    /// Walk `scim_targets.list` to exhaustion, concatenating every page.
    ///
    /// The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
    /// if `total` disagrees, so a misreporting server costs one wasted request
    /// rather than an unbounded loop.
    pub async fn list_all(
        &self,
        start: PageRequest,
    ) -> Result<Vec<models::ScimTargetResponse>, AxiamError> {
        collect_pages(start, |p| self.list(p)).await
    }

    /// `POST /api/v1/scim-targets`
    ///
    /// `credential` is required here (§31.3 rule 2). It is write-only: no
    /// response ever carries it, and the SDK keeps no copy.
    /// 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::ScimTargetInput,
    ) -> Result<models::ScimTargetResponse, AxiamError> {
        let body = models::ScimTargetInputWire::from(body);
        let body = &body;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "scim_targets.create",
            verb: Verb::Post,
            path_template: "/api/v1/scim-targets",
            path: "/api/v1/scim-targets".to_string(),
            query: &query,
        };
        self.client
            .management_send::<_, models::ScimTargetResponse>(call, Some(body))
            .await
    }

    /// `GET /api/v1/scim-targets/{id}`
    pub async fn get(&self, id: Uuid) -> Result<models::ScimTargetResponse, AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "scim_targets.get",
            verb: Verb::Get,
            path_template: "/api/v1/scim-targets/{id}",
            path: format!("/api/v1/scim-targets/{id}"),
            query: &query,
        };
        self.client
            .management_send::<_, models::ScimTargetResponse>(call, None::<&()>)
            .await
    }

    /// `PUT /api/v1/scim-targets/{id}`
    /// **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.
    ///
    /// **The credential is bound to its URL** (§31.3 rule 2): absent `credential`
    /// keeps the stored one -- except that changing `base_url` of a bearer
    /// target, `auth.token_url` or `base_url` of a client-credentials target, or
    /// `auth.type`, without `credential` in the same write is refused `400` and
    /// changes nothing. The SDK holds no credential to re-send. Every other
    /// member left out takes its default. An update overtaken by another
    /// administrator's write is `409` (§31.3 rule 4): reload, then retry
    /// yourself.
    /// 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 update(
        &self,
        id: Uuid,
        body: &models::ScimTargetInput,
    ) -> Result<models::ScimTargetResponse, AxiamError> {
        let body = models::ScimTargetInputWire::from(body);
        let body = &body;
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "scim_targets.update",
            verb: Verb::Put,
            path_template: "/api/v1/scim-targets/{id}",
            path: format!("/api/v1/scim-targets/{id}"),
            query: &query,
        };
        self.client
            .management_send::<_, models::ScimTargetResponse>(call, Some(body))
            .await
    }

    /// `DELETE /api/v1/scim-targets/{id}`
    ///
    /// **Deprovisions nothing downstream** (§31.3 rule 8): the users and groups
    /// AXIAM created in the service provider stay there, and AXIAM no longer
    /// knows them. To remove them, set `deprovision` to `delete`, let AXIAM push,
    /// and only then delete the target.
    /// 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(&self, id: Uuid) -> Result<(), AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "scim_targets.delete",
            verb: Verb::Delete,
            path_template: "/api/v1/scim-targets/{id}",
            path: format!("/api/v1/scim-targets/{id}"),
            query: &query,
        };
        self.client
            .management_send_no_content(call, None::<&()>)
            .await
    }

    /// `POST /api/v1/scim-targets/{id}/reconcile`
    ///
    /// Starts a reconciliation in the background and answers `202`; its outcome
    /// is on the target's `state` (§31.3 rule 7). `409` while a run holds the
    /// claim, within five minutes of the last one, or for a disabled target.
    /// 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 reconcile(&self, id: Uuid) -> Result<models::ScimReconcileAccepted, AxiamError> {
        let query: Vec<(&'static str, String)> = Vec::new();
        let call = Call {
            operation: "scim_targets.reconcile",
            verb: Verb::Post,
            path_template: "/api/v1/scim-targets/{id}/reconcile",
            path: format!("/api/v1/scim-targets/{id}/reconcile"),
            query: &query,
        };
        self.client
            .management_send::<_, models::ScimReconcileAccepted>(call, None::<&()>)
            .await
    }
}