Documentation ¶
Overview ¶
Package load_balancers contains functionality for working with ECL Load Balancer resources.
Example to List Load Balancers
listOpts := load_balancers.ListOpts{ Status: "ACTIVE", } allPages, err := load_balancers.List(networkClient, listOpts).AllPages() if err != nil { panic(err) } allLoadBalancers, err := load_balancers.ExtractLoadBalancers(allPages) if err != nil { panic(err) } for _, loadBalancer := range allLoadBalancers { fmt.Printf("%+v\n", loadBalancer) }
Example to Show Load Balancer
loadBalancerID := "f44e063c-5fea-45b8-9124-956995eafe2a" loadBalancer, err := load_balancers.Get(networkClient, loadBalancerID).Extract() if err != nil { panic(err) } fmt.Printf("%+v\n", loadBalancer)
Example to Create a Load Balancer
createOpts := load_balancers.CreateOpts{ AvailabilityZone: "zone1-groupa", Description: "Load Balancer 1", LoadBalancerPlanID: "69bf1e91-73f6-41d5-84c4-91de21a9af05", Name: "abcdefghijklmnopqrstuvwxyz", TenantID: "5cc454d62d8c4a0595134b2632bf2263", } loadBalancer, err := load_balancers.Create(networkClient, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Load Balancer
loadBalancerID := "f44e063c-5fea-45b8-9124-956995eafe2a" name := "new_name" updateOpts := load_balancers.UpdateOpts{ Name: &name, } loadBalancer, err := load_balancers.Update(networkClient, loadBalancerID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Load Balancer
loadBalancerID := "165fb257-2365-4c05-b368-a7bed21bb927" err := load_balancers.Delete(networkClient, loadBalancerID).ExtractErr() if err != nil { panic(err) }
Index ¶
- func IDFromName(client *eclcloud.ServiceClient, name string) (string, error)
- func List(c *eclcloud.ServiceClient, opts ListOpts) pagination.Pager
- type CreateOpts
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type LoadBalancer
- type LoadBalancerPage
- type UpdateOpts
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IDFromName ¶
func IDFromName(client *eclcloud.ServiceClient, name string) (string, error)
IDFromName is a convenience function that returns a Load Balancer's ID, given its name.
func List ¶
func List(c *eclcloud.ServiceClient, opts ListOpts) pagination.Pager
List returns a Pager which allows you to iterate over a collection of Load Balancers. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Default policy settings return only those Load Balancers that are owned by the tenant who submits the request, unless the request is submitted by a user with administrative rights.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // AvailabilityZone is one of the Virtual Server (Nova)’s availability zone. AvailabilityZone string `json:"availability_zone,omitempty"` // Description is description Description string `json:"description,omitempty"` // LoadBalancerPlanID is the UUID of Load Balancer Plan. LoadBalancerPlanID string `json:"load_balancer_plan_id" required:"true"` // Name is a human-readable name of the Load Balancer. Name string `json:"name,omitempty"` // The UUID of the project who owns the Load Balancer. Only administrative users // can specify a project UUID other than their own. TenantID string `json:"tenant_id,omitempty"` }
CreateOpts represents the attributes used when creating a new Load Balancer.
func (CreateOpts) ToLoadBalancerCreateMap ¶
func (opts CreateOpts) ToLoadBalancerCreateMap() (map[string]interface{}, error)
ToLoadBalancerCreateMap builds a request body from CreateOpts.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Load Balancer.
func Create ¶
func Create(c *eclcloud.ServiceClient, opts CreateOpts) (r CreateResult)
Create accepts a CreateOpts struct and creates a new Load Balancer using the values provided. You must remember to provide a valid LoadBalancerPlanID.
func (CreateResult) Extract ¶
func (r CreateResult) Extract() (*LoadBalancer, error)
Extract is a function that accepts a result and extracts a Load Balancer resource.
type DeleteResult ¶
DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.
func Delete ¶
func Delete(c *eclcloud.ServiceClient, id string) (r DeleteResult)
Delete accepts a unique ID and deletes the Load Balancer associated with it.
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 Load Balancer.
func Get ¶
func Get(c *eclcloud.ServiceClient, id string) (r GetResult)
Get retrieves a specific Load Balancer 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 Load Balancer resource.
type ListOpts ¶
type ListOpts struct { AdminUsername string `q:"admin_username"` AvailabilityZone string `q:"availability_zone"` DefaultGateway string `q:"default_gateway"` Description string `q:"description"` ID string `q:"id"` LoadBalancerPlanID string `q:"load_balancer_plan_id"` Name string `q:"name"` Status string `q:"status"` TenantID string `q:"tenant_id"` UserUsername string `q:"user_username"` }
ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the Load Balancer attributes you want to see returned. SortKey allows you to sort by a particular Load Balancer attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
func (ListOpts) ToLoadBalancersListQuery ¶
ToLoadBalancersListQuery formats a ListOpts into a query string.
type LoadBalancer ¶
type LoadBalancer struct { // AdminPassword is admin's password AdminPassword string `json:"admin_password"` // AdminUsername is admin's username AdminUsername string `json:"admin_username"` // AvailabilityZone is one of the Virtual Server (Nova)’s availability zone. AvailabilityZone string `json:"availability_zone"` // Description is description DefaultGateway *string `json:"default_gateway"` // Description is description Description string `json:"description"` // UUID representing the Load Balancer. ID string `json:"id"` // Attached interfaces by Load Balancer. Interfaces []load_balancer_interfaces.LoadBalancerInterface `json:"interfaces"` // LoadBalancerPlanID is the UUID of Load Balancer Plan. LoadBalancerPlanID string `json:"load_balancer_plan_id"` // Name of the Load Balancer. Name string `json:"name"` // The Load Balancer status. Status string `json:"status"` // Connected syslog servers. SyslogServers []load_balancer_syslog_servers.LoadBalancerSyslogServer `json:"syslog_servers"` // TenantID is the project owner of the Load Balancer. TenantID string `json:"tenant_id"` // User's password placeholder. UserPassword string `json:"user_password"` // User's username placeholder. UserUsername string `json:"user_username"` }
LoadBalancer represents a Load Balancer. See package documentation for a top-level description of what this is.
func ExtractLoadBalancers ¶
func ExtractLoadBalancers(r pagination.Page) ([]LoadBalancer, error)
ExtractLoadBalancers accepts a Page struct, specifically a LoadBalancerPage struct, and extracts the elements into a slice of Load Balancer structs. In other words, a generic collection is mapped into a relevant slice.
type LoadBalancerPage ¶
type LoadBalancerPage struct {
pagination.LinkedPageBase
}
LoadBalancerPage is the page returned by a pager when traversing over a collection of load balancers.
func (LoadBalancerPage) IsEmpty ¶
func (r LoadBalancerPage) IsEmpty() (bool, error)
IsEmpty checks whether a LoadBalancerPage struct is empty.
type UpdateOpts ¶
type UpdateOpts struct { // Description is description DefaultGateway *interface{} `json:"default_gateway,omitempty"` // Description is description Description *string `json:"description,omitempty"` // LoadBalancerPlanID is the UUID of Load Balancer Plan. LoadBalancerPlanID string `json:"load_balancer_plan_id,omitempty"` // Name is a human-readable name of the Load Balancer. Name *string `json:"name,omitempty"` }
UpdateOpts represents the attributes used when updating an existing Load Balancer.
func (UpdateOpts) ToLoadBalancerUpdateMap ¶
func (opts UpdateOpts) ToLoadBalancerUpdateMap() (map[string]interface{}, error)
ToLoadBalancerUpdateMap builds a request body from UpdateOpts.
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 Load Balancer.
func Update ¶
func Update(c *eclcloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult)
Update accepts a UpdateOpts struct and updates an existing Load Balancer using the values provided.
func (UpdateResult) Extract ¶
func (r UpdateResult) Extract() (*LoadBalancer, error)
Extract is a function that accepts a result and extracts a Load Balancer resource.