Crate supabase_management_rs

Source
Expand description

§Supabase Management API Client

⚠️ Note: This crate is still a work in progress and not all API endpoints are implemented yet.

This crate provides a client for interacting with the Supabase Management API.

It allows management of Supabase projects, including:

  • Organization management: View and manage organizations
  • Project operations: Create, list, retrieve, update, delete, pause, and restore projects
  • Project configuration: Manage database settings, API keys, and network restrictions
  • Database management: Execute queries, manage database branches, and view usage metrics
  • Storage management: Configure buckets, policies, and other storage settings
  • Functions management: Deploy, list and configure edge functions
  • Project monitoring: Check health status and view logs
  • SSL enforcement: Configure custom domains and SSL settings
  • Postgres extensions: Manage available and enabled extensions

§Example

use supabase_management_rs::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a client with your Supabase management API key
    let client = Client::new("your-api-key".to_string());

    // List all projects
    let projects = client.list_projects().await?;

    // Get the first project
    if let Some(project) = projects.first() {
        println!("Project name: {}", project.name);

        // Check project health
        let health = client.get_project_health(&project.id).await?;
        println!("Project health: {:?}", health);

        // Execute a query
        let results: serde_json::Value = client
            .query(&project.id, "SELECT now()")
            .await?;
        println!("Query result: {:?}", results);

        // Pause a project
        client.pause_project(&project.id).await?;
    }

    Ok(())
}

Structs§

AccessTokenResponse
Bucket
Client
A client to interact with the Supabase Management API.
Database
Represents a Supabase database.
Error
Features
ImageTransformation
PostgresConfig
Represents the configuration settings for a Postgres database.
Project
Represents a Supabase project.
S3Protocol
ServiceHealth
StorageConfig
SupavisorConfig

Enums§

DatabaseType
PoolMode
SessionReplicationRole
Status

Functions§

generate_access_token
Generate a new access token using an existing refresh token.