planetscale

package
v0.104.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 19 Imported by: 5

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func NewAuditLogsService added in v0.35.0

func NewAuditLogsService(client *Client) *auditlogsService

func NewBackupsService

func NewBackupsService(client *Client) *backupsService

func NewCertificatesService added in v0.51.0

func NewCertificatesService(client *Client) *certificatesService

func NewDatabaseBranchesService

func NewDatabaseBranchesService(client *Client) *databaseBranchesService

func NewDatabasesService

func NewDatabasesService(client *Client) *databasesService

func NewDeployRequestsService

func NewDeployRequestsService(client *Client) *deployRequestsService

func NewOrganizationsService

func NewOrganizationsService(client *Client) *organizationsService

func NewPasswordsService added in v0.40.0

func NewPasswordsService(client *Client) *passwordsService

func NewRegionsSevice added in v0.29.0

func NewRegionsSevice(client *Client) *regionsService

Types

type Actor added in v0.83.0

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 ApplyDeployRequestRequest added in v0.71.0

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

type AuditLog added in v0.35.0

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 added in v0.35.0

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 added in v0.35.0

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 added in v0.71.0

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 added in v0.62.0

type BillingPlan int
const (
	HobbyPlan BillingPlan = iota
	ScalerProPlan
)

func (BillingPlan) String added in v0.62.0

func (bp BillingPlan) String() string

type BranchKeyspacesRequest added in v0.68.0

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

type BranchRoutingRulesRequest added in v0.97.0

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 BranchVSchemaRequest added in v0.61.0

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

BranchVSchemaRequest encapsulates a request for getting a branch's VSchema.

type CancelDataImportRequest added in v0.58.0

type CancelDataImportRequest struct {
	Organization string
	Database     string
}

type CancelDeployRequestRequest

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

type CertificatesService

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

type Client

type Client struct {

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

	AuditLogs        AuditLogsService
	Backups          BackupsService
	Databases        DatabasesService
	DatabaseBranches DatabaseBranchesService
	DataImports      DataImportsService
	Organizations    OrganizationsService
	Passwords        PasswordsService
	Certificates     CertificatesService
	Regions          RegionsService
	DeployRequests   DeployRequestsService
	ServiceTokens    ServiceTokenService
	// 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 added in v0.67.0

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 added in v0.67.0

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 ClusterSize added in v0.88.0

type ClusterSize string
const (
	PS10  ClusterSize = "PS_10"
	PS20  ClusterSize = "PS_20"
	PS40  ClusterSize = "PS_40"
	PS80  ClusterSize = "PS_80"
	PS160 ClusterSize = "PS_160"
	PS320 ClusterSize = "PS_320"
	PS400 ClusterSize = "PS_400"
)

type CreateBackupRequest

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

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"`
}

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  ClusterSize `json:"cluster_size"`
	Plan         Plan        `json:"plan"`
}

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"`
}

type CreateServiceTokenRequest

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

type CursorPaginatedResponse added in v0.66.0

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 DataImport added in v0.58.0

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 added in v0.58.0

func (di *DataImport) ParseState()

type DataImportSource added in v0.58.0

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 added in v0.58.0

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

func (DataImportState) String added in v0.58.0

func (d DataImportState) String() string

type DataImportsService added in v0.58.0

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 added in v0.58.0

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"`
	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 {
	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"`
}

DatabaseBranch represents a database branch.

type DatabaseBranchCertificate added in v0.51.0

type DatabaseBranchCertificate struct {
	PublicID    string         `json:"id"`
	Name        string         `json:"display_name"`
	Role        string         `json:"role"`
	Actor       *Actor         `json:"actor"`
	Branch      DatabaseBranch `json:"database_branch"`
	Certificate string         `json:"certificate"`
	CreatedAt   time.Time      `json:"created_at"`
	DeletedAt   time.Time      `json:"deleted_at"`
}

func (*DatabaseBranchCertificate) X509KeyPair added in v0.51.0

type DatabaseBranchCertificateRequest added in v0.51.0

type DatabaseBranchCertificateRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	DisplayName  string `json:"display_name"`
	Role         string `json:"role"`
	PrivateKey   crypto.PrivateKey
}

DatabaseBranchCertificateRequest encapsulates the request for creating/getting/deleting a database branch certificate.

type DatabaseBranchPassword added in v0.40.0

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"`
	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"`
}

type DatabaseBranchPasswordRequest added in v0.40.0

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"`
}

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

type DatabaseDeletionRequest added in v0.65.0

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

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

type DatabaseState added in v0.52.0

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 added in v0.40.0

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
}

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 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 DemoteRequest added in v0.83.0

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 added in v0.50.0

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 added in v0.58.0

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 added in v0.84.0

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

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

type EnableSafeMigrationsRequest added in v0.84.0

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

	// 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 added in v0.58.0

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

func (ExternalDataSourceSSLVerificationMode) String added in v0.58.0

type GetBackupRequest

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

type GetDatabaseBranchCertificateRequest added in v0.51.0

type GetDatabaseBranchCertificateRequest struct {
	Organization string `json:"-"`
	Database     string `json:"-"`
	Branch       string `json:"-"`
	DisplayName  string `json:"display_name"`
	PasswordId   string
}

GetDatabaseBranchCertificateRequest encapsulates the request for listing all certificates for a given database branch.

type GetDatabaseBranchPasswordRequest added in v0.40.0

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 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 added in v0.58.0

type GetImportStatusRequest struct {
	Organization string
	Database     string
}

type GetOrganizationRequest

type GetOrganizationRequest struct {
	Organization string
}

GetOrganizationRequest encapsulates the request for getting a single organization.

type GetServiceTokenAccessRequest

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

type Keyspace added in v0.68.0

type Keyspace struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Shards    int       `json:"shards"`
	Sharded   bool      `json:"sharded"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type LintSchemaRequest added in v0.85.0

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

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

type ListAuditLogsRequest added in v0.35.0

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 ListDatabaseBranchCertificateRequest added in v0.51.0

type ListDatabaseBranchCertificateRequest struct {
	Organization string
	Database     string
	Branch       string
}

ListDatabaseBranchCertificateRequest encapsulates the request for listing all certificates for a given database branch.

type ListDatabaseBranchPasswordRequest added in v0.40.0

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 ListOption added in v0.66.0

type ListOption func(*ListOptions) error

func WithEventFilters added in v0.66.0

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 added in v0.66.0

func WithLimit(limit int) ListOption

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

func WithPage added in v0.74.0

func WithPage(page int) ListOption

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

func WithPerPage added in v0.74.0

func WithPerPage(perPage int) ListOption

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

func WithStartingAfter added in v0.66.0

func WithStartingAfter(startingAfter string) ListOption

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

type ListOptions added in v0.66.0

type ListOptions struct {
	URLValues *url.Values
}

ListOptions are options for listing responses.

type ListOrganizationRegionsRequest added in v0.40.0

type ListOrganizationRegionsRequest struct {
	Organization string
}

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

type ListRegionsRequest added in v0.29.0

type ListRegionsRequest struct{}

type ListServiceTokenGrantsRequest added in v0.76.0

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

type ListServiceTokensRequest

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

type MakePlanetScalePrimaryRequest added in v0.58.0

type MakePlanetScalePrimaryRequest struct {
	Organization string
	Database     string
}

type MakePlanetScaleReplicaRequest added in v0.58.0

type MakePlanetScaleReplicaRequest struct {
	Organization string
	Database     string
}

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

type OrganizationsService interface {
	Get(context.Context, *GetOrganizationRequest) (*Organization, error)
	List(context.Context) ([]*Organization, error)
	ListRegions(context.Context, *ListOrganizationRegionsRequest) ([]*Region, error)
}

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

type PasswordsService added in v0.40.0

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"`
}

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 Plan added in v0.88.0

type Plan string
const (
	Hobby     Plan = "hobby"
	Scaler    Plan = "scaler"
	ScalerPro Plan = "scaler_pro"
)

type PromoteRequest added in v0.46.0

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

PromoteRequest encapsulates the request for promoting a request to production.

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 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 added in v0.29.0

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

type RegionsService added in v0.29.0

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

type RenewDatabaseBranchPasswordRequest added in v0.95.0

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 RevertDeployRequestRequest added in v0.63.0

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 added in v0.97.0

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

type SchemaLintError added in v0.85.0

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 ServiceToken

type ServiceToken struct {
	ID    string `json:"id"`
	Type  string `json:"type"`
	Token string `json:"token"`
}

type ServiceTokenAccess

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

type ServiceTokenGrant added in v0.76.0

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 added in v0.81.0

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

type ServiceTokenResource added in v0.94.0

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 SkipRevertDeployRequestRequest added in v0.63.0

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

type StartDataImportRequest added in v0.58.0

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 TestDataImportSourceRequest added in v0.58.0

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

type TestDataImportSourceResponse added in v0.58.0

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 UpdateBranchRoutingRulesRequest added in v0.97.0

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

type UpdateBranchVschemaRequest added in v0.97.0

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

type UserShouldUpgradePlanError added in v0.60.0

type UserShouldUpgradePlanError struct{}

func (UserShouldUpgradePlanError) Error added in v0.60.0

type VSchema added in v0.98.0

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

VSchema returns a vschema for a branch

Jump to

Keyboard shortcuts

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