diff --git a/cmd/projects.go b/cmd/projects.go index 4ba28f08f..297ed5853 100644 --- a/cmd/projects.go +++ b/cmd/projects.go @@ -75,10 +75,10 @@ var ( projectName = args[0] } body := api.V1CreateProjectBody{ - Name: projectName, - OrganizationId: orgId, - DbPass: dbPassword, - Region: cast.Ptr(api.V1CreateProjectBodyRegion(region.Value)), + Name: projectName, + OrganizationSlug: orgId, + DbPass: dbPassword, + Region: cast.Ptr(api.V1CreateProjectBodyRegion(region.Value)), } if cmd.Flags().Changed("size") { body.DesiredInstanceSize = (*api.V1CreateProjectBodyDesiredInstanceSize)(&size.Value) diff --git a/internal/projects/create/create.go b/internal/projects/create/create.go index 9b8e03d1a..10bd5a460 100644 --- a/internal/projects/create/create.go +++ b/internal/projects/create/create.go @@ -38,7 +38,7 @@ func Run(ctx context.Context, params api.V1CreateProjectBody, fsys afero.Fs) err ` table += fmt.Sprintf( "|`%s`|`%s`|`%s`|`%s`|`%s`|\n", - resp.JSON201.OrganizationId, + resp.JSON201.OrganizationSlug, resp.JSON201.Id, strings.ReplaceAll(resp.JSON201.Name, "|", "\\|"), utils.FormatRegion(resp.JSON201.Region), @@ -64,11 +64,11 @@ func promptMissingParams(ctx context.Context, body *api.V1CreateProjectBody) err } else { fmt.Fprintln(os.Stderr, printKeyValue("Creating project", body.Name)) } - if len(body.OrganizationId) == 0 { - if body.OrganizationId, err = promptOrgId(ctx); err != nil { + if len(body.OrganizationSlug) == 0 { + if body.OrganizationSlug, err = promptOrgId(ctx); err != nil { return err } - fmt.Fprintln(os.Stderr, printKeyValue("Selected org-id", body.OrganizationId)) + fmt.Fprintln(os.Stderr, printKeyValue("Selected org-id", body.OrganizationSlug)) } if body.Region == nil || len(*body.Region) == 0 { region, err := promptProjectRegion(ctx) diff --git a/internal/projects/create/create_test.go b/internal/projects/create/create_test.go index 5e5363ded..484522415 100644 --- a/internal/projects/create/create_test.go +++ b/internal/projects/create/create_test.go @@ -16,10 +16,10 @@ import ( func TestProjectCreateCommand(t *testing.T) { var params = api.V1CreateProjectBody{ - Name: "Test Project", - OrganizationId: "combined-fuchsia-lion", - DbPass: "redacted", - Region: cast.Ptr(api.V1CreateProjectBodyRegionUsWest1), + Name: "Test Project", + OrganizationSlug: "combined-fuchsia-lion", + DbPass: "redacted", + Region: cast.Ptr(api.V1CreateProjectBodyRegionUsWest1), } t.Run("creates a new project", func(t *testing.T) { @@ -36,11 +36,11 @@ func TestProjectCreateCommand(t *testing.T) { JSON(params). Reply(201). JSON(api.V1ProjectResponse{ - Id: apitest.RandomProjectRef(), - OrganizationId: params.OrganizationId, - Name: params.Name, - Region: string(*params.Region), - CreatedAt: "2022-04-25T02:14:55.906498Z", + Id: apitest.RandomProjectRef(), + OrganizationSlug: params.OrganizationSlug, + Name: params.Name, + Region: string(*params.Region), + CreatedAt: "2022-04-25T02:14:55.906498Z", }) // Run test assert.NoError(t, Run(context.Background(), params, fsys)) diff --git a/internal/projects/list/list.go b/internal/projects/list/list.go index ef201f0c5..3c756abbf 100644 --- a/internal/projects/list/list.go +++ b/internal/projects/list/list.go @@ -49,7 +49,7 @@ func Run(ctx context.Context, fsys afero.Fs) error { table += fmt.Sprintf( "|`%s`|`%s`|`%s`|`%s`|`%s`|`%s`|\n", formatBullet(project.Linked), - project.OrganizationId, + project.OrganizationSlug, project.Id, strings.ReplaceAll(project.Name, "|", "\\|"), utils.FormatRegion(project.Region), diff --git a/internal/projects/list/list_test.go b/internal/projects/list/list_test.go index d5450bfb4..428dc2b88 100644 --- a/internal/projects/list/list_test.go +++ b/internal/projects/list/list_test.go @@ -27,11 +27,11 @@ func TestProjectListCommand(t *testing.T) { Reply(200). JSON([]api.V1ProjectResponse{ { - Id: apitest.RandomProjectRef(), - OrganizationId: "combined-fuchsia-lion", - Name: "Test Project", - Region: "us-west-1", - CreatedAt: "2022-04-25T02:14:55.906498Z", + Id: apitest.RandomProjectRef(), + OrganizationSlug: "combined-fuchsia-lion", + Name: "Test Project", + Region: "us-west-1", + CreatedAt: "2022-04-25T02:14:55.906498Z", }, }) // Run test diff --git a/internal/utils/flags/project_ref.go b/internal/utils/flags/project_ref.go index 3be14838e..fab292001 100644 --- a/internal/utils/flags/project_ref.go +++ b/internal/utils/flags/project_ref.go @@ -39,7 +39,7 @@ func PromptProjectRef(ctx context.Context, title string, opts ...tea.ProgramOpti for i, project := range *resp.JSON200 { items[i] = utils.PromptItem{ Summary: project.Id, - Details: fmt.Sprintf("name: %s, org: %s, region: %s", project.Name, project.OrganizationId, project.Region), + Details: fmt.Sprintf("name: %s, org: %s, region: %s", project.Name, project.OrganizationSlug, project.Region), } } choice, err := utils.PromptChoice(ctx, title, items, opts...) diff --git a/internal/utils/flags/project_ref_test.go b/internal/utils/flags/project_ref_test.go index ee6a5374a..5c4fc88c7 100644 --- a/internal/utils/flags/project_ref_test.go +++ b/internal/utils/flags/project_ref_test.go @@ -78,9 +78,9 @@ func TestProjectPrompt(t *testing.T) { Get("/v1/projects"). Reply(http.StatusOK). JSON([]api.V1ProjectResponse{{ - Id: "test-project", - Name: "My Project", - OrganizationId: "test-org", + Id: "test-project", + Name: "My Project", + OrganizationSlug: "test-org", }}) // Run test err := PromptProjectRef(context.Background(), "", input) diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 267dfb1cd..811f7c646 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -2942,8 +2942,13 @@ type OrganizationProjectsResponseProjectsStatus string // OrganizationResponseV1 defines model for OrganizationResponseV1. type OrganizationResponseV1 struct { + // Id Deprecated: Use `slug` instead. + // Deprecated: Id string `json:"id"` Name string `json:"name"` + + // Slug Organization slug + Slug string `json:"slug"` } // PgsodiumConfigResponse defines model for PgsodiumConfigResponse. @@ -2953,7 +2958,8 @@ type PgsodiumConfigResponse struct { // PostgresConfigResponse defines model for PostgresConfigResponse. type PostgresConfigResponse struct { - CheckpointTimeout *int `json:"checkpoint_timeout,omitempty"` + // CheckpointTimeout Default unit: s + CheckpointTimeout *string `json:"checkpoint_timeout,omitempty"` EffectiveCacheSize *string `json:"effective_cache_size,omitempty"` HotStandbyFeedback *bool `json:"hot_standby_feedback,omitempty"` LogicalDecodingWorkMem *string `json:"logical_decoding_work_mem,omitempty"` @@ -2972,12 +2978,16 @@ type PostgresConfigResponse struct { MaxWorkerProcesses *int `json:"max_worker_processes,omitempty"` SessionReplicationRole *PostgresConfigResponseSessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` - StatementTimeout *string `json:"statement_timeout,omitempty"` - TrackActivityQuerySize *string `json:"track_activity_query_size,omitempty"` - TrackCommitTimestamp *bool `json:"track_commit_timestamp,omitempty"` - WalKeepSize *string `json:"wal_keep_size,omitempty"` - WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` - WorkMem *string `json:"work_mem,omitempty"` + + // StatementTimeout Default unit: ms + StatementTimeout *string `json:"statement_timeout,omitempty"` + TrackActivityQuerySize *string `json:"track_activity_query_size,omitempty"` + TrackCommitTimestamp *bool `json:"track_commit_timestamp,omitempty"` + WalKeepSize *string `json:"wal_keep_size,omitempty"` + + // WalSenderTimeout Default unit: ms + WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` + WorkMem *string `json:"work_mem,omitempty"` } // PostgresConfigResponseSessionReplicationRole defines model for PostgresConfigResponse.SessionReplicationRole. @@ -3653,7 +3663,8 @@ type UpdatePgsodiumConfigBody struct { // UpdatePostgresConfigBody defines model for UpdatePostgresConfigBody. type UpdatePostgresConfigBody struct { - CheckpointTimeout *int `json:"checkpoint_timeout,omitempty"` + // CheckpointTimeout Default unit: s + CheckpointTimeout *string `json:"checkpoint_timeout,omitempty"` EffectiveCacheSize *string `json:"effective_cache_size,omitempty"` HotStandbyFeedback *bool `json:"hot_standby_feedback,omitempty"` LogicalDecodingWorkMem *string `json:"logical_decoding_work_mem,omitempty"` @@ -3673,12 +3684,16 @@ type UpdatePostgresConfigBody struct { RestartDatabase *bool `json:"restart_database,omitempty"` SessionReplicationRole *UpdatePostgresConfigBodySessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` - StatementTimeout *string `json:"statement_timeout,omitempty"` - TrackActivityQuerySize *string `json:"track_activity_query_size,omitempty"` - TrackCommitTimestamp *bool `json:"track_commit_timestamp,omitempty"` - WalKeepSize *string `json:"wal_keep_size,omitempty"` - WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` - WorkMem *string `json:"work_mem,omitempty"` + + // StatementTimeout Default unit: ms + StatementTimeout *string `json:"statement_timeout,omitempty"` + TrackActivityQuerySize *string `json:"track_activity_query_size,omitempty"` + TrackCommitTimestamp *bool `json:"track_commit_timestamp,omitempty"` + WalKeepSize *string `json:"wal_keep_size,omitempty"` + + // WalSenderTimeout Default unit: ms + WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` + WorkMem *string `json:"work_mem,omitempty"` } // UpdatePostgresConfigBodySessionReplicationRole defines model for UpdatePostgresConfigBody.SessionReplicationRole. @@ -3874,8 +3889,12 @@ type V1CreateProjectBody struct { // Name Name of your project Name string `json:"name"` - // OrganizationId Slug of your organization - OrganizationId string `json:"organization_id"` + // OrganizationId Deprecated: Use `organization_slug` instead. + // Deprecated: + OrganizationId *string `json:"organization_id,omitempty"` + + // OrganizationSlug Organization slug + OrganizationSlug string `json:"organization_slug"` // Plan Subscription Plan is now set on organization level and is ignored in this request // Deprecated: @@ -4142,9 +4161,13 @@ type V1ProjectResponse struct { // Name Name of your project Name string `json:"name"` - // OrganizationId Slug of your organization + // OrganizationId Deprecated: Use `organization_slug` instead. + // Deprecated: OrganizationId string `json:"organization_id"` + // OrganizationSlug Organization slug + OrganizationSlug string `json:"organization_slug"` + // Ref Project ref Ref string `json:"ref"` @@ -4181,9 +4204,13 @@ type V1ProjectWithDatabaseResponse struct { // Name Name of your project Name string `json:"name"` - // OrganizationId Slug of your organization + // OrganizationId Deprecated: Use `organization_slug` instead. + // Deprecated: OrganizationId string `json:"organization_id"` + // OrganizationSlug Organization slug + OrganizationSlug string `json:"organization_slug"` + // Ref Project ref Ref string `json:"ref"`