loadbalancers

package
v0.5.45 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MPL-2.0 Imports: 10 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"`
	SecretID         string             `json:"secret_id,omitempty"`
	SNISecretID      []string           `json:"sni_secret_id,omitempty"`
	InsertXForwarded bool               `json:"insert_x_forwarded"`
}

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,omitempty" validate:"omitempty,dive"`
	VipNetworkID string                                      `json:"vip_network_id,allowed_without=VipPortID,omitempty"`
	VipSubnetID  string                                      `json:"vip_subnet_id,omitempty"`
	VipPortID    string                                      `json:"vip_port_id,allowed_without=VipNetworkID,omitempty"`
	Flavor       *string                                     `json:"flavor,omitempty"`
	Tags         []string                                    `json:"tag,omitempty"`
	Metadata     map[string]string                           `json:"metadata,omitempty"`
	FloatingIP   *instances.CreateNewInterfaceFloatingIPOpts `json:"floating_ip,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"`
	MonitorAddress net.IP `json:"monitor_address,omitempty"`
	MonitorPort    *int   `json:"monitor_port,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 CustomSecurityGroup added in v0.4.27

type CustomSecurityGroup struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

CustomSecurityGroup represents a loadbalancer's custom security group.

type CustomSecurityGroupCreateResult added in v0.4.27

type CustomSecurityGroupCreateResult struct {
	gcorecloud.ErrResult
}

CustomSecurityGroupCreateResult represents the result of a creation of custom security group

func CreateCustomSecurityGroup added in v0.4.27

func CreateCustomSecurityGroup(c *gcorecloud.ServiceClient, loadbalancerID string) (r CustomSecurityGroupCreateResult)

CreateCustomSecurityGroup accepts a unique ID and create a custom security group for the load balancer's ingress port.

type CustomSecurityGroupGetResult added in v0.4.27

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

CustomSecurityGroupGetResult represents the result of a get operation of custom security group

func ListCustomSecurityGroup added in v0.4.27

func ListCustomSecurityGroup(c *gcorecloud.ServiceClient, loadbalancerID string) (r CustomSecurityGroupGetResult)

ListCustomSecurityGroup accepts a unique ID and returns a custom security group for the load balancer's ingress port.

func (CustomSecurityGroupGetResult) Extract added in v0.4.27

func (r CustomSecurityGroupGetResult) Extract() ([]CustomSecurityGroup, error)

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

func (CustomSecurityGroupGetResult) ExtractInto added in v0.4.27

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

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

type ListOpts struct {
	ShowStats        bool              `q:"show_stats" validate:"omitempty"`
	AssignedFloating bool              `q:"assigned_floating" validate:"omitempty"`
	MetadataK        string            `q:"metadata_k" validate:"omitempty"`
	MetadataKV       map[string]string `q:"metadata_kv" validate:"omitempty"`
}

ListOpts allows the filtering and sorting List API response.

func (ListOpts) ToLoadBalancerListQuery added in v0.5.16

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

ToLoadBalancerListQuery formats a ListOpts into a query string.

func (ListOpts) ToLoadBalancerQuery added in v0.5.20

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

ToFloatingIPListQuery formats a ListOpts into a query string.

type ListOptsBuilder added in v0.5.16

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

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

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"`
	Tags               []string                 `json:"tags"`
	Flavor             lbflavors.Flavor         `json:"flavor"`
	Metadata           []metadata.Metadata      `json:"metadata"`
}

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

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