planetscale

package
v0.312.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package planetscale is the CLI's client for the PlanetScale API.

It was vendored from github.com/planetscale/planetscale-go (v0.178.0) in July 2026 and is maintained here; the CLI no longer depends on that module. New endpoints are added directly to this package in the same PR as the CLI feature that uses them, and are synced back to planetscale-go for external users. See doc/api-client.md for background.

Index

Constants

View Source
const (
	PostgresBranchChangeStateCompleted = "completed"
	PostgresBranchChangeStateCanceled  = "canceled"
)

Terminal states for a PostgresBranchClusterResizeRequest. Non-terminal states are "queued", "pending", and "resizing".

View Source
const (
	DefaultBaseURL = "https://api.planetscale.com/"
)

Variables

This section is empty.

Functions

func NewAuditLogsService

func NewAuditLogsService(client *Client) *auditlogsService

func NewBackupsService

func NewBackupsService(client *Client) *backupsService

func NewBranchInfrastructureService

func NewBranchInfrastructureService(client *Client) *branchInfrastructureService

func NewDatabaseBranchesService

func NewDatabaseBranchesService(client *Client) *databaseBranchesService

func NewDatabasesService

func NewDatabasesService(client *Client) *databasesService

func NewDeployRequestsService

func NewDeployRequestsService(client *Client) *deployRequestsService

func NewKeyspacesService

func NewKeyspacesService(client *Client) *keyspacesService

func NewOrganizationsService

func NewOrganizationsService(client *Client) *organizationsService

func NewPasswordsService

func NewPasswordsService(client *Client) *passwordsService

func NewPostgresBranchesService

func NewPostgresBranchesService(client *Client) *postgresBranchesService

func NewPostgresRolesService

func NewPostgresRolesService(client *Client) *postgresRolesService

func NewQueryPatternsService

func NewQueryPatternsService(client *Client) *queryPatternsService

func NewRegionsSevice

func NewRegionsSevice(client *Client) *regionsService

func NewTrafficBudgetsService

func NewTrafficBudgetsService(client *Client) *trafficBudgetsService

NewTrafficBudgetsService returns a TrafficBudgetsService backed by client.

func NewTrafficRulesService

func NewTrafficRulesService(client *Client) *trafficRulesService

NewTrafficRulesService returns a TrafficRulesService backed by client.

func NewWorkflowsService

func NewWorkflowsService(client *Client) *workflowsService

Types

type Actor

type Actor struct {
	Type string `json:"type"`
	ID   string `json:"id"`
	Name string `json:"display_name"`
}

Actor represents a user or service token

type AddServiceTokenAccessRequest

type AddServiceTokenAccessRequest struct {
	Organization string   `json:"-"`
	ID           string   `json:"-"`
	Database     string   `json:"database"`
	Accesses     []string `json:"access"`
}

type Anomaly added in v0.307.0

type Anomaly struct {
	ID                 string    `json:"id"`
	PeriodStart        time.Time `json:"period_start"`
	PeriodEnd          time.Time `json:"period_end"`
	MinutesInViolation int64     `json:"minutes_in_violation"`
	Active             bool      `json:"active"`
	Duration           float64   `json:"duration"`
	MetricsStart       time.Time `json:"metrics_start"`
	MetricsEnd         time.Time `json:"metrics_end"`
}

Anomaly is a detected resource-usage anomaly on a branch's primary.

type ApplyDeployRequestRequest

type ApplyDeployRequestRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
}

type AuditLog

type AuditLog struct {
	ID   string `json:"id"`
	Type string `json:"type"`

	ActorID          string `json:"actor_id"`
	ActorType        string `json:"actor_type"`
	ActorDisplayName string `json:"actor_display_name"`

	AuditableID          string `json:"auditable_id"`
	AuditableType        string `json:"auditable_type"`
	AuditableDisplayName string `json:"auditable_display_name"`

	AuditAction string `json:"audit_action"`
	Action      string `json:"action"`

	Location string `json:"location"`
	RemoteIP string `json:"remote_ip"`

	TargetID          string `json:"target_id"`
	TargetType        string `json:"target_type"`
	TargetDisplayName string `json:"target_display_name"`

	Metadata map[string]interface{} `json:"metadata"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

AuditLog represents a PlanetScale audit log.

type AuditLogEvent

type AuditLogEvent string

AuditLogEvent represents an audit log's event type

const (
	AuditLogEventBranchCreated                 AuditLogEvent = "branch.created"
	AuditLogEventBranchDeleted                 AuditLogEvent = "branch.deleted"
	AuditLogEventDatabaseCreated               AuditLogEvent = "database.created"
	AuditLogEventDatabaseDeleted               AuditLogEvent = "database.deleted"
	AuditLogEventDeployRequestApproved         AuditLogEvent = "deploy_request.approved"
	AuditLogEventDeployRequestClosed           AuditLogEvent = "deploy_request.closed"
	AuditLogEventDeployRequestCreated          AuditLogEvent = "deploy_request.created"
	AuditLogEventDeployRequestDeleted          AuditLogEvent = "deploy_request.deleted"
	AuditLogEventDeployRequestQueued           AuditLogEvent = "deploy_request.queued"
	AuditLogEventDeployRequestUnqueued         AuditLogEvent = "deploy_request.unqueued"
	AuditLogEventIntegrationCreated            AuditLogEvent = "integration.created"
	AuditLogEventIntegrationDeleted            AuditLogEvent = "integration.deleted"
	AuditLogEventOrganizationInvitationCreated AuditLogEvent = "organization_invitation.created"
	AuditLogEventOrganizationInvitationDeleted AuditLogEvent = "organization_invitation.deleted"
	AuditLogEventOrganizationMembershipCreated AuditLogEvent = "organization_membership.created"
	AuditLogEventOrganizationJoined            AuditLogEvent = "organization.joined"
	AuditLogEventOrganizationRemovedMember     AuditLogEvent = "organization.removed_member"
	AuditLogEventOrganizationDisabledSSO       AuditLogEvent = "organization.disabled_sso"
	AuditLogEventOrganizationEnabledSSO        AuditLogEvent = "organization.enabled_sso"
	AuditLogEventOrganizationUpdatedRole       AuditLogEvent = "organization.updated_role"
	AuditLogEventServiceTokenCreated           AuditLogEvent = "service_token.created"
	AuditLogEventServiceTokenDeleted           AuditLogEvent = "service_token.deleted"
	AuditLogEventServiceTokenGrantedAccess     AuditLogEvent = "service_token.granted_access"
)

type AuditLogsService

type AuditLogsService interface {
	List(context.Context, *ListAuditLogsRequest, ...ListOption) (*CursorPaginatedResponse[*AuditLog], error)
}

AuditLogsService is an interface for communicating with the PlanetScale AuditLogs API endpoints.

type AutoApplyDeployRequestRequest

type AutoApplyDeployRequestRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
	Enable       bool   `json:"-"`
}

type Backup

type Backup struct {
	PublicID    string    `json:"id"`
	Name        string    `json:"name"`
	State       string    `json:"state"`
	Size        int64     `json:"size"`
	Actor       *Actor    `json:"actor"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	StartedAt   time.Time `json:"started_at"`
	ExpiresAt   time.Time `json:"expires_at"`
	CompletedAt time.Time `json:"completed_at"`
}

type BackupsService

BackupsService is an interface for communicating with the PlanetScale backup API endpoint.

type BillingPlan

type BillingPlan int
const (
	HobbyPlan BillingPlan = iota
	ScalerProPlan
)

func (BillingPlan) String

func (bp BillingPlan) String() string

type BranchInfraPod

type BranchInfraPod struct {
	Name         string     `json:"name"`
	Status       string     `json:"status"`
	Component    string     `json:"component"`
	Ready        string     `json:"ready"`
	RestartCount int        `json:"restart_count"`
	CreatedAt    *time.Time `json:"created_at"`
	Cell         string     `json:"cell"`
	Size         string     `json:"size"`
	Keyspace     *string    `json:"keyspace"`
	Shard        *string    `json:"shard"`
	TabletType   *string    `json:"tablet_type"`
}

BranchInfraPod represents a single pod in the branch infrastructure.

type BranchInfrastructure

type BranchInfrastructure struct {
	Type     string
	Vitess   *VitessBranchInfrastructure
	Postgres *PostgresBranchInfrastructure
}

BranchInfrastructure represents the infrastructure for a branch. Exactly one of Vitess or Postgres is set, depending on the branch's database engine.

func (*BranchInfrastructure) UnmarshalJSON

func (b *BranchInfrastructure) UnmarshalJSON(data []byte) error

type BranchInfrastructureService

type BranchInfrastructureService interface {
	Get(ctx context.Context, req *GetBranchInfrastructureRequest) (*BranchInfrastructure, error)
}

BranchInfrastructureService is an interface for interacting with the branch infrastructure API.

type BranchResizeRequest added in v0.310.0

type BranchResizeRequest struct {
	ID    string `json:"id"`
	Type  string `json:"type"`
	State string `json:"state"`
	Actor *Actor `json:"actor"`

	VTGateSize                         string `json:"vtgate_size"`
	PreviousVTGateSize                 string `json:"previous_vtgate_size"`
	VTGateName                         string `json:"vtgate_name"`
	VTGateDisplayName                  string `json:"vtgate_display_name"`
	PreviousVTGateName                 string `json:"previous_vtgate_name"`
	PreviousVTGateDisplayName          string `json:"previous_vtgate_display_name"`
	VTGateCount                        int    `json:"vtgate_count"`
	PreviousVTGateCount                int    `json:"previous_vtgate_count"`
	VTGateMaxCount                     *int   `json:"vtgate_max_count"`
	PreviousVTGateMaxCount             *int   `json:"previous_vtgate_max_count"`
	VTGateAutoscaling                  bool   `json:"vtgate_autoscaling"`
	PreviousVTGateAutoscaling          bool   `json:"previous_vtgate_autoscaling"`
	VTGateTargetCPUUtilization         *int   `json:"vtgate_target_cpu_utilization"`
	PreviousVTGateTargetCPUUtilization *int   `json:"previous_vtgate_target_cpu_utilization"`

	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
	StartedAt   *time.Time `json:"started_at"`
	CompletedAt *time.Time `json:"completed_at"`
}

BranchResizeRequest represents a Vitess branch VTGate resize request.

type BranchResizeStatusRequest added in v0.310.0

type BranchResizeStatusRequest struct {
	Organization string
	Database     string
	Branch       string
}

BranchResizeStatusRequest encapsulates a request for the latest branch VTGate resize status.

type BranchRoutingRulesRequest

type BranchRoutingRulesRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

type BranchSchemaRequest

type BranchSchemaRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
}

BranchSchemaRequest encapsulates a request for getting a branch's schema.

type CancelBranchResizeRequest added in v0.310.0

type CancelBranchResizeRequest struct {
	Organization string
	Database     string
	Branch       string
}

CancelBranchResizeRequest encapsulates a request to cancel a queued branch VTGate resize.

type CancelDataImportRequest

type CancelDataImportRequest struct {
	Organization string
	Database     string
}

type CancelDeployRequestRequest

type CancelDeployRequestRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
}

type CancelKeyspaceResizeRequest

type CancelKeyspaceResizeRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
}

type CancelPostgresBranchChangesRequest added in v0.304.0

type CancelPostgresBranchChangesRequest struct {
	Organization string
	Database     string
	Branch       string
}

CancelPostgresBranchChangesRequest encapsulates the request to cancel the queued change requests for a Postgres branch.

type CancelWorkflowRequest

type CancelWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type Client

type Client struct {

	// UserAgent is the version of the planetscale-go library that is being used
	UserAgent string

	AuditLogs             AuditLogsService
	Backups               BackupsService
	BranchInfrastructure  BranchInfrastructureService
	D1ImportNotifications D1ImportNotificationsService
	DatabaseBranches      DatabaseBranchesService
	Databases             DatabasesService
	DataImports           DataImportsService
	DeployRequests        DeployRequestsService
	Keyspaces             KeyspacesService
	LookupVindex          LookupVindexService
	Materialize           MaterializeService
	MoveTables            MoveTablesService
	Organizations         OrganizationsService
	Passwords             PasswordsService
	PlannedReparentShard  PlannedReparentShardService
	PostgresBranches      PostgresBranchesService
	PostgresRoles         PostgresRolesService
	Processlist           ProcesslistService
	QueryInsights         QueryInsightsService
	QueryPatterns         QueryPatternsService
	ReadOnlyRegions       ReadOnlyRegionsService
	Regions               RegionsService
	SchemaRecommendations SchemaRecommendationService
	ServiceTokens         ServiceTokenService
	TrafficBudgets        TrafficBudgetsService
	TrafficRules          TrafficRulesService
	VDiff                 VDiffService
	Vtctld                VtctldService
	Webhooks              WebhooksService
	Workflows             WorkflowsService
	// contains filtered or unexported fields
}

Client encapsulates a client that talks to the PlanetScale API

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

NewClient instantiates an instance of the PlanetScale API client.

type ClientOption

type ClientOption func(c *Client) error

ClientOption provides a variadic option for configuring the client

func WithAccessToken

func WithAccessToken(token string) ClientOption

WithAccessToken configures a client with the given PlanetScale access token.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the base URL for the API.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient configures the PlanetScale client with the given HTTP client.

func WithRequestHeaders

func WithRequestHeaders(headers map[string]string) ClientOption

WithRequestHeaders sets the request headers for every HTTP request.

func WithServiceToken

func WithServiceToken(name, token string) ClientOption

WithServiceToken configures a client with the given PlanetScale Service Token

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent overrides the User-Agent header.

type CloseDeployRequestRequest

type CloseDeployRequestRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
}

type CloseRequest

type CloseRequest struct {
	State string `json:"state"`
}

type ClosedByDeployRequest

type ClosedByDeployRequest struct {
	ID       string `json:"id"`
	BranchID string `json:"branch_id"`
	Number   int    `json:"number"`
}

type ClusterSKU

type ClusterSKU struct {
	Name        string `json:"name"`
	DisplayName string `json:"display_name"`
	CPU         string `json:"cpu"`
	Memory      int64  `json:"ram"`

	SortOrder int64 `json:"sort_order"`

	Storage *int64 `json:"storage"`

	Rate                 *int64  `json:"rate"`
	ReplicaRate          *int64  `json:"replica_rate"`
	ProviderInstanceType *string `json:"provider_instance_type"`
	Provider             *string `json:"provider"`
	Enabled              bool    `json:"enabled"`
	DefaultVTGate        string  `json:"default_vtgate"`
	DefaultVTGateRate    *int64  `json:"default_vtgate_rate"`

	Metal bool `json:"metal"`
}

ClusterSKU represents a SKU for a PlanetScale cluster

type CompleteWorkflowRequest

type CompleteWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type CreateBackupRequest

type CreateBackupRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	Name           string `json:"name,omitempty"`
	RetentionUnit  string `json:"retention_unit,omitempty"`
	RetentionValue int    `json:"retention_value,omitempty"`
	Emergency      bool   `json:"emergency,omitempty"`
}

type CreateD1ImportNotificationRequest

type CreateD1ImportNotificationRequest struct {
	Organization string
	Database     string
	BranchName   string
	MigrationID  string
	Event        string
	Method       string
	ExportBytes  int64
	TableCount   int
	Matched      *bool
	DurationMs   int64
	Error        string
	ErrorCode    string
	Stage        string
	Message      string
}

type CreateDatabaseBranchRequest

type CreateDatabaseBranchRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Region       string `json:"region,omitempty"`
	Name         string `json:"name"`
	ParentBranch string `json:"parent_branch"`
	BackupID     string `json:"backup_id,omitempty"`
	SeedData     string `json:"seed_data,omitempty"`
	ClusterSize  string `json:"cluster_size,omitempty"`
}

CreateDatabaseBranchRequest encapsulates the request for creating a new database branch

type CreateDatabaseRequest

type CreateDatabaseRequest struct {
	Organization        string
	Name                string         `json:"name"`
	Notes               string         `json:"notes,omitempty"`
	Region              string         `json:"region,omitempty"`
	ClusterSize         string         `json:"cluster_size,omitempty"`
	Kind                DatabaseEngine `json:"kind,omitempty"`
	Replicas            *int           `json:"replicas,omitempty"`
	MajorVersion        string         `json:"major_version,omitempty"`
	Storage             *StorageConfig `json:"storage,omitempty"`
	CloudflareAccountID string         `json:"cloudflare_account_id,omitempty"`
	CloudflareTimestamp string         `json:"cloudflare_timestamp,omitempty"`
	CloudflareSignature string         `json:"cloudflare_signature,omitempty"`
}

CreateDatabaseRequest encapsulates the request for creating a new database.

type CreateDeployRequestRequest

type CreateDeployRequestRequest struct {
	Organization     string `json:"-"`
	Database         string `json:"-"`
	Branch           string `json:"branch"`
	IntoBranch       string `json:"into_branch,omitempty"`
	Notes            string `json:"notes"`
	AutoCutover      bool   `json:"auto_cutover,omitempty"`
	AutoDeleteBranch bool   `json:"auto_delete_branch,omitempty"`
}

type CreateKeyspaceRequest

type CreateKeyspaceRequest struct {
	Organization  string `json:"-"`
	Database      string `json:"-"`
	Branch        string `json:"-"`
	Name          string `json:"name"`
	ClusterSize   string `json:"cluster_size"`
	ExtraReplicas int    `json:"extra_replicas"`
	Shards        int    `json:"shards"`
}

type CreatePostgresBranchRequest

type CreatePostgresBranchRequest struct {
	Organization string         `json:"-"`
	Database     string         `json:"-"`
	Region       string         `json:"region,omitempty"`
	Name         string         `json:"name"`
	ParentBranch string         `json:"parent_branch"`
	BackupID     string         `json:"backup_id,omitempty"`
	ClusterName  string         `json:"cluster_name,omitempty"`
	MajorVersion string         `json:"major_version,omitempty"`
	Storage      *StorageConfig `json:"storage,omitempty"`
}

CreatePostgresBranchRequest encapsulates the request to create a Postgres branch.

type CreatePostgresRoleRequest

type CreatePostgresRoleRequest struct {
	Organization    string   `json:"-"`
	Database        string   `json:"-"`
	Branch          string   `json:"-"`
	Name            string   `json:"name"`
	TTL             int      `json:"ttl,omitempty"`
	InheritedRoles  []string `json:"inherited_roles,omitempty"`
	WithReplication bool     `json:"with_replication,omitempty"`
}

CreatePostgresRoleRequest encapsulates the request for creating role credentials for a database branch.

type CreateQueryPatternsReportRequest

type CreateQueryPatternsReportRequest struct {
	Organization string
	Database     string
	Branch       string
}

type CreateServiceTokenRequest

type CreateServiceTokenRequest struct {
	Organization string  `json:"-"`
	Name         *string `json:"name,omitempty"`
	TTL          *int    `json:"ttl,omitempty"`
}

type CreateTrafficBudgetRequest

type CreateTrafficBudgetRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	Name string `json:"name"`
	Mode string `json:"mode"`

	Capacity         *int `json:"capacity,omitempty"`
	Rate             *int `json:"rate,omitempty"`
	Burst            *int `json:"burst,omitempty"`
	Concurrency      *int `json:"concurrency,omitempty"`
	WarningThreshold *int `json:"warning_threshold,omitempty"`

	Rules *[]CreateTrafficBudgetRuleRequest `json:"rules,omitempty"`
}

CreateTrafficBudgetRequest is the request for creating a traffic budget.

type CreateTrafficBudgetRuleRequest

type CreateTrafficBudgetRuleRequest struct {
	Kind        string            `json:"kind"`
	Fingerprint string            `json:"fingerprint,omitempty"`
	Keyspace    string            `json:"keyspace,omitempty"`
	Tags        *[]TrafficRuleTag `json:"tags,omitempty"`
}

CreateTrafficBudgetRuleRequest describes a rule when creating or updating a budget.

type CreateTrafficRuleRequest

type CreateTrafficRuleRequest struct {
	Organization string            `json:"-"`
	Database     string            `json:"-"`
	Branch       string            `json:"-"`
	BudgetID     string            `json:"-"`
	Kind         string            `json:"kind"`
	Fingerprint  *string           `json:"fingerprint,omitempty"`
	Keyspace     *string           `json:"keyspace,omitempty"`
	Tags         *[]TrafficRuleTag `json:"tags,omitempty"`
}

CreateTrafficRuleRequest is the request for creating a traffic rule on a budget.

type CreateWebhookRequest

type CreateWebhookRequest struct {
	Organization string   `json:"-"`
	Database     string   `json:"-"`
	URL          string   `json:"url"`
	Enabled      *bool    `json:"enabled,omitempty"`
	Events       []string `json:"events,omitempty"`
}

CreateWebhookRequest is the request for creating a webhook.

type CreateWorkflowRequest

type CreateWorkflowRequest struct {
	Organization       string   `json:"-"`
	Database           string   `json:"-"`
	Branch             string   `json:"branch_name"`
	Name               string   `json:"name"`
	SourceKeyspace     string   `json:"source_keyspace"`
	TargetKeyspace     string   `json:"target_keyspace"`
	Tables             []string `json:"tables"`
	GlobalKeyspace     *string  `json:"global_keyspace"`
	DeferSecondaryKeys *bool    `json:"defer_secondary_keys"`
	OnDDL              *string  `json:"on_ddl"`
}

type CursorPaginatedResponse

type CursorPaginatedResponse[T any] struct {
	Data    []T  `json:"data"`
	HasNext bool `json:"has_next"`
	HasPrev bool `json:"has_prev"`
	// CursorStart is the ending cursor of the previous page.
	CursorStart *string `json:"cursor_start"`

	// CursorEnd is the starting cursor of the next page.
	CursorEnd *string `json:"cursor_end"`
}

CursorPaginatedResponse provides a generic means of wrapping a paginated response.

type CutoverWorkflowRequest

type CutoverWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type D1ImportNotificationsService

type D1ImportNotificationsService interface {
	Create(ctx context.Context, req *CreateD1ImportNotificationRequest) error
}

type DataImport

type DataImport struct {
	ID                 string `json:"id"`
	ImportState        DataImportState
	State              string           `json:"state"`
	Errors             string           `json:"import_check_errors"`
	StartedAt          *time.Time       `json:"started_at"`
	FinishedAt         *time.Time       `json:"finished_at"`
	DeletedAt          *time.Time       `json:"deleted_at"`
	ExternalDataSource DataImportSource `json:"data_source"`
}

func (*DataImport) ParseState

func (di *DataImport) ParseState()

type DataImportSource

type DataImportSource struct {
	HostName            string `json:"hostname"`
	Database            string `json:"schema_name"`
	Port                int    `json:"port"`
	SSLMode             string `json:"ssl_mode"`
	SSLVerificationMode ExternalDataSourceSSLVerificationMode
	UserName            string `json:"username"`
	Password            string `json:"password"`
	SSLCA               string `json:"ssl_ca"`
	SSLCertificate      string `json:"ssl_cert"`
	SSLKey              string `json:"ssl_key"`
	SSLServerName       string `json:"ssl_server_name"`
}

type DataImportState

type DataImportState int
const (
	DataImportPreparingDataCopy DataImportState = iota
	DataImportPreparingDataCopyFailed
	DataImportCopyingData
	DataImportCopyingDataFailed
	DataImportSwitchTrafficPending
	DataImportSwitchTrafficRunning
	DataImportSwitchTrafficCompleted
	DataImportSwitchTrafficError
	DataImportReverseTrafficRunning
	DataImportReverseTrafficCompleted
	DataImportReverseTrafficError
	DataImportDetachExternalDatabaseRunning
	DataImportDetachExternalDatabaseError
	DataImportReady
)

func (DataImportState) String

func (d DataImportState) String() string

type DataImportsService

type DataImportsService interface {
	// TestDataImportSource checks if the external database that we're importing will be supported
	// by PlanetScale. It checks for ability to replicate binlogs, schema compatibility and other factors.
	TestDataImportSource(ctx context.Context, request *TestDataImportSourceRequest) (*TestDataImportSourceResponse, error)
	// StartDataImport spins up a downstream PlanetScale database in replica mode, with the
	// external database as a Primary and starts copying data from external to PlanetScale.
	StartDataImport(ctx context.Context, request *StartDataImportRequest) (*DataImport, error)
	// CancelDataImport halts all replication and data copy from external to PlanetScale
	// and deletes the PlanetScale database.
	CancelDataImport(ctx context.Context, request *CancelDataImportRequest) error
	// GetDataImportStatus gets the current status of a DataImport for a given database
	// Fails if the database is not importing any data.
	GetDataImportStatus(ctx context.Context, request *GetImportStatusRequest) (*DataImport, error)
	// MakePlanetScalePrimary makes the downstream PlanetScale database a Primary and the external database a Replica.
	MakePlanetScalePrimary(ctx context.Context, request *MakePlanetScalePrimaryRequest) (*DataImport, error)
	// MakePlanetScaleReplica makes the downstream PlanetScale database a Replica and the external database a Primary.
	MakePlanetScaleReplica(ctx context.Context, request *MakePlanetScaleReplicaRequest) (*DataImport, error)
	// DetachExternalDatabase detaches the external database from PlanetScale after a data import has finished
	// and PlanetScale is running as Primary.
	DetachExternalDatabase(ctx context.Context, request *DetachExternalDatabaseRequest) (*DataImport, error)
}

DataImportsService is an interface for communicating with the PlanetScale Data Imports API endpoint.

type DataSourceIncompatibilityError

type DataSourceIncompatibilityError struct {
	LintError        string `json:"lint_error"`
	Keyspace         string `json:"keyspace_name"`
	Table            string `json:"table_name"`
	SubjectType      string `json:"subject_type"`
	ErrorDescription string `json:"error_description"`
	DocsUrl          string `json:"docs_url"`
}

DataSourceIncompatibilityError represents an error that occurs when the source schema in an external database server is incompatible with PlanetScale.

type Database

type Database struct {
	Name      string         `json:"name"`
	Notes     string         `json:"notes"`
	Region    Region         `json:"region"`
	State     DatabaseState  `json:"state"`
	Kind      DatabaseEngine `json:"kind"`
	HtmlURL   string         `json:"html_url"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
}

Database represents a PlanetScale database

type DatabaseBranch

type DatabaseBranch struct {
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	ParentBranch   string    `json:"parent_branch"`
	Actor          Actor     `json:"actor"`
	Region         Region    `json:"region"`
	Ready          bool      `json:"ready"`
	Production     bool      `json:"production"`
	HtmlURL        string    `json:"html_url"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	SafeMigrations bool      `json:"safe_migrations"`
	VTGateSize     string    `json:"vtgate_size"`
	VTGateCount    int       `json:"vtgate_count"`
}

DatabaseBranch represents a database branch.

type DatabaseBranchPassword

type DatabaseBranchPassword struct {
	PublicID  string         `json:"id"`
	Name      string         `json:"name"`
	Hostname  string         `json:"access_host_url"`
	Username  string         `json:"username"`
	Role      string         `json:"role"`
	Actor     *Actor         `json:"actor"`
	Branch    DatabaseBranch `json:"database_branch"`
	Region    Region         `json:"region"`
	CreatedAt time.Time      `json:"created_at"`
	DeletedAt time.Time      `json:"deleted_at"`
	ExpiresAt time.Time      `json:"expires_at"`
	PlainText string         `json:"plain_text"`
	TTL       int            `json:"ttl_seconds"`
	Renewable bool           `json:"renewable"`
	Replica   bool           `json:"replica"`

	// ReadOnlyRegion is set client-side when the password is known to be scoped to a
	// Vitess read-only region (the API does not currently return a dedicated flag).
	ReadOnlyRegion bool `json:"-"`
}

type DatabaseBranchPasswordRequest

type DatabaseBranchPasswordRequest struct {
	Organization     string `json:"-"`
	Database         string `json:"-"`
	Branch           string `json:"-"`
	Role             string `json:"role,omitempty"`
	Name             string `json:"name"`
	TTL              int    `json:"ttl,omitempty"`
	Replica          bool   `json:"replica,omitempty"`
	ReadOnlyRegionID string `json:"read_only_region_id,omitempty"`
}

DatabaseBranchPasswordRequest encapsulates the request for creating/getting/deleting a database branch password.

type DatabaseBranchesService

type DatabaseBranchesService interface {
	Create(context.Context, *CreateDatabaseBranchRequest) (*DatabaseBranch, error)
	List(context.Context, *ListDatabaseBranchesRequest, ...ListOption) ([]*DatabaseBranch, error)
	Get(context.Context, *GetDatabaseBranchRequest) (*DatabaseBranch, error)
	Delete(context.Context, *DeleteDatabaseBranchRequest) error
	Diff(context.Context, *DiffBranchRequest) ([]*Diff, error)
	Schema(context.Context, *BranchSchemaRequest) ([]*Diff, error)
	RoutingRules(context.Context, *BranchRoutingRulesRequest) (*RoutingRules, error)
	UpdateRoutingRules(context.Context, *UpdateBranchRoutingRulesRequest) (*RoutingRules, error)
	RefreshSchema(context.Context, *RefreshSchemaRequest) error
	Demote(context.Context, *DemoteRequest) (*DatabaseBranch, error)
	Promote(context.Context, *PromoteRequest) (*DatabaseBranch, error)
	EnableSafeMigrations(context.Context, *EnableSafeMigrationsRequest) (*DatabaseBranch, error)
	DisableSafeMigrations(context.Context, *DisableSafeMigrationsRequest) (*DatabaseBranch, error)
	LintSchema(context.Context, *LintSchemaRequest) ([]*SchemaLintError, error)
	ListClusterSKUs(context.Context, *ListBranchClusterSKUsRequest, ...ListOption) ([]*ClusterSKU, error)
	Resize(context.Context, *ResizeBranchRequest) (*BranchResizeRequest, error)
	ListResizes(context.Context, *ListBranchResizesRequest) ([]*BranchResizeRequest, error)
	CancelResize(context.Context, *CancelBranchResizeRequest) error
	ResizeStatus(context.Context, *BranchResizeStatusRequest) (*BranchResizeRequest, error)
}

DatabaseBranchesService is an interface for communicating with the PlanetScale Database Branch API endpoint.

type DatabaseDeletionRequest

type DatabaseDeletionRequest struct {
	ID    string `json:"id"`
	Actor Actor  `json:"actor"`
}

DatabaseDeletionRequest encapsulates the request for deleting a database from an organization.

type DatabaseEngine

type DatabaseEngine string
const (
	DatabaseEngineMySQL    DatabaseEngine = "mysql"
	DatabaseEnginePostgres DatabaseEngine = "postgresql"
)

type DatabaseState

type DatabaseState string

DatabaseState represents the state of a database

const (
	DatabasePending         DatabaseState = "pending"
	DatabaseImporting       DatabaseState = "importing"
	DatabaseAwakening       DatabaseState = "awakening"
	DatabaseSleepInProgress DatabaseState = "sleep_in_progress"
	DatabaseSleeping        DatabaseState = "sleeping"
	DatabaseReady           DatabaseState = "ready"
)

type DatabasesService

DatabaseService is an interface for communicating with the PlanetScale Databases API endpoint.

type DeleteBackupRequest

type DeleteBackupRequest struct {
	Organization string
	Database     string
	Branch       string
	Backup       string
}

type DeleteDatabaseBranchPasswordRequest

type DeleteDatabaseBranchPasswordRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Name         string `json:"name"`
	PasswordId   string
}

DeleteDatabaseBranchPasswordRequest encapsulates the request for deleting a password for a given database branch.

type DeleteDatabaseBranchRequest

type DeleteDatabaseBranchRequest struct {
	Organization      string
	Database          string
	Branch            string
	DeleteDescendants bool
}

DeleteDatabaseRequest encapsulates the request for deleting a database branch from a database.

type DeleteDatabaseRequest

type DeleteDatabaseRequest struct {
	Organization string
	Database     string
}

DeleteDatabaseRequest encapsulates the request for deleting a database from an organization.

type DeletePostgresBranchRequest

type DeletePostgresBranchRequest struct {
	Organization      string
	Database          string
	Branch            string
	DeleteDescendants bool
}

DeletePostgresBranchRequest encapsulates the request to delete a Postgres branch.

type DeletePostgresRoleRequest

type DeletePostgresRoleRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	RoleId       string `json:"-"`
	Successor    string `json:"successor,omitempty"`
}

DeletePostgresRoleRequest encapsulates the request for deleting role credentials for a database branch.

type DeleteServiceTokenAccessRequest

type DeleteServiceTokenAccessRequest struct {
	Organization string   `json:"-"`
	ID           string   `json:"-"`
	Database     string   `json:"database"`
	Accesses     []string `json:"access"`
}

type DeleteServiceTokenRequest

type DeleteServiceTokenRequest struct {
	Organization string `json:"-"`
	ID           string `json:"-"`
}

type DeleteTrafficBudgetRequest

type DeleteTrafficBudgetRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	BudgetID     string `json:"-"`
}

DeleteTrafficBudgetRequest is the request for deleting a traffic budget.

type DeleteTrafficRuleRequest

type DeleteTrafficRuleRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	BudgetID     string `json:"-"`
	RuleID       string `json:"-"`
}

DeleteTrafficRuleRequest is the request for deleting a traffic rule.

type DeleteWebhookRequest

type DeleteWebhookRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	ID           string `json:"-"`
}

DeleteWebhookRequest is the request for deleting a webhook.

type DemoteRequest

type DemoteRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

DemoteRequest encapsulates the request for demoting a branch to development.

type DeployOperation

type DeployOperation struct {
	ID                 string    `json:"id"`
	State              string    `json:"state"`
	Table              string    `json:"table_name"`
	Keyspace           string    `json:"keyspace_name"`
	Operation          string    `json:"operation_name"`
	ETASeconds         int64     `json:"eta_seconds"`
	ProgressPercentage uint64    `json:"progress_percentage"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
}

DeployOperation encapsulates a deploy operation within a deployment from the PlanetScale API.

type DeployRequest

type DeployRequest struct {
	ID string `json:"id"`

	Branch     string `json:"branch"`
	IntoBranch string `json:"into_branch"`

	Actor           Actor  `json:"actor"`
	ClosedBy        *Actor `json:"closed_by"`
	BranchDeletedBy *Actor `json:"branch_deleted_by"`
	Number          uint64 `json:"number"`

	State string `json:"state"`

	DeploymentState string `json:"deployment_state"`

	Approved bool `json:"approved"`

	Notes string `json:"notes"`

	Deployment *Deployment `json:"deployment"`

	HtmlURL string `json:"html_url"`

	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	ClosedAt   *time.Time `json:"closed_at"`
	DeployedAt *time.Time `json:"deployed_at"`
}

DeployRequest encapsulates the request to deploy a database branch's schema to a production branch

type DeployRequestReview

type DeployRequestReview struct {
	ID        string    `json:"id"`
	Body      string    `json:"body"`
	State     string    `json:"state"`
	Actor     Actor     `json:"actor"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

DeployRequestReview posts a review to a deploy request.

type Deployment

type Deployment struct {
	ID                   string                 `json:"id"`
	State                string                 `json:"state"`
	Deployable           bool                   `json:"deployable"`
	LintErrors           []*DeploymentLintError `json:"lint_errors"`
	DeployRequestNumber  uint64                 `json:"deploy_request_number"`
	IntoBranch           string                 `json:"into_branch"`
	PrecedingDeployments []*QueuedDeployment    `json:"preceding_deployments"`

	InstantDDLEligible bool `json:"instant_ddl_eligible"`
	InstantDDL         bool `json:"instant_ddl"`

	Actor          *Actor `json:"actor"`
	CutoverActor   *Actor `json:"cutover_actor"`
	CancelledActor *Actor `json:"cancelled_actor"`

	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	StartedAt  *time.Time `json:"started_at"`
	QueuedAt   *time.Time `json:"queued_at"`
	FinishedAt *time.Time `json:"finished_at"`
}

Deployment encapsulates a deployment for a deploy request.

type DeploymentLintError

type DeploymentLintError struct {
	LintError        string `json:"lint_error"`
	Keyspace         string `json:"keyspace_name"`
	Table            string `json:"table_name"`
	SubjectType      string `json:"subject_type"`
	ErrorDescription string `json:"error_description"`
	DocsUrl          string `json:"docs_url"`
}

DeploymentLintError represents an error that occurs during the deployment flow.

type DetachExternalDatabaseRequest

type DetachExternalDatabaseRequest struct {
	Organization string
	Database     string
}

type Diff

type Diff struct {
	Name string `json:"name"`
	Raw  string `json:"raw"`
	HTML string `json:"html"`
}

Diff returns the diff for a database deploy request

type DiffBranchRequest

type DiffBranchRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

DiffBranchRequest encapsulates a request for getting the diff for a branch.

type DiffRequest

type DiffRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
}

type DisableSafeMigrationsRequest

type DisableSafeMigrationsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

DisableSafeMigrationsRequest encapsulates the request for disabling safe migrations on a branch.

type DismissSchemaRecommendationRequest

type DismissSchemaRecommendationRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	ID           string `json:"-"`
}

DismissSchemaRecommendationRequest is the request for dismissing a schema recommendation.

type DownloadQueryPatternsReportRequest

type DownloadQueryPatternsReportRequest struct {
	Organization string
	Database     string
	Branch       string
	Report       string
}

type EnableSafeMigrationsRequest

type EnableSafeMigrationsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

EnableSafeMigrationsRequest encapsulates the request for enabling safe migrations on a branch.

type Error

type Error struct {

	// Code specifies the error code. i.e; NotFound, RateLimited, etc...
	Code ErrorCode

	// APICode is the raw code from the API error JSON body (e.g.
	// "schema_mutation_blocked"). Empty when the response had no code field.
	APICode string

	// Meta contains additional information depending on the error code. As an
	// example, if the Code is "ErrResponseMalformed", the map will be: ["body"]
	// = "body of the response"
	Meta map[string]string
	// contains filtered or unexported fields
}

Error represents common errors originating from the Client.

func (*Error) Error

func (e *Error) Error() string

Error returns the string representation of the error.

type ErrorCode

type ErrorCode string

ErrorCode defines the code of an error.

const (
	ErrInternal          ErrorCode = "internal"           // Internal error.
	ErrInvalid           ErrorCode = "invalid"            // Invalid operation, e.g wrong params
	ErrPermission        ErrorCode = "permission"         // Permission denied.
	ErrNotFound          ErrorCode = "not_found"          // Resource not found.
	ErrRetry             ErrorCode = "retry"              // Operation should be retried.
	ErrResponseMalformed ErrorCode = "response_malformed" // Response body is malformed.
)

type ExternalDataSourceSSLVerificationMode

type ExternalDataSourceSSLVerificationMode int
const (
	SSLModeDisabled ExternalDataSourceSSLVerificationMode = iota
	SSLModePreferred
	SSLModeRequired
	SSLModeVerifyCA
	SSLModeVerifyIdentity
)

func (ExternalDataSourceSSLVerificationMode) String

type GetBackupRequest

type GetBackupRequest struct {
	Organization string
	Database     string
	Branch       string
	Backup       string
}

type GetBranchInfrastructureRequest

type GetBranchInfrastructureRequest struct {
	Organization string
	Database     string
	Branch       string
}

GetBranchInfrastructureRequest encapsulates the request for getting branch infrastructure.

type GetDatabaseBranchPasswordRequest

type GetDatabaseBranchPasswordRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Name         string `json:"name"`
	PasswordId   string
}

GetDatabaseBranchPasswordRequest encapsulates the request for listing all passwords for a given database branch.

type GetDatabaseBranchRequest

type GetDatabaseBranchRequest struct {
	Organization string
	Database     string
	Branch       string
}

GetDatabaseBranchRequest encapsulates the request for getting a single database branch for a database.

type GetDatabaseRequest

type GetDatabaseRequest struct {
	Organization string
	Database     string
}

DatabaseRequest encapsulates the request for getting a single database.

type GetDeployOperationsRequest

type GetDeployOperationsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
}

GetDeployOperationsRequest encapsulates the request for getting a deploy operation for a deploy request.

type GetDeployRequestRequest

type GetDeployRequestRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
}

GetDeployRequest encapsulates the request for getting a single deploy request.

type GetImportStatusRequest

type GetImportStatusRequest struct {
	Organization string
	Database     string
}

type GetKeyspaceRequest

type GetKeyspaceRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
	Full         bool   `json:"-"`
}

type GetKeyspaceVSchemaRequest

type GetKeyspaceVSchemaRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
}

type GetOrganizationRequest

type GetOrganizationRequest struct {
	Organization string
}

GetOrganizationRequest encapsulates the request for getting a single organization.

type GetPlannedReparentShardRequest

type GetPlannedReparentShardRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	ID           string `json:"-"`
}

GetPlannedReparentShardRequest is a request for retrieving a planned reparent shard operation.

type GetPostgresBranchChangeRequest added in v0.304.0

type GetPostgresBranchChangeRequest struct {
	Organization string
	Database     string
	Branch       string
	ID           string
}

GetPostgresBranchChangeRequest encapsulates the request to get a single change request for a Postgres branch.

type GetPostgresBranchRequest

type GetPostgresBranchRequest struct {
	Organization string
	Database     string
	Branch       string
}

GetPostgresBranchRequest encapsulates the request to get a specific Postgres branch.

type GetPostgresRoleRequest

type GetPostgresRoleRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	RoleId       string
}

GetPostgresRoleRequest encapsulates the request for getting a specific role for a given database branch.

type GetQueryPatternsReportRequest

type GetQueryPatternsReportRequest struct {
	Organization string
	Database     string
	Branch       string
	Report       string
}

type GetSchemaRecommendationRequest

type GetSchemaRecommendationRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	ID           string `json:"-"`
}

GetSchemaRecommendationRequest is the request for getting a schema recommendation.

type GetServiceTokenAccessRequest

type GetServiceTokenAccessRequest struct {
	Organization string `json:"-"`
	ID           string `json:"-"`
}

type GetTrafficBudgetRequest

type GetTrafficBudgetRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	BudgetID     string `json:"-"`
}

GetTrafficBudgetRequest is the request for getting a traffic budget.

type GetVtctldOperationRequest

type GetVtctldOperationRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	ID           string `json:"-"`
}

GetVtctldOperationRequest is a request for retrieving a vtctld operation.

type GetWebhookRequest

type GetWebhookRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	ID           string `json:"-"`
}

GetWebhookRequest is the request for getting a webhook.

type GetWorkflowRequest

type GetWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type IndexUsage added in v0.307.0

type IndexUsage struct {
	Name    string  `json:"name"`
	Count   int64   `json:"count"`
	Percent float64 `json:"percent"`
}

IndexUsage records how often an index served a query pattern.

type Keyspace

type Keyspace struct {
	ID                               string                            `json:"id"`
	Name                             string                            `json:"name"`
	Shards                           int                               `json:"shards"`
	Sharded                          bool                              `json:"sharded"`
	Replicas                         uint64                            `json:"replicas"`
	ExtraReplicas                    uint64                            `json:"extra_replicas"`
	ResizePending                    bool                              `json:"resize_pending"`
	Resizing                         bool                              `json:"resizing"`
	Ready                            bool                              `json:"ready"`
	ClusterSize                      string                            `json:"cluster_name"`
	CreatedAt                        time.Time                         `json:"created_at"`
	UpdatedAt                        time.Time                         `json:"updated_at"`
	VReplicationFlags                *VReplicationFlags                `json:"vreplication_flags"`
	ReplicationDurabilityConstraints *ReplicationDurabilityConstraints `json:"replication_durability_constraints"`
	ReadOnlyRegions                  []*ReadOnlyRegionKeyspace         `json:"read_only_regions"`
}

type KeyspaceResizeRequest

type KeyspaceResizeRequest struct {
	ID    string `json:"id"`
	State string `json:"state"`
	Actor *Actor `json:"actor"`

	ClusterSize         string `json:"cluster_name"`
	PreviousClusterSize string `json:"previous_cluster_name"`

	Replicas         uint `json:"replicas"`
	ExtraReplicas    uint `json:"extra_replicas"`
	PreviousReplicas uint `json:"previous_replicas"`

	UpdatedAt   time.Time  `json:"updated_at"`
	CreatedAt   time.Time  `json:"created_at"`
	StartedAt   *time.Time `json:"started_at"`
	CompletedAt *time.Time `json:"completed_at"`
}

type KeyspaceResizeStatusRequest

type KeyspaceResizeStatusRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
}

type KeyspaceRollout

type KeyspaceRollout struct {
	Name  string `json:"name"`
	State string `json:"state"`

	Shards []ShardRollout `json:"shards"`
}

type KeyspaceRolloutStatusRequest

type KeyspaceRolloutStatusRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
}

type KillProcessRequest

type KillProcessRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"keyspace,omitempty"`
	Shard        string `json:"shard,omitempty"`
	ID           int64  `json:"id"`
	Kind         string `json:"kind,omitempty"`
}

KillProcessRequest kills a single process by ID on a branch. Keyspace/Shard follow the same disambiguation rules as ProcesslistRequest. Kind is either "connection" (default) or "query".

type KillProcessResult

type KillProcessResult struct {
	Success  bool   `json:"success"`
	Keyspace string `json:"keyspace"`
	Shard    string `json:"shard"`
	Tablet   string `json:"tablet"`
	ID       int64  `json:"id"`
	Kind     string `json:"kind"`
}

KillProcessResult is the response from killing a process.

type LintSchemaRequest

type LintSchemaRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

LintSchemaRequest encapsulates the request for linting a branch's schema.

type ListAnomaliesRequest added in v0.307.0

type ListAnomaliesRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListAnomaliesRequest is the request for listing anomalies for a branch.

type ListAuditLogsRequest

type ListAuditLogsRequest struct {
	Organization string

	// Events can be used to filter out only the given audit log events.
	Events []AuditLogEvent
}

ListAuditLogsRequest encapsulates the request for listing the audit logs of an organization.

type ListBackupsRequest

type ListBackupsRequest struct {
	Organization string
	Database     string
	Branch       string
}

type ListBranchClusterSKUsRequest

type ListBranchClusterSKUsRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListBranchClusterSKUsRequest encapsulates the request for getting a list of Cluster SKUs for a branch.

type ListBranchResizesRequest added in v0.310.0

type ListBranchResizesRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListBranchResizesRequest encapsulates a request to list branch VTGate resize requests.

type ListBranchTabletsRequest

type ListBranchTabletsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	// Keyspace, if set, only returns tablets in this keyspace.
	Keyspace string `json:"-"`
	// Shard, if set, only returns tablets in this shard. It requires Keyspace
	// to also be set.
	Shard string `json:"-"`
	// TabletType, if set, only returns tablets of this type (e.g. "primary",
	// "replica", "rdonly").
	TabletType string `json:"-"`
	// TabletAliases, if set, only returns the tablets with these aliases (e.g.
	// "zone1-0000000100"). When set, the other filters are ignored.
	TabletAliases []string `json:"-"`
}

ListBranchTabletsRequest is a request for listing tablets on a branch.

type ListDatabaseBranchPasswordRequest

type ListDatabaseBranchPasswordRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListDatabaseBranchPasswordRequest encapsulates the request for listing all passwords for a given database branch.

type ListDatabaseBranchesRequest

type ListDatabaseBranchesRequest struct {
	Organization string
	Database     string
}

ListDatabaseBranchesRequest encapsulates the request for listing the branches of a database.

type ListDatabasesRequest

type ListDatabasesRequest struct {
	Organization string
}

ListDatabasesRequest encapsulates the request for listing all databases in an organization.

type ListDeployRequestsRequest

type ListDeployRequestsRequest struct {
	Organization string
	Database     string
	State        string
	Branch       string
	IntoBranch   string
}

ListDeployRequestsRequest gets the deploy requests for a specific database branch.

type ListKeyspacesRequest

type ListKeyspacesRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

type ListOption

type ListOption func(*ListOptions) error

func WithEventFilters

func WithEventFilters(events []AuditLogEvent) ListOption

WithEventFilters sets filters on a set of list filters from audit log events. For example, `audit_action:database.created`, `audit_action:database.deleted`, etc.

func WithLimit

func WithLimit(limit int) ListOption

WithLimit returns a ListOption that sets the "limit" URL parameter.

func WithPage

func WithPage(page int) ListOption

WithPage returns a ListOption that sets the "page" URL parameter.

func WithPerPage

func WithPerPage(perPage int) ListOption

WithPerPage returns a ListOption that sets the "per_page" URL paramter.

func WithPeriod added in v0.307.0

func WithPeriod(period string) ListOption

WithPeriod returns a ListOption that sets the "period" URL parameter (e.g. "1h", "24h").

func WithPostgreSQL

func WithPostgreSQL() ListOption

WithPostgreSQL returns a ListOption that sets the "postgresql" URL parameter.

func WithRates

func WithRates() ListOption

WithRates returns a ListOption that sets the "rates" URL parameter.

func WithRegion

func WithRegion(region string) ListOption

WithRegion returns a ListOption sets the "region" URL parameter.

func WithSearch added in v0.303.0

func WithSearch(search string) ListOption

WithSearch returns a ListOption that sets the "q" URL parameter.

func WithSort added in v0.307.0

func WithSort(sort, dir string) ListOption

WithSort returns a ListOption that sets the "sort" and "dir" URL parameters.

func WithStartingAfter

func WithStartingAfter(startingAfter string) ListOption

WithStartingAfter returns a ListOption that sets the "starting_after" URL parameter.

func WithStatus added in v0.303.0

func WithStatus(status string) ListOption

WithStatus returns a ListOption that sets the "status" URL parameter.

type ListOptions

type ListOptions struct {
	URLValues *url.Values
}

ListOptions are options for listing responses.

type ListOrganizationClusterSKUsRequest

type ListOrganizationClusterSKUsRequest struct {
	Organization string
}

ListOrganizationClusterSKUsRequest encapsulates the request for getting a list of Cluster SKUs for an organization.

type ListOrganizationRegionsRequest

type ListOrganizationRegionsRequest struct {
	Organization string
}

ListRegionsRequest encapsulates the request for getting a list of regions for an organization.

type ListPostgresBranchChangesRequest added in v0.304.0

type ListPostgresBranchChangesRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListPostgresBranchChangesRequest encapsulates the request to list change requests for a Postgres branch.

type ListPostgresBranchesRequest

type ListPostgresBranchesRequest struct {
	Organization string
	Database     string
}

ListPostgresBranchesRequest encapsulates the request to list Postgres branches for a database.

type ListPostgresParametersRequest added in v0.304.0

type ListPostgresParametersRequest struct {
	Organization string
	Database     string
	Branch       string

	// Extension filters parameters by whether they configure an extension.
	// Nil returns both.
	Extension *bool
	// Internal filters parameters by whether they are internal (immutable).
	// Nil returns both.
	Internal *bool
}

ListPostgresParametersRequest encapsulates the request to list the configuration parameters of a Postgres branch.

type ListPostgresRolesRequest

type ListPostgresRolesRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListPostgresRolesRequest encapsulates the request for listing all roles for a given database branch.

type ListQueryInsightsErrorsRequest added in v0.307.0

type ListQueryInsightsErrorsRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListQueryInsightsErrorsRequest is the request for listing query errors for a branch.

type ListQueryInsightsRequest added in v0.307.0

type ListQueryInsightsRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListQueryInsightsRequest is the request for listing query statistics for a branch.

type ListReadOnlyRegionsRequest added in v0.312.0

type ListReadOnlyRegionsRequest struct {
	Organization string
	Database     string
}

type ListRegionsRequest

type ListRegionsRequest struct{}

type ListSchemaRecommendationsRequest

type ListSchemaRecommendationsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
}

ListSchemaRecommendationsRequest is the request for listing schema recommendations.

type ListServiceTokenGrantsRequest

type ListServiceTokenGrantsRequest struct {
	Organization string `json:"-"`
	ID           string `json:"-"`
}

type ListServiceTokensRequest

type ListServiceTokensRequest struct {
	Organization string `json:"-"`
}

type ListTrafficBudgetsRequest

type ListTrafficBudgetsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

ListTrafficBudgetsRequest is the request for listing traffic budgets.

type ListWebhooksRequest

type ListWebhooksRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
}

ListWebhooksRequest is the request for listing webhooks.

type ListWorkflowsRequest

type ListWorkflowsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
}

type LookupVindexCancelRequest

type LookupVindexCancelRequest struct {
	Organization  string `json:"-"`
	Database      string `json:"-"`
	Branch        string `json:"-"`
	Name          string `json:"-"`
	TableKeyspace string `json:"table_keyspace"`
}

type LookupVindexCompleteRequest

type LookupVindexCompleteRequest struct {
	Organization  string `json:"-"`
	Database      string `json:"-"`
	Branch        string `json:"-"`
	Name          string `json:"-"`
	TableKeyspace string `json:"table_keyspace"`
	Keyspace      string `json:"keyspace,omitempty"`
}

type LookupVindexCreateRequest

type LookupVindexCreateRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	Name                         string   `json:"name"`
	TableKeyspace                string   `json:"table_keyspace"`
	Keyspace                     string   `json:"keyspace,omitempty"`
	TableOwner                   string   `json:"table_owner,omitempty"`
	TableName                    string   `json:"table_name,omitempty"`
	Type                         string   `json:"type,omitempty"`
	Cells                        []string `json:"cells,omitempty"`
	TabletTypes                  []string `json:"tablet_types,omitempty"`
	TabletTypesInPreferenceOrder *bool    `json:"tablet_types_in_preference_order,omitempty"`
	IgnoreNulls                  *bool    `json:"ignore_nulls,omitempty"`
	TableOwnerColumns            []string `json:"table_owner_columns,omitempty"`
	TableVindexType              string   `json:"table_vindex_type,omitempty"`
	ContinueAfterCopyWithOwner   *bool    `json:"continue_after_copy_with_owner,omitempty"`
}

type LookupVindexExternalizeRequest

type LookupVindexExternalizeRequest struct {
	Organization  string `json:"-"`
	Database      string `json:"-"`
	Branch        string `json:"-"`
	Name          string `json:"-"`
	TableKeyspace string `json:"table_keyspace"`
	Keyspace      string `json:"keyspace,omitempty"`
	Delete        *bool  `json:"delete,omitempty"`
}

type LookupVindexInternalizeRequest

type LookupVindexInternalizeRequest struct {
	Organization  string `json:"-"`
	Database      string `json:"-"`
	Branch        string `json:"-"`
	Name          string `json:"-"`
	TableKeyspace string `json:"table_keyspace"`
	Keyspace      string `json:"keyspace,omitempty"`
}

type LookupVindexService

LookupVindexService is an interface for interacting with the LookupVindex endpoints of the PlanetScale API.

type LookupVindexShowRequest

type LookupVindexShowRequest struct {
	Organization  string `json:"-"`
	Database      string `json:"-"`
	Branch        string `json:"-"`
	Name          string `json:"-"`
	TableKeyspace string `json:"-"`
}

type MakePlanetScalePrimaryRequest

type MakePlanetScalePrimaryRequest struct {
	Organization string
	Database     string
}

type MakePlanetScaleReplicaRequest

type MakePlanetScaleReplicaRequest struct {
	Organization string
	Database     string
}

type MaterializeCancelRequest

type MaterializeCancelRequest struct {
	Organization     string `json:"-"`
	Database         string `json:"-"`
	Branch           string `json:"-"`
	Workflow         string `json:"-"`
	TargetKeyspace   string `json:"target_keyspace"`
	KeepData         *bool  `json:"keep_data,omitempty"`
	KeepRoutingRules *bool  `json:"keep_routing_rules,omitempty"`
}

MaterializeCancelRequest is a request for canceling a Materialize workflow.

type MaterializeCreateRequest

type MaterializeCreateRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	Workflow                     string          `json:"workflow"`
	TargetKeyspace               string          `json:"target_keyspace"`
	SourceKeyspace               string          `json:"source_keyspace"`
	TableSettings                json.RawMessage `json:"table_settings"`
	Cells                        []string        `json:"cells,omitempty"`
	ReferenceTables              []string        `json:"reference_tables,omitempty"`
	TabletTypes                  []string        `json:"tablet_types,omitempty"`
	StopAfterCopy                *bool           `json:"stop_after_copy,omitempty"`
	TabletTypesInPreferenceOrder *bool           `json:"tablet_types_in_preference_order,omitempty"`
	DeferSecondaryKeys           *bool           `json:"defer_secondary_keys,omitempty"`
	AtomicCopy                   *bool           `json:"atomic_copy,omitempty"`
	OnDDL                        string          `json:"on_ddl,omitempty"`
	SourceTimeZone               string          `json:"source_time_zone,omitempty"`
}

MaterializeCreateRequest is a request for creating a Materialize workflow.

type MaterializeService

MaterializeService is an interface for interacting with the Materialize endpoints of the PlanetScale API.

type MaterializeShowRequest

type MaterializeShowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	Branch         string `json:"-"`
	Workflow       string `json:"-"`
	TargetKeyspace string `json:"-"`
	IncludeLogs    *bool  `json:"-"`
}

MaterializeShowRequest is a request for showing a Materialize workflow.

type MaterializeStartRequest

type MaterializeStartRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	Branch         string `json:"-"`
	Workflow       string `json:"-"`
	TargetKeyspace string `json:"target_keyspace"`
}

MaterializeStartRequest is a request for starting a Materialize workflow.

type MaterializeStopRequest

type MaterializeStopRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	Branch         string `json:"-"`
	Workflow       string `json:"-"`
	TargetKeyspace string `json:"target_keyspace"`
}

MaterializeStopRequest is a request for stopping a Materialize workflow.

type MoveTablesCancelRequest

type MoveTablesCancelRequest struct {
	Organization     string `json:"-"`
	Database         string `json:"-"`
	Branch           string `json:"-"`
	Workflow         string `json:"-"`
	TargetKeyspace   string `json:"target_keyspace"`
	KeepData         *bool  `json:"keep_data,omitempty"`
	KeepRoutingRules *bool  `json:"keep_routing_rules,omitempty"`
}

MoveTablesCancelRequest is a request for canceling a MoveTables workflow.

type MoveTablesCompleteRequest

type MoveTablesCompleteRequest struct {
	Organization     string `json:"-"`
	Database         string `json:"-"`
	Branch           string `json:"-"`
	Workflow         string `json:"-"`
	TargetKeyspace   string `json:"target_keyspace"`
	KeepData         *bool  `json:"keep_data,omitempty"`
	KeepRoutingRules *bool  `json:"keep_routing_rules,omitempty"`
	RenameTables     *bool  `json:"rename_tables,omitempty"`
	DryRun           *bool  `json:"dry_run,omitempty"`
}

MoveTablesCompleteRequest is a request for completing a MoveTables workflow.

type MoveTablesCreateRequest

type MoveTablesCreateRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	Workflow                     string   `json:"workflow"`
	TargetKeyspace               string   `json:"target_keyspace"`
	SourceKeyspace               string   `json:"source_keyspace"`
	Tables                       []string `json:"tables,omitempty"`
	AllTables                    *bool    `json:"all_tables,omitempty"`
	AutoStart                    *bool    `json:"auto_start,omitempty"`
	StopAfterCopy                *bool    `json:"stop_after_copy,omitempty"`
	DeferSecondaryKeys           *bool    `json:"defer_secondary_keys,omitempty"`
	OnDDL                        string   `json:"on_ddl,omitempty"`
	ShardedAutoIncrementHandling string   `json:"sharded_auto_increment_handling,omitempty"`
	GlobalKeyspace               string   `json:"global_keyspace,omitempty"`
	SourceTimeZone               string   `json:"source_time_zone,omitempty"`
	TenantID                     string   `json:"tenant_id,omitempty"`
	Cells                        []string `json:"cells,omitempty"`
	TabletTypes                  []string `json:"tablet_types,omitempty"`
	ExcludeTables                []string `json:"exclude_tables,omitempty"`
	AtomicCopy                   *bool    `json:"atomic_copy,omitempty"`
}

MoveTablesCreateRequest is a request for creating a MoveTables workflow.

type MoveTablesReverseTrafficRequest

type MoveTablesReverseTrafficRequest struct {
	Organization             string   `json:"-"`
	Database                 string   `json:"-"`
	Branch                   string   `json:"-"`
	Workflow                 string   `json:"-"`
	TargetKeyspace           string   `json:"target_keyspace"`
	TabletTypes              []string `json:"tablet_types,omitempty"`
	MaxReplicationLagAllowed *int64   `json:"max_replication_lag_allowed,omitempty"`
	DryRun                   *bool    `json:"dry_run,omitempty"`
}

MoveTablesReverseTrafficRequest is a request for reversing traffic for a MoveTables workflow.

type MoveTablesShowRequest

type MoveTablesShowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	Branch         string `json:"-"`
	Workflow       string `json:"-"`
	TargetKeyspace string `json:"-"`
}

MoveTablesShowRequest is a request for showing a MoveTables workflow.

type MoveTablesStatusRequest

type MoveTablesStatusRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	Branch         string `json:"-"`
	Workflow       string `json:"-"`
	TargetKeyspace string `json:"-"`
}

MoveTablesStatusRequest is a request for getting the status of a MoveTables workflow.

type MoveTablesSwitchTrafficRequest

type MoveTablesSwitchTrafficRequest struct {
	Organization              string   `json:"-"`
	Database                  string   `json:"-"`
	Branch                    string   `json:"-"`
	Workflow                  string   `json:"-"`
	TargetKeyspace            string   `json:"target_keyspace"`
	TabletTypes               []string `json:"tablet_types,omitempty"`
	MaxReplicationLagAllowed  *int64   `json:"max_replication_lag_allowed,omitempty"`
	DryRun                    *bool    `json:"dry_run,omitempty"`
	InitializeTargetSequences *bool    `json:"initialize_target_sequences,omitempty"`
}

MoveTablesSwitchTrafficRequest is a request for switching traffic for a MoveTables workflow.

type Organization

type Organization struct {
	Name                   string    `json:"name"`
	CreatedAt              time.Time `json:"created_at"`
	UpdatedAt              time.Time `json:"updated_at"`
	RemainingFreeDatabases int       `json:"free_databases_remaining"`
}

Organization represents a PlanetScale organization.

type OrganizationsService

OrganizationsService is an interface for communicating with the PlanetScale Organizations API endpoints.

type PasswordsService

DatabaseBranchPasswordsService is an interface for communicating with the PlanetScale Database Branch Passwords API endpoint.

type PerformDeployRequest

type PerformDeployRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
	InstantDDL   bool   `json:"instant_ddl"`
	Strategy     string `json:"strategy,omitempty"`
}

PerformDeployRequest is a request for approving and deploying a deploy request. NOTE: We deviate from naming convention here because we have a data model named DeployRequest already.

type PlannedReparentShardRequest

type PlannedReparentShardRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"keyspace"`
	Shard        string `json:"shard"`
	NewPrimary   string `json:"new_primary"`
}

PlannedReparentShardRequest is a request for creating a planned reparent shard operation.

type PlannedReparentShardService

PlannedReparentShardService is an interface for interacting with the PlannedReparentShard endpoints of the PlanetScale API.

type PostgresBranch

type PostgresBranch struct {
	ID                  string    `json:"id"`
	Name                string    `json:"name"`
	ClusterName         string    `json:"cluster_name"`
	ClusterDisplayName  string    `json:"cluster_display_name"`
	ClusterArchitecture string    `json:"cluster_architecture"`
	ClusterIOPS         int       `json:"cluster_iops"`
	State               string    `json:"state"`
	CreatedAt           time.Time `json:"created_at"`
	UpdatedAt           time.Time `json:"updated_at"`
	Actor               Actor     `json:"actor"`
	Production          bool      `json:"production"`
	Ready               bool      `json:"ready"`
	ParentBranch        string    `json:"parent_branch"`
	Region              Region    `json:"region"`
	Kind                string    `json:"kind"`
	Replicas            int       `json:"replicas"`
}

PostgresBranch represents a Postgres branch in the PlanetScale API.

type PostgresBranchClusterResizeRequest

type PostgresBranchClusterResizeRequest struct {
	ID    string `json:"id"`
	State string `json:"state"`

	ClusterName        string `json:"cluster_name"`
	ClusterDisplayName string `json:"cluster_display_name"`
	Replicas           int    `json:"replicas"`

	PreviousClusterName        string `json:"previous_cluster_name"`
	PreviousClusterDisplayName string `json:"previous_cluster_display_name"`
	PreviousReplicas           int    `json:"previous_replicas"`

	// Parameters and PreviousParameters are configuration parameter values
	// nested by namespace. Values are left untyped since the API returns
	// strings, numbers, and booleans depending on the parameter type.
	Parameters         map[string]map[string]any `json:"parameters"`
	PreviousParameters map[string]map[string]any `json:"previous_parameters"`

	StartedAt   *time.Time `json:"started_at"`
	CompletedAt *time.Time `json:"completed_at"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

PostgresBranchClusterResizeRequest represents an asynchronous Postgres branch cluster change (resize) request.

func (*PostgresBranchClusterResizeRequest) Finished added in v0.304.0

Finished reports whether the change request reached a terminal state.

type PostgresBranchInfrastructure

type PostgresBranchInfrastructure struct {
	State                           string                  `json:"state"`
	PrimaryName                     string                  `json:"primary_name"`
	PrimaryPromotedAt               *time.Time              `json:"primary_promoted_at"`
	VolumeModificationsBlockedUntil *time.Time              `json:"volume_modifications_blocked_until"`
	Nodes                           []*PostgresInfraNode    `json:"nodes"`
	Bouncers                        []*PostgresInfraBouncer `json:"bouncers"`
}

PostgresBranchInfrastructure represents the infrastructure (nodes and bouncers) for a Postgres branch.

type PostgresBranchSchema

type PostgresBranchSchema struct {
	Name string `json:"name"`
	Raw  string `json:"raw"`
	HTML string `json:"html"`
}

PostgresBranchSchema encapsulates the schema of a Postgres branch.

type PostgresBranchSchemaRequest

type PostgresBranchSchemaRequest struct {
	Organization string
	Database     string
	Branch       string
	Namespace    string `json:"-"`
}

PostgresBranchSchemaRequest encapsulates the request to get the schema of a Postgres branch.

type PostgresInfraBouncer

type PostgresInfraBouncer struct {
	ID              string                   `json:"id"`
	Name            string                   `json:"name"`
	Target          string                   `json:"target"`
	ReplicasPerCell int                      `json:"replicas_per_cell"`
	Region          Region                   `json:"region"`
	SKU             *PostgresInfraBouncerSKU `json:"sku"`
}

PostgresInfraBouncer represents a PgBouncer deployment in the branch infrastructure.

type PostgresInfraBouncerSKU

type PostgresInfraBouncerSKU struct {
	Name        string `json:"name"`
	DisplayName string `json:"display_name"`
	CPU         string `json:"cpu"`
	RAM         int64  `json:"ram"`
}

PostgresInfraBouncerSKU represents the size of a PgBouncer deployment.

type PostgresInfraDiskReplacement

type PostgresInfraDiskReplacement struct {
	Reason      string     `json:"reason"`
	Bytes       int64      `json:"bytes"`
	ScheduledAt *time.Time `json:"scheduled_at"`
}

PostgresInfraDiskReplacement represents a scheduled disk replacement for a Postgres node.

type PostgresInfraNode

type PostgresInfraNode struct {
	Name                         string                        `json:"name"`
	NormalizedName               string                        `json:"normalized_name"`
	Role                         string                        `json:"role"`
	AvailabilityZone             string                        `json:"availability_zone"`
	ClusterName                  string                        `json:"cluster_name"`
	ClusterDisplayName           string                        `json:"cluster_display_name"`
	PeersCount                   int                           `json:"peers_count"`
	VolumeUsageBytes             *int64                        `json:"volume_usage_bytes"`
	VolumeCapacityBytes          *int64                        `json:"volume_capacity_bytes"`
	VolumeShrinkThresholdPercent *float64                      `json:"volume_shrink_threshold_percent"`
	Region                       Region                        `json:"region"`
	DiskReplacement              *PostgresInfraDiskReplacement `json:"disk_replacement"`
}

PostgresInfraNode represents a single Postgres instance in the branch infrastructure.

type PostgresParameter added in v0.304.0

type PostgresParameter struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	DisplayName   string `json:"display_name"`
	Namespace     string `json:"namespace"`
	Category      string `json:"category"`
	Description   string `json:"description"`
	Extension     bool   `json:"extension"`
	Immutable     bool   `json:"immutable"`
	ParameterType string `json:"parameter_type"`
	DefaultValue  any    `json:"default_value"`
	Value         any    `json:"value"`
	Required      bool   `json:"required"`
	Restart       bool   `json:"restart"`

	// Min, Max, and Step are numbers for plain numeric parameters but strings
	// for byte- and time-typed ones (e.g. "8kB", "10s").
	Max     any      `json:"max,omitempty"`
	Min     any      `json:"min,omitempty"`
	Step    any      `json:"step,omitempty"`
	Options []string `json:"options,omitempty"`
	Units   []string `json:"units,omitempty"`
	URL     string   `json:"url"`

	CreatedAt *time.Time `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

PostgresParameter represents a configuration parameter of a Postgres branch.

type PostgresRole

type PostgresRole struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	AccessHostURL   string    `json:"access_host_url"`
	DatabaseName    string    `json:"database_name"`
	Password        string    `json:"password"`
	Actor           Actor     `json:"actor"`
	Username        string    `json:"username"`
	WithReplication bool      `json:"with_replication"`
	CreatedAt       time.Time `json:"created_at"`
}

PostgresRole represents a PostgreSQL role in PlanetScale.

type Process

type Process struct {
	ID      int64  `json:"id"`
	User    string `json:"user"`
	Host    string `json:"host"`
	DB      string `json:"db"`
	Command string `json:"command"`
	Time    int64  `json:"time"`
	State   string `json:"state"`
	Info    string `json:"info"`
}

Process is a single row from `SHOW FULL PROCESSLIST` on the resolved primary tablet.

type ProcesslistRequest

type ProcesslistRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
	Shard        string `json:"-"`
}

ProcesslistRequest lists the MySQL process list for a branch. Keyspace/Shard are only required to disambiguate multi-keyspace or sharded databases; for a single unsharded keyspace they may be left empty.

type ProcesslistResult

type ProcesslistResult struct {
	Keyspace  string    `json:"keyspace"`
	Shard     string    `json:"shard"`
	Tablet    string    `json:"tablet"`
	Processes []Process `json:"processes"`
}

ProcesslistResult is the response from showing the process list. It echoes the keyspace/shard/tablet that were resolved so the caller knows where the processes (and their IDs) live.

type ProcesslistService

type ProcesslistService interface {
	List(context.Context, *ProcesslistRequest) (*ProcesslistResult, error)
	Kill(context.Context, *KillProcessRequest) (*KillProcessResult, error)
}

ProcesslistService is an interface for viewing and killing MySQL processes on a Vitess branch.

type PromoteRequest

type PromoteRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

PromoteRequest encapsulates the request for promoting a request to production.

type QueryInsight added in v0.307.0

type QueryInsight struct {
	ID                     string       `json:"id"`
	Fingerprint            string       `json:"fingerprint"`
	NormalizedSQL          string       `json:"normalized_sql"`
	StatementType          string       `json:"statement_type"`
	Keyspace               string       `json:"keyspace"`
	Tables                 []string     `json:"tables"`
	IndexUsages            []IndexUsage `json:"index_usages"`
	QueryCount             int64        `json:"query_count"`
	ErrorCount             int64        `json:"error_count"`
	LastRunAt              time.Time    `json:"last_run_at"`
	TimePerQuery           float64      `json:"time_per_query"`
	P50Latency             float64      `json:"p50_latency"`
	P99Latency             float64      `json:"p99_latency"`
	MaxLatency             float64      `json:"max_latency"`
	SumRowsRead            int64        `json:"sum_rows_read"`
	SumRowsReturned        int64        `json:"sum_rows_returned"`
	SumRowsAffected        int64        `json:"sum_rows_affected"`
	RowsReadPerReturned    float64      `json:"rows_read_per_returned"`
	SumTotalDurationMillis float64      `json:"sum_total_duration_millis"`
	SumTotalDurationPct    float64      `json:"sum_total_duration_percent"`
	SumCPUDurationMillis   float64      `json:"sum_cpu_duration_millis"`
	SumIODurationMillis    float64      `json:"sum_io_duration_millis"`
	BlockCacheHitRatio     float64      `json:"block_cache_hit_ratio"`
	Multishard             bool         `json:"multishard"`
}

QueryInsight is an aggregated statistics record for a normalized query pattern on a branch.

type QueryInsightError added in v0.307.0

type QueryInsightError struct {
	ID                  string    `json:"id"`
	ErrorFingerprint    string    `json:"error_fingerprint"`
	StartedAt           time.Time `json:"started_at"`
	TotalDurationMillis float64   `json:"total_duration_millis"`
	TimePerQuery        float64   `json:"time_per_query"`
	ErrorCount          int64     `json:"error_count"`
	ErrorMessage        string    `json:"error_message"`
}

QueryInsightError is an aggregated error record for a query pattern on a branch.

type QueryInsightsService added in v0.307.0

type QueryInsightsService interface {
	ListQueries(context.Context, *ListQueryInsightsRequest, ...ListOption) ([]*QueryInsight, error)
	ListErrors(context.Context, *ListQueryInsightsErrorsRequest, ...ListOption) ([]*QueryInsightError, error)
	ListAnomalies(context.Context, *ListAnomaliesRequest, ...ListOption) ([]*Anomaly, error)
}

QueryInsightsService is an interface for communicating with the PlanetScale Query Insights API: aggregated query statistics, query errors, and detected anomalies for a database branch.

type QueryPatternsReport

type QueryPatternsReport struct {
	PublicID    string    `json:"id"`
	State       string    `json:"state"`
	Actor       *Actor    `json:"actor"`
	URL         string    `json:"url"`
	DownloadURL string    `json:"download_url"`
	CreatedAt   time.Time `json:"created_at"`
	FinishedAt  time.Time `json:"finished_at"`
}

QueryPatternsReport represents a query patterns report for a branch.

type QueryPatternsService

QueryPatternsService is an interface for communicating with the PlanetScale query patterns API endpoints.

type QueuedDeployment

type QueuedDeployment struct {
	ID                  string `json:"id"`
	State               string `json:"state"`
	DeployRequestNumber uint64 `json:"deploy_request_number"`
	IntoBranch          string `json:"into_branch"`

	Actor *Actor `json:"actor"`

	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	StartedAt  *time.Time `json:"started_at"`
	QueuedAt   *time.Time `json:"queued_at"`
	FinishedAt *time.Time `json:"finished_at"`
}

QueuedDeployment encapsulates a deployment that is in the queue.

type ReadOnlyRegion added in v0.312.0

type ReadOnlyRegion struct {
	ID          string    `json:"id"`
	DisplayName string    `json:"display_name"`
	Ready       bool      `json:"ready"`
	ReadyAt     time.Time `json:"ready_at"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Actor       *Actor    `json:"actor"`
	Region      Region    `json:"region"`
}

ReadOnlyRegion represents a Vitess read-only region for a database's default branch.

func FindReadOnlyRegion added in v0.312.0

func FindReadOnlyRegion(regions []*ReadOnlyRegion, name string) (*ReadOnlyRegion, error)

FindReadOnlyRegion matches a read-only region by public id, region slug, or display name.

type ReadOnlyRegionKeyspace added in v0.312.0

type ReadOnlyRegionKeyspace struct {
	Region             string `json:"region"`
	ClusterName        string `json:"cluster_name"`
	ClusterDisplayName string `json:"cluster_display_name"`
	Replicas           int    `json:"replicas"`
}

type ReadOnlyRegionsService added in v0.312.0

type ReadOnlyRegionsService interface {
	List(ctx context.Context, req *ListReadOnlyRegionsRequest, opts ...ListOption) ([]*ReadOnlyRegion, error)
}

ReadOnlyRegionsService lists read-only regions for a database.

type ReassignPostgresRoleObjectsRequest

type ReassignPostgresRoleObjectsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	RoleId       string `json:"-"`
	Successor    string `json:"successor"`
}

ReassignPostgresRoleObjectsRequest encapsulates the request for reassigning objects owned by one role to another role.

type RefreshSchemaRequest

type RefreshSchemaRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

RefreshSchemaRequest reflects the request needed to refresh a schema snapshot on a database branch.

type Region

type Region struct {
	Slug      string `json:"slug"`
	Provider  string `json:"provider"`
	Name      string `json:"display_name"`
	Location  string `json:"location"`
	Enabled   bool   `json:"enabled"`
	IsDefault bool   `json:"current_default"`
}

type RegionsService

type RegionsService interface {
	List(ctx context.Context, req *ListRegionsRequest) ([]*Region, error)
}

type RenewDatabaseBranchPasswordRequest

type RenewDatabaseBranchPasswordRequest struct {
	Organization string
	Database     string
	Branch       string
	PasswordId   string
}

RenewDatabaseBranchPasswordRequest encapsulates the request for renewing a password for a given database branch.

type RenewPostgresRoleRequest

type RenewPostgresRoleRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	RoleId       string `json:"-"`
}

RenewPostgresRoleRequest encapsulates the request for renewing role expiration for a database branch.

type ReplicationDurabilityConstraints

type ReplicationDurabilityConstraints struct {
	Strategy string `json:"strategy"`
}

type RequestOption

type RequestOption func(*requestOptions)

RequestOption allows for customizing HTTP requests

func WithQueryParams

func WithQueryParams(params url.Values) RequestOption

WithQueryParams sets query parameters for the request

type ResetDefaultRoleRequest

type ResetDefaultRoleRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

ResetDefaultRoleRequest encapsulates the request for resetting the default role of a Postgres database branch.

type ResetPostgresRolePasswordRequest

type ResetPostgresRolePasswordRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	RoleId       string `json:"-"`
}

ResetPostgresRolePasswordRequest encapsulates the request for resetting a role's password for a database branch.

type ResizeBranchRequest added in v0.310.0

type ResizeBranchRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	VTGateSize                 string `json:"vtgate_size,omitempty"`
	VTGateCount                *int   `json:"vtgate_count,omitempty"`
	VTGateMaxCount             *int   `json:"vtgate_max_count,omitempty"`
	VTGateAutoscaling          *bool  `json:"vtgate_autoscaling,omitempty"`
	VTGateTargetCPUUtilization *int   `json:"vtgate_target_cpu_utilization,omitempty"`
}

ResizeBranchRequest encapsulates a request to resize a branch's VTGates.

type ResizeKeyspaceRequest

type ResizeKeyspaceRequest struct {
	Organization  string  `json:"-"`
	Database      string  `json:"-"`
	Branch        string  `json:"-"`
	Keyspace      string  `json:"-"`
	ExtraReplicas *uint   `json:"extra_replicas,omitempty"`
	ClusterSize   *string `json:"cluster_size,omitempty"`
}

type ResizePostgresBranchRequest

type ResizePostgresBranchRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	// ClusterSize is the fully-qualified cluster size SKU name to resize to,
	// e.g. "PS_10_GCP_X86". Use the values returned by ListClusterSKUs.
	ClusterSize string `json:"cluster_size,omitempty"`
	// Replicas is the desired number of replicas. Nil leaves it unchanged.
	Replicas *int `json:"replicas,omitempty"`
	// Parameters holds configuration parameter values nested by namespace,
	// e.g. {"pgconf": {"max_connections": "200"}}. Use the values returned by
	// ListParameters. Nil leaves parameters unchanged.
	Parameters map[string]map[string]string `json:"parameters,omitempty"`
}

ResizePostgresBranchRequest encapsulates the request to change a Postgres branch's cluster: its size, replica count, and/or configuration parameters. All change kinds are upserted into a single asynchronous change request via the branch changes API.

type RetryWorkflowRequest

type RetryWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type ReverseCutoverWorkflowRequest

type ReverseCutoverWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type ReverseTrafficWorkflowRequest

type ReverseTrafficWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type RevertDeployRequestRequest

type RevertDeployRequestRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
}

type ReviewAction

type ReviewAction int

ReviewAction defines the action for an individual review.

const (
	// Comment is used to comment a Review with a custom text.
	ReviewComment ReviewAction = iota

	// Approve is used to approve a Review.
	ReviewApprove
)

func (ReviewAction) String

func (r ReviewAction) String() string

type ReviewDeployRequestRequest

type ReviewDeployRequestRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`

	// CommentText represents the comment body to be posted
	CommentText string `json:"-"`

	// ReviewAction defines the action for an individual review.
	ReviewAction ReviewAction `json:"-"`
}

type RoutingRules

type RoutingRules struct {
	Raw  string `json:"raw"`
	HTML string `json:"html"`
}

type SchemaLintError

type SchemaLintError struct {
	LintError        string `json:"lint_error"`
	Keyspace         string `json:"keyspace_name"`
	Table            string `json:"table_name"`
	SubjectType      string `json:"subject_type"`
	ErrorDescription string `json:"error_description"`
	DocsURL          string `json:"docs_url"`
}

SchemaLintError represents an error with the branch's schema

type SchemaRecommendation

type SchemaRecommendation struct {
	ID                    string                 `json:"id"`
	HtmlURL               string                 `json:"html_url"`
	Title                 string                 `json:"title"`
	Table                 string                 `json:"table_name"`
	Keyspace              string                 `json:"keyspace"`
	DDLStatement          string                 `json:"ddl_statement"`
	Number                int                    `json:"number"`
	State                 string                 `json:"state"`
	RecommendationType    string                 `json:"recommendation_type"`
	CreatedAt             time.Time              `json:"created_at"`
	UpdatedAt             time.Time              `json:"updated_at"`
	AppliedAt             *time.Time             `json:"applied_at"`
	DismissedAt           *time.Time             `json:"dismissed_at"`
	ClosedByDeployRequest *ClosedByDeployRequest `json:"closed_by_deploy_request"`
	DismissedBy           *Actor                 `json:"dismissed_by"`
}

SchemaRecommendation represents a PlanetScale schema recommendation.

type SchemaRecommendationService

SchemaRecommendationService is an interface for communicating with the PlanetScale Schema recommendation API.

type ServiceToken

type ServiceToken struct {
	ID         string     `json:"id"`
	Type       string     `json:"type"`
	Token      string     `json:"token"`
	Name       *string    `json:"name"`
	CreatedAt  time.Time  `json:"created_at"`
	LastUsedAt *time.Time `json:"last_used_at"`
	ExpiresAt  *time.Time `json:"expires_at"`
}

type ServiceTokenAccess

type ServiceTokenAccess struct {
	ID       string               `json:"id"`
	Access   string               `json:"access"`
	Type     string               `json:"type"`
	Resource ServiceTokenResource `json:"resource"`
}

type ServiceTokenGrant

type ServiceTokenGrant struct {
	ID           string                     `json:"id"`
	ResourceName string                     `json:"resource_name"`
	ResourceType string                     `json:"resource_type"`
	ResourceID   string                     `json:"resource_id"`
	Accesses     []*ServiceTokenGrantAccess `json:"accesses"`
}

type ServiceTokenGrantAccess

type ServiceTokenGrantAccess struct {
	Access      string `json:"access"`
	Description string `json:"description"`
}

type ServiceTokenResource

type ServiceTokenResource struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

type ServiceTokenService

ServiceTokenService is an interface for communicating with the PlanetScale Service Token API.

type ShardRollout

type ShardRollout struct {
	Name  string `json:"name"`
	State string `json:"state"`

	LastRolloutStartedAt  time.Time `json:"last_rollout_started_at"`
	LastRolloutFinishedAt time.Time `json:"last_rollout_finished_at"`
}

type SkipRevertDeployRequestRequest

type SkipRevertDeployRequestRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Number       uint64 `json:"-"`
}

type StartDataImportRequest

type StartDataImportRequest struct {
	Organization string           `json:"organization"`
	Database     string           `json:"database_name"`
	Connection   DataImportSource `json:"connection"`
	Region       string           `json:"region"`
	Plan         string           `json:"plan"`
	MaxPoolSize  int              `json:"max_pool_size"`
}

type StorageConfig

type StorageConfig struct {
	MinimumStorageBytes *int64 `json:"minimum_storage_bytes,omitempty"`
	MaximumStorageBytes *int64 `json:"maximum_storage_bytes,omitempty"`
}

StorageConfig represents storage size configuration for a database or branch.

type SwitchPrimariesWorkflowRequest

type SwitchPrimariesWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type SwitchReplicasWorkflowRequest

type SwitchReplicasWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type Tablet

type Tablet struct {
	Alias string `json:"alias"`
	Role  string `json:"role"`
	Cell  string `json:"cell"`
}

Tablet represents an individual vttablet.

type TabletGroup

type TabletGroup struct {
	Type     string   `json:"type"`
	Keyspace string   `json:"keyspace"`
	Shard    string   `json:"shard"`
	Tablets  []Tablet `json:"tablets"`
}

TabletGroup represents a group of tablets in a keyspace/shard.

type TestDataImportSourceRequest

type TestDataImportSourceRequest struct {
	Organization string           `json:"organization"`
	Database     string           `json:"database_name"`
	Connection   DataImportSource `json:"connection"`
}

type TestDataImportSourceResponse

type TestDataImportSourceResponse struct {
	CanConnect           bool   `json:"can_connect"`
	ShouldUpgradePlan    bool   `json:"should_upgrade"`
	SuggestedPlan        string `json:"suggested_plan"`
	SuggestedBillingPlan BillingPlan
	ConnectError         string                            `json:"error"`
	Errors               []*DataSourceIncompatibilityError `json:"lint_errors"`
	MaxPoolSize          int                               `json:"max_pool_size"`
}

type TestWebhookRequest

type TestWebhookRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	ID           string `json:"-"`
}

TestWebhookRequest is the request for testing a webhook.

type TrafficBudget

type TrafficBudget struct {
	ID   string `json:"id"`
	Type string `json:"type"`

	Name string `json:"name"`
	Mode string `json:"mode"`

	Capacity         *int `json:"capacity"`
	Rate             *int `json:"rate"`
	Burst            *int `json:"burst"`
	Concurrency      *int `json:"concurrency"`
	WarningThreshold *int `json:"warning_threshold"`

	Rules []TrafficRule `json:"rules"`

	Actor     Actor     `json:"actor"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

TrafficBudget represents a traffic budget on a branch.

type TrafficBudgetsService

TrafficBudgetsService communicates with the PlanetScale traffic budgets API.

type TrafficRule

type TrafficRule struct {
	ID                   string           `json:"id"`
	Type                 string           `json:"type"`
	Kind                 string           `json:"kind"`
	Fingerprint          *string          `json:"fingerprint"`
	Keyspace             *string          `json:"keyspace"`
	Tags                 []TrafficRuleTag `json:"tags"`
	Actor                Actor            `json:"actor"`
	SyntaxHighlightedSQL string           `json:"syntax_highlighted_sql"`
	CreatedAt            time.Time        `json:"created_at"`
	UpdatedAt            time.Time        `json:"updated_at"`
}

TrafficRule represents a rule for a traffic budget.

type TrafficRuleTag

type TrafficRuleTag struct {
	Type   string `json:"type"`
	KeyID  string `json:"key_id"`
	Key    string `json:"key"`
	Value  string `json:"value"`
	Source string `json:"source"`
}

TrafficRuleTag is a tag attached to a traffic rule.

type TrafficRulesService

type TrafficRulesService interface {
	Create(context.Context, *CreateTrafficRuleRequest) (*TrafficRule, error)
	Delete(context.Context, *DeleteTrafficRuleRequest) error
}

TrafficRulesService communicates with the PlanetScale traffic rules API.

type UpdateBranchRoutingRulesRequest

type UpdateBranchRoutingRulesRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	RoutingRules string `json:"routing_rules"`
}

type UpdateKeyspaceSettingsRequest

type UpdateKeyspaceSettingsRequest struct {
	Organization                     string                            `json:"-"`
	Database                         string                            `json:"-"`
	Branch                           string                            `json:"-"`
	Keyspace                         string                            `json:"-"`
	ReplicationDurabilityConstraints *ReplicationDurabilityConstraints `json:"replication_durability_constraints,omitempty"`
	VReplicationFlags                *VReplicationFlags                `json:"vreplication_flags,omitempty"`
}

type UpdateKeyspaceVSchemaRequest

type UpdateKeyspaceVSchemaRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
	VSchema      string `json:"vschema"`
}

type UpdatePostgresRoleRequest

type UpdatePostgresRoleRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	RoleId       string `json:"-"`
	Name         string `json:"name"`
}

UpdatePostgresRoleRequest encapsulates the request for updating a role name for a database branch.

type UpdateTrafficBudgetRequest

type UpdateTrafficBudgetRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	BudgetID     string `json:"-"`

	Name *string `json:"name,omitempty"`
	Mode *string `json:"mode,omitempty"`

	Capacity         *int `json:"capacity,omitempty"`
	Rate             *int `json:"rate,omitempty"`
	Burst            *int `json:"burst,omitempty"`
	Concurrency      *int `json:"concurrency,omitempty"`
	WarningThreshold *int `json:"warning_threshold,omitempty"`

	Rules *[]CreateTrafficBudgetRuleRequest `json:"rules,omitempty"`
}

UpdateTrafficBudgetRequest is the request for updating a traffic budget.

type UpdateWebhookRequest

type UpdateWebhookRequest struct {
	Organization string   `json:"-"`
	Database     string   `json:"-"`
	ID           string   `json:"-"`
	URL          *string  `json:"url,omitempty"`
	Enabled      *bool    `json:"enabled,omitempty"`
	Events       []string `json:"events,omitempty"`
}

UpdateWebhookRequest is the request for updating a webhook.

type UserShouldUpgradePlanError

type UserShouldUpgradePlanError struct{}

func (UserShouldUpgradePlanError) Error

type VDiffCreateRequest

type VDiffCreateRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Workflow     string `json:"-"`

	TargetKeyspace              string   `json:"target_keyspace"`
	AutoRetry                   *bool    `json:"auto_retry,omitempty"`
	AutoStart                   *bool    `json:"auto_start,omitempty"`
	DebugQuery                  bool     `json:"debug_query,omitempty"`
	OnlyPKs                     bool     `json:"only_pks,omitempty"`
	UpdateTableStats            bool     `json:"update_table_stats,omitempty"`
	Verbose                     bool     `json:"verbose,omitempty"`
	Tables                      []string `json:"tables,omitempty"`
	TabletTypes                 []string `json:"tablet_types,omitempty"`
	TabletSelectionPreference   string   `json:"tablet_selection_preference,omitempty"`
	FilteredReplicationWaitTime *int     `json:"filtered_replication_wait_time,omitempty"`
	MaxReportSampleRows         *int     `json:"max_report_sample_rows,omitempty"`
	MaxExtraRowsToCompare       *int     `json:"max_extra_rows_to_compare,omitempty"`
	RowDiffColumnTruncateAt     *int     `json:"row_diff_column_truncate_at,omitempty"`
	Limit                       *int     `json:"limit,omitempty"`
}

type VDiffDeleteRequest

type VDiffDeleteRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	Branch         string `json:"-"`
	Workflow       string `json:"-"`
	UUID           string `json:"-"`
	TargetKeyspace string `json:"-"`
}

type VDiffListRequest

type VDiffListRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	Branch         string `json:"-"`
	Workflow       string `json:"-"`
	TargetKeyspace string `json:"-"`
}

type VDiffResumeRequest

type VDiffResumeRequest struct {
	Organization   string   `json:"-"`
	Database       string   `json:"-"`
	Branch         string   `json:"-"`
	Workflow       string   `json:"-"`
	UUID           string   `json:"-"`
	TargetKeyspace string   `json:"target_keyspace"`
	TargetShards   []string `json:"target_shards,omitempty"`
}

type VDiffService

VDiffService is an interface for interacting with the VDiff endpoints of the PlanetScale API.

type VDiffShowRequest

type VDiffShowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	Branch         string `json:"-"`
	Workflow       string `json:"-"`
	UUID           string `json:"-"`
	TargetKeyspace string `json:"-"`
}

type VDiffStopRequest

type VDiffStopRequest struct {
	Organization   string   `json:"-"`
	Database       string   `json:"-"`
	Branch         string   `json:"-"`
	Workflow       string   `json:"-"`
	UUID           string   `json:"-"`
	TargetKeyspace string   `json:"target_keyspace"`
	TargetShards   []string `json:"target_shards,omitempty"`
}

type VReplicationFlags

type VReplicationFlags struct {
	OptimizeInserts           bool `json:"optimize_inserts"`
	AllowNoBlobBinlogRowImage bool `json:"allow_no_blob_binlog_row_image"`
	VPlayerBatching           bool `json:"vplayer_batching"`
}

type VSchema

type VSchema struct {
	Raw  string `json:"raw"`
	HTML string `json:"html"`
}

VSchema represnts the VSchema for a branch keyspace

type VerifyDataWorkflowRequest

type VerifyDataWorkflowRequest struct {
	Organization   string `json:"-"`
	Database       string `json:"-"`
	WorkflowNumber uint64 `json:"-"`
}

type VitessBranchInfrastructure

type VitessBranchInfrastructure struct {
	Ready bool              `json:"ready"`
	Pods  []*BranchInfraPod `json:"pods"`
}

VitessBranchInfrastructure represents the infrastructure (pods) for a Vitess branch.

type VtctldCheckThrottlerRequest

type VtctldCheckThrottlerRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	TabletAlias string `json:"tablet_alias"`
	// AppName is the app to issue the check on behalf of (e.g. "online-ddl"). If
	// empty, the throttler's default app is used.
	AppName string `json:"app_name,omitempty"`
	// Scope is the scope of the check, either "shard" or "self". If empty, the
	// throttler's default scope is used.
	Scope string `json:"scope,omitempty"`
	// SkipRequestHeartbeats instructs the throttler not to renew its heartbeat
	// lease while serving this check.
	SkipRequestHeartbeats *bool `json:"skip_request_heartbeats,omitempty"`
	// OkIfNotExists instructs the throttler to return OK even if the requested
	// metric does not exist.
	OkIfNotExists *bool `json:"ok_if_not_exists,omitempty"`
}

VtctldCheckThrottlerRequest is a request for issuing a throttler check against a single tablet. The tablet is identified by its alias, as discovered via ListTablets.

type VtctldGetRoutingRulesRequest

type VtctldGetRoutingRulesRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
}

VtctldGetRoutingRulesRequest is a request for reading live routing rules from the cluster via vtctld.

type VtctldGetShardRequest

type VtctldGetShardRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
	Shard        string `json:"-"`
}

VtctldGetShardRequest is a request for reading a shard record from the cluster via vtctld.

type VtctldGetThrottlerStatusRequest

type VtctldGetThrottlerStatusRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	TabletAlias  string `json:"-"`
}

VtctldGetThrottlerStatusRequest is a request for reading the tablet throttler status from a single tablet. The tablet is identified by its alias, as discovered via ListTablets.

type VtctldListKeyspacesRequest

type VtctldListKeyspacesRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Name         string `json:"-"`
}

type VtctldListWorkflowsRequest

type VtctldListWorkflowsRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Keyspace     string `json:"-"`
	Workflow     string `json:"-"`
	IncludeLogs  *bool  `json:"-"`
}

type VtctldOperation

type VtctldOperation struct {
	ID          string          `json:"id"`
	Type        string          `json:"type"`
	Action      string          `json:"action"`
	Timeout     int             `json:"timeout"`
	CreatedAt   time.Time       `json:"created_at"`
	CompletedAt *time.Time      `json:"completed_at"`
	State       string          `json:"state"`
	Completed   bool            `json:"completed"`
	Metadata    json.RawMessage `json:"metadata"`
	Result      json.RawMessage `json:"result"`
	Error       string          `json:"error"`
}

VtctldOperation represents a generic vtctld operation resource.

type VtctldOperationReference

type VtctldOperationReference struct {
	ID string `json:"id"`
}

VtctldOperationReference identifies an accepted vtctld operation that can be polled later.

type VtctldRefreshStateByShardRequest

type VtctldRefreshStateByShardRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	Keyspace string   `json:"keyspace"`
	Shard    string   `json:"shard"`
	Cells    []string `json:"cells,omitempty"`
}

VtctldRefreshStateByShardRequest reloads tablet records for all tablets in a shard via vtctld.

type VtctldSetShardTabletControlRequest

type VtctldSetShardTabletControlRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	Keyspace            string   `json:"keyspace"`
	Shard               string   `json:"shard"`
	TabletType          string   `json:"tablet_type"`
	Cells               []string `json:"cells,omitempty"`
	DeniedTables        []string `json:"denied_tables,omitempty"`
	Remove              *bool    `json:"remove,omitempty"`
	DisableQueryService *bool    `json:"disable_query_service,omitempty"`
}

VtctldSetShardTabletControlRequest is a request for updating shard tablet controls via vtctld.

type VtctldStartWorkflowRequest

type VtctldStartWorkflowRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Workflow     string `json:"-"`
	Keyspace     string `json:"keyspace"`
}

VtctldStartWorkflowRequest is a request for starting a workflow.

type VtctldStopWorkflowRequest

type VtctldStopWorkflowRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	Workflow     string `json:"-"`
	Keyspace     string `json:"keyspace"`
}

VtctldStopWorkflowRequest is a request for stopping a workflow.

type VtctldThrottledAppConfig

type VtctldThrottledAppConfig struct {
	// Name is the app to throttle (e.g. "online-ddl", "vreplication", or an
	// Online DDL migration UUID).
	Name string `json:"name"`
	// Ratio is the fraction of operations to throttle for the app, 0.00-1.00 in
	// increments of 0.01.
	Ratio *float64 `json:"ratio,omitempty"`
	// ExpireAt is an optional RFC3339 expiration time for the app rule. It must
	// be in the future. Omit to throttle until changed.
	ExpireAt string `json:"expire_at,omitempty"`
}

VtctldThrottledAppConfig configures a single throttled app rule for UpdateThrottlerConfig.

type VtctldUpdateThrottlerConfigRequest

type VtctldUpdateThrottlerConfigRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`

	Keyspace string `json:"keyspace"`
	// Enabled controls whether the tablet throttler is enabled for the keyspace.
	// Omit to leave the enable state unchanged.
	Enabled *bool `json:"enabled,omitempty"`
	// Threshold is the threshold for the default throttler check (replication
	// lag in seconds). It must be >= 0. Omit to leave the existing threshold
	// unchanged.
	Threshold *float64 `json:"threshold,omitempty"`
	// Apps configures zero or more per-app throttling rules.
	Apps []VtctldThrottledAppConfig `json:"apps,omitempty"`
	// UnthrottleApps names apps whose throttled-app rules should be removed.
	UnthrottleApps []string `json:"unthrottle_apps,omitempty"`
	// AppCheckedMetrics assigns metrics to check per app name
	// (e.g. {"rowstreamer": ["lag", "loadavg"]}).
	AppCheckedMetrics map[string][]string `json:"app_checked_metrics,omitempty"`
}

VtctldUpdateThrottlerConfigRequest is a request for updating the tablet throttler configuration for a keyspace.

type Webhook

type Webhook struct {
	ID              string    `json:"id"`
	URL             string    `json:"url"`
	Secret          string    `json:"secret"`
	Enabled         bool      `json:"enabled"`
	LastSentResult  string    `json:"last_sent_result"`
	LastSentSuccess bool      `json:"last_sent_success"`
	LastSentAt      time.Time `json:"last_sent_at"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	Events          []string  `json:"events"`
}

Webhook represents a PlanetScale webhook.

type WebhooksService

WebhooksService is an interface for communicating with the PlanetScale Webhooks API.

type Workflow

type Workflow struct {
	ID                  string     `json:"id"`
	Name                string     `json:"name"`
	Number              uint64     `json:"number"`
	State               string     `json:"state"`
	CreatedAt           time.Time  `json:"created_at"`
	UpdatedAt           time.Time  `json:"updated_at"`
	StartedAt           *time.Time `json:"started_at"`
	CompletedAt         *time.Time `json:"completed_at"`
	CancelledAt         *time.Time `json:"cancelled_at"`
	ReversedAt          *time.Time `json:"reversed_at"`
	RetriedAt           *time.Time `json:"retried_at"`
	DataCopyCompletedAt *time.Time `json:"data_copy_completed_at"`
	CutoverAt           *time.Time `json:"cutover_at"`
	ReplicasSwitched    bool       `json:"replicas_switched"`
	PrimariesSwitched   bool       `json:"primaries_switched"`
	SwitchReplicasAt    *time.Time `json:"switch_replicas_at"`
	SwitchPrimariesAt   *time.Time `json:"switch_primaries_at"`
	VerifyDataAt        *time.Time `json:"verify_data_at"`

	Branch         DatabaseBranch `json:"branch"`
	SourceKeyspace Keyspace       `json:"source_keyspace"`
	TargetKeyspace Keyspace       `json:"target_keyspace"`

	Actor             Actor  `json:"actor"`
	VerifyDataBy      *Actor `json:"verify_data_by"`
	ReversedBy        *Actor `json:"reversed_by"`
	SwitchReplicasBy  *Actor `json:"switch_replicas_by"`
	SwitchPrimariesBy *Actor `json:"switch_primaries_by"`
	CancelledBy       *Actor `json:"cancelled_by"`
	CompletedBy       *Actor `json:"completed_by"`
	RetriedBy         *Actor `json:"retried_by"`
	CutoverBy         *Actor `json:"cutover_by"`
	ReversedCutoverBy *Actor `json:"reversed_cutover_by"`

	Streams []*WorkflowStream `json:"streams"`
	Tables  []*WorkflowTable  `json:"tables"`
	VDiff   *WorkflowVDiff    `json:"vdiff"`
}

type WorkflowStream

type WorkflowStream struct {
	PublicID             string              `json:"id"`
	State                string              `json:"state"`
	CreatedAt            time.Time           `json:"created_at"`
	UpdatedAt            time.Time           `json:"updated_at"`
	TargetShard          string              `json:"target_shard"`
	SourceShard          string              `json:"source_shard"`
	Position             string              `json:"position"`
	StopPosition         string              `json:"stop_position"`
	RowsCopied           int64               `json:"rows_copied"`
	ComponentThrottled   *string             `json:"component_throttled"`
	ComponentThrottledAt *time.Time          `json:"component_throttled_at"`
	PrimaryServing       bool                `json:"primary_serving"`
	Info                 string              `json:"info"`
	Logs                 []WorkflowStreamLog `json:"logs"`
}

type WorkflowStreamLog

type WorkflowStreamLog struct {
	PublicID  string    `json:"id"`
	State     string    `json:"state"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Message   string    `json:"message"`
	LogType   string    `json:"log_type"`
}

type WorkflowTable

type WorkflowTable struct {
	PublicID       string    `json:"id"`
	Name           string    `json:"name"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	RowsCopied     uint64    `json:"rows_copied"`
	RowsTotal      uint64    `json:"rows_total"`
	RowsPercentage uint      `json:"rows_percentage"`
}

type WorkflowVDiff

type WorkflowVDiff struct {
	PublicID           string                     `json:"id"`
	State              string                     `json:"state"`
	CreatedAt          time.Time                  `json:"created_at"`
	UpdatedAt          time.Time                  `json:"updated_at"`
	StartedAt          *time.Time                 `json:"started_at"`
	CompletedAt        *time.Time                 `json:"completed_at"`
	HasMismatch        bool                       `json:"has_mismatch"`
	ProgressPercentage uint                       `json:"progress_percentage"`
	EtaSeconds         uint64                     `json:"eta_seconds"`
	TableReports       []WorkflowVDiffTableReport `json:"table_reports"`
}

type WorkflowVDiffTableReport

type WorkflowVDiffTableReport struct {
	PublicID                   string        `json:"id"`
	TableName                  string        `json:"table_name"`
	Shard                      string        `json:"shard"`
	MismatchedRowsCount        int64         `json:"mismatched_rows_count"`
	ExtraSourceRowsCount       int64         `json:"extra_source_rows_count"`
	ExtraTargetRowsCount       int64         `json:"extra_target_rows_count"`
	ExtraSourceRows            []interface{} `json:"extra_source_rows"`
	ExtraTargetRows            []interface{} `json:"extra_target_rows"`
	MismatchedRows             []interface{} `json:"mismatched_rows"`
	SampleExtraSourceRowsQuery string        `json:"sample_extra_source_rows_query"`
	SampleExtraTargetRowsQuery string        `json:"sample_extra_target_rows_query"`
	SampleMismatchedRowsQuery  string        `json:"sample_mismatched_rows_query"`
	CreatedAt                  time.Time     `json:"created_at"`
	UpdatedAt                  time.Time     `json:"updated_at"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL