supabase_management_rs/
project.rs1use serde::{Deserialize, Serialize};
2
3use crate::Client;
4
5impl Client {
6 pub async fn list_projects(&self) -> Result<Vec<Project>, crate::error::Error> {
8 self.get("projects".into()).await
9 }
10
11 pub async fn pause_project(&self, project_id: &str) -> Result<(), crate::Error> {
13 self.post(format!("projects/{}/pause", project_id), None::<()>)
14 .await
15 }
16
17 pub async fn restore_project(&self, project_id: &str) -> Result<(), crate::Error> {
19 self.post(format!("projects/{}/restore", project_id), None::<()>)
20 .await
21 }
22
23 pub async fn get_project_health(
25 &self,
26 project_id: &str,
27 ) -> Result<Vec<ServiceHealth>, crate::Error> {
28 self.get(format!(
29 "projects/{}/health?services=auth,db,pooler,storage",
30 project_id
31 ))
32 .await
33 }
34}
35
36#[derive(Serialize, Deserialize, Debug)]
38pub struct Project {
39 pub id: String,
40 pub organization_id: String,
41 pub name: String,
42 pub region: String,
43 pub created_at: String,
44 pub status: Status,
45 pub database: Database,
46}
47
48#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy)]
49#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
50pub enum Status {
51 Inactive,
52 ActiveHealthy,
53 ActiveUnhealthy,
54 ComingUp,
55 Unknown,
56 GoingDown,
57 InitFailed,
58 Removed,
59 Restoring,
60 Upgrading,
61 Pausing,
62 RestoreFailed,
63 Restarting,
64 PauseFailed,
65 Resizing,
66}
67
68#[derive(Serialize, Deserialize, Debug)]
70pub struct Database {
71 pub host: String,
72 pub version: String,
73 pub postgres_engine: String,
74 pub release_channel: String,
75}
76
77#[derive(Debug, Deserialize, Clone)]
78pub struct ServiceHealth {
79 pub name: String,
80 pub healthy: bool,
81 pub status: Status,
82}