Skip to content

Commit

Permalink
chore: update api/beta.yaml from staging v1-yaml (#2906)
Browse files Browse the repository at this point in the history
* chore: update api/beta.yaml from staging v1-yaml

* chore: revert to single quote

---------

Co-authored-by: Qiao Han <qiao@supabase.io>
  • Loading branch information
avallete and sweatybridge authored Nov 25, 2024
1 parent 8dbf6b2 commit 47bcb30
Show file tree
Hide file tree
Showing 12 changed files with 731 additions and 233 deletions.
233 changes: 191 additions & 42 deletions api/beta.yaml

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions cmd/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ var (
Allowed: awsRegions(),
}
plan = utils.EnumFlag{
Allowed: []string{string(api.V1CreateProjectBodyPlanFree), string(api.V1CreateProjectBodyPlanPro)},
Value: string(api.V1CreateProjectBodyPlanFree),
Allowed: []string{string(api.V1CreateProjectBodyDtoPlanFree), string(api.V1CreateProjectBodyDtoPlanPro)},
Value: string(api.V1CreateProjectBodyDtoPlanFree),
}
size = utils.EnumFlag{
Allowed: []string{
string(api.Micro),
string(api.Small),
string(api.Medium),
string(api.Large),
string(api.Xlarge),
string(api.N2xlarge),
string(api.N4xlarge),
string(api.N8xlarge),
string(api.N12xlarge),
string(api.N16xlarge),
string(api.DesiredInstanceSizeMicro),
string(api.DesiredInstanceSizeSmall),
string(api.DesiredInstanceSizeMedium),
string(api.DesiredInstanceSizeLarge),
string(api.DesiredInstanceSizeXlarge),
string(api.DesiredInstanceSizeN2xlarge),
string(api.DesiredInstanceSizeN4xlarge),
string(api.DesiredInstanceSizeN8xlarge),
string(api.DesiredInstanceSizeN12xlarge),
string(api.DesiredInstanceSizeN16xlarge),
},
}

Expand All @@ -69,14 +69,14 @@ var (
if len(args) > 0 {
projectName = args[0]
}
body := api.V1CreateProjectBody{
body := api.V1CreateProjectBodyDto{
Name: projectName,
OrganizationId: orgId,
DbPass: dbPassword,
Region: api.V1CreateProjectBodyRegion(region.Value),
Region: api.V1CreateProjectBodyDtoRegion(region.Value),
}
if cmd.Flags().Changed("size") {
body.DesiredInstanceSize = (*api.DesiredInstanceSize)(&size.Value)
body.DesiredInstanceSize = (*api.V1CreateProjectBodyDtoDesiredInstanceSize)(&size.Value)
}
return create.Run(cmd.Context(), body, afero.NewOsFs())
},
Expand Down
2 changes: 1 addition & 1 deletion internal/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func Run(ctx context.Context, starter StarterTemplate, fsys afero.Fs, options ..
return err
}
// 2. Create project
params := api.V1CreateProjectBody{
params := api.V1CreateProjectBodyDto{
Name: filepath.Base(workdir),
TemplateUrl: &starter.Url,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/link/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ func checkRemoteProjectStatus(ctx context.Context, projectRef string, fsys afero
}

switch resp.JSON200.Status {
case api.V1ProjectResponseStatusINACTIVE:
case api.V1ProjectWithDatabaseResponseStatusINACTIVE:
utils.CmdSuggestion = fmt.Sprintf("An admin must unpause it from the Supabase dashboard at %s", utils.Aqua(fmt.Sprintf("%s/project/%s", utils.GetSupabaseDashboardURL(), projectRef)))
return errors.New(errProjectPaused)
case api.V1ProjectResponseStatusACTIVEHEALTHY:
case api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY:
// Project is in the desired state, do nothing
default:
fmt.Fprintf(os.Stderr, "%s: Project status is %s instead of Active Healthy. Some operations might fail.\n", utils.Yellow("WARNING"), resp.JSON200.Status)
Expand Down
26 changes: 13 additions & 13 deletions internal/link/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func TestLinkCommand(t *testing.T) {
gock.New(utils.DefaultApiHost).
Get("/v1/projects/" + project).
Reply(200).
JSON(api.V1ProjectResponse{
Status: api.V1ProjectResponseStatusACTIVEHEALTHY,
Database: &postgres,
JSON(api.V1ProjectWithDatabaseResponse{
Status: api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY,
Database: postgres,
})
gock.New(utils.DefaultApiHost).
Get("/v1/projects/" + project + "/api-keys").
Expand Down Expand Up @@ -132,9 +132,9 @@ func TestLinkCommand(t *testing.T) {
gock.New(utils.DefaultApiHost).
Get("/v1/projects/" + project).
Reply(200).
JSON(api.V1ProjectResponse{
Status: api.V1ProjectResponseStatusACTIVEHEALTHY,
Database: &api.V1DatabaseResponse{},
JSON(api.V1ProjectWithDatabaseResponse{
Status: api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY,
Database: api.V1DatabaseResponse{},
})
gock.New(utils.DefaultApiHost).
Get("/v1/projects/" + project + "/api-keys").
Expand Down Expand Up @@ -186,9 +186,9 @@ func TestLinkCommand(t *testing.T) {
gock.New(utils.DefaultApiHost).
Get("/v1/projects/" + project).
Reply(200).
JSON(api.V1ProjectResponse{
Status: api.V1ProjectResponseStatusACTIVEHEALTHY,
Database: &api.V1DatabaseResponse{},
JSON(api.V1ProjectWithDatabaseResponse{
Status: api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY,
Database: api.V1DatabaseResponse{},
})
gock.New(utils.DefaultApiHost).
Get("/v1/projects/" + project + "/api-keys").
Expand Down Expand Up @@ -247,9 +247,9 @@ func TestStatusCheck(t *testing.T) {
gock.New(utils.DefaultApiHost).
Get("/v1/projects/" + project).
Reply(http.StatusOK).
JSON(api.V1ProjectResponse{
Status: api.V1ProjectResponseStatusACTIVEHEALTHY,
Database: &api.V1DatabaseResponse{Version: "15.6.1.139"},
JSON(api.V1ProjectWithDatabaseResponse{
Status: api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY,
Database: api.V1DatabaseResponse{Version: "15.6.1.139"},
})
// Run test
err := checkRemoteProjectStatus(context.Background(), project, fsys)
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestStatusCheck(t *testing.T) {
gock.New(utils.DefaultApiHost).
Get("/v1/projects/" + project).
Reply(http.StatusOK).
JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusINACTIVE})
JSON(api.V1ProjectWithDatabaseResponse{Status: api.V1ProjectWithDatabaseResponseStatusINACTIVE})
// Run test
err := checkRemoteProjectStatus(context.Background(), project, fsys)
// Check error
Expand Down
2 changes: 1 addition & 1 deletion internal/projects/apiKeys/api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs) error {
}

func RunGetApiKeys(ctx context.Context, projectRef string) ([]api.ApiKeyResponse, error) {
resp, err := utils.GetSupabase().V1GetProjectApiKeysWithResponse(ctx, projectRef)
resp, err := utils.GetSupabase().V1GetProjectApiKeysWithResponse(ctx, projectRef, &api.V1GetProjectApiKeysParams{})
if err != nil {
return nil, errors.Errorf("failed to get api keys: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/projects/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/supabase/cli/pkg/api"
)

func Run(ctx context.Context, params api.V1CreateProjectBody, fsys afero.Fs) error {
func Run(ctx context.Context, params api.V1CreateProjectBodyDto, fsys afero.Fs) error {
if err := promptMissingParams(ctx, &params); err != nil {
return err
}
Expand Down Expand Up @@ -49,7 +49,7 @@ func printKeyValue(key, value string) string {
return key + ":" + spaces + value
}

func promptMissingParams(ctx context.Context, body *api.V1CreateProjectBody) error {
func promptMissingParams(ctx context.Context, body *api.V1CreateProjectBodyDto) error {
var err error
if len(body.Name) == 0 {
if body.Name, err = promptProjectName(ctx); err != nil {
Expand Down Expand Up @@ -106,7 +106,7 @@ func promptOrgId(ctx context.Context) (string, error) {
return choice.Details, nil
}

func promptProjectRegion(ctx context.Context) (api.V1CreateProjectBodyRegion, error) {
func promptProjectRegion(ctx context.Context) (api.V1CreateProjectBodyDtoRegion, error) {
title := "Which region do you want to host the project in?"
items := make([]utils.PromptItem, len(utils.RegionMap))
i := 0
Expand All @@ -118,5 +118,5 @@ func promptProjectRegion(ctx context.Context) (api.V1CreateProjectBodyRegion, er
if err != nil {
return "", err
}
return api.V1CreateProjectBodyRegion(choice.Summary), nil
return api.V1CreateProjectBodyDtoRegion(choice.Summary), nil
}
4 changes: 2 additions & 2 deletions internal/projects/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
)

func TestProjectCreateCommand(t *testing.T) {
var params = api.V1CreateProjectBody{
var params = api.V1CreateProjectBodyDto{
Name: "Test Project",
OrganizationId: "combined-fuchsia-lion",
DbPass: "redacted",
Region: api.V1CreateProjectBodyRegionUsWest1,
Region: api.V1CreateProjectBodyDtoRegionUsWest1,
}

t.Run("creates a new project", func(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions internal/projects/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
)

type linkedProject struct {
api.V1ProjectResponse `yaml:",inline"`
Linked bool `json:"linked"`
api.V1ProjectWithDatabaseResponse `yaml:",inline"`
Linked bool `json:"linked"`
}

func Run(ctx context.Context, fsys afero.Fs) error {
Expand All @@ -37,8 +37,8 @@ func Run(ctx context.Context, fsys afero.Fs) error {
var projects []linkedProject
for _, project := range *resp.JSON200 {
projects = append(projects, linkedProject{
V1ProjectResponse: project,
Linked: project.Id == projectRef,
V1ProjectWithDatabaseResponse: project,
Linked: project.Id == projectRef,
})
}

Expand Down
2 changes: 1 addition & 1 deletion internal/utils/tenant/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewApiKey(resp []api.ApiKeyResponse) ApiKey {
}

func GetApiKeys(ctx context.Context, projectRef string) (ApiKey, error) {
resp, err := utils.GetSupabase().V1GetProjectApiKeysWithResponse(ctx, projectRef)
resp, err := utils.GetSupabase().V1GetProjectApiKeysWithResponse(ctx, projectRef, &api.V1GetProjectApiKeysParams{})
if err != nil {
return ApiKey{}, errors.Errorf("failed to get api keys: %w", err)
}
Expand Down
Loading

0 comments on commit 47bcb30

Please sign in to comment.