reasoninglayer 0.2.1

Rust client SDK for the Reasoning Layer API
Documentation
//! Administrative operations — destructive tenant / system-wide ops.

use crate::error::Error;
use crate::http::HttpClient;
use crate::types::admin::{ClearTenantResponse, FactoryResetResponse, ListTenantsResponse};
use crate::types::common::RequestOptions;

#[derive(Debug, Clone)]
pub struct AdminClient {
    http: HttpClient,
}

impl AdminClient {
    pub(crate) fn new(http: HttpClient) -> Self {
        Self { http }
    }

    /// Factory reset — wipes **all** tenants' data across every storage backend.
    pub async fn clear_all_data(
        &self,
        options: Option<&RequestOptions>,
    ) -> Result<FactoryResetResponse, Error> {
        self.http
            .post("/admin/clear-all", &serde_json::json!({}), options)
            .await
    }

    /// Clear all data for a specific tenant.
    pub async fn clear_tenant_data(
        &self,
        tenant_id: &str,
        options: Option<&RequestOptions>,
    ) -> Result<ClearTenantResponse, Error> {
        let path = format!("/admin/clear-tenant/{}", encode(tenant_id));
        self.http.post(&path, &serde_json::json!({}), options).await
    }

    /// List all tenants with data in the system.
    pub async fn list_tenants(
        &self,
        options: Option<&RequestOptions>,
    ) -> Result<ListTenantsResponse, Error> {
        self.http.get("/admin/tenants", None, options).await
    }
}

fn encode(s: &str) -> String {
    url::form_urlencoded::byte_serialize(s.as_bytes()).collect()
}