client

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//go:embed queries/create_service.graphql
	CreateServiceMutation string
	//go:embed queries/rename_service.graphql
	RenameServiceMutation string
	//go:embed queries/resize_instance.graphql
	ResizeInstanceMutation string
	//go:embed queries/delete_service.graphql
	DeleteServiceMutation string
	//go:embed queries/toggle_connection_pooler.graphql
	ToggleConnectionPoolerMutation string
	//go:embed queries/get_all_services.graphql
	GetAllServicesQuery string
	//go:embed queries/get_service.graphql
	GetServiceQuery string
	//go:embed queries/products.graphql
	ProductsQuery string
	//go:embed queries/jwt_cc.graphql
	JWTFromCCQuery string
	//go:embed queries/set_replica_count.graphql
	SetReplicaCountMutation string

	// VCPs ///////////////////////////////
	//go:embed queries/vpcs.graphql
	GetVPCsQuery string
	//go:embed queries/vpc_by_name.graphql
	GetVPCByNameQuery string
	//go:embed queries/vpc_by_id.graphql
	GetVPCByIDQuery string
	//go:embed queries/attach_service_to_vpc.graphql
	AttachServiceToVPCMutation string
	//go:embed queries/detach_service_from_vpc.graphql
	DetachServiceFromVPCMutation string
	//go:embed queries/create_vpc.graphql
	CreateVPCMutation string
	//go:embed queries/delete_vpc.graphql
	DeleteVPCMutation string
	//go:embed queries/rename_vpc.graphql
	RenameVPCMutation string
)

Functions

func JWTFromCC

func JWTFromCC(c *Client, accessKey, secretKey string) error

Types

type Client

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

func NewClient

func NewClient(token, projectID, env, terraformVersion string) *Client

func (*Client) AttachServiceToVPC added in v1.3.0

func (c *Client) AttachServiceToVPC(ctx context.Context, serviceID string, vpcID int64) error

func (*Client) CreateService

func (c *Client) CreateService(ctx context.Context, request CreateServiceRequest) (*CreateServiceResponse, error)

func (*Client) CreateVPC added in v1.3.0

func (c *Client) CreateVPC(ctx context.Context, name, cidr, regionCode string) (*VPC, error)

func (*Client) DeleteService

func (c *Client) DeleteService(ctx context.Context, id string) (*Service, error)

func (*Client) DeleteVPC added in v1.3.0

func (c *Client) DeleteVPC(ctx context.Context, vpcID int64) error

func (*Client) DetachServiceFromVPC added in v1.3.0

func (c *Client) DetachServiceFromVPC(ctx context.Context, serviceID string, vpcID int64) error

func (*Client) GetAllServices added in v1.2.0

func (c *Client) GetAllServices(ctx context.Context) ([]*Service, error)

func (*Client) GetProducts

func (c *Client) GetProducts(ctx context.Context) ([]*Product, error)

func (*Client) GetService

func (c *Client) GetService(ctx context.Context, id string) (*Service, error)

func (*Client) GetVPCByID added in v1.3.0

func (c *Client) GetVPCByID(ctx context.Context, vpcID int64) (*VPC, error)

func (*Client) GetVPCByName added in v1.3.0

func (c *Client) GetVPCByName(ctx context.Context, name string) (*VPC, error)

func (*Client) GetVPCs added in v0.2.1

func (c *Client) GetVPCs(ctx context.Context) ([]*VPC, error)

func (*Client) RenameService

func (c *Client) RenameService(ctx context.Context, serviceID string, newName string) error

func (*Client) RenameVPC added in v1.3.0

func (c *Client) RenameVPC(ctx context.Context, vpcID int64, newName string) error

func (*Client) ResizeInstance

func (c *Client) ResizeInstance(ctx context.Context, serviceID string, config ResourceConfig) error

func (*Client) SetReplicaCount added in v0.3.2

func (c *Client) SetReplicaCount(ctx context.Context, serviceID string, replicaCount int) error

func (*Client) ToggleConnectionPooler added in v1.4.0

func (c *Client) ToggleConnectionPooler(ctx context.Context, serviceID string, enable bool) error

type CreateServiceRequest

type CreateServiceRequest struct {
	Name     string
	MilliCPU string
	MemoryGB string
	// StorageGB is used for forks, since the CreateServiceRequest expects a storage to be requested
	// and the fork instance should match the storage size of the primary.
	StorageGB    string
	RegionCode   string
	ReplicaCount string
	VpcID        int64
	ForkConfig   *ForkConfig

	EnableConnectionPooler bool
}

type CreateServiceResponse

type CreateServiceResponse struct {
	Service         Service `json:"service"`
	InitialPassword string  `json:"initialPassword"`
}

type CreateServiceResponseData

type CreateServiceResponseData struct {
	CreateServiceResponse CreateServiceResponse `json:"createService"`
}

type CreateVPCResponse added in v1.3.0

type CreateVPCResponse struct {
	VPC *VPC `json:"createVPC"`
}

type DeleteServiceResponse

type DeleteServiceResponse struct {
	Service Service `json:"deleteService"`
}

type Error

type Error struct {
	Message string `json:"message"`
}

func (*Error) Error

func (e *Error) Error() string

type ForkConfig added in v1.2.0

type ForkConfig struct {
	ProjectID string `json:"projectID"`
	ServiceID string `json:"serviceID"`
	IsStandby bool   `json:"isStandby"`
}

type ForkSpec added in v1.2.0

type ForkSpec struct {
	ProjectID string `json:"projectId"`
	ServiceID string `json:"serviceId"`
	IsStandby bool   `json:"isStandby"`
}

type GetAllServicesResponse added in v1.2.0

type GetAllServicesResponse struct {
	Services []*Service `json:"getAllServices"`
}

type GetServiceResponse

type GetServiceResponse struct {
	Service Service `json:"getService"`
}

type JWTFromCCResponse

type JWTFromCCResponse struct {
	Token string `json:"getJWTForClientCredentials"`
}

type PeerVPC added in v1.3.0

type PeerVPC struct {
	ID         string `json:"id"`
	CIDR       string `json:"cidr"`
	AccountID  string `json:"accountId"`
	RegionCode string `json:"regionCode"`
}

type PeeringConnection added in v0.2.1

type PeeringConnection struct {
	ID           string   `json:"id"`
	VPCID        string   `json:"vpcId"`
	Status       string   `json:"status"`
	ErrorMessage string   `json:"errorMessage"`
	PeerVPC      *PeerVPC `json:"peerVPC"`
}

type Plan

type Plan struct {
	ID         string  `json:"id"`
	ProductID  string  `json:"productId"`
	RegionCode string  `json:"regionCode"`
	Price      float64 `json:"price"`
	MilliCPU   int64   `json:"milliCPU"`
	MemoryGB   int64   `json:"memoryGB"`
	StorageGB  int64   `json:"storageGB"`
}

type Product

type Product struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Plans       []*Plan `json:"plans"`
}

type ProductsResponse

type ProductsResponse struct {
	Products []*Product `json:"products"`
}

type ResourceConfig

type ResourceConfig struct {
	MilliCPU     string
	MemoryGB     string
	ReplicaCount string
}

type ResourceSpec

type ResourceSpec struct {
	ID   string `json:"id"`
	Spec struct {
		MilliCPU  int64 `json:"milliCPU"`
		MemoryGB  int64 `json:"memoryGB"`
		StorageGB int64 `json:"storageGB"`
	} `json:"spec"`
}

type Response

type Response[T any] struct {
	Data   *T       `json:"data"`
	Errors []*Error `json:"errors"`
}

type Service

type Service struct {
	ID                string `json:"id"`
	ProjectID         string `json:"projectId"`
	Name              string `json:"name"`
	AutoscaleSettings struct {
		Enabled bool `json:"enabled"`
	} `json:"autoscaleSettings"`
	Status        string         `json:"status"`
	RegionCode    string         `json:"regionCode"`
	ServiceSpec   ServiceSpec    `json:"spec"`
	Resources     []ResourceSpec `json:"resources"`
	Created       string         `json:"created"`
	ReplicaStatus string         `json:"replicaStatus"`
	VPCEndpoint   *VPCEndpoint   `json:"vpcEndpoint"`
	ForkSpec      *ForkSpec      `json:"forkedFromId"`
}

type ServiceSpec

type ServiceSpec struct {
	Hostname       string `json:"hostname"`
	Username       string `json:"username"`
	Port           int64  `json:"port"`
	PoolerHostname string `json:"poolerHostName"`
	PoolerPort     int64  `json:"poolerPort"`
	Pooler         bool   `json:"connectionPoolerEnabled"`
}

type VPC added in v0.2.1

type VPC struct {
	ID                 string               `json:"id"`
	ProvisionedID      string               `json:"provisionedId"`
	ProjectID          string               `json:"projectId"`
	CIDR               string               `json:"cidr"`
	Name               string               `json:"name"`
	RegionCode         string               `json:"regionCode"`
	Status             string               `json:"status"`
	ErrorMessage       string               `json:"errorMessage"`
	Created            string               `json:"created"`
	Updated            string               `json:"updated"`
	PeeringConnections []*PeeringConnection `json:"peeringConnections"`
}

type VPCEndpoint added in v1.3.0

type VPCEndpoint struct {
	Host  string `json:"host"`
	Port  int64  `json:"port"`
	VPCId string `json:"vpcId"`
}

type VPCResponse added in v1.3.0

type VPCResponse struct {
	VPC *VPC `json:"getVPCByName"`
}

type VPCsResponse added in v1.3.0

type VPCsResponse struct {
	VPCs []*VPC `json:"getAllVPCs"`
}

Jump to

Keyboard shortcuts

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