gocrunchybridge

package module
v0.0.0-...-5868074 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 14 Imported by: 0

README

Go-crunchybridge

Go SDK for Crunchybridge

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidClusterEnvironment = errors.New("not a valid ClusterEnvironment")
View Source
var ErrInvalidClusterProvider = errors.New("not a valid ClusterProvider")
View Source
var ErrInvalidListFilterOrderType = errors.New("not a valid ListFilterOrderType")
View Source
var ErrInvalidListOrderFieldType = errors.New("not a valid ListOrderFieldType")

Functions

func ToReader

func ToReader[T NoopRequestBody | any](t T) (io.Reader, error)

ToReader converts any struct into a io#Reader that can be used

Types

type APIKey

type APIKey string

func (APIKey) String

func (a APIKey) String() string

type AccessToken

type AccessToken struct {
	ID          string    `json:"id,omitempty"`
	AccessToken string    `json:"access_token,omitempty"`
	AccountID   string    `json:"account_id,omitempty"`
	APIKeyID    string    `json:"api_key_id,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	ExpiresAt   time.Time `json:"expires_at,omitempty"`
	TokenType   string    `json:"token_type,omitempty"`
}

type AccessTokenService

type AccessTokenService service

func (*AccessTokenService) Create

func (*AccessTokenService) Delete

func (a *AccessTokenService) Delete(ctx context.Context,
	token AccessToken,
) error

type AccountService

type AccountService service

func (*AccountService) User

type AuthenticatedAccount

type AuthenticatedAccount struct {
	CreatedAt            time.Time `json:"created_at"`
	DefaultTeamID        string    `json:"default_team_id"`
	Email                string    `json:"email"`
	FirstName            string    `json:"first_name"`
	HasPassword          bool      `json:"has_password"`
	HasSso               bool      `json:"has_sso"`
	ID                   string    `json:"id"`
	LastSeenAt           time.Time `json:"last_seen_at"`
	MultiFactorEnabled   bool      `json:"multi_factor_enabled"`
	Name                 string    `json:"name"`
	NotificationsEnabled bool      `json:"notifications_enabled"`
	UpdatedAt            time.Time `json:"updated_at"`
}

type CertificateService

type CertificateService service

func (*CertificateService) Get

type Client

type Client struct {
	Account     *AccountService
	AccessToken *AccessTokenService
	Certificate *CertificateService
	Cluster     *ClusterService
	Provider    *ProviderService
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Client, error)

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v any) (*Response, error)

type Cluster

type Cluster struct {
	ClusterID              any                `json:"cluster_id"`
	CPU                    int                `json:"cpu"`
	CreatedAt              time.Time          `json:"created_at"`
	DiskUsage              ClusterDiskUsage   `json:"disk_usage"`
	Environment            ClusterEnvironment `json:"environment"`
	Host                   string             `json:"host"`
	ID                     EID                `json:"id"`
	IsHighlyAvailable      bool               `json:"is_ha"`
	IsProtected            bool               `json:"is_protected"`
	IsSuspended            bool               `json:"is_suspended"`
	MaintenanceWindowStart int                `json:"maintenance_window_start"`
	MajorVersion           int                `json:"major_version"`
	Memory                 float64            `json:"memory"`
	Name                   string             `json:"name"`
	NetworkID              EID                `json:"network_id"`
	ParentID               EID                `json:"parent_id"`
	PlanID                 string             `json:"plan_id"`
	PostgresVersionID      string             `json:"postgres_version_id"`
	ProviderID             EID                `json:"provider_id"`
	RegionID               EID                `json:"region_id"`
	Replicas               []struct {
		ClusterID              any                `json:"cluster_id"`
		CPU                    int                `json:"cpu"`
		CreatedAt              time.Time          `json:"created_at"`
		DiskUsage              ClusterDiskUsage   `json:"disk_usage"`
		Environment            ClusterEnvironment `json:"environment"`
		Host                   string             `json:"host"`
		ID                     EID                `json:"id"`
		IsHighlyAvailable      bool               `json:"is_ha"`
		IsProtected            bool               `json:"is_protected"`
		IsSuspended            bool               `json:"is_suspended"`
		MaintenanceWindowStart int                `json:"maintenance_window_start"`
		MajorVersion           int                `json:"major_version"`
		Memory                 float64            `json:"memory"`
		Name                   string             `json:"name"`
		NetworkID              EID                `json:"network_id"`
		ParentID               EID                `json:"parent_id"`
		PlanID                 string             `json:"plan_id"`
		PostgresVersionID      string             `json:"postgres_version_id"`
		ProviderID             EID                `json:"provider_id"`
		RegionID               EID                `json:"region_id"`
		ResetStatsWeekly       bool               `json:"reset_stats_weekly"`
		Storage                int                `json:"storage"`
		TailscaleActive        bool               `json:"tailscale_active"`
		TeamID                 EID                `json:"team_id"`
		UpdatedAt              time.Time          `json:"updated_at"`
	} `json:"replicas"`
	ResetStatsWeekly bool      `json:"reset_stats_weekly"`
	Storage          int       `json:"storage"`
	TailscaleActive  bool      `json:"tailscale_active"`
	TeamID           EID       `json:"team_id"`
	UpdatedAt        time.Time `json:"updated_at"`
}

type ClusterDiskUsage

type ClusterDiskUsage struct {
	DiskAvailableMb int `json:"disk_available_mb"`
	DiskTotalSizeMb int `json:"disk_total_size_mb"`
	DiskUsedMb      int `json:"disk_used_mb"`
}

type ClusterEnvironment

type ClusterEnvironment string

ENUM(production)

const (
	// ClusterEnvironmentProduction is a ClusterEnvironment of type production.
	ClusterEnvironmentProduction ClusterEnvironment = "production"
)

func ParseClusterEnvironment

func ParseClusterEnvironment(name string) (ClusterEnvironment, error)

ParseClusterEnvironment attempts to convert a string to a ClusterEnvironment.

func (ClusterEnvironment) IsValid

func (x ClusterEnvironment) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ClusterEnvironment) String

func (x ClusterEnvironment) String() string

String implements the Stringer interface.

type ClusterProvider

type ClusterProvider string

ENUM(aws,gcp,azure)

const (
	// ClusterProviderAws is a ClusterProvider of type aws.
	ClusterProviderAws ClusterProvider = "aws"
	// ClusterProviderGcp is a ClusterProvider of type gcp.
	ClusterProviderGcp ClusterProvider = "gcp"
	// ClusterProviderAzure is a ClusterProvider of type azure.
	ClusterProviderAzure ClusterProvider = "azure"
)

func ParseClusterProvider

func ParseClusterProvider(name string) (ClusterProvider, error)

ParseClusterProvider attempts to convert a string to a ClusterProvider.

func (ClusterProvider) IsValid

func (x ClusterProvider) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ClusterProvider) String

func (x ClusterProvider) String() string

String implements the Stringer interface.

type ClusterService

type ClusterService service

func (*ClusterService) Create

func (c *ClusterService) Create(ctx context.Context,
	opts *CreateClusterOptions,
) (Cluster, error)

func (*ClusterService) Delete

func (*ClusterService) List

func (*ClusterService) Ping

type CreateAccessTokenOptions

type CreateAccessTokenOptions struct {
	ExpiresAt time.Time
	// contains filtered or unexported fields
}

func (CreateAccessTokenOptions) MarshalJSON

func (c CreateAccessTokenOptions) MarshalJSON() ([]byte, error)

type CreateClusterOptions

type CreateClusterOptions struct {
	// Hunan readable name for the cluster. If non is provided,
	// a default name would be generated for the cluster
	Name   string `json:"name,omitempty"`
	PlanID string `json:"plan_id,omitempty"`
	// You must have admin access to create a cluster
	TeamID EID `json:"team_id,omitempty"`

	ClusterGroupID EID `json:"cluster_group_id,omitempty"`

	HighlyAvailable   bool `json:"is_ha,omitempty"`
	KeychainID        EID  `json:"keychain_id,omitempty"`
	NetworkID         EID  `json:"network_id,omitempty"`
	PostgresVersionID int  `json:"postgres_version_id,omitempty"`
	// You cannot set this and NetworkID together
	RegionID    string          `json:"region_id,omitempty"`
	StorageSize int             `json:"storage,omitempty"`
	ProviderID  ClusterProvider `json:"provider_id,omitempty"`

	Environment ClusterEnvironment `json:"environment,omitempty"`
}

func (*CreateClusterOptions) Validate

func (c *CreateClusterOptions) Validate() error

type EID

type EID string

EID represents an encoded ID.

func (EID) IsEmpty

func (e EID) IsEmpty() bool

func (EID) IsValid

func (e EID) IsValid() error

func (EID) String

func (e EID) String() string

type FetchClusterOptions

type FetchClusterOptions struct {
	ID EID
}

type FetchProviderOptions

type FetchProviderOptions struct {
	Provider ClusterProvider
}

type FetchTeamCertificateOption

type FetchTeamCertificateOption struct {
	TeamID string
}

type ListClusterOptions

type ListClusterOptions struct {
	Order      ListFilterOrderType `url:"order,omitempty"`
	OrderField string              `url:"order_field,omitempty"`
	TeamID     EID                 `url:"team_id,omitempty"`
	Limit      int                 `url:"limit,omitempty"`
}

type ListClusterResponse

type ListClusterResponse struct {
	HasMore    bool      `json:"has_more,omitempty"`
	Clusters   []Cluster `json:"clusters,omitempty"`
	NextCursor EID       `json:"next_cursor,omitempty"`
}

type ListFilterOrderType

type ListFilterOrderType string

ENUM(asc,desc)

const (
	// ListFilterOrderTypeAsc is a ListFilterOrderType of type asc.
	ListFilterOrderTypeAsc ListFilterOrderType = "asc"
	// ListFilterOrderTypeDesc is a ListFilterOrderType of type desc.
	ListFilterOrderTypeDesc ListFilterOrderType = "desc"
)

func ParseListFilterOrderType

func ParseListFilterOrderType(name string) (ListFilterOrderType, error)

ParseListFilterOrderType attempts to convert a string to a ListFilterOrderType.

func (ListFilterOrderType) IsValid

func (x ListFilterOrderType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ListFilterOrderType) String

func (x ListFilterOrderType) String() string

String implements the Stringer interface.

type ListOrderFieldType

type ListOrderFieldType string

ENUM(id,name)

const (
	// ListOrderFieldTypeId is a ListOrderFieldType of type id.
	ListOrderFieldTypeId ListOrderFieldType = "id"
	// ListOrderFieldTypeName is a ListOrderFieldType of type name.
	ListOrderFieldTypeName ListOrderFieldType = "name"
)

func ParseListOrderFieldType

func ParseListOrderFieldType(name string) (ListOrderFieldType, error)

ParseListOrderFieldType attempts to convert a string to a ListOrderFieldType.

func (ListOrderFieldType) IsValid

func (x ListOrderFieldType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ListOrderFieldType) String

func (x ListOrderFieldType) String() string

String implements the Stringer interface.

type NoopRequestBody

type NoopRequestBody struct{}

NoopRequestBody is used to ide

type Option

type Option func(*Client)

func WithAPIKey

func WithAPIKey(a APIKey) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

func WithUserAgent

func WithUserAgent(s string) Option

type ProviderPlan

type ProviderPlan struct {
	DisplayName string `json:"display_name"`
	ID          string `json:"id"`
	Plans       []struct {
		CPU                       int     `json:"cpu"`
		DisplayName               string  `json:"display_name"`
		ID                        EID     `json:"id"`
		IopsBaseline              int     `json:"iops_baseline"`
		IopsMaximum               int     `json:"iops_maximum"`
		MaximumPerformanceLimited bool    `json:"maximum_performance_limited"`
		Memory                    float64 `json:"memory"`
		Rate                      int     `json:"rate"`
	} `json:"plans"`
	Regions []struct {
		DisplayName string `json:"display_name"`
		ID          EID    `json:"id"`
		Location    string `json:"location"`
	} `json:"regions"`
}

type ProviderResponse

type ProviderResponse struct {
	Providers []ProviderPlan `json:"providers"`
}

type ProviderService

type ProviderService service

func (*ProviderService) Get

type Response

type Response struct {
	*http.Response
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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