Rust SDK
The Rust SDK is published to crates.io as
platz-sdk, versioned to match the backend
release.
cargo add platz-sdk
Creating a client
PlatzClient::new() discovers the server URL and credentials automatically, trying in
order:
-
Environment variables —
PLATZ_URLplus eitherPLATZ_API_TOKEN(a user/bot token, sent via thex-platz-tokenheader) orPLATZ_USER_TOKEN(a JWT, sent asAuthorization: Bearer). -
A config file —
<config dir>/platz/config.toml(e.g.~/.config/platz/config.tomlon Linux) with named profiles. Select one with thePLATZ_PROFILEenvironment variable, or mark one withdefault_profile = true:[profile.prod]url = "https://platz.example.com"user_token = "<token>"default_profile = true -
Mounted deployment credentials —
/var/run/secrets/platz/(access_token,server_url,expires_at), which is where theplatz-credssecret lands when mounted into a deployment's pod. The client re-reads the files when the token nears expiry, so rotation is handled for you.
Usage
Typed helpers mirror the API resources — deployments, envs, clusters,
bots, secrets, and so on. List helpers take a filters struct and fetch all pages,
returning a flat Vec:
use platz_sdk::{DeploymentFilters, PlatzClient};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = PlatzClient::new().await?;
let deployments = client
.deployments(DeploymentFilters {
enabled: Some(true),
..Default::default()
})
.await?;
for deployment in deployments {
println!("{} ({})", deployment.name, deployment.status);
}
Ok(())
}
For endpoints or filters not covered by a typed helper, drop down to the raw request builder, which handles auth, pagination, and JSON for you:
let charts: Vec<serde_json::Value> = client
.request(reqwest::Method::GET, "/api/v2/helm-charts")
.query("kind_id", kind_id.to_string())
.paginated()
.await?;