1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Async Rust client for the [SquareCloud](https://squarecloud.app) API.
//!
//! # Overview
//!
//! This crate provides typed, async access to every endpoint exposed by the
//! SquareCloud platform: deploying and managing applications, provisioning
//! databases, organising workspaces, and inspecting account information.
//!
//! The main entry point is [`ApiClient`]. It reads the `API_TOKEN`
//! environment variable (or a `.env` file) on first use, so no explicit
//! configuration struct is needed.
//!
//! # Quick start
//!
//! ```no_run
//! use squarecloud::ApiClient;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = ApiClient::new();
//!
//! // Fetch your account information.
//! let me = client.me().await?;
//! println!("Logged in as {} ({})", me.user.name, me.user.email);
//!
//! // Inspect a running application.
//! // Note: `app()` consumes the client, so call account-level
//! // methods first.
//! let status = client.app("your-app-id").status().await?;
//! println!("CPU: {} RAM: {}", status.cpu, status.ram);
//!
//! Ok(())
//! }
//! ```
//!
//! # Crate layout
//!
//! | Item | Purpose |
//! |------|---------|
//! | [`ApiClient`] | Root entry point; construct with [`ApiClient::new`]. |
//! | [`resources`] | Resource handles returned by the factory methods on `ApiClient`. |
//! | [`types`] | Plain data structs deserialised from API responses. |
//! | [`ApiError`] / [`ApiErrorCode`] | Errors returned by every API call. |
//! | [`CommitError`] | Error type specific to [`resources::AppResource::commit`]. |
//!
//! # Environment variables
//!
//! | Variable | Description |
//! |----------|-------------|
//! | `API_TOKEN` | Your SquareCloud API key. |
//!
//! Read at first use via [`dotenvy`](https://docs.rs/dotenvy), so a `.env`
//! file in the working directory is supported automatically.
/// Resource handles returned by the factory methods on [`ApiClient`].
/// Plain data structs deserialised from API responses.
pub use Endpoint;
pub use EndpointSpec;
pub use ;
pub use ApiClient;
pub use ;