• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 12393231684

18 Dec 2024 12:45PM UTC coverage: 59.705% (-0.04%) from 59.744%
12393231684

Pull #2982

github

web-flow
Merge 3640979fc into b0f139950
Pull Request #2982: realtime: Bump image to 2.33.70

7650 of 12813 relevant lines covered (59.7%)

203.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/pkg/storage/buckets.go
1
package storage
2

3
import (
4
        "context"
5
        "net/http"
6

7
        "github.com/supabase/cli/pkg/fetcher"
8
)
9

10
type BucketResponse struct {
11
        Id               string   `json:"id"`                 // "test"
12
        Name             string   `json:"name"`               // "test"
13
        Owner            string   `json:"owner"`              // ""
14
        Public           bool     `json:"public"`             // true
15
        FileSizeLimit    *int     `json:"file_size_limit"`    // null
16
        AllowedMimeTypes []string `json:"allowed_mime_types"` // null
17
        CreatedAt        string   `json:"created_at"`         // "2023-10-13T17:48:58.491Z"
18
        UpdatedAt        string   `json:"updated_at"`         // "2023-10-13T17:48:58.491Z"
19
}
20

21
func (s *StorageAPI) ListBuckets(ctx context.Context) ([]BucketResponse, error) {
15✔
22
        resp, err := s.Send(ctx, http.MethodGet, "/storage/v1/bucket", nil)
15✔
23
        if err != nil {
17✔
24
                return nil, err
2✔
25
        }
2✔
26
        return fetcher.ParseJSON[[]BucketResponse](resp.Body)
13✔
27
}
28

29
type CreateBucketRequest struct {
30
        Name             string   `json:"name"`                         // "string",
31
        Id               string   `json:"id,omitempty"`                 // "string",
32
        Public           *bool    `json:"public,omitempty"`             // false,
33
        FileSizeLimit    int64    `json:"file_size_limit,omitempty"`    // 0,
34
        AllowedMimeTypes []string `json:"allowed_mime_types,omitempty"` // ["string"]
35
}
36

37
type CreateBucketResponse struct {
38
        Name string `json:"name"`
39
}
40

41
func (s *StorageAPI) CreateBucket(ctx context.Context, body CreateBucketRequest) (CreateBucketResponse, error) {
3✔
42
        resp, err := s.Send(ctx, http.MethodPost, "/storage/v1/bucket", body)
3✔
43
        if err != nil {
4✔
44
                return CreateBucketResponse{}, err
1✔
45
        }
1✔
46
        return fetcher.ParseJSON[CreateBucketResponse](resp.Body)
2✔
47
}
48

49
type UpdateBucketRequest struct {
50
        Id               string   `json:"-"`
51
        Public           *bool    `json:"public,omitempty"`             // false,
52
        FileSizeLimit    int64    `json:"file_size_limit,omitempty"`    // 0,
53
        AllowedMimeTypes []string `json:"allowed_mime_types,omitempty"` // ["string"]
54
}
55

56
type UpdateBucketResponse struct {
57
        Message string `json:"message"`
58
}
59

60
func (s *StorageAPI) UpdateBucket(ctx context.Context, body UpdateBucketRequest) (UpdateBucketResponse, error) {
1✔
61
        resp, err := s.Send(ctx, http.MethodPut, "/storage/v1/bucket/"+body.Id, body)
1✔
62
        if err != nil {
1✔
63
                return UpdateBucketResponse{}, err
×
64
        }
×
65
        return fetcher.ParseJSON[UpdateBucketResponse](resp.Body)
1✔
66
}
67

68
type DeleteBucketResponse struct {
69
        Message string `json:"message"`
70
}
71

72
func (s *StorageAPI) DeleteBucket(ctx context.Context, bucketId string) (DeleteBucketResponse, error) {
1✔
73
        resp, err := s.Send(ctx, http.MethodDelete, "/storage/v1/bucket/"+bucketId, nil)
1✔
74
        if err != nil {
1✔
75
                return DeleteBucketResponse{}, err
×
76
        }
×
77
        return fetcher.ParseJSON[DeleteBucketResponse](resp.Body)
1✔
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc