loadbalancers

package
v0.3.38 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package loadbalancer contains functionality for working GCLoud loadbalancers API resources

Example to List LoadBalancer

listOpts := loadbalancers.ListOpts{
}

allPages, err := loadbalancers.List(loadbalancerClient).AllPages()
if err != nil {
	panic(err)
}

allLoadBalancers, err := loadbalancers.ExtractLoadBalancers(allPages)
if err != nil {
	panic(err)
}

for _, loadbalancer := range allLoadBalancers {
	fmt.Printf("%+v", loadbalancer)
}

Example to Create a LoadBalancer

createOpts := loadbalancers.CreateOpts{
}

loadbalancers, err := loadbalancers.Create(loadbalancerClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a LoadBalancer

loadbalancerID := "484cda0e-106f-4f4b-bb3f-d413710bbe78"
err := loadbalancers.Delete(loadbalancerClient, loadbalancerID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

Create accepts a CreateOpts struct and creates a new loadbalancer using the values provided.

func Delete

func Delete(c *gcorecloud.ServiceClient, loadbalancerID string) (r tasks.Result)

Delete accepts a unique ID and deletes the loadbalancer associated with it.

func ExtractLoadBalancerIDFromTask

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

func ExtractLoadBalancersInto

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

Types

type CreateHealthMonitorOpts

type CreateHealthMonitorOpts struct {
	Type           types.HealthMonitorType `json:"type" required:"true"`
	Delay          int                     `json:"delay" required:"true"`
	MaxRetries     int                     `json:"max_retries" required:"true"`
	Timeout        int                     `json:"timeout" required:"true"`
	MaxRetriesDown int                     `json:"max_retries_down,omitempty"`
	HTTPMethod     *types.HTTPMethod       `json:"http_method,omitempty"`
	URLPath        string                  `json:"url_path,omitempty"`
}

CreateHealthMonitorOpts represents options used to create a loadbalancer health monitor.

type CreateListenerOpts

type CreateListenerOpts struct {
	Name             string             `json:"name" required:"true" validate:"required,name"`
	ProtocolPort     int                `json:"protocol_port" required:"true"`
	Protocol         types.ProtocolType `json:"protocol" required:"true"`
	Certificate      string             `json:"certificate,omitempty"`
	CertificateChain string             `json:"certificate_chain,omitempty"`
	PrivateKey       string             `json:"private_key,omitempty"`
	Pools            []CreatePoolOpts   `json:"pools,omitempty" validate:"omitempty,dive"`
}

CreateListenerOpts represents options used to create a loadbalancer listener.

type CreateOpts

type CreateOpts struct {
	Name         string               `json:"name" required:"true" validate:"required,name"`
	Listeners    []CreateListenerOpts `json:"listeners" required:"true" validate:"required,dive"`
	VipNetworkID string               `json:"vip_network_id,omitempty"`
	VipSubnetID  string               `json:"vip_subnet_id,omitempty"`
}

CreateOpts represents options used to create a loadbalancer.

func (CreateOpts) ToLoadBalancerCreateMap

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

ToLoadBalancerCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

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

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

type CreatePoolMemberOpts

type CreatePoolMemberOpts struct {
	ID           string `json:"id,omitempty"`
	Address      net.IP `json:"address" required:"true"`
	ProtocolPort int    `json:"protocol_port" required:"true"`
	Weight       int    `json:"weight,omitempty"`
	SubnetID     string `json:"subnet_id,omitempty"`
	InstanceID   string `json:"instance_id,omitempty"`
}

CreatePoolMemberOpts represents options used to create a loadbalancer listener pool member.

type CreatePoolOpts

type CreatePoolOpts struct {
	Name                  string                        `json:"name" required:"true" validate:"required,name"`
	Protocol              types.ProtocolType            `json:"protocol" required:"true"`
	Members               []CreatePoolMemberOpts        `json:"members"`
	HealthMonitor         *CreateHealthMonitorOpts      `json:"healthmonitor,omitempty"`
	LoadBalancerAlgorithm types.LoadBalancerAlgorithm   `json:"lb_algorithm,omitempty"`
	SessionPersistence    *CreateSessionPersistenceOpts `json:"session_persistence,omitempty"`
}

CreatePoolOpts represents options used to create a loadbalancer listener pool.

type CreateSessionPersistenceOpts

type CreateSessionPersistenceOpts struct {
	PersistenceGranularity string                `json:"persistence_granularity,omitempty"`
	PersistenceTimeout     int                   `json:"persistence_timeout,omitempty"`
	Type                   types.PersistenceType `json:"type" required:"true"`
	CookieName             string                `json:"cookie_name,omitempty"`
}

CreateSessionPersistenceOpts represents options used to create a loadbalancer listener pool session persistence rules.

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 LoadBalancer.

func Get

func Get(c *gcorecloud.ServiceClient, id string) (r GetResult)

Get retrieves a specific loadbalancer based on its unique ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a loadbalancer resource.

func (GetResult) ExtractInto

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

type LoadBalancer

type LoadBalancer struct {
	Name               string                   `json:"name"`
	ID                 string                   `json:"id"`
	ProvisioningStatus types.ProvisioningStatus `json:"provisioning_status"`
	OperationStatus    types.OperatingStatus    `json:"operating_status"`
	VipAddress         net.IP                   `json:"vip_address"`
	VipPortID          string                   `json:"vip_port_id"`
	Listeners          []gcorecloud.ItemID      `json:"listeners"`
	CreatorTaskID      *string                  `json:"creator_task_id"`
	TaskID             *string                  `json:"task_id"`
	CreatedAt          gcorecloud.JSONRFC3339Z  `json:"created_at"`
	UpdatedAt          *gcorecloud.JSONRFC3339Z `json:"updated_at"`
	ProjectID          int                      `json:"project_id"`
	RegionID           int                      `json:"region_id"`
	Region             string                   `json:"region"`
}

LoadBalancer represents a loadbalancer structure.

func ExtractLoadBalancers

func ExtractLoadBalancers(r pagination.Page) ([]LoadBalancer, error)

ExtractLoadBalancer accepts a Page struct, specifically a LoadBalancerPage struct, and extracts the elements into a slice of LoadBalancer structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

func ListAll(c *gcorecloud.ServiceClient) ([]LoadBalancer, error)

ListAll returns all LBs

func (LoadBalancer) IsDeleted

func (lb LoadBalancer) IsDeleted() bool

type LoadBalancerPage

type LoadBalancerPage struct {
	pagination.LinkedPageBase
}

LoadBalancerPage is the page returned by a pager when traversing over a collection of loadbalancers.

func (LoadBalancerPage) IsEmpty

func (r LoadBalancerPage) IsEmpty() (bool, error)

IsEmpty checks whether a LoadBalancerPage struct is empty.

func (LoadBalancerPage) NextPageURL

func (r LoadBalancerPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of loadbalancers has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type LoadBalancerTaskResult

type LoadBalancerTaskResult struct {
	LoadBalancers []string `json:"loadbalancers"`
}

type UpdateOpts

type UpdateOpts struct {
	Name string `json:"name,omitempty" required:"true" validate:"required,name"`
}

UpdateOpts represents options used to update a loadbalancer.

func (UpdateOpts) ToLoadBalancerUpdateMap

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

ToLoadBalancerUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

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

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

type UpdateResult

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

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a LoadBalancer.

func Update

func Update(c *gcorecloud.ServiceClient, loadbalancerID string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts a UpdateOpts struct and updates an existing loadbalancer using the values provided. For more information, see the Create function.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*LoadBalancer, error)

Extract is a function that accepts a result and extracts a loadbalancer resource.

func (UpdateResult) ExtractInto

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

Directories

Path Synopsis
loadbalancers unit tests
loadbalancers unit tests

Jump to

Keyboard shortcuts

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