Skip to main content

mountos_admin_sdk/
lib.rs

1//! Rust SDK for the mountOS provider API.
2//!
3//! Wraps the appserv provider API (`/api/v1/*`) with ED25519 JWT authentication.
4//! Construct a [`Client`] from a [`Config`] and call typed methods grouped by
5//! resource, e.g. `client.accounts.list(..)`.
6//!
7//! ```no_run
8//! use mountos_admin_sdk::{Client, Config};
9//!
10//! # async fn run() -> Result<(), mountos_admin_sdk::Error> {
11//! let client = Client::new(Config::new(
12//!     "https://appserv.example.com",
13//!     "<base64 ED25519 key>",
14//! ))?;
15//!
16//! let account = client.accounts.get(1).await?;
17//! println!("{}", account.name);
18//! # Ok(())
19//! # }
20//! ```
21//!
22//! Public structs and enums are `#[non_exhaustive]`. Build a struct with `new(required...)`,
23//! `Default` and the `with_<field>` setters, not with a struct literal:
24//!
25//! ```
26//! use mountos_admin_sdk::{AccountListOptions, CreateAccountRequest};
27//!
28//! let req = CreateAccountRequest::new("Acme").with_description("Demo account");
29//! let opts = AccountListOptions::default().with_page(1).with_limit(10);
30//! # let _ = (req, opts);
31//! ```
32//!
33//! The `private_key` is a base64-encoded ED25519 key - either a 32-byte seed or
34//! a 64-byte seed+public-key. JWT tokens are signed locally and cached for ~55
35//! minutes (1h TTL with a 5-minute refresh margin).
36
37#![forbid(unsafe_code)]
38// Public structs and enums stay non_exhaustive so a new field or variant is not a breaking change.
39#![warn(clippy::exhaustive_structs, clippy::exhaustive_enums)]
40
41// Compiles and runs the README snippets as doc tests.
42#[cfg(doctest)]
43#[doc = include_str!("../README.md")]
44struct ReadmeDoctests;
45
46mod auth;
47// Generated files are not rustfmt-clean by construction.
48#[rustfmt::skip]
49mod client_gen;
50mod compat;
51mod dashboard_user;
52mod errors;
53mod http;
54mod providers;
55#[rustfmt::skip]
56mod types_gen;
57
58pub use client_gen::*;
59pub use compat::{DrainPairStorageResponse, Pair, PairState, UpdateVolumePairConfigRequest};
60pub use dashboard_user::sign_dashboard_user;
61pub use errors::Error;
62pub use providers::*;
63pub use types_gen::*;
64
65// Re-exported so callers can build `serde_json::Value` fields (e.g.
66// `provider_info`) without taking their own version-matched dependency.
67pub use serde_json;