Skip to main content

Crate squarecloud

Crate squarecloud 

Source
Expand description

Async Rust client for the SquareCloud 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

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

ItemPurpose
ApiClientRoot entry point; construct with ApiClient::new.
resourcesResource handles returned by the factory methods on ApiClient.
typesPlain data structs deserialised from API responses.
ApiError / ApiErrorCodeErrors returned by every API call.
CommitErrorError type specific to resources::AppResource::commit.

§Environment variables

VariableDescription
API_TOKENYour SquareCloud API key.

Read at first use via dotenvy, so a .env file in the working directory is supported automatically.

Re-exports§

pub use types::CredentialType;
pub use types::DatabaseType;
pub use types::RealtimeEvent;
pub use types::SnapshotScope;

Modules§

resources
Resource handles returned by the factory methods on ApiClient.
types
Plain data structs deserialised from API responses.

Structs§

ApiClient
Authenticated HTTP client for the SquareCloud API.

Enums§

ApiError
An error returned by any API operation.
ApiErrorCode
Machine-readable error code returned by the SquareCloud API.
CommitError
An error that can occur during AppResource::commit.