supabase_management_rs/
storage.rs

1use serde::Deserialize;
2
3#[derive(Debug, Clone, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct StorageConfig {
6    pub file_size_limit: i64,
7    pub features: Features,
8}
9
10#[derive(Debug, Clone, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct Features {
13    pub image_transformation: ImageTransformation,
14    #[serde(rename = "s3Protocol")]
15    pub s3protocol: S3Protocol,
16}
17
18#[derive(Debug, Clone, Deserialize)]
19#[serde(rename_all = "camelCase")]
20pub struct ImageTransformation {
21    pub enabled: bool,
22}
23
24#[derive(Debug, Clone, Deserialize)]
25#[serde(rename_all = "camelCase")]
26pub struct S3Protocol {
27    pub enabled: bool,
28}
29
30#[derive(Debug, Clone, Deserialize)]
31pub struct Bucket {
32    pub id: String,
33    pub name: String,
34    pub owner: String,
35    pub created_at: String,
36    pub updated_at: String,
37    pub public: bool,
38}
39
40impl crate::Client {
41    /// Gets project's storage config
42    pub async fn get_storage_config(
43        &self,
44        project_id: &str,
45    ) -> Result<StorageConfig, crate::Error> {
46        self.get(format!("projects/{project_id}/config/storage"))
47            .await
48    }
49
50    pub async fn list_buckets(&self, project_id: &str) -> Result<Vec<Bucket>, crate::Error> {
51        self.get(format!("projects/{project_id}/storage/buckets"))
52            .await
53    }
54}