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 ¶
- func Create(c *gcorecloud.ServiceClient, opts CreateOptsBuilder, ...) (r tasks.Result)
- func Delete(c *gcorecloud.ServiceClient, loadbalancerID string, ...) (r tasks.Result)
- func ExtractLoadBalancerIDFromTask(task *tasks.Task) (string, error)
- func ExtractLoadBalancersInto(r pagination.Page, v interface{}) error
- func List(c *gcorecloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func Resize(c *gcorecloud.ServiceClient, loadbalancerID string, opts ResizeOptsBuilder, ...) (r tasks.Result)
- type CreateHealthMonitorOpts
- type CreateListenerOpts
- type CreateLoggingOpts
- type CreateOpts
- type CreateOptsBuilder
- type CreatePoolMemberOpts
- type CreatePoolOpts
- type CreateRetentionPolicyOpts
- type CreateSessionPersistenceOpts
- type CustomSecurityGroup
- type CustomSecurityGroupCreateResult
- type CustomSecurityGroupGetResult
- type GetOpts
- type GetOptsBuilder
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type LoadBalancer
- type LoadBalancerPage
- type LoadBalancerTaskResult
- type Logging
- type NetworkPortFixedIP
- type ResizeOpts
- type ResizeOptsBuilder
- type RetentionPolicy
- type UpdateLoggingOpts
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type UpdateRetentionPolicyOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(c *gcorecloud.ServiceClient, opts CreateOptsBuilder, reqOpts *gcorecloud.RequestOpts) (r tasks.Result)
Create accepts a CreateOpts struct and creates a new loadbalancer using the values provided.
func Delete ¶
func Delete(c *gcorecloud.ServiceClient, loadbalancerID string, reqOpts *gcorecloud.RequestOpts) (r tasks.Result)
Delete accepts a unique ID and deletes the loadbalancer associated with it.
func ExtractLoadBalancersInto ¶
func ExtractLoadBalancersInto(r pagination.Page, v interface{}) error
func List ¶
func List(c *gcorecloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
func Resize ¶ added in v0.6.38
func Resize(c *gcorecloud.ServiceClient, loadbalancerID string, opts ResizeOptsBuilder, reqOpts *gcorecloud.RequestOpts) (r tasks.Result)
Resize accepts a ResizeOpts struct and resizes a loadbalancer using the values provided.
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"` AllowedCIDRS []string `json:"allowed_cidrs,omitempty" validate:"omitempty,dive,cidr"` TimeoutClientData *int `json:"timeout_client_data,omitempty"` TimeoutMemberData *int `json:"timeout_member_data,omitempty"` TimeoutMemberConnect *int `json:"timeout_member_connect,omitempty"` ConnectionLimit *int `json:"connection_limit,omitempty"` }
CreateListenerOpts represents options used to create a loadbalancer listener.
type CreateLoggingOpts ¶ added in v0.6.29
type CreateLoggingOpts struct { Enabled bool `json:"enabled"` TopicName string `json:"topic_name,omitempty"` DestinationRegionID int `json:"destination_region_id,omitempty"` RetentionPolicy *CreateRetentionPolicyOpts `json:"retention_policy,omitempty" validate:"omitempty,dive"` }
CreateLoggingOpts represents options used to configure logging for a loadbalancer.
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,omitempty" validate:"omitempty,allowed_without=VipPortID"` VipSubnetID string `json:"vip_subnet_id,omitempty"` VipPortID string `json:"vip_port_id,omitempty" validate:"omitempty,allowed_without=VipNetworkID"` VIPIPFamily types.IPFamilyType `json:"vip_ip_family,omitempty" validate:"omitempty,enum"` Flavor *string `json:"flavor,omitempty"` Tags []string `json:"tag,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` FloatingIP *instances.CreateNewInterfaceFloatingIPOpts `json:"floating_ip,omitempty"` Logging *CreateLoggingOpts `json:"logging,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 ¶
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 CreateRetentionPolicyOpts ¶ added in v0.6.29
type CreateRetentionPolicyOpts struct {
Period int `json:"period,omitempty"`
}
CreateRetentionPolicyOpts represents options used to configure logging topic retention policy for a loadbalancer.
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
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 GetOpts ¶ added in v0.7.3
type GetOpts struct { ShowStats bool `q:"show_stats" validate:"omitempty"` WithDdos bool `q:"with_ddos" validate:"omitempty"` }
GetOpts allows the filtering and sorting Get API response.
func (GetOpts) ToLoadBalancerGetQuery ¶ added in v0.7.3
ToLoadBalancerListQuery formats a ListOpts into a query string.
type GetOptsBuilder ¶ added in v0.7.3
GetOptsBuilder allows extensions to add additional parameters to the Get request.
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, opts GetOptsBuilder) (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"` LoggingEnabled bool `q:"logging_enabled" validate:"omitempty"` MetadataK string `q:"metadata_k" validate:"omitempty"` MetadataKV map[string]string `q:"metadata_kv" validate:"omitempty"` WithDdos bool `q:"with_ddos" validate:"omitempty"` Name string `q:"name" validate:"omitempty"` }
ListOpts allows the filtering and sorting List API response.
func (ListOpts) ToLoadBalancerListQuery ¶ added in v0.5.16
ToLoadBalancerListQuery formats a ListOpts into a query string.
func (ListOpts) ToLoadBalancerQuery ¶ added in v0.5.20
ToFloatingIPListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶ added in v0.5.16
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"` DdosProfile *ddos.Profile `json:"ddos_profile"` VrrpIPs []NetworkPortFixedIP `json:"vrrp_ips"` VipIPFamilyType types.IPFamilyType `json:"vip_ip_family"` AdditionalVips []NetworkPortFixedIP `json:"additional_vips"` FloatingIPs []instances.FloatingIP `json:"floating_ips"` Logging *Logging `json:"logging"` }
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, opts ListOptsBuilder) ([]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 Logging ¶ added in v0.6.29
type Logging struct { Enabled bool `json:"enabled"` TopicName string `json:"topic_name"` DestinationRegionID int `json:"destination_region_id"` RetentionPolicy *RetentionPolicy `json:"retention_policy"` }
Logging represents logging configuration for a loadbalancer.
type NetworkPortFixedIP ¶ added in v0.6.16
type NetworkPortFixedIP struct { IpAddress net.IP `json:"ip_address"` SubnetID string `json:"subnet_id"` }
NetworkPortFixedIP represents VRRP entry structure.
type ResizeOpts ¶ added in v0.6.38
type ResizeOpts struct {
Flavor string `json:"flavor" required:"true"`
}
ResizeOpts represents options used to resize a loadbalancer.
func (ResizeOpts) ToLoadBalancerResizeMap ¶ added in v0.6.38
func (opts ResizeOpts) ToLoadBalancerResizeMap() (map[string]interface{}, error)
ToLoadBalancerResizeMap builds a request body from ResizeOpts.
type ResizeOptsBuilder ¶ added in v0.6.38
ResizeOptsBuilder allows extensions to add additional parameters to the Resize request.
type RetentionPolicy ¶ added in v0.6.29
type RetentionPolicy struct {
Period int `json:"period"`
}
RetentionPolicy represents log retention policy configuration for a loadbalancer.
type UpdateLoggingOpts ¶ added in v0.6.29
type UpdateLoggingOpts struct { Enabled bool `json:"enabled"` TopicName string `json:"topic_name,omitempty"` DestinationRegionID int `json:"destination_region_id,omitempty"` RetentionPolicy *UpdateRetentionPolicyOpts `json:"retention_policy,omitempty" validate:"omitempty,dive"` }
UpdateLoggingOpts represents options used to configure logging for a loadbalancer.
type UpdateOpts ¶
type UpdateOpts struct { Name string `json:"name,omitempty"` Logging *UpdateLoggingOpts `json:"logging,omitempty"` }
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 ¶
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
type UpdateRetentionPolicyOpts ¶ added in v0.6.29
type UpdateRetentionPolicyOpts struct {
Period int `json:"period,omitempty"`
}
UpdateRetentionPolicyOpts represents options used to configure logging topic retention policy for a loadbalancer.