Touching up docs
diff --git a/rackspace/lb/v1/acl/requests.go b/rackspace/lb/v1/acl/requests.go
index 3974923..a87287e 100644
--- a/rackspace/lb/v1/acl/requests.go
+++ b/rackspace/lb/v1/acl/requests.go
@@ -63,6 +63,10 @@
return itemMap{"accessList": items}, nil
}
+// Create is the operation responsible for adding network items to the access
+// rules for a particular load balancer. If network items already exist, the
+// new item will be appended. A single IP address or subnet range is considered
+// unique, and cannot be duplicated.
func Create(client *gophercloud.ServiceClient, loadBalancerID int, opts CreateOptsBuilder) CreateResult {
var res CreateResult
@@ -81,6 +85,8 @@
return res
}
+// BulkDelete will delete multiple network items from a load balancer's access
+// list in a single operation.
func BulkDelete(c *gophercloud.ServiceClient, loadBalancerID int, itemIDs []int) DeleteResult {
var res DeleteResult
@@ -100,6 +106,7 @@
return res
}
+// Delete will remove a single network item from a load balancer's access list.
func Delete(c *gophercloud.ServiceClient, lbID, itemID int) DeleteResult {
var res DeleteResult
_, res.Err = perigee.Request("DELETE", resourceURL(c, lbID, itemID), perigee.Options{
@@ -109,6 +116,8 @@
return res
}
+// DeleteAll will delete the entire contents of a load balancer's access list,
+// effectively resetting it and allowing all traffic.
func DeleteAll(c *gophercloud.ServiceClient, lbID int) DeleteResult {
var res DeleteResult
_, res.Err = perigee.Request("DELETE", rootURL(c, lbID), perigee.Options{
diff --git a/rackspace/lb/v1/acl/results.go b/rackspace/lb/v1/acl/results.go
index ed87be7..815caa7 100644
--- a/rackspace/lb/v1/acl/results.go
+++ b/rackspace/lb/v1/acl/results.go
@@ -7,16 +7,27 @@
"github.com/rackspace/gophercloud/pagination"
)
+// AccessList represents the rules of network access to a particular load
+// balancer.
type AccessList []NetworkItem
+// NetworkItem describes how an IP address or entire subnet may interact with a
+// load balancer.
type NetworkItem struct {
+ // The IP address or subnet (CIDR) that defines the network item.
Address string
- ID int
- Type Type
+
+ // The numeric unique ID for this item.
+ ID int
+
+ // Either ALLOW or DENY.
+ Type Type
}
+// Type defines how an item may connect to the load balancer.
type Type string
+// Convenience consts.
const (
ALLOW Type = "ALLOW"
DENY Type = "DENY"
@@ -50,10 +61,12 @@
return resp.List, err
}
+// CreateResult represents the result of a create operation.
type CreateResult struct {
gophercloud.ErrResult
}
+// DeleteResult represents the result of a delete operation.
type DeleteResult struct {
gophercloud.ErrResult
}
diff --git a/rackspace/lb/v1/common.go b/rackspace/lb/v1/common.go
index 89d9361..1f33709 100644
--- a/rackspace/lb/v1/common.go
+++ b/rackspace/lb/v1/common.go
@@ -20,3 +20,9 @@
}
return str
}
+
+// WithinRange returns TRUE if an integer falls within a defined range, and
+// FALSE if not.
+func WithinRange(val, min, max int) bool {
+ return val > min && val < max
+}
diff --git a/rackspace/lb/v1/lbs/fixtures.go b/rackspace/lb/v1/lbs/fixtures.go
index 64ec3c5..4c497e4 100644
--- a/rackspace/lb/v1/lbs/fixtures.go
+++ b/rackspace/lb/v1/lbs/fixtures.go
@@ -209,10 +209,7 @@
"persistenceType": "HTTP_COOKIE"
},
"connectionThrottle": {
- "minConnections": 10,
- "maxConnections": 100,
- "maxConnectionRate": 50,
- "rateInterval": 60
+ "maxConnections": 100
},
"cluster": {
"name": "c1.dfw1"
diff --git a/rackspace/lb/v1/lbs/requests.go b/rackspace/lb/v1/lbs/requests.go
index 6e1d614..a26e8ce 100644
--- a/rackspace/lb/v1/lbs/requests.go
+++ b/rackspace/lb/v1/lbs/requests.go
@@ -8,11 +8,19 @@
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/rackspace/lb/v1"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/acl"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/monitors"
"github.com/rackspace/gophercloud/rackspace/lb/v1/nodes"
"github.com/rackspace/gophercloud/rackspace/lb/v1/sessions"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/throttle"
"github.com/rackspace/gophercloud/rackspace/lb/v1/vips"
)
+var (
+ errNameRequired = errors.New("Name is a required attribute")
+ errTimeoutExceeded = errors.New("Timeout must be less than 120")
+)
+
// ListOptsBuilder allows extensions to add additional parameters to the
// List request.
type ListOptsBuilder interface {
@@ -55,17 +63,6 @@
})
}
-type enabledState *bool
-
-// Convenience vars to help setting enabled state.
-var (
- iTrue = true
- iFalse = false
-
- Enabled enabledState = &iTrue
- Disabled enabledState = &iFalse
-)
-
// CreateOptsBuilder is the interface options structs have to satisfy in order
// to be used in the main Create operation in this package. Since many
// extensions decorate or modify the common logic, it is useful for them to
@@ -93,7 +90,7 @@
// Half-Closed support provides the ability for one end of the connection to
// terminate its output, while still receiving data from the other end. Only
// available for TCP/TCP_CLIENT_FIRST protocols.
- HalfClosed enabledState
+ HalfClosed gophercloud.EnabledState
// Optional - the type of virtual IPs you want associated with the load
// balancer.
@@ -101,7 +98,7 @@
// Optional - the access list management feature allows fine-grained network
// access controls to be applied to the load balancer virtual IP address.
- AccessList string
+ AccessList *acl.AccessList
// Optional - algorithm that defines how traffic should be directed between
// back-end nodes.
@@ -112,10 +109,10 @@
// Optional - specifies a limit on the number of connections per IP address
// to help mitigate malicious or abusive traffic to your applications.
- ConnThrottle *ConnectionThrottle
+ ConnThrottle *throttle.ConnectionThrottle
- // Optional -
- //HealthMonitor string
+ // Optional
+ HealthMonitor *monitors.Monitor
// Optional - arbitrary information that can be associated with each LB.
Metadata map[string]interface{}
@@ -138,14 +135,9 @@
// would be redirected to https://example.com/page.html. Only available for
// HTTPS protocol (port=443), or HTTP protocol with a properly configured SSL
// termination (secureTrafficOnly=true, securePort=443).
- HTTPSRedirect enabledState
+ HTTPSRedirect gophercloud.EnabledState
}
-var (
- errNameRequired = errors.New("Name is a required attribute")
- errTimeoutExceeded = errors.New("Timeout must be less than 120")
-)
-
// ToLBCreateMap casts a CreateOpts struct to a map.
func (opts CreateOpts) ToLBCreateMap() (map[string]interface{}, error) {
lb := make(map[string]interface{})
@@ -177,14 +169,12 @@
if opts.HalfClosed != nil {
lb["halfClosed"] = opts.HalfClosed
}
-
if len(opts.VIPs) > 0 {
lb["virtualIps"] = opts.VIPs
}
-
- // if opts.AccessList != "" {
- // lb["accessList"] = opts.AccessList
- // }
+ if opts.AccessList != nil {
+ lb["accessList"] = &opts.AccessList
+ }
if opts.Algorithm != "" {
lb["algorithm"] = opts.Algorithm
}
@@ -194,9 +184,9 @@
if opts.ConnThrottle != nil {
lb["connectionThrottle"] = &opts.ConnThrottle
}
- // if opts.HealthMonitor != "" {
- // lb["healthMonitor"] = opts.HealthMonitor
- // }
+ if opts.HealthMonitor != nil {
+ lb["healthMonitor"] = &opts.HealthMonitor
+ }
if len(opts.Metadata) != 0 {
lb["metadata"] = opts.Metadata
}
@@ -318,7 +308,7 @@
Protocol string
// Optional - see the HalfClosed field in CreateOpts for more information.
- HalfClosed enabledState
+ HalfClosed gophercloud.EnabledState
// Optional - see the Algorithm field in CreateOpts for more information.
Algorithm string
@@ -330,7 +320,7 @@
Timeout int
// Optional - see the HTTPSRedirect field in CreateOpts for more information.
- HTTPSRedirect enabledState
+ HTTPSRedirect gophercloud.EnabledState
}
// ToLBUpdateMap casts an UpdateOpts struct to a map.
diff --git a/rackspace/lb/v1/lbs/requests_test.go b/rackspace/lb/v1/lbs/requests_test.go
index dafbda9..fd50883 100644
--- a/rackspace/lb/v1/lbs/requests_test.go
+++ b/rackspace/lb/v1/lbs/requests_test.go
@@ -3,9 +3,11 @@
import (
"testing"
+ "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/rackspace/lb/v1/nodes"
"github.com/rackspace/gophercloud/rackspace/lb/v1/sessions"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/throttle"
"github.com/rackspace/gophercloud/rackspace/lb/v1/vips"
th "github.com/rackspace/gophercloud/testhelper"
"github.com/rackspace/gophercloud/testhelper/client"
@@ -188,15 +190,10 @@
},
},
SessionPersistence: sessions.SessionPersistence{Type: "HTTP_COOKIE"},
- ConnectionThrottle: ConnectionThrottle{
- MinConns: 10,
- MaxConns: 100,
- MaxConnRate: 50,
- RateInterval: 60,
- },
- Cluster: Cluster{Name: "c1.dfw1"},
- Created: Datetime{Time: "2010-11-30T03:23:42Z"},
- Updated: Datetime{Time: "2010-11-30T03:23:44Z"},
+ ConnectionThrottle: throttle.ConnectionThrottle{MaxConnections: 100},
+ Cluster: Cluster{Name: "c1.dfw1"},
+ Created: Datetime{Time: "2010-11-30T03:23:42Z"},
+ Updated: Datetime{Time: "2010-11-30T03:23:44Z"},
SourceAddrs: SourceAddrs{
IPv4Public: "10.12.99.28",
IPv4Private: "10.0.0.0",
@@ -217,11 +214,11 @@
opts := UpdateOpts{
Name: "a-new-loadbalancer",
Protocol: "TCP",
- HalfClosed: Enabled,
+ HalfClosed: gophercloud.Enabled,
Algorithm: "RANDOM",
Port: 8080,
Timeout: 100,
- HTTPSRedirect: Disabled,
+ HTTPSRedirect: gophercloud.Disabled,
}
err := Update(client.ServiceClient(), id1, opts).ExtractErr()
diff --git a/rackspace/lb/v1/lbs/results.go b/rackspace/lb/v1/lbs/results.go
index 0ad998a..d015d9b 100644
--- a/rackspace/lb/v1/lbs/results.go
+++ b/rackspace/lb/v1/lbs/results.go
@@ -5,8 +5,10 @@
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/acl"
"github.com/rackspace/gophercloud/rackspace/lb/v1/nodes"
"github.com/rackspace/gophercloud/rackspace/lb/v1/sessions"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/throttle"
"github.com/rackspace/gophercloud/rackspace/lb/v1/vips"
)
@@ -124,10 +126,15 @@
// ConnectionThrottle specifies a limit on the number of connections per IP
// address to help mitigate malicious or abusive traffic to your applications.
- ConnectionThrottle ConnectionThrottle
+ ConnectionThrottle throttle.ConnectionThrottle
// TODO
SourceAddrs SourceAddrs `mapstructure:"sourceAddresses"`
+
+ // Represents the access rules for this particular load balancer. IP addresses
+ // or subnet ranges, depending on their type (ALLOW or DENY), can be permitted
+ // or blocked.
+ AccessList acl.AccessList
}
// SourceAddrs - temp
@@ -138,14 +145,6 @@
IPv6Private string `json:"ipv6Servicenet" mapstructure:"ipv6Servicenet"`
}
-// ConnectionThrottle - temp
-type ConnectionThrottle struct {
- MinConns int `json:"minConnections" mapstructure:"minConnections"`
- MaxConns int `json:"maxConnections" mapstructure:"maxConnections"`
- MaxConnRate int `json:"maxConnectionRate" mapstructure:"maxConnectionRate"`
- RateInterval int `json:"rateInterval" mapstructure:"rateInterval"`
-}
-
// ConnectionLogging - temp
type ConnectionLogging struct {
Enabled bool
diff --git a/rackspace/lb/v1/monitors/requests.go b/rackspace/lb/v1/monitors/requests.go
index 606c72e..aa6ec5b 100644
--- a/rackspace/lb/v1/monitors/requests.go
+++ b/rackspace/lb/v1/monitors/requests.go
@@ -6,6 +6,13 @@
"github.com/racker/perigee"
"github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1"
+)
+
+var (
+ errAttemptLimit = errors.New("AttemptLimit field must be an int greater than 1 and less than 10")
+ errDelay = errors.New("Delay field must be an int greater than 1 and less than 10")
+ errTimeout = errors.New("Timeout field must be an int greater than 1 and less than 10")
)
// UpdateOptsBuilder is the interface options structs have to satisfy in order
@@ -30,27 +37,17 @@
Timeout int
}
-var (
- errAttemptLimit = errors.New("AttemptLimit field must be an int greater than 1 and less than 10")
- errDelay = errors.New("Delay field must be an int greater than 1 and less than 10")
- errTimeout = errors.New("Timeout field must be an int greater than 1 and less than 10")
-)
-
-func withinRange(val, min, max int) bool {
- return val > min && val < max
-}
-
// ToMonitorUpdateMap produces a map for updating CONNECT monitors.
func (opts UpdateConnectMonitorOpts) ToMonitorUpdateMap() (map[string]interface{}, error) {
type m map[string]interface{}
- if !withinRange(opts.AttemptLimit, 1, 10) {
+ if !v1.WithinRange(opts.AttemptLimit, 1, 10) {
return m{}, errAttemptLimit
}
- if !withinRange(opts.Delay, 1, 3600) {
+ if !v1.WithinRange(opts.Delay, 1, 3600) {
return m{}, errDelay
}
- if !withinRange(opts.Timeout, 1, 300) {
+ if !v1.WithinRange(opts.Timeout, 1, 300) {
return m{}, errTimeout
}
@@ -98,13 +95,13 @@
func (opts UpdateHTTPMonitorOpts) ToMonitorUpdateMap() (map[string]interface{}, error) {
type m map[string]interface{}
- if !withinRange(opts.AttemptLimit, 1, 10) {
+ if !v1.WithinRange(opts.AttemptLimit, 1, 10) {
return m{}, errAttemptLimit
}
- if !withinRange(opts.Delay, 1, 3600) {
+ if !v1.WithinRange(opts.Delay, 1, 3600) {
return m{}, errDelay
}
- if !withinRange(opts.Timeout, 1, 300) {
+ if !v1.WithinRange(opts.Timeout, 1, 300) {
return m{}, errTimeout
}
if opts.Type != HTTP && opts.Type != HTTPS {
diff --git a/rackspace/lb/v1/nodes/requests.go b/rackspace/lb/v1/nodes/requests.go
index 026ecd8..1c3765a 100644
--- a/rackspace/lb/v1/nodes/requests.go
+++ b/rackspace/lb/v1/nodes/requests.go
@@ -169,12 +169,6 @@
return res
}
-// IntToPointer is a function for converting integers into integer pointers.
-// This is useful when updating the weight of a node.
-func IntToPointer(i int) *int {
- return &i
-}
-
// UpdateOptsBuilder represents a type that can be converted into a JSON-like
// map structure.
type UpdateOptsBuilder interface {
diff --git a/rackspace/lb/v1/nodes/requests_test.go b/rackspace/lb/v1/nodes/requests_test.go
index 7eabd29..f888a14 100644
--- a/rackspace/lb/v1/nodes/requests_test.go
+++ b/rackspace/lb/v1/nodes/requests_test.go
@@ -3,6 +3,7 @@
import (
"testing"
+ "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
"github.com/rackspace/gophercloud/testhelper/client"
@@ -149,7 +150,7 @@
opts := UpdateOpts{
Address: "1.2.3.4",
- Weight: IntToPointer(10),
+ Weight: gophercloud.IntToPointer(10),
Condition: DRAINING,
Type: SECONDARY,
}
diff --git a/rackspace/lb/v1/sessions/doc.go b/rackspace/lb/v1/sessions/doc.go
index fcc2d21..dcec0a8 100644
--- a/rackspace/lb/v1/sessions/doc.go
+++ b/rackspace/lb/v1/sessions/doc.go
@@ -1,6 +1,6 @@
/*
-Package nodes provides information and interaction with the Session Persistence
-feature of the Rackspace Cloud Load Balancer service.
+Package sessions provides information and interaction with the Session
+Persistence feature of the Rackspace Cloud Load Balancer service.
Session persistence is a feature of the load balancing service that forces
multiple requests from clients (of the same protocol) to be directed to the
diff --git a/rackspace/lb/v1/ssl/requests.go b/rackspace/lb/v1/ssl/requests.go
index c103d7a..e1fbbbd 100644
--- a/rackspace/lb/v1/ssl/requests.go
+++ b/rackspace/lb/v1/ssl/requests.go
@@ -9,8 +9,14 @@
"github.com/rackspace/gophercloud/pagination"
)
+var (
+ errPrivateKey = errors.New("PrivateKey is a required field")
+ errCertificate = errors.New("Certificate is a required field")
+ errIntCertificate = errors.New("IntCertificate is a required field")
+)
+
// UpdateOptsBuilder is the interface options structs have to satisfy in order
-// to be used in the main Create operation in this package.
+// to be used in the main Update operation in this package.
type UpdateOptsBuilder interface {
ToSSLUpdateMap() (map[string]interface{}, error)
}
@@ -37,12 +43,6 @@
SecureTrafficOnly *bool
}
-var (
- errPrivateKey = errors.New("PrivateKey is a required field")
- errCertificate = errors.New("Certificate is a required field")
- errIntCertificate = errors.New("IntCertificate is a required field")
-)
-
// ToSSLUpdateMap casts a CreateOpts struct to a map.
func (opts UpdateOpts) ToSSLUpdateMap() (map[string]interface{}, error) {
ssl := make(map[string]interface{})
@@ -124,6 +124,8 @@
return res
}
+// ListCerts will list all of the certificate mappings associated with a
+// SSL-terminated HTTP load balancer.
func ListCerts(c *gophercloud.ServiceClient, lbID int) pagination.Pager {
url := certURL(c, lbID)
return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
@@ -131,10 +133,13 @@
})
}
+// AddCertOptsBuilder is the interface options structs have to satisfy in order
+// to be used in the AddCert operation in this package.
type AddCertOptsBuilder interface {
ToCertAddMap() (map[string]interface{}, error)
}
+// AddCertOpts represents the options used when adding a new certificate mapping.
type AddCertOpts struct {
HostName string
PrivateKey string
@@ -142,6 +147,7 @@
IntCertificate string
}
+// ToCertAddMap will cast an AddCertOpts struct to a map for JSON serialization.
func (opts AddCertOpts) ToCertAddMap() (map[string]interface{}, error) {
cm := make(map[string]interface{})
@@ -166,6 +172,10 @@
return map[string]interface{}{"certificateMapping": cm}, nil
}
+// AddCert will add a new SSL certificate and allow an SSL-terminated HTTP
+// load balancer to use it. This feature is useful because it allows multiple
+// certificates to be used. The maximum number of certificates that can be
+// stored per LB is 20.
func AddCert(c *gophercloud.ServiceClient, lbID int, opts AddCertOptsBuilder) AddCertResult {
var res AddCertResult
@@ -185,6 +195,7 @@
return res
}
+// GetCert will show the details of an existing SSL certificate.
func GetCert(c *gophercloud.ServiceClient, lbID, certID int) GetCertResult {
var res GetCertResult
@@ -197,10 +208,13 @@
return res
}
+// UpdateCertOptsBuilder is the interface options structs have to satisfy in
+// order to be used in the UpdateCert operation in this package.
type UpdateCertOptsBuilder interface {
ToCertUpdateMap() (map[string]interface{}, error)
}
+// UpdateCertOpts represents the options needed to update a SSL certificate.
type UpdateCertOpts struct {
HostName string
PrivateKey string
@@ -208,6 +222,8 @@
IntCertificate string
}
+// ToCertUpdateMap will cast an UpdateCertOpts struct into a map for JSON
+// seralization.
func (opts UpdateCertOpts) ToCertUpdateMap() (map[string]interface{}, error) {
cm := make(map[string]interface{})
@@ -227,6 +243,8 @@
return map[string]interface{}{"certificateMapping": cm}, nil
}
+// UpdateCert is the operation responsible for updating the details of an
+// existing SSL certificate.
func UpdateCert(c *gophercloud.ServiceClient, lbID, certID int, opts UpdateCertOptsBuilder) UpdateCertResult {
var res UpdateCertResult
@@ -246,6 +264,8 @@
return res
}
+// DeleteCert is the operation responsible for permanently removing a SSL
+// certificate.
func DeleteCert(c *gophercloud.ServiceClient, lbID, certID int) DeleteResult {
var res DeleteResult
diff --git a/rackspace/lb/v1/ssl/results.go b/rackspace/lb/v1/ssl/results.go
index d3f860b..283f774 100644
--- a/rackspace/lb/v1/ssl/results.go
+++ b/rackspace/lb/v1/ssl/results.go
@@ -69,6 +69,8 @@
return &response.SSL, err
}
+// Certificate represents an SSL certificate associated with an SSL-terminated
+// HTTP load balancer.
type Certificate struct {
ID int
HostName string
@@ -76,6 +78,7 @@
IntCertificate string `mapstructure:"intermediateCertificate"`
}
+// CertPage represents a page of certificates.
type CertPage struct {
pagination.LinkedPageBase
}
@@ -89,8 +92,8 @@
return len(is) == 0, nil
}
-// ExtractCertMappings accepts a Page struct, specifically a CertMappingPage struct, and extracts
-// the elements into a slice of CertMapping structs. In other words, a generic
+// ExtractCerts accepts a Page struct, specifically a CertPage struct, and
+// extracts the elements into a slice of Cert structs. In other words, a generic
// collection is mapped into a relevant slice.
func ExtractCerts(page pagination.Page) ([]Certificate, error) {
type NestedMap struct {
@@ -129,14 +132,17 @@
return &response.Cert, err
}
+// AddCertResult represents the result of an AddCert operation.
type AddCertResult struct {
certResult
}
+// GetCertResult represents the result of a GetCert operation.
type GetCertResult struct {
certResult
}
+// UpdateCertResult represents the result of an UpdateCert operation.
type UpdateCertResult struct {
certResult
}