clusters

package
v0.29.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HighAvailabilityReplicationModeAsync HighAvailabilityReplicationMode = "async"
	HighAvailabilityReplicationModeSync  HighAvailabilityReplicationMode = "sync"

	PoolerModeSession     PoolerMode = "session"
	PoolerModeStatement   PoolerMode = "statement"
	PoolerModeTransaction PoolerMode = "transaction"

	ClusterStatusDeleting  ClusterStatus = "DELETING"
	ClusterStatusFailed    ClusterStatus = "FAILED"
	ClusterStatusPreparing ClusterStatus = "PREPARING"
	ClusterStatusReady     ClusterStatus = "READY"
	ClusterStatusUnhealthy ClusterStatus = "UNHEALTHY"
	ClusterStatusUpdating  ClusterStatus = "UPDATING"
	ClusterStatusUnknown   ClusterStatus = "UNKNOWN"

	RoleAttributeBypassRLS  RoleAttribute = "BYPASSRLS"
	RoleAttributeCreateRole RoleAttribute = "CREATEROLE"
	RoleAttributeCreateDB   RoleAttribute = "CREATEDB"
	RoleAttributeInherit    RoleAttribute = "INHERIT"
	RoleAttributeLogin      RoleAttribute = "LOGIN"
	RoleAttributeNoLogin    RoleAttribute = "NOLOGIN"
)

Variables

This section is empty.

Functions

func ClusterURL

func ClusterURL(c *gcorecloud.ServiceClient, clusterName string) string

ClusterURL returns the URL for specific PostgreSQL cluster operations

func Create

func Create(client *gcorecloud.ServiceClient, opts CreateOptsBuilder) (r tasks.Result)

Create creates a new PostgreSQL cluster.

func Delete

func Delete(client *gcorecloud.ServiceClient, clusterName string, opts DeleteOptsBuilder) (r tasks.Result)

Delete deletes a specific PostgreSQL cluster.

func ExtractClusterNameFromTask

func ExtractClusterNameFromTask(task *tasks.Task) (string, error)

func ExtractClustersInto

func ExtractClustersInto(r pagination.Page, v interface{}) error

func IsValidRoleAttribute

func IsValidRoleAttribute(s string) bool

func List

List retrieves PostgreSQL clusters.

func RoleAttributeSliceToStrings

func RoleAttributeSliceToStrings(roleAttributes []RoleAttribute) []string

func RoleAttributeStringList

func RoleAttributeStringList() []string

func Update

func Update(client *gcorecloud.ServiceClient, clusterName string, opts UpdateOptsBuilder) (r tasks.Result)

Update updates a new PostgreSQL cluster.

Types

type ClusterPage

type ClusterPage struct {
	pagination.OffsetPageBase
}

ClusterPage is the page returned by a pager when traversing over a collection of PG clusters.

type ClusterStatus

type ClusterStatus string

type ClusterTaskResult

type ClusterTaskResult struct {
	PostgresClusters []string `mapstructure:"postgresql_clusters"`
}

type CreateOpts

type CreateOpts struct {
	ClusterName           string                     `json:"cluster_name" validate:"required"`
	Databases             []DatabaseOpts             `json:"databases" validate:"required,dive"`
	Flavor                FlavorOpts                 `json:"flavor" validate:"required"`
	HighAvailability      *HighAvailabilityOpts      `json:"high_availability" validate:"omitempty"`
	Network               NetworkOpts                `json:"network" validate:"required"`
	PGServerConfiguration PGServerConfigurationOpts  `json:"pg_server_configuration" validate:"required"`
	Storage               PGStorageConfigurationOpts `json:"storage" validate:"required"`
	Users                 []PgUserOpts               `json:"users" validate:"required,dive"`
}

CreateOpts specifies the parameters for the Create method.

func (CreateOpts) ToCreateMap

func (opts CreateOpts) ToCreateMap() (map[string]interface{}, error)

ToCreateMap builds a request body from CreateOpts.

func (CreateOpts) Validate

func (opts CreateOpts) Validate() error

Validate checks if the provided options are valid.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type DatabaseOpts

type DatabaseOpts struct {
	Name  string `json:"name" validate:"required"`
	Owner string `json:"owner" validate:"required"`
}

type DatabaseOverview

type DatabaseOverview struct {
	Name  string `json:"name"`
	Owner string `json:"owner"`
	Size  int    `json:"size"`
}

type DeleteOpts

type DeleteOpts struct{}

DeleteOpts specifies the parameters for the Delete method.

func (DeleteOpts) ToClusterDeleteQuery

func (d DeleteOpts) ToClusterDeleteQuery() (string, error)

type DeleteOptsBuilder

type DeleteOptsBuilder interface {
	ToClusterDeleteQuery() (string, error)
}

DeleteOptsBuilder allows extensions to add parameters to delete cluster options.

type Flavor

type Flavor struct {
	CPU       int `json:"cpu"`
	MemoryGiB int `json:"memory_gib"`
}

type FlavorOpts

type FlavorOpts struct {
	CPU       int `json:"cpu" validate:"required,gte=1"`
	MemoryGiB int `json:"memory_gib" validate:"required,gte=1"`
}

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult represents the result of a get operation. Call its Extract method to interpret it as a PG Cluster.

func Get

func Get(client *gcorecloud.ServiceClient, clusterName string) (r GetResult)

func (GetResult) Extract

func (r GetResult) Extract() (*PostgresSQLCluster, error)

Extract is a function that accepts a result and extracts a PostgreSQL cluster resource.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type HighAvailability

type HighAvailability struct {
	ReplicationMode HighAvailabilityReplicationMode `json:"replication_mode"`
}

type HighAvailabilityOpts

type HighAvailabilityOpts struct {
	ReplicationMode HighAvailabilityReplicationMode `json:"replication_mode" validate:"required,oneof=async sync"`
}

type HighAvailabilityReplicationMode

type HighAvailabilityReplicationMode string

type ListOpts

type ListOpts struct {
	Limit  int `q:"limit" validate:"omitempty,gt=0"`
	Offset int `q:"offset" validate:"omitempty,gte=0"`
}

ListOpts allows the filtering and sorting of paginated collections through the API.

func (ListOpts) ToListClustersQuery

func (opts ListOpts) ToListClustersQuery() (string, error)

ToListClustersQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToListClustersQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Network

type Network struct {
	ACL              []string `json:"acl"`
	ConnectionString string   `json:"connection_string"`
	Host             string   `json:"host"`
	NetworkType      string   `json:"network_type"`
}

type NetworkOpts

type NetworkOpts struct {
	ACL         []string `json:"acl" validate:"required"`
	NetworkType string   `json:"network_type" validate:"required,oneof=public"`
}

type PGServerConfiguration

type PGServerConfiguration struct {
	PGConf  string  `json:"pg_conf"`
	Version string  `json:"version"`
	Pooler  *Pooler `json:"pooler"`
}

type PGServerConfigurationOpts

type PGServerConfigurationOpts struct {
	PGConf  string      `json:"pg_conf" validate:"required"`
	Version string      `json:"version" validate:"required"`
	Pooler  *PoolerOpts `json:"pooler,omitempty" validate:"omitempty"`
}

type PGServerConfigurationUpdateOpts

type PGServerConfigurationUpdateOpts struct {
	PGConf  string      `json:"pg_conf,omitempty" validate:"omitempty"`
	Version string      `json:"version,omitempty" validate:"omitempty"`
	Pooler  *PoolerOpts `json:"pooler,omitempty" validate:"omitempty"`
}

type PGStorageConfiguration

type PGStorageConfiguration struct {
	SizeGiB int    `json:"size_gib"`
	Type    string `json:"type"`
}

type PGStorageConfigurationOpts

type PGStorageConfigurationOpts struct {
	SizeGiB int    `json:"size_gib" validate:"required,gte=1,lte=100"`
	Type    string `json:"type" validate:"required"`
}

type PGStorageConfigurationUpdateOpts

type PGStorageConfigurationUpdateOpts struct {
	SizeGiB int `json:"size_gib" validate:"required,gte=1,lte=100"`
}

type PgUserOpts

type PgUserOpts struct {
	Name           string          `json:"name" validate:"required"`
	RoleAttributes []RoleAttribute `json:"role_attributes" validate:"required,min=1,dive,oneof=BYPASSRLS CREATEROLE CREATEDB INHERIT LOGIN NOLOGIN"`
}

type PgUserOverview

type PgUserOverview struct {
	IsSecretRevealed bool            `json:"is_secret_revealed"`
	Name             string          `json:"name"`
	RoleAttributes   []RoleAttribute `json:"role_attributes"`
}

type Pooler

type Pooler struct {
	Mode PoolerMode `json:"mode"`
	Type string     `json:"type"`
}

type PoolerMode

type PoolerMode string

type PoolerOpts

type PoolerOpts struct {
	Mode PoolerMode `json:"mode" validate:"required,oneof=session statement transaction"`
	Type string     `json:"type" validate:"oneof=pgbouncer"`
}

type PostgresSQLCluster

type PostgresSQLCluster struct {
	ClusterName           string                  `json:"cluster_name"`
	CreatedAt             gcorecloud.JSONRFC3339Z `json:"created_at"`
	Databases             []DatabaseOverview      `json:"databases"`
	Flavor                Flavor                  `json:"flavor"`
	HighAvailability      *HighAvailability       `json:"high_availability"`
	Network               Network                 `json:"network"`
	PGServerConfiguration PGServerConfiguration   `json:"pg_server_configuration"`
	Status                ClusterStatus           `json:"status"`
	Storage               PGStorageConfiguration  `json:"storage"`
	Users                 []PgUserOverview        `json:"users"`
}

type PostgresSQLClusterShort

type PostgresSQLClusterShort struct {
	ClusterName string                  `json:"cluster_name"`
	CreatedAt   gcorecloud.JSONRFC3339Z `json:"created_at"`
	Status      ClusterStatus           `json:"status"`
	Version     string                  `json:"version"`
}

func ExtractClusters

func ExtractClusters(r pagination.Page) ([]PostgresSQLClusterShort, error)

ExtractClusters accepts a Page struct, specifically a ClusterPage struct, and extracts the elements into a slice of PG cluster structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

ListAll is a convenience function that returns all PG clusters.

type RoleAttribute

type RoleAttribute string

func RoleAttributeList

func RoleAttributeList() []RoleAttribute

func (*RoleAttribute) String

func (it *RoleAttribute) String() string

type UpdateOpts

type UpdateOpts struct {
	Databases             []DatabaseOpts                    `json:"databases,omitempty" validate:"omitempty,dive"`
	Flavor                *FlavorOpts                       `json:"flavor,omitempty" validate:"omitempty"`
	HighAvailability      *HighAvailabilityOpts             `json:"high_availability,omitempty" validate:"omitempty"`
	Network               *NetworkOpts                      `json:"network,omitempty" validate:"omitempty"`
	PGServerConfiguration *PGServerConfigurationUpdateOpts  `json:"pg_server_configuration,omitempty" validate:"omitempty"`
	Storage               *PGStorageConfigurationUpdateOpts `json:"storage,omitempty" validate:"omitempty"`
	Users                 []PgUserOpts                      `json:"users,omitempty" validate:"omitempty,dive"`
}

func (UpdateOpts) ToUpdateMap

func (opts UpdateOpts) ToUpdateMap() (map[string]interface{}, error)

ToUpdateMap builds a request body from UpdateOpts.

func (UpdateOpts) Validate

func (opts UpdateOpts) Validate() error

Validate checks if the provided options are valid.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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