From a5da2d9f7badf3c3fdb96ef7c5ba36df2607c1b7 Mon Sep 17 00:00:00 2001 From: joe miller Date: Fri, 6 Sep 2024 20:45:45 +0000 Subject: [PATCH 01/12] update OpenAPI spec and regenerate client code --- GNUmakefile | 12 + internal/client/planetscale/planetscale.go | 1649 ++++++++++++--- internal/cmd/client_codegen/jenny.go | 5 +- internal/cmd/client_codegen/main.go | 23 +- internal/provider/backup_resource.go | 4 +- internal/provider/branch_resource.go | 40 +- internal/provider/database_resource.go | 22 +- internal/provider/models_data_source.go | 126 +- internal/provider/password_data_source.go | 2 +- internal/provider/password_resource.go | 2 +- internal/provider/provider.go | 7 + internal/provider/user_data_source.go | 6 +- openapi-spec.json | 1879 +++++++++++++---- openapi/openapi-spec.json | 2141 +++++++++++++++----- script/update_openapi_spec | 4 +- 15 files changed, 4694 insertions(+), 1228 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 7771cd6..a5d7b22 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,6 +1,18 @@ default: testacc +.PHONY: lint +lint: + golangci-lint run -v ./... + # Run acceptance tests .PHONY: testacc testacc: TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m + +.PHONY: generate +generate: + bash ./script/update_openapi_spec + bash ./script/generate + # curl https://api.planetscale.com/v1/openapi-spec >./openapi/openapi-spec.json + # cd ./internal/cmd/extractref && go run . >../../../openapi-spec.json + # cd ./internal/cmd/client_codegen && go run . >../../client/planetscale/planetscale.go \ No newline at end of file diff --git a/internal/client/planetscale/planetscale.go b/internal/client/planetscale/planetscale.go index 65d69fb..d4d009f 100644 --- a/internal/client/planetscale/planetscale.go +++ b/internal/client/planetscale/planetscale.go @@ -44,10 +44,10 @@ type Actor struct { Id string `json:"id" tfsdk:"id"` } type Backup struct { - Actor Actor `json:"actor" tfsdk:"actor"` - BackupPolicy BackupPolicy `json:"backup_policy" tfsdk:"backup_policy"` + Actor *Actor `json:"actor,omitempty" tfsdk:"actor"` + BackupPolicy *BackupPolicy `json:"backup_policy,omitempty" tfsdk:"backup_policy"` CreatedAt string `json:"created_at" tfsdk:"created_at"` - EstimatedStorageCost string `json:"estimated_storage_cost" tfsdk:"estimated_storage_cost"` + EstimatedStorageCost float64 `json:"estimated_storage_cost" tfsdk:"estimated_storage_cost"` Id string `json:"id" tfsdk:"id"` Name string `json:"name" tfsdk:"name"` Required bool `json:"required" tfsdk:"required"` @@ -73,13 +73,11 @@ type BackupPolicy struct { UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` } type Branch struct { - AccessHostUrl *string `json:"access_host_url,omitempty" tfsdk:"access_host_url"` Actor *Actor `json:"actor,omitempty" tfsdk:"actor"` ClusterRateName string `json:"cluster_rate_name" tfsdk:"cluster_rate_name"` CreatedAt string `json:"created_at" tfsdk:"created_at"` HtmlUrl string `json:"html_url" tfsdk:"html_url"` Id string `json:"id" tfsdk:"id"` - InitialRestoreId *string `json:"initial_restore_id,omitempty" tfsdk:"initial_restore_id"` MysqlAddress string `json:"mysql_address" tfsdk:"mysql_address"` MysqlEdgeAddress string `json:"mysql_edge_address" tfsdk:"mysql_edge_address"` Name string `json:"name" tfsdk:"name"` @@ -89,6 +87,7 @@ type Branch struct { Region *Region `json:"region,omitempty" tfsdk:"region"` RestoreChecklistCompletedAt *string `json:"restore_checklist_completed_at,omitempty" tfsdk:"restore_checklist_completed_at"` RestoredFromBranch *RestoredFromBranch `json:"restored_from_branch,omitempty" tfsdk:"restored_from_branch"` + SafeMigrations bool `json:"safe_migrations" tfsdk:"safe_migrations"` SchemaLastUpdatedAt string `json:"schema_last_updated_at" tfsdk:"schema_last_updated_at"` ShardCount *float64 `json:"shard_count,omitempty" tfsdk:"shard_count"` Sharded bool `json:"sharded" tfsdk:"sharded"` @@ -125,7 +124,6 @@ type DataSource struct { type Database struct { AllowDataBranching bool `json:"allow_data_branching" tfsdk:"allow_data_branching"` AtBackupRestoreBranchesLimit bool `json:"at_backup_restore_branches_limit" tfsdk:"at_backup_restore_branches_limit"` - AtDevelopmentBranchLimit bool `json:"at_development_branch_limit" tfsdk:"at_development_branch_limit"` AutomaticMigrations *bool `json:"automatic_migrations,omitempty" tfsdk:"automatic_migrations"` BranchesCount float64 `json:"branches_count" tfsdk:"branches_count"` BranchesUrl string `json:"branches_url" tfsdk:"branches_url"` @@ -154,7 +152,6 @@ type Database struct { SchemaLastUpdatedAt *string `json:"schema_last_updated_at,omitempty" tfsdk:"schema_last_updated_at"` Sharded bool `json:"sharded" tfsdk:"sharded"` State string `json:"state" tfsdk:"state"` - Type string `json:"type" tfsdk:"type"` UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` Url string `json:"url" tfsdk:"url"` } @@ -183,6 +180,7 @@ type DeployRequest struct { BranchDeleted bool `json:"branch_deleted" tfsdk:"branch_deleted"` BranchDeletedAt string `json:"branch_deleted_at" tfsdk:"branch_deleted_at"` BranchDeletedBy Actor `json:"branch_deleted_by" tfsdk:"branch_deleted_by"` + BranchId string `json:"branch_id" tfsdk:"branch_id"` ClosedAt string `json:"closed_at" tfsdk:"closed_at"` ClosedBy Actor `json:"closed_by" tfsdk:"closed_by"` CreatedAt string `json:"created_at" tfsdk:"created_at"` @@ -206,6 +204,7 @@ type DeployRequestWithDeployment struct { BranchDeleted bool `json:"branch_deleted" tfsdk:"branch_deleted"` BranchDeletedAt string `json:"branch_deleted_at" tfsdk:"branch_deleted_at"` BranchDeletedBy Actor `json:"branch_deleted_by" tfsdk:"branch_deleted_by"` + BranchId string `json:"branch_id" tfsdk:"branch_id"` ClosedAt string `json:"closed_at" tfsdk:"closed_at"` ClosedBy Actor `json:"closed_by" tfsdk:"closed_by"` CreatedAt string `json:"created_at" tfsdk:"created_at"` @@ -336,26 +335,24 @@ type OauthUserAccesses struct { Users []string `json:"users" tfsdk:"users"` } type Organization struct { - AdminOnlyProductionAccess bool `json:"admin_only_production_access" tfsdk:"admin_only_production_access"` - BillingEmail *string `json:"billing_email,omitempty" tfsdk:"billing_email"` - CanCreateDatabases bool `json:"can_create_databases" tfsdk:"can_create_databases"` - CreatedAt string `json:"created_at" tfsdk:"created_at"` - DatabaseCount float64 `json:"database_count" tfsdk:"database_count"` - Features *Features `json:"features,omitempty" tfsdk:"features"` - Flags *Flags `json:"flags,omitempty" tfsdk:"flags"` - FreeDatabasesRemaining float64 `json:"free_databases_remaining" tfsdk:"free_databases_remaining"` - HasPastDueInvoices bool `json:"has_past_due_invoices" tfsdk:"has_past_due_invoices"` - Id string `json:"id" tfsdk:"id"` - IdpManagedRoles bool `json:"idp_managed_roles" tfsdk:"idp_managed_roles"` - Name string `json:"name" tfsdk:"name"` - Plan string `json:"plan" tfsdk:"plan"` - SingleTenancy bool `json:"single_tenancy" tfsdk:"single_tenancy"` - SleepingDatabaseCount float64 `json:"sleeping_database_count" tfsdk:"sleeping_database_count"` - Sso bool `json:"sso" tfsdk:"sso"` - SsoDirectory bool `json:"sso_directory" tfsdk:"sso_directory"` - SsoPortalUrl *string `json:"sso_portal_url,omitempty" tfsdk:"sso_portal_url"` - UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` - ValidBillingInfo bool `json:"valid_billing_info" tfsdk:"valid_billing_info"` + BillingEmail *string `json:"billing_email,omitempty" tfsdk:"billing_email"` + CreatedAt string `json:"created_at" tfsdk:"created_at"` + DatabaseCount float64 `json:"database_count" tfsdk:"database_count"` + Features *Features `json:"features,omitempty" tfsdk:"features"` + Flags *Flags `json:"flags,omitempty" tfsdk:"flags"` + HasPastDueInvoices bool `json:"has_past_due_invoices" tfsdk:"has_past_due_invoices"` + Id string `json:"id" tfsdk:"id"` + IdpManagedRoles bool `json:"idp_managed_roles" tfsdk:"idp_managed_roles"` + InvoiceBudgetAmount float64 `json:"invoice_budget_amount" tfsdk:"invoice_budget_amount"` + Name string `json:"name" tfsdk:"name"` + Plan string `json:"plan" tfsdk:"plan"` + SingleTenancy bool `json:"single_tenancy" tfsdk:"single_tenancy"` + SleepingDatabaseCount float64 `json:"sleeping_database_count" tfsdk:"sleeping_database_count"` + Sso bool `json:"sso" tfsdk:"sso"` + SsoDirectory bool `json:"sso_directory" tfsdk:"sso_directory"` + SsoPortalUrl *string `json:"sso_portal_url,omitempty" tfsdk:"sso_portal_url"` + UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` + ValidBillingInfo bool `json:"valid_billing_info" tfsdk:"valid_billing_info"` } type Password struct { AccessHostUrl string `json:"access_host_url" tfsdk:"access_host_url"` @@ -368,6 +365,7 @@ type Password struct { Name string `json:"name" tfsdk:"name"` Region *Region `json:"region,omitempty" tfsdk:"region"` Renewable bool `json:"renewable" tfsdk:"renewable"` + Replica bool `json:"replica" tfsdk:"replica"` Role string `json:"role" tfsdk:"role"` TtlSeconds float64 `json:"ttl_seconds" tfsdk:"ttl_seconds"` Username *string `json:"username,omitempty" tfsdk:"username"` @@ -384,6 +382,7 @@ type PasswordWithPlaintext struct { PlainText string `json:"plain_text" tfsdk:"plain_text"` Region *Region `json:"region,omitempty" tfsdk:"region"` Renewable bool `json:"renewable" tfsdk:"renewable"` + Replica bool `json:"replica" tfsdk:"replica"` Role string `json:"role" tfsdk:"role"` TtlSeconds float64 `json:"ttl_seconds" tfsdk:"ttl_seconds"` Username *string `json:"username,omitempty" tfsdk:"username"` @@ -441,20 +440,27 @@ type TableSchema struct { Name string `json:"name" tfsdk:"name"` Raw string `json:"raw" tfsdk:"raw"` } +type User_DefaultOrganization struct { + CreatedAt string `json:"created_at" tfsdk:"created_at"` + DeletedAt string `json:"deleted_at" tfsdk:"deleted_at"` + Id string `json:"id" tfsdk:"id"` + Name string `json:"name" tfsdk:"name"` + UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` +} type User struct { - AvatarUrl *string `json:"avatar_url,omitempty" tfsdk:"avatar_url"` - CreatedAt *string `json:"created_at,omitempty" tfsdk:"created_at"` - DefaultOrganizationId *string `json:"default_organization_id,omitempty" tfsdk:"default_organization_id"` - DirectoryManaged *bool `json:"directory_managed,omitempty" tfsdk:"directory_managed"` - DisplayName *string `json:"display_name,omitempty" tfsdk:"display_name"` - Email *string `json:"email,omitempty" tfsdk:"email"` - EmailVerified *bool `json:"email_verified,omitempty" tfsdk:"email_verified"` - Id *string `json:"id,omitempty" tfsdk:"id"` - Managed *bool `json:"managed,omitempty" tfsdk:"managed"` - Name *string `json:"name,omitempty" tfsdk:"name"` - Sso *bool `json:"sso,omitempty" tfsdk:"sso"` - TwoFactorAuthConfigured *bool `json:"two_factor_auth_configured,omitempty" tfsdk:"two_factor_auth_configured"` - UpdatedAt *string `json:"updated_at,omitempty" tfsdk:"updated_at"` + AvatarUrl *string `json:"avatar_url,omitempty" tfsdk:"avatar_url"` + CreatedAt *string `json:"created_at,omitempty" tfsdk:"created_at"` + DefaultOrganization User_DefaultOrganization `json:"default_organization" tfsdk:"default_organization"` + DirectoryManaged *bool `json:"directory_managed,omitempty" tfsdk:"directory_managed"` + DisplayName *string `json:"display_name,omitempty" tfsdk:"display_name"` + Email *string `json:"email,omitempty" tfsdk:"email"` + EmailVerified *bool `json:"email_verified,omitempty" tfsdk:"email_verified"` + Id *string `json:"id,omitempty" tfsdk:"id"` + Managed *bool `json:"managed,omitempty" tfsdk:"managed"` + Name *string `json:"name,omitempty" tfsdk:"name"` + Sso *bool `json:"sso,omitempty" tfsdk:"sso"` + TwoFactorAuthConfigured *bool `json:"two_factor_auth_configured,omitempty" tfsdk:"two_factor_auth_configured"` + UpdatedAt *string `json:"updated_at,omitempty" tfsdk:"updated_at"` } type ListOrganizationsRes struct { Data []Organization `json:"data" tfsdk:"data"` @@ -609,9 +615,9 @@ func (cl *Client) GetOrganization(ctx context.Context, name string) (res200 *Get } type UpdateOrganizationReq struct { - BillingEmail *string `json:"billing_email,omitempty" tfsdk:"billing_email"` - IdpManagedRoles *bool `json:"idp_managed_roles,omitempty" tfsdk:"idp_managed_roles"` - RequireAdminForProductionAccess *bool `json:"require_admin_for_production_access,omitempty" tfsdk:"require_admin_for_production_access"` + BillingEmail *string `json:"billing_email,omitempty" tfsdk:"billing_email"` + IdpManagedRoles *bool `json:"idp_managed_roles,omitempty" tfsdk:"idp_managed_roles"` + InvoiceBudgetAmount *float64 `json:"invoice_budget_amount,omitempty" tfsdk:"invoice_budget_amount"` } type UpdateOrganizationRes struct { Organization @@ -689,6 +695,100 @@ func (cl *Client) UpdateOrganization(ctx context.Context, name string, req Updat return res200, err } +type ListAuditLogsRes_DataItem_Metadata struct{} +type ListAuditLogsRes_DataItem struct { + Action string `json:"action" tfsdk:"action"` + ActorDisplayName string `json:"actor_display_name" tfsdk:"actor_display_name"` + ActorId string `json:"actor_id" tfsdk:"actor_id"` + ActorType string `json:"actor_type" tfsdk:"actor_type"` + AuditableDisplayName string `json:"auditable_display_name" tfsdk:"auditable_display_name"` + AuditableId string `json:"auditable_id" tfsdk:"auditable_id"` + AuditableType string `json:"auditable_type" tfsdk:"auditable_type"` + CreatedAt string `json:"created_at" tfsdk:"created_at"` + Id string `json:"id" tfsdk:"id"` + Locale string `json:"locale" tfsdk:"locale"` + Metadata ListAuditLogsRes_DataItem_Metadata `json:"metadata" tfsdk:"metadata"` + RemoteIp string `json:"remote_ip" tfsdk:"remote_ip"` + TargetDisplayName string `json:"target_display_name" tfsdk:"target_display_name"` + TargetId string `json:"target_id" tfsdk:"target_id"` + TargetType string `json:"target_type" tfsdk:"target_type"` +} +type ListAuditLogsRes struct { + CursorEnd string `json:"cursor_end" tfsdk:"cursor_end"` + CursorStart string `json:"cursor_start" tfsdk:"cursor_start"` + Data []ListAuditLogsRes_DataItem `json:"data" tfsdk:"data"` + HasNext bool `json:"has_next" tfsdk:"has_next"` + HasPrev bool `json:"has_prev" tfsdk:"has_prev"` +} +type ListAuditLogsRes401 struct { + *ErrorResponse +} +type ListAuditLogsRes403 struct { + *ErrorResponse +} +type ListAuditLogsRes404 struct { + *ErrorResponse +} +type ListAuditLogsRes500 struct { + *ErrorResponse +} + +func (cl *Client) ListAuditLogs(ctx context.Context, name string) (res200 *ListAuditLogsRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + name + "/audit-log"}) + r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) + if err != nil { + return res200, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res200, err + } + defer res.Body.Close() + switch res.StatusCode { + case 200: + res200 = new(ListAuditLogsRes) + err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(ListAuditLogsRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(ListAuditLogsRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(ListAuditLogsRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(ListAuditLogsRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res200, err +} + type ListRegionsForOrganizationRes struct { Data []Region `json:"data" tfsdk:"data"` } @@ -850,9 +950,8 @@ func (cl *Client) ListDatabases(ctx context.Context, organization string, page * } type CreateDatabaseReq struct { - ClusterSize *string `json:"cluster_size,omitempty" tfsdk:"cluster_size"` + ClusterSize string `json:"cluster_size" tfsdk:"cluster_size"` Name string `json:"name" tfsdk:"name"` - Plan *string `json:"plan,omitempty" tfsdk:"plan"` Region *string `json:"region,omitempty" tfsdk:"region"` } type CreateDatabaseRes struct { @@ -1395,6 +1494,123 @@ func (cl *Client) DeleteBackup(ctx context.Context, organization string, databas return res204, err } +type UpdateBackupReq struct { + Protected *bool `json:"protected,omitempty" tfsdk:"protected"` +} +type UpdateBackupRes_Actor struct { + AvatarUrl string `json:"avatar_url" tfsdk:"avatar_url"` + DisplayName string `json:"display_name" tfsdk:"display_name"` + Id string `json:"id" tfsdk:"id"` +} +type UpdateBackupRes_BackupPolicy struct { + CreatedAt string `json:"created_at" tfsdk:"created_at"` + FrequencyUnit string `json:"frequency_unit" tfsdk:"frequency_unit"` + FrequencyValue float64 `json:"frequency_value" tfsdk:"frequency_value"` + Id string `json:"id" tfsdk:"id"` + LastRanAt string `json:"last_ran_at" tfsdk:"last_ran_at"` + Name string `json:"name" tfsdk:"name"` + NextRunAt string `json:"next_run_at" tfsdk:"next_run_at"` + RetentionUnit string `json:"retention_unit" tfsdk:"retention_unit"` + RetentionValue float64 `json:"retention_value" tfsdk:"retention_value"` + ScheduleDay string `json:"schedule_day" tfsdk:"schedule_day"` + ScheduleWeek string `json:"schedule_week" tfsdk:"schedule_week"` + Target string `json:"target" tfsdk:"target"` + UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` +} +type UpdateBackupRes_SchemaSnapshot struct { + CreatedAt string `json:"created_at" tfsdk:"created_at"` + Id string `json:"id" tfsdk:"id"` + Name string `json:"name" tfsdk:"name"` + UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` + Url string `json:"url" tfsdk:"url"` +} +type UpdateBackupRes struct { + Actor *UpdateBackupRes_Actor `json:"actor,omitempty" tfsdk:"actor"` + BackupPolicy *UpdateBackupRes_BackupPolicy `json:"backup_policy,omitempty" tfsdk:"backup_policy"` + CreatedAt string `json:"created_at" tfsdk:"created_at"` + EstimatedStorageCost float64 `json:"estimated_storage_cost" tfsdk:"estimated_storage_cost"` + Id string `json:"id" tfsdk:"id"` + Name string `json:"name" tfsdk:"name"` + Required bool `json:"required" tfsdk:"required"` + RestoredBranches *[]string `json:"restored_branches,omitempty" tfsdk:"restored_branches"` + SchemaSnapshot UpdateBackupRes_SchemaSnapshot `json:"schema_snapshot" tfsdk:"schema_snapshot"` + Size float64 `json:"size" tfsdk:"size"` + State string `json:"state" tfsdk:"state"` + UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` +} +type UpdateBackupRes401 struct { + *ErrorResponse +} +type UpdateBackupRes403 struct { + *ErrorResponse +} +type UpdateBackupRes404 struct { + *ErrorResponse +} +type UpdateBackupRes500 struct { + *ErrorResponse +} + +func (cl *Client) UpdateBackup(ctx context.Context, organization string, database string, branch string, id string, req UpdateBackupReq) (res200 *UpdateBackupRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + branch + "/backups/" + id}) + body := bytes.NewBuffer(nil) + if err = json.NewEncoder(body).Encode(req); err != nil { + return res200, err + } + r, err := http.NewRequestWithContext(ctx, "PATCH", u.String(), body) + if err != nil { + return res200, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res200, err + } + defer res.Body.Close() + switch res.StatusCode { + case 200: + res200 = new(UpdateBackupRes) + err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(UpdateBackupRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(UpdateBackupRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(UpdateBackupRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(UpdateBackupRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res200, err +} + type ListPasswordsRes struct { Data []Password `json:"data" tfsdk:"data"` } @@ -1479,9 +1695,10 @@ func (cl *Client) ListPasswords(ctx context.Context, organization string, databa } type CreatePasswordReq struct { - Name *string `json:"name,omitempty" tfsdk:"name"` - Role *string `json:"role,omitempty" tfsdk:"role"` - Ttl *float64 `json:"ttl,omitempty" tfsdk:"ttl"` + Name *string `json:"name,omitempty" tfsdk:"name"` + Replica *bool `json:"replica,omitempty" tfsdk:"replica"` + Role *string `json:"role,omitempty" tfsdk:"role"` + Ttl *float64 `json:"ttl,omitempty" tfsdk:"ttl"` } type CreatePasswordRes struct { PasswordWithPlaintext @@ -1584,13 +1801,8 @@ type GetPasswordRes500 struct { *ErrorResponse } -func (cl *Client) GetPassword(ctx context.Context, organization string, database string, branch string, id string, readOnlyRegionId *string) (res200 *GetPasswordRes, err error) { +func (cl *Client) GetPassword(ctx context.Context, organization string, database string, branch string, id string) (res200 *GetPasswordRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + branch + "/passwords/" + id}) - q := u.Query() - if readOnlyRegionId != nil { - q.Set("read_only_region_id", *readOnlyRegionId) - } - u.RawQuery = q.Encode() r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) if err != nil { return res200, err @@ -1794,9 +2006,6 @@ func (cl *Client) UpdatePassword(ctx context.Context, organization string, datab return res200, err } -type RenewPasswordReq struct { - ReadOnlyRegionId *string `json:"read_only_region_id,omitempty" tfsdk:"read_only_region_id"` -} type RenewPasswordRes struct { PasswordWithPlaintext } @@ -1813,13 +2022,9 @@ type RenewPasswordRes500 struct { *ErrorResponse } -func (cl *Client) RenewPassword(ctx context.Context, organization string, database string, branch string, id string, req RenewPasswordReq) (res200 *RenewPasswordRes, err error) { +func (cl *Client) RenewPassword(ctx context.Context, organization string, database string, branch string, id string) (res200 *RenewPasswordRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + branch + "/passwords/" + id + "/renew"}) - body := bytes.NewBuffer(nil) - if err = json.NewEncoder(body).Encode(req); err != nil { - return res200, err - } - r, err := http.NewRequestWithContext(ctx, "POST", u.String(), body) + r, err := http.NewRequestWithContext(ctx, "POST", u.String(), nil) if err != nil { return res200, err } @@ -2015,6 +2220,83 @@ func (cl *Client) DeleteBranch(ctx context.Context, organization string, databas return res204, err } +type UpdateBranchClusterConfigReq struct { + ClusterSize string `json:"cluster_size" tfsdk:"cluster_size"` +} +type UpdateBranchClusterConfigRes struct{} +type UpdateBranchClusterConfigRes401 struct { + *ErrorResponse +} +type UpdateBranchClusterConfigRes403 struct { + *ErrorResponse +} +type UpdateBranchClusterConfigRes404 struct { + *ErrorResponse +} +type UpdateBranchClusterConfigRes500 struct { + *ErrorResponse +} + +func (cl *Client) UpdateBranchClusterConfig(ctx context.Context, organization string, database string, name string, req UpdateBranchClusterConfigReq) (res204 *UpdateBranchClusterConfigRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + name + "/cluster"}) + body := bytes.NewBuffer(nil) + if err = json.NewEncoder(body).Encode(req); err != nil { + return res204, err + } + r, err := http.NewRequestWithContext(ctx, "PATCH", u.String(), body) + if err != nil { + return res204, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res204, err + } + defer res.Body.Close() + switch res.StatusCode { + case 204: + res204 = new(UpdateBranchClusterConfigRes) + err = json.NewDecoder(res.Body).Decode(&res204) + case 401: + res401 := new(UpdateBranchClusterConfigRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(UpdateBranchClusterConfigRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(UpdateBranchClusterConfigRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(UpdateBranchClusterConfigRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res204, err +} + type DemoteBranchRes struct { Branch } @@ -2159,23 +2441,23 @@ func (cl *Client) PromoteBranch(ctx context.Context, organization string, databa return res200, err } -type EnableSafeMigrationsForBranchRes struct { +type EnableSafeMigrationsRes struct { Branch } -type EnableSafeMigrationsForBranchRes401 struct { +type EnableSafeMigrationsRes401 struct { *ErrorResponse } -type EnableSafeMigrationsForBranchRes403 struct { +type EnableSafeMigrationsRes403 struct { *ErrorResponse } -type EnableSafeMigrationsForBranchRes404 struct { +type EnableSafeMigrationsRes404 struct { *ErrorResponse } -type EnableSafeMigrationsForBranchRes500 struct { +type EnableSafeMigrationsRes500 struct { *ErrorResponse } -func (cl *Client) EnableSafeMigrationsForBranch(ctx context.Context, organization string, database string, name string) (res200 *EnableSafeMigrationsForBranchRes, err error) { +func (cl *Client) EnableSafeMigrations(ctx context.Context, organization string, database string, name string) (res200 *EnableSafeMigrationsRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + name + "/safe-migrations"}) r, err := http.NewRequestWithContext(ctx, "POST", u.String(), nil) if err != nil { @@ -2190,28 +2472,28 @@ func (cl *Client) EnableSafeMigrationsForBranch(ctx context.Context, organizatio defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(EnableSafeMigrationsForBranchRes) + res200 = new(EnableSafeMigrationsRes) err = json.NewDecoder(res.Body).Decode(&res200) case 401: - res401 := new(EnableSafeMigrationsForBranchRes401) + res401 := new(EnableSafeMigrationsRes401) err = json.NewDecoder(res.Body).Decode(&res401) if err == nil { err = res401 } case 403: - res403 := new(EnableSafeMigrationsForBranchRes403) + res403 := new(EnableSafeMigrationsRes403) err = json.NewDecoder(res.Body).Decode(&res403) if err == nil { err = res403 } case 404: - res404 := new(EnableSafeMigrationsForBranchRes404) + res404 := new(EnableSafeMigrationsRes404) err = json.NewDecoder(res.Body).Decode(&res404) if err == nil { err = res404 } case 500: - res500 := new(EnableSafeMigrationsForBranchRes500) + res500 := new(EnableSafeMigrationsRes500) err = json.NewDecoder(res.Body).Decode(&res500) if err == nil { err = res500 @@ -2231,23 +2513,23 @@ func (cl *Client) EnableSafeMigrationsForBranch(ctx context.Context, organizatio return res200, err } -type DisableSafeMigrationsForBranchRes struct { +type DisableSafeMigrationsRes struct { Branch } -type DisableSafeMigrationsForBranchRes401 struct { +type DisableSafeMigrationsRes401 struct { *ErrorResponse } -type DisableSafeMigrationsForBranchRes403 struct { +type DisableSafeMigrationsRes403 struct { *ErrorResponse } -type DisableSafeMigrationsForBranchRes404 struct { +type DisableSafeMigrationsRes404 struct { *ErrorResponse } -type DisableSafeMigrationsForBranchRes500 struct { +type DisableSafeMigrationsRes500 struct { *ErrorResponse } -func (cl *Client) DisableSafeMigrationsForBranch(ctx context.Context, organization string, database string, name string) (res200 *DisableSafeMigrationsForBranchRes, err error) { +func (cl *Client) DisableSafeMigrations(ctx context.Context, organization string, database string, name string) (res200 *DisableSafeMigrationsRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/branches/" + name + "/safe-migrations"}) r, err := http.NewRequestWithContext(ctx, "DELETE", u.String(), nil) if err != nil { @@ -2262,28 +2544,28 @@ func (cl *Client) DisableSafeMigrationsForBranch(ctx context.Context, organizati defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(DisableSafeMigrationsForBranchRes) + res200 = new(DisableSafeMigrationsRes) err = json.NewDecoder(res.Body).Decode(&res200) case 401: - res401 := new(DisableSafeMigrationsForBranchRes401) + res401 := new(DisableSafeMigrationsRes401) err = json.NewDecoder(res.Body).Decode(&res401) if err == nil { err = res401 } case 403: - res403 := new(DisableSafeMigrationsForBranchRes403) + res403 := new(DisableSafeMigrationsRes403) err = json.NewDecoder(res.Body).Decode(&res403) if err == nil { err = res403 } case 404: - res404 := new(DisableSafeMigrationsForBranchRes404) + res404 := new(DisableSafeMigrationsRes404) err = json.NewDecoder(res.Body).Decode(&res404) if err == nil { err = res404 } case 500: - res500 := new(DisableSafeMigrationsForBranchRes500) + res500 := new(DisableSafeMigrationsRes500) err = json.NewDecoder(res.Body).Decode(&res500) if err == nil { err = res500 @@ -2460,11 +2742,23 @@ func (cl *Client) LintBranchSchema(ctx context.Context, organization string, dat return res200, err } -type GetTheDeployQueueRes struct { +type GetDeployQueueRes struct { Data []QueuedDeployRequest `json:"data" tfsdk:"data"` } +type GetDeployQueueRes401 struct { + *ErrorResponse +} +type GetDeployQueueRes403 struct { + *ErrorResponse +} +type GetDeployQueueRes404 struct { + *ErrorResponse +} +type GetDeployQueueRes500 struct { + *ErrorResponse +} -func (cl *Client) GetTheDeployQueue(ctx context.Context, organization string, database string) (res200 *GetTheDeployQueueRes, err error) { +func (cl *Client) GetDeployQueue(ctx context.Context, organization string, database string) (res200 *GetDeployQueueRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-queue"}) r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) if err != nil { @@ -2479,26 +2773,62 @@ func (cl *Client) GetTheDeployQueue(ctx context.Context, organization string, da defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(GetTheDeployQueueRes) + res200 = new(GetDeployQueueRes) err = json.NewDecoder(res.Body).Decode(&res200) - default: - var errBody *ErrorResponse - _ = json.NewDecoder(res.Body).Decode(&errBody) - if errBody != nil { - err = errBody - } else { - err = fmt.Errorf("unexpected status code %d", res.StatusCode) + case 401: + res401 := new(GetDeployQueueRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 } - } - if errors.Is(err, io.EOF) { - err = nil - } - return res200, err -} - + case 403: + res403 := new(GetDeployQueueRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(GetDeployQueueRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(GetDeployQueueRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res200, err +} + type ListDeployRequestsRes struct { Data []DeployRequest `json:"data" tfsdk:"data"` } +type ListDeployRequestsRes401 struct { + *ErrorResponse +} +type ListDeployRequestsRes403 struct { + *ErrorResponse +} +type ListDeployRequestsRes404 struct { + *ErrorResponse +} +type ListDeployRequestsRes500 struct { + *ErrorResponse +} func (cl *Client) ListDeployRequests(ctx context.Context, organization string, database string, page *int, perPage *int, state *string, branch *string, intoBranch *string) (res200 *ListDeployRequestsRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests"}) @@ -2534,6 +2864,30 @@ func (cl *Client) ListDeployRequests(ctx context.Context, organization string, d case 200: res200 = new(ListDeployRequestsRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(ListDeployRequestsRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(ListDeployRequestsRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(ListDeployRequestsRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(ListDeployRequestsRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2550,13 +2904,27 @@ func (cl *Client) ListDeployRequests(ctx context.Context, organization string, d } type CreateDeployRequestReq struct { - Branch *string `json:"branch,omitempty" tfsdk:"branch"` - IntoBranch *string `json:"into_branch,omitempty" tfsdk:"into_branch"` - Notes *string `json:"notes,omitempty" tfsdk:"notes"` + AutoCutover *bool `json:"auto_cutover,omitempty" tfsdk:"auto_cutover"` + AutoDeleteBranch *bool `json:"auto_delete_branch,omitempty" tfsdk:"auto_delete_branch"` + Branch string `json:"branch" tfsdk:"branch"` + IntoBranch string `json:"into_branch" tfsdk:"into_branch"` + Notes *string `json:"notes,omitempty" tfsdk:"notes"` } type CreateDeployRequestRes struct { DeployRequestWithDeployment } +type CreateDeployRequestRes401 struct { + *ErrorResponse +} +type CreateDeployRequestRes403 struct { + *ErrorResponse +} +type CreateDeployRequestRes404 struct { + *ErrorResponse +} +type CreateDeployRequestRes500 struct { + *ErrorResponse +} func (cl *Client) CreateDeployRequest(ctx context.Context, organization string, database string, req CreateDeployRequestReq) (res201 *CreateDeployRequestRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests"}) @@ -2579,6 +2947,30 @@ func (cl *Client) CreateDeployRequest(ctx context.Context, organization string, case 201: res201 = new(CreateDeployRequestRes) err = json.NewDecoder(res.Body).Decode(&res201) + case 401: + res401 := new(CreateDeployRequestRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(CreateDeployRequestRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(CreateDeployRequestRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(CreateDeployRequestRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2597,6 +2989,18 @@ func (cl *Client) CreateDeployRequest(ctx context.Context, organization string, type GetDeployRequestRes struct { DeployRequestWithDeployment } +type GetDeployRequestRes401 struct { + *ErrorResponse +} +type GetDeployRequestRes403 struct { + *ErrorResponse +} +type GetDeployRequestRes404 struct { + *ErrorResponse +} +type GetDeployRequestRes500 struct { + *ErrorResponse +} func (cl *Client) GetDeployRequest(ctx context.Context, organization string, database string, number string) (res200 *GetDeployRequestRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number}) @@ -2615,6 +3019,30 @@ func (cl *Client) GetDeployRequest(ctx context.Context, organization string, dat case 200: res200 = new(GetDeployRequestRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(GetDeployRequestRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(GetDeployRequestRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(GetDeployRequestRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(GetDeployRequestRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2636,6 +3064,18 @@ type CloseDeployRequestReq struct { type CloseDeployRequestRes struct { DeployRequestWithDeployment } +type CloseDeployRequestRes401 struct { + *ErrorResponse +} +type CloseDeployRequestRes403 struct { + *ErrorResponse +} +type CloseDeployRequestRes404 struct { + *ErrorResponse +} +type CloseDeployRequestRes500 struct { + *ErrorResponse +} func (cl *Client) CloseDeployRequest(ctx context.Context, organization string, database string, number string, req CloseDeployRequestReq) (res200 *CloseDeployRequestRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number}) @@ -2658,6 +3098,30 @@ func (cl *Client) CloseDeployRequest(ctx context.Context, organization string, d case 200: res200 = new(CloseDeployRequestRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(CloseDeployRequestRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(CloseDeployRequestRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(CloseDeployRequestRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(CloseDeployRequestRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2676,6 +3140,18 @@ func (cl *Client) CloseDeployRequest(ctx context.Context, organization string, d type CompleteGatedDeployRequestRes struct { DeployRequest } +type CompleteGatedDeployRequestRes401 struct { + *ErrorResponse +} +type CompleteGatedDeployRequestRes403 struct { + *ErrorResponse +} +type CompleteGatedDeployRequestRes404 struct { + *ErrorResponse +} +type CompleteGatedDeployRequestRes500 struct { + *ErrorResponse +} func (cl *Client) CompleteGatedDeployRequest(ctx context.Context, organization string, database string, number string) (res200 *CompleteGatedDeployRequestRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/apply-deploy"}) @@ -2694,6 +3170,30 @@ func (cl *Client) CompleteGatedDeployRequest(ctx context.Context, organization s case 200: res200 = new(CompleteGatedDeployRequestRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(CompleteGatedDeployRequestRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(CompleteGatedDeployRequestRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(CompleteGatedDeployRequestRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(CompleteGatedDeployRequestRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2709,14 +3209,26 @@ func (cl *Client) CompleteGatedDeployRequest(ctx context.Context, organization s return res200, err } -type UpdateAutoApplyForDeployRequestReq struct { +type UpdateAutoApplyReq struct { Enable *bool `json:"enable,omitempty" tfsdk:"enable"` } -type UpdateAutoApplyForDeployRequestRes struct { +type UpdateAutoApplyRes struct { DeployRequest } +type UpdateAutoApplyRes401 struct { + *ErrorResponse +} +type UpdateAutoApplyRes403 struct { + *ErrorResponse +} +type UpdateAutoApplyRes404 struct { + *ErrorResponse +} +type UpdateAutoApplyRes500 struct { + *ErrorResponse +} -func (cl *Client) UpdateAutoApplyForDeployRequest(ctx context.Context, organization string, database string, number string, req UpdateAutoApplyForDeployRequestReq) (res200 *UpdateAutoApplyForDeployRequestRes, err error) { +func (cl *Client) UpdateAutoApply(ctx context.Context, organization string, database string, number string, req UpdateAutoApplyReq) (res200 *UpdateAutoApplyRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/auto-apply"}) body := bytes.NewBuffer(nil) if err = json.NewEncoder(body).Encode(req); err != nil { @@ -2735,8 +3247,32 @@ func (cl *Client) UpdateAutoApplyForDeployRequest(ctx context.Context, organizat defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(UpdateAutoApplyForDeployRequestRes) + res200 = new(UpdateAutoApplyRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(UpdateAutoApplyRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(UpdateAutoApplyRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(UpdateAutoApplyRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(UpdateAutoApplyRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2752,11 +3288,23 @@ func (cl *Client) UpdateAutoApplyForDeployRequest(ctx context.Context, organizat return res200, err } -type CancelQueuedDeployRequestRes struct { +type CancelDeployRequestRes struct { DeployRequest } +type CancelDeployRequestRes401 struct { + *ErrorResponse +} +type CancelDeployRequestRes403 struct { + *ErrorResponse +} +type CancelDeployRequestRes404 struct { + *ErrorResponse +} +type CancelDeployRequestRes500 struct { + *ErrorResponse +} -func (cl *Client) CancelQueuedDeployRequest(ctx context.Context, organization string, database string, number string) (res200 *CancelQueuedDeployRequestRes, err error) { +func (cl *Client) CancelDeployRequest(ctx context.Context, organization string, database string, number string) (res200 *CancelDeployRequestRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/cancel"}) r, err := http.NewRequestWithContext(ctx, "POST", u.String(), nil) if err != nil { @@ -2771,8 +3319,32 @@ func (cl *Client) CancelQueuedDeployRequest(ctx context.Context, organization st defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(CancelQueuedDeployRequestRes) + res200 = new(CancelDeployRequestRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(CancelDeployRequestRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(CancelDeployRequestRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(CancelDeployRequestRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(CancelDeployRequestRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2791,6 +3363,18 @@ func (cl *Client) CancelQueuedDeployRequest(ctx context.Context, organization st type CompleteErroredDeployRes struct { DeployRequest } +type CompleteErroredDeployRes401 struct { + *ErrorResponse +} +type CompleteErroredDeployRes403 struct { + *ErrorResponse +} +type CompleteErroredDeployRes404 struct { + *ErrorResponse +} +type CompleteErroredDeployRes500 struct { + *ErrorResponse +} func (cl *Client) CompleteErroredDeploy(ctx context.Context, organization string, database string, number string) (res200 *CompleteErroredDeployRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/complete-deploy"}) @@ -2809,6 +3393,30 @@ func (cl *Client) CompleteErroredDeploy(ctx context.Context, organization string case 200: res200 = new(CompleteErroredDeployRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(CompleteErroredDeployRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(CompleteErroredDeployRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(CompleteErroredDeployRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(CompleteErroredDeployRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2827,8 +3435,20 @@ func (cl *Client) CompleteErroredDeploy(ctx context.Context, organization string type QueueDeployRequestRes struct { DeployRequest } - -func (cl *Client) QueueDeployRequest(ctx context.Context, organization string, database string, number string) (res200 *QueueDeployRequestRes, err error) { +type QueueDeployRequestRes401 struct { + *ErrorResponse +} +type QueueDeployRequestRes403 struct { + *ErrorResponse +} +type QueueDeployRequestRes404 struct { + *ErrorResponse +} +type QueueDeployRequestRes500 struct { + *ErrorResponse +} + +func (cl *Client) QueueDeployRequest(ctx context.Context, organization string, database string, number string) (res200 *QueueDeployRequestRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/deploy"}) r, err := http.NewRequestWithContext(ctx, "POST", u.String(), nil) if err != nil { @@ -2845,6 +3465,30 @@ func (cl *Client) QueueDeployRequest(ctx context.Context, organization string, d case 200: res200 = new(QueueDeployRequestRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(QueueDeployRequestRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(QueueDeployRequestRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(QueueDeployRequestRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(QueueDeployRequestRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2863,6 +3507,18 @@ func (cl *Client) QueueDeployRequest(ctx context.Context, organization string, d type GetDeploymentRes struct { Deployment } +type GetDeploymentRes401 struct { + *ErrorResponse +} +type GetDeploymentRes403 struct { + *ErrorResponse +} +type GetDeploymentRes404 struct { + *ErrorResponse +} +type GetDeploymentRes500 struct { + *ErrorResponse +} func (cl *Client) GetDeployment(ctx context.Context, organization string, database string, number string) (res200 *GetDeploymentRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/deployment"}) @@ -2881,6 +3537,30 @@ func (cl *Client) GetDeployment(ctx context.Context, organization string, databa case 200: res200 = new(GetDeploymentRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(GetDeploymentRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(GetDeploymentRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(GetDeploymentRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(GetDeploymentRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2899,6 +3579,18 @@ func (cl *Client) GetDeployment(ctx context.Context, organization string, databa type ListDeployOperationsRes struct { Data []DeployOperation `json:"data" tfsdk:"data"` } +type ListDeployOperationsRes401 struct { + *ErrorResponse +} +type ListDeployOperationsRes403 struct { + *ErrorResponse +} +type ListDeployOperationsRes404 struct { + *ErrorResponse +} +type ListDeployOperationsRes500 struct { + *ErrorResponse +} func (cl *Client) ListDeployOperations(ctx context.Context, organization string, database string, number string, page *int, perPage *int) (res200 *ListDeployOperationsRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/operations"}) @@ -2925,6 +3617,30 @@ func (cl *Client) ListDeployOperations(ctx context.Context, organization string, case 200: res200 = new(ListDeployOperationsRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(ListDeployOperationsRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(ListDeployOperationsRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(ListDeployOperationsRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(ListDeployOperationsRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2943,6 +3659,18 @@ func (cl *Client) ListDeployOperations(ctx context.Context, organization string, type CompleteRevertRes struct { DeployRequest } +type CompleteRevertRes401 struct { + *ErrorResponse +} +type CompleteRevertRes403 struct { + *ErrorResponse +} +type CompleteRevertRes404 struct { + *ErrorResponse +} +type CompleteRevertRes500 struct { + *ErrorResponse +} func (cl *Client) CompleteRevert(ctx context.Context, organization string, database string, number string) (res200 *CompleteRevertRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/revert"}) @@ -2961,6 +3689,30 @@ func (cl *Client) CompleteRevert(ctx context.Context, organization string, datab case 200: res200 = new(CompleteRevertRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(CompleteRevertRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(CompleteRevertRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(CompleteRevertRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(CompleteRevertRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -2979,6 +3731,18 @@ func (cl *Client) CompleteRevert(ctx context.Context, organization string, datab type ListDeployRequestReviewsRes struct { Data []DeployReview `json:"data" tfsdk:"data"` } +type ListDeployRequestReviewsRes401 struct { + *ErrorResponse +} +type ListDeployRequestReviewsRes403 struct { + *ErrorResponse +} +type ListDeployRequestReviewsRes404 struct { + *ErrorResponse +} +type ListDeployRequestReviewsRes500 struct { + *ErrorResponse +} func (cl *Client) ListDeployRequestReviews(ctx context.Context, organization string, database string, number string) (res200 *ListDeployRequestReviewsRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/reviews"}) @@ -2997,6 +3761,30 @@ func (cl *Client) ListDeployRequestReviews(ctx context.Context, organization str case 200: res200 = new(ListDeployRequestReviewsRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(ListDeployRequestReviewsRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(ListDeployRequestReviewsRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(ListDeployRequestReviewsRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(ListDeployRequestReviewsRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -3019,6 +3807,18 @@ type ReviewDeployRequestReq struct { type ReviewDeployRequestRes struct { DeployReview } +type ReviewDeployRequestRes401 struct { + *ErrorResponse +} +type ReviewDeployRequestRes403 struct { + *ErrorResponse +} +type ReviewDeployRequestRes404 struct { + *ErrorResponse +} +type ReviewDeployRequestRes500 struct { + *ErrorResponse +} func (cl *Client) ReviewDeployRequest(ctx context.Context, organization string, database string, number string, req ReviewDeployRequestReq) (res201 *ReviewDeployRequestRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/reviews"}) @@ -3041,6 +3841,30 @@ func (cl *Client) ReviewDeployRequest(ctx context.Context, organization string, case 201: res201 = new(ReviewDeployRequestRes) err = json.NewDecoder(res.Body).Decode(&res201) + case 401: + res401 := new(ReviewDeployRequestRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(ReviewDeployRequestRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(ReviewDeployRequestRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(ReviewDeployRequestRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -3059,6 +3883,18 @@ func (cl *Client) ReviewDeployRequest(ctx context.Context, organization string, type SkipRevertPeriodRes struct { DeployRequest } +type SkipRevertPeriodRes401 struct { + *ErrorResponse +} +type SkipRevertPeriodRes403 struct { + *ErrorResponse +} +type SkipRevertPeriodRes404 struct { + *ErrorResponse +} +type SkipRevertPeriodRes500 struct { + *ErrorResponse +} func (cl *Client) SkipRevertPeriod(ctx context.Context, organization string, database string, number string) (res200 *SkipRevertPeriodRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + database + "/deploy-requests/" + number + "/skip-revert"}) @@ -3077,6 +3913,259 @@ func (cl *Client) SkipRevertPeriod(ctx context.Context, organization string, dat case 200: res200 = new(SkipRevertPeriodRes) err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(SkipRevertPeriodRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(SkipRevertPeriodRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(SkipRevertPeriodRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(SkipRevertPeriodRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res200, err +} + +type GetDatabaseRes struct { + Database +} +type GetDatabaseRes401 struct { + *ErrorResponse +} +type GetDatabaseRes403 struct { + *ErrorResponse +} +type GetDatabaseRes404 struct { + *ErrorResponse +} +type GetDatabaseRes500 struct { + *ErrorResponse +} + +func (cl *Client) GetDatabase(ctx context.Context, organization string, name string) (res200 *GetDatabaseRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name}) + r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) + if err != nil { + return res200, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res200, err + } + defer res.Body.Close() + switch res.StatusCode { + case 200: + res200 = new(GetDatabaseRes) + err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(GetDatabaseRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(GetDatabaseRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(GetDatabaseRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(GetDatabaseRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res200, err +} + +type DeleteDatabaseRes struct{} +type DeleteDatabaseRes401 struct { + *ErrorResponse +} +type DeleteDatabaseRes403 struct { + *ErrorResponse +} +type DeleteDatabaseRes404 struct { + *ErrorResponse +} +type DeleteDatabaseRes500 struct { + *ErrorResponse +} + +func (cl *Client) DeleteDatabase(ctx context.Context, organization string, name string) (res204 *DeleteDatabaseRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name}) + r, err := http.NewRequestWithContext(ctx, "DELETE", u.String(), nil) + if err != nil { + return res204, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res204, err + } + defer res.Body.Close() + switch res.StatusCode { + case 204: + res204 = new(DeleteDatabaseRes) + err = json.NewDecoder(res.Body).Decode(&res204) + case 401: + res401 := new(DeleteDatabaseRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(DeleteDatabaseRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(DeleteDatabaseRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(DeleteDatabaseRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res204, err +} + +type UpdateDatabaseSettingsReq struct { + AllowDataBranching *bool `json:"allow_data_branching,omitempty" tfsdk:"allow_data_branching"` + AutomaticMigrations *bool `json:"automatic_migrations,omitempty" tfsdk:"automatic_migrations"` + DefaultBranch *string `json:"default_branch,omitempty" tfsdk:"default_branch"` + InsightsRawQueries *bool `json:"insights_raw_queries,omitempty" tfsdk:"insights_raw_queries"` + MigrationFramework *string `json:"migration_framework,omitempty" tfsdk:"migration_framework"` + MigrationTableName *string `json:"migration_table_name,omitempty" tfsdk:"migration_table_name"` + ProductionBranchWebConsole *bool `json:"production_branch_web_console,omitempty" tfsdk:"production_branch_web_console"` + RequireApprovalForDeploy *bool `json:"require_approval_for_deploy,omitempty" tfsdk:"require_approval_for_deploy"` + RestrictBranchRegion *bool `json:"restrict_branch_region,omitempty" tfsdk:"restrict_branch_region"` +} +type UpdateDatabaseSettingsRes struct { + Database +} +type UpdateDatabaseSettingsRes401 struct { + *ErrorResponse +} +type UpdateDatabaseSettingsRes403 struct { + *ErrorResponse +} +type UpdateDatabaseSettingsRes404 struct { + *ErrorResponse +} +type UpdateDatabaseSettingsRes500 struct { + *ErrorResponse +} + +func (cl *Client) UpdateDatabaseSettings(ctx context.Context, organization string, name string, req UpdateDatabaseSettingsReq) (res200 *UpdateDatabaseSettingsRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name}) + body := bytes.NewBuffer(nil) + if err = json.NewEncoder(body).Encode(req); err != nil { + return res200, err + } + r, err := http.NewRequestWithContext(ctx, "PATCH", u.String(), body) + if err != nil { + return res200, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res200, err + } + defer res.Body.Close() + switch res.StatusCode { + case 200: + res200 = new(UpdateDatabaseSettingsRes) + err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(UpdateDatabaseSettingsRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(UpdateDatabaseSettingsRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(UpdateDatabaseSettingsRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(UpdateDatabaseSettingsRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } default: var errBody *ErrorResponse _ = json.NewDecoder(res.Body).Decode(&errBody) @@ -3092,24 +4181,32 @@ func (cl *Client) SkipRevertPeriod(ctx context.Context, organization string, dat return res200, err } -type GetDatabaseRes struct { - Database +type ListReadOnlyRegionsRes struct { + Data []ReadOnlyRegion `json:"data" tfsdk:"data"` } -type GetDatabaseRes401 struct { +type ListReadOnlyRegionsRes401 struct { *ErrorResponse } -type GetDatabaseRes403 struct { +type ListReadOnlyRegionsRes403 struct { *ErrorResponse } -type GetDatabaseRes404 struct { +type ListReadOnlyRegionsRes404 struct { *ErrorResponse } -type GetDatabaseRes500 struct { +type ListReadOnlyRegionsRes500 struct { *ErrorResponse } -func (cl *Client) GetDatabase(ctx context.Context, organization string, name string) (res200 *GetDatabaseRes, err error) { - u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name}) +func (cl *Client) ListReadOnlyRegions(ctx context.Context, organization string, name string, page *int, perPage *int) (res200 *ListReadOnlyRegionsRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name + "/read-only-regions"}) + q := u.Query() + if page != nil { + q.Set("page", strconv.Itoa(*page)) + } + if perPage != nil { + q.Set("per_page", strconv.Itoa(*perPage)) + } + u.RawQuery = q.Encode() r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) if err != nil { return res200, err @@ -3123,28 +4220,28 @@ func (cl *Client) GetDatabase(ctx context.Context, organization string, name str defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(GetDatabaseRes) + res200 = new(ListReadOnlyRegionsRes) err = json.NewDecoder(res.Body).Decode(&res200) case 401: - res401 := new(GetDatabaseRes401) + res401 := new(ListReadOnlyRegionsRes401) err = json.NewDecoder(res.Body).Decode(&res401) if err == nil { err = res401 } case 403: - res403 := new(GetDatabaseRes403) + res403 := new(ListReadOnlyRegionsRes403) err = json.NewDecoder(res.Body).Decode(&res403) if err == nil { err = res403 } case 404: - res404 := new(GetDatabaseRes404) + res404 := new(ListReadOnlyRegionsRes404) err = json.NewDecoder(res.Body).Decode(&res404) if err == nil { err = res404 } case 500: - res500 := new(GetDatabaseRes500) + res500 := new(ListReadOnlyRegionsRes500) err = json.NewDecoder(res.Body).Decode(&res500) if err == nil { err = res500 @@ -3164,57 +4261,67 @@ func (cl *Client) GetDatabase(ctx context.Context, organization string, name str return res200, err } -type DeleteDatabaseRes struct{} -type DeleteDatabaseRes401 struct { +type ListDatabaseRegionsRes struct { + Data []Region `json:"data" tfsdk:"data"` +} +type ListDatabaseRegionsRes401 struct { *ErrorResponse } -type DeleteDatabaseRes403 struct { +type ListDatabaseRegionsRes403 struct { *ErrorResponse } -type DeleteDatabaseRes404 struct { +type ListDatabaseRegionsRes404 struct { *ErrorResponse } -type DeleteDatabaseRes500 struct { +type ListDatabaseRegionsRes500 struct { *ErrorResponse } -func (cl *Client) DeleteDatabase(ctx context.Context, organization string, name string) (res204 *DeleteDatabaseRes, err error) { - u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name}) - r, err := http.NewRequestWithContext(ctx, "DELETE", u.String(), nil) +func (cl *Client) ListDatabaseRegions(ctx context.Context, organization string, name string, page *int, perPage *int) (res200 *ListDatabaseRegionsRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name + "/regions"}) + q := u.Query() + if page != nil { + q.Set("page", strconv.Itoa(*page)) + } + if perPage != nil { + q.Set("per_page", strconv.Itoa(*perPage)) + } + u.RawQuery = q.Encode() + r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) if err != nil { - return res204, err + return res200, err } r.Header.Set("Content-Type", "application/json") r.Header.Set("Accept", "application/json") res, err := cl.httpCl.Do(r) if err != nil { - return res204, err + return res200, err } defer res.Body.Close() switch res.StatusCode { - case 204: - res204 = new(DeleteDatabaseRes) - err = json.NewDecoder(res.Body).Decode(&res204) + case 200: + res200 = new(ListDatabaseRegionsRes) + err = json.NewDecoder(res.Body).Decode(&res200) case 401: - res401 := new(DeleteDatabaseRes401) + res401 := new(ListDatabaseRegionsRes401) err = json.NewDecoder(res.Body).Decode(&res401) if err == nil { err = res401 } case 403: - res403 := new(DeleteDatabaseRes403) + res403 := new(ListDatabaseRegionsRes403) err = json.NewDecoder(res.Body).Decode(&res403) if err == nil { err = res403 } case 404: - res404 := new(DeleteDatabaseRes404) + res404 := new(ListDatabaseRegionsRes404) err = json.NewDecoder(res.Body).Decode(&res404) if err == nil { err = res404 } case 500: - res500 := new(DeleteDatabaseRes500) + res500 := new(ListDatabaseRegionsRes500) err = json.NewDecoder(res.Body).Decode(&res500) if err == nil { err = res500 @@ -3231,43 +4338,42 @@ func (cl *Client) DeleteDatabase(ctx context.Context, organization string, name if errors.Is(err, io.EOF) { err = nil } - return res204, err + return res200, err } -type UpdateDatabaseSettingsReq struct { - AllowDataBranching *bool `json:"allow_data_branching,omitempty" tfsdk:"allow_data_branching"` - AutomaticMigrations *bool `json:"automatic_migrations,omitempty" tfsdk:"automatic_migrations"` - DefaultBranch *string `json:"default_branch,omitempty" tfsdk:"default_branch"` - InsightsRawQueries *bool `json:"insights_raw_queries,omitempty" tfsdk:"insights_raw_queries"` - MigrationFramework *string `json:"migration_framework,omitempty" tfsdk:"migration_framework"` - MigrationTableName *string `json:"migration_table_name,omitempty" tfsdk:"migration_table_name"` - ProductionBranchWebConsole *bool `json:"production_branch_web_console,omitempty" tfsdk:"production_branch_web_console"` - RequireApprovalForDeploy *bool `json:"require_approval_for_deploy,omitempty" tfsdk:"require_approval_for_deploy"` - RestrictBranchRegion *bool `json:"restrict_branch_region,omitempty" tfsdk:"restrict_branch_region"` +type ListInvoicesRes_DataItem struct { + BillingPeriodEnd string `json:"billing_period_end" tfsdk:"billing_period_end"` + BillingPeriodStart string `json:"billing_period_start" tfsdk:"billing_period_start"` + Id string `json:"id" tfsdk:"id"` + Total float64 `json:"total" tfsdk:"total"` } -type UpdateDatabaseSettingsRes struct { - Database +type ListInvoicesRes struct { + Data []ListInvoicesRes_DataItem `json:"data" tfsdk:"data"` } -type UpdateDatabaseSettingsRes401 struct { +type ListInvoicesRes401 struct { *ErrorResponse } -type UpdateDatabaseSettingsRes403 struct { +type ListInvoicesRes403 struct { *ErrorResponse } -type UpdateDatabaseSettingsRes404 struct { +type ListInvoicesRes404 struct { *ErrorResponse } -type UpdateDatabaseSettingsRes500 struct { +type ListInvoicesRes500 struct { *ErrorResponse } -func (cl *Client) UpdateDatabaseSettings(ctx context.Context, organization string, name string, req UpdateDatabaseSettingsReq) (res200 *UpdateDatabaseSettingsRes, err error) { - u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name}) - body := bytes.NewBuffer(nil) - if err = json.NewEncoder(body).Encode(req); err != nil { - return res200, err +func (cl *Client) ListInvoices(ctx context.Context, organization string, page *int, perPage *int) (res200 *ListInvoicesRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/invoices"}) + q := u.Query() + if page != nil { + q.Set("page", strconv.Itoa(*page)) } - r, err := http.NewRequestWithContext(ctx, "PATCH", u.String(), body) + if perPage != nil { + q.Set("per_page", strconv.Itoa(*perPage)) + } + u.RawQuery = q.Encode() + r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) if err != nil { return res200, err } @@ -3280,28 +4386,28 @@ func (cl *Client) UpdateDatabaseSettings(ctx context.Context, organization strin defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(UpdateDatabaseSettingsRes) + res200 = new(ListInvoicesRes) err = json.NewDecoder(res.Body).Decode(&res200) case 401: - res401 := new(UpdateDatabaseSettingsRes401) + res401 := new(ListInvoicesRes401) err = json.NewDecoder(res.Body).Decode(&res401) if err == nil { err = res401 } case 403: - res403 := new(UpdateDatabaseSettingsRes403) + res403 := new(ListInvoicesRes403) err = json.NewDecoder(res.Body).Decode(&res403) if err == nil { err = res403 } case 404: - res404 := new(UpdateDatabaseSettingsRes404) + res404 := new(ListInvoicesRes404) err = json.NewDecoder(res.Body).Decode(&res404) if err == nil { err = res404 } case 500: - res500 := new(UpdateDatabaseSettingsRes500) + res500 := new(ListInvoicesRes500) err = json.NewDecoder(res.Body).Decode(&res500) if err == nil { err = res500 @@ -3321,32 +4427,27 @@ func (cl *Client) UpdateDatabaseSettings(ctx context.Context, organization strin return res200, err } -type ListReadOnlyRegionsRes struct { - Data []ReadOnlyRegion `json:"data" tfsdk:"data"` +type GetInvoiceRes struct { + BillingPeriodEnd string `json:"billing_period_end" tfsdk:"billing_period_end"` + BillingPeriodStart string `json:"billing_period_start" tfsdk:"billing_period_start"` + Id string `json:"id" tfsdk:"id"` + Total float64 `json:"total" tfsdk:"total"` } -type ListReadOnlyRegionsRes401 struct { +type GetInvoiceRes401 struct { *ErrorResponse } -type ListReadOnlyRegionsRes403 struct { +type GetInvoiceRes403 struct { *ErrorResponse } -type ListReadOnlyRegionsRes404 struct { +type GetInvoiceRes404 struct { *ErrorResponse } -type ListReadOnlyRegionsRes500 struct { +type GetInvoiceRes500 struct { *ErrorResponse } -func (cl *Client) ListReadOnlyRegions(ctx context.Context, organization string, name string, page *int, perPage *int) (res200 *ListReadOnlyRegionsRes, err error) { - u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name + "/read-only-regions"}) - q := u.Query() - if page != nil { - q.Set("page", strconv.Itoa(*page)) - } - if perPage != nil { - q.Set("per_page", strconv.Itoa(*perPage)) - } - u.RawQuery = q.Encode() +func (cl *Client) GetInvoice(ctx context.Context, organization string, id string) (res200 *GetInvoiceRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/invoices/" + id}) r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) if err != nil { return res200, err @@ -3360,28 +4461,28 @@ func (cl *Client) ListReadOnlyRegions(ctx context.Context, organization string, defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(ListReadOnlyRegionsRes) + res200 = new(GetInvoiceRes) err = json.NewDecoder(res.Body).Decode(&res200) case 401: - res401 := new(ListReadOnlyRegionsRes401) + res401 := new(GetInvoiceRes401) err = json.NewDecoder(res.Body).Decode(&res401) if err == nil { err = res401 } case 403: - res403 := new(ListReadOnlyRegionsRes403) + res403 := new(GetInvoiceRes403) err = json.NewDecoder(res.Body).Decode(&res403) if err == nil { err = res403 } case 404: - res404 := new(ListReadOnlyRegionsRes404) + res404 := new(GetInvoiceRes404) err = json.NewDecoder(res.Body).Decode(&res404) if err == nil { err = res404 } case 500: - res500 := new(ListReadOnlyRegionsRes500) + res500 := new(GetInvoiceRes500) err = json.NewDecoder(res.Body).Decode(&res500) if err == nil { err = res500 @@ -3401,32 +4502,40 @@ func (cl *Client) ListReadOnlyRegions(ctx context.Context, organization string, return res200, err } -type ListDatabaseRegionsRes struct { - Data []Region `json:"data" tfsdk:"data"` +type GetInvoiceLineItemsRes_DataItem_Resource struct { + CreatedAt string `json:"created_at" tfsdk:"created_at"` + DeletedAt string `json:"deleted_at" tfsdk:"deleted_at"` + Id string `json:"id" tfsdk:"id"` + Name string `json:"name" tfsdk:"name"` + UpdatedAt string `json:"updated_at" tfsdk:"updated_at"` } -type ListDatabaseRegionsRes401 struct { +type GetInvoiceLineItemsRes_DataItem struct { + DatabaseId string `json:"database_id" tfsdk:"database_id"` + DatabaseName string `json:"database_name" tfsdk:"database_name"` + Description string `json:"description" tfsdk:"description"` + Id string `json:"id" tfsdk:"id"` + MetricName string `json:"metric_name" tfsdk:"metric_name"` + Resource GetInvoiceLineItemsRes_DataItem_Resource `json:"resource" tfsdk:"resource"` + Subtotal float64 `json:"subtotal" tfsdk:"subtotal"` +} +type GetInvoiceLineItemsRes struct { + Data []GetInvoiceLineItemsRes_DataItem `json:"data" tfsdk:"data"` +} +type GetInvoiceLineItemsRes401 struct { *ErrorResponse } -type ListDatabaseRegionsRes403 struct { +type GetInvoiceLineItemsRes403 struct { *ErrorResponse } -type ListDatabaseRegionsRes404 struct { +type GetInvoiceLineItemsRes404 struct { *ErrorResponse } -type ListDatabaseRegionsRes500 struct { +type GetInvoiceLineItemsRes500 struct { *ErrorResponse } -func (cl *Client) ListDatabaseRegions(ctx context.Context, organization string, name string, page *int, perPage *int) (res200 *ListDatabaseRegionsRes, err error) { - u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/databases/" + name + "/regions"}) - q := u.Query() - if page != nil { - q.Set("page", strconv.Itoa(*page)) - } - if perPage != nil { - q.Set("per_page", strconv.Itoa(*perPage)) - } - u.RawQuery = q.Encode() +func (cl *Client) GetInvoiceLineItems(ctx context.Context, organization string, id string) (res200 *GetInvoiceLineItemsRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/invoices/" + id + "/line-items"}) r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) if err != nil { return res200, err @@ -3440,28 +4549,28 @@ func (cl *Client) ListDatabaseRegions(ctx context.Context, organization string, defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(ListDatabaseRegionsRes) + res200 = new(GetInvoiceLineItemsRes) err = json.NewDecoder(res.Body).Decode(&res200) case 401: - res401 := new(ListDatabaseRegionsRes401) + res401 := new(GetInvoiceLineItemsRes401) err = json.NewDecoder(res.Body).Decode(&res401) if err == nil { err = res401 } case 403: - res403 := new(ListDatabaseRegionsRes403) + res403 := new(GetInvoiceLineItemsRes403) err = json.NewDecoder(res.Body).Decode(&res403) if err == nil { err = res403 } case 404: - res404 := new(ListDatabaseRegionsRes404) + res404 := new(GetInvoiceLineItemsRes404) err = json.NewDecoder(res.Body).Decode(&res404) if err == nil { err = res404 } case 500: - res500 := new(ListDatabaseRegionsRes500) + res500 := new(GetInvoiceLineItemsRes500) err = json.NewDecoder(res.Body).Decode(&res500) if err == nil { err = res500 @@ -3855,7 +4964,7 @@ func (cl *Client) DeleteOauthToken(ctx context.Context, organization string, app return res204, err } -type CreateOrRenewOauthTokenReq struct { +type CreateOauthTokenReq struct { ClientId string `json:"client_id" tfsdk:"client_id"` ClientSecret string `json:"client_secret" tfsdk:"client_secret"` Code *string `json:"code,omitempty" tfsdk:"code"` @@ -3863,23 +4972,23 @@ type CreateOrRenewOauthTokenReq struct { RedirectUri *string `json:"redirect_uri,omitempty" tfsdk:"redirect_uri"` RefreshToken *string `json:"refresh_token,omitempty" tfsdk:"refresh_token"` } -type CreateOrRenewOauthTokenRes struct { +type CreateOauthTokenRes struct { CreatedOauthToken } -type CreateOrRenewOauthTokenRes403 struct { +type CreateOauthTokenRes403 struct { *ErrorResponse } -type CreateOrRenewOauthTokenRes404 struct { +type CreateOauthTokenRes404 struct { *ErrorResponse } -type CreateOrRenewOauthTokenRes422 struct { +type CreateOauthTokenRes422 struct { *ErrorResponse } -type CreateOrRenewOauthTokenRes500 struct { +type CreateOauthTokenRes500 struct { *ErrorResponse } -func (cl *Client) CreateOrRenewOauthToken(ctx context.Context, organization string, id string, req CreateOrRenewOauthTokenReq) (res200 *CreateOrRenewOauthTokenRes, err error) { +func (cl *Client) CreateOauthToken(ctx context.Context, organization string, id string, req CreateOauthTokenReq) (res200 *CreateOauthTokenRes, err error) { u := cl.baseURL.ResolveReference(&url.URL{Path: "organizations/" + organization + "/oauth-applications/" + id + "/token"}) body := bytes.NewBuffer(nil) if err = json.NewEncoder(body).Encode(req); err != nil { @@ -3898,28 +5007,116 @@ func (cl *Client) CreateOrRenewOauthToken(ctx context.Context, organization stri defer res.Body.Close() switch res.StatusCode { case 200: - res200 = new(CreateOrRenewOauthTokenRes) + res200 = new(CreateOauthTokenRes) err = json.NewDecoder(res.Body).Decode(&res200) case 403: - res403 := new(CreateOrRenewOauthTokenRes403) + res403 := new(CreateOauthTokenRes403) err = json.NewDecoder(res.Body).Decode(&res403) if err == nil { err = res403 } case 404: - res404 := new(CreateOrRenewOauthTokenRes404) + res404 := new(CreateOauthTokenRes404) err = json.NewDecoder(res.Body).Decode(&res404) if err == nil { err = res404 } case 422: - res422 := new(CreateOrRenewOauthTokenRes422) + res422 := new(CreateOauthTokenRes422) err = json.NewDecoder(res.Body).Decode(&res422) if err == nil { err = res422 } case 500: - res500 := new(CreateOrRenewOauthTokenRes500) + res500 := new(CreateOauthTokenRes500) + err = json.NewDecoder(res.Body).Decode(&res500) + if err == nil { + err = res500 + } + default: + var errBody *ErrorResponse + _ = json.NewDecoder(res.Body).Decode(&errBody) + if errBody != nil { + err = errBody + } else { + err = fmt.Errorf("unexpected status code %d", res.StatusCode) + } + } + if errors.Is(err, io.EOF) { + err = nil + } + return res200, err +} + +type GetRegionsRes_DataItem struct { + DisplayName string `json:"display_name" tfsdk:"display_name"` + Id string `json:"id" tfsdk:"id"` + Location string `json:"location" tfsdk:"location"` + Provider string `json:"provider" tfsdk:"provider"` + PublicIpAddresses []string `json:"public_ip_addresses" tfsdk:"public_ip_addresses"` + Slug string `json:"slug" tfsdk:"slug"` +} +type GetRegionsRes struct { + Data []GetRegionsRes_DataItem `json:"data" tfsdk:"data"` +} +type GetRegionsRes401 struct { + *ErrorResponse +} +type GetRegionsRes403 struct { + *ErrorResponse +} +type GetRegionsRes404 struct { + *ErrorResponse +} +type GetRegionsRes500 struct { + *ErrorResponse +} + +func (cl *Client) GetRegions(ctx context.Context, page *int, perPage *int) (res200 *GetRegionsRes, err error) { + u := cl.baseURL.ResolveReference(&url.URL{Path: "regions"}) + q := u.Query() + if page != nil { + q.Set("page", strconv.Itoa(*page)) + } + if perPage != nil { + q.Set("per_page", strconv.Itoa(*perPage)) + } + u.RawQuery = q.Encode() + r, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) + if err != nil { + return res200, err + } + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") + res, err := cl.httpCl.Do(r) + if err != nil { + return res200, err + } + defer res.Body.Close() + switch res.StatusCode { + case 200: + res200 = new(GetRegionsRes) + err = json.NewDecoder(res.Body).Decode(&res200) + case 401: + res401 := new(GetRegionsRes401) + err = json.NewDecoder(res.Body).Decode(&res401) + if err == nil { + err = res401 + } + case 403: + res403 := new(GetRegionsRes403) + err = json.NewDecoder(res.Body).Decode(&res403) + if err == nil { + err = res403 + } + case 404: + res404 := new(GetRegionsRes404) + err = json.NewDecoder(res.Body).Decode(&res404) + if err == nil { + err = res404 + } + case 500: + res500 := new(GetRegionsRes500) err = json.NewDecoder(res.Body).Decode(&res500) if err == nil { err = res500 diff --git a/internal/cmd/client_codegen/jenny.go b/internal/cmd/client_codegen/jenny.go index 6e4e344..667ce79 100644 --- a/internal/cmd/client_codegen/jenny.go +++ b/internal/cmd/client_codegen/jenny.go @@ -236,14 +236,15 @@ func genClientCall( reqBodyTypeName string, responseTypeNames map[int]string, ) error { - args := []jen.Code{jen.Id("ctx").Qual("context", "Context")} path = strings.TrimPrefix(path, "/") + // log.Printf("JOE: %s %s", verb, path) pathBuilderArg, pathArgs := pathInterpolator(path, pathArgs) for _, pathArg := range pathArgs { argName := lowerSnakeToCamel(pathArg.Name) + // log.Printf("JOE: %s %s", pathArg.Name, argName) argF := jen.Id(argName) switch pathArg.Type { @@ -370,12 +371,10 @@ func genClientCall( g.Defer().Id("res").Dot("Body").Dot("Close").Call() g.Switch(jen.Id("res").Dot("StatusCode")).BlockFunc(func(g *jen.Group) { - for _, code := range codes { returnValName := "res" + strconv.Itoa(code) returnValTypeName := responseTypeNames[code] if code < 400 { - g.Case(jen.Lit(code)).Block( jen.Id(returnValName).Op("=").New(jen.Id(returnValTypeName)), jen.Id("err").Op("=").Qual("encoding/json", "NewDecoder").Call(jen.Id("res").Dot("Body")).Dot("Decode").Call(jen.Op("&").Id(returnValName)), diff --git a/internal/cmd/client_codegen/main.go b/internal/cmd/client_codegen/main.go index c7325ae..c99ffbd 100644 --- a/internal/cmd/client_codegen/main.go +++ b/internal/cmd/client_codegen/main.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "log" "os" "sort" "strconv" @@ -118,7 +119,8 @@ func handleVerbPath(ll *slog.Logger, defns spec.Definitions, f *jen.File, path, var reqBodyStructName string if reqBody != nil { - reqBodyStructName = kebabToCamel(removeFillerWords(operation.ID)) + "Req" + // reqBodyStructName = kebabToCamel(removeFillerWords(operation.ID)) + "Req" + reqBodyStructName = snakeToCamel(removeFillerWords(operation.ID)) + "Req" if err := genParamStruct(defns, f, reqBodyStructName, reqBody.Schema); err != nil { return fmt.Errorf("generating call param struct: %w", err) } @@ -134,11 +136,15 @@ func handleVerbPath(ll *slog.Logger, defns spec.Definitions, f *jen.File, path, } } for _, code := range resCodes { - resBodyStructName := kebabToCamel(removeFillerWords(operation.ID)) + "Res" + strconv.Itoa(code) + // resBodyStructName := kebabToCamel(removeFillerWords(operation.ID)) + "Res" + strconv.Itoa(code) + resBodyStructName := snakeToCamel(removeFillerWords(operation.ID)) + "Res" + strconv.Itoa(code) + log.Printf("JOE: resBodyStructName: %s\n", resBodyStructName) res := operation.Responses.StatusCodeResponses[code] if code < 400 { if successResponseTypes == 1 { - resBodyStructName = kebabToCamel(removeFillerWords(operation.ID)) + "Res" + // resBodyStructName = kebabToCamel(removeFillerWords(operation.ID)) + "Res" + resBodyStructName = snakeToCamel(removeFillerWords(operation.ID)) + "Res" + log.Printf("JOE: resBodyStructName-2: %s\n", resBodyStructName) } respSchema := res.ResponseProps.Schema @@ -164,7 +170,9 @@ func handleVerbPath(ll *slog.Logger, defns spec.Definitions, f *jen.File, path, responses[code] = resBodyStructName } - clientCallFuncName := kebabToCamel(removeFillerWords(operation.ID)) + // clientCallFuncName := kebabToCamel(removeFillerWords(operation.ID)) + log.Printf("JOE: clientcall: %s", snakeToCamel(removeFillerWords(operation.ID))) + clientCallFuncName := snakeToCamel(removeFillerWords(operation.ID)) if err := genClientCall(f, path, verb, clientCallFuncName, pathParams, queryParams, reqBodyStructName, responses); err != nil { return fmt.Errorf("generating client call method: %w", err) } @@ -173,8 +181,11 @@ func handleVerbPath(ll *slog.Logger, defns spec.Definitions, f *jen.File, path, } func removeFillerWords(name string) string { + name = strings.ReplaceAll(name, "post", "create") + name = strings.ReplaceAll(name, "patch", "update") name = strings.ReplaceAll(name, "-an-", "-") name = strings.ReplaceAll(name, "-a-", "-") + log.Printf("JOE: removeFillerWords(%q) = %q", orig, name) return name } @@ -183,6 +194,7 @@ func kebabToCamel(kebab string) string { for _, w := range strings.Split(kebab, "-") { out.WriteString(cases.Title(language.AmericanEnglish).String(w)) } + log.Printf("JOE: kebabToCamel(%q) = %q", kebab, out.String()) return out.String() } @@ -191,10 +203,12 @@ func snakeToCamel(snake string) string { for _, w := range strings.Split(snake, "_") { out.WriteString(cases.Title(language.AmericanEnglish).String(w)) } + log.Printf("JOE: snakeToCamel(%q) = %q", snake, out.String()) return out.String() } func lowerSnakeToCamel(snake string) string { + // log.Printf("JOE: lowerSnakeToCamel(%q)", snake) var out strings.Builder for i, w := range strings.Split(snake, "_") { if i == 0 { @@ -203,6 +217,7 @@ func lowerSnakeToCamel(snake string) string { out.WriteString(cases.Title(language.AmericanEnglish).String(w)) } } + log.Printf("JOE: lowerSnakeToCamel(%q) = %q", snake, out.String()) return out.String() } diff --git a/internal/provider/backup_resource.go b/internal/provider/backup_resource.go index d8523ea..5f7f2cd 100644 --- a/internal/provider/backup_resource.go +++ b/internal/provider/backup_resource.go @@ -43,7 +43,7 @@ type backupResourceModel struct { Actor types.Object `tfsdk:"actor"` BackupPolicy types.Object `tfsdk:"backup_policy"` CreatedAt types.String `tfsdk:"created_at"` - EstimatedStorageCost types.String `tfsdk:"estimated_storage_cost"` + EstimatedStorageCost types.Float64 `tfsdk:"estimated_storage_cost"` Id types.String `tfsdk:"id"` Required types.Bool `tfsdk:"required"` RestoredBranches types.List `tfsdk:"restored_branches"` @@ -76,7 +76,7 @@ func backupResourceFromClient(ctx context.Context, backup *planetscale.Backup, o Name: types.StringValue(backup.Name), Actor: actor, CreatedAt: types.StringValue(backup.CreatedAt), - EstimatedStorageCost: types.StringValue(backup.EstimatedStorageCost), + EstimatedStorageCost: types.Float64Value(backup.EstimatedStorageCost), Id: types.StringValue(backup.Id), Required: types.BoolValue(backup.Required), RestoredBranches: restoredBranch, diff --git a/internal/provider/branch_resource.go b/internal/provider/branch_resource.go index 7a76c5b..09312f8 100644 --- a/internal/provider/branch_resource.go +++ b/internal/provider/branch_resource.go @@ -41,15 +41,15 @@ type branchResourceModel struct { Organization types.String `tfsdk:"organization"` Database types.String `tfsdk:"database"` - Name types.String `tfsdk:"name"` - ParentBranch types.String `tfsdk:"parent_branch"` - AccessHostUrl types.String `tfsdk:"access_host_url"` - Actor types.Object `tfsdk:"actor"` - ClusterRateName types.String `tfsdk:"cluster_rate_name"` - CreatedAt types.String `tfsdk:"created_at"` - HtmlUrl types.String `tfsdk:"html_url"` - Id types.String `tfsdk:"id"` - InitialRestoreId types.String `tfsdk:"initial_restore_id"` + Name types.String `tfsdk:"name"` + ParentBranch types.String `tfsdk:"parent_branch"` + // AccessHostUrl types.String `tfsdk:"access_host_url"` + Actor types.Object `tfsdk:"actor"` + ClusterRateName types.String `tfsdk:"cluster_rate_name"` + CreatedAt types.String `tfsdk:"created_at"` + HtmlUrl types.String `tfsdk:"html_url"` + Id types.String `tfsdk:"id"` + // InitialRestoreId types.String `tfsdk:"initial_restore_id"` MysqlAddress types.String `tfsdk:"mysql_address"` MysqlEdgeAddress types.String `tfsdk:"mysql_edge_address"` Region types.Object `tfsdk:"region"` @@ -77,17 +77,17 @@ func branchResourceFromClient(ctx context.Context, branch *planetscale.Branch, o Organization: organization, Database: database, - Actor: actor, - Region: region, - RestoredFromBranch: restoredFromBranch, - Name: types.StringValue(branch.Name), - ParentBranch: types.StringPointerValue(branch.ParentBranch), - AccessHostUrl: types.StringPointerValue(branch.AccessHostUrl), - ClusterRateName: types.StringValue(branch.ClusterRateName), - CreatedAt: types.StringValue(branch.CreatedAt), - HtmlUrl: types.StringValue(branch.HtmlUrl), - Id: types.StringValue(branch.Id), - InitialRestoreId: types.StringPointerValue(branch.InitialRestoreId), + Actor: actor, + Region: region, + RestoredFromBranch: restoredFromBranch, + Name: types.StringValue(branch.Name), + ParentBranch: types.StringPointerValue(branch.ParentBranch), + // AccessHostUrl: types.StringPointerValue(branch.AccessHostUrl), + ClusterRateName: types.StringValue(branch.ClusterRateName), + CreatedAt: types.StringValue(branch.CreatedAt), + HtmlUrl: types.StringValue(branch.HtmlUrl), + Id: types.StringValue(branch.Id), + // InitialRestoreId: types.StringPointerValue(branch.InitialRestoreId), MysqlAddress: types.StringValue(branch.MysqlAddress), MysqlEdgeAddress: types.StringValue(branch.MysqlEdgeAddress), Production: types.BoolValue(branch.Production), diff --git a/internal/provider/database_resource.go b/internal/provider/database_resource.go index 0e1cd3d..17cbf1b 100644 --- a/internal/provider/database_resource.go +++ b/internal/provider/database_resource.go @@ -84,12 +84,13 @@ func databaseResourcefromClient(ctx context.Context, database *planetscale.Datab dataImport, diags := types.ObjectValueFrom(ctx, importResourceAttrTypes, database.DataImport) diags.Append(diags...) return &databaseResourceModel{ - Organization: organization, - DataImport: dataImport, - Id: types.StringValue(database.Id), - AllowDataBranching: types.BoolValue(database.AllowDataBranching), - AtBackupRestoreBranchesLimit: types.BoolValue(database.AtBackupRestoreBranchesLimit), - AtDevelopmentBranchLimit: types.BoolValue(database.AtDevelopmentBranchLimit), + Organization: organization, + DataImport: dataImport, + Id: types.StringValue(database.Id), + AllowDataBranching: types.BoolValue(database.AllowDataBranching), + AtBackupRestoreBranchesLimit: types.BoolValue(database.AtBackupRestoreBranchesLimit), + // AtDevelopmentBranchLimit: types.BoolValue(database.AtDevelopmentBranchLimit), + AtDevelopmentBranchLimit: types.BoolValue(false), // at_development_branch_limit removed from API, hardcode to false going forward AutomaticMigrations: types.BoolPointerValue(database.AutomaticMigrations), BranchesCount: types.Float64Value(database.BranchesCount), BranchesUrl: types.StringValue(database.BranchesUrl), @@ -363,10 +364,11 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques } createDbReq := planetscale.CreateDatabaseReq{ - Name: name.ValueString(), - Plan: stringValueIfKnown(data.Plan), - ClusterSize: stringValueIfKnown(data.ClusterSize), - Region: stringValueIfKnown(data.Region), + Name: name.ValueString(), + // Plan: stringValueIfKnown(data.Plan), + ClusterSize: data.ClusterSize.ValueString(), + // ClusterSize: float64ValueIfKnown(data.ClusterSize), + Region: stringValueIfKnown(data.Region), } res, err := r.client.CreateDatabase(ctx, org.ValueString(), createDbReq) if err != nil { diff --git a/internal/provider/models_data_source.go b/internal/provider/models_data_source.go index e56a8d9..3f65189 100644 --- a/internal/provider/models_data_source.go +++ b/internal/provider/models_data_source.go @@ -123,26 +123,26 @@ func organizationFromClient(org *planetscale.Organization) *organizationDataSour return nil } return &organizationDataSourceModel{ - Features: featuresFromClient(org.Features), - Flags: flagsFromClient(org.Flags), - AdminOnlyProductionAccess: types.BoolValue(org.AdminOnlyProductionAccess), - BillingEmail: types.StringPointerValue(org.BillingEmail), - CanCreateDatabases: types.BoolValue(org.CanCreateDatabases), - CreatedAt: types.StringValue(org.CreatedAt), - DatabaseCount: types.Float64Value(org.DatabaseCount), - FreeDatabasesRemaining: types.Float64Value(org.FreeDatabasesRemaining), - HasPastDueInvoices: types.BoolValue(org.HasPastDueInvoices), - Id: types.StringValue(org.Id), - Name: types.StringValue(org.Name), - Plan: types.StringValue(org.Plan), - SingleTenancy: types.BoolValue(org.SingleTenancy), - SleepingDatabaseCount: types.Float64Value(org.SleepingDatabaseCount), - Sso: types.BoolValue(org.Sso), - SsoDirectory: types.BoolValue(org.SsoDirectory), - SsoPortalUrl: types.StringPointerValue(org.SsoPortalUrl), - UpdatedAt: types.StringValue(org.UpdatedAt), - ValidBillingInfo: types.BoolValue(org.ValidBillingInfo), - IdpManagedRoles: types.BoolValue(org.IdpManagedRoles), + Features: featuresFromClient(org.Features), + Flags: flagsFromClient(org.Flags), + // AdminOnlyProductionAccess: types.BoolValue(org.AdminOnlyProductionAccess), + BillingEmail: types.StringPointerValue(org.BillingEmail), + // CanCreateDatabases: types.BoolValue(org.CanCreateDatabases), + CreatedAt: types.StringValue(org.CreatedAt), + DatabaseCount: types.Float64Value(org.DatabaseCount), + // FreeDatabasesRemaining: types.Float64Value(org.FreeDatabasesRemaining), + HasPastDueInvoices: types.BoolValue(org.HasPastDueInvoices), + Id: types.StringValue(org.Id), + Name: types.StringValue(org.Name), + Plan: types.StringValue(org.Plan), + SingleTenancy: types.BoolValue(org.SingleTenancy), + SleepingDatabaseCount: types.Float64Value(org.SleepingDatabaseCount), + Sso: types.BoolValue(org.Sso), + SsoDirectory: types.BoolValue(org.SsoDirectory), + SsoPortalUrl: types.StringPointerValue(org.SsoPortalUrl), + UpdatedAt: types.StringValue(org.UpdatedAt), + ValidBillingInfo: types.BoolValue(org.ValidBillingInfo), + IdpManagedRoles: types.BoolValue(org.IdpManagedRoles), } } @@ -403,7 +403,7 @@ type databaseDataSourceModel struct { Organization string `tfsdk:"organization"` AllowDataBranching types.Bool `tfsdk:"allow_data_branching"` AtBackupRestoreBranchesLimit types.Bool `tfsdk:"at_backup_restore_branches_limit"` - AtDevelopmentBranchLimit types.Bool `tfsdk:"at_development_branch_limit"` + AtDevelopmentBranchLimit types.Bool `tfsdk:"at_development_branch_limit"` // XXX: deprecated. no longer exists in api AutomaticMigrations types.Bool `tfsdk:"automatic_migrations"` BranchesCount types.Float64 `tfsdk:"branches_count"` BranchesUrl types.String `tfsdk:"branches_url"` @@ -441,12 +441,12 @@ func databaseFromClient(database *planetscale.Database, orgName string, diags di return nil } return &databaseDataSourceModel{ - Organization: orgName, - DataImport: dataImportFromClient(database.DataImport), - Region: regionFromClient(&database.Region, diags), - AllowDataBranching: types.BoolValue(database.AllowDataBranching), - AtBackupRestoreBranchesLimit: types.BoolValue(database.AtBackupRestoreBranchesLimit), - AtDevelopmentBranchLimit: types.BoolValue(database.AtDevelopmentBranchLimit), + Organization: orgName, + DataImport: dataImportFromClient(database.DataImport), + Region: regionFromClient(&database.Region, diags), + AllowDataBranching: types.BoolValue(database.AllowDataBranching), + AtBackupRestoreBranchesLimit: types.BoolValue(database.AtBackupRestoreBranchesLimit), + // AtDevelopmentBranchLimit: types.BoolValue(database.AtDevelopmentBranchLimit), AutomaticMigrations: types.BoolPointerValue(database.AutomaticMigrations), BranchesCount: types.Float64Value(database.BranchesCount), BranchesUrl: types.StringValue(database.BranchesUrl), @@ -577,16 +577,16 @@ func branchDataSourceSchemaAttribute(computedName bool) map[string]schema.Attrib } type branchDataSourceModel struct { - Organization types.String `tfsdk:"organization"` - Database types.String `tfsdk:"database"` - Name types.String `tfsdk:"name"` - AccessHostUrl types.String `tfsdk:"access_host_url"` - Actor *actorDataSourceModel `tfsdk:"actor"` - ClusterRateName types.String `tfsdk:"cluster_rate_name"` - CreatedAt types.String `tfsdk:"created_at"` - HtmlUrl types.String `tfsdk:"html_url"` - Id types.String `tfsdk:"id"` - InitialRestoreId types.String `tfsdk:"initial_restore_id"` + Organization types.String `tfsdk:"organization"` + Database types.String `tfsdk:"database"` + Name types.String `tfsdk:"name"` + AccessHostUrl types.String `tfsdk:"access_host_url"` + Actor *actorDataSourceModel `tfsdk:"actor"` + ClusterRateName types.String `tfsdk:"cluster_rate_name"` + CreatedAt types.String `tfsdk:"created_at"` + HtmlUrl types.String `tfsdk:"html_url"` + Id types.String `tfsdk:"id"` + // InitialRestoreId types.String `tfsdk:"initial_restore_id"` MysqlAddress types.String `tfsdk:"mysql_address"` MysqlEdgeAddress types.String `tfsdk:"mysql_edge_address"` ParentBranch types.String `tfsdk:"parent_branch"` @@ -606,18 +606,18 @@ func branchFromClient(branch *planetscale.Branch, organization, database string, return nil } return &branchDataSourceModel{ - Organization: types.StringValue(organization), - Database: types.StringValue(database), - Actor: actorFromClient(branch.Actor), - Region: regionFromClient(branch.Region, diags), - RestoredFromBranch: restoredFromBranchFromClient(branch.RestoredFromBranch), - Name: types.StringValue(branch.Name), - AccessHostUrl: types.StringPointerValue(branch.AccessHostUrl), - ClusterRateName: types.StringValue(branch.ClusterRateName), - CreatedAt: types.StringValue(branch.CreatedAt), - HtmlUrl: types.StringValue(branch.HtmlUrl), - Id: types.StringValue(branch.Id), - InitialRestoreId: types.StringPointerValue(branch.InitialRestoreId), + Organization: types.StringValue(organization), + Database: types.StringValue(database), + Actor: actorFromClient(branch.Actor), + Region: regionFromClient(branch.Region, diags), + RestoredFromBranch: restoredFromBranchFromClient(branch.RestoredFromBranch), + Name: types.StringValue(branch.Name), + // AccessHostUrl: types.StringPointerValue(branch.AccessHostUrl), + ClusterRateName: types.StringValue(branch.ClusterRateName), + CreatedAt: types.StringValue(branch.CreatedAt), + HtmlUrl: types.StringValue(branch.HtmlUrl), + Id: types.StringValue(branch.Id), + // InitialRestoreId: types.StringPointerValue(branch.InitialRestoreId), MysqlAddress: types.StringValue(branch.MysqlAddress), MysqlEdgeAddress: types.StringValue(branch.MysqlEdgeAddress), ParentBranch: types.StringPointerValue(branch.ParentBranch), @@ -1376,15 +1376,15 @@ func backupDataSourceSchemaAttribute(computedID bool) map[string]schema.Attribut } type backupDataSourceModel struct { - Organization types.String `tfsdk:"organization"` - Database types.String `tfsdk:"database"` - Branch types.String `tfsdk:"branch"` - Name types.String `tfsdk:"name"` - Id types.String `tfsdk:"id"` - Actor *actorDataSourceModel `tfsdk:"actor"` + Organization types.String `tfsdk:"organization"` + Database types.String `tfsdk:"database"` + Branch types.String `tfsdk:"branch"` + Name types.String `tfsdk:"name"` + Id types.String `tfsdk:"id"` + // Actor *actorDataSourceModel `tfsdk:"actor"` BackupPolicy *backupPolicyDataSourceModel `tfsdk:"backup_policy"` CreatedAt types.String `tfsdk:"created_at"` - EstimatedStorageCost types.String `tfsdk:"estimated_storage_cost"` + EstimatedStorageCost types.Float64 `tfsdk:"estimated_storage_cost"` Required types.Bool `tfsdk:"required"` RestoredBranches types.List `tfsdk:"restored_branches"` Size types.Float64 `tfsdk:"size"` @@ -1401,14 +1401,14 @@ func backupFromClient(backup *planetscale.Backup, organization, database, branch restoredBranches = stringsToListValue(*backup.RestoredBranches, diags) } return &backupDataSourceModel{ - Organization: types.StringValue(organization), - Database: types.StringValue(database), - Branch: types.StringValue(branch), - Name: types.StringValue(backup.Name), - Actor: actorFromClient(&backup.Actor), - BackupPolicy: backupPolicyFromClient(&backup.BackupPolicy), + Organization: types.StringValue(organization), + Database: types.StringValue(database), + Branch: types.StringValue(branch), + Name: types.StringValue(backup.Name), + // Actor: actorFromClient(&backup.Actor), + BackupPolicy: backupPolicyFromClient(backup.BackupPolicy), CreatedAt: types.StringValue(backup.CreatedAt), - EstimatedStorageCost: types.StringValue(backup.EstimatedStorageCost), + EstimatedStorageCost: types.Float64Value(backup.EstimatedStorageCost), Id: types.StringValue(backup.Id), Required: types.BoolValue(backup.Required), RestoredBranches: restoredBranches, diff --git a/internal/provider/password_data_source.go b/internal/provider/password_data_source.go index 1120cc8..09ec2d6 100644 --- a/internal/provider/password_data_source.go +++ b/internal/provider/password_data_source.go @@ -61,7 +61,7 @@ func (d *passwordDataSource) Read(ctx context.Context, req datasource.ReadReques data.Database.ValueString(), data.Branch.ValueString(), data.Id.ValueString(), - data.ReadOnlyRegionId.ValueStringPointer(), + // data.ReadOnlyRegionId.ValueStringPointer(), ) if err != nil { resp.Diagnostics.AddError("Unable to read database password", err.Error()) diff --git a/internal/provider/password_resource.go b/internal/provider/password_resource.go index d310e22..3847e1d 100644 --- a/internal/provider/password_resource.go +++ b/internal/provider/password_resource.go @@ -356,7 +356,7 @@ func (r *passwordResource) Read(ctx context.Context, req resource.ReadRequest, r database.ValueString(), branch.ValueString(), id.ValueString(), - nil, // not sure why this would need a region id + // nil, // not sure why this would need a region id ) if err != nil { if notFoundErr, ok := err.(*planetscale.GetPasswordRes404); ok { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 7d03460..466c585 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -266,6 +266,13 @@ func stringValueIfKnown(v basetypes.StringValue) *string { return v.ValueStringPointer() } +func float64ValueIfKnown(v basetypes.Float64Value) *float64 { + if v.IsUnknown() || v.IsNull() { + return nil + } + return v.ValueFloat64Pointer() +} + func stringValueOrDefault(v basetypes.StringValue, def string) string { if v.IsUnknown() || v.IsNull() { return def diff --git a/internal/provider/user_data_source.go b/internal/provider/user_data_source.go index 49b5c84..7c02ee8 100644 --- a/internal/provider/user_data_source.go +++ b/internal/provider/user_data_source.go @@ -137,9 +137,9 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r return } state := userDataSourceModel{ - AvatarUrl: res200.AvatarUrl, - CreatedAt: res200.CreatedAt, - DefaultOrganizationId: res200.DefaultOrganizationId, + AvatarUrl: res200.AvatarUrl, + CreatedAt: res200.CreatedAt, + // DefaultOrganizationId: res200.DefaultOrganizationId, DirectoryManaged: res200.DirectoryManaged, DisplayName: res200.DisplayName, Email: res200.Email, diff --git a/openapi-spec.json b/openapi-spec.json index 4107a58..931cb82 100644 --- a/openapi-spec.json +++ b/openapi-spec.json @@ -10,10 +10,10 @@ ], "swagger": "2.0", "info": { - "description": "\n

PlanetScale API

\n© 2023 PlanetScale, Inc.", + "description": "\n

PlanetScale API

\n© 2024 PlanetScale, Inc.", "title": "PlanetScale API", "version": "v1", - "x-copyright": "© 2023 PlanetScale, Inc." + "x-copyright": "© 2024 PlanetScale, Inc." }, "host": "api.planetscale.com", "basePath": "/v1", @@ -28,7 +28,7 @@ "Organizations" ], "summary": "List organizations", - "operationId": "list-organizations", + "operationId": "list_organizations", "parameters": [ { "type": "number", @@ -89,7 +89,7 @@ "Organizations" ], "summary": "Get an organization", - "operationId": "get-an-organization", + "operationId": "get_organization", "parameters": [ { "type": "string", @@ -129,7 +129,7 @@ "Organizations" ], "summary": "Update an organization", - "operationId": "update-an-organization", + "operationId": "update_organization", "parameters": [ { "type": "string", @@ -152,9 +152,9 @@ "description": "Whether or not the IdP provider is be responsible for managing roles in PlanetScale", "type": "boolean" }, - "require_admin_for_production_access": { - "description": "Whether or not only admins can access production", - "type": "boolean" + "invoice_budget_amount": { + "description": "The expected monthly budget for the organization", + "type": "number" } }, "additionalProperties": false @@ -183,6 +183,161 @@ } } }, + "/organizations/{name}/audit-log": { + "get": { + "description": "\n### Authorization\nA service token must have at least one of the following access in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_audit_logs`\n\n", + "consumes": [ + "application/json" + ], + "tags": [ + "Organizations" + ], + "summary": "List audit logs", + "operationId": "list_audit_logs", + "parameters": [ + { + "type": "string", + "description": "The name of the organization", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Gets the audit logs for the organization", + "schema": { + "type": "object", + "required": [ + "has_next", + "has_prev", + "cursor_start", + "cursor_end", + "data" + ], + "properties": { + "cursor_end": { + "description": "The ID of the last audit log in the current results", + "type": "string" + }, + "cursor_start": { + "description": "The ID of the first audit log in the current results", + "type": "string" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "actor_id", + "actor_type", + "auditable_id", + "auditable_type", + "target_id", + "target_type", + "locale", + "target_display_name", + "actor_display_name", + "auditable_display_name", + "action", + "remote_ip", + "created_at", + "metadata" + ], + "properties": { + "action": { + "description": "The action that was taken", + "type": "string" + }, + "actor_display_name": { + "description": "The name of the actor", + "type": "string" + }, + "actor_id": { + "description": "The ID of the actor", + "type": "string" + }, + "actor_type": { + "description": "The type of the actor. Such as 'User' or 'ServiceToken'", + "type": "string" + }, + "auditable_display_name": { + "description": "The name of the auditable object", + "type": "string" + }, + "auditable_id": { + "description": "The ID of the auditable object", + "type": "string" + }, + "auditable_type": { + "description": "The type of the auditable. Such as 'Organization' or 'Database'", + "type": "string" + }, + "created_at": { + "description": "When the audit log was created", + "type": "string" + }, + "id": { + "description": "The ID for the audit log", + "type": "string" + }, + "locale": { + "description": "The location of the actor based on their IP address", + "type": "string" + }, + "metadata": { + "description": "Additional metadata containing details about the change", + "type": "object", + "additionalProperties": true + }, + "remote_ip": { + "description": "The IP address of the actor", + "type": "string" + }, + "target_display_name": { + "description": "The name of the target", + "type": "string" + }, + "target_id": { + "description": "The ID of the target", + "type": "string" + }, + "target_type": { + "description": "The type of the target. Such as 'DatabaseBranch' or 'DatabaseBranchPassword'", + "type": "string" + } + }, + "additionalProperties": false + } + }, + "has_next": { + "description": "Whether there is a next page of results", + "type": "boolean" + }, + "has_prev": { + "description": "Whether there is a previous page of results", + "type": "boolean" + } + }, + "additionalProperties": false + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, "/organizations/{name}/regions": { "get": { "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_organization`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| User | `read_organizations` |\n| Organization | `read_organization` |", @@ -193,7 +348,7 @@ "Organizations" ], "summary": "List regions for an organization", - "operationId": "list-regions-for-an-organization", + "operationId": "list_regions_for_organization", "parameters": [ { "type": "string", @@ -253,7 +408,7 @@ }, "/organizations/{organization}/databases": { "get": { - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |", + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |", "consumes": [ "application/json" ], @@ -261,7 +416,7 @@ "Databases" ], "summary": "List databases", - "operationId": "list-databases", + "operationId": "list_databases", "parameters": [ { "type": "string", @@ -327,7 +482,7 @@ "Databases" ], "summary": "Create a database", - "operationId": "create-a-database", + "operationId": "create_database", "parameters": [ { "type": "string", @@ -342,21 +497,18 @@ "schema": { "type": "object", "required": [ - "name" + "name", + "cluster_size" ], "properties": { "cluster_size": { - "description": "The database cluster size. This is required for Scaler Pro databases. Options: PS_10, PS_20, PS_40, PS_80, PS_160, PS_320, PS_400, PS_640, PS_700, PS_900, PS_1280, PS_1400, PS_1800, PS_2100, PS_2560, PS_2700, PS_2800.", + "description": "The database cluster size. Options: PS_10, PS_20, PS_40, PS_80, PS_160, PS_320, PS_400, PS_640, PS_700, PS_900, PS_1280, PS_1400, PS_1800, PS_2100, PS_2560, PS_2700, PS_2800.", "type": "string" }, "name": { "description": "Name of the database", "type": "string" }, - "plan": { - "description": "The database billing plan. Options: 'hobby', 'scaler', or 'scaler_pro'.", - "type": "string" - }, "region": { "description": "The region the database will be deployed in. If left blank, defaults to the organization's default region.", "type": "string" @@ -398,19 +550,19 @@ "Database branches" ], "summary": "List branches", - "operationId": "list-branches", + "operationId": "list_branches", "parameters": [ { "type": "string", - "description": "The name of the database the branch belongs to", - "name": "database", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the database the branch belongs to", + "name": "database", "in": "path", "required": true }, @@ -471,19 +623,19 @@ "Database branches" ], "summary": "Create a branch", - "operationId": "create-a-branch", + "operationId": "create_branch", "parameters": [ { "type": "string", - "description": "The name of the database the branch belongs to", - "name": "database", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the database the branch belongs to", + "name": "database", "in": "path", "required": true }, @@ -546,12 +698,12 @@ "Backups" ], "summary": "List backups", - "operationId": "list-backups", + "operationId": "list_backups", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "branch", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -564,8 +716,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "branch", "in": "path", "required": true }, @@ -626,12 +778,12 @@ "Backups" ], "summary": "Create a backup", - "operationId": "create-a-backup", + "operationId": "create_backup", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "branch", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -644,8 +796,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "branch", "in": "path", "required": true }, @@ -711,33 +863,33 @@ "Backups" ], "summary": "Get a backup", - "operationId": "get-a-backup", + "operationId": "get_backup", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "branch", + "description": "The ID for the backup", + "name": "id", "in": "path", "required": true }, { "type": "string", - "description": "The name of the database the branch belongs to", - "name": "database", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the database the branch belongs to", + "name": "database", "in": "path", "required": true }, { "type": "string", - "description": "The ID for the backup", - "name": "id", + "description": "The name of the branch", + "name": "branch", "in": "path", "required": true } @@ -772,12 +924,19 @@ "Backups" ], "summary": "Delete a backup", - "operationId": "delete-a-backup", + "operationId": "delete_backup", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "branch", + "description": "The ID of the backup", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -790,22 +949,291 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "branch", "in": "path", "required": true + } + ], + "responses": { + "204": { + "description": "Delete a backup" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + }, + "patch": { + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `write_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `write_backups` |\n| Database | `write_backups` |\n| Branch | `write_backups` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Backups" + ], + "summary": "Update a backup", + "operationId": "update_backup", + "parameters": [ { "type": "string", "description": "The ID of the backup", "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "The name of the organization the branch belongs to", + "name": "organization", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the database the branch belongs to", + "name": "database", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the branch", + "name": "branch", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "protected": { + "description": "Whether the backup is protected from deletion or not", + "type": "boolean" + } + }, + "additionalProperties": false + } } ], "responses": { - "204": { - "description": "Delete a backup" + "200": { + "description": "Returns the backup", + "schema": { + "type": "object", + "required": [ + "id", + "name", + "state", + "size", + "estimated_storage_cost", + "created_at", + "updated_at", + "required", + "schema_snapshot" + ], + "properties": { + "actor": { + "type": "object", + "required": [ + "id", + "display_name", + "avatar_url" + ], + "properties": { + "avatar_url": { + "description": "The URL of the actor's avatar", + "type": "string" + }, + "display_name": { + "description": "The name of the actor", + "type": "string" + }, + "id": { + "description": "The ID of the actor", + "type": "string" + } + }, + "additionalProperties": false + }, + "backup_policy": { + "type": "object", + "required": [ + "id", + "name", + "target", + "retention_value", + "retention_unit", + "frequency_value", + "frequency_unit", + "schedule_day", + "schedule_week", + "created_at", + "updated_at", + "last_ran_at", + "next_run_at" + ], + "properties": { + "created_at": { + "description": "When the backup policy was created", + "type": "string" + }, + "frequency_unit": { + "description": "The unit for the frequency of the backup policy", + "type": "string" + }, + "frequency_value": { + "description": "A number value for the frequency of the backup policy", + "type": "number" + }, + "id": { + "description": "The ID of the backup policy", + "type": "string" + }, + "last_ran_at": { + "description": "When the backup was last run", + "type": "string" + }, + "name": { + "description": "The name of the backup policy", + "type": "string" + }, + "next_run_at": { + "description": "When the backup will next run", + "type": "string" + }, + "retention_unit": { + "description": "The unit for the retention period of the backup policy", + "type": "string" + }, + "retention_value": { + "description": "A number value for the retention period of the backup policy", + "type": "number" + }, + "schedule_day": { + "description": "Day of the week that the backup is scheduled", + "type": "string", + "enum": [ + "0..6" + ] + }, + "schedule_week": { + "description": "Week of the month that the backup is scheduled", + "type": "string", + "enum": [ + "0..3" + ] + }, + "target": { + "description": "Whether the backup policy is for a production or development database, or for a database branch", + "type": "string", + "enum": [ + "production", + "development", + "branch" + ] + }, + "updated_at": { + "description": "When the backup policy was last updated", + "type": "string" + } + }, + "additionalProperties": false + }, + "created_at": { + "description": "When the backup was created", + "type": "string" + }, + "estimated_storage_cost": { + "description": "The estimated storage cost of the backup", + "type": "number" + }, + "id": { + "description": "The ID of the backup", + "type": "string" + }, + "name": { + "description": "The name of the backup", + "type": "string" + }, + "required": { + "description": "Whether or not the backup policy is required", + "type": "boolean" + }, + "restored_branches": { + "description": "Branches that have been restored with this backup", + "type": "array", + "items": { + "type": "string" + } + }, + "schema_snapshot": { + "type": "object", + "required": [ + "id", + "url", + "name", + "created_at", + "updated_at" + ], + "properties": { + "created_at": { + "description": "When the schema snapshot was created", + "type": "string" + }, + "id": { + "description": "The ID of the schema snapshot", + "type": "string" + }, + "name": { + "description": "The name of the schema snapshot", + "type": "string" + }, + "updated_at": { + "description": "When the schema snapshot was last updated", + "type": "string" + }, + "url": { + "description": "The URL to the schema snapshot in the PlanetScale app", + "type": "string" + } + }, + "additionalProperties": false + }, + "size": { + "description": "The size of the backup", + "type": "number" + }, + "state": { + "description": "The current state of the backup", + "type": "string", + "enum": [ + "pending", + "running", + "success", + "failed", + "canceled", + "ignored" + ] + }, + "updated_at": { + "description": "When the backup was last updated", + "type": "string" + } + }, + "additionalProperties": false + } }, "401": { "description": "Unauthorized" @@ -832,12 +1260,12 @@ "Database branch passwords" ], "summary": "List passwords", - "operationId": "list-passwords", + "operationId": "list_passwords", "parameters": [ { "type": "string", - "description": "The name of the branch the password belongs to", - "name": "branch", + "description": "The name of the organization the password belongs to", + "name": "organization", "in": "path", "required": true }, @@ -850,8 +1278,8 @@ }, { "type": "string", - "description": "The name of the organization the password belongs to", - "name": "organization", + "description": "The name of the branch the password belongs to", + "name": "branch", "in": "path", "required": true }, @@ -910,7 +1338,7 @@ } }, "post": { - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `create_branch_password`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |", + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `connect_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |", "consumes": [ "application/json" ], @@ -918,12 +1346,12 @@ "Database branch passwords" ], "summary": "Create a password", - "operationId": "create-a-password", + "operationId": "create_password", "parameters": [ { "type": "string", - "description": "The name of the branch the password belongs to", - "name": "branch", + "description": "The name of the organization the password belongs to", + "name": "organization", "in": "path", "required": true }, @@ -936,8 +1364,8 @@ }, { "type": "string", - "description": "The name of the organization the password belongs to", - "name": "organization", + "description": "The name of the branch the password belongs to", + "name": "branch", "in": "path", "required": true }, @@ -951,6 +1379,10 @@ "description": "Optional name of the password", "type": "string" }, + "replica": { + "description": "Whether the password is for a read replica", + "type": "boolean" + }, "role": { "description": "The database role of the password (i.e. admin)", "type": "string", @@ -1005,41 +1437,35 @@ "Database branch passwords" ], "summary": "Get a password", - "operationId": "get-a-password", + "operationId": "get_password", "parameters": [ { "type": "string", - "description": "The ID of the password", - "name": "id", + "description": "The name of the organization the password belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the branch the password belongs to", - "name": "branch", + "description": "The name of the database the password belongs to", + "name": "database", "in": "path", "required": true }, { "type": "string", - "description": "The name of the database the password belongs to", - "name": "database", + "description": "The name of the branch the password belongs to", + "name": "branch", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the password belongs to", - "name": "organization", + "description": "The ID of the password", + "name": "id", "in": "path", "required": true - }, - { - "type": "string", - "description": "A read-only region of the database branch. If present, the password results will be filtered to only those in the region", - "name": "read_only_region_id", - "in": "query" } ], "responses": { @@ -1072,33 +1498,33 @@ "Database branch passwords" ], "summary": "Delete a password", - "operationId": "delete-a-password", + "operationId": "delete_password", "parameters": [ { "type": "string", - "description": "The ID of the password", - "name": "id", + "description": "The name of the organization the password belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the branch the password belongs to", - "name": "branch", + "description": "The name of the database the password belongs to", + "name": "database", "in": "path", "required": true }, { "type": "string", - "description": "The name of the database the password belongs to", - "name": "database", + "description": "The name of the branch the password belongs to", + "name": "branch", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the password belongs to", - "name": "organization", + "description": "The ID of the password", + "name": "id", "in": "path", "required": true } @@ -1122,7 +1548,7 @@ } }, "patch": { - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `create_branch_password`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |", + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `connect_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |", "consumes": [ "application/json" ], @@ -1130,33 +1556,33 @@ "Database branch passwords" ], "summary": "Update a password", - "operationId": "update-a-password", + "operationId": "update_password", "parameters": [ { "type": "string", - "description": "The ID of the password", - "name": "id", + "description": "The name of the organization the password belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the branch the password belongs to", - "name": "branch", + "description": "The name of the database the password belongs to", + "name": "database", "in": "path", "required": true }, { "type": "string", - "description": "The name of the database the password belongs to", - "name": "database", + "description": "The name of the branch the password belongs to", + "name": "branch", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the password belongs to", - "name": "organization", + "description": "The ID of the password", + "name": "id", "in": "path", "required": true }, @@ -1202,7 +1628,7 @@ }, "/organizations/{organization}/databases/{database}/branches/{branch}/passwords/{id}/renew": { "post": { - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `create_branch_password`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |", + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `connect_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |", "consumes": [ "application/json" ], @@ -1210,49 +1636,35 @@ "Database branch passwords" ], "summary": "Renew a password", - "operationId": "renew-a-password", + "operationId": "renew_password", "parameters": [ { "type": "string", - "description": "The ID of the password", - "name": "id", + "description": "The name of the organization the password belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the branch the password belongs to", - "name": "branch", + "description": "The name of the database the password belongs to", + "name": "database", "in": "path", "required": true }, { "type": "string", - "description": "The name of the database the password belongs to", - "name": "database", + "description": "The name of the branch the password belongs to", + "name": "branch", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the password belongs to", - "name": "organization", + "description": "The ID of the password", + "name": "id", "in": "path", "required": true - }, - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "read_only_region_id": { - "description": "A read-only region of the database branch. If present, the password results will be filtered to only those in the region", - "type": "string" - } - }, - "additionalProperties": false - } } ], "responses": { @@ -1287,12 +1699,12 @@ "Database branches" ], "summary": "Get a branch", - "operationId": "get-a-branch", + "operationId": "get_branch", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "name", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -1305,8 +1717,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "name", "in": "path", "required": true } @@ -1341,12 +1753,12 @@ "Database branches" ], "summary": "Delete a branch", - "operationId": "delete-a-branch", + "operationId": "delete_branch", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "name", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -1357,17 +1769,87 @@ "in": "path", "required": true }, + { + "type": "string", + "description": "The name of the branch", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Delete a branch" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/organizations/{organization}/databases/{database}/branches/{name}/cluster": { + "patch": { + "description": "\n### Authorization\nA service token must have at least one of the following access in order to use this API endpoint:\n\n**Service Token Accesses**\n `write_database`\n\n", + "consumes": [ + "application/json" + ], + "tags": [ + "Database branches" + ], + "summary": "Change a branch cluster configuration", + "operationId": "update_branch_cluster_config", + "parameters": [ { "type": "string", "description": "The name of the organization the branch belongs to", "name": "organization", "in": "path", "required": true + }, + { + "type": "string", + "description": "The name of the database the branch belongs to", + "name": "database", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the branch to configure", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": [ + "cluster_size" + ], + "properties": { + "cluster_size": { + "description": "The new size of the database cluster: PS_10, PS_20,…", + "type": "string" + } + }, + "additionalProperties": false + } } ], "responses": { "204": { - "description": "Delete a branch" + "description": "Returns an empty response body" }, "401": { "description": "Unauthorized" @@ -1394,12 +1876,12 @@ "Database branches" ], "summary": "Demote a branch", - "operationId": "demote-a-branch", + "operationId": "demote_branch", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "name", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -1412,8 +1894,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "name", "in": "path", "required": true } @@ -1450,12 +1932,12 @@ "Database branches" ], "summary": "Promote a branch", - "operationId": "promote-a-branch", + "operationId": "promote_branch", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "name", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -1468,8 +1950,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "name", "in": "path", "required": true } @@ -1506,12 +1988,12 @@ "Database branches" ], "summary": "Enable safe migrations for a branch", - "operationId": "enable-safe-migrations-for-a-branch", + "operationId": "enable_safe_migrations", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "name", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -1524,8 +2006,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "name", "in": "path", "required": true } @@ -1560,12 +2042,12 @@ "Database branches" ], "summary": "Disable safe migrations for a branch", - "operationId": "disable-safe-migrations-for-a-branch", + "operationId": "disable_safe_migrations", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "name", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -1578,8 +2060,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "name", "in": "path", "required": true } @@ -1616,12 +2098,12 @@ "Database branches" ], "summary": "Get a branch schema", - "operationId": "get-a-branch-schema", + "operationId": "get_branch_schema", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "name", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -1634,8 +2116,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "name", "in": "path", "required": true }, @@ -1690,12 +2172,12 @@ "Database branches" ], "summary": "Lint a branch schema", - "operationId": "lint-a-branch-schema", + "operationId": "lint_branch_schema", "parameters": [ { "type": "string", - "description": "The name of the branch", - "name": "name", + "description": "The name of the organization the branch belongs to", + "name": "organization", "in": "path", "required": true }, @@ -1708,8 +2190,8 @@ }, { "type": "string", - "description": "The name of the organization the branch belongs to", - "name": "organization", + "description": "The name of the branch", + "name": "name", "in": "path", "required": true }, @@ -1772,19 +2254,19 @@ "Deploy requests" ], "summary": "Get the deploy queue", - "operationId": "get-the-deploy-queue", + "operationId": "get_deploy_queue", "parameters": [ { "type": "string", - "description": "The name of the deploy request's database", - "name": "database", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The name of the deploy request's database", + "name": "database", "in": "path", "required": true } @@ -1807,6 +2289,18 @@ }, "additionalProperties": false } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -1821,19 +2315,19 @@ "Deploy requests" ], "summary": "List deploy requests", - "operationId": "list-deploy-requests", + "operationId": "list_deploy_requests", "parameters": [ { "type": "string", - "description": "The name of the deploy request's database", - "name": "database", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The name of the deploy request's database", + "name": "database", "in": "path", "required": true }, @@ -1888,6 +2382,18 @@ }, "additionalProperties": false } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } }, @@ -1900,19 +2406,19 @@ "Deploy requests" ], "summary": "Create a deploy request", - "operationId": "create-a-deploy-request", + "operationId": "create_deploy_request", "parameters": [ { "type": "string", - "description": "The name of the deploy request's database", - "name": "database", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The name of the deploy request's database", + "name": "database", "in": "path", "required": true }, @@ -1921,7 +2427,19 @@ "in": "body", "schema": { "type": "object", + "required": [ + "branch", + "into_branch" + ], "properties": { + "auto_cutover": { + "description": "Whether or not to enable auto_cutover for the deploy request. When enabled, will auto cutover to the new schema as soon as it is ready.", + "type": "boolean" + }, + "auto_delete_branch": { + "description": "Whether or not to enable auto_delete_branch for the deploy request. When enabled, will delete the branch once the DR successfully completes.", + "type": "boolean" + }, "branch": { "description": "The name of the branch the deploy request is created from", "type": "string" @@ -1945,26 +2463,38 @@ "schema": { "$ref": "#/definitions/deploy_request_with_deployment" } - } - } - } - }, - "/organizations/{organization}/databases/{database}/deploy-requests/{number}": { - "get": { - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_deploy_request`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_deploy_requests` |\n| Database | `read_deploy_requests` |", - "consumes": [ - "application/json" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/organizations/{organization}/databases/{database}/deploy-requests/{number}": { + "get": { + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_deploy_request`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_deploy_requests` |\n| Database | `read_deploy_requests` |", + "consumes": [ + "application/json" ], "tags": [ "Deploy requests" ], "summary": "Get a deploy request", - "operationId": "get-a-deploy-request", + "operationId": "get_deploy_request", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -1977,8 +2507,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -1989,6 +2519,18 @@ "schema": { "$ref": "#/definitions/deploy_request_with_deployment" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } }, @@ -2001,12 +2543,12 @@ "Deploy requests" ], "summary": "Close a deploy request", - "operationId": "close-a-deploy-request", + "operationId": "close_deploy_request", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -2019,8 +2561,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true }, @@ -2048,6 +2590,18 @@ "schema": { "$ref": "#/definitions/deploy_request_with_deployment" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2062,12 +2616,12 @@ "Deploy requests" ], "summary": "Complete a gated deploy request", - "operationId": "complete-a-gated-deploy-request", + "operationId": "complete_gated_deploy_request", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -2080,8 +2634,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -2092,6 +2646,18 @@ "schema": { "$ref": "#/definitions/deploy_request" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2106,12 +2672,12 @@ "Deploy requests" ], "summary": "Update auto-apply for deploy request", - "operationId": "update-auto-apply-for-deploy-request", + "operationId": "update_auto_apply", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -2124,8 +2690,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true }, @@ -2150,6 +2716,18 @@ "schema": { "$ref": "#/definitions/deploy_request" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2164,12 +2742,12 @@ "Deploy requests" ], "summary": "Cancel a queued deploy request", - "operationId": "cancel-a-queued-deploy-request", + "operationId": "cancel_deploy_request", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -2182,8 +2760,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -2194,6 +2772,18 @@ "schema": { "$ref": "#/definitions/deploy_request" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2208,12 +2798,12 @@ "Deploy requests" ], "summary": "Complete an errored deploy", - "operationId": "complete-an-errored-deploy", + "operationId": "complete_errored_deploy", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -2226,8 +2816,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -2238,6 +2828,18 @@ "schema": { "$ref": "#/definitions/deploy_request" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2252,12 +2854,12 @@ "Deploy requests" ], "summary": "Queue a deploy request", - "operationId": "queue-a-deploy-request", + "operationId": "queue_deploy_request", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the organization the deploy request belongs to", + "name": "organization", "in": "path", "required": true }, @@ -2270,8 +2872,8 @@ }, { "type": "string", - "description": "The name of the organization the deploy request belongs to", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -2282,6 +2884,18 @@ "schema": { "$ref": "#/definitions/deploy_request" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2296,12 +2910,12 @@ "Deploy requests" ], "summary": "Get a deployment", - "operationId": "get-a-deployment", + "operationId": "get_deployment", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -2314,8 +2928,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -2326,6 +2940,18 @@ "schema": { "$ref": "#/definitions/deployment" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2340,12 +2966,12 @@ "Deploy requests" ], "summary": "List deploy operations", - "operationId": "list-deploy-operations", + "operationId": "list_deploy_operations", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the organization the deploy request belongs to", + "name": "organization", "in": "path", "required": true }, @@ -2358,8 +2984,8 @@ }, { "type": "string", - "description": "The name of the organization the deploy request belongs to", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true }, @@ -2396,6 +3022,18 @@ }, "additionalProperties": false } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2410,12 +3048,12 @@ "Deploy requests" ], "summary": "Complete a revert", - "operationId": "complete-a-revert", + "operationId": "complete_revert", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -2428,8 +3066,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -2440,6 +3078,18 @@ "schema": { "$ref": "#/definitions/deploy_request" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2454,12 +3104,12 @@ "Deploy requests" ], "summary": "List deploy request reviews", - "operationId": "list-deploy-request-reviews", + "operationId": "list_deploy_request_reviews", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the organization the deploy request belongs to", + "name": "organization", "in": "path", "required": true }, @@ -2472,8 +3122,8 @@ }, { "type": "string", - "description": "The name of the organization the deploy request belongs to", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -2496,6 +3146,18 @@ }, "additionalProperties": false } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } }, @@ -2508,12 +3170,12 @@ "Deploy requests" ], "summary": "Review a deploy request", - "operationId": "review-a-deploy-request", + "operationId": "review_deploy_request", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the organization the deploy request belongs to", + "name": "organization", "in": "path", "required": true }, @@ -2526,8 +3188,8 @@ }, { "type": "string", - "description": "The name of the organization the deploy request belongs to", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true }, @@ -2560,6 +3222,18 @@ "schema": { "$ref": "#/definitions/deploy_review" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } @@ -2574,12 +3248,12 @@ "Deploy requests" ], "summary": "Skip revert period", - "operationId": "skip-revert-period", + "operationId": "skip_revert_period", "parameters": [ { "type": "string", - "description": "The number of the deploy request", - "name": "number", + "description": "The name of the deploy request's organization", + "name": "organization", "in": "path", "required": true }, @@ -2592,8 +3266,8 @@ }, { "type": "string", - "description": "The name of the deploy request's organization", - "name": "organization", + "description": "The number of the deploy request", + "name": "number", "in": "path", "required": true } @@ -2604,13 +3278,25 @@ "schema": { "$ref": "#/definitions/deploy_request" } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" } } } }, "/organizations/{organization}/databases/{name}": { "get": { - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |\n| Database | `read_database` |", + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |\n| Database | `read_database` |", "consumes": [ "application/json" ], @@ -2618,19 +3304,19 @@ "Databases" ], "summary": "Get a database", - "operationId": "get-a-database", + "operationId": "get_database", "parameters": [ { "type": "string", - "description": "The name of the database", - "name": "name", + "description": "The name of the organization the database belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the database belongs to", - "name": "organization", + "description": "The name of the database", + "name": "name", "in": "path", "required": true } @@ -2665,19 +3351,19 @@ "Databases" ], "summary": "Delete a database", - "operationId": "delete-a-database", + "operationId": "delete_database", "parameters": [ { "type": "string", - "description": "The name of the database", - "name": "name", + "description": "The name of the organization the database belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the database belongs to", - "name": "organization", + "description": "The name of the database", + "name": "name", "in": "path", "required": true } @@ -2709,19 +3395,19 @@ "Databases" ], "summary": "Update database settings", - "operationId": "update-database-settings", + "operationId": "update_database_settings", "parameters": [ { "type": "string", - "description": "The name of the database", - "name": "name", + "description": "The name of the organization the database belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the database belongs to", - "name": "organization", + "description": "The name of the database", + "name": "name", "in": "path", "required": true }, @@ -2774,9 +3460,159 @@ ], "responses": { "200": { - "description": "Returns the updated database", + "description": "Returns the updated database", + "schema": { + "$ref": "#/definitions/database" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/organizations/{organization}/databases/{name}/read-only-regions": { + "get": { + "description": "List read-only regions for the database's default branch\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Databases" + ], + "summary": "List read-only regions", + "operationId": "list_read_only_regions", + "parameters": [ + { + "type": "string", + "description": "The name of the organization the database belongs to", + "name": "organization", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the database", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "number", + "default": 1, + "description": "If provided, specifies the page offset of returned results", + "name": "page", + "in": "query" + }, + { + "type": "number", + "default": 25, + "description": "If provided, specifies the number of returned results", + "name": "per_page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "List of the database's read-only regions", + "schema": { + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/read_only_region" + } + } + }, + "additionalProperties": false + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/organizations/{organization}/databases/{name}/regions": { + "get": { + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |\n| Database | `read_database` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Databases" + ], + "summary": "List database regions", + "operationId": "list_database_regions", + "parameters": [ + { + "type": "string", + "description": "The name of the organization the database belongs to", + "name": "organization", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the database", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "number", + "default": 1, + "description": "If provided, specifies the page offset of returned results", + "name": "page", + "in": "query" + }, + { + "type": "number", + "default": 25, + "description": "If provided, specifies the number of returned results", + "name": "per_page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Returns the available regions for a database", "schema": { - "$ref": "#/definitions/database" + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/region" + } + } + }, + "additionalProperties": false } }, "401": { @@ -2794,28 +3630,21 @@ } } }, - "/organizations/{organization}/databases/{name}/read-only-regions": { + "/organizations/{organization}/invoices": { "get": { - "description": "List read-only regions for the database's default branch\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |", + "description": "Get the invoices for an organization\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_invoices`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_invoices` |", "consumes": [ "application/json" ], "tags": [ - "Databases" + "Invoices" ], - "summary": "List read-only regions", - "operationId": "list-read-only-regions", + "summary": "Get invoices", + "operationId": "list_invoices", "parameters": [ { "type": "string", - "description": "The name of the database", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "The name of the organization the database belongs to", + "description": "The name of the organization", "name": "organization", "in": "path", "required": true @@ -2837,7 +3666,7 @@ ], "responses": { "200": { - "description": "List of the database's read-only regions", + "description": "Gets the invoices for an organization", "schema": { "type": "object", "required": [ @@ -2847,7 +3676,32 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/read_only_region" + "type": "object", + "required": [ + "id", + "total", + "billing_period_start", + "billing_period_end" + ], + "properties": { + "billing_period_end": { + "description": "End of the billing period", + "type": "string" + }, + "billing_period_start": { + "description": "Start of the billing period", + "type": "string" + }, + "id": { + "description": "The ID for the invoice", + "type": "string" + }, + "total": { + "description": "The total amount of the invoice", + "type": "number" + } + }, + "additionalProperties": false } } }, @@ -2869,50 +3723,110 @@ } } }, - "/organizations/{organization}/databases/{name}/regions": { + "/organizations/{organization}/invoices/{id}": { "get": { - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |\n| Database | `read_database` |", + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_invoices`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_invoices` |", "consumes": [ "application/json" ], "tags": [ - "Databases" + "Invoices" ], - "summary": "List database regions", - "operationId": "list-database-regions", + "summary": "Get an invoice", + "operationId": "get_invoice", "parameters": [ { "type": "string", - "description": "The name of the database", - "name": "name", + "description": "The name of the organization", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the database belongs to", - "name": "organization", + "description": "The ID of the invoice", + "name": "id", "in": "path", "required": true + } + ], + "responses": { + "200": { + "description": "Returns an invoice", + "schema": { + "type": "object", + "required": [ + "id", + "total", + "billing_period_start", + "billing_period_end" + ], + "properties": { + "billing_period_end": { + "description": "End of the billing period", + "type": "string" + }, + "billing_period_start": { + "description": "Start of the billing period", + "type": "string" + }, + "id": { + "description": "The ID for the invoice", + "type": "string" + }, + "total": { + "description": "The total amount of the invoice", + "type": "number" + } + }, + "additionalProperties": false + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/organizations/{organization}/invoices/{id}/line-items": { + "get": { + "description": "Get the line items for an invoice\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_invoices`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_invoices` |", + "consumes": [ + "application/json" + ], + "tags": [ + "Invoices" + ], + "summary": "Get invoice line items", + "operationId": "get_invoice_line_items", + "parameters": [ { - "type": "number", - "default": 1, - "description": "If provided, specifies the page offset of returned results", - "name": "page", - "in": "query" + "type": "string", + "description": "The name of the organization", + "name": "organization", + "in": "path", + "required": true }, { - "type": "number", - "default": 25, - "description": "If provided, specifies the number of returned results", - "name": "per_page", - "in": "query" + "type": "string", + "description": "The ID of the invoice", + "name": "id", + "in": "path", + "required": true } ], "responses": { "200": { - "description": "Returns the available regions for a database", + "description": "Gets the line items for an invoice", "schema": { "type": "object", "required": [ @@ -2922,7 +3836,76 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/region" + "type": "object", + "required": [ + "id", + "subtotal", + "description", + "metric_name", + "database_id", + "database_name", + "resource" + ], + "properties": { + "database_id": { + "description": "The ID for the billed database", + "type": "string" + }, + "database_name": { + "description": "The name for the billed database", + "type": "string" + }, + "description": { + "description": "The description for the line item", + "type": "string" + }, + "id": { + "description": "The ID for the line item", + "type": "string" + }, + "metric_name": { + "description": "The metric describes what is being billed for. Such as PS_10 or Storage.", + "type": "string" + }, + "resource": { + "type": "object", + "required": [ + "id", + "name", + "created_at", + "updated_at", + "deleted_at" + ], + "properties": { + "created_at": { + "description": "When the resource was created", + "type": "string" + }, + "deleted_at": { + "description": "When the resource was deleted, if deleted", + "type": "string" + }, + "id": { + "description": "The ID for the resource", + "type": "string" + }, + "name": { + "description": "The name for the resource", + "type": "string" + }, + "updated_at": { + "description": "When the resource was last updated", + "type": "string" + } + }, + "additionalProperties": false + }, + "subtotal": { + "description": "The total for the line item", + "type": "number" + } + }, + "additionalProperties": false } } }, @@ -2954,7 +3937,7 @@ "OAuth applications" ], "summary": "List OAuth applications", - "operationId": "list-oauth-applications", + "operationId": "list_oauth_applications", "parameters": [ { "type": "string", @@ -3022,19 +4005,19 @@ "OAuth applications" ], "summary": "Get an OAuth application", - "operationId": "get-an-oauth-application", + "operationId": "get_oauth_application", "parameters": [ { "type": "string", - "description": "The ID of the OAuth application", - "name": "application_id", + "description": "The name of the organization the OAuth application belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the OAuth application belongs to", - "name": "organization", + "description": "The ID of the OAuth application", + "name": "application_id", "in": "path", "required": true } @@ -3071,19 +4054,19 @@ "OAuth applications" ], "summary": "List OAuth tokens", - "operationId": "list-oauth-tokens", + "operationId": "list_oauth_tokens", "parameters": [ { "type": "string", - "description": "The ID of the OAuth application", - "name": "application_id", + "description": "The name of the organization the OAuth application belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the OAuth application belongs to", - "name": "organization", + "description": "The ID of the OAuth application", + "name": "application_id", "in": "path", "required": true }, @@ -3146,12 +4129,12 @@ "OAuth applications" ], "summary": "Get an OAuth token", - "operationId": "get-an-oauth-token", + "operationId": "get_oauth_token", "parameters": [ { "type": "string", - "description": "The ID of the OAuth application token", - "name": "token_id", + "description": "The name of the organization the OAuth application belongs to", + "name": "organization", "in": "path", "required": true }, @@ -3164,8 +4147,8 @@ }, { "type": "string", - "description": "The name of the organization the OAuth application belongs to", - "name": "organization", + "description": "The ID of the OAuth application token", + "name": "token_id", "in": "path", "required": true } @@ -3200,12 +4183,12 @@ "OAuth applications" ], "summary": "Delete an OAuth token", - "operationId": "delete-an-oauth-token", + "operationId": "delete_oauth_token", "parameters": [ { "type": "string", - "description": "The ID of the OAuth application token", - "name": "token_id", + "description": "The name of the organization the OAuth application belongs to", + "name": "organization", "in": "path", "required": true }, @@ -3218,8 +4201,8 @@ }, { "type": "string", - "description": "The name of the organization the OAuth application belongs to", - "name": "organization", + "description": "The ID of the OAuth application token", + "name": "token_id", "in": "path", "required": true } @@ -3253,19 +4236,19 @@ "OAuth tokens" ], "summary": "Create or renew an OAuth token", - "operationId": "create-or-renew-an-oauth-token", + "operationId": "create_oauth_token", "parameters": [ { "type": "string", - "description": "The ID of the OAuth application", - "name": "id", + "description": "The name of the organization the OAuth application belongs to", + "name": "organization", "in": "path", "required": true }, { "type": "string", - "description": "The name of the organization the OAuth application belongs to", - "name": "organization", + "description": "The ID of the OAuth application", + "name": "id", "in": "path", "required": true }, @@ -3335,6 +4318,105 @@ } } }, + "/regions": { + "get": { + "description": "Endpoint is available without authentication.\n", + "consumes": [ + "application/json" + ], + "tags": [ + "Regions" + ], + "summary": "List public regions", + "operationId": "get_regions", + "parameters": [ + { + "type": "number", + "default": 1, + "description": "If provided, specifies the page offset of returned results", + "name": "page", + "in": "query" + }, + { + "type": "number", + "default": 25, + "description": "If provided, specifies the number of returned results", + "name": "per_page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Returns the available public PlanetScale regions", + "schema": { + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "provider", + "public_ip_addresses", + "display_name", + "location", + "slug" + ], + "properties": { + "display_name": { + "description": "Name of the region", + "type": "string" + }, + "id": { + "description": "The ID of the region", + "type": "string" + }, + "location": { + "description": "Location of the region", + "type": "string" + }, + "provider": { + "description": "Provider for the region (ex. AWS)", + "type": "string" + }, + "public_ip_addresses": { + "description": "Public IP addresses for the region", + "type": "array", + "items": { + "type": "string" + } + }, + "slug": { + "description": "The slug of the region", + "type": "string" + } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, "/user": { "get": { "description": "Get the user associated with this service token\n### Authorization\nA OAuth token must have at least one of the following scopes in order to use this API endpoint:\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| User | `read_user` |", @@ -3345,7 +4427,7 @@ "Users" ], "summary": "Get current user", - "operationId": "get-current-user", + "operationId": "get_current_user", "responses": { "200": { "description": "Returns the current user that is associated with this service token", @@ -3397,7 +4479,6 @@ "type": "object", "required": [ "id", - "actor", "name", "state", "size", @@ -3405,7 +4486,6 @@ "created_at", "updated_at", "required", - "backup_policy", "schema_snapshot" ], "properties": { @@ -3421,7 +4501,7 @@ }, "estimated_storage_cost": { "description": "The estimated storage cost of the backup", - "type": "string" + "type": "number" }, "id": { "description": "The ID of the backup", @@ -3566,13 +4646,10 @@ "production", "sharded", "html_url", - "cluster_rate_name" + "cluster_rate_name", + "safe_migrations" ], "properties": { - "access_host_url": { - "description": "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`", - "type": "string" - }, "actor": { "$ref": "#/definitions/actor" }, @@ -3592,10 +4669,6 @@ "description": "The ID of the branch", "type": "string" }, - "initial_restore_id": { - "description": "The ID of the backup from which the branch was restored", - "type": "string" - }, "mysql_address": { "description": "The MySQL address for the branch", "type": "string" @@ -3630,6 +4703,10 @@ "restored_from_branch": { "$ref": "#/definitions/restored_from_branch" }, + "safe_migrations": { + "description": "Whether or not the branch has safe migrations enabled", + "type": "boolean" + }, "schema_last_updated_at": { "description": "When the schema for the branch was last updated", "type": "string" @@ -3771,7 +4848,6 @@ "type": "object", "required": [ "id", - "type", "url", "branches_url", "branches_count", @@ -3780,7 +4856,6 @@ "issues_count", "multiple_admins_required_for_deletion", "ready", - "at_development_branch_limit", "at_backup_restore_branches_limit", "region", "html_url", @@ -3809,10 +4884,6 @@ "description": "If the database has reached its backup restored branch limit", "type": "boolean" }, - "at_development_branch_limit": { - "description": "If the database has reached its development branch limit", - "type": "boolean" - }, "automatic_migrations": { "description": "Whether to automatically manage Rails migrations during deploy requests", "type": "boolean" @@ -3922,10 +4993,6 @@ "description": "State of the database", "type": "string" }, - "type": { - "description": "The object type", - "type": "string" - }, "updated_at": { "type": "string" }, @@ -4043,6 +5110,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -4083,6 +5151,10 @@ "branch_deleted_by": { "$ref": "#/definitions/actor" }, + "branch_id": { + "description": "The id of the branch the deploy request was created from", + "type": "string" + }, "closed_at": { "description": "When the deploy request was closed", "type": "string" @@ -4117,6 +5189,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -4178,6 +5251,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -4219,6 +5293,10 @@ "branch_deleted_by": { "$ref": "#/definitions/actor" }, + "branch_id": { + "description": "The id of the branch the deploy request was created from", + "type": "string" + }, "closed_at": { "description": "When the deploy request was closed", "type": "string" @@ -4256,6 +5334,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -4426,6 +5505,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -4898,26 +5978,16 @@ "sso_directory", "single_tenancy", "has_past_due_invoices", - "can_create_databases", - "free_databases_remaining", "database_count", "sleeping_database_count", - "admin_only_production_access", - "idp_managed_roles" + "idp_managed_roles", + "invoice_budget_amount" ], "properties": { - "admin_only_production_access": { - "description": "Whether or not only administrators can access production branches in the organization", - "type": "boolean" - }, "billing_email": { "description": "The billing email of the organization", "type": "string" }, - "can_create_databases": { - "description": "Whether or not more databases can be created in the organization", - "type": "boolean" - }, "created_at": { "description": "When the organization was created", "type": "string" @@ -4932,10 +6002,6 @@ "flags": { "$ref": "#/definitions/flags" }, - "free_databases_remaining": { - "description": "The number of remaining free databases that can be created in the organization", - "type": "number" - }, "has_past_due_invoices": { "description": "Whether or not the organization has past due billing invoices", "type": "boolean" @@ -4948,6 +6014,10 @@ "description": "Whether or not the IdP provider is be responsible for managing roles in PlanetScale", "type": "boolean" }, + "invoice_budget_amount": { + "description": "The expected monthly budget for the organization", + "type": "number" + }, "name": { "description": "The name of the organization", "type": "string" @@ -4996,6 +6066,7 @@ "created_at", "ttl_seconds", "access_host_url", + "replica", "renewable", "database_branch" ], @@ -5037,6 +6108,10 @@ "description": "Whether or not the password can be renewed", "type": "boolean" }, + "replica": { + "description": "Whether or not the password is for a read replica", + "type": "boolean" + }, "role": { "description": "The role for the password", "type": "string" @@ -5061,6 +6136,7 @@ "created_at", "ttl_seconds", "access_host_url", + "replica", "renewable", "database_branch", "plain_text" @@ -5107,6 +6183,10 @@ "description": "Whether or not the password can be renewed", "type": "boolean" }, + "replica": { + "description": "Whether or not the password is for a read replica", + "type": "boolean" + }, "role": { "description": "The role for the password", "type": "string" @@ -5193,6 +6273,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -5393,6 +6474,9 @@ }, "user": { "type": "object", + "required": [ + "default_organization" + ], "properties": { "avatar_url": { "description": "The URL source of the user's avatar", @@ -5402,9 +6486,38 @@ "description": "When the user was created", "type": "string" }, - "default_organization_id": { - "description": "The default organization for the user", - "type": "string" + "default_organization": { + "type": "object", + "required": [ + "id", + "name", + "created_at", + "updated_at", + "deleted_at" + ], + "properties": { + "created_at": { + "description": "When the resource was created", + "type": "string" + }, + "deleted_at": { + "description": "When the resource was deleted, if deleted", + "type": "string" + }, + "id": { + "description": "The ID for the resource", + "type": "string" + }, + "name": { + "description": "The name for the resource", + "type": "string" + }, + "updated_at": { + "description": "When the resource was last updated", + "type": "string" + } + }, + "additionalProperties": false }, "directory_managed": { "description": "Whether or not the user is managed by a WorkOS directory", @@ -5469,14 +6582,18 @@ "description": " API endpoints for managing database branch backups.\n", "name": "Backups" }, - { - "description": " API endpoints for managing databases within an organization.\n", - "name": "Databases" - }, { "description": " API endpoints for managing database branch passwords.\n", "name": "Database branch passwords" }, + { + "description": " API endpoints for managing database deploy requests.\n", + "name": "Deploy requests" + }, + { + "description": " API endpoints for managing databases within an organization.\n", + "name": "Databases" + }, { "description": " API endpoints for fetching OAuth applications.\n", "name": "OAuth applications" @@ -5490,12 +6607,12 @@ "name": "Organizations" }, { - "description": " API endpoints for fetching user information.\n", - "name": "Users" + "description": " API endpoints for fetching invoice information.\n", + "name": "Invoices" }, { - "description": " API endpoints for managing database deploy requests.\n", - "name": "Deploy requests" + "description": " API endpoints for fetching user information.\n", + "name": "Users" } ], "x-readme": { diff --git a/openapi/openapi-spec.json b/openapi/openapi-spec.json index faac24c..0261f97 100644 --- a/openapi/openapi-spec.json +++ b/openapi/openapi-spec.json @@ -2,9 +2,9 @@ "swagger": "2.0", "info": { "title": "PlanetScale API", - "description": "\n

PlanetScale API

\n© 2023 PlanetScale, Inc.", + "description": "\n

PlanetScale API

\n© 2024 PlanetScale, Inc.", "version": "v1", - "x-copyright": "© 2023 PlanetScale, Inc." + "x-copyright": "© 2024 PlanetScale, Inc." }, "basePath": "/v1", "consumes": [ @@ -19,7 +19,7 @@ "consumes": [ "application/json" ], - "operationId": "list-organizations", + "operationId": "list_organizations", "summary": "List organizations", "parameters": [ { @@ -104,14 +104,6 @@ "type": "boolean", "description": "Whether or not the organization has past due billing invoices" }, - "can_create_databases": { - "type": "boolean", - "description": "Whether or not more databases can be created in the organization" - }, - "free_databases_remaining": { - "type": "number", - "description": "The number of remaining free databases that can be created in the organization" - }, "database_count": { "type": "number", "description": "The number of databases in the organization" @@ -120,10 +112,6 @@ "type": "number", "description": "The number of sleeping databases in the organization" }, - "admin_only_production_access": { - "type": "boolean", - "description": "Whether or not only administrators can access production branches in the organization" - }, "sso_portal_url": { "type": "string", "description": "The URL of the organization's SSO portal" @@ -159,6 +147,10 @@ "idp_managed_roles": { "type": "boolean", "description": "Whether or not the IdP provider is be responsible for managing roles in PlanetScale" + }, + "invoice_budget_amount": { + "type": "number", + "description": "The expected monthly budget for the organization" } }, "additionalProperties": false, @@ -173,12 +165,10 @@ "sso_directory", "single_tenancy", "has_past_due_invoices", - "can_create_databases", - "free_databases_remaining", "database_count", "sleeping_database_count", - "admin_only_production_access", - "idp_managed_roles" + "idp_managed_roles", + "invoice_budget_amount" ] } } @@ -201,7 +191,7 @@ "consumes": [ "application/json" ], - "operationId": "get-an-organization", + "operationId": "get_organization", "summary": "Get an organization", "parameters": [ { @@ -274,14 +264,6 @@ "type": "boolean", "description": "Whether or not the organization has past due billing invoices" }, - "can_create_databases": { - "type": "boolean", - "description": "Whether or not more databases can be created in the organization" - }, - "free_databases_remaining": { - "type": "number", - "description": "The number of remaining free databases that can be created in the organization" - }, "database_count": { "type": "number", "description": "The number of databases in the organization" @@ -290,10 +272,6 @@ "type": "number", "description": "The number of sleeping databases in the organization" }, - "admin_only_production_access": { - "type": "boolean", - "description": "Whether or not only administrators can access production branches in the organization" - }, "sso_portal_url": { "type": "string", "description": "The URL of the organization's SSO portal" @@ -329,6 +307,10 @@ "idp_managed_roles": { "type": "boolean", "description": "Whether or not the IdP provider is be responsible for managing roles in PlanetScale" + }, + "invoice_budget_amount": { + "type": "number", + "description": "The expected monthly budget for the organization" } }, "additionalProperties": false, @@ -343,12 +325,10 @@ "sso_directory", "single_tenancy", "has_past_due_invoices", - "can_create_databases", - "free_databases_remaining", "database_count", "sleeping_database_count", - "admin_only_production_access", - "idp_managed_roles" + "idp_managed_roles", + "invoice_budget_amount" ] } } @@ -362,7 +342,7 @@ "consumes": [ "application/json" ], - "operationId": "update-an-organization", + "operationId": "update_organization", "summary": "Update an organization", "parameters": [ { @@ -382,13 +362,13 @@ "type": "string", "description": "The billing email for the organization" }, - "require_admin_for_production_access": { - "type": "boolean", - "description": "Whether or not only admins can access production" - }, "idp_managed_roles": { "type": "boolean", "description": "Whether or not the IdP provider is be responsible for managing roles in PlanetScale" + }, + "invoice_budget_amount": { + "type": "number", + "description": "The expected monthly budget for the organization" } }, "additionalProperties": false @@ -457,14 +437,6 @@ "type": "boolean", "description": "Whether or not the organization has past due billing invoices" }, - "can_create_databases": { - "type": "boolean", - "description": "Whether or not more databases can be created in the organization" - }, - "free_databases_remaining": { - "type": "number", - "description": "The number of remaining free databases that can be created in the organization" - }, "database_count": { "type": "number", "description": "The number of databases in the organization" @@ -473,10 +445,6 @@ "type": "number", "description": "The number of sleeping databases in the organization" }, - "admin_only_production_access": { - "type": "boolean", - "description": "Whether or not only administrators can access production branches in the organization" - }, "sso_portal_url": { "type": "string", "description": "The URL of the organization's SSO portal" @@ -512,6 +480,10 @@ "idp_managed_roles": { "type": "boolean", "description": "Whether or not the IdP provider is be responsible for managing roles in PlanetScale" + }, + "invoice_budget_amount": { + "type": "number", + "description": "The expected monthly budget for the organization" } }, "additionalProperties": false, @@ -526,12 +498,10 @@ "sso_directory", "single_tenancy", "has_past_due_invoices", - "can_create_databases", - "free_databases_remaining", "database_count", "sleeping_database_count", - "admin_only_production_access", - "idp_managed_roles" + "idp_managed_roles", + "invoice_budget_amount" ] } } @@ -539,6 +509,161 @@ "description": "\n### Authorization\nA OAuth token must have at least one of the following scopes in order to use this API endpoint:\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `write_organization` |" } }, + "/organizations/{name}/audit-log": { + "get": { + "tags": [ + "Organizations" + ], + "consumes": [ + "application/json" + ], + "operationId": "list_audit_logs", + "summary": "List audit logs", + "parameters": [ + { + "name": "name", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "200": { + "description": "Gets the audit logs for the organization", + "schema": { + "type": "object", + "properties": { + "has_next": { + "type": "boolean", + "description": "Whether there is a next page of results" + }, + "has_prev": { + "type": "boolean", + "description": "Whether there is a previous page of results" + }, + "cursor_start": { + "type": "string", + "description": "The ID of the first audit log in the current results" + }, + "cursor_end": { + "type": "string", + "description": "The ID of the last audit log in the current results" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the audit log" + }, + "actor_id": { + "type": "string", + "description": "The ID of the actor" + }, + "actor_type": { + "type": "string", + "description": "The type of the actor. Such as 'User' or 'ServiceToken'" + }, + "auditable_id": { + "type": "string", + "description": "The ID of the auditable object" + }, + "auditable_type": { + "type": "string", + "description": "The type of the auditable. Such as 'Organization' or 'Database'" + }, + "target_id": { + "type": "string", + "description": "The ID of the target" + }, + "target_type": { + "type": "string", + "description": "The type of the target. Such as 'DatabaseBranch' or 'DatabaseBranchPassword'" + }, + "locale": { + "type": "string", + "description": "The location of the actor based on their IP address" + }, + "target_display_name": { + "type": "string", + "description": "The name of the target" + }, + "actor_display_name": { + "type": "string", + "description": "The name of the actor" + }, + "auditable_display_name": { + "type": "string", + "description": "The name of the auditable object" + }, + "action": { + "type": "string", + "description": "The action that was taken" + }, + "remote_ip": { + "type": "string", + "description": "The IP address of the actor" + }, + "created_at": { + "type": "string", + "description": "When the audit log was created" + }, + "metadata": { + "type": "object", + "additionalProperties": true, + "description": "Additional metadata containing details about the change" + } + }, + "additionalProperties": false, + "required": [ + "id", + "actor_id", + "actor_type", + "auditable_id", + "auditable_type", + "target_id", + "target_type", + "locale", + "target_display_name", + "actor_display_name", + "auditable_display_name", + "action", + "remote_ip", + "created_at", + "metadata" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "has_next", + "has_prev", + "cursor_start", + "cursor_end", + "data" + ] + } + } + }, + "description": "\n### Authorization\nA service token must have at least one of the following access in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_audit_logs`\n\n" + } + }, "/organizations/{name}/regions": { "get": { "tags": [ @@ -547,7 +672,7 @@ "consumes": [ "application/json" ], - "operationId": "list-regions-for-an-organization", + "operationId": "list_regions_for_organization", "summary": "List regions for an organization", "parameters": [ { @@ -658,7 +783,7 @@ "consumes": [ "application/json" ], - "operationId": "list-databases", + "operationId": "list_databases", "summary": "List databases", "parameters": [ { @@ -710,10 +835,6 @@ "type": "string", "description": "The ID of the database" }, - "type": { - "type": "string", - "description": "The object type" - }, "url": { "type": "string", "description": "The URL to the database API endpoint" @@ -746,10 +867,6 @@ "type": "boolean", "description": "If the database is ready to be used" }, - "at_development_branch_limit": { - "type": "boolean", - "description": "If the database has reached its development branch limit" - }, "at_backup_restore_branches_limit": { "type": "boolean", "description": "If the database has reached its backup restored branch limit" @@ -927,7 +1044,6 @@ "additionalProperties": false, "required": [ "id", - "type", "url", "branches_url", "branches_count", @@ -936,7 +1052,6 @@ "issues_count", "multiple_admins_required_for_deletion", "ready", - "at_development_branch_limit", "at_backup_restore_branches_limit", "region", "html_url", @@ -966,7 +1081,7 @@ } } }, - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |" + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |" }, "post": { "tags": [ @@ -975,7 +1090,7 @@ "consumes": [ "application/json" ], - "operationId": "create-a-database", + "operationId": "create_database", "summary": "Create a database", "parameters": [ { @@ -999,18 +1114,15 @@ "type": "string", "description": "The region the database will be deployed in. If left blank, defaults to the organization's default region." }, - "plan": { - "type": "string", - "description": "The database billing plan. Options: 'hobby', 'scaler', or 'scaler_pro'." - }, "cluster_size": { "type": "string", - "description": "The database cluster size. This is required for Scaler Pro databases. Options: PS_10, PS_20, PS_40, PS_80, PS_160, PS_320, PS_400, PS_640, PS_700, PS_900, PS_1280, PS_1400, PS_1800, PS_2100, PS_2560, PS_2700, PS_2800." + "description": "The database cluster size. Options: PS_10, PS_20, PS_40, PS_80, PS_160, PS_320, PS_400, PS_640, PS_700, PS_900, PS_1280, PS_1400, PS_1800, PS_2100, PS_2560, PS_2700, PS_2800." } }, "additionalProperties": false, "required": [ - "name" + "name", + "cluster_size" ] } } @@ -1037,10 +1149,6 @@ "type": "string", "description": "The ID of the database" }, - "type": { - "type": "string", - "description": "The object type" - }, "url": { "type": "string", "description": "The URL to the database API endpoint" @@ -1073,10 +1181,6 @@ "type": "boolean", "description": "If the database is ready to be used" }, - "at_development_branch_limit": { - "type": "boolean", - "description": "If the database has reached its development branch limit" - }, "at_backup_restore_branches_limit": { "type": "boolean", "description": "If the database has reached its backup restored branch limit" @@ -1254,7 +1358,6 @@ "additionalProperties": false, "required": [ "id", - "type", "url", "branches_url", "branches_count", @@ -1263,7 +1366,6 @@ "issues_count", "multiple_admins_required_for_deletion", "ready", - "at_development_branch_limit", "at_backup_restore_branches_limit", "region", "html_url", @@ -1297,22 +1399,22 @@ "consumes": [ "application/json" ], - "operationId": "list-branches", + "operationId": "list_branches", "summary": "List branches", "parameters": [ { - "name": "database", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the database the branch belongs to" + "description": "The name of the organization the branch belongs to" }, { - "name": "organization", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the database the branch belongs to" }, { "name": "page", @@ -1372,10 +1474,6 @@ "type": "string", "description": "When a user last marked a backup restore checklist as completed" }, - "access_host_url": { - "type": "string", - "description": "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`" - }, "schema_last_updated_at": { "type": "string", "description": "When the schema for the branch was last updated" @@ -1388,10 +1486,6 @@ "type": "string", "description": "The address of the MySQL provider for the branch" }, - "initial_restore_id": { - "type": "string", - "description": "The ID of the backup from which the branch was restored" - }, "ready": { "type": "boolean", "description": "Whether or not the branch is ready to serve queries" @@ -1521,6 +1615,10 @@ "cluster_rate_name": { "type": "string", "description": "The SKU representing the branch's cluster size" + }, + "safe_migrations": { + "type": "boolean", + "description": "Whether or not the branch has safe migrations enabled" } }, "additionalProperties": false, @@ -1536,7 +1634,8 @@ "production", "sharded", "html_url", - "cluster_rate_name" + "cluster_rate_name", + "safe_migrations" ] } } @@ -1557,22 +1656,22 @@ "consumes": [ "application/json" ], - "operationId": "create-a-branch", + "operationId": "create_branch", "summary": "Create a branch", "parameters": [ { - "name": "database", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the database the branch belongs to" + "description": "The name of the organization the branch belongs to" }, { - "name": "organization", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the database the branch belongs to" }, { "name": "body", @@ -1639,10 +1738,6 @@ "type": "string", "description": "When a user last marked a backup restore checklist as completed" }, - "access_host_url": { - "type": "string", - "description": "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`" - }, "schema_last_updated_at": { "type": "string", "description": "When the schema for the branch was last updated" @@ -1655,10 +1750,6 @@ "type": "string", "description": "The address of the MySQL provider for the branch" }, - "initial_restore_id": { - "type": "string", - "description": "The ID of the backup from which the branch was restored" - }, "ready": { "type": "boolean", "description": "Whether or not the branch is ready to serve queries" @@ -1788,6 +1879,10 @@ "cluster_rate_name": { "type": "string", "description": "The SKU representing the branch's cluster size" + }, + "safe_migrations": { + "type": "boolean", + "description": "Whether or not the branch has safe migrations enabled" } }, "additionalProperties": false, @@ -1803,7 +1898,8 @@ "production", "sharded", "html_url", - "cluster_rate_name" + "cluster_rate_name", + "safe_migrations" ] } } @@ -1819,15 +1915,15 @@ "consumes": [ "application/json" ], - "operationId": "list-backups", + "operationId": "list_backups", "summary": "List backups", "parameters": [ { - "name": "branch", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -1837,11 +1933,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" }, { "name": "page", @@ -1929,7 +2025,7 @@ "description": "The size of the backup" }, "estimated_storage_cost": { - "type": "string", + "type": "number", "description": "The estimated storage cost of the backup" }, "created_at": { @@ -2072,7 +2168,6 @@ "additionalProperties": false, "required": [ "id", - "actor", "name", "state", "size", @@ -2080,7 +2175,6 @@ "created_at", "updated_at", "required", - "backup_policy", "schema_snapshot" ] } @@ -2102,15 +2196,15 @@ "consumes": [ "application/json" ], - "operationId": "create-a-backup", + "operationId": "create_backup", "summary": "Create a backup", "parameters": [ { - "name": "branch", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -2120,11 +2214,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" }, { "name": "body", @@ -2222,7 +2316,7 @@ "description": "The size of the backup" }, "estimated_storage_cost": { - "type": "string", + "type": "number", "description": "The estimated storage cost of the backup" }, "created_at": { @@ -2365,7 +2459,6 @@ "additionalProperties": false, "required": [ "id", - "actor", "name", "state", "size", @@ -2373,7 +2466,6 @@ "created_at", "updated_at", "required", - "backup_policy", "schema_snapshot" ] } @@ -2390,36 +2482,36 @@ "consumes": [ "application/json" ], - "operationId": "get-a-backup", + "operationId": "get_backup", "summary": "Get a backup", "parameters": [ { - "name": "branch", + "name": "id", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The ID for the backup" }, { - "name": "database", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the database the branch belongs to" + "description": "The name of the organization the branch belongs to" }, { - "name": "organization", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the database the branch belongs to" }, { - "name": "id", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The ID for the backup" + "description": "The name of the branch" } ], "responses": { @@ -2488,7 +2580,7 @@ "description": "The size of the backup" }, "estimated_storage_cost": { - "type": "string", + "type": "number", "description": "The estimated storage cost of the backup" }, "created_at": { @@ -2631,7 +2723,6 @@ "additionalProperties": false, "required": [ "id", - "actor", "name", "state", "size", @@ -2639,7 +2730,6 @@ "created_at", "updated_at", "required", - "backup_policy", "schema_snapshot" ] } @@ -2647,43 +2737,57 @@ }, "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_backups` |\n| Database | `read_backups` |\n| Branch | `read_backups` |" }, - "delete": { + "patch": { "tags": [ "Backups" ], "consumes": [ "application/json" ], - "operationId": "delete-a-backup", - "summary": "Delete a backup", + "operationId": "update_backup", + "summary": "Update a backup", "parameters": [ { - "name": "branch", + "name": "id", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The ID of the backup" }, { - "name": "database", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the database the branch belongs to" + "description": "The name of the organization the branch belongs to" }, { - "name": "organization", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the database the branch belongs to" }, { - "name": "id", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The ID of the backup" + "description": "The name of the branch" + }, + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "protected": { + "type": "boolean", + "description": "Whether the backup is protected from deletion or not" + } + }, + "additionalProperties": false + } } ], "responses": { @@ -2699,38 +2803,286 @@ "500": { "description": "Internal Server Error" }, - "204": { - "description": "Delete a backup" - } - }, - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `delete_backups`, `delete_production_branch_backups` |\n| Database | `delete_backups`, `delete_production_branch_backups` |\n| Branch | `delete_backups` |" - } - }, - "/organizations/{organization}/databases/{database}/branches/{branch}/passwords": { - "get": { - "tags": [ - "Database branch passwords" - ], + "200": { + "description": "Returns the backup", + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID of the backup" + }, + "actor": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID of the actor" + }, + "display_name": { + "type": "string", + "description": "The name of the actor" + }, + "avatar_url": { + "type": "string", + "description": "The URL of the actor's avatar" + } + }, + "additionalProperties": false, + "required": [ + "id", + "display_name", + "avatar_url" + ] + }, + "name": { + "type": "string", + "description": "The name of the backup" + }, + "state": { + "type": "string", + "enum": [ + "pending", + "running", + "success", + "failed", + "canceled", + "ignored" + ], + "description": "The current state of the backup" + }, + "size": { + "type": "number", + "description": "The size of the backup" + }, + "estimated_storage_cost": { + "type": "number", + "description": "The estimated storage cost of the backup" + }, + "created_at": { + "type": "string", + "description": "When the backup was created" + }, + "updated_at": { + "type": "string", + "description": "When the backup was last updated" + }, + "required": { + "type": "boolean", + "description": "Whether or not the backup policy is required" + }, + "restored_branches": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Branches that have been restored with this backup" + }, + "backup_policy": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID of the backup policy" + }, + "name": { + "type": "string", + "description": "The name of the backup policy" + }, + "target": { + "type": "string", + "enum": [ + "production", + "development", + "branch" + ], + "description": "Whether the backup policy is for a production or development database, or for a database branch" + }, + "retention_value": { + "type": "number", + "description": "A number value for the retention period of the backup policy" + }, + "retention_unit": { + "type": "string", + "description": "The unit for the retention period of the backup policy" + }, + "frequency_value": { + "type": "number", + "description": "A number value for the frequency of the backup policy" + }, + "frequency_unit": { + "type": "string", + "description": "The unit for the frequency of the backup policy" + }, + "schedule_day": { + "type": "string", + "enum": [ + "0..6" + ], + "description": "Day of the week that the backup is scheduled" + }, + "schedule_week": { + "type": "string", + "enum": [ + "0..3" + ], + "description": "Week of the month that the backup is scheduled" + }, + "created_at": { + "type": "string", + "description": "When the backup policy was created" + }, + "updated_at": { + "type": "string", + "description": "When the backup policy was last updated" + }, + "last_ran_at": { + "type": "string", + "description": "When the backup was last run" + }, + "next_run_at": { + "type": "string", + "description": "When the backup will next run" + } + }, + "additionalProperties": false, + "required": [ + "id", + "name", + "target", + "retention_value", + "retention_unit", + "frequency_value", + "frequency_unit", + "schedule_day", + "schedule_week", + "created_at", + "updated_at", + "last_ran_at", + "next_run_at" + ] + }, + "schema_snapshot": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID of the schema snapshot" + }, + "url": { + "type": "string", + "description": "The URL to the schema snapshot in the PlanetScale app" + }, + "name": { + "type": "string", + "description": "The name of the schema snapshot" + }, + "created_at": { + "type": "string", + "description": "When the schema snapshot was created" + }, + "updated_at": { + "type": "string", + "description": "When the schema snapshot was last updated" + } + }, + "additionalProperties": false, + "required": [ + "id", + "url", + "name", + "created_at", + "updated_at" + ] + } + }, + "additionalProperties": false, + "required": [ + "id", + "name", + "state", + "size", + "estimated_storage_cost", + "created_at", + "updated_at", + "required", + "schema_snapshot" + ] + } + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `write_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `write_backups` |\n| Database | `write_backups` |\n| Branch | `write_backups` |" + }, + "delete": { + "tags": [ + "Backups" + ], "consumes": [ "application/json" ], - "operationId": "list-passwords", - "summary": "List passwords", + "operationId": "delete_backup", + "summary": "Delete a backup", "parameters": [ { - "name": "branch", + "name": "id", "type": "string", "in": "path", "required": true, - "description": "The name of the branch the password belongs to" + "description": "The ID of the backup" + }, + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization the branch belongs to" }, { "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the database the password belongs to" + "description": "The name of the database the branch belongs to" + }, + { + "name": "branch", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the branch" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" }, + "500": { + "description": "Internal Server Error" + }, + "204": { + "description": "Delete a backup" + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `delete_backups`, `delete_production_branch_backups` |\n| Database | `delete_backups`, `delete_production_branch_backups` |\n| Branch | `delete_backups` |" + } + }, + "/organizations/{organization}/databases/{database}/branches/{branch}/passwords": { + "get": { + "tags": [ + "Database branch passwords" + ], + "consumes": [ + "application/json" + ], + "operationId": "list_passwords", + "summary": "List passwords", + "parameters": [ { "name": "organization", "type": "string", @@ -2738,6 +3090,20 @@ "required": true, "description": "The name of the organization the password belongs to" }, + { + "name": "database", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the database the password belongs to" + }, + { + "name": "branch", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the branch the password belongs to" + }, { "name": "read_only_region_id", "type": "string", @@ -2887,6 +3253,10 @@ "type": "string", "description": "The username for the password" }, + "replica": { + "type": "boolean", + "description": "Whether or not the password is for a read replica" + }, "renewable": { "type": "boolean", "description": "Whether or not the password can be renewed" @@ -2933,6 +3303,7 @@ "created_at", "ttl_seconds", "access_host_url", + "replica", "renewable", "database_branch" ] @@ -2955,15 +3326,15 @@ "consumes": [ "application/json" ], - "operationId": "create-a-password", + "operationId": "create_password", "summary": "Create a password", "parameters": [ { - "name": "branch", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch the password belongs to" + "description": "The name of the organization the password belongs to" }, { "name": "database", @@ -2973,11 +3344,11 @@ "description": "The name of the database the password belongs to" }, { - "name": "organization", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the password belongs to" + "description": "The name of the branch the password belongs to" }, { "name": "body", @@ -2999,6 +3370,10 @@ ], "description": "The database role of the password (i.e. admin)" }, + "replica": { + "type": "boolean", + "description": "Whether the password is for a read replica" + }, "ttl": { "type": "number", "description": "Time to live (in seconds) for the password. The password will be invalid when TTL has passed" @@ -3134,6 +3509,10 @@ "type": "string", "description": "The username for the password" }, + "replica": { + "type": "boolean", + "description": "Whether or not the password is for a read replica" + }, "renewable": { "type": "boolean", "description": "Whether or not the password can be renewed" @@ -3184,6 +3563,7 @@ "created_at", "ttl_seconds", "access_host_url", + "replica", "renewable", "database_branch", "plain_text" @@ -3191,7 +3571,7 @@ } } }, - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `create_branch_password`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |" + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `connect_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |" } }, "/organizations/{organization}/databases/{database}/branches/{branch}/passwords/{id}": { @@ -3202,22 +3582,15 @@ "consumes": [ "application/json" ], - "operationId": "get-a-password", + "operationId": "get_password", "summary": "Get a password", "parameters": [ { - "name": "id", - "type": "string", - "in": "path", - "required": true, - "description": "The ID of the password" - }, - { - "name": "branch", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch the password belongs to" + "description": "The name of the organization the password belongs to" }, { "name": "database", @@ -3227,17 +3600,18 @@ "description": "The name of the database the password belongs to" }, { - "name": "organization", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the password belongs to" + "description": "The name of the branch the password belongs to" }, { - "name": "read_only_region_id", + "name": "id", "type": "string", - "in": "query", - "description": "A read-only region of the database branch. If present, the password results will be filtered to only those in the region" + "in": "path", + "required": true, + "description": "The ID of the password" } ], "responses": { @@ -3363,6 +3737,10 @@ "type": "string", "description": "The username for the password" }, + "replica": { + "type": "boolean", + "description": "Whether or not the password is for a read replica" + }, "renewable": { "type": "boolean", "description": "Whether or not the password can be renewed" @@ -3409,6 +3787,7 @@ "created_at", "ttl_seconds", "access_host_url", + "replica", "renewable", "database_branch" ] @@ -3424,36 +3803,36 @@ "consumes": [ "application/json" ], - "operationId": "update-a-password", + "operationId": "update_password", "summary": "Update a password", "parameters": [ { - "name": "id", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The ID of the password" + "description": "The name of the organization the password belongs to" }, { - "name": "branch", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the branch the password belongs to" + "description": "The name of the database the password belongs to" }, { - "name": "database", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The name of the database the password belongs to" + "description": "The name of the branch the password belongs to" }, { - "name": "organization", + "name": "id", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the password belongs to" + "description": "The ID of the password" }, { "name": "body", @@ -3596,6 +3975,10 @@ "type": "string", "description": "The username for the password" }, + "replica": { + "type": "boolean", + "description": "Whether or not the password is for a read replica" + }, "renewable": { "type": "boolean", "description": "Whether or not the password can be renewed" @@ -3642,13 +4025,14 @@ "created_at", "ttl_seconds", "access_host_url", + "replica", "renewable", "database_branch" ] } } }, - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `create_branch_password`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |" + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `connect_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |" }, "delete": { "tags": [ @@ -3657,36 +4041,36 @@ "consumes": [ "application/json" ], - "operationId": "delete-a-password", + "operationId": "delete_password", "summary": "Delete a password", "parameters": [ { - "name": "id", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The ID of the password" + "description": "The name of the organization the password belongs to" }, { - "name": "branch", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the branch the password belongs to" + "description": "The name of the database the password belongs to" }, { - "name": "database", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The name of the database the password belongs to" + "description": "The name of the branch the password belongs to" }, { - "name": "organization", + "name": "id", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the password belongs to" + "description": "The ID of the password" } ], "responses": { @@ -3717,50 +4101,36 @@ "consumes": [ "application/json" ], - "operationId": "renew-a-password", + "operationId": "renew_password", "summary": "Renew a password", "parameters": [ { - "name": "id", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The ID of the password" + "description": "The name of the organization the password belongs to" }, { - "name": "branch", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the branch the password belongs to" + "description": "The name of the database the password belongs to" }, { - "name": "database", + "name": "branch", "type": "string", "in": "path", "required": true, - "description": "The name of the database the password belongs to" + "description": "The name of the branch the password belongs to" }, { - "name": "organization", + "name": "id", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the password belongs to" - }, - { - "name": "body", - "in": "body", - "schema": { - "type": "object", - "properties": { - "read_only_region_id": { - "type": "string", - "description": "A read-only region of the database branch. If present, the password results will be filtered to only those in the region" - } - }, - "additionalProperties": false - } + "description": "The ID of the password" } ], "responses": { @@ -3886,6 +4256,10 @@ "type": "string", "description": "The username for the password" }, + "replica": { + "type": "boolean", + "description": "Whether or not the password is for a read replica" + }, "renewable": { "type": "boolean", "description": "Whether or not the password can be renewed" @@ -3936,6 +4310,7 @@ "created_at", "ttl_seconds", "access_host_url", + "replica", "renewable", "database_branch", "plain_text" @@ -3943,7 +4318,7 @@ } } }, - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `create_branch_password`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |" + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `connect_production_branch`, `connect_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `manage_passwords`, `manage_production_branch_passwords` |\n| Database | `manage_passwords`, `manage_production_branch_passwords` |\n| Branch | `manage_passwords` |" } }, "/organizations/{organization}/databases/{database}/branches/{name}": { @@ -3954,15 +4329,15 @@ "consumes": [ "application/json" ], - "operationId": "get-a-branch", + "operationId": "get_branch", "summary": "Get a branch", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -3972,11 +4347,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" } ], "responses": { @@ -4017,10 +4392,6 @@ "type": "string", "description": "When a user last marked a backup restore checklist as completed" }, - "access_host_url": { - "type": "string", - "description": "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`" - }, "schema_last_updated_at": { "type": "string", "description": "When the schema for the branch was last updated" @@ -4033,10 +4404,6 @@ "type": "string", "description": "The address of the MySQL provider for the branch" }, - "initial_restore_id": { - "type": "string", - "description": "The ID of the backup from which the branch was restored" - }, "ready": { "type": "boolean", "description": "Whether or not the branch is ready to serve queries" @@ -4166,6 +4533,10 @@ "cluster_rate_name": { "type": "string", "description": "The SKU representing the branch's cluster size" + }, + "safe_migrations": { + "type": "boolean", + "description": "Whether or not the branch has safe migrations enabled" } }, "additionalProperties": false, @@ -4181,7 +4552,8 @@ "production", "sharded", "html_url", - "cluster_rate_name" + "cluster_rate_name", + "safe_migrations" ] } } @@ -4195,15 +4567,15 @@ "consumes": [ "application/json" ], - "operationId": "delete-a-branch", + "operationId": "delete_branch", "summary": "Delete a branch", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -4213,11 +4585,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" } ], "responses": { @@ -4240,6 +4612,76 @@ "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `delete_branch`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `delete_branches`, `delete_production_branches` |\n| Database | `delete_branches`, `delete_production_branches` |\n| Branch | `delete_branch` |" } }, + "/organizations/{organization}/databases/{database}/branches/{name}/cluster": { + "patch": { + "tags": [ + "Database branches" + ], + "consumes": [ + "application/json" + ], + "operationId": "update_branch_cluster_config", + "summary": "Change a branch cluster configuration", + "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization the branch belongs to" + }, + { + "name": "database", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the database the branch belongs to" + }, + { + "name": "name", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the branch to configure" + }, + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "properties": { + "cluster_size": { + "type": "string", + "description": "The new size of the database cluster: PS_10, PS_20,…" + } + }, + "additionalProperties": false, + "required": [ + "cluster_size" + ] + } + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "204": { + "description": "Returns an empty response body" + } + }, + "description": "\n### Authorization\nA service token must have at least one of the following access in order to use this API endpoint:\n\n**Service Token Accesses**\n `write_database`\n\n" + } + }, "/organizations/{organization}/databases/{database}/branches/{name}/demote": { "post": { "tags": [ @@ -4248,15 +4690,15 @@ "consumes": [ "application/json" ], - "operationId": "demote-a-branch", + "operationId": "demote_branch", "summary": "Demote a branch", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -4266,11 +4708,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" } ], "responses": { @@ -4311,10 +4753,6 @@ "type": "string", "description": "When a user last marked a backup restore checklist as completed" }, - "access_host_url": { - "type": "string", - "description": "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`" - }, "schema_last_updated_at": { "type": "string", "description": "When the schema for the branch was last updated" @@ -4327,10 +4765,6 @@ "type": "string", "description": "The address of the MySQL provider for the branch" }, - "initial_restore_id": { - "type": "string", - "description": "The ID of the backup from which the branch was restored" - }, "ready": { "type": "boolean", "description": "Whether or not the branch is ready to serve queries" @@ -4460,6 +4894,10 @@ "cluster_rate_name": { "type": "string", "description": "The SKU representing the branch's cluster size" + }, + "safe_migrations": { + "type": "boolean", + "description": "Whether or not the branch has safe migrations enabled" } }, "additionalProperties": false, @@ -4475,7 +4913,8 @@ "production", "sharded", "html_url", - "cluster_rate_name" + "cluster_rate_name", + "safe_migrations" ] } } @@ -4491,15 +4930,15 @@ "consumes": [ "application/json" ], - "operationId": "promote-a-branch", + "operationId": "promote_branch", "summary": "Promote a branch", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -4509,11 +4948,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" } ], "responses": { @@ -4554,10 +4993,6 @@ "type": "string", "description": "When a user last marked a backup restore checklist as completed" }, - "access_host_url": { - "type": "string", - "description": "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`" - }, "schema_last_updated_at": { "type": "string", "description": "When the schema for the branch was last updated" @@ -4570,10 +5005,6 @@ "type": "string", "description": "The address of the MySQL provider for the branch" }, - "initial_restore_id": { - "type": "string", - "description": "The ID of the backup from which the branch was restored" - }, "ready": { "type": "boolean", "description": "Whether or not the branch is ready to serve queries" @@ -4703,6 +5134,10 @@ "cluster_rate_name": { "type": "string", "description": "The SKU representing the branch's cluster size" + }, + "safe_migrations": { + "type": "boolean", + "description": "Whether or not the branch has safe migrations enabled" } }, "additionalProperties": false, @@ -4718,7 +5153,8 @@ "production", "sharded", "html_url", - "cluster_rate_name" + "cluster_rate_name", + "safe_migrations" ] } } @@ -4734,15 +5170,15 @@ "consumes": [ "application/json" ], - "operationId": "enable-safe-migrations-for-a-branch", + "operationId": "enable_safe_migrations", "summary": "Enable safe migrations for a branch", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -4752,11 +5188,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" } ], "responses": { @@ -4797,10 +5233,6 @@ "type": "string", "description": "When a user last marked a backup restore checklist as completed" }, - "access_host_url": { - "type": "string", - "description": "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`" - }, "schema_last_updated_at": { "type": "string", "description": "When the schema for the branch was last updated" @@ -4813,10 +5245,6 @@ "type": "string", "description": "The address of the MySQL provider for the branch" }, - "initial_restore_id": { - "type": "string", - "description": "The ID of the backup from which the branch was restored" - }, "ready": { "type": "boolean", "description": "Whether or not the branch is ready to serve queries" @@ -4946,6 +5374,10 @@ "cluster_rate_name": { "type": "string", "description": "The SKU representing the branch's cluster size" + }, + "safe_migrations": { + "type": "boolean", + "description": "Whether or not the branch has safe migrations enabled" } }, "additionalProperties": false, @@ -4961,7 +5393,8 @@ "production", "sharded", "html_url", - "cluster_rate_name" + "cluster_rate_name", + "safe_migrations" ] } } @@ -4975,15 +5408,15 @@ "consumes": [ "application/json" ], - "operationId": "disable-safe-migrations-for-a-branch", + "operationId": "disable_safe_migrations", "summary": "Disable safe migrations for a branch", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -4993,11 +5426,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" } ], "responses": { @@ -5038,10 +5471,6 @@ "type": "string", "description": "When a user last marked a backup restore checklist as completed" }, - "access_host_url": { - "type": "string", - "description": "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`" - }, "schema_last_updated_at": { "type": "string", "description": "When the schema for the branch was last updated" @@ -5054,10 +5483,6 @@ "type": "string", "description": "The address of the MySQL provider for the branch" }, - "initial_restore_id": { - "type": "string", - "description": "The ID of the backup from which the branch was restored" - }, "ready": { "type": "boolean", "description": "Whether or not the branch is ready to serve queries" @@ -5187,6 +5612,10 @@ "cluster_rate_name": { "type": "string", "description": "The SKU representing the branch's cluster size" + }, + "safe_migrations": { + "type": "boolean", + "description": "Whether or not the branch has safe migrations enabled" } }, "additionalProperties": false, @@ -5202,7 +5631,8 @@ "production", "sharded", "html_url", - "cluster_rate_name" + "cluster_rate_name", + "safe_migrations" ] } } @@ -5218,15 +5648,15 @@ "consumes": [ "application/json" ], - "operationId": "get-a-branch-schema", + "operationId": "get_branch_schema", "summary": "Get a branch schema", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -5236,11 +5666,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" }, { "name": "keyspace", @@ -5312,15 +5742,15 @@ "consumes": [ "application/json" ], - "operationId": "lint-a-branch-schema", + "operationId": "lint_branch_schema", "summary": "Lint a branch schema", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the branch" + "description": "The name of the organization the branch belongs to" }, { "name": "database", @@ -5330,11 +5760,11 @@ "description": "The name of the database the branch belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the branch belongs to" + "description": "The name of the branch" }, { "name": "page", @@ -5495,25 +5925,37 @@ "consumes": [ "application/json" ], - "operationId": "get-the-deploy-queue", + "operationId": "get_deploy_queue", "summary": "Get the deploy queue", "parameters": [ { - "name": "database", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's database" + "description": "The name of the deploy request's organization" }, { - "name": "organization", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The name of the deploy request's database" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the deploy queue for a database", "schema": { @@ -5582,6 +6024,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -5629,22 +6072,22 @@ "consumes": [ "application/json" ], - "operationId": "list-deploy-requests", + "operationId": "list_deploy_requests", "summary": "List deploy requests", "parameters": [ { - "name": "database", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's database" + "description": "The name of the deploy request's organization" }, { - "name": "organization", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The name of the deploy request's database" }, { "name": "page", @@ -5680,6 +6123,18 @@ } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns a list of deploy requests for a database", "schema": { @@ -5748,6 +6203,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -5821,6 +6280,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -5864,6 +6324,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -5900,22 +6361,22 @@ "consumes": [ "application/json" ], - "operationId": "create-a-deploy-request", + "operationId": "create_deploy_request", "summary": "Create a deploy request", "parameters": [ { - "name": "database", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's database" + "description": "The name of the deploy request's organization" }, { - "name": "organization", + "name": "database", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The name of the deploy request's database" }, { "name": "body", @@ -5934,13 +6395,37 @@ "notes": { "type": "string", "description": "Notes about the deploy request" + }, + "auto_cutover": { + "type": "boolean", + "description": "Whether or not to enable auto_cutover for the deploy request. When enabled, will auto cutover to the new schema as soon as it is ready." + }, + "auto_delete_branch": { + "type": "boolean", + "description": "Whether or not to enable auto_delete_branch for the deploy request. When enabled, will delete the branch once the DR successfully completes." } }, - "additionalProperties": false + "additionalProperties": false, + "required": [ + "branch", + "into_branch" + ] } } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "201": { "description": "Returns the created deploy request", "schema": { @@ -6004,6 +6489,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -6077,6 +6566,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -6173,6 +6663,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -6208,6 +6699,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -6240,15 +6732,15 @@ "consumes": [ "application/json" ], - "operationId": "get-a-deploy-request", + "operationId": "get_deploy_request", "summary": "Get a deploy request", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -6258,14 +6750,26 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns information about a deploy request", "schema": { @@ -6329,6 +6833,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -6402,6 +6910,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -6498,6 +7007,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -6533,6 +7043,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -6563,15 +7074,15 @@ "consumes": [ "application/json" ], - "operationId": "close-a-deploy-request", + "operationId": "close_deploy_request", "summary": "Close a deploy request", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -6581,11 +7092,11 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" }, { "name": "body", @@ -6606,6 +7117,18 @@ } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the updated deploy request", "schema": { @@ -6669,6 +7192,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -6742,6 +7269,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -6838,6 +7366,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -6873,6 +7402,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -6905,15 +7435,15 @@ "consumes": [ "application/json" ], - "operationId": "complete-a-gated-deploy-request", + "operationId": "complete_gated_deploy_request", "summary": "Complete a gated deploy request", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -6923,14 +7453,26 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the deploy request whose deployment has been completed", "schema": { @@ -6994,6 +7536,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -7067,6 +7613,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -7110,6 +7657,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -7141,15 +7689,15 @@ "consumes": [ "application/json" ], - "operationId": "update-auto-apply-for-deploy-request", + "operationId": "update_auto_apply", "summary": "Update auto-apply for deploy request", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -7159,11 +7707,11 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" }, { "name": "body", @@ -7181,6 +7729,18 @@ } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the deploy request whose auto-apply setting was updated", "schema": { @@ -7244,6 +7804,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -7317,6 +7881,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -7360,6 +7925,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -7391,15 +7957,15 @@ "consumes": [ "application/json" ], - "operationId": "cancel-a-queued-deploy-request", + "operationId": "cancel_deploy_request", "summary": "Cancel a queued deploy request", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -7409,14 +7975,26 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the deploy request whose deployment was canceled", "schema": { @@ -7480,6 +8058,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -7553,6 +8135,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -7596,6 +8179,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -7627,15 +8211,15 @@ "consumes": [ "application/json" ], - "operationId": "complete-an-errored-deploy", + "operationId": "complete_errored_deploy", "summary": "Complete an errored deploy", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -7645,14 +8229,26 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the completed deploy request", "schema": { @@ -7716,6 +8312,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -7789,6 +8389,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -7832,6 +8433,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -7863,15 +8465,15 @@ "consumes": [ "application/json" ], - "operationId": "queue-a-deploy-request", + "operationId": "queue_deploy_request", "summary": "Queue a deploy request", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the organization the deploy request belongs to" }, { "name": "database", @@ -7881,14 +8483,26 @@ "description": "The name of the database the deploy request belongs to" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the deploy request belongs to" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the deployed deploy request", "schema": { @@ -7952,6 +8566,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -8025,6 +8643,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -8068,6 +8687,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -8099,15 +8719,15 @@ "consumes": [ "application/json" ], - "operationId": "get-a-deployment", + "operationId": "get_deployment", "summary": "Get a deployment", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -8117,14 +8737,26 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the deployment for a deploy request", "schema": { @@ -8188,6 +8820,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -8228,15 +8861,15 @@ "consumes": [ "application/json" ], - "operationId": "list-deploy-operations", + "operationId": "list_deploy_operations", "summary": "List deploy operations", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the organization the deploy request belongs to" }, { "name": "database", @@ -8246,11 +8879,11 @@ "description": "The name of the database the deploy request belongs to" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the deploy request belongs to" + "description": "The number of the deploy request" }, { "name": "page", @@ -8268,6 +8901,18 @@ } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns a list of deploy operations for the deploy request", "schema": { @@ -8394,15 +9039,15 @@ "consumes": [ "application/json" ], - "operationId": "complete-a-revert", + "operationId": "complete_revert", "summary": "Complete a revert", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -8412,14 +9057,26 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the deploy request that was reverted", "schema": { @@ -8483,6 +9140,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -8556,6 +9217,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -8599,6 +9261,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -8630,15 +9293,15 @@ "consumes": [ "application/json" ], - "operationId": "list-deploy-request-reviews", + "operationId": "list_deploy_request_reviews", "summary": "List deploy request reviews", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the organization the deploy request belongs to" }, { "name": "database", @@ -8648,14 +9311,26 @@ "description": "The name of the database the deploy request belongs to" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the deploy request belongs to" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns an array of deploy request reviews", "schema": { @@ -8747,15 +9422,15 @@ "consumes": [ "application/json" ], - "operationId": "review-a-deploy-request", + "operationId": "review_deploy_request", "summary": "Review a deploy request", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the organization the deploy request belongs to" }, { "name": "database", @@ -8765,11 +9440,11 @@ "description": "The name of the database the deploy request belongs to" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the deploy request belongs to" + "description": "The number of the deploy request" }, { "name": "body", @@ -8795,6 +9470,18 @@ } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "201": { "description": "Returns the created deploy request review", "schema": { @@ -8876,15 +9563,15 @@ "consumes": [ "application/json" ], - "operationId": "skip-revert-period", + "operationId": "skip_revert_period", "summary": "Skip revert period", "parameters": [ { - "name": "number", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The number of the deploy request" + "description": "The name of the deploy request's organization" }, { "name": "database", @@ -8894,14 +9581,26 @@ "description": "The name of the deploy request's database" }, { - "name": "organization", + "name": "number", "type": "string", "in": "path", "required": true, - "description": "The name of the deploy request's organization" + "description": "The number of the deploy request" } ], "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, "200": { "description": "Returns the deploy request whose deploy revert was skipped", "schema": { @@ -8965,6 +9664,10 @@ "type": "string", "description": "The name of the branch the deploy request was created from" }, + "branch_id": { + "type": "string", + "description": "The id of the branch the deploy request was created from" + }, "branch_deleted": { "type": "boolean", "description": "Whether or not the deploy request branch was deleted" @@ -9038,6 +9741,7 @@ "complete_error", "complete_pending_revert", "in_progress_revert", + "in_progress_revert_vschema", "complete_revert", "complete_revert_error", "cancelled", @@ -9081,6 +9785,7 @@ "actor", "closed_by", "branch", + "branch_id", "branch_deleted", "branch_deleted_by", "branch_deleted_at", @@ -9112,22 +9817,22 @@ "consumes": [ "application/json" ], - "operationId": "get-a-database", + "operationId": "get_database", "summary": "Get a database", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the database" + "description": "The name of the organization the database belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the database belongs to" + "description": "The name of the database" } ], "responses": { @@ -9152,10 +9857,6 @@ "type": "string", "description": "The ID of the database" }, - "type": { - "type": "string", - "description": "The object type" - }, "url": { "type": "string", "description": "The URL to the database API endpoint" @@ -9188,10 +9889,6 @@ "type": "boolean", "description": "If the database is ready to be used" }, - "at_development_branch_limit": { - "type": "boolean", - "description": "If the database has reached its development branch limit" - }, "at_backup_restore_branches_limit": { "type": "boolean", "description": "If the database has reached its backup restored branch limit" @@ -9369,7 +10066,6 @@ "additionalProperties": false, "required": [ "id", - "type", "url", "branches_url", "branches_count", @@ -9378,7 +10074,6 @@ "issues_count", "multiple_admins_required_for_deletion", "ready", - "at_development_branch_limit", "at_backup_restore_branches_limit", "region", "html_url", @@ -9401,7 +10096,7 @@ } } }, - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |\n| Database | `read_database` |" + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |\n| Database | `read_database` |" }, "patch": { "tags": [ @@ -9410,22 +10105,22 @@ "consumes": [ "application/json" ], - "operationId": "update-database-settings", + "operationId": "update_database_settings", "summary": "Update database settings", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the database" + "description": "The name of the organization the database belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the database belongs to" + "description": "The name of the database" }, { "name": "body", @@ -9496,10 +10191,6 @@ "type": "string", "description": "The ID of the database" }, - "type": { - "type": "string", - "description": "The object type" - }, "url": { "type": "string", "description": "The URL to the database API endpoint" @@ -9532,10 +10223,6 @@ "type": "boolean", "description": "If the database is ready to be used" }, - "at_development_branch_limit": { - "type": "boolean", - "description": "If the database has reached its development branch limit" - }, "at_backup_restore_branches_limit": { "type": "boolean", "description": "If the database has reached its backup restored branch limit" @@ -9713,7 +10400,6 @@ "additionalProperties": false, "required": [ "id", - "type", "url", "branches_url", "branches_count", @@ -9722,7 +10408,6 @@ "issues_count", "multiple_admins_required_for_deletion", "ready", - "at_development_branch_limit", "at_backup_restore_branches_limit", "region", "html_url", @@ -9754,22 +10439,22 @@ "consumes": [ "application/json" ], - "operationId": "delete-a-database", + "operationId": "delete_database", "summary": "Delete a database", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the database" + "description": "The name of the organization the database belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the database belongs to" + "description": "The name of the database" } ], "responses": { @@ -9800,22 +10485,22 @@ "consumes": [ "application/json" ], - "operationId": "list-read-only-regions", + "operationId": "list_read_only_regions", "summary": "List read-only regions", "parameters": [ { - "name": "name", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the database" + "description": "The name of the organization the database belongs to" }, { - "name": "organization", + "name": "name", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the database belongs to" + "description": "The name of the database" }, { "name": "page", @@ -9970,7 +10655,7 @@ } } }, - "description": "List read-only regions for the database's default branch\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |" + "description": "List read-only regions for the database's default branch\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_branches` |\n| Database | `read_branches` |" } }, "/organizations/{organization}/databases/{name}/regions": { @@ -9981,9 +10666,16 @@ "consumes": [ "application/json" ], - "operationId": "list-database-regions", + "operationId": "list_database_regions", "summary": "List database regions", "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization the database belongs to" + }, { "name": "name", "type": "string", @@ -9991,12 +10683,116 @@ "required": true, "description": "The name of the database" }, + { + "name": "page", + "type": "number", + "in": "query", + "default": 1, + "description": "If provided, specifies the page offset of returned results" + }, + { + "name": "per_page", + "type": "number", + "in": "query", + "default": 25, + "description": "If provided, specifies the number of returned results" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "200": { + "description": "Returns the available regions for a database", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID of the region" + }, + "provider": { + "type": "string", + "description": "Provider for the region (ex. AWS)" + }, + "enabled": { + "type": "boolean", + "description": "Whether or not the region is currently active" + }, + "public_ip_addresses": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Public IP addresses for the region" + }, + "display_name": { + "type": "string", + "description": "Name of the region" + }, + "location": { + "type": "string", + "description": "Location of the region" + }, + "slug": { + "type": "string", + "description": "The slug of the region" + } + }, + "additionalProperties": false, + "required": [ + "id", + "provider", + "enabled", + "public_ip_addresses", + "display_name", + "location", + "slug" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "data" + ] + } + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_schema_recommendations`, `close_schema_recommendations`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |\n| Database | `read_database` |" + } + }, + "/organizations/{organization}/invoices": { + "get": { + "tags": [ + "Invoices" + ], + "consumes": [ + "application/json" + ], + "operationId": "list_invoices", + "summary": "Get invoices", + "parameters": [ { "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the database belongs to" + "description": "The name of the organization" }, { "name": "page", @@ -10027,7 +10823,167 @@ "description": "Internal Server Error" }, "200": { - "description": "Returns the available regions for a database", + "description": "Gets the invoices for an organization", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the invoice" + }, + "total": { + "type": "number", + "description": "The total amount of the invoice" + }, + "billing_period_start": { + "type": "string", + "description": "Start of the billing period" + }, + "billing_period_end": { + "type": "string", + "description": "End of the billing period" + } + }, + "additionalProperties": false, + "required": [ + "id", + "total", + "billing_period_start", + "billing_period_end" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "data" + ] + } + } + }, + "description": "Get the invoices for an organization\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_invoices`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_invoices` |" + } + }, + "/organizations/{organization}/invoices/{id}": { + "get": { + "tags": [ + "Invoices" + ], + "consumes": [ + "application/json" + ], + "operationId": "get_invoice", + "summary": "Get an invoice", + "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization" + }, + { + "name": "id", + "type": "string", + "in": "path", + "required": true, + "description": "The ID of the invoice" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "200": { + "description": "Returns an invoice", + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the invoice" + }, + "total": { + "type": "number", + "description": "The total amount of the invoice" + }, + "billing_period_start": { + "type": "string", + "description": "Start of the billing period" + }, + "billing_period_end": { + "type": "string", + "description": "End of the billing period" + } + }, + "additionalProperties": false, + "required": [ + "id", + "total", + "billing_period_start", + "billing_period_end" + ] + } + } + }, + "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_invoices`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_invoices` |" + } + }, + "/organizations/{organization}/invoices/{id}/line-items": { + "get": { + "tags": [ + "Invoices" + ], + "consumes": [ + "application/json" + ], + "operationId": "get_invoice_line_items", + "summary": "Get invoice line items", + "parameters": [ + { + "name": "organization", + "type": "string", + "in": "path", + "required": true, + "description": "The name of the organization" + }, + { + "name": "id", + "type": "string", + "in": "path", + "required": true, + "description": "The ID of the invoice" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "200": { + "description": "Gets the line items for an invoice", "schema": { "type": "object", "properties": { @@ -10038,45 +10994,71 @@ "properties": { "id": { "type": "string", - "description": "The ID of the region" - }, - "provider": { - "type": "string", - "description": "Provider for the region (ex. AWS)" + "description": "The ID for the line item" }, - "enabled": { - "type": "boolean", - "description": "Whether or not the region is currently active" + "subtotal": { + "type": "number", + "description": "The total for the line item" }, - "public_ip_addresses": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Public IP addresses for the region" + "description": { + "type": "string", + "description": "The description for the line item" }, - "display_name": { + "metric_name": { "type": "string", - "description": "Name of the region" + "description": "The metric describes what is being billed for. Such as PS_10 or Storage." }, - "location": { + "database_id": { "type": "string", - "description": "Location of the region" + "description": "The ID for the billed database" }, - "slug": { + "database_name": { "type": "string", - "description": "The slug of the region" + "description": "The name for the billed database" + }, + "resource": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the resource" + }, + "name": { + "type": "string", + "description": "The name for the resource" + }, + "created_at": { + "type": "string", + "description": "When the resource was created" + }, + "updated_at": { + "type": "string", + "description": "When the resource was last updated" + }, + "deleted_at": { + "type": "string", + "description": "When the resource was deleted, if deleted" + } + }, + "additionalProperties": false, + "required": [ + "id", + "name", + "created_at", + "updated_at", + "deleted_at" + ] } }, "additionalProperties": false, "required": [ "id", - "provider", - "enabled", - "public_ip_addresses", - "display_name", - "location", - "slug" + "subtotal", + "description", + "metric_name", + "database_id", + "database_name", + "resource" ] } } @@ -10088,7 +11070,7 @@ } } }, - "description": "\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_database`, `delete_database`, `write_database`, `read_branch`, `delete_branch`, `create_branch`, `delete_production_branch`, `connect_branch`, `connect_production_branch`, `delete_branch_password`, `delete_production_branch_password`, `read_deploy_request`, `create_deploy_request`, `approve_deploy_request`, `read_comment`, `create_comment`, `restore_backup`, `restore_production_branch_backup`, `read_backups`, `write_backups`, `delete_backups`, `delete_production_branch_backups`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_databases` |\n| Database | `read_database` |" + "description": "Get the line items for an invoice\n### Authorization\nA service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:\n\n**Service Token Accesses**\n `read_invoices`\n\n**OAuth Scopes**\n\n | Resource | Scopes |\n| :------- | :---------- |\n| Organization | `read_invoices` |" } }, "/organizations/{organization}/oauth-applications": { @@ -10099,7 +11081,7 @@ "consumes": [ "application/json" ], - "operationId": "list-oauth-applications", + "operationId": "list_oauth_applications", "summary": "List OAuth applications", "parameters": [ { @@ -10224,22 +11206,22 @@ "consumes": [ "application/json" ], - "operationId": "get-an-oauth-application", + "operationId": "get_oauth_application", "summary": "Get an OAuth application", "parameters": [ { - "name": "application_id", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The ID of the OAuth application" + "description": "The name of the organization the OAuth application belongs to" }, { - "name": "organization", + "name": "application_id", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the OAuth application belongs to" + "description": "The ID of the OAuth application" } ], "responses": { @@ -10330,22 +11312,22 @@ "consumes": [ "application/json" ], - "operationId": "list-oauth-tokens", + "operationId": "list_oauth_tokens", "summary": "List OAuth tokens", "parameters": [ { - "name": "application_id", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The ID of the OAuth application" + "description": "The name of the organization the OAuth application belongs to" }, { - "name": "organization", + "name": "application_id", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the OAuth application belongs to" + "description": "The ID of the OAuth application" }, { "name": "page", @@ -10465,15 +11447,15 @@ "consumes": [ "application/json" ], - "operationId": "get-an-oauth-token", + "operationId": "get_oauth_token", "summary": "Get an OAuth token", "parameters": [ { - "name": "token_id", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The ID of the OAuth application token" + "description": "The name of the organization the OAuth application belongs to" }, { "name": "application_id", @@ -10483,11 +11465,11 @@ "description": "The ID of the OAuth application" }, { - "name": "organization", + "name": "token_id", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the OAuth application belongs to" + "description": "The ID of the OAuth application token" } ], "responses": { @@ -10688,15 +11670,15 @@ "consumes": [ "application/json" ], - "operationId": "delete-an-oauth-token", + "operationId": "delete_oauth_token", "summary": "Delete an OAuth token", "parameters": [ { - "name": "token_id", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The ID of the OAuth application token" + "description": "The name of the organization the OAuth application belongs to" }, { "name": "application_id", @@ -10706,11 +11688,11 @@ "description": "The ID of the OAuth application" }, { - "name": "organization", + "name": "token_id", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the OAuth application belongs to" + "description": "The ID of the OAuth application token" } ], "responses": { @@ -10741,22 +11723,22 @@ "consumes": [ "application/json" ], - "operationId": "create-or-renew-an-oauth-token", + "operationId": "create_oauth_token", "summary": "Create or renew an OAuth token", "parameters": [ { - "name": "id", + "name": "organization", "type": "string", "in": "path", "required": true, - "description": "The ID of the OAuth application" + "description": "The name of the organization the OAuth application belongs to" }, { - "name": "organization", + "name": "id", "type": "string", "in": "path", "required": true, - "description": "The name of the organization the OAuth application belongs to" + "description": "The ID of the OAuth application" }, { "name": "body", @@ -10859,6 +11841,105 @@ "description": "Create an OAuth token from an authorization grant code, or refresh an OAuth token from a refresh token\n### Authorization\nA service token must have at least one of the following access in order to use this API endpoint:\n\n**Service Token Accesses**\n `write_oauth_tokens`\n\n" } }, + "/regions": { + "get": { + "tags": [ + "Regions" + ], + "consumes": [ + "application/json" + ], + "operationId": "get_regions", + "summary": "List public regions", + "parameters": [ + { + "name": "page", + "type": "number", + "in": "query", + "default": 1, + "description": "If provided, specifies the page offset of returned results" + }, + { + "name": "per_page", + "type": "number", + "in": "query", + "default": 25, + "description": "If provided, specifies the number of returned results" + } + ], + "responses": { + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Not Found" + }, + "403": { + "description": "Forbidden" + }, + "500": { + "description": "Internal Server Error" + }, + "200": { + "description": "Returns the available public PlanetScale regions", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID of the region" + }, + "provider": { + "type": "string", + "description": "Provider for the region (ex. AWS)" + }, + "public_ip_addresses": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Public IP addresses for the region" + }, + "display_name": { + "type": "string", + "description": "Name of the region" + }, + "location": { + "type": "string", + "description": "Location of the region" + }, + "slug": { + "type": "string", + "description": "The slug of the region" + } + }, + "additionalProperties": false, + "required": [ + "id", + "provider", + "public_ip_addresses", + "display_name", + "location", + "slug" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "data" + ] + } + } + }, + "description": "Endpoint is available without authentication.\n" + } + }, "/user": { "get": { "tags": [ @@ -10867,7 +11948,7 @@ "consumes": [ "application/json" ], - "operationId": "get-current-user", + "operationId": "get_current_user", "summary": "Get current user", "parameters": [], "responses": { @@ -10920,9 +12001,38 @@ "type": "boolean", "description": "Whether or not the user has configured two factor authentication" }, - "default_organization_id": { - "type": "string", - "description": "The default organization for the user" + "default_organization": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID for the resource" + }, + "name": { + "type": "string", + "description": "The name for the resource" + }, + "created_at": { + "type": "string", + "description": "When the resource was created" + }, + "updated_at": { + "type": "string", + "description": "When the resource was last updated" + }, + "deleted_at": { + "type": "string", + "description": "When the resource was deleted, if deleted" + } + }, + "additionalProperties": false, + "required": [ + "id", + "name", + "created_at", + "updated_at", + "deleted_at" + ] }, "sso": { "type": "boolean", @@ -10941,7 +12051,10 @@ "description": "Whether or not the user is verified by email" } }, - "additionalProperties": false + "additionalProperties": false, + "required": [ + "default_organization" + ] } } }, @@ -10958,14 +12071,18 @@ "name": "Backups", "description": " API endpoints for managing database branch backups.\n" }, - { - "name": "Databases", - "description": " API endpoints for managing databases within an organization.\n" - }, { "name": "Database branch passwords", "description": " API endpoints for managing database branch passwords.\n" }, + { + "name": "Deploy requests", + "description": " API endpoints for managing database deploy requests.\n" + }, + { + "name": "Databases", + "description": " API endpoints for managing databases within an organization.\n" + }, { "name": "OAuth applications", "description": " API endpoints for fetching OAuth applications.\n" @@ -10979,12 +12096,12 @@ "description": " API endpoints for managing organizations.\n" }, { - "name": "Users", - "description": " API endpoints for fetching user information.\n" + "name": "Invoices", + "description": " API endpoints for fetching invoice information.\n" }, { - "name": "Deploy requests", - "description": " API endpoints for managing database deploy requests.\n" + "name": "Users", + "description": " API endpoints for fetching user information.\n" } ], "securityDefinitions": { diff --git a/script/update_openapi_spec b/script/update_openapi_spec index 2b081ea..bf8aacd 100755 --- a/script/update_openapi_spec +++ b/script/update_openapi_spec @@ -5,7 +5,7 @@ set -euo pipefail root=$(git rev-parse --show-toplevel) function main() { - curl -q https://api.planetscale.com/v1/openapi-spec | jq . > ${root}/openapi/openapi-spec.json + curl -q https://api.planetscale.com/v1/openapi-spec | jq . >${root}/openapi/openapi-spec.json } -main \ No newline at end of file +main From 89fa7df3b3c5a3e64cbe75780c5c59242d33da2c Mon Sep 17 00:00:00 2001 From: joe miller Date: Fri, 27 Sep 2024 17:39:42 +0000 Subject: [PATCH 02/12] update backup resource to match latest API This change introduces a breaking change to rhe `planetscale_backup` resource. This is necessary to align with the latest API changes. The `planetscale_backup` resource is a one-time resource that creates a backup of a database at a specific point in time. Any updates to the resource will result in a recreation anyway. This is not the same as a backup schedule which produces multiple backups over a period of time. Backup schedules are not yet supported in the Terraform provider. Prior to this change a `planetscale_backup` resource would be defined with retention values in the `backup_policy` hash, eg: ```hcl resource "planetscale_backup" "test" { organization = "myorg" name = "my-backup" database = "mydb" branch = "mybranch" backup_policy = { retention_unit = "d" retention_value = 7.0 } } ``` Now they must be defined like: ```hcl resource "planetscale_backup" "test" { organization = "myorg" name = "my-backup" database = "mydb" branch = "mybranch" retention_unit = "d" retention_value = 7.0 } ``` In order to prevent Terraform from deleting an existing backup and creating a new one: 1. Manually remove the existing backup from state: `terraform state rm planetscale_backup.test` 2. Update the `name` of the `planetscale_backup` to a new name. --- internal/provider/backup_resource.go | 63 +++++++++++++---- internal/provider/branch_resource.go | 44 +++++------- internal/provider/models_data_source.go | 89 ++++++++++++------------- 3 files changed, 106 insertions(+), 90 deletions(-) diff --git a/internal/provider/backup_resource.go b/internal/provider/backup_resource.go index 5f7f2cd..f717848 100644 --- a/internal/provider/backup_resource.go +++ b/internal/provider/backup_resource.go @@ -12,10 +12,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/float64planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/planetscale/terraform-provider-planetscale/internal/client/planetscale" ) @@ -47,6 +47,8 @@ type backupResourceModel struct { Id types.String `tfsdk:"id"` Required types.Bool `tfsdk:"required"` RestoredBranches types.List `tfsdk:"restored_branches"` + RetentionUnit types.String `tfsdk:"retention_unit"` + RetentionValue types.Float64 `tfsdk:"retention_value"` Size types.Float64 `tfsdk:"size"` State types.String `tfsdk:"state"` UpdatedAt types.String `tfsdk:"updated_at"` @@ -126,13 +128,27 @@ Known limitations: stringplanmodifier.RequiresReplace(), }, }, - "backup_policy": schema.SingleNestedAttribute{ - Description: "The policy used by the backup.", + "retention_unit": schema.StringAttribute{ + Description: "The unit for the retention period of the backup policy.", Required: true, - Attributes: backupPolicyResourceAttribute, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "retention_value": schema.Float64Attribute{ + Description: "A number value for the retention period of the backup policy.", + Required: true, + PlanModifiers: []planmodifier.Float64{ + float64planmodifier.RequiresReplace(), + }, }, // read only + "backup_policy": schema.SingleNestedAttribute{ + Description: "The policy used by the backup.", + Computed: true, + Attributes: backupPolicyResourceAttribute, + }, "actor": schema.SingleNestedAttribute{ Description: ".", Computed: true, @@ -146,7 +162,7 @@ Known limitations: Description: "When the backup was created.", Computed: true, }, - "estimated_storage_cost": schema.StringAttribute{ + "estimated_storage_cost": schema.Float64Attribute{ Description: "The estimated storage cost of the backup.", Computed: true, }, @@ -203,7 +219,8 @@ func (r *backupResource) Create(ctx context.Context, req resource.CreateRequest, database := data.Database branch := data.Branch name := data.Name - backupPolicy := data.BackupPolicy + retentionUnit := data.RetentionUnit + retentionValue := data.RetentionValue if org.IsNull() || org.IsUnknown() || org.ValueString() == "" { resp.Diagnostics.AddAttributeError(path.Root("organization"), "organization is required", "an organization must be provided and cannot be empty") @@ -221,20 +238,19 @@ func (r *backupResource) Create(ctx context.Context, req resource.CreateRequest, resp.Diagnostics.AddAttributeError(path.Root("name"), "name is required", "a name must be provided and cannot be empty") return } - if backupPolicy.IsNull() || backupPolicy.IsUnknown() { - resp.Diagnostics.AddAttributeError(path.Root("backup_policy"), "backup_policy is required", "a backup_policy must be provided and cannot be empty") + if retentionUnit.IsNull() || retentionUnit.IsUnknown() || retentionUnit.ValueString() == "" { + resp.Diagnostics.AddAttributeError(path.Root("retention_unit"), "retention_unit is required", "a retention_unit must be provided and cannot be empty") return } - var bp backupPolicyDataSourceModel - resp.Diagnostics.Append(backupPolicy.As(ctx, &bp, basetypes.ObjectAsOptions{})...) - if resp.Diagnostics.HasError() { + if retentionValue.IsNull() || retentionValue.IsUnknown() || retentionValue.ValueFloat64() == 0 { + resp.Diagnostics.AddAttributeError(path.Root("retention_value"), "retention_value is required", "a retention_value must be provided and cannot be empty") return } createReq := planetscale.CreateBackupReq{ Name: name.ValueStringPointer(), - RetentionUnit: bp.RetentionUnit.ValueStringPointer(), - RetentionValue: bp.RetentionValue.ValueFloat64Pointer(), + RetentionUnit: retentionUnit.ValueStringPointer(), + RetentionValue: retentionValue.ValueFloat64Pointer(), } res, err := r.client.CreateBackup(ctx, org.ValueString(), database.ValueString(), branch.ValueString(), createReq) if err != nil { @@ -250,6 +266,9 @@ func (r *backupResource) Create(ctx context.Context, req resource.CreateRequest, if resp.Diagnostics.HasError() { return } + + data.RetentionUnit = retentionUnit + data.RetentionValue = retentionValue resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } @@ -267,6 +286,8 @@ func (r *backupResource) Read(ctx context.Context, req resource.ReadRequest, res database := data.Database branch := data.Branch id := data.Id + retentionUnit := data.RetentionUnit + retentionValue := data.RetentionValue if org.IsNull() || org.IsUnknown() || org.ValueString() == "" { resp.Diagnostics.AddAttributeError(path.Root("organization"), "organization is required", "an organization must be provided and cannot be empty") @@ -284,6 +305,14 @@ func (r *backupResource) Read(ctx context.Context, req resource.ReadRequest, res resp.Diagnostics.AddAttributeError(path.Root("id"), "id is required", "an ID must be provided and cannot be empty") return } + if retentionUnit.IsNull() || retentionUnit.IsUnknown() || retentionUnit.ValueString() == "" { + resp.Diagnostics.AddAttributeError(path.Root("retention_unit"), "retention_unit is required", "a retention_unit must be provided and cannot be empty") + return + } + if retentionValue.IsNull() || retentionValue.IsUnknown() || retentionValue.ValueFloat64() == 0 { + resp.Diagnostics.AddAttributeError(path.Root("retention_value"), "retention_value is required", "a retention_value must be provided and cannot be empty") + return + } res, err := r.client.GetBackup(ctx, org.ValueString(), database.ValueString(), branch.ValueString(), id.ValueString()) if err != nil { @@ -300,11 +329,17 @@ func (r *backupResource) Read(ctx context.Context, req resource.ReadRequest, res if resp.Diagnostics.HasError() { return } + + // add the retention unit and value to the data model from existing state + // since it is not returned by the API. + data.RetentionUnit = retentionUnit + data.RetentionValue = retentionValue + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } func (r *backupResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - // nothing to do, backups have no updatable settings + // TODO: backups have one updatable field: protected (bool). https://api-docs.planetscale.com/reference/update_backup } func (r *backupResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { diff --git a/internal/provider/branch_resource.go b/internal/provider/branch_resource.go index 09312f8..66fed8d 100644 --- a/internal/provider/branch_resource.go +++ b/internal/provider/branch_resource.go @@ -41,15 +41,13 @@ type branchResourceModel struct { Organization types.String `tfsdk:"organization"` Database types.String `tfsdk:"database"` - Name types.String `tfsdk:"name"` - ParentBranch types.String `tfsdk:"parent_branch"` - // AccessHostUrl types.String `tfsdk:"access_host_url"` - Actor types.Object `tfsdk:"actor"` - ClusterRateName types.String `tfsdk:"cluster_rate_name"` - CreatedAt types.String `tfsdk:"created_at"` - HtmlUrl types.String `tfsdk:"html_url"` - Id types.String `tfsdk:"id"` - // InitialRestoreId types.String `tfsdk:"initial_restore_id"` + Name types.String `tfsdk:"name"` + ParentBranch types.String `tfsdk:"parent_branch"` + Actor types.Object `tfsdk:"actor"` + ClusterRateName types.String `tfsdk:"cluster_rate_name"` + CreatedAt types.String `tfsdk:"created_at"` + HtmlUrl types.String `tfsdk:"html_url"` + Id types.String `tfsdk:"id"` MysqlAddress types.String `tfsdk:"mysql_address"` MysqlEdgeAddress types.String `tfsdk:"mysql_edge_address"` Region types.Object `tfsdk:"region"` @@ -77,17 +75,15 @@ func branchResourceFromClient(ctx context.Context, branch *planetscale.Branch, o Organization: organization, Database: database, - Actor: actor, - Region: region, - RestoredFromBranch: restoredFromBranch, - Name: types.StringValue(branch.Name), - ParentBranch: types.StringPointerValue(branch.ParentBranch), - // AccessHostUrl: types.StringPointerValue(branch.AccessHostUrl), - ClusterRateName: types.StringValue(branch.ClusterRateName), - CreatedAt: types.StringValue(branch.CreatedAt), - HtmlUrl: types.StringValue(branch.HtmlUrl), - Id: types.StringValue(branch.Id), - // InitialRestoreId: types.StringPointerValue(branch.InitialRestoreId), + Actor: actor, + Region: region, + RestoredFromBranch: restoredFromBranch, + Name: types.StringValue(branch.Name), + ParentBranch: types.StringPointerValue(branch.ParentBranch), + ClusterRateName: types.StringValue(branch.ClusterRateName), + CreatedAt: types.StringValue(branch.CreatedAt), + HtmlUrl: types.StringValue(branch.HtmlUrl), + Id: types.StringValue(branch.Id), MysqlAddress: types.StringValue(branch.MysqlAddress), MysqlEdgeAddress: types.StringValue(branch.MysqlEdgeAddress), Production: types.BoolValue(branch.Production), @@ -149,10 +145,6 @@ func (r *branchResource) Schema(ctx context.Context, req resource.SchemaRequest, Description: "The ID of the branch.", Computed: true, }, - "access_host_url": schema.StringAttribute{ - Description: "The access host URL for the branch. This is a legacy field, use `mysql_edge_address`.", - Computed: true, - }, "actor": schema.SingleNestedAttribute{ Description: "The actor who created this branch.", Computed: true, @@ -170,10 +162,6 @@ func (r *branchResource) Schema(ctx context.Context, req resource.SchemaRequest, Description: "Planetscale app URL for the branch.", Computed: true, }, - "initial_restore_id": schema.StringAttribute{ - Description: "The ID of the backup from which the branch was restored.", - Computed: true, - }, "mysql_address": schema.StringAttribute{ Description: "The MySQL address for the branch.", Computed: true, diff --git a/internal/provider/models_data_source.go b/internal/provider/models_data_source.go index 3f65189..6452662 100644 --- a/internal/provider/models_data_source.go +++ b/internal/provider/models_data_source.go @@ -123,14 +123,11 @@ func organizationFromClient(org *planetscale.Organization) *organizationDataSour return nil } return &organizationDataSourceModel{ - Features: featuresFromClient(org.Features), - Flags: flagsFromClient(org.Flags), - // AdminOnlyProductionAccess: types.BoolValue(org.AdminOnlyProductionAccess), - BillingEmail: types.StringPointerValue(org.BillingEmail), - // CanCreateDatabases: types.BoolValue(org.CanCreateDatabases), - CreatedAt: types.StringValue(org.CreatedAt), - DatabaseCount: types.Float64Value(org.DatabaseCount), - // FreeDatabasesRemaining: types.Float64Value(org.FreeDatabasesRemaining), + Features: featuresFromClient(org.Features), + Flags: flagsFromClient(org.Flags), + BillingEmail: types.StringPointerValue(org.BillingEmail), + CreatedAt: types.StringValue(org.CreatedAt), + DatabaseCount: types.Float64Value(org.DatabaseCount), HasPastDueInvoices: types.BoolValue(org.HasPastDueInvoices), Id: types.StringValue(org.Id), Name: types.StringValue(org.Name), @@ -441,12 +438,11 @@ func databaseFromClient(database *planetscale.Database, orgName string, diags di return nil } return &databaseDataSourceModel{ - Organization: orgName, - DataImport: dataImportFromClient(database.DataImport), - Region: regionFromClient(&database.Region, diags), - AllowDataBranching: types.BoolValue(database.AllowDataBranching), - AtBackupRestoreBranchesLimit: types.BoolValue(database.AtBackupRestoreBranchesLimit), - // AtDevelopmentBranchLimit: types.BoolValue(database.AtDevelopmentBranchLimit), + Organization: orgName, + DataImport: dataImportFromClient(database.DataImport), + Region: regionFromClient(&database.Region, diags), + AllowDataBranching: types.BoolValue(database.AllowDataBranching), + AtBackupRestoreBranchesLimit: types.BoolValue(database.AtBackupRestoreBranchesLimit), AutomaticMigrations: types.BoolPointerValue(database.AutomaticMigrations), BranchesCount: types.Float64Value(database.BranchesCount), BranchesUrl: types.StringValue(database.BranchesUrl), @@ -577,16 +573,15 @@ func branchDataSourceSchemaAttribute(computedName bool) map[string]schema.Attrib } type branchDataSourceModel struct { - Organization types.String `tfsdk:"organization"` - Database types.String `tfsdk:"database"` - Name types.String `tfsdk:"name"` - AccessHostUrl types.String `tfsdk:"access_host_url"` - Actor *actorDataSourceModel `tfsdk:"actor"` - ClusterRateName types.String `tfsdk:"cluster_rate_name"` - CreatedAt types.String `tfsdk:"created_at"` - HtmlUrl types.String `tfsdk:"html_url"` - Id types.String `tfsdk:"id"` - // InitialRestoreId types.String `tfsdk:"initial_restore_id"` + Organization types.String `tfsdk:"organization"` + Database types.String `tfsdk:"database"` + Name types.String `tfsdk:"name"` + AccessHostUrl types.String `tfsdk:"access_host_url"` + Actor *actorDataSourceModel `tfsdk:"actor"` + ClusterRateName types.String `tfsdk:"cluster_rate_name"` + CreatedAt types.String `tfsdk:"created_at"` + HtmlUrl types.String `tfsdk:"html_url"` + Id types.String `tfsdk:"id"` MysqlAddress types.String `tfsdk:"mysql_address"` MysqlEdgeAddress types.String `tfsdk:"mysql_edge_address"` ParentBranch types.String `tfsdk:"parent_branch"` @@ -606,18 +601,16 @@ func branchFromClient(branch *planetscale.Branch, organization, database string, return nil } return &branchDataSourceModel{ - Organization: types.StringValue(organization), - Database: types.StringValue(database), - Actor: actorFromClient(branch.Actor), - Region: regionFromClient(branch.Region, diags), - RestoredFromBranch: restoredFromBranchFromClient(branch.RestoredFromBranch), - Name: types.StringValue(branch.Name), - // AccessHostUrl: types.StringPointerValue(branch.AccessHostUrl), - ClusterRateName: types.StringValue(branch.ClusterRateName), - CreatedAt: types.StringValue(branch.CreatedAt), - HtmlUrl: types.StringValue(branch.HtmlUrl), - Id: types.StringValue(branch.Id), - // InitialRestoreId: types.StringPointerValue(branch.InitialRestoreId), + Organization: types.StringValue(organization), + Database: types.StringValue(database), + Actor: actorFromClient(branch.Actor), + Region: regionFromClient(branch.Region, diags), + RestoredFromBranch: restoredFromBranchFromClient(branch.RestoredFromBranch), + Name: types.StringValue(branch.Name), + ClusterRateName: types.StringValue(branch.ClusterRateName), + CreatedAt: types.StringValue(branch.CreatedAt), + HtmlUrl: types.StringValue(branch.HtmlUrl), + Id: types.StringValue(branch.Id), MysqlAddress: types.StringValue(branch.MysqlAddress), MysqlEdgeAddress: types.StringValue(branch.MysqlEdgeAddress), ParentBranch: types.StringPointerValue(branch.ParentBranch), @@ -1348,7 +1341,7 @@ func backupDataSourceSchemaAttribute(computedID bool) map[string]schema.Attribut Description: "When the backup was created.", Computed: true, }, - "estimated_storage_cost": schema.StringAttribute{ + "estimated_storage_cost": schema.Float64Attribute{ Description: "The estimated storage cost of the backup.", Computed: true, }, @@ -1376,12 +1369,12 @@ func backupDataSourceSchemaAttribute(computedID bool) map[string]schema.Attribut } type backupDataSourceModel struct { - Organization types.String `tfsdk:"organization"` - Database types.String `tfsdk:"database"` - Branch types.String `tfsdk:"branch"` - Name types.String `tfsdk:"name"` - Id types.String `tfsdk:"id"` - // Actor *actorDataSourceModel `tfsdk:"actor"` + Organization types.String `tfsdk:"organization"` + Database types.String `tfsdk:"database"` + Branch types.String `tfsdk:"branch"` + Name types.String `tfsdk:"name"` + Id types.String `tfsdk:"id"` + Actor *actorDataSourceModel `tfsdk:"actor"` BackupPolicy *backupPolicyDataSourceModel `tfsdk:"backup_policy"` CreatedAt types.String `tfsdk:"created_at"` EstimatedStorageCost types.Float64 `tfsdk:"estimated_storage_cost"` @@ -1401,11 +1394,11 @@ func backupFromClient(backup *planetscale.Backup, organization, database, branch restoredBranches = stringsToListValue(*backup.RestoredBranches, diags) } return &backupDataSourceModel{ - Organization: types.StringValue(organization), - Database: types.StringValue(database), - Branch: types.StringValue(branch), - Name: types.StringValue(backup.Name), - // Actor: actorFromClient(&backup.Actor), + Organization: types.StringValue(organization), + Database: types.StringValue(database), + Branch: types.StringValue(branch), + Name: types.StringValue(backup.Name), + Actor: actorFromClient(backup.Actor), BackupPolicy: backupPolicyFromClient(backup.BackupPolicy), CreatedAt: types.StringValue(backup.CreatedAt), EstimatedStorageCost: types.Float64Value(backup.EstimatedStorageCost), From 290b508812b5c99e3137e783817979b5ff3a3fb8 Mon Sep 17 00:00:00 2001 From: joe miller Date: Fri, 27 Sep 2024 17:49:09 +0000 Subject: [PATCH 03/12] cleanup debug --- internal/cmd/client_codegen/jenny.go | 2 -- internal/cmd/client_codegen/main.go | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/internal/cmd/client_codegen/jenny.go b/internal/cmd/client_codegen/jenny.go index 667ce79..0750d25 100644 --- a/internal/cmd/client_codegen/jenny.go +++ b/internal/cmd/client_codegen/jenny.go @@ -239,12 +239,10 @@ func genClientCall( args := []jen.Code{jen.Id("ctx").Qual("context", "Context")} path = strings.TrimPrefix(path, "/") - // log.Printf("JOE: %s %s", verb, path) pathBuilderArg, pathArgs := pathInterpolator(path, pathArgs) for _, pathArg := range pathArgs { argName := lowerSnakeToCamel(pathArg.Name) - // log.Printf("JOE: %s %s", pathArg.Name, argName) argF := jen.Id(argName) switch pathArg.Type { diff --git a/internal/cmd/client_codegen/main.go b/internal/cmd/client_codegen/main.go index c99ffbd..f5a16fa 100644 --- a/internal/cmd/client_codegen/main.go +++ b/internal/cmd/client_codegen/main.go @@ -3,7 +3,6 @@ package main import ( "flag" "fmt" - "log" "os" "sort" "strconv" @@ -119,7 +118,6 @@ func handleVerbPath(ll *slog.Logger, defns spec.Definitions, f *jen.File, path, var reqBodyStructName string if reqBody != nil { - // reqBodyStructName = kebabToCamel(removeFillerWords(operation.ID)) + "Req" reqBodyStructName = snakeToCamel(removeFillerWords(operation.ID)) + "Req" if err := genParamStruct(defns, f, reqBodyStructName, reqBody.Schema); err != nil { return fmt.Errorf("generating call param struct: %w", err) @@ -136,15 +134,11 @@ func handleVerbPath(ll *slog.Logger, defns spec.Definitions, f *jen.File, path, } } for _, code := range resCodes { - // resBodyStructName := kebabToCamel(removeFillerWords(operation.ID)) + "Res" + strconv.Itoa(code) resBodyStructName := snakeToCamel(removeFillerWords(operation.ID)) + "Res" + strconv.Itoa(code) - log.Printf("JOE: resBodyStructName: %s\n", resBodyStructName) res := operation.Responses.StatusCodeResponses[code] if code < 400 { if successResponseTypes == 1 { - // resBodyStructName = kebabToCamel(removeFillerWords(operation.ID)) + "Res" resBodyStructName = snakeToCamel(removeFillerWords(operation.ID)) + "Res" - log.Printf("JOE: resBodyStructName-2: %s\n", resBodyStructName) } respSchema := res.ResponseProps.Schema @@ -170,8 +164,6 @@ func handleVerbPath(ll *slog.Logger, defns spec.Definitions, f *jen.File, path, responses[code] = resBodyStructName } - // clientCallFuncName := kebabToCamel(removeFillerWords(operation.ID)) - log.Printf("JOE: clientcall: %s", snakeToCamel(removeFillerWords(operation.ID))) clientCallFuncName := snakeToCamel(removeFillerWords(operation.ID)) if err := genClientCall(f, path, verb, clientCallFuncName, pathParams, queryParams, reqBodyStructName, responses); err != nil { return fmt.Errorf("generating client call method: %w", err) @@ -185,7 +177,6 @@ func removeFillerWords(name string) string { name = strings.ReplaceAll(name, "patch", "update") name = strings.ReplaceAll(name, "-an-", "-") name = strings.ReplaceAll(name, "-a-", "-") - log.Printf("JOE: removeFillerWords(%q) = %q", orig, name) return name } @@ -194,7 +185,6 @@ func kebabToCamel(kebab string) string { for _, w := range strings.Split(kebab, "-") { out.WriteString(cases.Title(language.AmericanEnglish).String(w)) } - log.Printf("JOE: kebabToCamel(%q) = %q", kebab, out.String()) return out.String() } @@ -203,12 +193,10 @@ func snakeToCamel(snake string) string { for _, w := range strings.Split(snake, "_") { out.WriteString(cases.Title(language.AmericanEnglish).String(w)) } - log.Printf("JOE: snakeToCamel(%q) = %q", snake, out.String()) return out.String() } func lowerSnakeToCamel(snake string) string { - // log.Printf("JOE: lowerSnakeToCamel(%q)", snake) var out strings.Builder for i, w := range strings.Split(snake, "_") { if i == 0 { @@ -217,7 +205,6 @@ func lowerSnakeToCamel(snake string) string { out.WriteString(cases.Title(language.AmericanEnglish).String(w)) } } - log.Printf("JOE: lowerSnakeToCamel(%q) = %q", snake, out.String()) return out.String() } From 2a870a1a8d78483214edd282ccf0124332fd2a52 Mon Sep 17 00:00:00 2001 From: joe miller Date: Sat, 5 Oct 2024 17:44:20 +0000 Subject: [PATCH 04/12] update resource schema to match latest api --- internal/provider/database_resource.go | 17 +++---- internal/provider/password_data_source.go | 1 - internal/provider/password_resource.go | 1 - internal/provider/user_data_source.go | 56 ++++++++++++++++------- 4 files changed, 46 insertions(+), 29 deletions(-) diff --git a/internal/provider/database_resource.go b/internal/provider/database_resource.go index 17cbf1b..5b88b6e 100644 --- a/internal/provider/database_resource.go +++ b/internal/provider/database_resource.go @@ -84,12 +84,11 @@ func databaseResourcefromClient(ctx context.Context, database *planetscale.Datab dataImport, diags := types.ObjectValueFrom(ctx, importResourceAttrTypes, database.DataImport) diags.Append(diags...) return &databaseResourceModel{ - Organization: organization, - DataImport: dataImport, - Id: types.StringValue(database.Id), - AllowDataBranching: types.BoolValue(database.AllowDataBranching), - AtBackupRestoreBranchesLimit: types.BoolValue(database.AtBackupRestoreBranchesLimit), - // AtDevelopmentBranchLimit: types.BoolValue(database.AtDevelopmentBranchLimit), + Organization: organization, + DataImport: dataImport, + Id: types.StringValue(database.Id), + AllowDataBranching: types.BoolValue(database.AllowDataBranching), + AtBackupRestoreBranchesLimit: types.BoolValue(database.AtBackupRestoreBranchesLimit), AtDevelopmentBranchLimit: types.BoolValue(false), // at_development_branch_limit removed from API, hardcode to false going forward AutomaticMigrations: types.BoolPointerValue(database.AutomaticMigrations), BranchesCount: types.Float64Value(database.BranchesCount), @@ -364,11 +363,9 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques } createDbReq := planetscale.CreateDatabaseReq{ - Name: name.ValueString(), - // Plan: stringValueIfKnown(data.Plan), + Name: name.ValueString(), ClusterSize: data.ClusterSize.ValueString(), - // ClusterSize: float64ValueIfKnown(data.ClusterSize), - Region: stringValueIfKnown(data.Region), + Region: stringValueIfKnown(data.Region), } res, err := r.client.CreateDatabase(ctx, org.ValueString(), createDbReq) if err != nil { diff --git a/internal/provider/password_data_source.go b/internal/provider/password_data_source.go index 09ec2d6..04ba2f7 100644 --- a/internal/provider/password_data_source.go +++ b/internal/provider/password_data_source.go @@ -61,7 +61,6 @@ func (d *passwordDataSource) Read(ctx context.Context, req datasource.ReadReques data.Database.ValueString(), data.Branch.ValueString(), data.Id.ValueString(), - // data.ReadOnlyRegionId.ValueStringPointer(), ) if err != nil { resp.Diagnostics.AddError("Unable to read database password", err.Error()) diff --git a/internal/provider/password_resource.go b/internal/provider/password_resource.go index 3847e1d..5027e7f 100644 --- a/internal/provider/password_resource.go +++ b/internal/provider/password_resource.go @@ -356,7 +356,6 @@ func (r *passwordResource) Read(ctx context.Context, req resource.ReadRequest, r database.ValueString(), branch.ValueString(), id.ValueString(), - // nil, // not sure why this would need a region id ) if err != nil { if notFoundErr, ok := err.(*planetscale.GetPasswordRes404); ok { diff --git a/internal/provider/user_data_source.go b/internal/provider/user_data_source.go index 7c02ee8..d0fc5a6 100644 --- a/internal/provider/user_data_source.go +++ b/internal/provider/user_data_source.go @@ -23,19 +23,19 @@ type userDataSource struct { } type userDataSourceModel struct { - Id *string `tfsdk:"id"` - Name *string `tfsdk:"name"` - AvatarUrl *string `tfsdk:"avatar_url"` - CreatedAt *string `tfsdk:"created_at"` - DefaultOrganizationId *string `tfsdk:"default_organization_id"` - DirectoryManaged *bool `tfsdk:"directory_managed"` - DisplayName *string `tfsdk:"display_name"` - Email *string `tfsdk:"email"` - EmailVerified *bool `tfsdk:"email_verified"` - Managed *bool `tfsdk:"managed"` - Sso *bool `tfsdk:"sso"` - TwoFactorAuthConfigured *bool `tfsdk:"two_factor_auth_configured"` - UpdatedAt *string `tfsdk:"updated_at"` + Id *string `tfsdk:"id"` + Name *string `tfsdk:"name"` + AvatarUrl *string `tfsdk:"avatar_url"` + CreatedAt *string `tfsdk:"created_at"` + DefaultOrganization *planetscale.User_DefaultOrganization `tfsdk:"default_organization"` + DirectoryManaged *bool `tfsdk:"directory_managed"` + DisplayName *string `tfsdk:"display_name"` + Email *string `tfsdk:"email"` + EmailVerified *bool `tfsdk:"email_verified"` + Managed *bool `tfsdk:"managed"` + Sso *bool `tfsdk:"sso"` + TwoFactorAuthConfigured *bool `tfsdk:"two_factor_auth_configured"` + UpdatedAt *string `tfsdk:"updated_at"` } func (d *userDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { @@ -66,9 +66,31 @@ Known limitations: Description: "When the user was created.", Computed: true, }, - "default_organization_id": schema.StringAttribute{ + "default_organization": schema.SingleNestedAttribute{ Description: "The default organization for the user.", Computed: true, + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Description: "The ID of the organization.", + Computed: true, + }, + "name": schema.StringAttribute{ + Description: "The name of the organization.", + Computed: true, + }, + "created_at": schema.StringAttribute{ + Description: "When the organization was created.", + Computed: true, + }, + "updated_at": schema.StringAttribute{ + Description: "When the organization was last updated.", + Computed: true, + }, + "deleted_at": schema.StringAttribute{ + Description: "When the organization was last deleted.", + Computed: true, + }, + }, }, "directory_managed": schema.BoolAttribute{ Description: "Whether or not the user is managed by a WorkOS directory.", @@ -137,10 +159,10 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r return } state := userDataSourceModel{ - AvatarUrl: res200.AvatarUrl, - CreatedAt: res200.CreatedAt, - // DefaultOrganizationId: res200.DefaultOrganizationId, + AvatarUrl: res200.AvatarUrl, + CreatedAt: res200.CreatedAt, DirectoryManaged: res200.DirectoryManaged, + DefaultOrganization: &res200.DefaultOrganization, DisplayName: res200.DisplayName, Email: res200.Email, EmailVerified: res200.EmailVerified, From c305e99bcaead8cd72b892b303898d20bbf604a4 Mon Sep 17 00:00:00 2001 From: joe miller Date: Sat, 5 Oct 2024 17:47:58 +0000 Subject: [PATCH 05/12] make: update generate task to use scripts --- GNUmakefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index a5d7b22..46ea9e8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -12,7 +12,4 @@ testacc: .PHONY: generate generate: bash ./script/update_openapi_spec - bash ./script/generate - # curl https://api.planetscale.com/v1/openapi-spec >./openapi/openapi-spec.json - # cd ./internal/cmd/extractref && go run . >../../../openapi-spec.json - # cd ./internal/cmd/client_codegen && go run . >../../client/planetscale/planetscale.go \ No newline at end of file + bash ./script/generate \ No newline at end of file From eefa54d565843abfb4e83acba568b374e1f92b7a Mon Sep 17 00:00:00 2001 From: joe miller Date: Sat, 5 Oct 2024 17:59:24 +0000 Subject: [PATCH 06/12] linter fixups --- internal/cmd/client_codegen/main.go | 8 -------- internal/provider/provider.go | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/internal/cmd/client_codegen/main.go b/internal/cmd/client_codegen/main.go index f5a16fa..809d381 100644 --- a/internal/cmd/client_codegen/main.go +++ b/internal/cmd/client_codegen/main.go @@ -180,14 +180,6 @@ func removeFillerWords(name string) string { return name } -func kebabToCamel(kebab string) string { - var out strings.Builder - for _, w := range strings.Split(kebab, "-") { - out.WriteString(cases.Title(language.AmericanEnglish).String(w)) - } - return out.String() -} - func snakeToCamel(snake string) string { var out strings.Builder for _, w := range strings.Split(snake, "_") { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 466c585..0c5f083 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -266,6 +266,7 @@ func stringValueIfKnown(v basetypes.StringValue) *string { return v.ValueStringPointer() } +//nolint:unused func float64ValueIfKnown(v basetypes.Float64Value) *float64 { if v.IsUnknown() || v.IsNull() { return nil From 643d59fbc9b257080732b45494ad2eccd0c3ed48 Mon Sep 17 00:00:00 2001 From: joe miller Date: Sat, 5 Oct 2024 18:26:33 +0000 Subject: [PATCH 07/12] add tests for planetscale_user data source --- internal/provider/user_data_source_test.go | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 internal/provider/user_data_source_test.go diff --git a/internal/provider/user_data_source_test.go b/internal/provider/user_data_source_test.go new file mode 100644 index 0000000..b226dbd --- /dev/null +++ b/internal/provider/user_data_source_test.go @@ -0,0 +1,44 @@ +package provider + +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccUserDataSource(t *testing.T) { + if os.Getenv("PLANETSCALE_ACCESS_TOKEN") == "" { + t.Skip("PLANETSCALE_ACCESS_TOKEN is required for planetscale_user data source tests.") + } + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Read testing + { + Config: testAccUserDataSourceConfig, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "id"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "name"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "avatar_url"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "created_at"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "default_organization.%"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "directory_managed"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "display_name"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "email"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "email_verified"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "managed"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "sso"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "two_factor_auth_configured"), + resource.TestCheckResourceAttrSet("data.planetscale_user.current", "updated_at"), + ), + }, + }, + }) +} + +const testAccUserDataSourceConfig = ` +data "planetscale_user" "current" {} +` From 1004d1c11214856154a4e3f9785cc958ca7a29d9 Mon Sep 17 00:00:00 2001 From: joe miller Date: Sat, 5 Oct 2024 18:32:08 +0000 Subject: [PATCH 08/12] regenerate docs --- GNUmakefile | 3 ++- docs/data-sources/backup.md | 2 +- docs/data-sources/backups.md | 2 +- docs/data-sources/user.md | 13 ++++++++++++- docs/resources/backup.md | 26 ++++++++++++++------------ docs/resources/branch.md | 2 -- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 46ea9e8..3a28c52 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -12,4 +12,5 @@ testacc: .PHONY: generate generate: bash ./script/update_openapi_spec - bash ./script/generate \ No newline at end of file + bash ./script/generate + go gnenerate ./... \ No newline at end of file diff --git a/docs/data-sources/backup.md b/docs/data-sources/backup.md index c892c01..23bf28b 100644 --- a/docs/data-sources/backup.md +++ b/docs/data-sources/backup.md @@ -40,7 +40,7 @@ output "backup" { - `actor` (Attributes) The actor that created the backup. (see [below for nested schema](#nestedatt--actor)) - `backup_policy` (Attributes) The backup policy being followed. (see [below for nested schema](#nestedatt--backup_policy)) - `created_at` (String) When the backup was created. -- `estimated_storage_cost` (String) The estimated storage cost of the backup. +- `estimated_storage_cost` (Number) The estimated storage cost of the backup. - `name` (String) The name of the backup. - `required` (Boolean) Whether or not the backup policy is required. - `restored_branches` (List of String) Branches that have been restored with this backup. diff --git a/docs/data-sources/backups.md b/docs/data-sources/backups.md index 87227ae..f670acf 100644 --- a/docs/data-sources/backups.md +++ b/docs/data-sources/backups.md @@ -47,7 +47,7 @@ Read-Only: - `branch` (String) The branch this backup belongs to. - `created_at` (String) When the backup was created. - `database` (String) The database this backup belongs to. -- `estimated_storage_cost` (String) The estimated storage cost of the backup. +- `estimated_storage_cost` (Number) The estimated storage cost of the backup. - `id` (String) The ID of the backup. - `name` (String) The name of the backup. - `organization` (String) The organization this backup belongs to. diff --git a/docs/data-sources/user.md b/docs/data-sources/user.md index 9e4487e..e9d31d5 100644 --- a/docs/data-sources/user.md +++ b/docs/data-sources/user.md @@ -34,7 +34,7 @@ output "current_user" { - `avatar_url` (String) The URL source of the user's avatar. - `created_at` (String) When the user was created. -- `default_organization_id` (String) The default organization for the user. +- `default_organization` (Attributes) The default organization for the user. (see [below for nested schema](#nestedatt--default_organization)) - `directory_managed` (Boolean) Whether or not the user is managed by a WorkOS directory. - `display_name` (String) The display name of the user. - `email` (String) The email of the user. @@ -45,3 +45,14 @@ output "current_user" { - `sso` (Boolean) Whether or not the user is managed by WorkOS. - `two_factor_auth_configured` (Boolean) Whether or not the user has configured two factor authentication. - `updated_at` (String) When the user was last updated. + + +### Nested Schema for `default_organization` + +Read-Only: + +- `created_at` (String) When the organization was created. +- `deleted_at` (String) When the organization was last deleted. +- `id` (String) The ID of the organization. +- `name` (String) The name of the organization. +- `updated_at` (String) When the organization was last updated. diff --git a/docs/resources/backup.md b/docs/resources/backup.md index 025e44a..4692bbb 100644 --- a/docs/resources/backup.md +++ b/docs/resources/backup.md @@ -35,17 +35,19 @@ resource "planetscale_backup" "example" { ### Required -- `backup_policy` (Attributes) The policy used by the backup. (see [below for nested schema](#nestedatt--backup_policy)) - `branch` (String) The branch being backed up. - `database` (String) The database to which the branch being backed up belongs to. - `name` (String) The name of the backup. - `organization` (String) The organization in which the database branch being backed up belongs to. +- `retention_unit` (String) The unit for the retention period of the backup policy. +- `retention_value` (Number) A number value for the retention period of the backup policy. ### Read-Only - `actor` (Attributes) . (see [below for nested schema](#nestedatt--actor)) +- `backup_policy` (Attributes) The policy used by the backup. (see [below for nested schema](#nestedatt--backup_policy)) - `created_at` (String) When the backup was created. -- `estimated_storage_cost` (String) The estimated storage cost of the backup. +- `estimated_storage_cost` (Number) The estimated storage cost of the backup. - `id` (String) The ID of the backup. - `required` (Boolean) Whether or not the backup policy is required. - `restored_branches` (List of String) Branches that have been restored with this backup. @@ -53,6 +55,16 @@ resource "planetscale_backup" "example" { - `state` (String) The current state of the backup. - `updated_at` (String) When the backup was last updated. + +### Nested Schema for `actor` + +Read-Only: + +- `avatar_url` (String) The URL of the actor's avatar +- `display_name` (String) The name of the actor +- `id` (String) The ID of the actor + + ### Nested Schema for `backup_policy` @@ -74,13 +86,3 @@ Read-Only: - `schedule_week` (String) Week of the month that the backup is scheduled. - `target` (String) Whether the backup policy is for a production or development database, or for a database branch. - `updated_at` (String) When the backup policy was last updated. - - - -### Nested Schema for `actor` - -Read-Only: - -- `avatar_url` (String) The URL of the actor's avatar -- `display_name` (String) The name of the actor -- `id` (String) The ID of the actor diff --git a/docs/resources/branch.md b/docs/resources/branch.md index 9f94c3b..39c0d6a 100644 --- a/docs/resources/branch.md +++ b/docs/resources/branch.md @@ -37,13 +37,11 @@ resource "planetscale_branch" "example" { ### Read-Only -- `access_host_url` (String) The access host URL for the branch. This is a legacy field, use `mysql_edge_address`. - `actor` (Attributes) The actor who created this branch. (see [below for nested schema](#nestedatt--actor)) - `cluster_rate_name` (String) The SKU representing the branch's cluster size. - `created_at` (String) When the branch was created. - `html_url` (String) Planetscale app URL for the branch. - `id` (String) The ID of the branch. -- `initial_restore_id` (String) The ID of the backup from which the branch was restored. - `mysql_address` (String) The MySQL address for the branch. - `mysql_edge_address` (String) The address of the MySQL provider for the branch. - `ready` (Boolean) Whether or not the branch is ready to serve queries. From 17d3aa495b6a5b6da59b846d87e57e07fc3feeac Mon Sep 17 00:00:00 2001 From: joe miller Date: Sat, 5 Oct 2024 21:23:30 +0000 Subject: [PATCH 09/12] make: fix spelling --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 3a28c52..5d714bb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -13,4 +13,4 @@ testacc: generate: bash ./script/update_openapi_spec bash ./script/generate - go gnenerate ./... \ No newline at end of file + go generate ./... \ No newline at end of file From ccfe1cd91aa381e0371bd351c4d59c6866de11c5 Mon Sep 17 00:00:00 2001 From: joe miller Date: Sun, 6 Oct 2024 00:16:40 +0000 Subject: [PATCH 10/12] chore: bump openapi spec doc. no code changes from this one --- openapi-spec.json | 16 ++++++++-------- openapi/openapi-spec.json | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/openapi-spec.json b/openapi-spec.json index 931cb82..e24afce 100644 --- a/openapi-spec.json +++ b/openapi-spec.json @@ -6586,10 +6586,6 @@ "description": " API endpoints for managing database branch passwords.\n", "name": "Database branch passwords" }, - { - "description": " API endpoints for managing database deploy requests.\n", - "name": "Deploy requests" - }, { "description": " API endpoints for managing databases within an organization.\n", "name": "Databases" @@ -6606,13 +6602,17 @@ "description": " API endpoints for managing organizations.\n", "name": "Organizations" }, - { - "description": " API endpoints for fetching invoice information.\n", - "name": "Invoices" - }, { "description": " API endpoints for fetching user information.\n", "name": "Users" + }, + { + "description": " API endpoints for managing database deploy requests.\n", + "name": "Deploy requests" + }, + { + "description": " API endpoints for fetching invoice information.\n", + "name": "Invoices" } ], "x-readme": { diff --git a/openapi/openapi-spec.json b/openapi/openapi-spec.json index 0261f97..d0b8daf 100644 --- a/openapi/openapi-spec.json +++ b/openapi/openapi-spec.json @@ -12075,10 +12075,6 @@ "name": "Database branch passwords", "description": " API endpoints for managing database branch passwords.\n" }, - { - "name": "Deploy requests", - "description": " API endpoints for managing database deploy requests.\n" - }, { "name": "Databases", "description": " API endpoints for managing databases within an organization.\n" @@ -12095,13 +12091,17 @@ "name": "Organizations", "description": " API endpoints for managing organizations.\n" }, - { - "name": "Invoices", - "description": " API endpoints for fetching invoice information.\n" - }, { "name": "Users", "description": " API endpoints for fetching user information.\n" + }, + { + "name": "Deploy requests", + "description": " API endpoints for managing database deploy requests.\n" + }, + { + "name": "Invoices", + "description": " API endpoints for fetching invoice information.\n" } ], "securityDefinitions": { From 6f6284b8c735e8bcd87a60684fe65f46370eec9a Mon Sep 17 00:00:00 2001 From: joe miller Date: Sun, 6 Oct 2024 00:17:39 +0000 Subject: [PATCH 11/12] ignore `invoice_budget_amount` in organization resources the api is returning this value as a string even though the openapi spec says it should be a number (float64). we are not using this field, so let's comment it out for now --- internal/client/planetscale/planetscale.go | 6 ++---- internal/cmd/client_codegen/jenny.go | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/client/planetscale/planetscale.go b/internal/client/planetscale/planetscale.go index d4d009f..a202e8c 100644 --- a/internal/client/planetscale/planetscale.go +++ b/internal/client/planetscale/planetscale.go @@ -343,7 +343,6 @@ type Organization struct { HasPastDueInvoices bool `json:"has_past_due_invoices" tfsdk:"has_past_due_invoices"` Id string `json:"id" tfsdk:"id"` IdpManagedRoles bool `json:"idp_managed_roles" tfsdk:"idp_managed_roles"` - InvoiceBudgetAmount float64 `json:"invoice_budget_amount" tfsdk:"invoice_budget_amount"` Name string `json:"name" tfsdk:"name"` Plan string `json:"plan" tfsdk:"plan"` SingleTenancy bool `json:"single_tenancy" tfsdk:"single_tenancy"` @@ -615,9 +614,8 @@ func (cl *Client) GetOrganization(ctx context.Context, name string) (res200 *Get } type UpdateOrganizationReq struct { - BillingEmail *string `json:"billing_email,omitempty" tfsdk:"billing_email"` - IdpManagedRoles *bool `json:"idp_managed_roles,omitempty" tfsdk:"idp_managed_roles"` - InvoiceBudgetAmount *float64 `json:"invoice_budget_amount,omitempty" tfsdk:"invoice_budget_amount"` + BillingEmail *string `json:"billing_email,omitempty" tfsdk:"billing_email"` + IdpManagedRoles *bool `json:"idp_managed_roles,omitempty" tfsdk:"idp_managed_roles"` } type UpdateOrganizationRes struct { Organization diff --git a/internal/cmd/client_codegen/jenny.go b/internal/cmd/client_codegen/jenny.go index 0750d25..275260d 100644 --- a/internal/cmd/client_codegen/jenny.go +++ b/internal/cmd/client_codegen/jenny.go @@ -93,6 +93,14 @@ func genParamStruct(defns spec.Definitions, file *jen.File, typename string, bod var fields []jen.Code if body != nil { for _, item := range body.Properties.ToOrderedSchemaItems() { + + // XXX: skip `invoice_budget_amount` field. It's reported as a number/float64 + // in the openapi spec, but the api is currently returning strings. + // TODO(joem): remove this when the issue is resolved in the api + if item.Name == "invoice_budget_amount" { + continue + } + f, err := toField(item) if err != nil { return fmt.Errorf("looking at item %q: %w", item.Name, err) From afdbf737dded76dc5204ff1011977b5531dbe905 Mon Sep 17 00:00:00 2001 From: joe miller Date: Sun, 6 Oct 2024 00:29:24 +0000 Subject: [PATCH 12/12] remove retired fields from org resources --- docs/data-sources/organization.md | 3 -- docs/data-sources/organizations.md | 3 -- internal/provider/models_data_source.go | 49 +++++++------------ .../provider/organization_data_source_test.go | 3 -- .../organizations_data_source_test.go | 4 -- 5 files changed, 17 insertions(+), 45 deletions(-) diff --git a/docs/data-sources/organization.md b/docs/data-sources/organization.md index dd727cf..65fce5a 100644 --- a/docs/data-sources/organization.md +++ b/docs/data-sources/organization.md @@ -31,14 +31,11 @@ output "org" { ### Read-Only -- `admin_only_production_access` (Boolean) Whether or not only administrators can access production branches in the organization. - `billing_email` (String) The billing email of the organization. -- `can_create_databases` (Boolean) Whether or not more databases can be created in the organization. - `created_at` (String) When the organization was created. - `database_count` (Number) The number of databases in the organization. - `features` (Attributes) Features that are enabled on the organization. (see [below for nested schema](#nestedatt--features)) - `flags` (Attributes) . (see [below for nested schema](#nestedatt--flags)) -- `free_databases_remaining` (Number) The number of remaining free databases that can be created in the organization. - `has_past_due_invoices` (Boolean) Whether or not the organization has past due billing invoices. - `id` (String) The ID for the organization. - `idp_managed_roles` (Boolean) Whether or not the IdP provider is be responsible for managing roles in PlanetScale. diff --git a/docs/data-sources/organizations.md b/docs/data-sources/organizations.md index 2510888..4ff4227 100644 --- a/docs/data-sources/organizations.md +++ b/docs/data-sources/organizations.md @@ -32,14 +32,11 @@ output "orgs" { Read-Only: -- `admin_only_production_access` (Boolean) Whether or not only administrators can access production branches in the organization. - `billing_email` (String) The billing email of the organization. -- `can_create_databases` (Boolean) Whether or not more databases can be created in the organization. - `created_at` (String) When the organization was created. - `database_count` (Number) The number of databases in the organization. - `features` (Attributes) Features that are enabled on the organization. (see [below for nested schema](#nestedatt--organizations--features)) - `flags` (Attributes) . (see [below for nested schema](#nestedatt--organizations--flags)) -- `free_databases_remaining` (Number) The number of remaining free databases that can be created in the organization. - `has_past_due_invoices` (Boolean) Whether or not the organization has past due billing invoices. - `id` (String) The ID for the organization. - `idp_managed_roles` (Boolean) Whether or not the IdP provider is be responsible for managing roles in PlanetScale. diff --git a/internal/provider/models_data_source.go b/internal/provider/models_data_source.go index 6452662..9687140 100644 --- a/internal/provider/models_data_source.go +++ b/internal/provider/models_data_source.go @@ -14,18 +14,10 @@ func organizationDataSourceSchemaAttribute(computedName bool) map[string]schema. Description: "The name of the organization.", Required: !computedName, Computed: computedName, }, - "admin_only_production_access": schema.BoolAttribute{ - Description: "Whether or not only administrators can access production branches in the organization.", - Computed: true, - }, "billing_email": schema.StringAttribute{ Description: "The billing email of the organization.", Computed: true, }, - "can_create_databases": schema.BoolAttribute{ - Description: "Whether or not more databases can be created in the organization.", - Computed: true, - }, "created_at": schema.StringAttribute{ Description: "When the organization was created.", Computed: true, @@ -44,10 +36,6 @@ func organizationDataSourceSchemaAttribute(computedName bool) map[string]schema. Computed: true, Attributes: flagsDataSourceSchemaAttribute, }, - "free_databases_remaining": schema.Float64Attribute{ - Description: "The number of remaining free databases that can be created in the organization.", - Computed: true, - }, "has_past_due_invoices": schema.BoolAttribute{ Description: "Whether or not the organization has past due billing invoices.", Computed: true, @@ -96,26 +84,23 @@ func organizationDataSourceSchemaAttribute(computedName bool) map[string]schema. } type organizationDataSourceModel struct { - AdminOnlyProductionAccess types.Bool `tfsdk:"admin_only_production_access"` - BillingEmail types.String `tfsdk:"billing_email"` - CanCreateDatabases types.Bool `tfsdk:"can_create_databases"` - CreatedAt types.String `tfsdk:"created_at"` - DatabaseCount types.Float64 `tfsdk:"database_count"` - Features *featuresDataSourceModel `tfsdk:"features"` - Flags *flagsDataSourceModel `tfsdk:"flags"` - FreeDatabasesRemaining types.Float64 `tfsdk:"free_databases_remaining"` - HasPastDueInvoices types.Bool `tfsdk:"has_past_due_invoices"` - Id types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Plan types.String `tfsdk:"plan"` - SingleTenancy types.Bool `tfsdk:"single_tenancy"` - SleepingDatabaseCount types.Float64 `tfsdk:"sleeping_database_count"` - Sso types.Bool `tfsdk:"sso"` - SsoDirectory types.Bool `tfsdk:"sso_directory"` - SsoPortalUrl types.String `tfsdk:"sso_portal_url"` - UpdatedAt types.String `tfsdk:"updated_at"` - ValidBillingInfo types.Bool `tfsdk:"valid_billing_info"` - IdpManagedRoles types.Bool `tfsdk:"idp_managed_roles"` + BillingEmail types.String `tfsdk:"billing_email"` + CreatedAt types.String `tfsdk:"created_at"` + DatabaseCount types.Float64 `tfsdk:"database_count"` + Features *featuresDataSourceModel `tfsdk:"features"` + Flags *flagsDataSourceModel `tfsdk:"flags"` + HasPastDueInvoices types.Bool `tfsdk:"has_past_due_invoices"` + Id types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Plan types.String `tfsdk:"plan"` + SingleTenancy types.Bool `tfsdk:"single_tenancy"` + SleepingDatabaseCount types.Float64 `tfsdk:"sleeping_database_count"` + Sso types.Bool `tfsdk:"sso"` + SsoDirectory types.Bool `tfsdk:"sso_directory"` + SsoPortalUrl types.String `tfsdk:"sso_portal_url"` + UpdatedAt types.String `tfsdk:"updated_at"` + ValidBillingInfo types.Bool `tfsdk:"valid_billing_info"` + IdpManagedRoles types.Bool `tfsdk:"idp_managed_roles"` } func organizationFromClient(org *planetscale.Organization) *organizationDataSourceModel { diff --git a/internal/provider/organization_data_source_test.go b/internal/provider/organization_data_source_test.go index 2a11c60..55fa977 100644 --- a/internal/provider/organization_data_source_test.go +++ b/internal/provider/organization_data_source_test.go @@ -16,13 +16,10 @@ func TestAccOrganizationDataSource(t *testing.T) { Config: testAccOrganizationDataSourceConfig, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.planetscale_organization.test", "name", "planetscale-terraform-testing"), - resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "admin_only_production_access"), resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "billing_email"), - resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "can_create_databases"), resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "created_at"), resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "database_count"), resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "features.insights"), - resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "free_databases_remaining"), resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "has_past_due_invoices"), resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "id"), resource.TestCheckResourceAttrSet("data.planetscale_organization.test", "idp_managed_roles"), diff --git a/internal/provider/organizations_data_source_test.go b/internal/provider/organizations_data_source_test.go index d17cfeb..893d13a 100644 --- a/internal/provider/organizations_data_source_test.go +++ b/internal/provider/organizations_data_source_test.go @@ -17,13 +17,9 @@ func TestAccOrganizationsDataSource(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.planetscale_organizations.test", "organizations.#", "1"), resource.TestCheckResourceAttr("data.planetscale_organizations.test", "organizations.0.name", testAccOrg), - resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.admin_only_production_access"), resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.billing_email"), - resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.can_create_databases"), - resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.created_at"), resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.database_count"), resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.features.insights"), - resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.free_databases_remaining"), resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.has_past_due_invoices"), resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.id"), resource.TestCheckResourceAttrSet("data.planetscale_organizations.test", "organizations.0.idp_managed_roles"),