Adding more LB docs
diff --git a/rackspace/lb/v1/lbs/doc.go b/rackspace/lb/v1/lbs/doc.go
index 185ebbf..6047d3f 100644
--- a/rackspace/lb/v1/lbs/doc.go
+++ b/rackspace/lb/v1/lbs/doc.go
@@ -1,6 +1,44 @@
/*
+Package lbs provides information and interaction with the Load Balancer API
+resource for the Rackspace Cloud Load Balancer service.
+
A load balancer is a logical device which belongs to a cloud account. It is
used to distribute workloads between multiple back-end systems or services,
-based on the criteria defined as part of its configuration.
+based on the criteria defined as part of its configuration. This configuration
+is defined using the Create operation, and can be updated with Update.
+
+To conserve IPv4 address space, it is highly recommended that you share Virtual
+IPs between load balancers. If you have at least one load balancer, you may
+create subsequent ones that share a single virtual IPv4 and/or a single IPv6 by
+passing in a virtual IP ID to the Update operation (instead of a type). This
+feature is also highly desirable if you wish to load balance both an unsecured
+and secure protocol using one IP or DNS name. In order to share a virtual IP,
+each Load Balancer must utilize a unique port.
+
+All load balancers have a Status attribute that shows the current configuration
+status of the device. This status is immutable by the caller and is updated
+automatically based on state changes within the service. When a load balancer
+is first created, it is placed into a BUILD state while the configuration is
+being generated and applied based on the request. Once the configuration is
+applied and finalized, it is in an ACTIVE status. In the event of a
+configuration change or update, the status of the load balancer changes to
+PENDING_UPDATE to signify configuration changes are in progress but are not yet
+been finalized. Load balancers in a SUSPENDED status are configured to reject
+traffic and does not forward requests to back-end nodes.
+
+A HTTP load balancer has the X-Forwarded-For (XFF) HTTP header set by default.
+This header contains the originating IP address of a client connecting to a web
+server through an HTTP proxy or load balancer, which many web applications are
+already designed to use when determining the source address for a request.
+
+It also includes the X-Forwarded-Proto (XFP) HTTP header, which has been added
+for identifying the originating protocol of an HTTP request as "http" or
+"https" depending on what protocol the client requested. This is useful when
+using SSL termination.
+
+Finally, it also includes the X-Forwarded-Port HTTP header, which has been
+added for being able to generate secure URLs containing the specified port.
+This header, along with the X-Forwarded-For header, provide the needed
+information to the underlying application servers.
*/
package lbs
diff --git a/rackspace/lb/v1/lbs/requests.go b/rackspace/lb/v1/lbs/requests.go
index 5d45c14..0aef0cd 100644
--- a/rackspace/lb/v1/lbs/requests.go
+++ b/rackspace/lb/v1/lbs/requests.go
@@ -36,6 +36,8 @@
return q.String(), nil
}
+// List is the operation responsible for returning a paginated collection of
+// load balancers. You may pass in a ListOpts struct to filter results.
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
url := rootURL(client)
if opts != nil {
@@ -53,6 +55,7 @@
type enabledState *bool
+// Convenience vars to help setting enabled state.
var (
iTrue = true
iFalse = false
@@ -105,9 +108,10 @@
// Optional - specifies a limit on the number of connections per IP address
// to help mitigate malicious or abusive traffic to your applications.
- //??? ConnThrottle string
+ ConnThrottle *ConnectionThrottle
- //??? HealthMonitor string
+ // Optional -
+ //HealthMonitor string
// Optional - arbitrary information that can be associated with each LB.
Metadata map[string]interface{}
@@ -121,7 +125,7 @@
// Optional - specifies whether multiple requests from clients are directed
// to the same node.
- //??? SessionPersistence
+ SessionPersistence *SessionPersistence
// Optional - enables or disables HTTP to HTTPS redirection for the load
// balancer. When enabled, any HTTP request returns status code 301 (Moved
@@ -171,7 +175,6 @@
}
if len(opts.VIPs) > 0 {
-
lb["virtualIps"] = opts.VIPs
}
@@ -184,9 +187,9 @@
if opts.ConnectionLogging != nil {
lb["connectionLogging"] = &opts.ConnectionLogging
}
- // if opts.ConnThrottle != "" {
- // lb["connectionThrottle"] = opts.ConnThrottle
- // }
+ if opts.ConnThrottle != nil {
+ lb["connectionThrottle"] = &opts.ConnThrottle
+ }
// if opts.HealthMonitor != "" {
// lb["healthMonitor"] = opts.HealthMonitor
// }
@@ -199,9 +202,9 @@
if opts.Timeout > 0 {
lb["timeout"] = opts.Timeout
}
- // if opts.SessionPersistence != "" {
- // lb["sessionPersistence"] = opts.SessionPersistence
- // }
+ if opts.SessionPersistence != nil {
+ lb["sessionPersistence"] = &opts.SessionPersistence
+ }
if opts.HTTPSRedirect != nil {
lb["httpsRedirect"] = &opts.HTTPSRedirect
}
@@ -209,6 +212,18 @@
return map[string]interface{}{"loadBalancer": lb}, nil
}
+// Create is the operation responsible for asynchronously provisioning a new
+// load balancer based on the configuration defined in CreateOpts. Once the
+// request is validated and progress has started on the provisioning process, a
+// response struct is returned. When extracted (with Extract()), you have
+// to the load balancer's unique ID and status.
+//
+// Once an ID is attained, you can check on the progress of the operation by
+// calling Get and passing in the ID. If the corresponding request cannot be
+// fulfilled due to insufficient or invalid data, a HTTP 400 (Bad Request)
+// error response is returned with information regarding the nature of the
+// failure in the body of the response. Failures in the validation process are
+// non-recoverable and require the caller to correct the cause of the failure.
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
var res CreateResult
@@ -228,6 +243,10 @@
return res
}
+// Get is the operation responsible for providing detailed information
+// regarding a specific load balancer which is configured and associated with
+// your account. This operation is not capable of returning details for a load
+// balancer which has been deleted.
func Get(c *gophercloud.ServiceClient, id int) GetResult {
var res GetResult
@@ -240,6 +259,13 @@
return res
}
+// BulkDelete removes all the load balancers referenced in the slice of IDs.
+// Any and all configuration data associated with these load balancers are
+// immediately purged and is not recoverable.
+//
+// If one of the items in the list cannot be removed due to its current status,
+// a 400 Bad Request error is returned along with the IDs of the ones the
+// system identified as potential failures for this request.
func BulkDelete(c *gophercloud.ServiceClient, ids []int) DeleteResult {
var res DeleteResult
@@ -259,6 +285,7 @@
return res
}
+// Delete removes a single load balancer.
func Delete(c *gophercloud.ServiceClient, id int) DeleteResult {
var res DeleteResult
@@ -270,27 +297,37 @@
return res
}
+// UpdateOptsBuilder represents a type that can be converted into a JSON-like
+// map structure.
type UpdateOptsBuilder interface {
ToLBUpdateMap() (map[string]interface{}, error)
}
+// UpdateOpts represent the options for updating an existing load balancer.
type UpdateOpts struct {
+ // Optional - new name of the load balancer.
Name string
+ // Optional - the new protocol you want your load balancer to have.
Protocol Protocol
+ // Optional - see the HalfClosed field in CreateOpts for more information.
HalfClosed enabledState
+ // Optional - see the Algorithm field in CreateOpts for more information.
Algorithm Algorithm
+ // Optional - see the Port field in CreateOpts for more information.
Port int
+ // Optional - see the Timeout field in CreateOpts for more information.
Timeout int
+ // Optional - see the HTTPSRedirect field in CreateOpts for more information.
HTTPSRedirect enabledState
}
-// ToLBUpdateMap casts a CreateOpts struct to a map.
+// ToLBUpdateMap casts an UpdateOpts struct to a map.
func (opts UpdateOpts) ToLBUpdateMap() (map[string]interface{}, error) {
lb := make(map[string]interface{})
@@ -319,6 +356,12 @@
return map[string]interface{}{"loadBalancer": lb}, nil
}
+// Update is the operation responsible for asynchronously updating the
+// attributes of a specific load balancer. Upon successful validation of the
+// request, the service returns a 202 Accepted response and the load balancer
+// enters a PENDING_UPDATE state. A user can poll the load balancer with Get to
+// wait for the changes to be applied. When this happens, the load balancer will
+// return to an ACTIVE state.
func Update(c *gophercloud.ServiceClient, id int, opts UpdateOptsBuilder) UpdateResult {
var res UpdateResult
diff --git a/rackspace/lb/v1/lbs/results.go b/rackspace/lb/v1/lbs/results.go
index 42ccfae..2feb856 100644
--- a/rackspace/lb/v1/lbs/results.go
+++ b/rackspace/lb/v1/lbs/results.go
@@ -8,6 +8,7 @@
"github.com/rackspace/gophercloud/rackspace/lb/v1/nodes"
)
+// Protocol represents the network protocol which the load balancer accepts.
type Protocol string
// The constants below represent all the compatible load balancer protocols.
@@ -62,6 +63,7 @@
WRR = "WEIGHTED_ROUND_ROBIN"
)
+// Status represents the potential state of a load balancer resource.
type Status string
const (
@@ -94,10 +96,12 @@
DELETED = "DELETED"
)
+// Datetime represents the structure of a Created or Updated field.
type Datetime struct {
Time string
}
+// VIP - temp
type VIP struct {
Address string `json:"address,omitempty"`
ID int `json:"id,omitempty"`
@@ -105,6 +109,7 @@
Version string `json:"ipVersion,omitempty" mapstructure:"ipVersion"`
}
+// LoadBalancer represents a load balancer API resource.
type LoadBalancer struct {
// Human-readable name for the load balancer.
Name string
@@ -112,11 +117,12 @@
// The unique ID for the load balancer.
ID int
- // Represents the service protocol being load balanced.
+ // Represents the service protocol being load balanced. See Protocol type for
+ // a list of accepted values.
Protocol Protocol
// Defines how traffic should be directed between back-end nodes. The default
- // algorithm is RANDOM.
+ // algorithm is RANDOM. See Algorithm type for a list of accepted values.
Algorithm Algorithm
// The current status of the load balancer.
@@ -134,25 +140,41 @@
// Datetime when the LB was created.
Updated Datetime
+ // Port number for the service you are load balancing.
Port int
+ // HalfClosed provides the ability for one end of the connection to
+ // terminate its output while still receiving data from the other end. This
+ // is only available on TCP/TCP_CLIENT_FIRST protocols.
HalfClosed bool
+ // Timeout represents the timeout value between a load balancer and its
+ // nodes. Defaults to 30 seconds with a maximum of 120 seconds.
Timeout int
+ // TODO
Cluster Cluster
+ // Nodes shows all the back-end nodes which are associated with the load
+ // balancer. These are the devices which are delivered traffic.
Nodes []nodes.Node
+ // TODO
ConnectionLogging ConnectionLogging
+ // SessionPersistence specifies whether multiple requests from clients are
+ // directed to the same node.
SessionPersistence SessionPersistence
+ // ConnectionThrottle specifies a limit on the number of connections per IP
+ // address to help mitigate malicious or abusive traffic to your applications.
ConnectionThrottle ConnectionThrottle
+ // TODO
SourceAddrs SourceAddrs `mapstructure:"sourceAddresses"`
}
+// SourceAddrs - temp
type SourceAddrs struct {
IPv4Public string `json:"ipv4Public" mapstructure:"ipv4Public"`
IPv4Private string `json:"ipv4Servicenet" mapstructure:"ipv4Servicenet"`
@@ -160,10 +182,12 @@
IPv6Private string `json:"ipv6Servicenet" mapstructure:"ipv6Servicenet"`
}
+// SessionPersistence - temp
type SessionPersistence struct {
Type string `json:"persistenceType" mapstructure:"persistenceType"`
}
+// ConnectionThrottle - temp
type ConnectionThrottle struct {
MinConns int `json:"minConnections" mapstructure:"minConnections"`
MaxConns int `json:"maxConnections" mapstructure:"maxConnections"`
@@ -171,10 +195,12 @@
RateInterval int `json:"rateInterval" mapstructure:"rateInterval"`
}
+// ConnectionLogging - temp
type ConnectionLogging struct {
Enabled bool
}
+// Cluster - temp
type Cluster struct {
Name string
}
@@ -226,18 +252,22 @@
return &response.LB, err
}
+// CreateResult represents the result of a create operation.
type CreateResult struct {
commonResult
}
+// DeleteResult represents the result of a delete operation.
type DeleteResult struct {
gophercloud.ErrResult
}
+// UpdateResult represents the result of an update operation.
type UpdateResult struct {
gophercloud.ErrResult
}
+// GetResult represents the result of a get operation.
type GetResult struct {
commonResult
}