initial migration from rackspace/gophercloud
diff --git a/endpoint_search.go b/endpoint_search.go
index 5189431..9887947 100644
--- a/endpoint_search.go
+++ b/endpoint_search.go
@@ -1,21 +1,5 @@
package gophercloud
-import "errors"
-
-var (
- // ErrServiceNotFound is returned when no service in a service catalog matches
- // the provided EndpointOpts. This is generally returned by provider service
- // factory methods like "NewComputeV2()" and can mean that a service is not
- // enabled for your account.
- ErrServiceNotFound = errors.New("No suitable service could be found in the service catalog.")
-
- // ErrEndpointNotFound is returned when no available endpoints match the
- // provided EndpointOpts. This is also generally returned by provider service
- // factory methods, and usually indicates that a region was specified
- // incorrectly.
- ErrEndpointNotFound = errors.New("No suitable endpoint could be found in the service catalog.")
-)
-
// Availability indicates to whom a specific service endpoint is accessible:
// the internet at large, internal networks only, or only to administrators.
// Different identity services use different terminology for these. Identity v2
diff --git a/errors.go b/errors.go
new file mode 100644
index 0000000..e47aff1
--- /dev/null
+++ b/errors.go
@@ -0,0 +1,188 @@
+package gophercloud
+
+import "fmt"
+
+// BaseError is an error type that all other error types embed.
+type BaseError struct {
+ OriginalError string
+ Function string
+}
+
+func (e *BaseError) Error() string {
+ return "An error occurred while executing a Gophercloud request."
+}
+
+// ErrInvalidInput is an error type used for most non-HTTP Gophercloud errors.
+type ErrInvalidInput struct {
+ BaseError
+ Argument string
+ Value interface{}
+}
+
+func (e *ErrInvalidInput) Error() string {
+ return fmt.Sprintf("Invalid input provided for argument [%s]: [%+v]", e.Argument, e.Value)
+}
+
+// ErrUnexpectedResponseCode is returned by the Request method when a response code other than
+// those listed in OkCodes is encountered.
+type ErrUnexpectedResponseCode struct {
+ BaseError
+ URL string
+ Method string
+ Expected []int
+ Actual int
+ Body []byte
+}
+
+func (err *ErrUnexpectedResponseCode) Error() string {
+ return fmt.Sprintf(
+ "Expected HTTP response code %v when accessing [%s %s], but got %d instead\n%s",
+ err.Expected, err.Method, err.URL, err.Actual, err.Body,
+ )
+}
+
+type ErrDefault400 struct {
+ *ErrUnexpectedResponseCode
+}
+type ErrDefault401 struct {
+ *ErrUnexpectedResponseCode
+}
+type ErrDefault404 struct {
+ *ErrUnexpectedResponseCode
+}
+type ErrDefault405 struct {
+ *ErrUnexpectedResponseCode
+}
+type ErrDefault408 struct {
+ *ErrUnexpectedResponseCode
+}
+type ErrDefault429 struct {
+ *ErrUnexpectedResponseCode
+}
+type ErrDefault500 struct {
+ *ErrUnexpectedResponseCode
+}
+type ErrDefault503 struct {
+ *ErrUnexpectedResponseCode
+}
+
+func (e ErrDefault400) Error() string {
+ return "Invalid request due to incorrect syntax or missing required parameters."
+}
+func (e ErrDefault401) Error() string {
+ return "Authentication failed"
+}
+func (e ErrDefault404) Error() string {
+ return "Resource not found"
+}
+func (e ErrDefault405) Error() string {
+ return "Method not allowed"
+}
+func (e ErrDefault408) Error() string {
+ return "The server timed out waiting for the request"
+}
+func (e ErrDefault429) Error() string {
+ return "Too many requests have been sent in a given amount of time. Pause requests, wait up to one minute, and try again."
+}
+func (e ErrDefault500) Error() string {
+ return "Internal Server Error"
+}
+func (e ErrDefault503) Error() string {
+ return "The service is currently unable to handle the request due to a temporary overloading or maintenance. This is a temporary condition. Try again later."
+}
+
+// Err400er is the interface resource error types implement to override the error message
+// from a 400 error.
+type Err400er interface {
+ Error400(*ErrUnexpectedResponseCode) error
+}
+
+// Err401er is the interface resource error types implement to override the error message
+// from a 401 error.
+type Err401er interface {
+ Error401(*ErrUnexpectedResponseCode) error
+}
+
+// Err404er is the interface resource error types implement to override the error message
+// from a 404 error.
+type Err404er interface {
+ Error404(*ErrUnexpectedResponseCode) error
+}
+
+// Err405er is the interface resource error types implement to override the error message
+// from a 405 error.
+type Err405er interface {
+ Error405(*ErrUnexpectedResponseCode) error
+}
+
+// Err408er is the interface resource error types implement to override the error message
+// from a 408 error.
+type Err408er interface {
+ Error408(*ErrUnexpectedResponseCode) error
+}
+
+// Err429er is the interface resource error types implement to override the error message
+// from a 429 error.
+type Err429er interface {
+ Error429(*ErrUnexpectedResponseCode) error
+}
+
+// Err500er is the interface resource error types implement to override the error message
+// from a 500 error.
+type Err500er interface {
+ Error500(*ErrUnexpectedResponseCode) error
+}
+
+// Err503er is the interface resource error types implement to override the error message
+// from a 503 error.
+type Err503er interface {
+ Error503(*ErrUnexpectedResponseCode) error
+}
+
+type ErrTimeOut struct {
+ *BaseError
+}
+
+func (e *ErrTimeOut) Error() string {
+ return "A time out occurred"
+}
+
+type ErrUnableToReauthenticate struct {
+ *BaseError
+}
+
+func (e *ErrUnableToReauthenticate) Error() string {
+ return fmt.Sprintf("Unable to re-authenticate: %s", e.OriginalError)
+}
+
+type ErrErrorAfterReauthentication struct {
+ *BaseError
+}
+
+func (e *ErrErrorAfterReauthentication) Error() string {
+ return fmt.Sprintf("Successfully re-authenticated, but got error executing request: %s", e.OriginalError)
+}
+
+// ErrServiceNotFound is returned when no service in a service catalog matches
+// the provided EndpointOpts. This is generally returned by provider service
+// factory methods like "NewComputeV2()" and can mean that a service is not
+// enabled for your account.
+type ErrServiceNotFound struct {
+ *BaseError
+}
+
+func (e *ErrServiceNotFound) Error() string {
+ return "No suitable service could be found in the service catalog."
+}
+
+// ErrEndpointNotFound is returned when no available endpoints match the
+// provided EndpointOpts. This is also generally returned by provider service
+// factory methods, and usually indicates that a region was specified
+// incorrectly.
+type ErrEndpointNotFound struct {
+ *BaseError
+}
+
+func (e *ErrEndpointNotFound) Error() string {
+ return "No suitable endpoint could be found in the service catalog."
+}
diff --git a/openstack/compute/v2/servers/requests.go b/openstack/compute/v2/servers/requests.go
index 8e60daa..c938895 100644
--- a/openstack/compute/v2/servers/requests.go
+++ b/openstack/compute/v2/servers/requests.go
@@ -6,9 +6,9 @@
"errors"
"fmt"
+ "github.com/jrperritt/gophercloud/openstack/compute/v2/images"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/compute/v2/flavors"
- "github.com/rackspace/gophercloud/openstack/compute/v2/images"
"github.com/rackspace/gophercloud/pagination"
)
@@ -130,7 +130,7 @@
// CreateOpts specifies server creation parameters.
type CreateOpts struct {
// Name [required] is the name to assign to the newly launched server.
- Name string
+ Name string `b:"name,required"`
// ImageRef [optional; required if ImageName is not provided] is the ID or full
// URL to the image that contains the server's OS and initial state.
@@ -247,6 +247,30 @@
server["personality"] = opts.Personality
}
+ // If ImageRef isn't provided, use ImageName to ascertain the image ID.
+ if opts.ImageRef == "" {
+ if opts.ImageName == "" {
+ return nil, errors.New("One and only one of ImageRef and ImageName must be provided.")
+ }
+ imageID, err := images.IDFromName(client, opts.ImageName)
+ if err != nil {
+ return nil, err
+ }
+ server["imageRef"] = imageID
+ }
+
+ // If FlavorRef isn't provided, use FlavorName to ascertain the flavor ID.
+ if opts.FlavorRef == "" {
+ if opts.FlavorName == "" {
+ return nil, errors.New("One and only one of FlavorRef and FlavorName must be provided.")
+ }
+ flavorID, err := flavors.IDFromName(client, opts.FlavorName)
+ if err != nil {
+ return nil, err
+ }
+ server["flavorRef"] = flavorID
+ }
+
return map[string]interface{}{"server": server}, nil
}
@@ -260,38 +284,6 @@
return res
}
- // If ImageRef isn't provided, use ImageName to ascertain the image ID.
- if reqBody["server"].(map[string]interface{})["imageRef"].(string) == "" {
- imageName := reqBody["server"].(map[string]interface{})["imageName"].(string)
- if imageName == "" {
- res.Err = errors.New("One and only one of ImageRef and ImageName must be provided.")
- return res
- }
- imageID, err := images.IDFromName(client, imageName)
- if err != nil {
- res.Err = err
- return res
- }
- reqBody["server"].(map[string]interface{})["imageRef"] = imageID
- }
- delete(reqBody["server"].(map[string]interface{}), "imageName")
-
- // If FlavorRef isn't provided, use FlavorName to ascertain the flavor ID.
- if reqBody["server"].(map[string]interface{})["flavorRef"].(string) == "" {
- flavorName := reqBody["server"].(map[string]interface{})["flavorName"].(string)
- if flavorName == "" {
- res.Err = errors.New("One and only one of FlavorRef and FlavorName must be provided.")
- return res
- }
- flavorID, err := flavors.IDFromName(client, flavorName)
- if err != nil {
- res.Err = err
- return res
- }
- reqBody["server"].(map[string]interface{})["flavorRef"] = flavorID
- }
- delete(reqBody["server"].(map[string]interface{}), "flavorName")
-
_, res.Err = client.Post(listURL(client), reqBody, &res.Body, nil)
return res
}
@@ -814,14 +806,14 @@
}
// CreateImage makes a request against the nova API to schedule an image to be created of the server
-func CreateImage(client *gophercloud.ServiceClient, serverId string, opts CreateImageOptsBuilder) CreateImageResult {
+func CreateImage(client *gophercloud.ServiceClient, serverID string, opts CreateImageOptsBuilder) CreateImageResult {
var res CreateImageResult
reqBody, err := opts.ToServerCreateImageMap()
if err != nil {
res.Err = err
return res
}
- response, err := client.Post(actionURL(client, serverId), reqBody, nil, &gophercloud.RequestOpts{
+ response, err := client.Post(actionURL(client, serverID), reqBody, nil, &gophercloud.RequestOpts{
OkCodes: []int{202},
})
res.Err = err
diff --git a/params.go b/params.go
index 4d0f1e6..cd5bc65 100644
--- a/params.go
+++ b/params.go
@@ -9,6 +9,10 @@
"time"
)
+type Opts struct {
+ ServiceClient *ServiceClient
+}
+
// EnabledState is a convenience type, mostly used in Create and Update
// operations. Because the zero value of a bool is FALSE, we need to use a
// pointer instead to indicate zero-ness.
diff --git a/provider_client.go b/provider_client.go
index 53fce73..5f55442 100644
--- a/provider_client.go
+++ b/provider_client.go
@@ -11,7 +11,7 @@
)
// DefaultUserAgent is the default User-Agent string set in the request header.
-const DefaultUserAgent = "gophercloud/1.0.0"
+const DefaultUserAgent = "gophercloud/2.0.0"
// UserAgent represents a User-Agent header.
type UserAgent struct {
@@ -85,46 +85,27 @@
// content type of the request will default to "application/json" unless overridden by MoreHeaders.
// It's an error to specify both a JSONBody and a RawBody.
JSONBody interface{}
- // RawBody contains an io.ReadSeeker that will be consumed by the request directly. No content-type
+ // RawBody contains an io.Reader that will be consumed by the request directly. No content-type
// will be set unless one is provided explicitly by MoreHeaders.
- RawBody io.ReadSeeker
-
+ RawBody io.Reader
// JSONResponse, if provided, will be populated with the contents of the response body parsed as
// JSON.
JSONResponse interface{}
// OkCodes contains a list of numeric HTTP status codes that should be interpreted as success. If
// the response has a different code, an error will be returned.
OkCodes []int
-
// MoreHeaders specifies additional HTTP headers to be provide on the request. If a header is
// provided with a blank value (""), that header will be *omitted* instead: use this to suppress
// the default Accept header or an inferred Content-Type, for example.
MoreHeaders map[string]string
}
-// UnexpectedResponseCodeError is returned by the Request method when a response code other than
-// those listed in OkCodes is encountered.
-type UnexpectedResponseCodeError struct {
- URL string
- Method string
- Expected []int
- Actual int
- Body []byte
-}
-
-func (err *UnexpectedResponseCodeError) Error() string {
- return fmt.Sprintf(
- "Expected HTTP response code %v when accessing [%s %s], but got %d instead\n%s",
- err.Expected, err.Method, err.URL, err.Actual, err.Body,
- )
-}
-
var applicationJSON = "application/json"
// Request performs an HTTP request using the ProviderClient's current HTTPClient. An authentication
// header will automatically be provided.
func (client *ProviderClient) Request(method, url string, options RequestOpts) (*http.Response, error) {
- var body io.ReadSeeker
+ var body io.Reader
var contentType *string
// Derive the content body by either encoding an arbitrary object as JSON, or by taking a provided
@@ -192,8 +173,8 @@
if err != nil {
return nil, fmt.Errorf("Error trying to re-authenticate: %s", err)
}
- if options.RawBody != nil {
- options.RawBody.Seek(0, 0)
+ if seeker, ok := options.RawBody.(io.ReadSeeker); ok && options.RawBody != nil {
+ seeker.Seek(0, 0)
}
resp.Body.Close()
resp, err = client.Request(method, url, options)
@@ -221,7 +202,7 @@
if !ok {
body, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
- return resp, &UnexpectedResponseCodeError{
+ return resp, &ErrUnexpectedResponseCode{
URL: url,
Method: method,
Expected: options.OkCodes,
diff --git a/rackspace/auth_env.go b/rackspace/auth_env.go
deleted file mode 100644
index 5852c3c..0000000
--- a/rackspace/auth_env.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package rackspace
-
-import (
- "fmt"
- "os"
-
- "github.com/rackspace/gophercloud"
-)
-
-var nilOptions = gophercloud.AuthOptions{}
-
-// ErrNoAuthUrl, ErrNoUsername, and ErrNoPassword errors indicate of the
-// required RS_AUTH_URL, RS_USERNAME, or RS_PASSWORD environment variables,
-// respectively, remain undefined. See the AuthOptions() function for more details.
-var (
- ErrNoAuthURL = fmt.Errorf("Environment variable RS_AUTH_URL or OS_AUTH_URL need to be set.")
- ErrNoUsername = fmt.Errorf("Environment variable RS_USERNAME or OS_USERNAME need to be set.")
- ErrNoPassword = fmt.Errorf("Environment variable RS_API_KEY or RS_PASSWORD needs to be set.")
-)
-
-func prefixedEnv(base string) string {
- value := os.Getenv("RS_" + base)
- if value == "" {
- value = os.Getenv("OS_" + base)
- }
- return value
-}
-
-// AuthOptionsFromEnv fills out an identity.AuthOptions structure with the
-// settings found on the various Rackspace RS_* environment variables.
-func AuthOptionsFromEnv() (gophercloud.AuthOptions, error) {
- authURL := prefixedEnv("AUTH_URL")
- username := prefixedEnv("USERNAME")
- password := prefixedEnv("PASSWORD")
- apiKey := prefixedEnv("API_KEY")
-
- if authURL == "" {
- return nilOptions, ErrNoAuthURL
- }
-
- if username == "" {
- return nilOptions, ErrNoUsername
- }
-
- if password == "" && apiKey == "" {
- return nilOptions, ErrNoPassword
- }
-
- ao := gophercloud.AuthOptions{
- IdentityEndpoint: authURL,
- Username: username,
- Password: password,
- APIKey: apiKey,
- }
-
- return ao, nil
-}
diff --git a/rackspace/blockstorage/v1/snapshots/delegate.go b/rackspace/blockstorage/v1/snapshots/delegate.go
deleted file mode 100644
index 1cd1b6e..0000000
--- a/rackspace/blockstorage/v1/snapshots/delegate.go
+++ /dev/null
@@ -1,131 +0,0 @@
-package snapshots
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots"
-)
-
-func updateURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL("snapshots", id)
-}
-
-// CreateOptsBuilder allows extensions to add additional parameters to the
-// Create request.
-type CreateOptsBuilder interface {
- ToSnapshotCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts contains options for creating a Snapshot. This object is passed to
-// the snapshots.Create function. For more information about these parameters,
-// see the Snapshot object.
-type CreateOpts struct {
- // REQUIRED
- VolumeID string
- // OPTIONAL
- Description string
- // OPTIONAL
- Force bool
- // OPTIONAL
- Name string
-}
-
-// ToSnapshotCreateMap assembles a request body based on the contents of a
-// CreateOpts.
-func (opts CreateOpts) ToSnapshotCreateMap() (map[string]interface{}, error) {
- s := make(map[string]interface{})
-
- if opts.VolumeID == "" {
- return nil, errors.New("Required CreateOpts field 'VolumeID' not set.")
- }
-
- s["volume_id"] = opts.VolumeID
-
- if opts.Description != "" {
- s["display_description"] = opts.Description
- }
- if opts.Name != "" {
- s["display_name"] = opts.Name
- }
- if opts.Force {
- s["force"] = opts.Force
- }
-
- return map[string]interface{}{"snapshot": s}, nil
-}
-
-// Create will create a new Snapshot based on the values in CreateOpts. To
-// extract the Snapshot object from the response, call the Extract method on the
-// CreateResult.
-func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
- return CreateResult{os.Create(client, opts)}
-}
-
-// Delete will delete the existing Snapshot with the provided ID.
-func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult {
- return os.Delete(client, id)
-}
-
-// Get retrieves the Snapshot with the provided ID. To extract the Snapshot
-// object from the response, call the Extract method on the GetResult.
-func Get(client *gophercloud.ServiceClient, id string) GetResult {
- return GetResult{os.Get(client, id)}
-}
-
-// List returns Snapshots.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client, os.ListOpts{})
-}
-
-// UpdateOptsBuilder is the interface options structs have to satisfy in order
-// to be used in the main Update operation in this package. Since many
-// extensions decorate or modify the common logic, it is useful for them to
-// satisfy a basic interface in order for them to be used.
-type UpdateOptsBuilder interface {
- ToSnapshotUpdateMap() (map[string]interface{}, error)
-}
-
-// UpdateOpts is the common options struct used in this package's Update
-// operation.
-type UpdateOpts struct {
- Name string
- Description string
-}
-
-// ToSnapshotUpdateMap casts a UpdateOpts struct to a map.
-func (opts UpdateOpts) ToSnapshotUpdateMap() (map[string]interface{}, error) {
- s := make(map[string]interface{})
-
- if opts.Name != "" {
- s["display_name"] = opts.Name
- }
- if opts.Description != "" {
- s["display_description"] = opts.Description
- }
-
- return map[string]interface{}{"snapshot": s}, nil
-}
-
-// Update accepts a UpdateOpts struct and updates an existing snapshot using the
-// values provided.
-func Update(c *gophercloud.ServiceClient, snapshotID string, opts UpdateOptsBuilder) UpdateResult {
- var res UpdateResult
-
- reqBody, err := opts.ToSnapshotUpdateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- // Send request to API
- _, res.Err = c.Request("PUT", updateURL(c, snapshotID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 201},
- })
-
- return res
-}
diff --git a/rackspace/blockstorage/v1/snapshots/delegate_test.go b/rackspace/blockstorage/v1/snapshots/delegate_test.go
deleted file mode 100644
index 1a02b46..0000000
--- a/rackspace/blockstorage/v1/snapshots/delegate_test.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package snapshots
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const endpoint = "http://localhost:57909/v1/12345"
-
-func endpointClient() *gophercloud.ServiceClient {
- return &gophercloud.ServiceClient{Endpoint: endpoint}
-}
-
-func TestUpdateURL(t *testing.T) {
- actual := updateURL(endpointClient(), "foo")
- expected := endpoint + "snapshots/foo"
- th.AssertEquals(t, expected, actual)
-}
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockListResponse(t)
-
- count := 0
-
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractSnapshots(page)
- if err != nil {
- t.Errorf("Failed to extract snapshots: %v", err)
- return false, err
- }
-
- expected := []Snapshot{
- Snapshot{
- ID: "289da7f8-6440-407c-9fb4-7db01ec49164",
- Name: "snapshot-001",
- },
- Snapshot{
- ID: "96c3bda7-c82a-4f50-be73-ca7621794835",
- Name: "snapshot-002",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertEquals(t, 1, count)
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockGetResponse(t)
-
- v, err := Get(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, v.Name, "snapshot-001")
- th.AssertEquals(t, v.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockCreateResponse(t)
-
- options := &CreateOpts{VolumeID: "1234", Name: "snapshot-001"}
- n, err := Create(fake.ServiceClient(), options).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.VolumeID, "1234")
- th.AssertEquals(t, n.Name, "snapshot-001")
- th.AssertEquals(t, n.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockDeleteResponse(t)
-
- res := Delete(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/blockstorage/v1/snapshots/doc.go b/rackspace/blockstorage/v1/snapshots/doc.go
deleted file mode 100644
index ad6064f..0000000
--- a/rackspace/blockstorage/v1/snapshots/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package snapshots provides information and interaction with the snapshot
-// API resource for the Rackspace Block Storage service.
-package snapshots
diff --git a/rackspace/blockstorage/v1/snapshots/results.go b/rackspace/blockstorage/v1/snapshots/results.go
deleted file mode 100644
index c81644c..0000000
--- a/rackspace/blockstorage/v1/snapshots/results.go
+++ /dev/null
@@ -1,147 +0,0 @@
-package snapshots
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots"
- "github.com/rackspace/gophercloud/pagination"
-
- "github.com/mitchellh/mapstructure"
-)
-
-// Status is the type used to represent a snapshot's status
-type Status string
-
-// Constants to use for supported statuses
-const (
- Creating Status = "CREATING"
- Available Status = "AVAILABLE"
- Deleting Status = "DELETING"
- Error Status = "ERROR"
- DeleteError Status = "ERROR_DELETING"
-)
-
-// Snapshot is the Rackspace representation of an external block storage device.
-type Snapshot struct {
- // The timestamp when this snapshot was created.
- CreatedAt string `mapstructure:"created_at"`
-
- // The human-readable description for this snapshot.
- Description string `mapstructure:"display_description"`
-
- // The human-readable name for this snapshot.
- Name string `mapstructure:"display_name"`
-
- // The UUID for this snapshot.
- ID string `mapstructure:"id"`
-
- // The random metadata associated with this snapshot. Note: unlike standard
- // OpenStack snapshots, this cannot actually be set.
- Metadata map[string]string `mapstructure:"metadata"`
-
- // Indicates the current progress of the snapshot's backup procedure.
- Progress string `mapstructure:"os-extended-snapshot-attributes:progress"`
-
- // The project ID.
- ProjectID string `mapstructure:"os-extended-snapshot-attributes:project_id"`
-
- // The size of the volume which this snapshot backs up.
- Size int `mapstructure:"size"`
-
- // The status of the snapshot.
- Status Status `mapstructure:"status"`
-
- // The ID of the volume which this snapshot seeks to back up.
- VolumeID string `mapstructure:"volume_id"`
-}
-
-// CreateResult represents the result of a create operation
-type CreateResult struct {
- os.CreateResult
-}
-
-// GetResult represents the result of a get operation
-type GetResult struct {
- os.GetResult
-}
-
-// UpdateResult represents the result of an update operation
-type UpdateResult struct {
- gophercloud.Result
-}
-
-func commonExtract(resp interface{}, err error) (*Snapshot, error) {
- if err != nil {
- return nil, err
- }
-
- var respStruct struct {
- Snapshot *Snapshot `json:"snapshot"`
- }
-
- err = mapstructure.Decode(resp, &respStruct)
-
- return respStruct.Snapshot, err
-}
-
-// Extract will get the Snapshot object out of the GetResult object.
-func (r GetResult) Extract() (*Snapshot, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// Extract will get the Snapshot object out of the CreateResult object.
-func (r CreateResult) Extract() (*Snapshot, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// Extract will get the Snapshot object out of the UpdateResult object.
-func (r UpdateResult) Extract() (*Snapshot, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// ExtractSnapshots extracts and returns Snapshots. It is used while iterating over a snapshots.List call.
-func ExtractSnapshots(page pagination.Page) ([]Snapshot, error) {
- var response struct {
- Snapshots []Snapshot `json:"snapshots"`
- }
-
- err := mapstructure.Decode(page.(os.ListResult).Body, &response)
- return response.Snapshots, err
-}
-
-// WaitUntilComplete will continually poll a snapshot until it successfully
-// transitions to a specified state. It will do this for at most the number of
-// seconds specified.
-func (snapshot Snapshot) WaitUntilComplete(c *gophercloud.ServiceClient, timeout int) error {
- return gophercloud.WaitFor(timeout, func() (bool, error) {
- // Poll resource
- current, err := Get(c, snapshot.ID).Extract()
- if err != nil {
- return false, err
- }
-
- // Has it been built yet?
- if current.Progress == "100%" {
- return true, nil
- }
-
- return false, nil
- })
-}
-
-// WaitUntilDeleted will continually poll a snapshot until it has been
-// successfully deleted, i.e. returns a 404 status.
-func (snapshot Snapshot) WaitUntilDeleted(c *gophercloud.ServiceClient, timeout int) error {
- return gophercloud.WaitFor(timeout, func() (bool, error) {
- // Poll resource
- _, err := Get(c, snapshot.ID).Extract()
-
- // Check for a 404
- if casted, ok := err.(*gophercloud.UnexpectedResponseCodeError); ok && casted.Actual == 404 {
- return true, nil
- } else if err != nil {
- return false, err
- }
-
- return false, nil
- })
-}
diff --git a/rackspace/blockstorage/v1/volumes/delegate.go b/rackspace/blockstorage/v1/volumes/delegate.go
deleted file mode 100644
index 4383494..0000000
--- a/rackspace/blockstorage/v1/volumes/delegate.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package volumes
-
-import (
- "fmt"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-type CreateOpts struct {
- os.CreateOpts
-}
-
-func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error) {
- if opts.Size < 75 || opts.Size > 1024 {
- return nil, fmt.Errorf("Size field must be between 75 and 1024")
- }
-
- return opts.CreateOpts.ToVolumeCreateMap()
-}
-
-// Create will create a new Volume based on the values in CreateOpts. To extract
-// the Volume object from the response, call the Extract method on the
-// CreateResult.
-func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) CreateResult {
- return CreateResult{os.Create(client, opts)}
-}
-
-// Delete will delete the existing Volume with the provided ID.
-func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult {
- return os.Delete(client, id)
-}
-
-// Get retrieves the Volume with the provided ID. To extract the Volume object
-// from the response, call the Extract method on the GetResult.
-func Get(client *gophercloud.ServiceClient, id string) GetResult {
- return GetResult{os.Get(client, id)}
-}
-
-// List returns volumes optionally limited by the conditions provided in ListOpts.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client, os.ListOpts{})
-}
-
-// UpdateOpts contain options for updating an existing Volume. This object is passed
-// to the volumes.Update function. For more information about the parameters, see
-// the Volume object.
-type UpdateOpts struct {
- // OPTIONAL
- Name string
- // OPTIONAL
- Description string
-}
-
-// ToVolumeUpdateMap assembles a request body based on the contents of an
-// UpdateOpts.
-func (opts UpdateOpts) ToVolumeUpdateMap() (map[string]interface{}, error) {
- v := make(map[string]interface{})
-
- if opts.Description != "" {
- v["display_description"] = opts.Description
- }
- if opts.Name != "" {
- v["display_name"] = opts.Name
- }
-
- return map[string]interface{}{"volume": v}, nil
-}
-
-// Update will update the Volume with provided information. To extract the updated
-// Volume from the response, call the Extract method on the UpdateResult.
-func Update(client *gophercloud.ServiceClient, id string, opts os.UpdateOptsBuilder) UpdateResult {
- return UpdateResult{os.Update(client, id, opts)}
-}
diff --git a/rackspace/blockstorage/v1/volumes/delegate_test.go b/rackspace/blockstorage/v1/volumes/delegate_test.go
deleted file mode 100644
index b6831f2..0000000
--- a/rackspace/blockstorage/v1/volumes/delegate_test.go
+++ /dev/null
@@ -1,107 +0,0 @@
-package volumes
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes"
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/testing"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockListResponse(t)
-
- count := 0
-
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractVolumes(page)
- if err != nil {
- t.Errorf("Failed to extract volumes: %v", err)
- return false, err
- }
-
- expected := []Volume{
- Volume{
- ID: "289da7f8-6440-407c-9fb4-7db01ec49164",
- Name: "vol-001",
- },
- Volume{
- ID: "96c3bda7-c82a-4f50-be73-ca7621794835",
- Name: "vol-002",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertEquals(t, 1, count)
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockGetResponse(t)
-
- v, err := Get(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, v.Name, "vol-001")
- th.AssertEquals(t, v.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockCreateResponse(t)
-
- n, err := Create(fake.ServiceClient(), CreateOpts{volumes.CreateOpts{Size: 75}}).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.Size, 4)
- th.AssertEquals(t, n.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
-}
-
-func TestSizeRange(t *testing.T) {
- _, err := Create(fake.ServiceClient(), CreateOpts{volumes.CreateOpts{Size: 1}}).Extract()
- if err == nil {
- t.Fatalf("Expected error, got none")
- }
-
- _, err = Create(fake.ServiceClient(), CreateOpts{volumes.CreateOpts{Size: 2000}}).Extract()
- if err == nil {
- t.Fatalf("Expected error, got none")
- }
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockDeleteResponse(t)
-
- res := Delete(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22")
- th.AssertNoErr(t, res.Err)
-}
-
-func TestUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockUpdateResponse(t)
-
- options := &UpdateOpts{Name: "vol-002"}
- v, err := Update(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22", options).Extract()
- th.AssertNoErr(t, err)
- th.CheckEquals(t, "vol-002", v.Name)
-}
diff --git a/rackspace/blockstorage/v1/volumes/doc.go b/rackspace/blockstorage/v1/volumes/doc.go
deleted file mode 100644
index b2be25c..0000000
--- a/rackspace/blockstorage/v1/volumes/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package volumes provides information and interaction with the volume
-// API resource for the Rackspace Block Storage service.
-package volumes
diff --git a/rackspace/blockstorage/v1/volumes/results.go b/rackspace/blockstorage/v1/volumes/results.go
deleted file mode 100644
index c7c2cc4..0000000
--- a/rackspace/blockstorage/v1/volumes/results.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package volumes
-
-import (
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes"
- "github.com/rackspace/gophercloud/pagination"
-
- "github.com/mitchellh/mapstructure"
-)
-
-// Volume wraps an Openstack volume
-type Volume os.Volume
-
-// CreateResult represents the result of a create operation
-type CreateResult struct {
- os.CreateResult
-}
-
-// GetResult represents the result of a get operation
-type GetResult struct {
- os.GetResult
-}
-
-// UpdateResult represents the result of an update operation
-type UpdateResult struct {
- os.UpdateResult
-}
-
-func commonExtract(resp interface{}, err error) (*Volume, error) {
- if err != nil {
- return nil, err
- }
-
- var respStruct struct {
- Volume *Volume `json:"volume"`
- }
-
- err = mapstructure.Decode(resp, &respStruct)
-
- return respStruct.Volume, err
-}
-
-// Extract will get the Volume object out of the GetResult object.
-func (r GetResult) Extract() (*Volume, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// Extract will get the Volume object out of the CreateResult object.
-func (r CreateResult) Extract() (*Volume, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// Extract will get the Volume object out of the UpdateResult object.
-func (r UpdateResult) Extract() (*Volume, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// ExtractVolumes extracts and returns Volumes. It is used while iterating over a volumes.List call.
-func ExtractVolumes(page pagination.Page) ([]Volume, error) {
- var response struct {
- Volumes []Volume `json:"volumes"`
- }
-
- err := mapstructure.Decode(page.(os.ListResult).Body, &response)
-
- return response.Volumes, err
-}
diff --git a/rackspace/blockstorage/v1/volumetypes/delegate.go b/rackspace/blockstorage/v1/volumetypes/delegate.go
deleted file mode 100644
index c96b3e4..0000000
--- a/rackspace/blockstorage/v1/volumetypes/delegate.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package volumetypes
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns all volume types.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client)
-}
-
-// Get will retrieve the volume type with the provided ID. To extract the volume
-// type from the result, call the Extract method on the GetResult.
-func Get(client *gophercloud.ServiceClient, id string) GetResult {
- return GetResult{os.Get(client, id)}
-}
diff --git a/rackspace/blockstorage/v1/volumetypes/delegate_test.go b/rackspace/blockstorage/v1/volumetypes/delegate_test.go
deleted file mode 100644
index 6e65c90..0000000
--- a/rackspace/blockstorage/v1/volumetypes/delegate_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package volumetypes
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockListResponse(t)
-
- count := 0
-
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractVolumeTypes(page)
- if err != nil {
- t.Errorf("Failed to extract volume types: %v", err)
- return false, err
- }
-
- expected := []VolumeType{
- VolumeType{
- ID: "289da7f8-6440-407c-9fb4-7db01ec49164",
- Name: "vol-type-001",
- ExtraSpecs: map[string]interface{}{
- "capabilities": "gpu",
- },
- },
- VolumeType{
- ID: "96c3bda7-c82a-4f50-be73-ca7621794835",
- Name: "vol-type-002",
- ExtraSpecs: map[string]interface{}{},
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertEquals(t, 1, count)
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.MockGetResponse(t)
-
- vt, err := Get(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertDeepEquals(t, vt.ExtraSpecs, map[string]interface{}{"serverNumber": "2"})
- th.AssertEquals(t, vt.Name, "vol-type-001")
- th.AssertEquals(t, vt.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
-}
diff --git a/rackspace/blockstorage/v1/volumetypes/doc.go b/rackspace/blockstorage/v1/volumetypes/doc.go
deleted file mode 100644
index 70122b7..0000000
--- a/rackspace/blockstorage/v1/volumetypes/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package volumetypes provides information and interaction with the volume type
-// API resource for the Rackspace Block Storage service.
-package volumetypes
diff --git a/rackspace/blockstorage/v1/volumetypes/results.go b/rackspace/blockstorage/v1/volumetypes/results.go
deleted file mode 100644
index 39c8d6f..0000000
--- a/rackspace/blockstorage/v1/volumetypes/results.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package volumetypes
-
-import (
- "github.com/mitchellh/mapstructure"
- os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-type VolumeType os.VolumeType
-
-type GetResult struct {
- os.GetResult
-}
-
-// Extract will get the Volume Type struct out of the response.
-func (r GetResult) Extract() (*VolumeType, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var res struct {
- VolumeType *VolumeType `json:"volume_type" mapstructure:"volume_type"`
- }
-
- err := mapstructure.Decode(r.Body, &res)
-
- return res.VolumeType, err
-}
-
-func ExtractVolumeTypes(page pagination.Page) ([]VolumeType, error) {
- var response struct {
- VolumeTypes []VolumeType `mapstructure:"volume_types"`
- }
-
- err := mapstructure.Decode(page.(os.ListResult).Body, &response)
- return response.VolumeTypes, err
-}
diff --git a/rackspace/cdn/v1/base/delegate.go b/rackspace/cdn/v1/base/delegate.go
deleted file mode 100644
index 5af7e07..0000000
--- a/rackspace/cdn/v1/base/delegate.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package base
-
-import (
- "github.com/rackspace/gophercloud"
-
- os "github.com/rackspace/gophercloud/openstack/cdn/v1/base"
-)
-
-// Get retrieves the home document, allowing the user to discover the
-// entire API.
-func Get(c *gophercloud.ServiceClient) os.GetResult {
- return os.Get(c)
-}
-
-// Ping retrieves a ping to the server.
-func Ping(c *gophercloud.ServiceClient) os.PingResult {
- return os.Ping(c)
-}
diff --git a/rackspace/cdn/v1/base/delegate_test.go b/rackspace/cdn/v1/base/delegate_test.go
deleted file mode 100644
index 731fc6d..0000000
--- a/rackspace/cdn/v1/base/delegate_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package base
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/cdn/v1/base"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestGetHomeDocument(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetSuccessfully(t)
-
- actual, err := Get(fake.ServiceClient()).Extract()
- th.CheckNoErr(t, err)
-
- expected := os.HomeDocument{
- "rel/cdn": map[string]interface{}{
- "href-template": "services{?marker,limit}",
- "href-vars": map[string]interface{}{
- "marker": "param/marker",
- "limit": "param/limit",
- },
- "hints": map[string]interface{}{
- "allow": []string{"GET"},
- "formats": map[string]interface{}{
- "application/json": map[string]interface{}{},
- },
- },
- },
- }
- th.CheckDeepEquals(t, expected, *actual)
-}
-
-func TestPing(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandlePingSuccessfully(t)
-
- err := Ping(fake.ServiceClient()).ExtractErr()
- th.CheckNoErr(t, err)
-}
diff --git a/rackspace/cdn/v1/base/doc.go b/rackspace/cdn/v1/base/doc.go
deleted file mode 100644
index 5582306..0000000
--- a/rackspace/cdn/v1/base/doc.go
+++ /dev/null
@@ -1,4 +0,0 @@
-// Package base provides information and interaction with the base API
-// resource in the Rackspace CDN service. This API resource allows for
-// retrieving the Home Document and pinging the root URL.
-package base
diff --git a/rackspace/cdn/v1/flavors/delegate.go b/rackspace/cdn/v1/flavors/delegate.go
deleted file mode 100644
index 7152fa2..0000000
--- a/rackspace/cdn/v1/flavors/delegate.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package flavors
-
-import (
- "github.com/rackspace/gophercloud"
-
- os "github.com/rackspace/gophercloud/openstack/cdn/v1/flavors"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a single page of CDN flavors.
-func List(c *gophercloud.ServiceClient) pagination.Pager {
- return os.List(c)
-}
-
-// Get retrieves a specific flavor based on its unique ID.
-func Get(c *gophercloud.ServiceClient, id string) os.GetResult {
- return os.Get(c, id)
-}
diff --git a/rackspace/cdn/v1/flavors/delegate_test.go b/rackspace/cdn/v1/flavors/delegate_test.go
deleted file mode 100644
index d6d299d..0000000
--- a/rackspace/cdn/v1/flavors/delegate_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-package flavors
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/cdn/v1/flavors"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleListCDNFlavorsSuccessfully(t)
-
- count := 0
-
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractFlavors(page)
- if err != nil {
- t.Errorf("Failed to extract flavors: %v", err)
- return false, err
- }
-
- expected := []os.Flavor{
- os.Flavor{
- ID: "europe",
- Providers: []os.Provider{
- os.Provider{
- Provider: "Fastly",
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "http://www.fastly.com",
- Rel: "provider_url",
- },
- },
- },
- },
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "https://www.poppycdn.io/v1.0/flavors/europe",
- Rel: "self",
- },
- },
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleGetCDNFlavorSuccessfully(t)
-
- expected := &os.Flavor{
- ID: "asia",
- Providers: []os.Provider{
- os.Provider{
- Provider: "ChinaCache",
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "http://www.chinacache.com",
- Rel: "provider_url",
- },
- },
- },
- },
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "https://www.poppycdn.io/v1.0/flavors/asia",
- Rel: "self",
- },
- },
- }
-
- actual, err := Get(fake.ServiceClient(), "asia").Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/cdn/v1/flavors/doc.go b/rackspace/cdn/v1/flavors/doc.go
deleted file mode 100644
index 4ad966e..0000000
--- a/rackspace/cdn/v1/flavors/doc.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// Package flavors provides information and interaction with the flavors API
-// resource in the Rackspace CDN service. This API resource allows for
-// listing flavors and retrieving a specific flavor.
-//
-// A flavor is a mapping configuration to a CDN provider.
-package flavors
diff --git a/rackspace/cdn/v1/serviceassets/delegate.go b/rackspace/cdn/v1/serviceassets/delegate.go
deleted file mode 100644
index 07c93a8..0000000
--- a/rackspace/cdn/v1/serviceassets/delegate.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package serviceassets
-
-import (
- "github.com/rackspace/gophercloud"
-
- os "github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets"
-)
-
-// Delete accepts a unique ID and deletes the CDN service asset associated with
-// it.
-func Delete(c *gophercloud.ServiceClient, id string, opts os.DeleteOptsBuilder) os.DeleteResult {
- return os.Delete(c, id, opts)
-}
diff --git a/rackspace/cdn/v1/serviceassets/delegate_test.go b/rackspace/cdn/v1/serviceassets/delegate_test.go
deleted file mode 100644
index 328e168..0000000
--- a/rackspace/cdn/v1/serviceassets/delegate_test.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package serviceassets
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleDeleteCDNAssetSuccessfully(t)
-
- err := Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", nil).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/cdn/v1/serviceassets/doc.go b/rackspace/cdn/v1/serviceassets/doc.go
deleted file mode 100644
index 46b3d50..0000000
--- a/rackspace/cdn/v1/serviceassets/doc.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// Package serviceassets provides information and interaction with the
-// serviceassets API resource in the Rackspace CDN service. This API resource
-// allows for deleting cached assets.
-//
-// A service distributes assets across the network. Service assets let you
-// interrogate properties about these assets and perform certain actions on them.
-package serviceassets
diff --git a/rackspace/cdn/v1/services/delegate.go b/rackspace/cdn/v1/services/delegate.go
deleted file mode 100644
index e3f1459..0000000
--- a/rackspace/cdn/v1/services/delegate.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package services
-
-import (
- "github.com/rackspace/gophercloud"
-
- os "github.com/rackspace/gophercloud/openstack/cdn/v1/services"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager which allows you to iterate over a collection of
-// CDN services. It accepts a ListOpts struct, which allows for pagination via
-// marker and limit.
-func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, opts)
-}
-
-// Create accepts a CreateOpts struct and creates a new CDN service using the
-// values provided.
-func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(c, opts)
-}
-
-// Get retrieves a specific service based on its unique ID.
-func Get(c *gophercloud.ServiceClient, id string) os.GetResult {
- return os.Get(c, id)
-}
-
-// Update accepts a UpdateOpts struct and updates an existing CDN service using
-// the values provided.
-func Update(c *gophercloud.ServiceClient, id string, patches []os.Patch) os.UpdateResult {
- return os.Update(c, id, patches)
-}
-
-// Delete accepts a unique ID and deletes the CDN service associated with it.
-func Delete(c *gophercloud.ServiceClient, id string) os.DeleteResult {
- return os.Delete(c, id)
-}
diff --git a/rackspace/cdn/v1/services/delegate_test.go b/rackspace/cdn/v1/services/delegate_test.go
deleted file mode 100644
index 6c48365..0000000
--- a/rackspace/cdn/v1/services/delegate_test.go
+++ /dev/null
@@ -1,359 +0,0 @@
-package services
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/cdn/v1/services"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleListCDNServiceSuccessfully(t)
-
- count := 0
-
- err := List(fake.ServiceClient(), &os.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractServices(page)
- if err != nil {
- t.Errorf("Failed to extract services: %v", err)
- return false, err
- }
-
- expected := []os.Service{
- os.Service{
- ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
- Name: "mywebsite.com",
- Domains: []os.Domain{
- os.Domain{
- Domain: "www.mywebsite.com",
- },
- },
- Origins: []os.Origin{
- os.Origin{
- Origin: "mywebsite.com",
- Port: 80,
- SSL: false,
- },
- },
- Caching: []os.CacheRule{
- os.CacheRule{
- Name: "default",
- TTL: 3600,
- },
- os.CacheRule{
- Name: "home",
- TTL: 17200,
- Rules: []os.TTLRule{
- os.TTLRule{
- Name: "index",
- RequestURL: "/index.htm",
- },
- },
- },
- os.CacheRule{
- Name: "images",
- TTL: 12800,
- Rules: []os.TTLRule{
- os.TTLRule{
- Name: "images",
- RequestURL: "*.png",
- },
- },
- },
- },
- Restrictions: []os.Restriction{
- os.Restriction{
- Name: "website only",
- Rules: []os.RestrictionRule{
- os.RestrictionRule{
- Name: "mywebsite.com",
- Referrer: "www.mywebsite.com",
- },
- },
- },
- },
- FlavorID: "asia",
- Status: "deployed",
- Errors: []os.Error{},
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
- Rel: "self",
- },
- gophercloud.Link{
- Href: "mywebsite.com.cdn123.poppycdn.net",
- Rel: "access_url",
- },
- gophercloud.Link{
- Href: "https://www.poppycdn.io/v1.0/flavors/asia",
- Rel: "flavor",
- },
- },
- },
- os.Service{
- ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1",
- Name: "myothersite.com",
- Domains: []os.Domain{
- os.Domain{
- Domain: "www.myothersite.com",
- },
- },
- Origins: []os.Origin{
- os.Origin{
- Origin: "44.33.22.11",
- Port: 80,
- SSL: false,
- },
- os.Origin{
- Origin: "77.66.55.44",
- Port: 80,
- SSL: false,
- Rules: []os.OriginRule{
- os.OriginRule{
- Name: "videos",
- RequestURL: "^/videos/*.m3u",
- },
- },
- },
- },
- Caching: []os.CacheRule{
- os.CacheRule{
- Name: "default",
- TTL: 3600,
- },
- },
- Restrictions: []os.Restriction{},
- FlavorID: "europe",
- Status: "deployed",
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1",
- Rel: "self",
- },
- gophercloud.Link{
- Href: "myothersite.com.poppycdn.net",
- Rel: "access_url",
- },
- gophercloud.Link{
- Href: "https://www.poppycdn.io/v1.0/flavors/europe",
- Rel: "flavor",
- },
- },
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
-
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleCreateCDNServiceSuccessfully(t)
-
- createOpts := os.CreateOpts{
- Name: "mywebsite.com",
- Domains: []os.Domain{
- os.Domain{
- Domain: "www.mywebsite.com",
- },
- os.Domain{
- Domain: "blog.mywebsite.com",
- },
- },
- Origins: []os.Origin{
- os.Origin{
- Origin: "mywebsite.com",
- Port: 80,
- SSL: false,
- },
- },
- Restrictions: []os.Restriction{
- os.Restriction{
- Name: "website only",
- Rules: []os.RestrictionRule{
- os.RestrictionRule{
- Name: "mywebsite.com",
- Referrer: "www.mywebsite.com",
- },
- },
- },
- },
- Caching: []os.CacheRule{
- os.CacheRule{
- Name: "default",
- TTL: 3600,
- },
- },
- FlavorID: "cdn",
- }
-
- expected := "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
- actual, err := Create(fake.ServiceClient(), createOpts).Extract()
- th.AssertNoErr(t, err)
- th.AssertEquals(t, expected, actual)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleGetCDNServiceSuccessfully(t)
-
- expected := &os.Service{
- ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
- Name: "mywebsite.com",
- Domains: []os.Domain{
- os.Domain{
- Domain: "www.mywebsite.com",
- Protocol: "http",
- },
- },
- Origins: []os.Origin{
- os.Origin{
- Origin: "mywebsite.com",
- Port: 80,
- SSL: false,
- },
- },
- Caching: []os.CacheRule{
- os.CacheRule{
- Name: "default",
- TTL: 3600,
- },
- os.CacheRule{
- Name: "home",
- TTL: 17200,
- Rules: []os.TTLRule{
- os.TTLRule{
- Name: "index",
- RequestURL: "/index.htm",
- },
- },
- },
- os.CacheRule{
- Name: "images",
- TTL: 12800,
- Rules: []os.TTLRule{
- os.TTLRule{
- Name: "images",
- RequestURL: "*.png",
- },
- },
- },
- },
- Restrictions: []os.Restriction{
- os.Restriction{
- Name: "website only",
- Rules: []os.RestrictionRule{
- os.RestrictionRule{
- Name: "mywebsite.com",
- Referrer: "www.mywebsite.com",
- },
- },
- },
- },
- FlavorID: "cdn",
- Status: "deployed",
- Errors: []os.Error{},
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
- Rel: "self",
- },
- gophercloud.Link{
- Href: "blog.mywebsite.com.cdn1.raxcdn.com",
- Rel: "access_url",
- },
- gophercloud.Link{
- Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/flavors/cdn",
- Rel: "flavor",
- },
- },
- }
-
- actual, err := Get(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestSuccessfulUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleUpdateCDNServiceSuccessfully(t)
-
- expected := "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
- ops := []os.Patch{
- // Append a single Domain
- os.Append{Value: os.Domain{Domain: "appended.mocksite4.com"}},
- // Insert a single Domain
- os.Insertion{
- Index: 4,
- Value: os.Domain{Domain: "inserted.mocksite4.com"},
- },
- // Bulk addition
- os.Append{
- Value: os.DomainList{
- os.Domain{Domain: "bulkadded1.mocksite4.com"},
- os.Domain{Domain: "bulkadded2.mocksite4.com"},
- },
- },
- // Replace a single Origin
- os.Replacement{
- Index: 2,
- Value: os.Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
- },
- // Bulk replace Origins
- os.Replacement{
- Index: 0, // Ignored
- Value: os.OriginList{
- os.Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
- os.Origin{Origin: "55.44.33.22", Port: 443, SSL: true},
- },
- },
- // Remove a single CacheRule
- os.Removal{
- Index: 8,
- Path: os.PathCaching,
- },
- // Bulk removal
- os.Removal{
- All: true,
- Path: os.PathCaching,
- },
- // Service name replacement
- os.NameReplacement{
- NewName: "differentServiceName",
- },
- }
-
- actual, err := Update(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", ops).Extract()
- th.AssertNoErr(t, err)
- th.AssertEquals(t, expected, actual)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleDeleteCDNServiceSuccessfully(t)
-
- err := Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/cdn/v1/services/doc.go b/rackspace/cdn/v1/services/doc.go
deleted file mode 100644
index ee6e2a5..0000000
--- a/rackspace/cdn/v1/services/doc.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// Package services provides information and interaction with the services API
-// resource in the Rackspace CDN service. This API resource allows for
-// listing, creating, updating, retrieving, and deleting services.
-//
-// A service represents an application that has its content cached to the edge
-// nodes.
-package services
diff --git a/rackspace/client.go b/rackspace/client.go
deleted file mode 100644
index a8f413e..0000000
--- a/rackspace/client.go
+++ /dev/null
@@ -1,224 +0,0 @@
-package rackspace
-
-import (
- "fmt"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack"
- "github.com/rackspace/gophercloud/openstack/utils"
- tokens2 "github.com/rackspace/gophercloud/rackspace/identity/v2/tokens"
-)
-
-const (
- // RackspaceUSIdentity is an identity endpoint located in the United States.
- RackspaceUSIdentity = "https://identity.api.rackspacecloud.com/v2.0/"
-
- // RackspaceUKIdentity is an identity endpoint located in the UK.
- RackspaceUKIdentity = "https://lon.identity.api.rackspacecloud.com/v2.0/"
-)
-
-const (
- v20 = "v2.0"
-)
-
-// NewClient creates a client that's prepared to communicate with the Rackspace API, but is not
-// yet authenticated. Most users will probably prefer using the AuthenticatedClient function
-// instead.
-//
-// Provide the base URL of the identity endpoint you wish to authenticate against as "endpoint".
-// Often, this will be either RackspaceUSIdentity or RackspaceUKIdentity.
-func NewClient(endpoint string) (*gophercloud.ProviderClient, error) {
- if endpoint == "" {
- return os.NewClient(RackspaceUSIdentity)
- }
- return os.NewClient(endpoint)
-}
-
-// AuthenticatedClient logs in to Rackspace with the provided credentials and constructs a
-// ProviderClient that's ready to operate.
-//
-// If the provided AuthOptions does not specify an explicit IdentityEndpoint, it will default to
-// the canonical, production Rackspace US identity endpoint.
-func AuthenticatedClient(options gophercloud.AuthOptions) (*gophercloud.ProviderClient, error) {
- client, err := NewClient(options.IdentityEndpoint)
- if err != nil {
- return nil, err
- }
-
- err = Authenticate(client, options)
- if err != nil {
- return nil, err
- }
- return client, nil
-}
-
-// Authenticate or re-authenticate against the most recent identity service supported at the
-// provided endpoint.
-func Authenticate(client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error {
- versions := []*utils.Version{
- &utils.Version{ID: v20, Priority: 20, Suffix: "/v2.0/"},
- }
-
- chosen, endpoint, err := utils.ChooseVersion(client, versions)
- if err != nil {
- return err
- }
-
- switch chosen.ID {
- case v20:
- return v2auth(client, endpoint, options)
- default:
- // The switch statement must be out of date from the versions list.
- return fmt.Errorf("Unrecognized identity version: %s", chosen.ID)
- }
-}
-
-// AuthenticateV2 explicitly authenticates with v2 of the identity service.
-func AuthenticateV2(client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error {
- return v2auth(client, "", options)
-}
-
-func v2auth(client *gophercloud.ProviderClient, endpoint string, options gophercloud.AuthOptions) error {
- v2Client := NewIdentityV2(client)
- if endpoint != "" {
- v2Client.Endpoint = endpoint
- }
-
- result := tokens2.Create(v2Client, tokens2.WrapOptions(options))
-
- token, err := result.ExtractToken()
- if err != nil {
- return err
- }
-
- catalog, err := result.ExtractServiceCatalog()
- if err != nil {
- return err
- }
-
- if options.AllowReauth {
- client.ReauthFunc = func() error {
- return AuthenticateV2(client, options)
- }
- }
- client.TokenID = token.ID
- client.EndpointLocator = func(opts gophercloud.EndpointOpts) (string, error) {
- return os.V2EndpointURL(catalog, opts)
- }
-
- return nil
-}
-
-// NewIdentityV2 creates a ServiceClient that may be used to access the v2 identity service.
-func NewIdentityV2(client *gophercloud.ProviderClient) *gophercloud.ServiceClient {
- v2Endpoint := client.IdentityBase + "v2.0/"
-
- return &gophercloud.ServiceClient{
- ProviderClient: client,
- Endpoint: v2Endpoint,
- }
-}
-
-// NewComputeV2 creates a ServiceClient that may be used to access the v2 compute service.
-func NewComputeV2(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("compute")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
-
- return &gophercloud.ServiceClient{
- ProviderClient: client,
- Endpoint: url,
- }, nil
-}
-
-// NewObjectCDNV1 creates a ServiceClient that may be used with the Rackspace v1 CDN.
-func NewObjectCDNV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("rax:object-cdn")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
- return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil
-}
-
-// NewObjectStorageV1 creates a ServiceClient that may be used with the Rackspace v1 object storage package.
-func NewObjectStorageV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- return os.NewObjectStorageV1(client, eo)
-}
-
-// NewBlockStorageV1 creates a ServiceClient that can be used to access the
-// Rackspace Cloud Block Storage v1 API.
-func NewBlockStorageV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("volume")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
-
- return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil
-}
-
-// NewLBV1 creates a ServiceClient that can be used to access the Rackspace
-// Cloud Load Balancer v1 API.
-func NewLBV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("rax:load-balancer")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
- return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil
-}
-
-// NewNetworkV2 creates a ServiceClient that can be used to access the Rackspace
-// Networking v2 API.
-func NewNetworkV2(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("network")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
- return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil
-}
-
-// NewCDNV1 creates a ServiceClient that may be used to access the Rackspace v1
-// CDN service.
-func NewCDNV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("rax:cdn")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
- return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil
-}
-
-// NewOrchestrationV1 creates a ServiceClient that may be used to access the v1 orchestration service.
-func NewOrchestrationV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("orchestration")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
- return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil
-}
-
-// NewRackConnectV3 creates a ServiceClient that may be used to access the v3 RackConnect service.
-func NewRackConnectV3(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("rax:rackconnect")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
- return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil
-}
-
-// NewDBV1 creates a ServiceClient that may be used to access the v1 DB service.
-func NewDBV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
- eo.ApplyDefaults("rax:database")
- url, err := client.EndpointLocator(eo)
- if err != nil {
- return nil, err
- }
- return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil
-}
diff --git a/rackspace/client_test.go b/rackspace/client_test.go
deleted file mode 100644
index 73b1c88..0000000
--- a/rackspace/client_test.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package rackspace
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- "github.com/rackspace/gophercloud"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-func TestAuthenticatedClientV2(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/tokens", func(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, `
- {
- "access": {
- "token": {
- "id": "01234567890",
- "expires": "2014-10-01T10:00:00.000000Z"
- },
- "serviceCatalog": []
- }
- }
- `)
- })
-
- options := gophercloud.AuthOptions{
- Username: "me",
- APIKey: "09876543210",
- IdentityEndpoint: th.Endpoint() + "v2.0/",
- }
- client, err := AuthenticatedClient(options)
- th.AssertNoErr(t, err)
- th.CheckEquals(t, "01234567890", client.TokenID)
-}
diff --git a/rackspace/compute/v2/bootfromvolume/delegate.go b/rackspace/compute/v2/bootfromvolume/delegate.go
deleted file mode 100644
index 2580459..0000000
--- a/rackspace/compute/v2/bootfromvolume/delegate.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package bootfromvolume
-
-import (
- "github.com/rackspace/gophercloud"
- osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
- osServers "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
-)
-
-// Create requests the creation of a server from the given block device mapping.
-func Create(client *gophercloud.ServiceClient, opts osServers.CreateOptsBuilder) osServers.CreateResult {
- return osBFV.Create(client, opts)
-}
diff --git a/rackspace/compute/v2/bootfromvolume/delegate_test.go b/rackspace/compute/v2/bootfromvolume/delegate_test.go
deleted file mode 100644
index 571a1be..0000000
--- a/rackspace/compute/v2/bootfromvolume/delegate_test.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package bootfromvolume
-
-import (
- "testing"
-
- osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
- "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-func TestCreateOpts(t *testing.T) {
- base := servers.CreateOpts{
- Name: "createdserver",
- ImageRef: "asdfasdfasdf",
- FlavorRef: "performance1-1",
- }
-
- ext := osBFV.CreateOptsExt{
- CreateOptsBuilder: base,
- BlockDevice: []osBFV.BlockDevice{
- osBFV.BlockDevice{
- UUID: "123456",
- SourceType: osBFV.Image,
- DestinationType: "volume",
- VolumeSize: 10,
- },
- },
- }
-
- expected := `
- {
- "server": {
- "name": "createdserver",
- "imageRef": "asdfasdfasdf",
- "flavorRef": "performance1-1",
- "flavorName": "",
- "imageName": "",
- "block_device_mapping_v2":[
- {
- "uuid":"123456",
- "source_type":"image",
- "destination_type":"volume",
- "boot_index": "0",
- "delete_on_termination": "false",
- "volume_size": "10"
- }
- ]
- }
- }
- `
- actual, err := ext.ToServerCreateMap()
- th.AssertNoErr(t, err)
- th.CheckJSONEquals(t, expected, actual)
-}
diff --git a/rackspace/compute/v2/flavors/delegate.go b/rackspace/compute/v2/flavors/delegate.go
deleted file mode 100644
index 081ea47..0000000
--- a/rackspace/compute/v2/flavors/delegate.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package flavors
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/compute/v2/flavors"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// ListOpts helps control the results returned by the List() function. For example, a flavor with a
-// minDisk field of 10 will not be returned if you specify MinDisk set to 20.
-type ListOpts struct {
-
- // MinDisk and MinRAM, if provided, elide flavors that do not meet your criteria.
- MinDisk int `q:"minDisk"`
- MinRAM int `q:"minRam"`
-
- // Marker specifies the ID of the last flavor in the previous page.
- Marker string `q:"marker"`
-
- // Limit instructs List to refrain from sending excessively large lists of flavors.
- Limit int `q:"limit"`
-}
-
-// ToFlavorListQuery formats a ListOpts into a query string.
-func (opts ListOpts) ToFlavorListQuery() (string, error) {
- q, err := gophercloud.BuildQueryString(opts)
- if err != nil {
- return "", err
- }
- return q.String(), nil
-}
-
-// ListDetail enumerates the server images available to your account.
-func ListDetail(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.ListDetail(client, opts)
-}
-
-// Get returns details about a single flavor, identity by ID.
-func Get(client *gophercloud.ServiceClient, id string) GetResult {
- var res GetResult
- _, res.Err = client.Get(getURL(client, id), &res.Body, nil)
- return res
-}
diff --git a/rackspace/compute/v2/flavors/delegate_test.go b/rackspace/compute/v2/flavors/delegate_test.go
deleted file mode 100644
index 204081d..0000000
--- a/rackspace/compute/v2/flavors/delegate_test.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package flavors
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListFlavors(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/flavors/detail", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- r.ParseForm()
- marker := r.Form.Get("marker")
- switch marker {
- case "":
- fmt.Fprintf(w, ListOutput)
- case "performance1-2":
- fmt.Fprintf(w, `{ "flavors": [] }`)
- default:
- t.Fatalf("Unexpected marker: [%s]", marker)
- }
- })
-
- count := 0
- err := ListDetail(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- actual, err := ExtractFlavors(page)
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, ExpectedFlavorSlice, actual)
-
- count++
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestGetFlavor(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/flavors/performance1-1", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- fmt.Fprintf(w, GetOutput)
- })
-
- actual, err := Get(client.ServiceClient(), "performance1-1").Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &Performance1Flavor, actual)
-}
diff --git a/rackspace/compute/v2/flavors/doc.go b/rackspace/compute/v2/flavors/doc.go
deleted file mode 100644
index 278229a..0000000
--- a/rackspace/compute/v2/flavors/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package flavors provides information and interaction with the flavor
-// API resource for the Rackspace Cloud Servers service.
-package flavors
diff --git a/rackspace/compute/v2/flavors/fixtures.go b/rackspace/compute/v2/flavors/fixtures.go
deleted file mode 100644
index 957dccf..0000000
--- a/rackspace/compute/v2/flavors/fixtures.go
+++ /dev/null
@@ -1,137 +0,0 @@
-// +build fixtures
-
-package flavors
-
-// ListOutput is a sample response of a flavor List request.
-const ListOutput = `
-{
- "flavors": [
- {
- "OS-FLV-EXT-DATA:ephemeral": 0,
- "OS-FLV-WITH-EXT-SPECS:extra_specs": {
- "class": "performance1",
- "disk_io_index": "40",
- "number_of_data_disks": "0",
- "policy_class": "performance_flavor",
- "resize_policy_class": "performance_flavor"
- },
- "disk": 20,
- "id": "performance1-1",
- "links": [
- {
- "href": "https://iad.servers.api.rackspacecloud.com/v2/864477/flavors/performance1-1",
- "rel": "self"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/864477/flavors/performance1-1",
- "rel": "bookmark"
- }
- ],
- "name": "1 GB Performance",
- "ram": 1024,
- "rxtx_factor": 200,
- "swap": "",
- "vcpus": 1
- },
- {
- "OS-FLV-EXT-DATA:ephemeral": 20,
- "OS-FLV-WITH-EXT-SPECS:extra_specs": {
- "class": "performance1",
- "disk_io_index": "40",
- "number_of_data_disks": "1",
- "policy_class": "performance_flavor",
- "resize_policy_class": "performance_flavor"
- },
- "disk": 40,
- "id": "performance1-2",
- "links": [
- {
- "href": "https://iad.servers.api.rackspacecloud.com/v2/864477/flavors/performance1-2",
- "rel": "self"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/864477/flavors/performance1-2",
- "rel": "bookmark"
- }
- ],
- "name": "2 GB Performance",
- "ram": 2048,
- "rxtx_factor": 400,
- "swap": "",
- "vcpus": 2
- }
- ]
-}`
-
-// GetOutput is a sample response from a flavor Get request. Its contents correspond to the
-// Performance1Flavor struct.
-const GetOutput = `
-{
- "flavor": {
- "OS-FLV-EXT-DATA:ephemeral": 0,
- "OS-FLV-WITH-EXT-SPECS:extra_specs": {
- "class": "performance1",
- "disk_io_index": "40",
- "number_of_data_disks": "0",
- "policy_class": "performance_flavor",
- "resize_policy_class": "performance_flavor"
- },
- "disk": 20,
- "id": "performance1-1",
- "links": [
- {
- "href": "https://iad.servers.api.rackspacecloud.com/v2/864477/flavors/performance1-1",
- "rel": "self"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/864477/flavors/performance1-1",
- "rel": "bookmark"
- }
- ],
- "name": "1 GB Performance",
- "ram": 1024,
- "rxtx_factor": 200,
- "swap": "",
- "vcpus": 1
- }
-}
-`
-
-// Performance1Flavor is the expected result of parsing GetOutput, or the first element of
-// ListOutput.
-var Performance1Flavor = Flavor{
- ID: "performance1-1",
- Disk: 20,
- RAM: 1024,
- Name: "1 GB Performance",
- RxTxFactor: 200.0,
- Swap: 0,
- VCPUs: 1,
- ExtraSpecs: ExtraSpecs{
- NumDataDisks: 0,
- Class: "performance1",
- DiskIOIndex: 0,
- PolicyClass: "performance_flavor",
- },
-}
-
-// Performance2Flavor is the second result expected from parsing ListOutput.
-var Performance2Flavor = Flavor{
- ID: "performance1-2",
- Disk: 40,
- RAM: 2048,
- Name: "2 GB Performance",
- RxTxFactor: 400.0,
- Swap: 0,
- VCPUs: 2,
- ExtraSpecs: ExtraSpecs{
- NumDataDisks: 0,
- Class: "performance1",
- DiskIOIndex: 0,
- PolicyClass: "performance_flavor",
- },
-}
-
-// ExpectedFlavorSlice is the slice of Flavor structs that are expected to be parsed from
-// ListOutput.
-var ExpectedFlavorSlice = []Flavor{Performance1Flavor, Performance2Flavor}
diff --git a/rackspace/compute/v2/flavors/results.go b/rackspace/compute/v2/flavors/results.go
deleted file mode 100644
index af444a7..0000000
--- a/rackspace/compute/v2/flavors/results.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package flavors
-
-import (
- "reflect"
-
- "github.com/rackspace/gophercloud"
- "github.com/mitchellh/mapstructure"
- os "github.com/rackspace/gophercloud/openstack/compute/v2/flavors"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// ExtraSpecs provide additional information about the flavor.
-type ExtraSpecs struct {
- // The number of data disks
- NumDataDisks int `mapstructure:"number_of_data_disks"`
- // The flavor class
- Class string `mapstructure:"class"`
- // Relative measure of disk I/O performance from 0-99, where higher is faster
- DiskIOIndex int `mapstructure:"disk_io_index"`
- PolicyClass string `mapstructure:"policy_class"`
-}
-
-// Flavor records represent (virtual) hardware configurations for server resources in a region.
-type Flavor struct {
- // The Id field contains the flavor's unique identifier.
- // For example, this identifier will be useful when specifying which hardware configuration to use for a new server instance.
- ID string `mapstructure:"id"`
-
- // The Disk and RA< fields provide a measure of storage space offered by the flavor, in GB and MB, respectively.
- Disk int `mapstructure:"disk"`
- RAM int `mapstructure:"ram"`
-
- // The Name field provides a human-readable moniker for the flavor.
- Name string `mapstructure:"name"`
-
- RxTxFactor float64 `mapstructure:"rxtx_factor"`
-
- // Swap indicates how much space is reserved for swap.
- // If not provided, this field will be set to 0.
- Swap int `mapstructure:"swap"`
-
- // VCPUs indicates how many (virtual) CPUs are available for this flavor.
- VCPUs int `mapstructure:"vcpus"`
-
- // ExtraSpecs provides extra information about the flavor
- ExtraSpecs ExtraSpecs `mapstructure:"OS-FLV-WITH-EXT-SPECS:extra_specs"`
-}
-
-// GetResult temporarily holds the response from a Get call.
-type GetResult struct {
- gophercloud.Result
-}
-
-// Extract provides access to the individual Flavor returned by the Get function.
-func (gr GetResult) Extract() (*Flavor, error) {
- if gr.Err != nil {
- return nil, gr.Err
- }
-
- var result struct {
- Flavor Flavor `mapstructure:"flavor"`
- }
-
- cfg := &mapstructure.DecoderConfig{
- DecodeHook: defaulter,
- Result: &result,
- }
- decoder, err := mapstructure.NewDecoder(cfg)
- if err != nil {
- return nil, err
- }
- err = decoder.Decode(gr.Body)
- return &result.Flavor, err
-}
-
-func defaulter(from, to reflect.Kind, v interface{}) (interface{}, error) {
- if (from == reflect.String) && (to == reflect.Int) {
- return 0, nil
- }
- return v, nil
-}
-
-// ExtractFlavors provides access to the list of flavors in a page acquired from the List operation.
-func ExtractFlavors(page pagination.Page) ([]Flavor, error) {
- casted := page.(os.FlavorPage).Body
- var container struct {
- Flavors []Flavor `mapstructure:"flavors"`
- }
-
- cfg := &mapstructure.DecoderConfig{
- DecodeHook: defaulter,
- Result: &container,
- }
- decoder, err := mapstructure.NewDecoder(cfg)
- if err != nil {
- return container.Flavors, err
- }
- err = decoder.Decode(casted)
- if err != nil {
- return container.Flavors, err
- }
-
- return container.Flavors, nil
-}
diff --git a/rackspace/compute/v2/flavors/urls.go b/rackspace/compute/v2/flavors/urls.go
deleted file mode 100644
index f4e2c3d..0000000
--- a/rackspace/compute/v2/flavors/urls.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package flavors
-
-import (
- "github.com/rackspace/gophercloud"
-)
-
-func getURL(client *gophercloud.ServiceClient, id string) string {
- return client.ServiceURL("flavors", id)
-}
diff --git a/rackspace/compute/v2/images/delegate.go b/rackspace/compute/v2/images/delegate.go
deleted file mode 100644
index 18e1f31..0000000
--- a/rackspace/compute/v2/images/delegate.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package images
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/compute/v2/images"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// ListDetail enumerates the available server images.
-func ListDetail(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.ListDetail(client, opts)
-}
-
-// Get acquires additional detail about a specific image by ID.
-func Get(client *gophercloud.ServiceClient, id string) os.GetResult {
- return os.Get(client, id)
-}
-
-// ExtractImages interprets a page as a collection of server images.
-func ExtractImages(page pagination.Page) ([]os.Image, error) {
- return os.ExtractImages(page)
-}
diff --git a/rackspace/compute/v2/images/delegate_test.go b/rackspace/compute/v2/images/delegate_test.go
deleted file mode 100644
index db0a6e3..0000000
--- a/rackspace/compute/v2/images/delegate_test.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package images
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListImageDetails(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/images/detail", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- r.ParseForm()
- marker := r.Form.Get("marker")
- switch marker {
- case "":
- fmt.Fprintf(w, ListOutput)
- case "e19a734c-c7e6-443a-830c-242209c4d65d":
- fmt.Fprintf(w, `{ "images": [] }`)
- default:
- t.Fatalf("Unexpected marker: [%s]", marker)
- }
- })
-
- count := 0
- err := ListDetail(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractImages(page)
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, ExpectedImageSlice, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestGetImageDetails(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/images/e19a734c-c7e6-443a-830c-242209c4d65d", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- fmt.Fprintf(w, GetOutput)
- })
-
- actual, err := Get(client.ServiceClient(), "e19a734c-c7e6-443a-830c-242209c4d65d").Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &UbuntuImage, actual)
-}
diff --git a/rackspace/compute/v2/images/doc.go b/rackspace/compute/v2/images/doc.go
deleted file mode 100644
index cfae806..0000000
--- a/rackspace/compute/v2/images/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package images provides information and interaction with the image
-// API resource for the Rackspace Cloud Servers service.
-package images
diff --git a/rackspace/compute/v2/images/fixtures.go b/rackspace/compute/v2/images/fixtures.go
deleted file mode 100644
index ccfbdc6..0000000
--- a/rackspace/compute/v2/images/fixtures.go
+++ /dev/null
@@ -1,200 +0,0 @@
-// +build fixtures
-
-package images
-
-import (
- os "github.com/rackspace/gophercloud/openstack/compute/v2/images"
-)
-
-// ListOutput is an example response from an /images/detail request.
-const ListOutput = `
-{
- "images": [
- {
- "OS-DCF:diskConfig": "MANUAL",
- "OS-EXT-IMG-SIZE:size": 1.017415075e+09,
- "created": "2014-10-01T15:49:02Z",
- "id": "30aa010e-080e-4d4b-a7f9-09fc55b07d69",
- "links": [
- {
- "href": "https://iad.servers.api.rackspacecloud.com/v2/111222/images/30aa010e-080e-4d4b-a7f9-09fc55b07d69",
- "rel": "self"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/111222/images/30aa010e-080e-4d4b-a7f9-09fc55b07d69",
- "rel": "bookmark"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/111222/images/30aa010e-080e-4d4b-a7f9-09fc55b07d69",
- "rel": "alternate",
- "type": "application/vnd.openstack.image"
- }
- ],
- "metadata": {
- "auto_disk_config": "disabled",
- "cache_in_nova": "True",
- "com.rackspace__1__build_core": "1",
- "com.rackspace__1__build_managed": "1",
- "com.rackspace__1__build_rackconnect": "1",
- "com.rackspace__1__options": "0",
- "com.rackspace__1__platform_target": "PublicCloud",
- "com.rackspace__1__release_build_date": "2014-10-01_15-46-08",
- "com.rackspace__1__release_id": "100",
- "com.rackspace__1__release_version": "10",
- "com.rackspace__1__source": "kickstart",
- "com.rackspace__1__visible_core": "1",
- "com.rackspace__1__visible_managed": "0",
- "com.rackspace__1__visible_rackconnect": "0",
- "image_type": "base",
- "org.openstack__1__architecture": "x64",
- "org.openstack__1__os_distro": "org.archlinux",
- "org.openstack__1__os_version": "2014.8",
- "os_distro": "arch",
- "os_type": "linux",
- "vm_mode": "hvm"
- },
- "minDisk": 20,
- "minRam": 512,
- "name": "Arch 2014.10 (PVHVM)",
- "progress": 100,
- "status": "ACTIVE",
- "updated": "2014-10-01T19:37:58Z"
- },
- {
- "OS-DCF:diskConfig": "AUTO",
- "OS-EXT-IMG-SIZE:size": 1.060306463e+09,
- "created": "2014-10-01T12:58:11Z",
- "id": "e19a734c-c7e6-443a-830c-242209c4d65d",
- "links": [
- {
- "href": "https://iad.servers.api.rackspacecloud.com/v2/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "self"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "bookmark"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "alternate",
- "type": "application/vnd.openstack.image"
- }
- ],
- "metadata": {
- "auto_disk_config": "True",
- "cache_in_nova": "True",
- "com.rackspace__1__build_core": "1",
- "com.rackspace__1__build_managed": "1",
- "com.rackspace__1__build_rackconnect": "1",
- "com.rackspace__1__options": "0",
- "com.rackspace__1__platform_target": "PublicCloud",
- "com.rackspace__1__release_build_date": "2014-10-01_12-31-03",
- "com.rackspace__1__release_id": "1007",
- "com.rackspace__1__release_version": "6",
- "com.rackspace__1__source": "kickstart",
- "com.rackspace__1__visible_core": "1",
- "com.rackspace__1__visible_managed": "1",
- "com.rackspace__1__visible_rackconnect": "1",
- "image_type": "base",
- "org.openstack__1__architecture": "x64",
- "org.openstack__1__os_distro": "com.ubuntu",
- "org.openstack__1__os_version": "14.04",
- "os_distro": "ubuntu",
- "os_type": "linux",
- "vm_mode": "xen"
- },
- "minDisk": 20,
- "minRam": 512,
- "name": "Ubuntu 14.04 LTS (Trusty Tahr)",
- "progress": 100,
- "status": "ACTIVE",
- "updated": "2014-10-01T15:51:44Z"
- }
- ]
-}
-`
-
-// GetOutput is an example response from an /images request.
-const GetOutput = `
-{
- "image": {
- "OS-DCF:diskConfig": "AUTO",
- "OS-EXT-IMG-SIZE:size": 1060306463,
- "created": "2014-10-01T12:58:11Z",
- "id": "e19a734c-c7e6-443a-830c-242209c4d65d",
- "links": [
- {
- "href": "https://iad.servers.api.rackspacecloud.com/v2/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "self"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "bookmark"
- },
- {
- "href": "https://iad.servers.api.rackspacecloud.com/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "alternate",
- "type": "application/vnd.openstack.image"
- }
- ],
- "metadata": {
- "auto_disk_config": "True",
- "cache_in_nova": "True",
- "com.rackspace__1__build_core": "1",
- "com.rackspace__1__build_managed": "1",
- "com.rackspace__1__build_rackconnect": "1",
- "com.rackspace__1__options": "0",
- "com.rackspace__1__platform_target": "PublicCloud",
- "com.rackspace__1__release_build_date": "2014-10-01_12-31-03",
- "com.rackspace__1__release_id": "1007",
- "com.rackspace__1__release_version": "6",
- "com.rackspace__1__source": "kickstart",
- "com.rackspace__1__visible_core": "1",
- "com.rackspace__1__visible_managed": "1",
- "com.rackspace__1__visible_rackconnect": "1",
- "image_type": "base",
- "org.openstack__1__architecture": "x64",
- "org.openstack__1__os_distro": "com.ubuntu",
- "org.openstack__1__os_version": "14.04",
- "os_distro": "ubuntu",
- "os_type": "linux",
- "vm_mode": "xen"
- },
- "minDisk": 20,
- "minRam": 512,
- "name": "Ubuntu 14.04 LTS (Trusty Tahr)",
- "progress": 100,
- "status": "ACTIVE",
- "updated": "2014-10-01T15:51:44Z"
- }
-}
-`
-
-// ArchImage is the first Image structure that should be parsed from ListOutput.
-var ArchImage = os.Image{
- ID: "30aa010e-080e-4d4b-a7f9-09fc55b07d69",
- Name: "Arch 2014.10 (PVHVM)",
- Created: "2014-10-01T15:49:02Z",
- Updated: "2014-10-01T19:37:58Z",
- MinDisk: 20,
- MinRAM: 512,
- Progress: 100,
- Status: "ACTIVE",
-}
-
-// UbuntuImage is the second Image structure that should be parsed from ListOutput and
-// the only image that should be extracted from GetOutput.
-var UbuntuImage = os.Image{
- ID: "e19a734c-c7e6-443a-830c-242209c4d65d",
- Name: "Ubuntu 14.04 LTS (Trusty Tahr)",
- Created: "2014-10-01T12:58:11Z",
- Updated: "2014-10-01T15:51:44Z",
- MinDisk: 20,
- MinRAM: 512,
- Progress: 100,
- Status: "ACTIVE",
-}
-
-// ExpectedImageSlice is the collection of images that should be parsed from ListOutput,
-// in order.
-var ExpectedImageSlice = []os.Image{ArchImage, UbuntuImage}
diff --git a/rackspace/compute/v2/keypairs/delegate.go b/rackspace/compute/v2/keypairs/delegate.go
deleted file mode 100644
index 3e53525..0000000
--- a/rackspace/compute/v2/keypairs/delegate.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package keypairs
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager that allows you to iterate over a collection of KeyPairs.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client)
-}
-
-// Create requests the creation of a new keypair on the server, or to import a pre-existing
-// keypair.
-func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(client, opts)
-}
-
-// Get returns public data about a previously uploaded KeyPair.
-func Get(client *gophercloud.ServiceClient, name string) os.GetResult {
- return os.Get(client, name)
-}
-
-// Delete requests the deletion of a previous stored KeyPair from the server.
-func Delete(client *gophercloud.ServiceClient, name string) os.DeleteResult {
- return os.Delete(client, name)
-}
-
-// ExtractKeyPairs interprets a page of results as a slice of KeyPairs.
-func ExtractKeyPairs(page pagination.Page) ([]os.KeyPair, error) {
- return os.ExtractKeyPairs(page)
-}
diff --git a/rackspace/compute/v2/keypairs/delegate_test.go b/rackspace/compute/v2/keypairs/delegate_test.go
deleted file mode 100644
index 62e5df9..0000000
--- a/rackspace/compute/v2/keypairs/delegate_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package keypairs
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListSuccessfully(t)
-
- count := 0
- err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractKeyPairs(page)
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, os.ExpectedKeyPairSlice, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCreateSuccessfully(t)
-
- actual, err := Create(client.ServiceClient(), os.CreateOpts{
- Name: "createdkey",
- }).Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &os.CreatedKeyPair, actual)
-}
-
-func TestImport(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleImportSuccessfully(t)
-
- actual, err := Create(client.ServiceClient(), os.CreateOpts{
- Name: "importedkey",
- PublicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGgB4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0lRE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYcpSxsIbECHw== Generated by Nova",
- }).Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &os.ImportedKeyPair, actual)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetSuccessfully(t)
-
- actual, err := Get(client.ServiceClient(), "firstkey").Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &os.FirstKeyPair, actual)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDeleteSuccessfully(t)
-
- err := Delete(client.ServiceClient(), "deletedkey").ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/compute/v2/keypairs/doc.go b/rackspace/compute/v2/keypairs/doc.go
deleted file mode 100644
index 3171375..0000000
--- a/rackspace/compute/v2/keypairs/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package keypairs provides information and interaction with the keypair
-// API resource for the Rackspace Cloud Servers service.
-package keypairs
diff --git a/rackspace/compute/v2/networks/doc.go b/rackspace/compute/v2/networks/doc.go
deleted file mode 100644
index 8e5c773..0000000
--- a/rackspace/compute/v2/networks/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package networks provides information and interaction with the network
-// API resource for the Rackspace Cloud Servers service.
-package networks
diff --git a/rackspace/compute/v2/networks/requests.go b/rackspace/compute/v2/networks/requests.go
deleted file mode 100644
index cebbffd..0000000
--- a/rackspace/compute/v2/networks/requests.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package networks
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager which allows you to iterate over a collection of
-// networks. It accepts a ListOpts struct, which allows you to filter and sort
-// the returned collection for greater efficiency.
-func List(c *gophercloud.ServiceClient) pagination.Pager {
- createPage := func(r pagination.PageResult) pagination.Page {
- return NetworkPage{pagination.SinglePageBase(r)}
- }
-
- return pagination.NewPager(c, listURL(c), createPage)
-}
-
-// Get retrieves a specific network based on its unique ID.
-func Get(c *gophercloud.ServiceClient, id string) GetResult {
- var res GetResult
- _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
- return res
-}
-
-// 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
-// satisfy a basic interface in order for them to be used.
-type CreateOptsBuilder interface {
- ToNetworkCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts is the common options struct used in this package's Create
-// operation.
-type CreateOpts struct {
- // REQUIRED. See Network object for more info.
- CIDR string
- // REQUIRED. See Network object for more info.
- Label string
-}
-
-// ToNetworkCreateMap casts a CreateOpts struct to a map.
-func (opts CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) {
- n := make(map[string]interface{})
-
- if opts.CIDR == "" {
- return nil, errors.New("Required field CIDR not set.")
- }
- if opts.Label == "" {
- return nil, errors.New("Required field Label not set.")
- }
-
- n["label"] = opts.Label
- n["cidr"] = opts.CIDR
- return map[string]interface{}{"network": n}, nil
-}
-
-// Create accepts a CreateOpts struct and creates a new network using the values
-// provided. This operation does not actually require a request body, i.e. the
-// CreateOpts struct argument can be empty.
-//
-// The tenant ID that is contained in the URI is the tenant that creates the
-// network. An admin user, however, has the option of specifying another tenant
-// ID in the CreateOpts struct.
-func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
- var res CreateResult
-
- reqBody, err := opts.ToNetworkCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- // Send request to API
- _, res.Err = c.Post(createURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{
- OkCodes: []int{200, 201, 202},
- })
- return res
-}
-
-// Delete accepts a unique ID and deletes the network associated with it.
-func Delete(c *gophercloud.ServiceClient, networkID string) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(deleteURL(c, networkID), nil)
- return res
-}
diff --git a/rackspace/compute/v2/networks/requests_test.go b/rackspace/compute/v2/networks/requests_test.go
deleted file mode 100644
index 6f44c1c..0000000
--- a/rackspace/compute/v2/networks/requests_test.go
+++ /dev/null
@@ -1,156 +0,0 @@
-package networks
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/os-networksv2", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "networks": [
- {
- "label": "test-network-1",
- "cidr": "192.168.100.0/24",
- "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22"
- },
- {
- "label": "test-network-2",
- "cidr": "192.30.250.00/18",
- "id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324"
- }
- ]
-}
- `)
- })
-
- client := fake.ServiceClient()
- count := 0
-
- err := List(client).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNetworks(page)
- if err != nil {
- t.Errorf("Failed to extract networks: %v", err)
- return false, err
- }
-
- expected := []Network{
- Network{
- Label: "test-network-1",
- CIDR: "192.168.100.0/24",
- ID: "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- },
- Network{
- Label: "test-network-2",
- CIDR: "192.30.250.00/18",
- ID: "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/os-networksv2/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "network": {
- "label": "test-network-1",
- "cidr": "192.168.100.0/24",
- "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22"
- }
-}
- `)
- })
-
- n, err := Get(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.CIDR, "192.168.100.0/24")
- th.AssertEquals(t, n.Label, "test-network-1")
- th.AssertEquals(t, n.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/os-networksv2", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "network": {
- "label": "test-network-1",
- "cidr": "192.168.100.0/24"
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `
-{
- "network": {
- "label": "test-network-1",
- "cidr": "192.168.100.0/24",
- "id": "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
- }
-}
- `)
- })
-
- options := CreateOpts{Label: "test-network-1", CIDR: "192.168.100.0/24"}
- n, err := Create(fake.ServiceClient(), options).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.Label, "test-network-1")
- th.AssertEquals(t, n.ID, "4e8e5957-649f-477b-9e5b-f1f75b21c03c")
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/os-networksv2/4e8e5957-649f-477b-9e5b-f1f75b21c03c", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-
- res := Delete(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/compute/v2/networks/results.go b/rackspace/compute/v2/networks/results.go
deleted file mode 100644
index eb6a76c..0000000
--- a/rackspace/compute/v2/networks/results.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package networks
-
-import (
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-type commonResult struct {
- gophercloud.Result
-}
-
-// Extract is a function that accepts a result and extracts a network resource.
-func (r commonResult) Extract() (*Network, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var res struct {
- Network *Network `json:"network"`
- }
-
- err := mapstructure.Decode(r.Body, &res)
-
- return res.Network, err
-}
-
-// CreateResult represents the result of a create operation.
-type CreateResult struct {
- commonResult
-}
-
-// GetResult represents the result of a get operation.
-type GetResult struct {
- commonResult
-}
-
-// DeleteResult represents the result of a delete operation.
-type DeleteResult struct {
- gophercloud.ErrResult
-}
-
-// Network represents, well, a network.
-type Network struct {
- // UUID for the network
- ID string `mapstructure:"id" json:"id"`
-
- // Human-readable name for the network. Might not be unique.
- Label string `mapstructure:"label" json:"label"`
-
- // Classless Inter-Domain Routing
- CIDR string `mapstructure:"cidr" json:"cidr"`
-}
-
-// NetworkPage is the page returned by a pager when traversing over a
-// collection of networks.
-type NetworkPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty returns true if the NetworkPage contains no Networks.
-func (r NetworkPage) IsEmpty() (bool, error) {
- networks, err := ExtractNetworks(r)
- if err != nil {
- return true, err
- }
- return len(networks) == 0, nil
-}
-
-// ExtractNetworks accepts a Page struct, specifically a NetworkPage struct,
-// and extracts the elements into a slice of Network structs. In other words,
-// a generic collection is mapped into a relevant slice.
-func ExtractNetworks(page pagination.Page) ([]Network, error) {
- var resp struct {
- Networks []Network `mapstructure:"networks" json:"networks"`
- }
-
- err := mapstructure.Decode(page.(NetworkPage).Body, &resp)
-
- return resp.Networks, err
-}
diff --git a/rackspace/compute/v2/networks/urls.go b/rackspace/compute/v2/networks/urls.go
deleted file mode 100644
index 19a21aa..0000000
--- a/rackspace/compute/v2/networks/urls.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package networks
-
-import "github.com/rackspace/gophercloud"
-
-func resourceURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL("os-networksv2", id)
-}
-
-func rootURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL("os-networksv2")
-}
-
-func getURL(c *gophercloud.ServiceClient, id string) string {
- return resourceURL(c, id)
-}
-
-func listURL(c *gophercloud.ServiceClient) string {
- return rootURL(c)
-}
-
-func createURL(c *gophercloud.ServiceClient) string {
- return rootURL(c)
-}
-
-func deleteURL(c *gophercloud.ServiceClient, id string) string {
- return resourceURL(c, id)
-}
diff --git a/rackspace/compute/v2/networks/urls_test.go b/rackspace/compute/v2/networks/urls_test.go
deleted file mode 100644
index 983992e..0000000
--- a/rackspace/compute/v2/networks/urls_test.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package networks
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-const endpoint = "http://localhost:57909/"
-
-func endpointClient() *gophercloud.ServiceClient {
- return &gophercloud.ServiceClient{Endpoint: endpoint}
-}
-
-func TestGetURL(t *testing.T) {
- actual := getURL(endpointClient(), "foo")
- expected := endpoint + "os-networksv2/foo"
- th.AssertEquals(t, expected, actual)
-}
-
-func TestCreateURL(t *testing.T) {
- actual := createURL(endpointClient())
- expected := endpoint + "os-networksv2"
- th.AssertEquals(t, expected, actual)
-}
-
-func TestListURL(t *testing.T) {
- actual := createURL(endpointClient())
- expected := endpoint + "os-networksv2"
- th.AssertEquals(t, expected, actual)
-}
-
-func TestDeleteURL(t *testing.T) {
- actual := deleteURL(endpointClient(), "foo")
- expected := endpoint + "os-networksv2/foo"
- th.AssertEquals(t, expected, actual)
-}
diff --git a/rackspace/compute/v2/servers/delegate.go b/rackspace/compute/v2/servers/delegate.go
deleted file mode 100644
index 7810d15..0000000
--- a/rackspace/compute/v2/servers/delegate.go
+++ /dev/null
@@ -1,116 +0,0 @@
-package servers
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List makes a request against the API to list servers accessible to you.
-func List(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(client, opts)
-}
-
-// Create requests a server to be provisioned to the user in the current tenant.
-func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(client, opts)
-}
-
-// Update requests an existing server to be updated with the supplied options.
-func Update(client *gophercloud.ServiceClient, id string, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(client, id, opts)
-}
-
-// Delete requests that a server previously provisioned be removed from your account.
-func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult {
- return os.Delete(client, id)
-}
-
-// Get requests details on a single server, by ID.
-func Get(client *gophercloud.ServiceClient, id string) os.GetResult {
- return os.Get(client, id)
-}
-
-// ChangeAdminPassword alters the administrator or root password for a specified server.
-func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) os.ActionResult {
- return os.ChangeAdminPassword(client, id, newPassword)
-}
-
-// Reboot requests that a given server reboot. Two methods exist for rebooting a server:
-//
-// os.HardReboot (aka PowerCycle) restarts the server instance by physically cutting power to the
-// machine, or if a VM, terminating it at the hypervisor level. It's done. Caput. Full stop. Then,
-// after a brief wait, power is restored or the VM instance restarted.
-//
-// os.SoftReboot (aka OSReboot) simply tells the OS to restart under its own procedures. E.g., in
-// Linux, asking it to enter runlevel 6, or executing "sudo shutdown -r now", or by asking Windows to restart the machine.
-func Reboot(client *gophercloud.ServiceClient, id string, how os.RebootMethod) os.ActionResult {
- return os.Reboot(client, id, how)
-}
-
-// Rebuild will reprovision the server according to the configuration options provided in the
-// RebuildOpts struct.
-func Rebuild(client *gophercloud.ServiceClient, id string, opts os.RebuildOptsBuilder) os.RebuildResult {
- return os.Rebuild(client, id, opts)
-}
-
-// Resize instructs the provider to change the flavor of the server.
-// Note that this implies rebuilding it.
-// Unfortunately, one cannot pass rebuild parameters to the resize function.
-// When the resize completes, the server will be in RESIZE_VERIFY state.
-// While in this state, you can explore the use of the new server's configuration.
-// If you like it, call ConfirmResize() to commit the resize permanently.
-// Otherwise, call RevertResize() to restore the old configuration.
-func Resize(client *gophercloud.ServiceClient, id string, opts os.ResizeOptsBuilder) os.ActionResult {
- return os.Resize(client, id, opts)
-}
-
-// ConfirmResize confirms a previous resize operation on a server.
-// See Resize() for more details.
-func ConfirmResize(client *gophercloud.ServiceClient, id string) os.ActionResult {
- return os.ConfirmResize(client, id)
-}
-
-// WaitForStatus will continually poll a server until it successfully transitions to a specified
-// status. It will do this for at most the number of seconds specified.
-func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error {
- return os.WaitForStatus(c, id, status, secs)
-}
-
-// ExtractServers interprets the results of a single page from a List() call, producing a slice of Server entities.
-func ExtractServers(page pagination.Page) ([]os.Server, error) {
- return os.ExtractServers(page)
-}
-
-// ListAddresses makes a request against the API to list the servers IP addresses.
-func ListAddresses(client *gophercloud.ServiceClient, id string) pagination.Pager {
- return os.ListAddresses(client, id)
-}
-
-// ExtractAddresses interprets the results of a single page from a ListAddresses() call, producing a map of Address slices.
-func ExtractAddresses(page pagination.Page) (map[string][]os.Address, error) {
- return os.ExtractAddresses(page)
-}
-
-// ListAddressesByNetwork makes a request against the API to list the servers IP addresses
-// for the given network.
-func ListAddressesByNetwork(client *gophercloud.ServiceClient, id, network string) pagination.Pager {
- return os.ListAddressesByNetwork(client, id, network)
-}
-
-// ExtractNetworkAddresses interprets the results of a single page from a ListAddressesByNetwork() call, producing a map of Address slices.
-func ExtractNetworkAddresses(page pagination.Page) ([]os.Address, error) {
- return os.ExtractNetworkAddresses(page)
-}
-
-// Metadata requests all the metadata for the given server ID.
-func Metadata(client *gophercloud.ServiceClient, id string) os.GetMetadataResult {
- return os.Metadata(client, id)
-}
-
-// UpdateMetadata updates (or creates) all the metadata specified by opts for the given server ID.
-// This operation does not affect already-existing metadata that is not specified
-// by opts.
-func UpdateMetadata(client *gophercloud.ServiceClient, id string, opts os.UpdateMetadataOptsBuilder) os.UpdateMetadataResult {
- return os.UpdateMetadata(client, id, opts)
-}
diff --git a/rackspace/compute/v2/servers/delegate_test.go b/rackspace/compute/v2/servers/delegate_test.go
deleted file mode 100644
index 03e7ace..0000000
--- a/rackspace/compute/v2/servers/delegate_test.go
+++ /dev/null
@@ -1,182 +0,0 @@
-package servers
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListServers(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/servers/detail", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- fmt.Fprintf(w, ListOutput)
- })
-
- count := 0
- err := List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractServers(page)
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, ExpectedServerSlice, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestCreateServer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleServerCreationSuccessfully(t, CreateOutput)
-
- actual, err := Create(client.ServiceClient(), os.CreateOpts{
- Name: "derp",
- ImageRef: "f90f6034-2570-4974-8351-6b49732ef2eb",
- FlavorRef: "1",
- }).Extract()
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, &CreatedServer, actual)
-}
-
-func TestDeleteServer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleServerDeletionSuccessfully(t)
-
- res := Delete(client.ServiceClient(), "asdfasdfasdf")
- th.AssertNoErr(t, res.Err)
-}
-
-func TestGetServer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- fmt.Fprintf(w, GetOutput)
- })
-
- actual, err := Get(client.ServiceClient(), "8c65cb68-0681-4c30-bc88-6b83a8a26aee").Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &GophercloudServer, actual)
-}
-
-func TestUpdateServer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
- th.TestJSONRequest(t, r, `{ "server": { "name": "test-server-updated" } }`)
-
- w.Header().Add("Content-Type", "application/json")
-
- fmt.Fprintf(w, UpdateOutput)
- })
-
- opts := os.UpdateOpts{
- Name: "test-server-updated",
- }
- actual, err := Update(client.ServiceClient(), "8c65cb68-0681-4c30-bc88-6b83a8a26aee", opts).Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &GophercloudUpdatedServer, actual)
-}
-
-func TestChangeAdminPassword(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleAdminPasswordChangeSuccessfully(t)
-
- res := ChangeAdminPassword(client.ServiceClient(), "1234asdf", "new-password")
- th.AssertNoErr(t, res.Err)
-}
-
-func TestReboot(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleRebootSuccessfully(t)
-
- res := Reboot(client.ServiceClient(), "1234asdf", os.SoftReboot)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestRebuildServer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleRebuildSuccessfully(t, GetOutput)
-
- opts := os.RebuildOpts{
- Name: "new-name",
- AdminPass: "swordfish",
- ImageID: "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb",
- AccessIPv4: "1.2.3.4",
- }
- actual, err := Rebuild(client.ServiceClient(), "1234asdf", opts).Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &GophercloudServer, actual)
-}
-
-func TestListAddresses(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleAddressListSuccessfully(t)
-
- expected := os.ListAddressesExpected
- pages := 0
- err := ListAddresses(client.ServiceClient(), "asdfasdfasdf").EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := ExtractAddresses(page)
- th.AssertNoErr(t, err)
-
- if len(actual) != 2 {
- t.Fatalf("Expected 2 networks, got %d", len(actual))
- }
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, pages)
-}
-
-func TestListAddressesByNetwork(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleNetworkAddressListSuccessfully(t)
-
- expected := os.ListNetworkAddressesExpected
- pages := 0
- err := ListAddressesByNetwork(client.ServiceClient(), "asdfasdfasdf", "public").EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := ExtractNetworkAddresses(page)
- th.AssertNoErr(t, err)
-
- if len(actual) != 2 {
- t.Fatalf("Expected 2 addresses, got %d", len(actual))
- }
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, pages)
-}
diff --git a/rackspace/compute/v2/servers/doc.go b/rackspace/compute/v2/servers/doc.go
deleted file mode 100644
index c9f77f6..0000000
--- a/rackspace/compute/v2/servers/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package servers provides information and interaction with the server
-// API resource for the Rackspace Cloud Servers service.
-package servers
diff --git a/rackspace/compute/v2/servers/fixtures.go b/rackspace/compute/v2/servers/fixtures.go
deleted file mode 100644
index 75cccd0..0000000
--- a/rackspace/compute/v2/servers/fixtures.go
+++ /dev/null
@@ -1,574 +0,0 @@
-// +build fixtures
-
-package servers
-
-import (
- os "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
-)
-
-// ListOutput is the recorded output of a Rackspace servers.List request.
-const ListOutput = `
-{
- "servers": [
- {
- "OS-DCF:diskConfig": "MANUAL",
- "OS-EXT-STS:power_state": 1,
- "OS-EXT-STS:task_state": null,
- "OS-EXT-STS:vm_state": "active",
- "accessIPv4": "1.2.3.4",
- "accessIPv6": "1111:4822:7818:121:2000:9b5e:7438:a2d0",
- "addresses": {
- "private": [
- {
- "addr": "10.208.230.113",
- "version": 4
- }
- ],
- "public": [
- {
- "addr": "2001:4800:7818:101:2000:9b5e:7428:a2d0",
- "version": 6
- },
- {
- "addr": "104.130.131.164",
- "version": 4
- }
- ]
- },
- "created": "2014-09-23T12:34:58Z",
- "flavor": {
- "id": "performance1-8",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-8",
- "rel": "bookmark"
- }
- ]
- },
- "hostId": "e8951a524bc465b0898aeac7674da6fe1495e253ae1ea17ddb2c2475",
- "id": "59818cee-bc8c-44eb-8073-673ee65105f7",
- "image": {
- "id": "255df5fb-e3d4-45a3-9a07-c976debf7c14",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/255df5fb-e3d4-45a3-9a07-c976debf7c14",
- "rel": "bookmark"
- }
- ]
- },
- "key_name": "mykey",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/59818cee-bc8c-44eb-8073-673ee65105f7",
- "rel": "self"
- },
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/59818cee-bc8c-44eb-8073-673ee65105f7",
- "rel": "bookmark"
- }
- ],
- "metadata": {},
- "name": "devstack",
- "progress": 100,
- "status": "ACTIVE",
- "tenant_id": "111111",
- "updated": "2014-09-23T12:38:19Z",
- "user_id": "14ae7bb21d81422694655f3cc30f2930"
- },
- {
- "OS-DCF:diskConfig": "MANUAL",
- "OS-EXT-STS:power_state": 1,
- "OS-EXT-STS:task_state": null,
- "OS-EXT-STS:vm_state": "active",
- "accessIPv4": "1.1.2.3",
- "accessIPv6": "2222:4444:7817:101:be76:4eff:f0e5:9e02",
- "addresses": {
- "private": [
- {
- "addr": "10.10.20.30",
- "version": 4
- }
- ],
- "public": [
- {
- "addr": "1.1.2.3",
- "version": 4
- },
- {
- "addr": "2222:4444:7817:101:be76:4eff:f0e5:9e02",
- "version": 6
- }
- ]
- },
- "created": "2014-07-21T19:32:55Z",
- "flavor": {
- "id": "performance1-2",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-2",
- "rel": "bookmark"
- }
- ]
- },
- "hostId": "f859679906d6b1a38c1bd516b78f4dcc7d5fcf012578fa3ce460716c",
- "id": "25f1c7f5-e00a-4715-b354-16e24b2f4630",
- "image": {
- "id": "bb02b1a3-bc77-4d17-ab5b-421d89850fca",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/bb02b1a3-bc77-4d17-ab5b-421d89850fca",
- "rel": "bookmark"
- }
- ]
- },
- "key_name": "otherkey",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/25f1c7f5-e00a-4715-b355-16e24b2f4630",
- "rel": "self"
- },
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/25f1c7f5-e00a-4715-b355-16e24b2f4630",
- "rel": "bookmark"
- }
- ],
- "metadata": {},
- "name": "peril-dfw",
- "progress": 100,
- "status": "ACTIVE",
- "tenant_id": "111111",
- "updated": "2014-07-21T19:34:24Z",
- "user_id": "14ae7bb21d81422694655f3cc30f2930"
- }
- ]
-}
-`
-
-// GetOutput is the recorded output of a Rackspace servers.Get request.
-const GetOutput = `
-{
- "server": {
- "OS-DCF:diskConfig": "AUTO",
- "OS-EXT-STS:power_state": 1,
- "OS-EXT-STS:task_state": null,
- "OS-EXT-STS:vm_state": "active",
- "accessIPv4": "1.2.4.8",
- "accessIPv6": "2001:4800:6666:105:2a0f:c056:f594:7777",
- "addresses": {
- "private": [
- {
- "addr": "10.20.40.80",
- "version": 4
- }
- ],
- "public": [
- {
- "addr": "1.2.4.8",
- "version": 4
- },
- {
- "addr": "2001:4800:6666:105:2a0f:c056:f594:7777",
- "version": 6
- }
- ]
- },
- "created": "2014-10-21T14:42:16Z",
- "flavor": {
- "id": "performance1-1",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-1",
- "rel": "bookmark"
- }
- ]
- },
- "hostId": "430d2ae02de0a7af77012c94778145eccf67e75b1fac0528aa10d4a7",
- "id": "8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "image": {
- "id": "e19a734c-c7e6-443a-830c-242209c4d65d",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "bookmark"
- }
- ]
- },
- "key_name": null,
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "rel": "self"
- },
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "rel": "bookmark"
- }
- ],
- "metadata": {},
- "name": "Gophercloud-pxpGGuey",
- "progress": 100,
- "status": "ACTIVE",
- "tenant_id": "111111",
- "updated": "2014-10-21T14:42:57Z",
- "user_id": "14ae7bb21d81423694655f4dd30f2930"
- }
-}
-`
-
-// UpdateOutput is the recorded output of a Rackspace servers.Update request.
-const UpdateOutput = `
-{
- "server": {
- "OS-DCF:diskConfig": "AUTO",
- "OS-EXT-STS:power_state": 1,
- "OS-EXT-STS:task_state": null,
- "OS-EXT-STS:vm_state": "active",
- "accessIPv4": "1.2.4.8",
- "accessIPv6": "2001:4800:6666:105:2a0f:c056:f594:7777",
- "addresses": {
- "private": [
- {
- "addr": "10.20.40.80",
- "version": 4
- }
- ],
- "public": [
- {
- "addr": "1.2.4.8",
- "version": 4
- },
- {
- "addr": "2001:4800:6666:105:2a0f:c056:f594:7777",
- "version": 6
- }
- ]
- },
- "created": "2014-10-21T14:42:16Z",
- "flavor": {
- "id": "performance1-1",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-1",
- "rel": "bookmark"
- }
- ]
- },
- "hostId": "430d2ae02de0a7af77012c94778145eccf67e75b1fac0528aa10d4a7",
- "id": "8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "image": {
- "id": "e19a734c-c7e6-443a-830c-242209c4d65d",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "bookmark"
- }
- ]
- },
- "key_name": null,
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "rel": "self"
- },
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "rel": "bookmark"
- }
- ],
- "metadata": {},
- "name": "test-server-updated",
- "progress": 100,
- "status": "ACTIVE",
- "tenant_id": "111111",
- "updated": "2014-10-21T14:42:57Z",
- "user_id": "14ae7bb21d81423694655f4dd30f2930"
- }
-}
-`
-
-// CreateOutput contains a sample of Rackspace's response to a Create call.
-const CreateOutput = `
-{
- "server": {
- "OS-DCF:diskConfig": "AUTO",
- "adminPass": "v7tADqbE5pr9",
- "id": "bb63327b-6a2f-34bc-b0ef-4b6d97ea637e",
- "links": [
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/bb63327b-6a2f-34bc-b0ef-4b6d97ea637e",
- "rel": "self"
- },
- {
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/bb63327b-6a2f-34bc-b0ef-4b6d97ea637e",
- "rel": "bookmark"
- }
- ]
- }
-}
-`
-
-// DevstackServer is the expected first result from parsing ListOutput.
-var DevstackServer = os.Server{
- ID: "59818cee-bc8c-44eb-8073-673ee65105f7",
- Name: "devstack",
- TenantID: "111111",
- UserID: "14ae7bb21d81422694655f3cc30f2930",
- HostID: "e8951a524bc465b0898aeac7674da6fe1495e253ae1ea17ddb2c2475",
- Updated: "2014-09-23T12:38:19Z",
- Created: "2014-09-23T12:34:58Z",
- AccessIPv4: "1.2.3.4",
- AccessIPv6: "1111:4822:7818:121:2000:9b5e:7438:a2d0",
- Progress: 100,
- Status: "ACTIVE",
- Image: map[string]interface{}{
- "id": "255df5fb-e3d4-45a3-9a07-c976debf7c14",
- "links": []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/255df5fb-e3d4-45a3-9a07-c976debf7c14",
- "rel": "bookmark",
- },
- },
- },
- Flavor: map[string]interface{}{
- "id": "performance1-8",
- "links": []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-8",
- "rel": "bookmark",
- },
- },
- },
- Addresses: map[string]interface{}{
- "private": []interface{}{
- map[string]interface{}{
- "addr": "10.20.30.40",
- "version": float64(4.0),
- },
- },
- "public": []interface{}{
- map[string]interface{}{
- "addr": "1111:4822:7818:121:2000:9b5e:7438:a2d0",
- "version": float64(6.0),
- },
- map[string]interface{}{
- "addr": "1.2.3.4",
- "version": float64(4.0),
- },
- },
- },
- Metadata: map[string]interface{}{},
- Links: []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/59918cee-bd9d-44eb-8173-673ee75105f7",
- "rel": "self",
- },
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/59818cee-bc8c-44eb-8073-673ee65105f7",
- "rel": "bookmark",
- },
- },
- KeyName: "mykey",
- AdminPass: "",
-}
-
-// PerilServer is the expected second result from parsing ListOutput.
-var PerilServer = os.Server{
- ID: "25f1c7f5-e00a-4715-b354-16e24b2f4630",
- Name: "peril-dfw",
- TenantID: "111111",
- UserID: "14ae7bb21d81422694655f3cc30f2930",
- HostID: "f859679906d6b1a38c1bd516b78f4dcc7d5fcf012578fa3ce460716c",
- Updated: "2014-07-21T19:34:24Z",
- Created: "2014-07-21T19:32:55Z",
- AccessIPv4: "1.1.2.3",
- AccessIPv6: "2222:4444:7817:101:be76:4eff:f0e5:9e02",
- Progress: 100,
- Status: "ACTIVE",
- Image: map[string]interface{}{
- "id": "bb02b1a3-bc77-4d17-ab5b-421d89850fca",
- "links": []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/bb02b1a3-bc77-4d17-ab5b-421d89850fca",
- "rel": "bookmark",
- },
- },
- },
- Flavor: map[string]interface{}{
- "id": "performance1-2",
- "links": []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-2",
- "rel": "bookmark",
- },
- },
- },
- Addresses: map[string]interface{}{
- "private": []interface{}{
- map[string]interface{}{
- "addr": "10.10.20.30",
- "version": float64(4.0),
- },
- },
- "public": []interface{}{
- map[string]interface{}{
- "addr": "2222:4444:7817:101:be76:4eff:f0e5:9e02",
- "version": float64(6.0),
- },
- map[string]interface{}{
- "addr": "1.1.2.3",
- "version": float64(4.0),
- },
- },
- },
- Metadata: map[string]interface{}{},
- Links: []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/25f1c7f5-e00a-4715-b355-16e24b2f4630",
- "rel": "self",
- },
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/25f1c7f5-e00a-4715-b355-16e24b2f4630",
- "rel": "bookmark",
- },
- },
- KeyName: "otherkey",
- AdminPass: "",
-}
-
-// GophercloudServer is the expected result from parsing GetOutput.
-var GophercloudServer = os.Server{
- ID: "8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- Name: "Gophercloud-pxpGGuey",
- TenantID: "111111",
- UserID: "14ae7bb21d81423694655f4dd30f2930",
- HostID: "430d2ae02de0a7af77012c94778145eccf67e75b1fac0528aa10d4a7",
- Updated: "2014-10-21T14:42:57Z",
- Created: "2014-10-21T14:42:16Z",
- AccessIPv4: "1.2.4.8",
- AccessIPv6: "2001:4800:6666:105:2a0f:c056:f594:7777",
- Progress: 100,
- Status: "ACTIVE",
- Image: map[string]interface{}{
- "id": "e19a734c-c7e6-443a-830c-242209c4d65d",
- "links": []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "bookmark",
- },
- },
- },
- Flavor: map[string]interface{}{
- "id": "performance1-1",
- "links": []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-1",
- "rel": "bookmark",
- },
- },
- },
- Addresses: map[string]interface{}{
- "private": []interface{}{
- map[string]interface{}{
- "addr": "10.20.40.80",
- "version": float64(4.0),
- },
- },
- "public": []interface{}{
- map[string]interface{}{
- "addr": "2001:4800:6666:105:2a0f:c056:f594:7777",
- "version": float64(6.0),
- },
- map[string]interface{}{
- "addr": "1.2.4.8",
- "version": float64(4.0),
- },
- },
- },
- Metadata: map[string]interface{}{},
- Links: []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "rel": "self",
- },
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "rel": "bookmark",
- },
- },
- KeyName: "",
- AdminPass: "",
-}
-
-// GophercloudUpdatedServer is the expected result from parsing UpdateOutput.
-var GophercloudUpdatedServer = os.Server{
- ID: "8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- Name: "test-server-updated",
- TenantID: "111111",
- UserID: "14ae7bb21d81423694655f4dd30f2930",
- HostID: "430d2ae02de0a7af77012c94778145eccf67e75b1fac0528aa10d4a7",
- Updated: "2014-10-21T14:42:57Z",
- Created: "2014-10-21T14:42:16Z",
- AccessIPv4: "1.2.4.8",
- AccessIPv6: "2001:4800:6666:105:2a0f:c056:f594:7777",
- Progress: 100,
- Status: "ACTIVE",
- Image: map[string]interface{}{
- "id": "e19a734c-c7e6-443a-830c-242209c4d65d",
- "links": []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/e19a734c-c7e6-443a-830c-242209c4d65d",
- "rel": "bookmark",
- },
- },
- },
- Flavor: map[string]interface{}{
- "id": "performance1-1",
- "links": []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-1",
- "rel": "bookmark",
- },
- },
- },
- Addresses: map[string]interface{}{
- "private": []interface{}{
- map[string]interface{}{
- "addr": "10.20.40.80",
- "version": float64(4.0),
- },
- },
- "public": []interface{}{
- map[string]interface{}{
- "addr": "2001:4800:6666:105:2a0f:c056:f594:7777",
- "version": float64(6.0),
- },
- map[string]interface{}{
- "addr": "1.2.4.8",
- "version": float64(4.0),
- },
- },
- },
- Metadata: map[string]interface{}{},
- Links: []interface{}{
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "rel": "self",
- },
- map[string]interface{}{
- "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee",
- "rel": "bookmark",
- },
- },
- KeyName: "",
- AdminPass: "",
-}
-
-// CreatedServer is the partial Server struct that can be parsed from CreateOutput.
-var CreatedServer = os.Server{
- ID: "bb63327b-6a2f-34bc-b0ef-4b6d97ea637e",
- AdminPass: "v7tADqbE5pr9",
- Links: []interface{}{},
-}
-
-// ExpectedServerSlice is the collection of servers, in order, that should be parsed from ListOutput.
-var ExpectedServerSlice = []os.Server{DevstackServer, PerilServer}
diff --git a/rackspace/compute/v2/servers/requests.go b/rackspace/compute/v2/servers/requests.go
deleted file mode 100644
index d4472a0..0000000
--- a/rackspace/compute/v2/servers/requests.go
+++ /dev/null
@@ -1,178 +0,0 @@
-package servers
-
-import (
- "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
- "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig"
- os "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
-)
-
-// CreateOpts specifies all of the options that Rackspace accepts in its Create request, including
-// the union of all extensions that Rackspace supports.
-type CreateOpts struct {
- // Name [required] is the name to assign to the newly launched server.
- Name string
-
- // ImageRef [optional; required if ImageName is not provided] is the ID or full
- // URL to the image that contains the server's OS and initial state.
- // Also optional if using the boot-from-volume extension.
- ImageRef string
-
- // ImageName [optional; required if ImageRef is not provided] is the name of the
- // image that contains the server's OS and initial state.
- // Also optional if using the boot-from-volume extension.
- ImageName string
-
- // FlavorRef [optional; required if FlavorName is not provided] is the ID or
- // full URL to the flavor that describes the server's specs.
- FlavorRef string
-
- // FlavorName [optional; required if FlavorRef is not provided] is the name of
- // the flavor that describes the server's specs.
- FlavorName string
-
- // SecurityGroups [optional] lists the names of the security groups to which this server should belong.
- SecurityGroups []string
-
- // UserData [optional] contains configuration information or scripts to use upon launch.
- // Create will base64-encode it for you.
- UserData []byte
-
- // AvailabilityZone [optional] in which to launch the server.
- AvailabilityZone string
-
- // Networks [optional] dictates how this server will be attached to available networks.
- // By default, the server will be attached to all isolated networks for the tenant.
- Networks []os.Network
-
- // Metadata [optional] contains key-value pairs (up to 255 bytes each) to attach to the server.
- Metadata map[string]string
-
- // Personality [optional] includes files to inject into the server at launch.
- // Create will base64-encode file contents for you.
- Personality os.Personality
-
- // ConfigDrive [optional] enables metadata injection through a configuration drive.
- ConfigDrive bool
-
- // AdminPass [optional] sets the root user password. If not set, a randomly-generated
- // password will be created and returned in the response.
- AdminPass string
-
- // Rackspace-specific extensions begin here.
-
- // KeyPair [optional] specifies the name of the SSH KeyPair to be injected into the newly launched
- // server. See the "keypairs" extension in OpenStack compute v2.
- KeyPair string
-
- // DiskConfig [optional] controls how the created server's disk is partitioned. See the "diskconfig"
- // extension in OpenStack compute v2.
- DiskConfig diskconfig.DiskConfig
-
- // BlockDevice [optional] will create the server from a volume, which is created from an image,
- // a snapshot, or another volume.
- BlockDevice []bootfromvolume.BlockDevice
-}
-
-// ToServerCreateMap constructs a request body using all of the OpenStack extensions that are
-// active on Rackspace.
-func (opts CreateOpts) ToServerCreateMap() (map[string]interface{}, error) {
- base := os.CreateOpts{
- Name: opts.Name,
- ImageRef: opts.ImageRef,
- ImageName: opts.ImageName,
- FlavorRef: opts.FlavorRef,
- FlavorName: opts.FlavorName,
- SecurityGroups: opts.SecurityGroups,
- UserData: opts.UserData,
- AvailabilityZone: opts.AvailabilityZone,
- Networks: opts.Networks,
- Metadata: opts.Metadata,
- Personality: opts.Personality,
- ConfigDrive: opts.ConfigDrive,
- AdminPass: opts.AdminPass,
- }
-
- drive := diskconfig.CreateOptsExt{
- CreateOptsBuilder: base,
- DiskConfig: opts.DiskConfig,
- }
-
- res, err := drive.ToServerCreateMap()
- if err != nil {
- return nil, err
- }
-
- if len(opts.BlockDevice) != 0 {
- bfv := bootfromvolume.CreateOptsExt{
- CreateOptsBuilder: drive,
- BlockDevice: opts.BlockDevice,
- }
-
- res, err = bfv.ToServerCreateMap()
- if err != nil {
- return nil, err
- }
- }
-
- // key_name doesn't actually come from the extension (or at least isn't documented there) so
- // we need to add it manually.
- serverMap := res["server"].(map[string]interface{})
- if opts.KeyPair != "" {
- serverMap["key_name"] = opts.KeyPair
- }
-
- return res, nil
-}
-
-// RebuildOpts represents all of the configuration options used in a server rebuild operation that
-// are supported by Rackspace.
-type RebuildOpts struct {
- // Required. The ID of the image you want your server to be provisioned on
- ImageID string
-
- // Name to set the server to
- Name string
-
- // Required. The server's admin password
- AdminPass string
-
- // AccessIPv4 [optional] provides a new IPv4 address for the instance.
- AccessIPv4 string
-
- // AccessIPv6 [optional] provides a new IPv6 address for the instance.
- AccessIPv6 string
-
- // Metadata [optional] contains key-value pairs (up to 255 bytes each) to attach to the server.
- Metadata map[string]string
-
- // Personality [optional] includes files to inject into the server at launch.
- // Rebuild will base64-encode file contents for you.
- Personality os.Personality
-
- // Rackspace-specific stuff begins here.
-
- // DiskConfig [optional] controls how the created server's disk is partitioned. See the "diskconfig"
- // extension in OpenStack compute v2.
- DiskConfig diskconfig.DiskConfig
-}
-
-// ToServerRebuildMap constructs a request body using all of the OpenStack extensions that are
-// active on Rackspace.
-func (opts RebuildOpts) ToServerRebuildMap() (map[string]interface{}, error) {
- base := os.RebuildOpts{
- ImageID: opts.ImageID,
- Name: opts.Name,
- AdminPass: opts.AdminPass,
- AccessIPv4: opts.AccessIPv4,
- AccessIPv6: opts.AccessIPv6,
- Metadata: opts.Metadata,
- Personality: opts.Personality,
- }
-
- drive := diskconfig.RebuildOptsExt{
- RebuildOptsBuilder: base,
- DiskConfig: opts.DiskConfig,
- }
-
- return drive.ToServerRebuildMap()
-}
diff --git a/rackspace/compute/v2/servers/requests_test.go b/rackspace/compute/v2/servers/requests_test.go
deleted file mode 100644
index 828b5dc..0000000
--- a/rackspace/compute/v2/servers/requests_test.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package servers
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-func TestCreateOpts(t *testing.T) {
- opts := CreateOpts{
- Name: "createdserver",
- ImageRef: "image-id",
- FlavorRef: "flavor-id",
- KeyPair: "mykey",
- DiskConfig: diskconfig.Manual,
- }
-
- expected := `
- {
- "server": {
- "name": "createdserver",
- "imageRef": "image-id",
- "flavorRef": "flavor-id",
- "flavorName": "",
- "imageName": "",
- "key_name": "mykey",
- "OS-DCF:diskConfig": "MANUAL"
- }
- }
- `
- actual, err := opts.ToServerCreateMap()
- th.AssertNoErr(t, err)
- th.CheckJSONEquals(t, expected, actual)
-}
-
-func TestRebuildOpts(t *testing.T) {
- opts := RebuildOpts{
- Name: "rebuiltserver",
- AdminPass: "swordfish",
- ImageID: "asdfasdfasdf",
- DiskConfig: diskconfig.Auto,
- }
-
- actual, err := opts.ToServerRebuildMap()
- th.AssertNoErr(t, err)
-
- expected := `
- {
- "rebuild": {
- "name": "rebuiltserver",
- "imageRef": "asdfasdfasdf",
- "adminPass": "swordfish",
- "OS-DCF:diskConfig": "AUTO"
- }
- }
- `
- th.CheckJSONEquals(t, expected, actual)
-}
diff --git a/rackspace/compute/v2/virtualinterfaces/requests.go b/rackspace/compute/v2/virtualinterfaces/requests.go
deleted file mode 100644
index 1ff7c5a..0000000
--- a/rackspace/compute/v2/virtualinterfaces/requests.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package virtualinterfaces
-
-import (
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager which allows you to iterate over a collection of
-// networks. It accepts a ListOpts struct, which allows you to filter and sort
-// the returned collection for greater efficiency.
-func List(c *gophercloud.ServiceClient, instanceID string) pagination.Pager {
- createPage := func(r pagination.PageResult) pagination.Page {
- return VirtualInterfacePage{pagination.SinglePageBase(r)}
- }
-
- return pagination.NewPager(c, listURL(c, instanceID), createPage)
-}
-
-// Create creates a new virtual interface for a network and attaches the network
-// to the server instance.
-func Create(c *gophercloud.ServiceClient, instanceID, networkID string) CreateResult {
- var res CreateResult
-
- reqBody := map[string]map[string]string{
- "virtual_interface": {
- "network_id": networkID,
- },
- }
-
- // Send request to API
- _, res.Err = c.Post(createURL(c, instanceID), reqBody, &res.Body, &gophercloud.RequestOpts{
- OkCodes: []int{200, 201, 202},
- })
- return res
-}
-
-// Delete deletes the interface with interfaceID attached to the instance with
-// instanceID.
-func Delete(c *gophercloud.ServiceClient, instanceID, interfaceID string) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(deleteURL(c, instanceID, interfaceID), &gophercloud.RequestOpts{
- OkCodes: []int{200, 204},
- })
- return res
-}
diff --git a/rackspace/compute/v2/virtualinterfaces/requests_test.go b/rackspace/compute/v2/virtualinterfaces/requests_test.go
deleted file mode 100644
index d40af9c..0000000
--- a/rackspace/compute/v2/virtualinterfaces/requests_test.go
+++ /dev/null
@@ -1,165 +0,0 @@
-package virtualinterfaces
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/servers/12345/os-virtual-interfacesv2", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "virtual_interfaces": [
- {
- "id": "de7c6d53-b895-4b4a-963c-517ccb0f0775",
- "ip_addresses": [
- {
- "address": "192.168.0.2",
- "network_id": "f212726e-6321-4210-9bae-a13f5a33f83f",
- "network_label": "superprivate_xml"
- }
- ],
- "mac_address": "BC:76:4E:04:85:20"
- },
- {
- "id": "e14e789d-3b98-44a6-9c2d-c23eb1d1465c",
- "ip_addresses": [
- {
- "address": "10.181.1.30",
- "network_id": "3b324a1b-31b8-4db5-9fe5-4a2067f60297",
- "network_label": "private"
- }
- ],
- "mac_address": "BC:76:4E:04:81:55"
- }
- ]
-}
- `)
- })
-
- client := fake.ServiceClient()
- count := 0
-
- err := List(client, "12345").EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractVirtualInterfaces(page)
- if err != nil {
- t.Errorf("Failed to extract networks: %v", err)
- return false, err
- }
-
- expected := []VirtualInterface{
- VirtualInterface{
- MACAddress: "BC:76:4E:04:85:20",
- IPAddresses: []IPAddress{
- IPAddress{
- Address: "192.168.0.2",
- NetworkID: "f212726e-6321-4210-9bae-a13f5a33f83f",
- NetworkLabel: "superprivate_xml",
- },
- },
- ID: "de7c6d53-b895-4b4a-963c-517ccb0f0775",
- },
- VirtualInterface{
- MACAddress: "BC:76:4E:04:81:55",
- IPAddresses: []IPAddress{
- IPAddress{
- Address: "10.181.1.30",
- NetworkID: "3b324a1b-31b8-4db5-9fe5-4a2067f60297",
- NetworkLabel: "private",
- },
- },
- ID: "e14e789d-3b98-44a6-9c2d-c23eb1d1465c",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/servers/12345/os-virtual-interfacesv2", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "virtual_interface": {
- "network_id": "6789"
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `{
- "virtual_interfaces": [
- {
- "id": "de7c6d53-b895-4b4a-963c-517ccb0f0775",
- "ip_addresses": [
- {
- "address": "192.168.0.2",
- "network_id": "f212726e-6321-4210-9bae-a13f5a33f83f",
- "network_label": "superprivate_xml"
- }
- ],
- "mac_address": "BC:76:4E:04:85:20"
- }
- ]
- }`)
- })
-
- expected := &VirtualInterface{
- MACAddress: "BC:76:4E:04:85:20",
- IPAddresses: []IPAddress{
- IPAddress{
- Address: "192.168.0.2",
- NetworkID: "f212726e-6321-4210-9bae-a13f5a33f83f",
- NetworkLabel: "superprivate_xml",
- },
- },
- ID: "de7c6d53-b895-4b4a-963c-517ccb0f0775",
- }
-
- actual, err := Create(fake.ServiceClient(), "12345", "6789").Extract()
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, expected, actual)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/servers/12345/os-virtual-interfacesv2/6789", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-
- res := Delete(fake.ServiceClient(), "12345", "6789")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/compute/v2/virtualinterfaces/results.go b/rackspace/compute/v2/virtualinterfaces/results.go
deleted file mode 100644
index 26fa7f3..0000000
--- a/rackspace/compute/v2/virtualinterfaces/results.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package virtualinterfaces
-
-import (
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-type commonResult struct {
- gophercloud.Result
-}
-
-// Extract is a function that accepts a result and extracts a network resource.
-func (r commonResult) Extract() (*VirtualInterface, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var res struct {
- VirtualInterfaces []VirtualInterface `mapstructure:"virtual_interfaces" json:"virtual_interfaces"`
- }
-
- err := mapstructure.Decode(r.Body, &res)
-
- return &res.VirtualInterfaces[0], 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
-}
-
-// IPAddress represents a vitual address attached to a VirtualInterface.
-type IPAddress struct {
- Address string `mapstructure:"address" json:"address"`
- NetworkID string `mapstructure:"network_id" json:"network_id"`
- NetworkLabel string `mapstructure:"network_label" json:"network_label"`
-}
-
-// VirtualInterface represents a virtual interface.
-type VirtualInterface struct {
- // UUID for the virtual interface
- ID string `mapstructure:"id" json:"id"`
-
- MACAddress string `mapstructure:"mac_address" json:"mac_address"`
-
- IPAddresses []IPAddress `mapstructure:"ip_addresses" json:"ip_addresses"`
-}
-
-// VirtualInterfacePage is the page returned by a pager when traversing over a
-// collection of virtual interfaces.
-type VirtualInterfacePage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty returns true if the NetworkPage contains no Networks.
-func (r VirtualInterfacePage) IsEmpty() (bool, error) {
- networks, err := ExtractVirtualInterfaces(r)
- if err != nil {
- return true, err
- }
- return len(networks) == 0, nil
-}
-
-// ExtractVirtualInterfaces accepts a Page struct, specifically a VirtualInterfacePage struct,
-// and extracts the elements into a slice of VirtualInterface structs. In other words,
-// a generic collection is mapped into a relevant slice.
-func ExtractVirtualInterfaces(page pagination.Page) ([]VirtualInterface, error) {
- var resp struct {
- VirtualInterfaces []VirtualInterface `mapstructure:"virtual_interfaces" json:"virtual_interfaces"`
- }
-
- err := mapstructure.Decode(page.(VirtualInterfacePage).Body, &resp)
-
- return resp.VirtualInterfaces, err
-}
diff --git a/rackspace/compute/v2/virtualinterfaces/urls.go b/rackspace/compute/v2/virtualinterfaces/urls.go
deleted file mode 100644
index 9e5693e..0000000
--- a/rackspace/compute/v2/virtualinterfaces/urls.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package virtualinterfaces
-
-import "github.com/rackspace/gophercloud"
-
-func listURL(c *gophercloud.ServiceClient, instanceID string) string {
- return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2")
-}
-
-func createURL(c *gophercloud.ServiceClient, instanceID string) string {
- return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2")
-}
-
-func deleteURL(c *gophercloud.ServiceClient, instanceID, interfaceID string) string {
- return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2", interfaceID)
-}
diff --git a/rackspace/compute/v2/virtualinterfaces/urls_test.go b/rackspace/compute/v2/virtualinterfaces/urls_test.go
deleted file mode 100644
index 6732e4e..0000000
--- a/rackspace/compute/v2/virtualinterfaces/urls_test.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package virtualinterfaces
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-const endpoint = "http://localhost:57909/"
-
-func endpointClient() *gophercloud.ServiceClient {
- return &gophercloud.ServiceClient{Endpoint: endpoint}
-}
-
-func TestCreateURL(t *testing.T) {
- actual := createURL(endpointClient(), "12345")
- expected := endpoint + "servers/12345/os-virtual-interfacesv2"
- th.AssertEquals(t, expected, actual)
-}
-
-func TestListURL(t *testing.T) {
- actual := createURL(endpointClient(), "12345")
- expected := endpoint + "servers/12345/os-virtual-interfacesv2"
- th.AssertEquals(t, expected, actual)
-}
-
-func TestDeleteURL(t *testing.T) {
- actual := deleteURL(endpointClient(), "12345", "6789")
- expected := endpoint + "servers/12345/os-virtual-interfacesv2/6789"
- th.AssertEquals(t, expected, actual)
-}
diff --git a/rackspace/compute/v2/volumeattach/delegate.go b/rackspace/compute/v2/volumeattach/delegate.go
deleted file mode 100644
index c6003e0..0000000
--- a/rackspace/compute/v2/volumeattach/delegate.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package volumeattach
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager that allows you to iterate over a collection of VolumeAttachments.
-func List(client *gophercloud.ServiceClient, serverID string) pagination.Pager {
- return os.List(client, serverID)
-}
-
-// Create requests the creation of a new volume attachment on the server
-func Create(client *gophercloud.ServiceClient, serverID string, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(client, serverID, opts)
-}
-
-// Get returns public data about a previously created VolumeAttachment.
-func Get(client *gophercloud.ServiceClient, serverID, aID string) os.GetResult {
- return os.Get(client, serverID, aID)
-}
-
-// Delete requests the deletion of a previous stored VolumeAttachment from the server.
-func Delete(client *gophercloud.ServiceClient, serverID, aID string) os.DeleteResult {
- return os.Delete(client, serverID, aID)
-}
diff --git a/rackspace/compute/v2/volumeattach/delegate_test.go b/rackspace/compute/v2/volumeattach/delegate_test.go
deleted file mode 100644
index f7ef45e..0000000
--- a/rackspace/compute/v2/volumeattach/delegate_test.go
+++ /dev/null
@@ -1,95 +0,0 @@
-package volumeattach
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach"
- fixtures "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/testing"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-// FirstVolumeAttachment is the first result in ListOutput.
-var FirstVolumeAttachment = volumeattach.VolumeAttachment{
- Device: "/dev/vdd",
- ID: "a26887c6-c47b-4654-abb5-dfadf7d3f803",
- ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
- VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f803",
-}
-
-// SecondVolumeAttachment is the first result in ListOutput.
-var SecondVolumeAttachment = volumeattach.VolumeAttachment{
- Device: "/dev/vdc",
- ID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
- ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
- VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
-}
-
-// ExpectedVolumeAttachmentSlide is the slice of results that should be parsed
-// from ListOutput, in the expected order.
-var ExpectedVolumeAttachmentSlice = []volumeattach.VolumeAttachment{FirstVolumeAttachment, SecondVolumeAttachment}
-
-//CreatedVolumeAttachment is the parsed result from CreatedOutput.
-var CreatedVolumeAttachment = volumeattach.VolumeAttachment{
- Device: "/dev/vdc",
- ID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
- ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
- VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
-}
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixtures.HandleListSuccessfully(t)
- serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
-
- count := 0
- err := List(client.ServiceClient(), serverId).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := volumeattach.ExtractVolumeAttachments(page)
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, ExpectedVolumeAttachmentSlice, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixtures.HandleCreateSuccessfully(t)
- serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
-
- actual, err := Create(client.ServiceClient(), serverId, volumeattach.CreateOpts{
- Device: "/dev/vdc",
- VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
- }).Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &CreatedVolumeAttachment, actual)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixtures.HandleGetSuccessfully(t)
- aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
- serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
-
- actual, err := Get(client.ServiceClient(), serverId, aId).Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, &SecondVolumeAttachment, actual)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixtures.HandleDeleteSuccessfully(t)
- aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
- serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
-
- err := Delete(client.ServiceClient(), serverId, aId).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/compute/v2/volumeattach/doc.go b/rackspace/compute/v2/volumeattach/doc.go
deleted file mode 100644
index 2164908..0000000
--- a/rackspace/compute/v2/volumeattach/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package volumeattach provides the ability to attach and detach volume
-// to instances to Rackspace servers
-package volumeattach
diff --git a/rackspace/db/v1/backups/doc.go b/rackspace/db/v1/backups/doc.go
deleted file mode 100644
index 664eead..0000000
--- a/rackspace/db/v1/backups/doc.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// Package backups provides information and interaction with the backup API
-// resource in the Rackspace Database service.
-//
-// A backup is a copy of a database instance that can be used to restore it to
-// some defined point in history.
-package backups
diff --git a/rackspace/db/v1/backups/fixtures.go b/rackspace/db/v1/backups/fixtures.go
deleted file mode 100644
index 45c2376..0000000
--- a/rackspace/db/v1/backups/fixtures.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package backups
-
-import "time"
-
-var (
- timestamp = "2015-11-12T14:22:42Z"
- timeVal, _ = time.Parse(time.RFC3339, timestamp)
-)
-
-var getResp = `
-{
- "backup": {
- "created": "` + timestamp + `",
- "description": "My Backup",
- "id": "61f12fef-edb1-4561-8122-e7c00ef26a82",
- "instance_id": "d4603f69-ec7e-4e9b-803f-600b9205576f",
- "locationRef": null,
- "name": "snapshot",
- "parent_id": null,
- "size": 100,
- "status": "NEW",
- "datastore": {
- "version": "5.1",
- "type": "MySQL",
- "version_id": "20000000-0000-0000-0000-000000000002"
- },
- "updated": "` + timestamp + `"
- }
-}
-`
-
-var createReq = `
-{
- "backup": {
- "description": "My Backup",
- "instance": "d4603f69-ec7e-4e9b-803f-600b9205576f",
- "name": "snapshot"
- }
-}
-`
-
-var createResp = getResp
-
-var listResp = `
-{
- "backups": [
- {
- "status": "COMPLETED",
- "updated": "` + timestamp + `",
- "description": "Backup from Restored Instance",
- "datastore": {
- "version": "5.1",
- "type": "MySQL",
- "version_id": "20000000-0000-0000-0000-000000000002"
- },
- "id": "87972694-4be2-40f5-83f8-501656e0032a",
- "size": 0.141026,
- "name": "restored_backup",
- "created": "` + timestamp + `",
- "instance_id": "29af2cd9-0674-48ab-b87a-b160f00208e6",
- "parent_id": null,
- "locationRef": "http://localhost/path/to/backup"
- }
- ]
-}
-`
diff --git a/rackspace/db/v1/backups/requests.go b/rackspace/db/v1/backups/requests.go
deleted file mode 100644
index 9170d78..0000000
--- a/rackspace/db/v1/backups/requests.go
+++ /dev/null
@@ -1,138 +0,0 @@
-package backups
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// CreateOptsBuilder is the top-level interface for creating JSON maps.
-type CreateOptsBuilder interface {
- ToBackupCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts is responsible for configuring newly provisioned backups.
-type CreateOpts struct {
- // [REQUIRED] The name of the backup. The only restriction is the name must
- // be less than 64 characters long.
- Name string
-
- // [REQUIRED] The ID of the instance being backed up.
- InstanceID string
-
- // [OPTIONAL] A human-readable explanation of the backup.
- Description string
-}
-
-// ToBackupCreateMap will create a JSON map for the Create operation.
-func (opts CreateOpts) ToBackupCreateMap() (map[string]interface{}, error) {
- if opts.Name == "" {
- return nil, errors.New("Name is a required field")
- }
- if opts.InstanceID == "" {
- return nil, errors.New("InstanceID is a required field")
- }
-
- backup := map[string]interface{}{
- "name": opts.Name,
- "instance": opts.InstanceID,
- }
-
- if opts.Description != "" {
- backup["description"] = opts.Description
- }
-
- return map[string]interface{}{"backup": backup}, nil
-}
-
-// Create asynchronously creates a new backup for a specified database instance.
-// During the backup process, write access on MyISAM databases will be
-// temporarily disabled; innoDB databases will be unaffected. During this time,
-// you will not be able to add or delete databases or users; nor delete, stop
-// or reboot the instance itself. Only one backup is permitted at once.
-//
-// Backups are not deleted when database instances are deleted; you must
-// manually delete any backups created using Delete(). Backups are saved to your
-// Cloud Files account in a new container called z_CLOUDDB_BACKUPS. It is
-// strongly recommended you do not alter this container or its contents; usual
-// storage costs apply.
-func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
- var res CreateResult
-
- reqBody, err := opts.ToBackupCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = client.Request("POST", baseURL(client), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{202},
- })
-
- return res
-}
-
-// ListOptsBuilder is the top-level interface for creating query strings.
-type ListOptsBuilder interface {
- ToBackupListQuery() (string, error)
-}
-
-// ListOpts allows you to refine a list search by certain parameters.
-type ListOpts struct {
- // The type of datastore by which to filter.
- Datastore string `q:"datastore"`
-}
-
-// ToBackupListQuery converts a ListOpts struct into a query string.
-func (opts ListOpts) ToBackupListQuery() (string, error) {
- q, err := gophercloud.BuildQueryString(opts)
- if err != nil {
- return "", err
- }
- return q.String(), nil
-}
-
-// List will list all the saved backups for all database instances.
-func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
- url := baseURL(client)
-
- if opts != nil {
- query, err := opts.ToBackupListQuery()
- if err != nil {
- return pagination.Pager{Err: err}
- }
- url += query
- }
-
- pageFn := func(r pagination.PageResult) pagination.Page {
- return BackupPage{pagination.SinglePageBase(r)}
- }
-
- return pagination.NewPager(client, url, pageFn)
-}
-
-// Get will retrieve details for a particular backup based on its unique ID.
-func Get(client *gophercloud.ServiceClient, id string) GetResult {
- var res GetResult
-
- _, res.Err = client.Request("GET", resourceURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
- return res
-}
-
-// Delete will permanently delete a backup.
-func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
- var res DeleteResult
-
- _, res.Err = client.Request("DELETE", resourceURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
- return res
-}
diff --git a/rackspace/db/v1/backups/requests_test.go b/rackspace/db/v1/backups/requests_test.go
deleted file mode 100644
index d706733..0000000
--- a/rackspace/db/v1/backups/requests_test.go
+++ /dev/null
@@ -1,131 +0,0 @@
-package backups
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud/openstack/db/v1/datastores"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
- "github.com/rackspace/gophercloud/testhelper/fixture"
-)
-
-var (
- backupID = "{backupID}"
- _rootURL = "/backups"
- resURL = _rootURL + "/" + backupID
-)
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _rootURL, "POST", createReq, createResp, 202)
-
- opts := CreateOpts{
- Name: "snapshot",
- Description: "My Backup",
- InstanceID: "d4603f69-ec7e-4e9b-803f-600b9205576f",
- }
-
- instance, err := Create(fake.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
-
- expected := &Backup{
- Created: timeVal,
- Description: "My Backup",
- ID: "61f12fef-edb1-4561-8122-e7c00ef26a82",
- InstanceID: "d4603f69-ec7e-4e9b-803f-600b9205576f",
- LocationRef: "",
- Name: "snapshot",
- ParentID: "",
- Size: 100,
- Status: "NEW",
- Updated: timeVal,
- Datastore: datastores.DatastorePartial{
- Version: "5.1",
- Type: "MySQL",
- VersionID: "20000000-0000-0000-0000-000000000002",
- },
- }
-
- th.AssertDeepEquals(t, expected, instance)
-}
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _rootURL, "GET", "", listResp, 200)
-
- pages := 0
-
- err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- pages++
- actual, err := ExtractBackups(page)
- th.AssertNoErr(t, err)
-
- expected := []Backup{
- Backup{
- Created: timeVal,
- Description: "Backup from Restored Instance",
- ID: "87972694-4be2-40f5-83f8-501656e0032a",
- InstanceID: "29af2cd9-0674-48ab-b87a-b160f00208e6",
- LocationRef: "http://localhost/path/to/backup",
- Name: "restored_backup",
- ParentID: "",
- Size: 0.141026,
- Status: "COMPLETED",
- Updated: timeVal,
- Datastore: datastores.DatastorePartial{
- Version: "5.1",
- Type: "MySQL",
- VersionID: "20000000-0000-0000-0000-000000000002",
- },
- },
- }
-
- th.AssertDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "GET", "", getResp, 200)
-
- instance, err := Get(fake.ServiceClient(), backupID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &Backup{
- Created: timeVal,
- Description: "My Backup",
- ID: "61f12fef-edb1-4561-8122-e7c00ef26a82",
- InstanceID: "d4603f69-ec7e-4e9b-803f-600b9205576f",
- LocationRef: "",
- Name: "snapshot",
- ParentID: "",
- Size: 100,
- Status: "NEW",
- Updated: timeVal,
- Datastore: datastores.DatastorePartial{
- Version: "5.1",
- Type: "MySQL",
- VersionID: "20000000-0000-0000-0000-000000000002",
- },
- }
-
- th.AssertDeepEquals(t, expected, instance)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "DELETE", "", "", 202)
-
- err := Delete(fake.ServiceClient(), backupID).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/db/v1/backups/results.go b/rackspace/db/v1/backups/results.go
deleted file mode 100644
index 04faf32..0000000
--- a/rackspace/db/v1/backups/results.go
+++ /dev/null
@@ -1,149 +0,0 @@
-package backups
-
-import (
- "fmt"
- "reflect"
- "time"
-
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/openstack/db/v1/datastores"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// Status represents the various states a Backup can be in.
-type Status string
-
-// Enum types for the status.
-const (
- StatusNew Status = "NEW"
- StatusBuilding Status = "BUILDING"
- StatusCompleted Status = "COMPLETED"
- StatusFailed Status = "FAILED"
- StatusDeleteFailed Status = "DELETE_FAILED"
-)
-
-// Backup represents a Backup API resource.
-type Backup struct {
- Description string
- ID string
- InstanceID string `json:"instance_id" mapstructure:"instance_id"`
- LocationRef string
- Name string
- ParentID string `json:"parent_id" mapstructure:"parent_id"`
- Size float64
- Status Status
- Created time.Time `mapstructure:"-"`
- Updated time.Time `mapstructure:"-"`
- Datastore datastores.DatastorePartial
-}
-
-// CreateResult represents the result of a create operation.
-type CreateResult struct {
- commonResult
-}
-
-// GetResult represents the result of a get operation.
-type GetResult struct {
- commonResult
-}
-
-// DeleteResult represents the result of a delete operation.
-type DeleteResult struct {
- gophercloud.ErrResult
-}
-
-type commonResult struct {
- gophercloud.Result
-}
-
-// Extract will retrieve a Backup struct from an operation's result.
-func (r commonResult) Extract() (*Backup, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- Backup Backup `mapstructure:"backup"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
- val := r.Body.(map[string]interface{})["backup"].(map[string]interface{})
-
- if t, ok := val["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &response.Backup, err
- }
- response.Backup.Created = creationTime
- }
-
- if t, ok := val["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &response.Backup, err
- }
- response.Backup.Updated = updatedTime
- }
-
- return &response.Backup, err
-}
-
-// BackupPage represents a page of backups.
-type BackupPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty checks whether an BackupPage struct is empty.
-func (r BackupPage) IsEmpty() (bool, error) {
- is, err := ExtractBackups(r)
- if err != nil {
- return true, err
- }
- return len(is) == 0, nil
-}
-
-// ExtractBackups will retrieve a slice of Backup structs from a paginated collection.
-func ExtractBackups(page pagination.Page) ([]Backup, error) {
- casted := page.(BackupPage).Body
-
- var resp struct {
- Backups []Backup `mapstructure:"backups" json:"backups"`
- }
-
- if err := mapstructure.Decode(casted, &resp); err != nil {
- return nil, err
- }
-
- var vals []interface{}
- switch casted.(type) {
- case map[string]interface{}:
- vals = casted.(map[string]interface{})["backups"].([]interface{})
- case map[string][]interface{}:
- vals = casted.(map[string][]interface{})["backups"]
- default:
- return resp.Backups, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
- }
-
- for i, v := range vals {
- val := v.(map[string]interface{})
-
- if t, ok := val["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return resp.Backups, err
- }
- resp.Backups[i].Created = creationTime
- }
-
- if t, ok := val["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return resp.Backups, err
- }
- resp.Backups[i].Updated = updatedTime
- }
- }
-
- return resp.Backups, nil
-}
diff --git a/rackspace/db/v1/backups/urls.go b/rackspace/db/v1/backups/urls.go
deleted file mode 100644
index 553444e..0000000
--- a/rackspace/db/v1/backups/urls.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package backups
-
-import "github.com/rackspace/gophercloud"
-
-func baseURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL("backups")
-}
-
-func resourceURL(c *gophercloud.ServiceClient, backupID string) string {
- return c.ServiceURL("backups", backupID)
-}
diff --git a/rackspace/db/v1/configurations/delegate.go b/rackspace/db/v1/configurations/delegate.go
deleted file mode 100644
index d8cb48a..0000000
--- a/rackspace/db/v1/configurations/delegate.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package configurations
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/db/v1/configurations"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List will list all of the available configurations.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client)
-}
-
-// Create will create a new configuration group.
-func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(client, opts)
-}
-
-// Get will retrieve the details for a specified configuration group.
-func Get(client *gophercloud.ServiceClient, configID string) os.GetResult {
- return os.Get(client, configID)
-}
-
-// Update will modify an existing configuration group by performing a merge
-// between new and existing values. If the key already exists, the new value
-// will overwrite. All other keys will remain unaffected.
-func Update(client *gophercloud.ServiceClient, configID string, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(client, configID, opts)
-}
-
-// Replace will modify an existing configuration group by overwriting the
-// entire parameter group with the new values provided. Any existing keys not
-// included in UpdateOptsBuilder will be deleted.
-func Replace(client *gophercloud.ServiceClient, configID string, opts os.UpdateOptsBuilder) os.ReplaceResult {
- return os.Replace(client, configID, opts)
-}
-
-// Delete will permanently delete a configuration group. Please note that
-// config groups cannot be deleted whilst still attached to running instances -
-// you must detach and then delete them.
-func Delete(client *gophercloud.ServiceClient, configID string) os.DeleteResult {
- return os.Delete(client, configID)
-}
-
-// ListInstances will list all the instances associated with a particular
-// configuration group.
-func ListInstances(client *gophercloud.ServiceClient, configID string) pagination.Pager {
- return os.ListInstances(client, configID)
-}
-
-// ListDatastoreParams will list all the available and supported parameters
-// that can be used for a particular datastore ID and a particular version.
-// For example, if you are wondering how you can configure a MySQL 5.6 instance,
-// you can use this operation (you will need to retrieve the MySQL datastore ID
-// by using the datastores API).
-func ListDatastoreParams(client *gophercloud.ServiceClient, datastoreID, versionID string) pagination.Pager {
- return os.ListDatastoreParams(client, datastoreID, versionID)
-}
-
-// GetDatastoreParam will retrieve information about a specific configuration
-// parameter. For example, you can use this operation to understand more about
-// "innodb_file_per_table" configuration param for MySQL datastores. You will
-// need the param's ID first, which can be attained by using the ListDatastoreParams
-// operation.
-func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID, paramID string) os.ParamResult {
- return os.GetDatastoreParam(client, datastoreID, versionID, paramID)
-}
-
-// ListGlobalParams is similar to ListDatastoreParams but does not require a
-// DatastoreID.
-func ListGlobalParams(client *gophercloud.ServiceClient, versionID string) pagination.Pager {
- return os.ListGlobalParams(client, versionID)
-}
-
-// GetGlobalParam is similar to GetDatastoreParam but does not require a
-// DatastoreID.
-func GetGlobalParam(client *gophercloud.ServiceClient, versionID, paramID string) os.ParamResult {
- return os.GetGlobalParam(client, versionID, paramID)
-}
diff --git a/rackspace/db/v1/configurations/delegate_test.go b/rackspace/db/v1/configurations/delegate_test.go
deleted file mode 100644
index 580f02a..0000000
--- a/rackspace/db/v1/configurations/delegate_test.go
+++ /dev/null
@@ -1,237 +0,0 @@
-package configurations
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/db/v1/configurations"
- "github.com/rackspace/gophercloud/pagination"
- "github.com/rackspace/gophercloud/rackspace/db/v1/instances"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
- "github.com/rackspace/gophercloud/testhelper/fixture"
-)
-
-var (
- configID = "{configID}"
- _baseURL = "/configurations"
- resURL = _baseURL + "/" + configID
-
- dsID = "{datastoreID}"
- versionID = "{versionID}"
- paramID = "{paramID}"
- dsParamListURL = "/datastores/" + dsID + "/versions/" + versionID + "/parameters"
- dsParamGetURL = "/datastores/" + dsID + "/versions/" + versionID + "/parameters/" + paramID
- globalParamListURL = "/datastores/versions/" + versionID + "/parameters"
- globalParamGetURL = "/datastores/versions/" + versionID + "/parameters/" + paramID
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _baseURL, "GET", "", listConfigsJSON, 200)
-
- count := 0
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractConfigs(page)
- th.AssertNoErr(t, err)
-
- expected := []os.Config{exampleConfig}
- th.AssertDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertEquals(t, 1, count)
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "GET", "", getConfigJSON, 200)
-
- config, err := Get(fake.ServiceClient(), configID).Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, &exampleConfig, config)
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _baseURL, "POST", createReq, createConfigJSON, 200)
-
- opts := os.CreateOpts{
- Datastore: &os.DatastoreOpts{
- Type: "a00000a0-00a0-0a00-00a0-000a000000aa",
- Version: "b00000b0-00b0-0b00-00b0-000b000000bb",
- },
- Description: "example description",
- Name: "example-configuration-name",
- Values: map[string]interface{}{
- "collation_server": "latin1_swedish_ci",
- "connect_timeout": 120,
- },
- }
-
- config, err := Create(fake.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, &exampleConfigWithValues, config)
-}
-
-func TestUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "PATCH", updateReq, "", 200)
-
- opts := os.UpdateOpts{
- Values: map[string]interface{}{
- "connect_timeout": 300,
- },
- }
-
- err := Update(fake.ServiceClient(), configID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestReplace(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "PUT", updateReq, "", 202)
-
- opts := os.UpdateOpts{
- Values: map[string]interface{}{
- "connect_timeout": 300,
- },
- }
-
- err := Replace(fake.ServiceClient(), configID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "DELETE", "", "", 202)
-
- err := Delete(fake.ServiceClient(), configID).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestListInstances(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL+"/instances", "GET", "", listInstancesJSON, 200)
-
- expectedInstance := instances.Instance{
- ID: "d4603f69-ec7e-4e9b-803f-600b9205576f",
- Name: "json_rack_instance",
- }
-
- pages := 0
- err := ListInstances(fake.ServiceClient(), configID).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := instances.ExtractInstances(page)
- if err != nil {
- return false, err
- }
-
- th.AssertDeepEquals(t, actual, []instances.Instance{expectedInstance})
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestListDSParams(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, dsParamListURL, "GET", "", listParamsJSON, 200)
-
- pages := 0
- err := ListDatastoreParams(fake.ServiceClient(), dsID, versionID).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := os.ExtractParams(page)
- if err != nil {
- return false, err
- }
-
- expected := []os.Param{
- os.Param{Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer"},
- os.Param{Max: 4294967296, Min: 0, Name: "key_buffer_size", RestartRequired: false, Type: "integer"},
- os.Param{Max: 65535, Min: 2, Name: "connect_timeout", RestartRequired: false, Type: "integer"},
- os.Param{Max: 4294967296, Min: 0, Name: "join_buffer_size", RestartRequired: false, Type: "integer"},
- }
-
- th.AssertDeepEquals(t, actual, expected)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestGetDSParam(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, dsParamGetURL, "GET", "", getParamJSON, 200)
-
- param, err := GetDatastoreParam(fake.ServiceClient(), dsID, versionID, paramID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &os.Param{
- Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer",
- }
-
- th.AssertDeepEquals(t, expected, param)
-}
-
-func TestListGlobalParams(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, globalParamListURL, "GET", "", listParamsJSON, 200)
-
- pages := 0
- err := ListGlobalParams(fake.ServiceClient(), versionID).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := os.ExtractParams(page)
- if err != nil {
- return false, err
- }
-
- expected := []os.Param{
- os.Param{Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer"},
- os.Param{Max: 4294967296, Min: 0, Name: "key_buffer_size", RestartRequired: false, Type: "integer"},
- os.Param{Max: 65535, Min: 2, Name: "connect_timeout", RestartRequired: false, Type: "integer"},
- os.Param{Max: 4294967296, Min: 0, Name: "join_buffer_size", RestartRequired: false, Type: "integer"},
- }
-
- th.AssertDeepEquals(t, actual, expected)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestGetGlobalParam(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, globalParamGetURL, "GET", "", getParamJSON, 200)
-
- param, err := GetGlobalParam(fake.ServiceClient(), versionID, paramID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &os.Param{
- Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer",
- }
-
- th.AssertDeepEquals(t, expected, param)
-}
diff --git a/rackspace/db/v1/configurations/doc.go b/rackspace/db/v1/configurations/doc.go
deleted file mode 100644
index 48c51d6..0000000
--- a/rackspace/db/v1/configurations/doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package configurations
diff --git a/rackspace/db/v1/configurations/fixtures.go b/rackspace/db/v1/configurations/fixtures.go
deleted file mode 100644
index d8a2233..0000000
--- a/rackspace/db/v1/configurations/fixtures.go
+++ /dev/null
@@ -1,159 +0,0 @@
-package configurations
-
-import (
- "fmt"
- "time"
-
- os "github.com/rackspace/gophercloud/openstack/db/v1/configurations"
-)
-
-var (
- timestamp = "2015-11-12T14:22:42Z"
- timeVal, _ = time.Parse(time.RFC3339, timestamp)
-)
-
-var singleConfigJSON = `
-{
- "created": "` + timestamp + `",
- "datastore_name": "mysql",
- "datastore_version_id": "b00000b0-00b0-0b00-00b0-000b000000bb",
- "datastore_version_name": "5.6",
- "description": "example_description",
- "id": "005a8bb7-a8df-40ee-b0b7-fc144641abc2",
- "name": "example-configuration-name",
- "updated": "` + timestamp + `"
-}
-`
-
-var singleConfigWithValuesJSON = `
-{
- "created": "` + timestamp + `",
- "datastore_name": "mysql",
- "datastore_version_id": "b00000b0-00b0-0b00-00b0-000b000000bb",
- "datastore_version_name": "5.6",
- "description": "example description",
- "id": "005a8bb7-a8df-40ee-b0b7-fc144641abc2",
- "instance_count": 0,
- "name": "example-configuration-name",
- "updated": "` + timestamp + `",
- "values": {
- "collation_server": "latin1_swedish_ci",
- "connect_timeout": 120
- }
-}
-`
-
-var (
- listConfigsJSON = fmt.Sprintf(`{"configurations": [%s]}`, singleConfigJSON)
- getConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigJSON)
- createConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigWithValuesJSON)
-)
-
-var createReq = `
-{
- "configuration": {
- "datastore": {
- "type": "a00000a0-00a0-0a00-00a0-000a000000aa",
- "version": "b00000b0-00b0-0b00-00b0-000b000000bb"
- },
- "description": "example description",
- "name": "example-configuration-name",
- "values": {
- "collation_server": "latin1_swedish_ci",
- "connect_timeout": 120
- }
- }
-}
-`
-
-var updateReq = `
-{
- "configuration": {
- "values": {
- "connect_timeout": 300
- }
- }
-}
-`
-
-var listInstancesJSON = `
-{
- "instances": [
- {
- "id": "d4603f69-ec7e-4e9b-803f-600b9205576f",
- "name": "json_rack_instance"
- }
- ]
-}
-`
-
-var listParamsJSON = `
-{
- "configuration-parameters": [
- {
- "max": 1,
- "min": 0,
- "name": "innodb_file_per_table",
- "restart_required": true,
- "type": "integer"
- },
- {
- "max": 4294967296,
- "min": 0,
- "name": "key_buffer_size",
- "restart_required": false,
- "type": "integer"
- },
- {
- "max": 65535,
- "min": 2,
- "name": "connect_timeout",
- "restart_required": false,
- "type": "integer"
- },
- {
- "max": 4294967296,
- "min": 0,
- "name": "join_buffer_size",
- "restart_required": false,
- "type": "integer"
- }
- ]
-}
-`
-
-var getParamJSON = `
-{
- "max": 1,
- "min": 0,
- "name": "innodb_file_per_table",
- "restart_required": true,
- "type": "integer"
-}
-`
-
-var exampleConfig = os.Config{
- Created: timeVal,
- DatastoreName: "mysql",
- DatastoreVersionID: "b00000b0-00b0-0b00-00b0-000b000000bb",
- DatastoreVersionName: "5.6",
- Description: "example_description",
- ID: "005a8bb7-a8df-40ee-b0b7-fc144641abc2",
- Name: "example-configuration-name",
- Updated: timeVal,
-}
-
-var exampleConfigWithValues = os.Config{
- Created: timeVal,
- DatastoreName: "mysql",
- DatastoreVersionID: "b00000b0-00b0-0b00-00b0-000b000000bb",
- DatastoreVersionName: "5.6",
- Description: "example description",
- ID: "005a8bb7-a8df-40ee-b0b7-fc144641abc2",
- Name: "example-configuration-name",
- Updated: timeVal,
- Values: map[string]interface{}{
- "collation_server": "latin1_swedish_ci",
- "connect_timeout": 120,
- },
-}
diff --git a/rackspace/db/v1/databases/delegate.go b/rackspace/db/v1/databases/delegate.go
deleted file mode 100644
index 56552d1..0000000
--- a/rackspace/db/v1/databases/delegate.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package databases
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/db/v1/databases"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-func Create(client *gophercloud.ServiceClient, instanceID string, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(client, instanceID, opts)
-}
-
-func List(client *gophercloud.ServiceClient, instanceID string) pagination.Pager {
- return os.List(client, instanceID)
-}
-
-func Delete(client *gophercloud.ServiceClient, instanceID, dbName string) os.DeleteResult {
- return os.Delete(client, instanceID, dbName)
-}
diff --git a/rackspace/db/v1/databases/delegate_test.go b/rackspace/db/v1/databases/delegate_test.go
deleted file mode 100644
index b9e50a5..0000000
--- a/rackspace/db/v1/databases/delegate_test.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package databases
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/db/v1/databases"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-var (
- instanceID = "{instanceID}"
- rootURL = "/instances"
- resURL = rootURL + "/" + instanceID
- uRootURL = resURL + "/root"
- aURL = resURL + "/action"
-)
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCreate(t)
-
- opts := os.BatchCreateOpts{
- os.CreateOpts{Name: "testingdb", CharSet: "utf8", Collate: "utf8_general_ci"},
- os.CreateOpts{Name: "sampledb"},
- }
-
- res := Create(fake.ServiceClient(), instanceID, opts)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleList(t)
-
- expectedDBs := []os.Database{
- os.Database{Name: "anotherexampledb"},
- os.Database{Name: "exampledb"},
- os.Database{Name: "nextround"},
- os.Database{Name: "sampledb"},
- os.Database{Name: "testingdb"},
- }
-
- pages := 0
- err := List(fake.ServiceClient(), instanceID).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := os.ExtractDBs(page)
- if err != nil {
- return false, err
- }
-
- th.CheckDeepEquals(t, expectedDBs, actual)
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDelete(t)
-
- err := os.Delete(fake.ServiceClient(), instanceID, "{dbName}").ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/db/v1/databases/doc.go b/rackspace/db/v1/databases/doc.go
deleted file mode 100644
index 1a178b6..0000000
--- a/rackspace/db/v1/databases/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package databases provides information and interaction with the database API
-// resource in the Rackspace Database service.
-package databases
diff --git a/rackspace/db/v1/databases/urls.go b/rackspace/db/v1/databases/urls.go
deleted file mode 100644
index 18cbec7..0000000
--- a/rackspace/db/v1/databases/urls.go
+++ /dev/null
@@ -1 +0,0 @@
-package databases
diff --git a/rackspace/db/v1/datastores/delegate.go b/rackspace/db/v1/datastores/delegate.go
deleted file mode 100644
index 573496d..0000000
--- a/rackspace/db/v1/datastores/delegate.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package datastores
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/db/v1/datastores"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List will list all available flavors.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client)
-}
-
-// Get retrieves the details for a particular flavor.
-func Get(client *gophercloud.ServiceClient, flavorID string) os.GetResult {
- return os.Get(client, flavorID)
-}
-
-// ListVersions will list all of the available versions for a specified
-// datastore type.
-func ListVersions(client *gophercloud.ServiceClient, datastoreID string) pagination.Pager {
- return os.ListVersions(client, datastoreID)
-}
-
-// GetVersion will retrieve the details of a specified datastore version.
-func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) os.GetVersionResult {
- return os.GetVersion(client, datastoreID, versionID)
-}
diff --git a/rackspace/db/v1/datastores/delegate_test.go b/rackspace/db/v1/datastores/delegate_test.go
deleted file mode 100644
index 71111b9..0000000
--- a/rackspace/db/v1/datastores/delegate_test.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package datastores
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/db/v1/datastores"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
- "github.com/rackspace/gophercloud/testhelper/fixture"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, "/datastores", "GET", "", os.ListDSResp, 200)
-
- pages := 0
-
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := os.ExtractDatastores(page)
- if err != nil {
- return false, err
- }
-
- th.CheckDeepEquals(t, []os.Datastore{os.ExampleDatastore}, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, "/datastores/{dsID}", "GET", "", os.GetDSResp, 200)
-
- ds, err := Get(fake.ServiceClient(), "{dsID}").Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, &os.ExampleDatastore, ds)
-}
-
-func TestListVersions(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, "/datastores/{dsID}/versions", "GET", "", os.ListVersionsResp, 200)
-
- pages := 0
-
- err := ListVersions(fake.ServiceClient(), "{dsID}").EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := os.ExtractVersions(page)
- if err != nil {
- return false, err
- }
-
- th.CheckDeepEquals(t, os.ExampleVersions, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestGetVersion(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, "/datastores/{dsID}/versions/{versionID}", "GET", "", os.GetVersionResp, 200)
-
- ds, err := GetVersion(fake.ServiceClient(), "{dsID}", "{versionID}").Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, &os.ExampleVersion1, ds)
-}
diff --git a/rackspace/db/v1/datastores/doc.go b/rackspace/db/v1/datastores/doc.go
deleted file mode 100644
index f36997a..0000000
--- a/rackspace/db/v1/datastores/doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package datastores
diff --git a/rackspace/db/v1/flavors/delegate.go b/rackspace/db/v1/flavors/delegate.go
deleted file mode 100644
index 689b81e..0000000
--- a/rackspace/db/v1/flavors/delegate.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package flavors
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List will list all available flavors.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client)
-}
-
-// Get retrieves the details for a particular flavor.
-func Get(client *gophercloud.ServiceClient, flavorID string) os.GetResult {
- return os.Get(client, flavorID)
-}
diff --git a/rackspace/db/v1/flavors/delegate_test.go b/rackspace/db/v1/flavors/delegate_test.go
deleted file mode 100644
index f5f6442..0000000
--- a/rackspace/db/v1/flavors/delegate_test.go
+++ /dev/null
@@ -1,95 +0,0 @@
-package flavors
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListFlavors(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleList(t)
-
- pages := 0
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := os.ExtractFlavors(page)
- if err != nil {
- return false, err
- }
-
- expected := []os.Flavor{
- os.Flavor{
- ID: "1",
- Name: "m1.tiny",
- RAM: 512,
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/1", Rel: "self"},
- gophercloud.Link{Href: "https://openstack.example.com/flavors/1", Rel: "bookmark"},
- },
- },
- os.Flavor{
- ID: "2",
- Name: "m1.small",
- RAM: 1024,
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/2", Rel: "self"},
- gophercloud.Link{Href: "https://openstack.example.com/flavors/2", Rel: "bookmark"},
- },
- },
- os.Flavor{
- ID: "3",
- Name: "m1.medium",
- RAM: 2048,
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/3", Rel: "self"},
- gophercloud.Link{Href: "https://openstack.example.com/flavors/3", Rel: "bookmark"},
- },
- },
- os.Flavor{
- ID: "4",
- Name: "m1.large",
- RAM: 4096,
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/4", Rel: "self"},
- gophercloud.Link{Href: "https://openstack.example.com/flavors/4", Rel: "bookmark"},
- },
- },
- }
-
- th.AssertDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- if pages != 1 {
- t.Errorf("Expected one page, got %d", pages)
- }
-}
-
-func TestGetFlavor(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGet(t)
-
- actual, err := Get(fake.ServiceClient(), "{flavorID}").Extract()
- th.AssertNoErr(t, err)
-
- expected := &os.Flavor{
- ID: "1",
- Name: "m1.tiny",
- RAM: 512,
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://openstack.example.com/v1.0/1234/flavors/1", Rel: "self"},
- },
- }
-
- th.AssertDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/db/v1/flavors/doc.go b/rackspace/db/v1/flavors/doc.go
deleted file mode 100644
index 922a4e6..0000000
--- a/rackspace/db/v1/flavors/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package flavors provides information and interaction with the flavor API
-// resource in the Rackspace Database service.
-package flavors
diff --git a/rackspace/db/v1/instances/delegate.go b/rackspace/db/v1/instances/delegate.go
deleted file mode 100644
index f2656fe..0000000
--- a/rackspace/db/v1/instances/delegate.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package instances
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
-)
-
-// Get retrieves the status and information for a specified database instance.
-func Get(client *gophercloud.ServiceClient, id string) GetResult {
- return GetResult{os.Get(client, id)}
-}
-
-// Delete permanently destroys the database instance.
-func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult {
- return os.Delete(client, id)
-}
-
-// EnableRootUser enables the login from any host for the root user and
-// provides the user with a generated root password.
-func EnableRootUser(client *gophercloud.ServiceClient, id string) os.UserRootResult {
- return os.EnableRootUser(client, id)
-}
-
-// IsRootEnabled checks an instance to see if root access is enabled. It returns
-// True if root user is enabled for the specified database instance or False
-// otherwise.
-func IsRootEnabled(client *gophercloud.ServiceClient, id string) (bool, error) {
- return os.IsRootEnabled(client, id)
-}
-
-// Restart will restart only the MySQL Instance. Restarting MySQL will
-// erase any dynamic configuration settings that you have made within MySQL.
-// The MySQL service will be unavailable until the instance restarts.
-func Restart(client *gophercloud.ServiceClient, id string) os.ActionResult {
- return os.Restart(client, id)
-}
-
-// Resize changes the memory size of the instance, assuming a valid
-// flavorRef is provided. It will also restart the MySQL service.
-func Resize(client *gophercloud.ServiceClient, id, flavorRef string) os.ActionResult {
- return os.Resize(client, id, flavorRef)
-}
-
-// ResizeVolume will resize the attached volume for an instance. It supports
-// only increasing the volume size and does not support decreasing the size.
-// The volume size is in gigabytes (GB) and must be an integer.
-func ResizeVolume(client *gophercloud.ServiceClient, id string, size int) os.ActionResult {
- return os.ResizeVolume(client, id, size)
-}
diff --git a/rackspace/db/v1/instances/delegate_test.go b/rackspace/db/v1/instances/delegate_test.go
deleted file mode 100644
index 716e0a4..0000000
--- a/rackspace/db/v1/instances/delegate_test.go
+++ /dev/null
@@ -1,107 +0,0 @@
-package instances
-
-import (
- "testing"
-
- osDBs "github.com/rackspace/gophercloud/openstack/db/v1/databases"
- os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
- osUsers "github.com/rackspace/gophercloud/openstack/db/v1/users"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
- "github.com/rackspace/gophercloud/testhelper/fixture"
-)
-
-var (
- _rootURL = "/instances"
- resURL = "/instances/" + instanceID
-)
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _rootURL, "POST", createReq, createResp, 200)
-
- opts := CreateOpts{
- Name: "json_rack_instance",
- FlavorRef: "1",
- Databases: osDBs.BatchCreateOpts{
- osDBs.CreateOpts{CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"},
- osDBs.CreateOpts{Name: "nextround"},
- },
- Users: osUsers.BatchCreateOpts{
- osUsers.CreateOpts{
- Name: "demouser",
- Password: "demopassword",
- Databases: osDBs.BatchCreateOpts{
- osDBs.CreateOpts{Name: "sampledb"},
- },
- },
- },
- Size: 2,
- RestorePoint: "1234567890",
- }
-
- instance, err := Create(fake.ServiceClient(), opts).Extract()
-
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expectedInstance, instance)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "GET", "", getResp, 200)
-
- instance, err := Get(fake.ServiceClient(), instanceID).Extract()
-
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expectedInstance, instance)
-}
-
-func TestDeleteInstance(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDelete(t)
-
- res := Delete(fake.ServiceClient(), instanceID)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestEnableRootUser(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleEnableRoot(t)
-
- expected := &osUsers.User{Name: "root", Password: "secretsecret"}
-
- user, err := EnableRootUser(fake.ServiceClient(), instanceID).Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, user)
-}
-
-func TestRestart(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleRestart(t)
-
- res := Restart(fake.ServiceClient(), instanceID)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestResize(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleResize(t)
-
- res := Resize(fake.ServiceClient(), instanceID, "2")
- th.AssertNoErr(t, res.Err)
-}
-
-func TestResizeVolume(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleResizeVol(t)
-
- res := ResizeVolume(fake.ServiceClient(), instanceID, 4)
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/db/v1/instances/doc.go b/rackspace/db/v1/instances/doc.go
deleted file mode 100644
index 0c8ad63..0000000
--- a/rackspace/db/v1/instances/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package instances provides information and interaction with the instance API
-// resource in the Rackspace Database service.
-package instances
diff --git a/rackspace/db/v1/instances/fixtures.go b/rackspace/db/v1/instances/fixtures.go
deleted file mode 100644
index c5ff37a..0000000
--- a/rackspace/db/v1/instances/fixtures.go
+++ /dev/null
@@ -1,340 +0,0 @@
-package instances
-
-import (
- "fmt"
- "time"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/openstack/db/v1/datastores"
- "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
- os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
-)
-
-var (
- timestamp = "2015-11-12T14:22:42Z"
- timeVal, _ = time.Parse(time.RFC3339, timestamp)
-)
-
-var instance = `
-{
- "created": "` + timestamp + `",
- "datastore": {
- "type": "mysql",
- "version": "5.6"
- },
- "flavor": {
- "id": "1",
- "links": [
- {
- "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1",
- "rel": "self"
- },
- {
- "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1",
- "rel": "bookmark"
- }
- ]
- },
- "links": [
- {
- "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1",
- "rel": "self"
- }
- ],
- "hostname": "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com",
- "id": "{instanceID}",
- "name": "json_rack_instance",
- "status": "BUILD",
- "updated": "` + timestamp + `",
- "volume": {
- "size": 2
- }
-}
-`
-
-var createReq = `
-{
- "instance": {
- "databases": [
- {
- "character_set": "utf8",
- "collate": "utf8_general_ci",
- "name": "sampledb"
- },
- {
- "name": "nextround"
- }
- ],
- "flavorRef": "1",
- "name": "json_rack_instance",
- "users": [
- {
- "databases": [
- {
- "name": "sampledb"
- }
- ],
- "name": "demouser",
- "password": "demopassword"
- }
- ],
- "volume": {
- "size": 2
- },
- "restorePoint": {
- "backupRef": "1234567890"
- }
- }
-}
-`
-
-var createReplicaReq = `
-{
- "instance": {
- "volume": {
- "size": 1
- },
- "flavorRef": "9",
- "name": "t2s1_ALT_GUEST",
- "replica_of": "6bdca2fc-418e-40bd-a595-62abda61862d"
- }
-}
-`
-
-var createReplicaResp = `
-{
- "instance": {
- "status": "BUILD",
- "updated": "` + timestamp + `",
- "name": "t2s1_ALT_GUEST",
- "links": [
- {
- "href": "https://ord.databases.api.rackspacecloud.com/v1.0/5919009/instances/8367c312-7c40-4a66-aab1-5767478914fc",
- "rel": "self"
- },
- {
- "href": "https://ord.databases.api.rackspacecloud.com/instances/8367c312-7c40-4a66-aab1-5767478914fc",
- "rel": "bookmark"
- }
- ],
- "created": "` + timestamp + `",
- "id": "8367c312-7c40-4a66-aab1-5767478914fc",
- "volume": {
- "size": 1
- },
- "flavor": {
- "id": "9"
- },
- "datastore": {
- "version": "5.6",
- "type": "mysql"
- },
- "replica_of": {
- "id": "6bdca2fc-418e-40bd-a595-62abda61862d"
- }
- }
-}
-`
-
-var listReplicasResp = `
-{
- "instances": [
- {
- "status": "ACTIVE",
- "name": "t1s1_ALT_GUEST",
- "links": [
- {
- "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/instances/3c691f06-bf9a-4618-b7ec-2817ce0cf254",
- "rel": "self"
- },
- {
- "href": "https://ord.databases.api.rackspacecloud.com/instances/3c691f06-bf9a-4618-b7ec-2817ce0cf254",
- "rel": "bookmark"
- }
- ],
- "ip": [
- "10.0.0.3"
- ],
- "id": "3c691f06-bf9a-4618-b7ec-2817ce0cf254",
- "volume": {
- "size": 1
- },
- "flavor": {
- "id": "9"
- },
- "datastore": {
- "version": "5.6",
- "type": "mysql"
- },
- "replica_of": {
- "id": "8b499b45-52d6-402d-b398-f9d8f279c69a"
- }
- }
- ]
-}
-`
-
-var getReplicaResp = `
-{
- "instance": {
- "status": "ACTIVE",
- "updated": "` + timestamp + `",
- "name": "t1_ALT_GUEST",
- "created": "` + timestamp + `",
- "ip": [
- "10.0.0.2"
- ],
- "replicas": [
- {
- "id": "3c691f06-bf9a-4618-b7ec-2817ce0cf254"
- }
- ],
- "id": "8b499b45-52d6-402d-b398-f9d8f279c69a",
- "volume": {
- "used": 0.54,
- "size": 1
- },
- "flavor": {
- "id": "9"
- },
- "datastore": {
- "version": "5.6",
- "type": "mysql"
- }
- }
-}
-`
-
-var detachReq = `
-{
- "instance": {
- "replica_of": "",
- "slave_of": ""
- }
-}
-`
-
-var getConfigResp = `
-{
- "instance": {
- "configuration": {
- "basedir": "/usr",
- "connect_timeout": "15",
- "datadir": "/var/lib/mysql",
- "default_storage_engine": "innodb",
- "innodb_buffer_pool_instances": "1",
- "innodb_buffer_pool_size": "175M",
- "innodb_checksum_algorithm": "crc32",
- "innodb_data_file_path": "ibdata1:10M:autoextend",
- "innodb_file_per_table": "1",
- "innodb_io_capacity": "200",
- "innodb_log_file_size": "256M",
- "innodb_log_files_in_group": "2",
- "innodb_open_files": "8192",
- "innodb_thread_concurrency": "0",
- "join_buffer_size": "1M",
- "key_buffer_size": "50M",
- "local-infile": "0",
- "log-error": "/var/log/mysql/mysqld.log",
- "max_allowed_packet": "16M",
- "max_connect_errors": "10000",
- "max_connections": "40",
- "max_heap_table_size": "16M",
- "myisam-recover": "BACKUP",
- "open_files_limit": "8192",
- "performance_schema": "off",
- "pid_file": "/var/run/mysqld/mysqld.pid",
- "port": "3306",
- "query_cache_limit": "1M",
- "query_cache_size": "8M",
- "query_cache_type": "1",
- "read_buffer_size": "256K",
- "read_rnd_buffer_size": "1M",
- "server_id": "1",
- "skip-external-locking": "1",
- "skip_name_resolve": "1",
- "sort_buffer_size": "256K",
- "table_open_cache": "4096",
- "thread_stack": "192K",
- "tmp_table_size": "16M",
- "tmpdir": "/var/tmp",
- "user": "mysql",
- "wait_timeout": "3600"
- }
- }
-}
-`
-
-var associateReq = `{"instance": {"configuration": "{configGroupID}"}}`
-
-var listBackupsResp = `
-{
- "backups": [
- {
- "status": "COMPLETED",
- "updated": "` + timestamp + `",
- "description": "Backup from Restored Instance",
- "datastore": {
- "version": "5.1",
- "type": "MySQL",
- "version_id": "20000000-0000-0000-0000-000000000002"
- },
- "id": "87972694-4be2-40f5-83f8-501656e0032a",
- "size": 0.141026,
- "name": "restored_backup",
- "created": "` + timestamp + `",
- "instance_id": "29af2cd9-0674-48ab-b87a-b160f00208e6",
- "parent_id": null,
- "locationRef": "http://localhost/path/to/backup"
- }
- ]
-}
-`
-
-var (
- createResp = fmt.Sprintf(`{"instance":%s}`, instance)
- getResp = fmt.Sprintf(`{"instance":%s}`, instance)
- associateResp = fmt.Sprintf(`{"instance":%s}`, instance)
- listInstancesResp = fmt.Sprintf(`{"instances":[%s]}`, instance)
-)
-
-var instanceID = "{instanceID}"
-
-var expectedInstance = &Instance{
- Created: timeVal,
- Updated: timeVal,
- Datastore: datastores.DatastorePartial{Type: "mysql", Version: "5.6"},
- Flavor: flavors.Flavor{
- ID: "1",
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "self"},
- gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "bookmark"},
- },
- },
- Hostname: "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com",
- ID: instanceID,
- Links: []gophercloud.Link{
- gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "self"},
- },
- Name: "json_rack_instance",
- Status: "BUILD",
- Volume: os.Volume{Size: 2},
-}
-
-var expectedReplica = &Instance{
- Status: "BUILD",
- Updated: timeVal,
- Name: "t2s1_ALT_GUEST",
- Links: []gophercloud.Link{
- gophercloud.Link{Rel: "self", Href: "https://ord.databases.api.rackspacecloud.com/v1.0/5919009/instances/8367c312-7c40-4a66-aab1-5767478914fc"},
- gophercloud.Link{Rel: "bookmark", Href: "https://ord.databases.api.rackspacecloud.com/instances/8367c312-7c40-4a66-aab1-5767478914fc"},
- },
- Created: timeVal,
- ID: "8367c312-7c40-4a66-aab1-5767478914fc",
- Volume: os.Volume{Size: 1},
- Flavor: flavors.Flavor{ID: "9"},
- Datastore: datastores.DatastorePartial{Version: "5.6", Type: "mysql"},
- ReplicaOf: &Instance{
- ID: "6bdca2fc-418e-40bd-a595-62abda61862d",
- },
-}
diff --git a/rackspace/db/v1/instances/requests.go b/rackspace/db/v1/instances/requests.go
deleted file mode 100644
index f4df692..0000000
--- a/rackspace/db/v1/instances/requests.go
+++ /dev/null
@@ -1,199 +0,0 @@
-package instances
-
-import (
- "github.com/rackspace/gophercloud"
- osDBs "github.com/rackspace/gophercloud/openstack/db/v1/databases"
- os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
- osUsers "github.com/rackspace/gophercloud/openstack/db/v1/users"
- "github.com/rackspace/gophercloud/pagination"
- "github.com/rackspace/gophercloud/rackspace/db/v1/backups"
-)
-
-// CreateOpts is the struct responsible for configuring a new database instance.
-type CreateOpts struct {
- // Either the integer UUID (in string form) of the flavor, or its URI
- // reference as specified in the response from the List() call. Required.
- FlavorRef string
-
- // Specifies the volume size in gigabytes (GB). The value must be between 1
- // and 300. Required.
- Size int
-
- // Name of the instance to create. The length of the name is limited to
- // 255 characters and any characters are permitted. Optional.
- Name string
-
- // A slice of database information options.
- Databases osDBs.CreateOptsBuilder
-
- // A slice of user information options.
- Users osUsers.CreateOptsBuilder
-
- // ID of the configuration group to associate with the instance. Optional.
- ConfigID string
-
- // Options to configure the type of datastore the instance will use. This is
- // optional, and if excluded will default to MySQL.
- Datastore *os.DatastoreOpts
-
- // Specifies the backup ID from which to restore the database instance. There
- // are some things to be aware of before using this field. When you execute
- // the Restore Backup operation, a new database instance is created to store
- // the backup whose ID is specified by the restorePoint attribute. This will
- // mean that:
- // - All users, passwords and access that were on the instance at the time of
- // the backup will be restored along with the databases.
- // - You can create new users or databases if you want, but they cannot be
- // the same as the ones from the instance that was backed up.
- RestorePoint string
-
- ReplicaOf string
-}
-
-func (opts CreateOpts) ToInstanceCreateMap() (map[string]interface{}, error) {
- instance, err := os.CreateOpts{
- FlavorRef: opts.FlavorRef,
- Size: opts.Size,
- Name: opts.Name,
- Databases: opts.Databases,
- Users: opts.Users,
- }.ToInstanceCreateMap()
-
- if err != nil {
- return nil, err
- }
-
- instance = instance["instance"].(map[string]interface{})
-
- if opts.ConfigID != "" {
- instance["configuration"] = opts.ConfigID
- }
-
- if opts.Datastore != nil {
- ds, err := opts.Datastore.ToMap()
- if err != nil {
- return nil, err
- }
- instance["datastore"] = ds
- }
-
- if opts.RestorePoint != "" {
- instance["restorePoint"] = map[string]string{"backupRef": opts.RestorePoint}
- }
-
- if opts.ReplicaOf != "" {
- instance["replica_of"] = opts.ReplicaOf
- }
-
- return map[string]interface{}{"instance": instance}, nil
-}
-
-// Create asynchronously provisions a new database instance. It requires the
-// user to specify a flavor and a volume size. The API service then provisions
-// the instance with the requested flavor and sets up a volume of the specified
-// size, which is the storage for the database instance.
-//
-// Although this call only allows the creation of 1 instance per request, you
-// can create an instance with multiple databases and users. The default
-// binding for a MySQL instance is port 3306.
-func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) CreateResult {
- return CreateResult{os.Create(client, opts)}
-}
-
-// ListOpts specifies all of the query options to be used when returning a list
-// of database instances.
-type ListOpts struct {
- // IncludeHA includes or excludes High Availability instances from the result set
- IncludeHA bool `q:"include_ha"`
-
- // IncludeReplicas includes or excludes Replica instances from the result set
- IncludeReplicas bool `q:"include_replicas"`
-}
-
-// ToInstanceListQuery formats a ListOpts into a query string.
-func (opts ListOpts) ToInstanceListQuery() (string, error) {
- q, err := gophercloud.BuildQueryString(opts)
- if err != nil {
- return "", err
- }
- return q.String(), nil
-}
-
-// List retrieves the status and information for all database instances.
-func List(client *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager {
- url := baseURL(client)
-
- if opts != nil {
- query, err := opts.ToInstanceListQuery()
- if err != nil {
- return pagination.Pager{Err: err}
- }
- url += query
- }
-
- createPageFn := func(r pagination.PageResult) pagination.Page {
- return os.InstancePage{pagination.LinkedPageBase{PageResult: r}}
- }
-
- return pagination.NewPager(client, url, createPageFn)
-}
-
-// GetDefaultConfig lists the default configuration settings from the template
-// that was applied to the specified instance. In a sense, this is the vanilla
-// configuration setting applied to an instance. Further configuration can be
-// applied by associating an instance with a configuration group.
-func GetDefaultConfig(client *gophercloud.ServiceClient, id string) ConfigResult {
- var res ConfigResult
-
- _, res.Err = client.Request("GET", configURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
- return res
-}
-
-// AssociateWithConfigGroup associates a specified instance to a specified
-// configuration group. If any of the parameters within a configuration group
-// require a restart, then the instance will transition into a restart.
-func AssociateWithConfigGroup(client *gophercloud.ServiceClient, instanceID, configGroupID string) UpdateResult {
- reqBody := map[string]string{
- "configuration": configGroupID,
- }
-
- var res UpdateResult
-
- _, res.Err = client.Request("PUT", resourceURL(client, instanceID), gophercloud.RequestOpts{
- JSONBody: map[string]map[string]string{"instance": reqBody},
- OkCodes: []int{202},
- })
-
- return res
-}
-
-// DetachFromConfigGroup will detach an instance from all config groups.
-func DetachFromConfigGroup(client *gophercloud.ServiceClient, instanceID string) UpdateResult {
- return AssociateWithConfigGroup(client, instanceID, "")
-}
-
-// ListBackups will list all the backups for a specified database instance.
-func ListBackups(client *gophercloud.ServiceClient, instanceID string) pagination.Pager {
- pageFn := func(r pagination.PageResult) pagination.Page {
- return backups.BackupPage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(client, backupsURL(client, instanceID), pageFn)
-}
-
-// DetachReplica will detach a specified replica instance from its source
-// instance, effectively allowing it to operate independently. Detaching a
-// replica will restart the MySQL service on the instance.
-func DetachReplica(client *gophercloud.ServiceClient, replicaID string) DetachResult {
- var res DetachResult
-
- _, res.Err = client.Request("PATCH", resourceURL(client, replicaID), gophercloud.RequestOpts{
- JSONBody: map[string]interface{}{"instance": map[string]string{"replica_of": "", "slave_of": ""}},
- OkCodes: []int{202},
- })
-
- return res
-}
diff --git a/rackspace/db/v1/instances/requests_test.go b/rackspace/db/v1/instances/requests_test.go
deleted file mode 100644
index 7fa4601..0000000
--- a/rackspace/db/v1/instances/requests_test.go
+++ /dev/null
@@ -1,246 +0,0 @@
-package instances
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/openstack/db/v1/datastores"
- "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
- os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
- "github.com/rackspace/gophercloud/pagination"
- "github.com/rackspace/gophercloud/rackspace/db/v1/backups"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
- "github.com/rackspace/gophercloud/testhelper/fixture"
-)
-
-func TestInstanceList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- fixture.SetupHandler(t, "/instances", "GET", "", listInstancesResp, 200)
-
- opts := &ListOpts{
- IncludeHA: false,
- IncludeReplicas: false,
- }
-
- pages := 0
- err := List(fake.ServiceClient(), opts).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := ExtractInstances(page)
- if err != nil {
- return false, err
- }
-
- th.CheckDeepEquals(t, []Instance{*expectedInstance}, actual)
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestGetConfig(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL+"/configuration", "GET", "", getConfigResp, 200)
-
- config, err := GetDefaultConfig(fake.ServiceClient(), instanceID).Extract()
-
- expected := map[string]string{
- "basedir": "/usr",
- "connect_timeout": "15",
- "datadir": "/var/lib/mysql",
- "default_storage_engine": "innodb",
- "innodb_buffer_pool_instances": "1",
- "innodb_buffer_pool_size": "175M",
- "innodb_checksum_algorithm": "crc32",
- "innodb_data_file_path": "ibdata1:10M:autoextend",
- "innodb_file_per_table": "1",
- "innodb_io_capacity": "200",
- "innodb_log_file_size": "256M",
- "innodb_log_files_in_group": "2",
- "innodb_open_files": "8192",
- "innodb_thread_concurrency": "0",
- "join_buffer_size": "1M",
- "key_buffer_size": "50M",
- "local-infile": "0",
- "log-error": "/var/log/mysql/mysqld.log",
- "max_allowed_packet": "16M",
- "max_connect_errors": "10000",
- "max_connections": "40",
- "max_heap_table_size": "16M",
- "myisam-recover": "BACKUP",
- "open_files_limit": "8192",
- "performance_schema": "off",
- "pid_file": "/var/run/mysqld/mysqld.pid",
- "port": "3306",
- "query_cache_limit": "1M",
- "query_cache_size": "8M",
- "query_cache_type": "1",
- "read_buffer_size": "256K",
- "read_rnd_buffer_size": "1M",
- "server_id": "1",
- "skip-external-locking": "1",
- "skip_name_resolve": "1",
- "sort_buffer_size": "256K",
- "table_open_cache": "4096",
- "thread_stack": "192K",
- "tmp_table_size": "16M",
- "tmpdir": "/var/tmp",
- "user": "mysql",
- "wait_timeout": "3600",
- }
-
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, config)
-}
-
-func TestAssociateWithConfigGroup(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "PUT", associateReq, associateResp, 202)
-
- res := AssociateWithConfigGroup(fake.ServiceClient(), instanceID, "{configGroupID}")
- th.AssertNoErr(t, res.Err)
-}
-
-func TestListBackups(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL+"/backups", "GET", "", listBackupsResp, 200)
-
- pages := 0
-
- err := ListBackups(fake.ServiceClient(), instanceID).EachPage(func(page pagination.Page) (bool, error) {
- pages++
- actual, err := backups.ExtractBackups(page)
- th.AssertNoErr(t, err)
-
- expected := []backups.Backup{
- backups.Backup{
- Created: timeVal,
- Description: "Backup from Restored Instance",
- ID: "87972694-4be2-40f5-83f8-501656e0032a",
- InstanceID: "29af2cd9-0674-48ab-b87a-b160f00208e6",
- LocationRef: "http://localhost/path/to/backup",
- Name: "restored_backup",
- ParentID: "",
- Size: 0.141026,
- Status: "COMPLETED",
- Updated: timeVal,
- Datastore: datastores.DatastorePartial{Version: "5.1", Type: "MySQL", VersionID: "20000000-0000-0000-0000-000000000002"},
- },
- }
-
- th.AssertDeepEquals(t, expected, actual)
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestCreateReplica(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _rootURL, "POST", createReplicaReq, createReplicaResp, 200)
-
- opts := CreateOpts{
- Name: "t2s1_ALT_GUEST",
- FlavorRef: "9",
- Size: 1,
- ReplicaOf: "6bdca2fc-418e-40bd-a595-62abda61862d",
- }
-
- replica, err := Create(fake.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expectedReplica, replica)
-}
-
-func TestListReplicas(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _rootURL, "GET", "", listReplicasResp, 200)
-
- pages := 0
- err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := ExtractInstances(page)
- if err != nil {
- return false, err
- }
-
- expected := []Instance{
- Instance{
- Status: "ACTIVE",
- Name: "t1s1_ALT_GUEST",
- Links: []gophercloud.Link{
- gophercloud.Link{Rel: "self", Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/instances/3c691f06-bf9a-4618-b7ec-2817ce0cf254"},
- gophercloud.Link{Rel: "bookmark", Href: "https://ord.databases.api.rackspacecloud.com/instances/3c691f06-bf9a-4618-b7ec-2817ce0cf254"},
- },
- ID: "3c691f06-bf9a-4618-b7ec-2817ce0cf254",
- IP: []string{"10.0.0.3"},
- Volume: os.Volume{Size: 1},
- Flavor: flavors.Flavor{ID: "9"},
- Datastore: datastores.DatastorePartial{Version: "5.6", Type: "mysql"},
- ReplicaOf: &Instance{
- ID: "8b499b45-52d6-402d-b398-f9d8f279c69a",
- },
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestGetReplica(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "GET", "", getReplicaResp, 200)
-
- replica, err := Get(fake.ServiceClient(), instanceID).Extract()
- th.AssertNoErr(t, err)
-
- expectedReplica := &Instance{
- Status: "ACTIVE",
- Updated: timeVal,
- Name: "t1_ALT_GUEST",
- Created: timeVal,
- IP: []string{
- "10.0.0.2",
- },
- Replicas: []Instance{
- Instance{ID: "3c691f06-bf9a-4618-b7ec-2817ce0cf254"},
- },
- ID: "8b499b45-52d6-402d-b398-f9d8f279c69a",
- Volume: os.Volume{
- Used: 0.54,
- Size: 1,
- },
- Flavor: flavors.Flavor{ID: "9"},
- Datastore: datastores.DatastorePartial{
- Version: "5.6",
- Type: "mysql",
- },
- }
-
- th.AssertDeepEquals(t, replica, expectedReplica)
-}
-
-func TestDetachReplica(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, resURL, "PATCH", detachReq, "", 202)
-
- err := DetachReplica(fake.ServiceClient(), instanceID).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/db/v1/instances/results.go b/rackspace/db/v1/instances/results.go
deleted file mode 100644
index cdcc9c7..0000000
--- a/rackspace/db/v1/instances/results.go
+++ /dev/null
@@ -1,191 +0,0 @@
-package instances
-
-import (
- "fmt"
- "reflect"
- "time"
-
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/openstack/db/v1/datastores"
- "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
- os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// Instance represents a remote MySQL instance.
-type Instance struct {
- // Indicates the datetime that the instance was created
- Created time.Time `mapstructure:"-"`
-
- // Indicates the most recent datetime that the instance was updated.
- Updated time.Time `mapstructure:"-"`
-
- // Indicates how the instance stores data.
- Datastore datastores.DatastorePartial
-
- // Indicates the hardware flavor the instance uses.
- Flavor flavors.Flavor
-
- // A DNS-resolvable hostname associated with the database instance (rather
- // than an IPv4 address). Since the hostname always resolves to the correct
- // IP address of the database instance, this relieves the user from the task
- // of maintaining the mapping. Note that although the IP address may likely
- // change on resizing, migrating, and so forth, the hostname always resolves
- // to the correct database instance.
- Hostname string
-
- // Indicates the unique identifier for the instance resource.
- ID string
-
- // Exposes various links that reference the instance resource.
- Links []gophercloud.Link
-
- // The human-readable name of the instance.
- Name string
-
- // The build status of the instance.
- Status string
-
- // Information about the attached volume of the instance.
- Volume os.Volume
-
- // IP indicates the various IP addresses which allow access.
- IP []string
-
- // Indicates whether this instance is a replica of another source instance.
- ReplicaOf *Instance `mapstructure:"replica_of" json:"replica_of"`
-
- // Indicates whether this instance is the source of other replica instances.
- Replicas []Instance
-}
-
-func commonExtract(err error, body interface{}) (*Instance, error) {
- if err != nil {
- return nil, err
- }
-
- var response struct {
- Instance Instance `mapstructure:"instance"`
- }
-
- err = mapstructure.Decode(body, &response)
-
- val := body.(map[string]interface{})["instance"].(map[string]interface{})
-
- if t, ok := val["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &response.Instance, err
- }
- response.Instance.Created = creationTime
- }
-
- if t, ok := val["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &response.Instance, err
- }
- response.Instance.Updated = updatedTime
- }
-
- return &response.Instance, err
-}
-
-// CreateResult represents the result of a Create operation.
-type CreateResult struct {
- os.CreateResult
-}
-
-// Extract will retrieve an instance from a create result.
-func (r CreateResult) Extract() (*Instance, error) {
- return commonExtract(r.Err, r.Body)
-}
-
-// GetResult represents the result of a Get operation.
-type GetResult struct {
- os.GetResult
-}
-
-// Extract will extract an Instance from a GetResult.
-func (r GetResult) Extract() (*Instance, error) {
- return commonExtract(r.Err, r.Body)
-}
-
-// ConfigResult represents the result of getting default configuration for an
-// instance.
-type ConfigResult struct {
- gophercloud.Result
-}
-
-// DetachResult represents the result of detaching a replica from its source.
-type DetachResult struct {
- gophercloud.ErrResult
-}
-
-// Extract will extract the configuration information (in the form of a map)
-// about a particular instance.
-func (r ConfigResult) Extract() (map[string]string, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- Instance struct {
- Config map[string]string `mapstructure:"configuration"`
- } `mapstructure:"instance"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
- return response.Instance.Config, err
-}
-
-// UpdateResult represents the result of an Update operation.
-type UpdateResult struct {
- gophercloud.ErrResult
-}
-
-// ExtractInstances retrieves a slice of instances from a paginated collection.
-func ExtractInstances(page pagination.Page) ([]Instance, error) {
- casted := page.(os.InstancePage).Body
-
- var resp struct {
- Instances []Instance `mapstructure:"instances"`
- }
-
- if err := mapstructure.Decode(casted, &resp); err != nil {
- return nil, err
- }
-
- var vals []interface{}
- switch casted.(type) {
- case map[string]interface{}:
- vals = casted.(map[string]interface{})["instances"].([]interface{})
- case map[string][]interface{}:
- vals = casted.(map[string][]interface{})["instances"]
- default:
- return resp.Instances, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
- }
-
- for i, v := range vals {
- val := v.(map[string]interface{})
-
- if t, ok := val["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return resp.Instances, err
- }
- resp.Instances[i].Created = creationTime
- }
-
- if t, ok := val["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return resp.Instances, err
- }
- resp.Instances[i].Updated = updatedTime
- }
- }
-
- return resp.Instances, nil
-}
diff --git a/rackspace/db/v1/instances/urls.go b/rackspace/db/v1/instances/urls.go
deleted file mode 100644
index 5955f4c..0000000
--- a/rackspace/db/v1/instances/urls.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package instances
-
-import "github.com/rackspace/gophercloud"
-
-func baseURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL("instances")
-}
-
-func createURL(c *gophercloud.ServiceClient) string {
- return baseURL(c)
-}
-
-func resourceURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL("instances", id)
-}
-
-func configURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL("instances", id, "configuration")
-}
-
-func backupsURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL("instances", id, "backups")
-}
diff --git a/rackspace/db/v1/users/delegate.go b/rackspace/db/v1/users/delegate.go
deleted file mode 100644
index 8298c46..0000000
--- a/rackspace/db/v1/users/delegate.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package users
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/db/v1/users"
-)
-
-// Create will create a new database user for the specified database instance.
-func Create(client *gophercloud.ServiceClient, instanceID string, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(client, instanceID, opts)
-}
-
-// Delete will permanently remove a user from a specified database instance.
-func Delete(client *gophercloud.ServiceClient, instanceID, userName string) os.DeleteResult {
- return os.Delete(client, instanceID, userName)
-}
diff --git a/rackspace/db/v1/users/delegate_test.go b/rackspace/db/v1/users/delegate_test.go
deleted file mode 100644
index 7a1b773..0000000
--- a/rackspace/db/v1/users/delegate_test.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package users
-
-import (
- "testing"
-
- db "github.com/rackspace/gophercloud/openstack/db/v1/databases"
- os "github.com/rackspace/gophercloud/openstack/db/v1/users"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const instanceID = "{instanceID}"
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCreate(t)
-
- opts := os.BatchCreateOpts{
- os.CreateOpts{
- Databases: db.BatchCreateOpts{
- db.CreateOpts{Name: "databaseA"},
- },
- Name: "dbuser3",
- Password: "secretsecret",
- },
- os.CreateOpts{
- Databases: db.BatchCreateOpts{
- db.CreateOpts{Name: "databaseB"},
- db.CreateOpts{Name: "databaseC"},
- },
- Name: "dbuser4",
- Password: "secretsecret",
- },
- }
-
- res := Create(fake.ServiceClient(), instanceID, opts)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDelete(t)
-
- res := Delete(fake.ServiceClient(), instanceID, "{userName}")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/db/v1/users/doc.go b/rackspace/db/v1/users/doc.go
deleted file mode 100644
index 84f2eb3..0000000
--- a/rackspace/db/v1/users/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package users provides information and interaction with the user API
-// resource in the Rackspace Database service.
-package users
diff --git a/rackspace/db/v1/users/fixtures.go b/rackspace/db/v1/users/fixtures.go
deleted file mode 100644
index 5314e85..0000000
--- a/rackspace/db/v1/users/fixtures.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package users
-
-const singleDB = `{"databases": [{"name": "databaseE"}]}`
-
-var changePwdReq = `
-{
- "users": [
- {
- "name": "dbuser1",
- "password": "newpassword"
- },
- {
- "name": "dbuser2",
- "password": "anotherpassword"
- }
- ]
-}
-`
-
-var updateReq = `
-{
- "user": {
- "name": "new_username",
- "password": "new_password"
- }
-}
-`
-
-var getResp = `
-{
- "user": {
- "name": "exampleuser",
- "host": "foo",
- "databases": [
- {
- "name": "databaseA"
- },
- {
- "name": "databaseB"
- }
- ]
- }
-}
-`
-
-var listResp = `
-{
-"users": [
- {
- "name": "dbuser1",
- "host": "localhost",
- "databases": [
- {
- "name": "databaseA"
- }
- ]
- },
- {
- "name": "dbuser2",
- "host": "localhost",
- "databases": [
- {
- "name": "databaseB"
- },
- {
- "name": "databaseC"
- }
- ]
- }
-]
-}
-`
-
-var (
- listUserAccessResp = singleDB
- grantUserAccessReq = singleDB
-)
diff --git a/rackspace/db/v1/users/requests.go b/rackspace/db/v1/users/requests.go
deleted file mode 100644
index 74e47ab..0000000
--- a/rackspace/db/v1/users/requests.go
+++ /dev/null
@@ -1,176 +0,0 @@
-package users
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
- db "github.com/rackspace/gophercloud/openstack/db/v1/databases"
- os "github.com/rackspace/gophercloud/openstack/db/v1/users"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List will list all available users for a specified database instance.
-func List(client *gophercloud.ServiceClient, instanceID string) pagination.Pager {
- createPageFn := func(r pagination.PageResult) pagination.Page {
- return UserPage{pagination.LinkedPageBase{PageResult: r}}
- }
-
- return pagination.NewPager(client, baseURL(client, instanceID), createPageFn)
-}
-
-/*
-ChangePassword changes the password for one or more users. For example, to
-change the respective passwords for two users:
-
- opts := os.BatchCreateOpts{
- os.CreateOpts{Name: "db_user_1", Password: "new_password_1"},
- os.CreateOpts{Name: "db_user_2", Password: "new_password_2"},
- }
-
- ChangePassword(client, "instance_id", opts)
-*/
-func ChangePassword(client *gophercloud.ServiceClient, instanceID string, opts os.CreateOptsBuilder) UpdatePasswordsResult {
- var res UpdatePasswordsResult
-
- reqBody, err := opts.ToUserCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = client.Request("PUT", baseURL(client, instanceID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
- return res
-}
-
-// UpdateOpts is the struct responsible for updating an existing user.
-type UpdateOpts struct {
- // [OPTIONAL] Specifies a name for the user. Valid names can be composed
- // of the following characters: letters (either case); numbers; these
- // characters '@', '?', '#', ' ' but NEVER beginning a name string; '_' is
- // permitted anywhere. Prohibited characters that are forbidden include:
- // single quotes, double quotes, back quotes, semicolons, commas, backslashes,
- // and forward slashes. Spaces at the front or end of a user name are also
- // not permitted.
- Name string
-
- // [OPTIONAL] Specifies a password for the user.
- Password string
-
- // [OPTIONAL] Specifies the host from which a user is allowed to connect to
- // the database. Possible values are a string containing an IPv4 address or
- // "%" to allow connecting from any host. Optional; the default is "%".
- Host string
-}
-
-// ToMap is a convenience function for creating sub-maps for individual users.
-func (opts UpdateOpts) ToMap() (map[string]interface{}, error) {
- if opts.Name == "root" {
- return nil, errors.New("root is a reserved user name and cannot be used")
- }
-
- user := map[string]interface{}{}
-
- if opts.Name != "" {
- user["name"] = opts.Name
- }
-
- if opts.Password != "" {
- user["password"] = opts.Password
- }
-
- if opts.Host != "" {
- user["host"] = opts.Host
- }
-
- return user, nil
-}
-
-// Update will modify the attributes of a specified user. Attributes that can
-// be updated are: user name, password, and host.
-func Update(client *gophercloud.ServiceClient, instanceID, userName string, opts UpdateOpts) UpdateResult {
- var res UpdateResult
-
- reqBody, err := opts.ToMap()
- if err != nil {
- res.Err = err
- return res
- }
- reqBody = map[string]interface{}{"user": reqBody}
-
- _, res.Err = client.Request("PUT", userURL(client, instanceID, userName), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
- return res
-}
-
-// Get will retrieve the details for a particular user.
-func Get(client *gophercloud.ServiceClient, instanceID, userName string) GetResult {
- var res GetResult
-
- _, res.Err = client.Request("GET", userURL(client, instanceID, userName), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
- return res
-}
-
-// ListAccess will list all of the databases a user has access to.
-func ListAccess(client *gophercloud.ServiceClient, instanceID, userName string) pagination.Pager {
- pageFn := func(r pagination.PageResult) pagination.Page {
- return AccessPage{pagination.LinkedPageBase{PageResult: r}}
- }
-
- return pagination.NewPager(client, dbsURL(client, instanceID, userName), pageFn)
-}
-
-/*
-GrantAccess for the specified user to one or more databases on a specified
-instance. For example, to add a user to multiple databases:
-
- opts := db.BatchCreateOpts{
- db.CreateOpts{Name: "database_1"},
- db.CreateOpts{Name: "database_3"},
- db.CreateOpts{Name: "database_19"},
- }
-
- GrantAccess(client, "instance_id", "user_name", opts)
-*/
-func GrantAccess(client *gophercloud.ServiceClient, instanceID, userName string, opts db.CreateOptsBuilder) GrantAccessResult {
- var res GrantAccessResult
-
- reqBody, err := opts.ToDBCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = client.Request("PUT", dbsURL(client, instanceID, userName), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
- return res
-}
-
-/*
-RevokeAccess will revoke access for the specified user to one or more databases
-on a specified instance. For example:
-
- RevokeAccess(client, "instance_id", "user_name", "db_name")
-*/
-func RevokeAccess(client *gophercloud.ServiceClient, instanceID, userName, dbName string) RevokeAccessResult {
- var res RevokeAccessResult
-
- _, res.Err = client.Request("DELETE", dbURL(client, instanceID, userName, dbName), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
- return res
-}
diff --git a/rackspace/db/v1/users/requests_test.go b/rackspace/db/v1/users/requests_test.go
deleted file mode 100644
index 2f2dca7..0000000
--- a/rackspace/db/v1/users/requests_test.go
+++ /dev/null
@@ -1,156 +0,0 @@
-package users
-
-import (
- "testing"
-
- db "github.com/rackspace/gophercloud/openstack/db/v1/databases"
- os "github.com/rackspace/gophercloud/openstack/db/v1/users"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
- "github.com/rackspace/gophercloud/testhelper/fixture"
-)
-
-var (
- userName = "{userName}"
- _rootURL = "/instances/" + instanceID + "/users"
- _userURL = _rootURL + "/" + userName
- _dbURL = _userURL + "/databases"
-)
-
-func TestChangeUserPassword(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _rootURL, "PUT", changePwdReq, "", 202)
-
- opts := os.BatchCreateOpts{
- os.CreateOpts{Name: "dbuser1", Password: "newpassword"},
- os.CreateOpts{Name: "dbuser2", Password: "anotherpassword"},
- }
-
- err := ChangePassword(fake.ServiceClient(), instanceID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestUpdateUser(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _userURL, "PUT", updateReq, "", 202)
-
- opts := UpdateOpts{
- Name: "new_username",
- Password: "new_password",
- }
-
- err := Update(fake.ServiceClient(), instanceID, userName, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGetUser(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _userURL, "GET", "", getResp, 200)
-
- user, err := Get(fake.ServiceClient(), instanceID, userName).Extract()
-
- th.AssertNoErr(t, err)
-
- expected := &User{
- Name: "exampleuser",
- Host: "foo",
- Databases: []db.Database{
- db.Database{Name: "databaseA"},
- db.Database{Name: "databaseB"},
- },
- }
-
- th.AssertDeepEquals(t, expected, user)
-}
-
-func TestUserAccessList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _userURL+"/databases", "GET", "", listUserAccessResp, 200)
-
- expectedDBs := []db.Database{
- db.Database{Name: "databaseE"},
- }
-
- pages := 0
- err := ListAccess(fake.ServiceClient(), instanceID, userName).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := ExtractDBs(page)
- if err != nil {
- return false, err
- }
-
- th.CheckDeepEquals(t, expectedDBs, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestUserList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- fixture.SetupHandler(t, "/instances/"+instanceID+"/users", "GET", "", listResp, 200)
-
- expectedUsers := []User{
- User{
- Databases: []db.Database{
- db.Database{Name: "databaseA"},
- },
- Name: "dbuser1",
- Host: "localhost",
- },
- User{
- Databases: []db.Database{
- db.Database{Name: "databaseB"},
- db.Database{Name: "databaseC"},
- },
- Name: "dbuser2",
- Host: "localhost",
- },
- }
-
- pages := 0
- err := List(fake.ServiceClient(), instanceID).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- actual, err := ExtractUsers(page)
- if err != nil {
- return false, err
- }
-
- th.CheckDeepEquals(t, expectedUsers, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, pages)
-}
-
-func TestGrantAccess(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _dbURL, "PUT", grantUserAccessReq, "", 202)
-
- opts := db.BatchCreateOpts{db.CreateOpts{Name: "databaseE"}}
- err := GrantAccess(fake.ServiceClient(), instanceID, userName, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestRevokeAccess(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- fixture.SetupHandler(t, _dbURL+"/{dbName}", "DELETE", "", "", 202)
-
- err := RevokeAccess(fake.ServiceClient(), instanceID, userName, "{dbName}").ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/db/v1/users/results.go b/rackspace/db/v1/users/results.go
deleted file mode 100644
index 85b3a7a..0000000
--- a/rackspace/db/v1/users/results.go
+++ /dev/null
@@ -1,149 +0,0 @@
-package users
-
-import (
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- db "github.com/rackspace/gophercloud/openstack/db/v1/databases"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// User represents a database user
-type User struct {
- // The user name
- Name string
-
- // The user password
- Password string
-
- // Specifies the host from which a user is allowed to connect to the database.
- // Possible values are a string containing an IPv4 address or "%" to allow
- // connecting from any host.
- Host string
-
- // The databases associated with this user
- Databases []db.Database
-}
-
-// UpdatePasswordsResult represents the result of changing a user password.
-type UpdatePasswordsResult struct {
- gophercloud.ErrResult
-}
-
-// UpdateResult represents the result of updating a user.
-type UpdateResult struct {
- gophercloud.ErrResult
-}
-
-// GetResult represents the result of getting a user.
-type GetResult struct {
- gophercloud.Result
-}
-
-// Extract will retrieve a User struct from a getresult.
-func (r GetResult) Extract() (*User, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- User User `mapstructure:"user"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
- return &response.User, err
-}
-
-// AccessPage represents a single page of a paginated user collection.
-type AccessPage struct {
- pagination.LinkedPageBase
-}
-
-// IsEmpty checks to see whether the collection is empty.
-func (page AccessPage) IsEmpty() (bool, error) {
- users, err := ExtractDBs(page)
- if err != nil {
- return true, err
- }
- return len(users) == 0, nil
-}
-
-// NextPageURL will retrieve the next page URL.
-func (page AccessPage) NextPageURL() (string, error) {
- type resp struct {
- Links []gophercloud.Link `mapstructure:"databases_links"`
- }
-
- var r resp
- err := mapstructure.Decode(page.Body, &r)
- if err != nil {
- return "", err
- }
-
- return gophercloud.ExtractNextURL(r.Links)
-}
-
-// ExtractDBs will convert a generic pagination struct into a more
-// relevant slice of DB structs.
-func ExtractDBs(page pagination.Page) ([]db.Database, error) {
- casted := page.(AccessPage).Body
-
- var response struct {
- DBs []db.Database `mapstructure:"databases"`
- }
-
- err := mapstructure.Decode(casted, &response)
- return response.DBs, err
-}
-
-// UserPage represents a single page of a paginated user collection.
-type UserPage struct {
- pagination.LinkedPageBase
-}
-
-// IsEmpty checks to see whether the collection is empty.
-func (page UserPage) IsEmpty() (bool, error) {
- users, err := ExtractUsers(page)
- if err != nil {
- return true, err
- }
- return len(users) == 0, nil
-}
-
-// NextPageURL will retrieve the next page URL.
-func (page UserPage) NextPageURL() (string, error) {
- type resp struct {
- Links []gophercloud.Link `mapstructure:"users_links"`
- }
-
- var r resp
- err := mapstructure.Decode(page.Body, &r)
- if err != nil {
- return "", err
- }
-
- return gophercloud.ExtractNextURL(r.Links)
-}
-
-// ExtractUsers will convert a generic pagination struct into a more
-// relevant slice of User structs.
-func ExtractUsers(page pagination.Page) ([]User, error) {
- casted := page.(UserPage).Body
-
- var response struct {
- Users []User `mapstructure:"users"`
- }
-
- err := mapstructure.Decode(casted, &response)
-
- return response.Users, err
-}
-
-// GrantAccessResult represents the result of granting access to a user.
-type GrantAccessResult struct {
- gophercloud.ErrResult
-}
-
-// RevokeAccessResult represents the result of revoking access to a user.
-type RevokeAccessResult struct {
- gophercloud.ErrResult
-}
diff --git a/rackspace/db/v1/users/urls.go b/rackspace/db/v1/users/urls.go
deleted file mode 100644
index bac8788..0000000
--- a/rackspace/db/v1/users/urls.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package users
-
-import "github.com/rackspace/gophercloud"
-
-func baseURL(c *gophercloud.ServiceClient, instanceID string) string {
- return c.ServiceURL("instances", instanceID, "users")
-}
-
-func userURL(c *gophercloud.ServiceClient, instanceID, userName string) string {
- return c.ServiceURL("instances", instanceID, "users", userName)
-}
-
-func dbsURL(c *gophercloud.ServiceClient, instanceID, userName string) string {
- return c.ServiceURL("instances", instanceID, "users", userName, "databases")
-}
-
-func dbURL(c *gophercloud.ServiceClient, instanceID, userName, dbName string) string {
- return c.ServiceURL("instances", instanceID, "users", userName, "databases", dbName)
-}
diff --git a/rackspace/identity/v2/extensions/delegate.go b/rackspace/identity/v2/extensions/delegate.go
deleted file mode 100644
index fc547cd..0000000
--- a/rackspace/identity/v2/extensions/delegate.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package extensions
-
-import (
- "github.com/rackspace/gophercloud"
- common "github.com/rackspace/gophercloud/openstack/common/extensions"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the
-// elements into a slice of os.Extension structs.
-func ExtractExtensions(page pagination.Page) ([]common.Extension, error) {
- return common.ExtractExtensions(page)
-}
-
-// Get retrieves information for a specific extension using its alias.
-func Get(c *gophercloud.ServiceClient, alias string) common.GetResult {
- return common.Get(c, alias)
-}
-
-// List returns a Pager which allows you to iterate over the full collection of extensions.
-// It does not accept query parameters.
-func List(c *gophercloud.ServiceClient) pagination.Pager {
- return common.List(c)
-}
diff --git a/rackspace/identity/v2/extensions/delegate_test.go b/rackspace/identity/v2/extensions/delegate_test.go
deleted file mode 100644
index e30f794..0000000
--- a/rackspace/identity/v2/extensions/delegate_test.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package extensions
-
-import (
- "testing"
-
- common "github.com/rackspace/gophercloud/openstack/common/extensions"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- common.HandleListExtensionsSuccessfully(t)
-
- count := 0
-
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractExtensions(page)
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, common.ExpectedExtensions, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- common.HandleGetExtensionSuccessfully(t)
-
- actual, err := Get(fake.ServiceClient(), "agent").Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, common.SingleExtension, actual)
-}
diff --git a/rackspace/identity/v2/extensions/doc.go b/rackspace/identity/v2/extensions/doc.go
deleted file mode 100644
index b02a95b..0000000
--- a/rackspace/identity/v2/extensions/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package extensions provides information and interaction with the all the
-// extensions available for the Rackspace Identity service.
-package extensions
diff --git a/rackspace/identity/v2/roles/delegate.go b/rackspace/identity/v2/roles/delegate.go
deleted file mode 100644
index a6ee851..0000000
--- a/rackspace/identity/v2/roles/delegate.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package roles
-
-import (
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-
- os "github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles"
-)
-
-// List is the operation responsible for listing all available global roles
-// that a user can adopt.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client)
-}
-
-// AddUserRole is the operation responsible for assigning a particular role to
-// a user. This is confined to the scope of the user's tenant - so the tenant
-// ID is a required argument.
-func AddUserRole(client *gophercloud.ServiceClient, userID, roleID string) UserRoleResult {
- var result UserRoleResult
-
- _, result.Err = client.Request("PUT", userRoleURL(client, userID, roleID), gophercloud.RequestOpts{
- OkCodes: []int{200, 201},
- })
-
- return result
-}
-
-// DeleteUserRole is the operation responsible for deleting a particular role
-// from a user. This is confined to the scope of the user's tenant - so the
-// tenant ID is a required argument.
-func DeleteUserRole(client *gophercloud.ServiceClient, userID, roleID string) UserRoleResult {
- var result UserRoleResult
-
- _, result.Err = client.Request("DELETE", userRoleURL(client, userID, roleID), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
-
- return result
-}
-
-// UserRoleResult represents the result of either an AddUserRole or
-// a DeleteUserRole operation.
-type UserRoleResult struct {
- gophercloud.ErrResult
-}
-
-func userRoleURL(c *gophercloud.ServiceClient, userID, roleID string) string {
- return c.ServiceURL(os.UserPath, userID, os.RolePath, os.ExtPath, roleID)
-}
diff --git a/rackspace/identity/v2/roles/delegate_test.go b/rackspace/identity/v2/roles/delegate_test.go
deleted file mode 100644
index fcee97d..0000000
--- a/rackspace/identity/v2/roles/delegate_test.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package roles
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestRole(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- MockListRoleResponse(t)
-
- count := 0
-
- err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractRoles(page)
- if err != nil {
- t.Errorf("Failed to extract users: %v", err)
- return false, err
- }
-
- expected := []os.Role{
- os.Role{
- ID: "123",
- Name: "compute:admin",
- Description: "Nova Administrator",
- ServiceID: "cke5372ebabeeabb70a0e702a4626977x4406e5",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestAddUserRole(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- MockAddUserRoleResponse(t)
-
- err := AddUserRole(client.ServiceClient(), "{user_id}", "{role_id}").ExtractErr()
-
- th.AssertNoErr(t, err)
-}
-
-func TestDeleteUserRole(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- MockDeleteUserRoleResponse(t)
-
- err := DeleteUserRole(client.ServiceClient(), "{user_id}", "{role_id}").ExtractErr()
-
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/identity/v2/roles/fixtures.go b/rackspace/identity/v2/roles/fixtures.go
deleted file mode 100644
index 5f22d0f..0000000
--- a/rackspace/identity/v2/roles/fixtures.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package roles
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func MockListRoleResponse(t *testing.T) {
- th.Mux.HandleFunc("/OS-KSADM/roles", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "roles": [
- {
- "id": "123",
- "name": "compute:admin",
- "description": "Nova Administrator",
- "serviceId": "cke5372ebabeeabb70a0e702a4626977x4406e5"
- }
- ]
-}
- `)
- })
-}
-
-func MockAddUserRoleResponse(t *testing.T) {
- th.Mux.HandleFunc("/users/{user_id}/roles/OS-KSADM/{role_id}", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusCreated)
- })
-}
-
-func MockDeleteUserRoleResponse(t *testing.T) {
- th.Mux.HandleFunc("/users/{user_id}/roles/OS-KSADM/{role_id}", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-}
diff --git a/rackspace/identity/v2/tenants/delegate.go b/rackspace/identity/v2/tenants/delegate.go
deleted file mode 100644
index 6cdd0cf..0000000
--- a/rackspace/identity/v2/tenants/delegate.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package tenants
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/identity/v2/tenants"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// ExtractTenants interprets a page of List results as a more usable slice of Tenant structs.
-func ExtractTenants(page pagination.Page) ([]os.Tenant, error) {
- return os.ExtractTenants(page)
-}
-
-// List enumerates the tenants to which the current token grants access.
-func List(client *gophercloud.ServiceClient, opts *os.ListOpts) pagination.Pager {
- return os.List(client, opts)
-}
diff --git a/rackspace/identity/v2/tenants/delegate_test.go b/rackspace/identity/v2/tenants/delegate_test.go
deleted file mode 100644
index eccbfe2..0000000
--- a/rackspace/identity/v2/tenants/delegate_test.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package tenants
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/identity/v2/tenants"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListTenants(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListTenantsSuccessfully(t)
-
- count := 0
- err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- actual, err := ExtractTenants(page)
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, os.ExpectedTenantSlice, actual)
-
- count++
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
diff --git a/rackspace/identity/v2/tenants/doc.go b/rackspace/identity/v2/tenants/doc.go
deleted file mode 100644
index c1825c2..0000000
--- a/rackspace/identity/v2/tenants/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package tenants provides information and interaction with the tenant
-// API resource for the Rackspace Identity service.
-package tenants
diff --git a/rackspace/identity/v2/tokens/delegate.go b/rackspace/identity/v2/tokens/delegate.go
deleted file mode 100644
index 4f9885a..0000000
--- a/rackspace/identity/v2/tokens/delegate.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package tokens
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/identity/v2/tokens"
-)
-
-var (
- // ErrPasswordProvided is returned if both a password and an API key are provided to Create.
- ErrPasswordProvided = errors.New("Please provide either a password or an API key.")
-)
-
-// AuthOptions wraps the OpenStack AuthOptions struct to be able to customize the request body
-// when API key authentication is used.
-type AuthOptions struct {
- os.AuthOptions
-}
-
-// WrapOptions embeds a root AuthOptions struct in a package-specific one.
-func WrapOptions(original gophercloud.AuthOptions) AuthOptions {
- return AuthOptions{AuthOptions: os.WrapOptions(original)}
-}
-
-// ToTokenCreateMap serializes an AuthOptions into a request body. If an API key is provided, it
-// will be used, otherwise
-func (auth AuthOptions) ToTokenCreateMap() (map[string]interface{}, error) {
- if auth.APIKey == "" {
- return auth.AuthOptions.ToTokenCreateMap()
- }
-
- // Verify that other required attributes are present.
- if auth.Username == "" {
- return nil, os.ErrUsernameRequired
- }
-
- authMap := make(map[string]interface{})
-
- authMap["RAX-KSKEY:apiKeyCredentials"] = map[string]interface{}{
- "username": auth.Username,
- "apiKey": auth.APIKey,
- }
-
- if auth.TenantID != "" {
- authMap["tenantId"] = auth.TenantID
- }
- if auth.TenantName != "" {
- authMap["tenantName"] = auth.TenantName
- }
-
- return map[string]interface{}{"auth": authMap}, nil
-}
-
-// Create authenticates to Rackspace's identity service and attempts to acquire a Token. Rather
-// than interact with this service directly, users should generally call
-// rackspace.AuthenticatedClient().
-func Create(client *gophercloud.ServiceClient, auth AuthOptions) os.CreateResult {
- return os.Create(client, auth)
-}
diff --git a/rackspace/identity/v2/tokens/delegate_test.go b/rackspace/identity/v2/tokens/delegate_test.go
deleted file mode 100644
index 6678ff4..0000000
--- a/rackspace/identity/v2/tokens/delegate_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package tokens
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/identity/v2/tokens"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func tokenPost(t *testing.T, options gophercloud.AuthOptions, requestJSON string) os.CreateResult {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleTokenPost(t, requestJSON)
-
- return Create(client.ServiceClient(), WrapOptions(options))
-}
-
-func TestCreateTokenWithAPIKey(t *testing.T) {
- options := gophercloud.AuthOptions{
- Username: "me",
- APIKey: "1234567890abcdef",
- }
-
- os.IsSuccessful(t, tokenPost(t, options, `
- {
- "auth": {
- "RAX-KSKEY:apiKeyCredentials": {
- "username": "me",
- "apiKey": "1234567890abcdef"
- }
- }
- }
- `))
-}
diff --git a/rackspace/identity/v2/tokens/doc.go b/rackspace/identity/v2/tokens/doc.go
deleted file mode 100644
index 44043e5..0000000
--- a/rackspace/identity/v2/tokens/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package tokens provides information and interaction with the token
-// API resource for the Rackspace Identity service.
-package tokens
diff --git a/rackspace/identity/v2/users/delegate.go b/rackspace/identity/v2/users/delegate.go
deleted file mode 100644
index 6135bec..0000000
--- a/rackspace/identity/v2/users/delegate.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package users
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/identity/v2/users"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a pager that allows traversal over a collection of users.
-func List(client *gophercloud.ServiceClient) pagination.Pager {
- return os.List(client)
-}
-
-// CommonOpts are the options which are shared between CreateOpts and
-// UpdateOpts
-type CommonOpts struct {
- // Required. The username to assign to the user. When provided, the username
- // must:
- // - start with an alphabetical (A-Za-z) character
- // - have a minimum length of 1 character
- //
- // The username may contain upper and lowercase characters, as well as any of
- // the following special character: . - @ _
- Username string
-
- // Required. Email address for the user account.
- Email string
-
- // Required. Indicates whether the user can authenticate after the user
- // account is created. If no value is specified, the default value is true.
- Enabled os.EnabledState
-
- // Optional. The password to assign to the user. If provided, the password
- // must:
- // - start with an alphabetical (A-Za-z) character
- // - have a minimum length of 8 characters
- // - contain at least one uppercase character, one lowercase character, and
- // one numeric character.
- //
- // The password may contain any of the following special characters: . - @ _
- Password string
-}
-
-// CreateOpts represents the options needed when creating new users.
-type CreateOpts CommonOpts
-
-// ToUserCreateMap assembles a request body based on the contents of a CreateOpts.
-func (opts CreateOpts) ToUserCreateMap() (map[string]interface{}, error) {
- m := make(map[string]interface{})
-
- if opts.Username == "" {
- return m, errors.New("Username is a required field")
- }
- if opts.Enabled == nil {
- return m, errors.New("Enabled is a required field")
- }
- if opts.Email == "" {
- return m, errors.New("Email is a required field")
- }
-
- if opts.Username != "" {
- m["username"] = opts.Username
- }
- if opts.Email != "" {
- m["email"] = opts.Email
- }
- if opts.Enabled != nil {
- m["enabled"] = opts.Enabled
- }
- if opts.Password != "" {
- m["OS-KSADM:password"] = opts.Password
- }
-
- return map[string]interface{}{"user": m}, nil
-}
-
-// Create is the operation responsible for creating new users.
-func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) CreateResult {
- return CreateResult{os.Create(client, opts)}
-}
-
-// Get requests details on a single user, either by ID.
-func Get(client *gophercloud.ServiceClient, id string) GetResult {
- return GetResult{os.Get(client, id)}
-}
-
-// UpdateOptsBuilder allows extensions to add additional attributes to the Update request.
-type UpdateOptsBuilder interface {
- ToUserUpdateMap() map[string]interface{}
-}
-
-// UpdateOpts specifies the base attributes that may be updated on an existing server.
-type UpdateOpts CommonOpts
-
-// ToUserUpdateMap formats an UpdateOpts structure into a request body.
-func (opts UpdateOpts) ToUserUpdateMap() map[string]interface{} {
- m := make(map[string]interface{})
-
- if opts.Username != "" {
- m["username"] = opts.Username
- }
- if opts.Enabled != nil {
- m["enabled"] = &opts.Enabled
- }
- if opts.Email != "" {
- m["email"] = opts.Email
- }
-
- return map[string]interface{}{"user": m}
-}
-
-// Update is the operation responsible for updating exist users by their UUID.
-func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult {
- var result UpdateResult
-
- _, result.Err = client.Request("POST", os.ResourceURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: opts.ToUserUpdateMap(),
- OkCodes: []int{200},
- })
-
- return result
-}
-
-// Delete is the operation responsible for permanently deleting an API user.
-func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult {
- return os.Delete(client, id)
-}
-
-// ResetAPIKey resets the User's API key.
-func ResetAPIKey(client *gophercloud.ServiceClient, id string) ResetAPIKeyResult {
- var result ResetAPIKeyResult
-
- _, result.Err = client.Request("POST", resetAPIKeyURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- OkCodes: []int{200},
- })
-
- return result
-}
diff --git a/rackspace/identity/v2/users/delegate_test.go b/rackspace/identity/v2/users/delegate_test.go
deleted file mode 100644
index 62faf0c..0000000
--- a/rackspace/identity/v2/users/delegate_test.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package users
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/identity/v2/users"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListResponse(t)
-
- count := 0
-
- err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- users, err := os.ExtractUsers(page)
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, "u1000", users[0].ID)
- th.AssertEquals(t, "u1001", users[1].ID)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestCreateUser(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockCreateUser(t)
-
- opts := CreateOpts{
- Username: "new_user",
- Enabled: os.Disabled,
- Email: "new_user@foo.com",
- Password: "foo",
- }
-
- user, err := Create(client.ServiceClient(), opts).Extract()
-
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, "123456", user.ID)
- th.AssertEquals(t, "5830280", user.DomainID)
- th.AssertEquals(t, "DFW", user.DefaultRegion)
-}
-
-func TestGetUser(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetUser(t)
-
- user, err := Get(client.ServiceClient(), "new_user").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, true, user.Enabled)
- th.AssertEquals(t, true, user.MultiFactorEnabled)
-}
-
-func TestUpdateUser(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockUpdateUser(t)
-
- id := "c39e3de9be2d4c779f1dfd6abacc176d"
-
- opts := UpdateOpts{
- Enabled: os.Enabled,
- Email: "new_email@foo.com",
- }
-
- user, err := Update(client.ServiceClient(), id, opts).Extract()
-
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, true, user.Enabled)
- th.AssertEquals(t, "new_email@foo.com", user.Email)
-}
-
-func TestDeleteServer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteUser(t)
-
- res := Delete(client.ServiceClient(), "c39e3de9be2d4c779f1dfd6abacc176d")
- th.AssertNoErr(t, res.Err)
-}
-
-func TestResetAPIKey(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockResetAPIKey(t)
-
- apiKey, err := ResetAPIKey(client.ServiceClient(), "99").Extract()
- th.AssertNoErr(t, err)
- th.AssertEquals(t, "joesmith", apiKey.Username)
- th.AssertEquals(t, "mooH1eiLahd5ahYood7r", apiKey.APIKey)
-}
diff --git a/rackspace/identity/v2/users/fixtures.go b/rackspace/identity/v2/users/fixtures.go
deleted file mode 100644
index 973f39e..0000000
--- a/rackspace/identity/v2/users/fixtures.go
+++ /dev/null
@@ -1,154 +0,0 @@
-package users
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func mockListResponse(t *testing.T) {
- th.Mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "users":[
- {
- "id": "u1000",
- "username": "jqsmith",
- "email": "john.smith@example.org",
- "enabled": true
- },
- {
- "id": "u1001",
- "username": "jqsmith",
- "email": "jane.smith@example.org",
- "enabled": true
- }
- ]
-}
- `)
- })
-}
-
-func mockCreateUser(t *testing.T) {
- th.Mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "user": {
- "username": "new_user",
- "enabled": false,
- "email": "new_user@foo.com",
- "OS-KSADM:password": "foo"
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "user": {
- "RAX-AUTH:defaultRegion": "DFW",
- "RAX-AUTH:domainId": "5830280",
- "id": "123456",
- "username": "new_user",
- "email": "new_user@foo.com",
- "enabled": false
- }
-}
-`)
- })
-}
-
-func mockGetUser(t *testing.T) {
- th.Mux.HandleFunc("/users/new_user", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "user": {
- "RAX-AUTH:defaultRegion": "DFW",
- "RAX-AUTH:domainId": "5830280",
- "RAX-AUTH:multiFactorEnabled": "true",
- "id": "c39e3de9be2d4c779f1dfd6abacc176d",
- "username": "jqsmith",
- "email": "john.smith@example.org",
- "enabled": true
- }
-}
-`)
- })
-}
-
-func mockUpdateUser(t *testing.T) {
- th.Mux.HandleFunc("/users/c39e3de9be2d4c779f1dfd6abacc176d", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "user": {
- "email": "new_email@foo.com",
- "enabled": true
- }
-}
-`)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "user": {
- "RAX-AUTH:defaultRegion": "DFW",
- "RAX-AUTH:domainId": "5830280",
- "RAX-AUTH:multiFactorEnabled": "true",
- "id": "123456",
- "username": "jqsmith",
- "email": "new_email@foo.com",
- "enabled": true
- }
-}
-`)
- })
-}
-
-func mockDeleteUser(t *testing.T) {
- th.Mux.HandleFunc("/users/c39e3de9be2d4c779f1dfd6abacc176d", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-}
-
-func mockResetAPIKey(t *testing.T) {
- th.Mux.HandleFunc("/users/99/OS-KSADM/credentials/RAX-KSKEY:apiKeyCredentials/RAX-AUTH/reset", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `
-{
- "RAX-KSKEY:apiKeyCredentials": {
- "username": "joesmith",
- "apiKey": "mooH1eiLahd5ahYood7r"
- }
-}`)
- })
-}
diff --git a/rackspace/identity/v2/users/results.go b/rackspace/identity/v2/users/results.go
deleted file mode 100644
index 6936ecb..0000000
--- a/rackspace/identity/v2/users/results.go
+++ /dev/null
@@ -1,129 +0,0 @@
-package users
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/identity/v2/users"
-
- "github.com/mitchellh/mapstructure"
-)
-
-// User represents a user resource that exists on the API.
-type User struct {
- // The UUID for this user.
- ID string
-
- // The human name for this user.
- Name string
-
- // The username for this user.
- Username string
-
- // Indicates whether the user is enabled (true) or disabled (false).
- Enabled bool
-
- // The email address for this user.
- Email string
-
- // The ID of the tenant to which this user belongs.
- TenantID string `mapstructure:"tenant_id"`
-
- // Specifies the default region for the user account. This value is inherited
- // from the user administrator when the account is created.
- DefaultRegion string `mapstructure:"RAX-AUTH:defaultRegion"`
-
- // Identifies the domain that contains the user account. This value is
- // inherited from the user administrator when the account is created.
- DomainID string `mapstructure:"RAX-AUTH:domainId"`
-
- // The password value that the user needs for authentication. If the Add user
- // request included a password value, this attribute is not included in the
- // response.
- Password string `mapstructure:"OS-KSADM:password"`
-
- // Indicates whether the user has enabled multi-factor authentication.
- MultiFactorEnabled bool `mapstructure:"RAX-AUTH:multiFactorEnabled"`
-}
-
-// CreateResult represents the result of a Create operation
-type CreateResult struct {
- os.CreateResult
-}
-
-// GetResult represents the result of a Get operation
-type GetResult struct {
- os.GetResult
-}
-
-// UpdateResult represents the result of an Update operation
-type UpdateResult struct {
- os.UpdateResult
-}
-
-func commonExtract(resp interface{}, err error) (*User, error) {
- if err != nil {
- return nil, err
- }
-
- var respStruct struct {
- User *User `json:"user"`
- }
-
- // Since the API returns a string instead of a bool, we need to hack the JSON
- json := resp.(map[string]interface{})
- user := json["user"].(map[string]interface{})
- if s, ok := user["RAX-AUTH:multiFactorEnabled"].(string); ok && s != "" {
- if b, err := strconv.ParseBool(s); err == nil {
- user["RAX-AUTH:multiFactorEnabled"] = b
- }
- }
-
- err = mapstructure.Decode(json, &respStruct)
-
- return respStruct.User, err
-}
-
-// Extract will get the Snapshot object out of the GetResult object.
-func (r GetResult) Extract() (*User, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// Extract will get the Snapshot object out of the CreateResult object.
-func (r CreateResult) Extract() (*User, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// Extract will get the Snapshot object out of the UpdateResult object.
-func (r UpdateResult) Extract() (*User, error) {
- return commonExtract(r.Body, r.Err)
-}
-
-// ResetAPIKeyResult represents the server response to the ResetAPIKey method.
-type ResetAPIKeyResult struct {
- gophercloud.Result
-}
-
-// ResetAPIKeyValue represents an API Key that has been reset.
-type ResetAPIKeyValue struct {
- // The Username for this API Key reset.
- Username string `mapstructure:"username"`
-
- // The new API Key for this user.
- APIKey string `mapstructure:"apiKey"`
-}
-
-// Extract will get the Error or ResetAPIKeyValue object out of the ResetAPIKeyResult object.
-func (r ResetAPIKeyResult) Extract() (*ResetAPIKeyValue, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- ResetAPIKeyValue ResetAPIKeyValue `mapstructure:"RAX-KSKEY:apiKeyCredentials"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- return &response.ResetAPIKeyValue, err
-}
diff --git a/rackspace/identity/v2/users/urls.go b/rackspace/identity/v2/users/urls.go
deleted file mode 100644
index bc1aaef..0000000
--- a/rackspace/identity/v2/users/urls.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package users
-
-import "github.com/rackspace/gophercloud"
-
-func resetAPIKeyURL(client *gophercloud.ServiceClient, id string) string {
- return client.ServiceURL("users", id, "OS-KSADM", "credentials", "RAX-KSKEY:apiKeyCredentials", "RAX-AUTH", "reset")
-}
diff --git a/rackspace/lb/v1/acl/doc.go b/rackspace/lb/v1/acl/doc.go
deleted file mode 100644
index 42325fe..0000000
--- a/rackspace/lb/v1/acl/doc.go
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
-Package acl provides information and interaction with the access lists feature
-of the Rackspace Cloud Load Balancer service.
-
-The access list management feature allows fine-grained network access controls
-to be applied to the load balancer's virtual IP address. A single IP address,
-multiple IP addresses, or entire network subnets can be added. Items that are
-configured with the ALLOW type always takes precedence over items with the DENY
-type. To reject traffic from all items except for those with the ALLOW type,
-add a networkItem with an address of "0.0.0.0/0" and a DENY type.
-*/
-package acl
diff --git a/rackspace/lb/v1/acl/fixtures.go b/rackspace/lb/v1/acl/fixtures.go
deleted file mode 100644
index e3c941c..0000000
--- a/rackspace/lb/v1/acl/fixtures.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package acl
-
-import (
- "fmt"
- "net/http"
- "strconv"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func _rootURL(lbID int) string {
- return "/loadbalancers/" + strconv.Itoa(lbID) + "/accesslist"
-}
-
-func mockListResponse(t *testing.T, id int) {
- th.Mux.HandleFunc(_rootURL(id), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "accessList": [
- {
- "address": "206.160.163.21",
- "id": 21,
- "type": "DENY"
- },
- {
- "address": "206.160.163.22",
- "id": 22,
- "type": "DENY"
- },
- {
- "address": "206.160.163.23",
- "id": 23,
- "type": "DENY"
- },
- {
- "address": "206.160.163.24",
- "id": 24,
- "type": "DENY"
- }
- ]
-}
- `)
- })
-}
-
-func mockCreateResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "accessList": [
- {
- "address": "206.160.163.21",
- "type": "DENY"
- },
- {
- "address": "206.160.165.11",
- "type": "DENY"
- }
- ]
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockDeleteAllResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockBatchDeleteResponse(t *testing.T, lbID int, ids []int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- r.ParseForm()
-
- for k, v := range ids {
- fids := r.Form["id"]
- th.AssertEquals(t, strconv.Itoa(v), fids[k])
- }
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockDeleteResponse(t *testing.T, lbID, networkID int) {
- th.Mux.HandleFunc(_rootURL(lbID)+"/"+strconv.Itoa(networkID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
diff --git a/rackspace/lb/v1/acl/requests.go b/rackspace/lb/v1/acl/requests.go
deleted file mode 100644
index d4ce7c0..0000000
--- a/rackspace/lb/v1/acl/requests.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package acl
-
-import (
- "errors"
- "fmt"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List is the operation responsible for returning a paginated collection of
-// network items that define a load balancer's access list.
-func List(client *gophercloud.ServiceClient, lbID int) pagination.Pager {
- url := rootURL(client, lbID)
-
- return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
- return AccessListPage{pagination.SinglePageBase(r)}
- })
-}
-
-// CreateOptsBuilder is the interface responsible for generating the JSON
-// for a Create operation.
-type CreateOptsBuilder interface {
- ToAccessListCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts is a slice of CreateOpt structs, that allow the user to create
-// multiple nodes in a single operation (one node per CreateOpt).
-type CreateOpts []CreateOpt
-
-// CreateOpt represents the options to create a single node.
-type CreateOpt struct {
- // Required - the IP address or CIDR for item to add to access list.
- Address string
-
- // Required - the type of the node. Either ALLOW or DENY.
- Type Type
-}
-
-// ToAccessListCreateMap converts a slice of options into a map that can be
-// used for the JSON.
-func (opts CreateOpts) ToAccessListCreateMap() (map[string]interface{}, error) {
- type itemMap map[string]interface{}
- items := []itemMap{}
-
- for k, v := range opts {
- if v.Address == "" {
- return itemMap{}, fmt.Errorf("Address is a required attribute, none provided for %d CreateOpt element", k)
- }
- if v.Type != ALLOW && v.Type != DENY {
- return itemMap{}, fmt.Errorf("Type must be ALLOW or DENY")
- }
-
- item := make(itemMap)
- item["address"] = v.Address
- item["type"] = v.Type
-
- items = append(items, item)
- }
-
- 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
-
- reqBody, err := opts.ToAccessListCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = client.Post(rootURL(client, loadBalancerID), reqBody, nil, nil)
- 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
-
- if len(itemIDs) > 10 || len(itemIDs) == 0 {
- res.Err = errors.New("You must provide a minimum of 1 and a maximum of 10 item IDs")
- return res
- }
-
- url := rootURL(c, loadBalancerID)
- url += gophercloud.IDSliceToQueryString("id", itemIDs)
-
- _, res.Err = c.Delete(url, nil)
- 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 = c.Delete(resourceURL(c, lbID, itemID), nil)
- 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 = c.Delete(rootURL(c, lbID), nil)
- return res
-}
diff --git a/rackspace/lb/v1/acl/requests_test.go b/rackspace/lb/v1/acl/requests_test.go
deleted file mode 100644
index c4961a3..0000000
--- a/rackspace/lb/v1/acl/requests_test.go
+++ /dev/null
@@ -1,91 +0,0 @@
-package acl
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const (
- lbID = 12345
- itemID1 = 67890
- itemID2 = 67891
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListResponse(t, lbID)
-
- count := 0
-
- err := List(client.ServiceClient(), lbID).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractAccessList(page)
- th.AssertNoErr(t, err)
-
- expected := AccessList{
- NetworkItem{Address: "206.160.163.21", ID: 21, Type: DENY},
- NetworkItem{Address: "206.160.163.22", ID: 22, Type: DENY},
- NetworkItem{Address: "206.160.163.23", ID: 23, Type: DENY},
- NetworkItem{Address: "206.160.163.24", ID: 24, Type: DENY},
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockCreateResponse(t, lbID)
-
- opts := CreateOpts{
- CreateOpt{Address: "206.160.163.21", Type: DENY},
- CreateOpt{Address: "206.160.165.11", Type: DENY},
- }
-
- err := Create(client.ServiceClient(), lbID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestBulkDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- ids := []int{itemID1, itemID2}
-
- mockBatchDeleteResponse(t, lbID, ids)
-
- err := BulkDelete(client.ServiceClient(), lbID, ids).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteResponse(t, lbID, itemID1)
-
- err := Delete(client.ServiceClient(), lbID, itemID1).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDeleteAll(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteAllResponse(t, lbID)
-
- err := DeleteAll(client.ServiceClient(), lbID).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/lb/v1/acl/results.go b/rackspace/lb/v1/acl/results.go
deleted file mode 100644
index 9ea5ea2..0000000
--- a/rackspace/lb/v1/acl/results.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package acl
-
-import (
- "github.com/mitchellh/mapstructure"
-
- "github.com/rackspace/gophercloud"
- "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
-
- // 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"
-)
-
-// AccessListPage is the page returned by a pager for traversing over a
-// collection of network items in an access list.
-type AccessListPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty checks whether an AccessListPage struct is empty.
-func (p AccessListPage) IsEmpty() (bool, error) {
- is, err := ExtractAccessList(p)
- if err != nil {
- return true, nil
- }
- return len(is) == 0, nil
-}
-
-// ExtractAccessList accepts a Page struct, specifically an AccessListPage
-// struct, and extracts the elements into a slice of NetworkItem structs. In
-// other words, a generic collection is mapped into a relevant slice.
-func ExtractAccessList(page pagination.Page) (AccessList, error) {
- var resp struct {
- List AccessList `mapstructure:"accessList" json:"accessList"`
- }
-
- err := mapstructure.Decode(page.(AccessListPage).Body, &resp)
-
- 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/acl/urls.go b/rackspace/lb/v1/acl/urls.go
deleted file mode 100644
index e373fa1..0000000
--- a/rackspace/lb/v1/acl/urls.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package acl
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-const (
- path = "loadbalancers"
- aclPath = "accesslist"
-)
-
-func resourceURL(c *gophercloud.ServiceClient, lbID, networkID int) string {
- return c.ServiceURL(path, strconv.Itoa(lbID), aclPath, strconv.Itoa(networkID))
-}
-
-func rootURL(c *gophercloud.ServiceClient, lbID int) string {
- return c.ServiceURL(path, strconv.Itoa(lbID), aclPath)
-}
diff --git a/rackspace/lb/v1/lbs/doc.go b/rackspace/lb/v1/lbs/doc.go
deleted file mode 100644
index 05f0032..0000000
--- a/rackspace/lb/v1/lbs/doc.go
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-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. 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 insecure
-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 have not yet
-been finalized. Load balancers in a SUSPENDED status are configured to reject
-traffic and do not forward requests to back-end nodes.
-
-An 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 which 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, provides the needed
-information to the underlying application servers.
-*/
-package lbs
diff --git a/rackspace/lb/v1/lbs/fixtures.go b/rackspace/lb/v1/lbs/fixtures.go
deleted file mode 100644
index 6325310..0000000
--- a/rackspace/lb/v1/lbs/fixtures.go
+++ /dev/null
@@ -1,584 +0,0 @@
-package lbs
-
-import (
- "fmt"
- "net/http"
- "strconv"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func mockListLBResponse(t *testing.T) {
- th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "loadBalancers":[
- {
- "name":"lb-site1",
- "id":71,
- "protocol":"HTTP",
- "port":80,
- "algorithm":"RANDOM",
- "status":"ACTIVE",
- "nodeCount":3,
- "virtualIps":[
- {
- "id":403,
- "address":"206.55.130.1",
- "type":"PUBLIC",
- "ipVersion":"IPV4"
- }
- ],
- "created":{
- "time":"2010-11-30T03:23:42Z"
- },
- "updated":{
- "time":"2010-11-30T03:23:44Z"
- }
- },
- {
- "name":"lb-site2",
- "id":72,
- "created":{
- "time":"2011-11-30T03:23:42Z"
- },
- "updated":{
- "time":"2011-11-30T03:23:44Z"
- }
- },
- {
- "name":"lb-site3",
- "id":73,
- "created":{
- "time":"2012-11-30T03:23:42Z"
- },
- "updated":{
- "time":"2012-11-30T03:23:44Z"
- }
- }
- ]
-}
- `)
- })
-}
-
-func mockCreateLBResponse(t *testing.T) {
- th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "loadBalancer": {
- "name": "a-new-loadbalancer",
- "port": 80,
- "protocol": "HTTP",
- "virtualIps": [
- {
- "id": 2341
- },
- {
- "id": 900001
- }
- ],
- "nodes": [
- {
- "address": "10.1.1.1",
- "port": 80,
- "condition": "ENABLED"
- }
- ]
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusAccepted)
-
- fmt.Fprintf(w, `
-{
- "loadBalancer": {
- "name": "a-new-loadbalancer",
- "id": 144,
- "protocol": "HTTP",
- "halfClosed": false,
- "port": 83,
- "algorithm": "RANDOM",
- "status": "BUILD",
- "timeout": 30,
- "cluster": {
- "name": "ztm-n01.staging1.lbaas.rackspace.net"
- },
- "nodes": [
- {
- "address": "10.1.1.1",
- "id": 653,
- "port": 80,
- "status": "ONLINE",
- "condition": "ENABLED",
- "weight": 1
- }
- ],
- "virtualIps": [
- {
- "address": "206.10.10.210",
- "id": 39,
- "type": "PUBLIC",
- "ipVersion": "IPV4"
- },
- {
- "address": "2001:4801:79f1:0002:711b:be4c:0000:0021",
- "id": 900001,
- "type": "PUBLIC",
- "ipVersion": "IPV6"
- }
- ],
- "created": {
- "time": "2010-11-30T03:23:42Z"
- },
- "updated": {
- "time": "2010-11-30T03:23:44Z"
- },
- "connectionLogging": {
- "enabled": false
- }
- }
-}
- `)
- })
-}
-
-func mockBatchDeleteLBResponse(t *testing.T, ids []int) {
- th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- r.ParseForm()
-
- for k, v := range ids {
- fids := r.Form["id"]
- th.AssertEquals(t, strconv.Itoa(v), fids[k])
- }
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockDeleteLBResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockGetLBResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "loadBalancer": {
- "id": 2000,
- "name": "sample-loadbalancer",
- "protocol": "HTTP",
- "port": 80,
- "algorithm": "RANDOM",
- "status": "ACTIVE",
- "timeout": 30,
- "connectionLogging": {
- "enabled": true
- },
- "virtualIps": [
- {
- "id": 1000,
- "address": "206.10.10.210",
- "type": "PUBLIC",
- "ipVersion": "IPV4"
- }
- ],
- "nodes": [
- {
- "id": 1041,
- "address": "10.1.1.1",
- "port": 80,
- "condition": "ENABLED",
- "status": "ONLINE"
- },
- {
- "id": 1411,
- "address": "10.1.1.2",
- "port": 80,
- "condition": "ENABLED",
- "status": "ONLINE"
- }
- ],
- "sessionPersistence": {
- "persistenceType": "HTTP_COOKIE"
- },
- "connectionThrottle": {
- "maxConnections": 100
- },
- "cluster": {
- "name": "c1.dfw1"
- },
- "created": {
- "time": "2010-11-30T03:23:42Z"
- },
- "updated": {
- "time": "2010-11-30T03:23:44Z"
- },
- "sourceAddresses": {
- "ipv6Public": "2001:4801:79f1:1::1/64",
- "ipv4Servicenet": "10.0.0.0",
- "ipv4Public": "10.12.99.28"
- }
- }
-}
- `)
- })
-}
-
-func mockUpdateLBResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "loadBalancer": {
- "name": "a-new-loadbalancer",
- "protocol": "TCP",
- "halfClosed": true,
- "algorithm": "RANDOM",
- "port": 8080,
- "timeout": 100,
- "httpsRedirect": false
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockListProtocolsResponse(t *testing.T) {
- th.Mux.HandleFunc("/loadbalancers/protocols", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "protocols": [
- {
- "name": "DNS_TCP",
- "port": 53
- },
- {
- "name": "DNS_UDP",
- "port": 53
- },
- {
- "name": "FTP",
- "port": 21
- },
- {
- "name": "HTTP",
- "port": 80
- },
- {
- "name": "HTTPS",
- "port": 443
- },
- {
- "name": "IMAPS",
- "port": 993
- },
- {
- "name": "IMAPv4",
- "port": 143
- },
- {
- "name": "LDAP",
- "port": 389
- },
- {
- "name": "LDAPS",
- "port": 636
- },
- {
- "name": "MYSQL",
- "port": 3306
- },
- {
- "name": "POP3",
- "port": 110
- },
- {
- "name": "POP3S",
- "port": 995
- },
- {
- "name": "SMTP",
- "port": 25
- },
- {
- "name": "TCP",
- "port": 0
- },
- {
- "name": "TCP_CLIENT_FIRST",
- "port": 0
- },
- {
- "name": "UDP",
- "port": 0
- },
- {
- "name": "UDP_STREAM",
- "port": 0
- },
- {
- "name": "SFTP",
- "port": 22
- },
- {
- "name": "TCP_STREAM",
- "port": 0
- }
- ]
-}
- `)
- })
-}
-
-func mockListAlgorithmsResponse(t *testing.T) {
- th.Mux.HandleFunc("/loadbalancers/algorithms", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "algorithms": [
- {
- "name": "LEAST_CONNECTIONS"
- },
- {
- "name": "RANDOM"
- },
- {
- "name": "ROUND_ROBIN"
- },
- {
- "name": "WEIGHTED_LEAST_CONNECTIONS"
- },
- {
- "name": "WEIGHTED_ROUND_ROBIN"
- }
- ]
-}
- `)
- })
-}
-
-func mockGetLoggingResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "connectionLogging": {
- "enabled": true
- }
-}
- `)
- })
-}
-
-func mockEnableLoggingResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "connectionLogging":{
- "enabled":true
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockDisableLoggingResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "connectionLogging":{
- "enabled":false
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockGetErrorPageResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "errorpage": {
- "content": "<html>DEFAULT ERROR PAGE</html>"
- }
-}
- `)
- })
-}
-
-func mockSetErrorPageResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "errorpage": {
- "content": "<html>New error page</html>"
- }
-}
- `)
-
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "errorpage": {
- "content": "<html>New error page</html>"
- }
-}
- `)
- })
-}
-
-func mockDeleteErrorPageResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusOK)
- })
-}
-
-func mockGetStatsResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/stats", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "connectTimeOut": 10,
- "connectError": 20,
- "connectFailure": 30,
- "dataTimedOut": 40,
- "keepAliveTimedOut": 50,
- "maxConn": 60,
- "currentConn": 40,
- "connectTimeOutSsl": 10,
- "connectErrorSsl": 20,
- "connectFailureSsl": 30,
- "dataTimedOutSsl": 40,
- "keepAliveTimedOutSsl": 50,
- "maxConnSsl": 60,
- "currentConnSsl": 40
-}
- `)
- })
-}
-
-func mockGetCachingResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "contentCaching": {
- "enabled": true
- }
-}
- `)
- })
-}
-
-func mockEnableCachingResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "contentCaching":{
- "enabled":true
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockDisableCachingResponse(t *testing.T, id int) {
- th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "contentCaching":{
- "enabled":false
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
diff --git a/rackspace/lb/v1/lbs/requests.go b/rackspace/lb/v1/lbs/requests.go
deleted file mode 100644
index 46f5f02..0000000
--- a/rackspace/lb/v1/lbs/requests.go
+++ /dev/null
@@ -1,497 +0,0 @@
-package lbs
-
-import (
- "errors"
-
- "github.com/mitchellh/mapstructure"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
- "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 {
- ToLBListQuery() (string, error)
-}
-
-// ListOpts allows the filtering and sorting of paginated collections through
-// the API.
-type ListOpts struct {
- ChangesSince string `q:"changes-since"`
- Status Status `q:"status"`
- NodeAddr string `q:"nodeaddress"`
- Marker string `q:"marker"`
- Limit int `q:"limit"`
-}
-
-// ToLBListQuery formats a ListOpts into a query string.
-func (opts ListOpts) ToLBListQuery() (string, error) {
- q, err := gophercloud.BuildQueryString(opts)
- if err != nil {
- return "", err
- }
- 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 {
- query, err := opts.ToLBListQuery()
- if err != nil {
- return pagination.Pager{Err: err}
- }
- url += query
- }
-
- return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
- return LBPage{pagination.LinkedPageBase{PageResult: r}}
- })
-}
-
-// 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
-// satisfy a basic interface in order for them to be used.
-type CreateOptsBuilder interface {
- ToLBCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts is the common options struct used in this package's Create
-// operation.
-type CreateOpts struct {
- // Required - name of the load balancer to create. The name must be 128
- // characters or fewer in length, and all UTF-8 characters are valid.
- Name string
-
- // Optional - nodes to be added.
- Nodes []nodes.Node
-
- // Required - protocol of the service that is being load balanced.
- // See http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/protocols.html
- // for a full list of supported protocols.
- Protocol string
-
- // Optional - enables or disables Half-Closed support for the load balancer.
- // 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 gophercloud.EnabledState
-
- // Optional - the type of virtual IPs you want associated with the load
- // balancer.
- VIPs []vips.VIP
-
- // Optional - the access list management feature allows fine-grained network
- // access controls to be applied to the load balancer virtual IP address.
- AccessList *acl.AccessList
-
- // Optional - algorithm that defines how traffic should be directed between
- // back-end nodes.
- Algorithm string
-
- // Optional - current connection logging configuration.
- ConnectionLogging *ConnectionLogging
-
- // Optional - specifies a limit on the number of connections per IP address
- // to help mitigate malicious or abusive traffic to your applications.
- ConnThrottle *throttle.ConnectionThrottle
-
- // Optional - the type of health monitor check to perform to ensure that the
- // service is performing properly.
- HealthMonitor *monitors.Monitor
-
- // Optional - arbitrary information that can be associated with each LB.
- Metadata map[string]interface{}
-
- // Optional - port number for the service you are load balancing.
- Port int
-
- // Optional - the timeout value for the load balancer and communications with
- // its nodes. Defaults to 30 seconds with a maximum of 120 seconds.
- Timeout int
-
- // Optional - specifies whether multiple requests from clients are directed
- // to the same node.
- SessionPersistence *sessions.SessionPersistence
-
- // Optional - enables or disables HTTP to HTTPS redirection for the load
- // balancer. When enabled, any HTTP request returns status code 301 (Moved
- // Permanently), and the requester is redirected to the requested URL via the
- // HTTPS protocol on port 443. For example, http://example.com/page.html
- // 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 gophercloud.EnabledState
-}
-
-// ToLBCreateMap casts a CreateOpts struct to a map.
-func (opts CreateOpts) ToLBCreateMap() (map[string]interface{}, error) {
- lb := make(map[string]interface{})
-
- if opts.Name == "" {
- return lb, errNameRequired
- }
- if opts.Timeout > 120 {
- return lb, errTimeoutExceeded
- }
-
- lb["name"] = opts.Name
-
- if len(opts.Nodes) > 0 {
- nodes := []map[string]interface{}{}
- for _, n := range opts.Nodes {
- nodes = append(nodes, map[string]interface{}{
- "address": n.Address,
- "port": n.Port,
- "condition": n.Condition,
- })
- }
- lb["nodes"] = nodes
- }
-
- if opts.Protocol != "" {
- lb["protocol"] = opts.Protocol
- }
- if opts.HalfClosed != nil {
- lb["halfClosed"] = opts.HalfClosed
- }
- if len(opts.VIPs) > 0 {
- lb["virtualIps"] = opts.VIPs
- }
- if opts.AccessList != nil {
- lb["accessList"] = &opts.AccessList
- }
- if opts.Algorithm != "" {
- lb["algorithm"] = opts.Algorithm
- }
- if opts.ConnectionLogging != nil {
- lb["connectionLogging"] = &opts.ConnectionLogging
- }
- if opts.ConnThrottle != nil {
- lb["connectionThrottle"] = &opts.ConnThrottle
- }
- if opts.HealthMonitor != nil {
- lb["healthMonitor"] = &opts.HealthMonitor
- }
- if len(opts.Metadata) != 0 {
- lb["metadata"] = opts.Metadata
- }
- if opts.Port > 0 {
- lb["port"] = opts.Port
- }
- if opts.Timeout > 0 {
- lb["timeout"] = opts.Timeout
- }
- if opts.SessionPersistence != nil {
- lb["sessionPersistence"] = &opts.SessionPersistence
- }
- if opts.HTTPSRedirect != nil {
- lb["httpsRedirect"] = &opts.HTTPSRedirect
- }
-
- 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, an 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
-
- reqBody, err := opts.ToLBCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
- 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
-
- _, res.Err = c.Get(resourceURL(c, id), &res.Body, &gophercloud.RequestOpts{
- OkCodes: []int{200},
- })
-
- return res
-}
-
-// BulkDelete removes all the load balancers referenced in the slice of IDs.
-// Any and all configuration data associated with these load balancers is
-// 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
-
- if len(ids) > 10 || len(ids) == 0 {
- res.Err = errors.New("You must provide a minimum of 1 and a maximum of 10 LB IDs")
- return res
- }
-
- url := rootURL(c)
- url += gophercloud.IDSliceToQueryString("id", ids)
-
- _, res.Err = c.Delete(url, nil)
- return res
-}
-
-// Delete removes a single load balancer.
-func Delete(c *gophercloud.ServiceClient, id int) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(resourceURL(c, id), nil)
- 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 represents 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.
- // See http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/protocols.html
- // for a full list of supported protocols.
- Protocol string
-
- // Optional - see the HalfClosed field in CreateOpts for more information.
- HalfClosed gophercloud.EnabledState
-
- // Optional - see the Algorithm field in CreateOpts for more information.
- Algorithm string
-
- // 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 gophercloud.EnabledState
-}
-
-// ToLBUpdateMap casts an UpdateOpts struct to a map.
-func (opts UpdateOpts) ToLBUpdateMap() (map[string]interface{}, error) {
- lb := make(map[string]interface{})
-
- if opts.Name != "" {
- lb["name"] = opts.Name
- }
- if opts.Protocol != "" {
- lb["protocol"] = opts.Protocol
- }
- if opts.HalfClosed != nil {
- lb["halfClosed"] = opts.HalfClosed
- }
- if opts.Algorithm != "" {
- lb["algorithm"] = opts.Algorithm
- }
- if opts.Port > 0 {
- lb["port"] = opts.Port
- }
- if opts.Timeout > 0 {
- lb["timeout"] = opts.Timeout
- }
- if opts.HTTPSRedirect != nil {
- lb["httpsRedirect"] = &opts.HTTPSRedirect
- }
-
- 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
-
- reqBody, err := opts.ToLBUpdateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Put(resourceURL(c, id), reqBody, nil, nil)
- return res
-}
-
-// ListProtocols is the operation responsible for returning a paginated
-// collection of load balancer protocols.
-func ListProtocols(client *gophercloud.ServiceClient) pagination.Pager {
- url := protocolsURL(client)
- return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
- return ProtocolPage{pagination.SinglePageBase(r)}
- })
-}
-
-// ListAlgorithms is the operation responsible for returning a paginated
-// collection of load balancer algorithms.
-func ListAlgorithms(client *gophercloud.ServiceClient) pagination.Pager {
- url := algorithmsURL(client)
- return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
- return AlgorithmPage{pagination.SinglePageBase(r)}
- })
-}
-
-// IsLoggingEnabled returns true if the load balancer has connection logging
-// enabled and false if not.
-func IsLoggingEnabled(client *gophercloud.ServiceClient, id int) (bool, error) {
- var body interface{}
-
- _, err := client.Get(loggingURL(client, id), &body, nil)
- if err != nil {
- return false, err
- }
-
- var resp struct {
- CL struct {
- Enabled bool `mapstructure:"enabled"`
- } `mapstructure:"connectionLogging"`
- }
-
- err = mapstructure.Decode(body, &resp)
- return resp.CL.Enabled, err
-}
-
-func toConnLoggingMap(state bool) map[string]map[string]bool {
- return map[string]map[string]bool{
- "connectionLogging": map[string]bool{"enabled": state},
- }
-}
-
-// EnableLogging will enable connection logging for a specified load balancer.
-func EnableLogging(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- var res gophercloud.ErrResult
- _, res.Err = client.Put(loggingURL(client, id), toConnLoggingMap(true), nil, nil)
- return res
-}
-
-// DisableLogging will disable connection logging for a specified load balancer.
-func DisableLogging(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- var res gophercloud.ErrResult
- _, res.Err = client.Put(loggingURL(client, id), toConnLoggingMap(false), nil, nil)
- return res
-}
-
-// GetErrorPage will retrieve the current error page for the load balancer.
-func GetErrorPage(client *gophercloud.ServiceClient, id int) ErrorPageResult {
- var res ErrorPageResult
- _, res.Err = client.Get(errorPageURL(client, id), &res.Body, nil)
- return res
-}
-
-// SetErrorPage will set the HTML of the load balancer's error page to a
-// specific value.
-func SetErrorPage(client *gophercloud.ServiceClient, id int, html string) ErrorPageResult {
- var res ErrorPageResult
-
- type stringMap map[string]string
- reqBody := map[string]stringMap{"errorpage": stringMap{"content": html}}
-
- _, res.Err = client.Put(errorPageURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
- OkCodes: []int{200},
- })
-
- return res
-}
-
-// DeleteErrorPage will delete the current error page for the load balancer.
-func DeleteErrorPage(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- var res gophercloud.ErrResult
- _, res.Err = client.Delete(errorPageURL(client, id), &gophercloud.RequestOpts{
- OkCodes: []int{200},
- })
- return res
-}
-
-// GetStats will retrieve detailed stats related to the load balancer's usage.
-func GetStats(client *gophercloud.ServiceClient, id int) StatsResult {
- var res StatsResult
- _, res.Err = client.Get(statsURL(client, id), &res.Body, nil)
- return res
-}
-
-// IsContentCached will check to see whether the specified load balancer caches
-// content. When content caching is enabled, recently-accessed files are stored
-// on the load balancer for easy retrieval by web clients. Content caching
-// improves the performance of high traffic web sites by temporarily storing
-// data that was recently accessed. While it's cached, requests for that data
-// are served by the load balancer, which in turn reduces load off the back-end
-// nodes. The result is improved response times for those requests and less
-// load on the web server.
-func IsContentCached(client *gophercloud.ServiceClient, id int) (bool, error) {
- var body interface{}
-
- _, err := client.Get(cacheURL(client, id), &body, nil)
- if err != nil {
- return false, err
- }
-
- var resp struct {
- CC struct {
- Enabled bool `mapstructure:"enabled"`
- } `mapstructure:"contentCaching"`
- }
-
- err = mapstructure.Decode(body, &resp)
- return resp.CC.Enabled, err
-}
-
-func toCachingMap(state bool) map[string]map[string]bool {
- return map[string]map[string]bool{
- "contentCaching": map[string]bool{"enabled": state},
- }
-}
-
-// EnableCaching will enable content-caching for the specified load balancer.
-func EnableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- var res gophercloud.ErrResult
- _, res.Err = client.Put(cacheURL(client, id), toCachingMap(true), nil, nil)
- return res
-}
-
-// DisableCaching will disable content-caching for the specified load balancer.
-func DisableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- var res gophercloud.ErrResult
- _, res.Err = client.Put(cacheURL(client, id), toCachingMap(false), nil, nil)
- return res
-}
diff --git a/rackspace/lb/v1/lbs/requests_test.go b/rackspace/lb/v1/lbs/requests_test.go
deleted file mode 100644
index a8ec19e..0000000
--- a/rackspace/lb/v1/lbs/requests_test.go
+++ /dev/null
@@ -1,438 +0,0 @@
-package lbs
-
-import (
- "testing"
- "time"
-
- "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"
-)
-
-const (
- id1 = 12345
- id2 = 67890
- ts1 = "2010-11-30T03:23:42Z"
- ts2 = "2010-11-30T03:23:44Z"
-)
-
-func toTime(t *testing.T, str string) time.Time {
- ts, err := time.Parse(time.RFC3339, str)
- if err != nil {
- t.Fatalf("Could not parse time: %s", err.Error())
- }
- return ts
-}
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListLBResponse(t)
-
- count := 0
-
- err := List(client.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractLBs(page)
- th.AssertNoErr(t, err)
-
- expected := []LoadBalancer{
- LoadBalancer{
- Name: "lb-site1",
- ID: 71,
- Protocol: "HTTP",
- Port: 80,
- Algorithm: "RANDOM",
- Status: ACTIVE,
- NodeCount: 3,
- VIPs: []vips.VIP{
- vips.VIP{
- ID: 403,
- Address: "206.55.130.1",
- Type: "PUBLIC",
- Version: "IPV4",
- },
- },
- Created: Datetime{Time: toTime(t, ts1)},
- Updated: Datetime{Time: toTime(t, ts2)},
- },
- LoadBalancer{
- ID: 72,
- Name: "lb-site2",
- Created: Datetime{Time: toTime(t, "2011-11-30T03:23:42Z")},
- Updated: Datetime{Time: toTime(t, "2011-11-30T03:23:44Z")},
- },
- LoadBalancer{
- ID: 73,
- Name: "lb-site3",
- Created: Datetime{Time: toTime(t, "2012-11-30T03:23:42Z")},
- Updated: Datetime{Time: toTime(t, "2012-11-30T03:23:44Z")},
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockCreateLBResponse(t)
-
- opts := CreateOpts{
- Name: "a-new-loadbalancer",
- Port: 80,
- Protocol: "HTTP",
- VIPs: []vips.VIP{
- vips.VIP{ID: 2341},
- vips.VIP{ID: 900001},
- },
- Nodes: []nodes.Node{
- nodes.Node{Address: "10.1.1.1", Port: 80, Condition: "ENABLED"},
- },
- }
-
- lb, err := Create(client.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
-
- expected := &LoadBalancer{
- Name: "a-new-loadbalancer",
- ID: 144,
- Protocol: "HTTP",
- HalfClosed: false,
- Port: 83,
- Algorithm: "RANDOM",
- Status: BUILD,
- Timeout: 30,
- Cluster: Cluster{Name: "ztm-n01.staging1.lbaas.rackspace.net"},
- Nodes: []nodes.Node{
- nodes.Node{
- Address: "10.1.1.1",
- ID: 653,
- Port: 80,
- Status: "ONLINE",
- Condition: "ENABLED",
- Weight: 1,
- },
- },
- VIPs: []vips.VIP{
- vips.VIP{
- ID: 39,
- Address: "206.10.10.210",
- Type: vips.PUBLIC,
- Version: vips.IPV4,
- },
- vips.VIP{
- ID: 900001,
- Address: "2001:4801:79f1:0002:711b:be4c:0000:0021",
- Type: vips.PUBLIC,
- Version: vips.IPV6,
- },
- },
- Created: Datetime{Time: toTime(t, ts1)},
- Updated: Datetime{Time: toTime(t, ts2)},
- ConnectionLogging: ConnectionLogging{Enabled: false},
- }
-
- th.AssertDeepEquals(t, expected, lb)
-}
-
-func TestBulkDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- ids := []int{id1, id2}
-
- mockBatchDeleteLBResponse(t, ids)
-
- err := BulkDelete(client.ServiceClient(), ids).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteLBResponse(t, id1)
-
- err := Delete(client.ServiceClient(), id1).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetLBResponse(t, id1)
-
- lb, err := Get(client.ServiceClient(), id1).Extract()
-
- expected := &LoadBalancer{
- Name: "sample-loadbalancer",
- ID: 2000,
- Protocol: "HTTP",
- Port: 80,
- Algorithm: "RANDOM",
- Status: ACTIVE,
- Timeout: 30,
- ConnectionLogging: ConnectionLogging{Enabled: true},
- VIPs: []vips.VIP{
- vips.VIP{
- ID: 1000,
- Address: "206.10.10.210",
- Type: "PUBLIC",
- Version: "IPV4",
- },
- },
- Nodes: []nodes.Node{
- nodes.Node{
- Address: "10.1.1.1",
- ID: 1041,
- Port: 80,
- Status: "ONLINE",
- Condition: "ENABLED",
- },
- nodes.Node{
- Address: "10.1.1.2",
- ID: 1411,
- Port: 80,
- Status: "ONLINE",
- Condition: "ENABLED",
- },
- },
- SessionPersistence: sessions.SessionPersistence{Type: "HTTP_COOKIE"},
- ConnectionThrottle: throttle.ConnectionThrottle{MaxConnections: 100},
- Cluster: Cluster{Name: "c1.dfw1"},
- Created: Datetime{Time: toTime(t, ts1)},
- Updated: Datetime{Time: toTime(t, ts2)},
- SourceAddrs: SourceAddrs{
- IPv4Public: "10.12.99.28",
- IPv4Private: "10.0.0.0",
- IPv6Public: "2001:4801:79f1:1::1/64",
- },
- }
-
- th.AssertDeepEquals(t, expected, lb)
- th.AssertNoErr(t, err)
-}
-
-func TestUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockUpdateLBResponse(t, id1)
-
- opts := UpdateOpts{
- Name: "a-new-loadbalancer",
- Protocol: "TCP",
- HalfClosed: gophercloud.Enabled,
- Algorithm: "RANDOM",
- Port: 8080,
- Timeout: 100,
- HTTPSRedirect: gophercloud.Disabled,
- }
-
- err := Update(client.ServiceClient(), id1, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestListProtocols(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListProtocolsResponse(t)
-
- count := 0
-
- err := ListProtocols(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractProtocols(page)
- th.AssertNoErr(t, err)
-
- expected := []Protocol{
- Protocol{Name: "DNS_TCP", Port: 53},
- Protocol{Name: "DNS_UDP", Port: 53},
- Protocol{Name: "FTP", Port: 21},
- Protocol{Name: "HTTP", Port: 80},
- Protocol{Name: "HTTPS", Port: 443},
- Protocol{Name: "IMAPS", Port: 993},
- Protocol{Name: "IMAPv4", Port: 143},
- }
-
- th.CheckDeepEquals(t, expected[0:7], actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestListAlgorithms(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListAlgorithmsResponse(t)
-
- count := 0
-
- err := ListAlgorithms(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractAlgorithms(page)
- th.AssertNoErr(t, err)
-
- expected := []Algorithm{
- Algorithm{Name: "LEAST_CONNECTIONS"},
- Algorithm{Name: "RANDOM"},
- Algorithm{Name: "ROUND_ROBIN"},
- Algorithm{Name: "WEIGHTED_LEAST_CONNECTIONS"},
- Algorithm{Name: "WEIGHTED_ROUND_ROBIN"},
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestIsLoggingEnabled(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetLoggingResponse(t, id1)
-
- res, err := IsLoggingEnabled(client.ServiceClient(), id1)
- th.AssertNoErr(t, err)
- th.AssertEquals(t, true, res)
-}
-
-func TestEnablingLogging(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockEnableLoggingResponse(t, id1)
-
- err := EnableLogging(client.ServiceClient(), id1).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDisablingLogging(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDisableLoggingResponse(t, id1)
-
- err := DisableLogging(client.ServiceClient(), id1).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGetErrorPage(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetErrorPageResponse(t, id1)
-
- content, err := GetErrorPage(client.ServiceClient(), id1).Extract()
- th.AssertNoErr(t, err)
-
- expected := &ErrorPage{Content: "<html>DEFAULT ERROR PAGE</html>"}
- th.AssertDeepEquals(t, expected, content)
-}
-
-func TestSetErrorPage(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockSetErrorPageResponse(t, id1)
-
- html := "<html>New error page</html>"
- content, err := SetErrorPage(client.ServiceClient(), id1, html).Extract()
- th.AssertNoErr(t, err)
-
- expected := &ErrorPage{Content: html}
- th.AssertDeepEquals(t, expected, content)
-}
-
-func TestDeleteErrorPage(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteErrorPageResponse(t, id1)
-
- err := DeleteErrorPage(client.ServiceClient(), id1).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGetStats(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetStatsResponse(t, id1)
-
- content, err := GetStats(client.ServiceClient(), id1).Extract()
- th.AssertNoErr(t, err)
-
- expected := &Stats{
- ConnectTimeout: 10,
- ConnectError: 20,
- ConnectFailure: 30,
- DataTimedOut: 40,
- KeepAliveTimedOut: 50,
- MaxConnections: 60,
- CurrentConnections: 40,
- SSLConnectTimeout: 10,
- SSLConnectError: 20,
- SSLConnectFailure: 30,
- SSLDataTimedOut: 40,
- SSLKeepAliveTimedOut: 50,
- SSLMaxConnections: 60,
- SSLCurrentConnections: 40,
- }
- th.AssertDeepEquals(t, expected, content)
-}
-
-func TestIsCached(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetCachingResponse(t, id1)
-
- res, err := IsContentCached(client.ServiceClient(), id1)
- th.AssertNoErr(t, err)
- th.AssertEquals(t, true, res)
-}
-
-func TestEnablingCaching(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockEnableCachingResponse(t, id1)
-
- err := EnableCaching(client.ServiceClient(), id1).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDisablingCaching(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDisableCachingResponse(t, id1)
-
- err := DisableCaching(client.ServiceClient(), id1).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/lb/v1/lbs/results.go b/rackspace/lb/v1/lbs/results.go
deleted file mode 100644
index 98f3962..0000000
--- a/rackspace/lb/v1/lbs/results.go
+++ /dev/null
@@ -1,420 +0,0 @@
-package lbs
-
-import (
- "reflect"
- "time"
-
- "github.com/mitchellh/mapstructure"
-
- "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"
-)
-
-// Protocol represents the network protocol which the load balancer accepts.
-type Protocol struct {
- // The name of the protocol, e.g. HTTP, LDAP, FTP, etc.
- Name string
-
- // The port number for the protocol.
- Port int
-}
-
-// Algorithm defines how traffic should be directed between back-end nodes.
-type Algorithm struct {
- // The name of the algorithm, e.g RANDOM, ROUND_ROBIN, etc.
- Name string
-}
-
-// Status represents the potential state of a load balancer resource.
-type Status string
-
-const (
- // ACTIVE indicates that the LB is configured properly and ready to serve
- // traffic to incoming requests via the configured virtual IPs.
- ACTIVE Status = "ACTIVE"
-
- // BUILD indicates that the LB is being provisioned for the first time and
- // configuration is being applied to bring the service online. The service
- // cannot yet serve incoming requests.
- BUILD Status = "BUILD"
-
- // PENDINGUPDATE indicates that the LB is online but configuration changes
- // are being applied to update the service based on a previous request.
- PENDINGUPDATE Status = "PENDING_UPDATE"
-
- // PENDINGDELETE indicates that the LB is online but configuration changes
- // are being applied to begin deletion of the service based on a previous
- // request.
- PENDINGDELETE Status = "PENDING_DELETE"
-
- // SUSPENDED indicates that the LB has been taken offline and disabled.
- SUSPENDED Status = "SUSPENDED"
-
- // ERROR indicates that the system encountered an error when attempting to
- // configure the load balancer.
- ERROR Status = "ERROR"
-
- // DELETED indicates that the LB has been deleted.
- DELETED Status = "DELETED"
-)
-
-// Datetime represents the structure of a Created or Updated field.
-type Datetime struct {
- Time time.Time `mapstructure:"-"`
-}
-
-// LoadBalancer represents a load balancer API resource.
-type LoadBalancer struct {
- // Human-readable name for the load balancer.
- Name string
-
- // The unique ID for the load balancer.
- ID int
-
- // Represents the service protocol being load balanced. See Protocol type for
- // a list of accepted values.
- // See http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/protocols.html
- // for a full list of supported protocols.
- Protocol string
-
- // Defines how traffic should be directed between back-end nodes. The default
- // algorithm is RANDOM. See Algorithm type for a list of accepted values.
- Algorithm string
-
- // The current status of the load balancer.
- Status Status
-
- // The number of load balancer nodes.
- NodeCount int `mapstructure:"nodeCount"`
-
- // Slice of virtual IPs associated with this load balancer.
- VIPs []vips.VIP `mapstructure:"virtualIps"`
-
- // Datetime when the LB was created.
- Created Datetime
-
- // 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
-
- // The cluster name.
- 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
-
- // Current connection logging configuration.
- ConnectionLogging ConnectionLogging
-
- // SessionPersistence specifies whether multiple requests from clients are
- // directed to the same node.
- SessionPersistence sessions.SessionPersistence
-
- // ConnectionThrottle specifies a limit on the number of connections per IP
- // address to help mitigate malicious or abusive traffic to your applications.
- ConnectionThrottle throttle.ConnectionThrottle
-
- // The source public and private IP addresses.
- 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 represents the source public and private IP addresses.
-type SourceAddrs struct {
- IPv4Public string `json:"ipv4Public" mapstructure:"ipv4Public"`
- IPv4Private string `json:"ipv4Servicenet" mapstructure:"ipv4Servicenet"`
- IPv6Public string `json:"ipv6Public" mapstructure:"ipv6Public"`
- IPv6Private string `json:"ipv6Servicenet" mapstructure:"ipv6Servicenet"`
-}
-
-// ConnectionLogging - temp
-type ConnectionLogging struct {
- Enabled bool
-}
-
-// Cluster - temp
-type Cluster struct {
- Name string
-}
-
-// LBPage is the page returned by a pager when traversing over a collection of
-// LBs.
-type LBPage struct {
- pagination.LinkedPageBase
-}
-
-// IsEmpty checks whether a NetworkPage struct is empty.
-func (p LBPage) IsEmpty() (bool, error) {
- is, err := ExtractLBs(p)
- if err != nil {
- return true, nil
- }
- return len(is) == 0, nil
-}
-
-// ExtractLBs accepts a Page struct, specifically a LBPage struct, and extracts
-// the elements into a slice of LoadBalancer structs. In other words, a generic
-// collection is mapped into a relevant slice.
-func ExtractLBs(page pagination.Page) ([]LoadBalancer, error) {
- var resp struct {
- LBs []LoadBalancer `mapstructure:"loadBalancers" json:"loadBalancers"`
- }
-
- coll := page.(LBPage).Body
- err := mapstructure.Decode(coll, &resp)
-
- s := reflect.ValueOf(coll.(map[string]interface{})["loadBalancers"])
-
- for i := 0; i < s.Len(); i++ {
- val := (s.Index(i).Interface()).(map[string]interface{})
-
- ts, err := extractTS(val, "created")
- if err != nil {
- return resp.LBs, err
- }
- resp.LBs[i].Created.Time = ts
-
- ts, err = extractTS(val, "updated")
- if err != nil {
- return resp.LBs, err
- }
- resp.LBs[i].Updated.Time = ts
- }
-
- return resp.LBs, err
-}
-
-func extractTS(body map[string]interface{}, key string) (time.Time, error) {
- val := body[key].(map[string]interface{})
- return time.Parse(time.RFC3339, val["time"].(string))
-}
-
-type commonResult struct {
- gophercloud.Result
-}
-
-// Extract interprets any commonResult as a LB, if possible.
-func (r commonResult) Extract() (*LoadBalancer, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- LB LoadBalancer `mapstructure:"loadBalancer"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- json := r.Body.(map[string]interface{})
- lb := json["loadBalancer"].(map[string]interface{})
-
- ts, err := extractTS(lb, "created")
- if err != nil {
- return nil, err
- }
- response.LB.Created.Time = ts
-
- ts, err = extractTS(lb, "updated")
- if err != nil {
- return nil, err
- }
- response.LB.Updated.Time = ts
-
- 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
-}
-
-// ProtocolPage is the page returned by a pager when traversing over a
-// collection of LB protocols.
-type ProtocolPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty checks whether a ProtocolPage struct is empty.
-func (p ProtocolPage) IsEmpty() (bool, error) {
- is, err := ExtractProtocols(p)
- if err != nil {
- return true, nil
- }
- return len(is) == 0, nil
-}
-
-// ExtractProtocols accepts a Page struct, specifically a ProtocolPage struct,
-// and extracts the elements into a slice of Protocol structs. In other
-// words, a generic collection is mapped into a relevant slice.
-func ExtractProtocols(page pagination.Page) ([]Protocol, error) {
- var resp struct {
- Protocols []Protocol `mapstructure:"protocols" json:"protocols"`
- }
- err := mapstructure.Decode(page.(ProtocolPage).Body, &resp)
- return resp.Protocols, err
-}
-
-// AlgorithmPage is the page returned by a pager when traversing over a
-// collection of LB algorithms.
-type AlgorithmPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty checks whether an AlgorithmPage struct is empty.
-func (p AlgorithmPage) IsEmpty() (bool, error) {
- is, err := ExtractAlgorithms(p)
- if err != nil {
- return true, nil
- }
- return len(is) == 0, nil
-}
-
-// ExtractAlgorithms accepts a Page struct, specifically an AlgorithmPage struct,
-// and extracts the elements into a slice of Algorithm structs. In other
-// words, a generic collection is mapped into a relevant slice.
-func ExtractAlgorithms(page pagination.Page) ([]Algorithm, error) {
- var resp struct {
- Algorithms []Algorithm `mapstructure:"algorithms" json:"algorithms"`
- }
- err := mapstructure.Decode(page.(AlgorithmPage).Body, &resp)
- return resp.Algorithms, err
-}
-
-// ErrorPage represents the HTML file that is shown to an end user who is
-// attempting to access a load balancer node that is offline/unavailable.
-//
-// During provisioning, every load balancer is configured with a default error
-// page that gets displayed when traffic is requested for an offline node.
-//
-// You can add a single custom error page with an HTTP-based protocol to a load
-// balancer. Page updates override existing content. If a custom error page is
-// deleted, or the load balancer is changed to a non-HTTP protocol, the default
-// error page is restored.
-type ErrorPage struct {
- Content string
-}
-
-// ErrorPageResult represents the result of an error page operation -
-// specifically getting or creating one.
-type ErrorPageResult struct {
- gophercloud.Result
-}
-
-// Extract interprets any commonResult as an ErrorPage, if possible.
-func (r ErrorPageResult) Extract() (*ErrorPage, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- ErrorPage ErrorPage `mapstructure:"errorpage"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- return &response.ErrorPage, err
-}
-
-// Stats represents all the key information about a load balancer's usage.
-type Stats struct {
- // The number of connections closed by this load balancer because its
- // ConnectTimeout interval was exceeded.
- ConnectTimeout int `mapstructure:"connectTimeOut"`
-
- // The number of transaction or protocol errors for this load balancer.
- ConnectError int
-
- // Number of connection failures for this load balancer.
- ConnectFailure int
-
- // Number of connections closed by this load balancer because its Timeout
- // interval was exceeded.
- DataTimedOut int
-
- // Number of connections closed by this load balancer because the
- // 'keepalive_timeout' interval was exceeded.
- KeepAliveTimedOut int
-
- // The maximum number of simultaneous TCP connections this load balancer has
- // processed at any one time.
- MaxConnections int `mapstructure:"maxConn"`
-
- // Number of simultaneous connections active at the time of the request.
- CurrentConnections int `mapstructure:"currentConn"`
-
- // Number of SSL connections closed by this load balancer because the
- // ConnectTimeout interval was exceeded.
- SSLConnectTimeout int `mapstructure:"connectTimeOutSsl"`
-
- // Number of SSL transaction or protocol erros in this load balancer.
- SSLConnectError int `mapstructure:"connectErrorSsl"`
-
- // Number of SSL connection failures in this load balancer.
- SSLConnectFailure int `mapstructure:"connectFailureSsl"`
-
- // Number of SSL connections closed by this load balancer because the
- // Timeout interval was exceeded.
- SSLDataTimedOut int `mapstructure:"dataTimedOutSsl"`
-
- // Number of SSL connections closed by this load balancer because the
- // 'keepalive_timeout' interval was exceeded.
- SSLKeepAliveTimedOut int `mapstructure:"keepAliveTimedOutSsl"`
-
- // Maximum number of simultaneous SSL connections this load balancer has
- // processed at any one time.
- SSLMaxConnections int `mapstructure:"maxConnSsl"`
-
- // Number of simultaneous SSL connections active at the time of the request.
- SSLCurrentConnections int `mapstructure:"currentConnSsl"`
-}
-
-// StatsResult represents the result of a Stats operation.
-type StatsResult struct {
- gophercloud.Result
-}
-
-// Extract interprets any commonResult as a Stats struct, if possible.
-func (r StatsResult) Extract() (*Stats, error) {
- if r.Err != nil {
- return nil, r.Err
- }
- res := &Stats{}
- err := mapstructure.Decode(r.Body, res)
- return res, err
-}
diff --git a/rackspace/lb/v1/lbs/urls.go b/rackspace/lb/v1/lbs/urls.go
deleted file mode 100644
index 471a86b..0000000
--- a/rackspace/lb/v1/lbs/urls.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package lbs
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-const (
- path = "loadbalancers"
- protocolsPath = "protocols"
- algorithmsPath = "algorithms"
- logPath = "connectionlogging"
- epPath = "errorpage"
- stPath = "stats"
- cachePath = "contentcaching"
-)
-
-func resourceURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id))
-}
-
-func rootURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL(path)
-}
-
-func protocolsURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL(path, protocolsPath)
-}
-
-func algorithmsURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL(path, algorithmsPath)
-}
-
-func loggingURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id), logPath)
-}
-
-func errorPageURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id), epPath)
-}
-
-func statsURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id), stPath)
-}
-
-func cacheURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id), cachePath)
-}
diff --git a/rackspace/lb/v1/monitors/doc.go b/rackspace/lb/v1/monitors/doc.go
deleted file mode 100644
index 2c5be75..0000000
--- a/rackspace/lb/v1/monitors/doc.go
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Package monitors provides information and interaction with the Health Monitor
-API resource for the Rackspace Cloud Load Balancer service.
-
-The load balancing service includes a health monitoring resource that
-periodically checks your back-end nodes to ensure they are responding correctly.
-If a node does not respond, it is removed from rotation until the health monitor
-determines that the node is functional. In addition to being performed
-periodically, a health check also executes against every new node that is
-added, to ensure that the node is operating properly before allowing it to
-service traffic. Only one health monitor is allowed to be enabled on a load
-balancer at a time.
-
-As part of a good strategy for monitoring connections, secondary nodes should
-also be created which provide failover for effectively routing traffic in case
-the primary node fails. This is an additional feature that ensures that you
-remain up in case your primary node fails.
-
-There are three types of health monitor: CONNECT, HTTP and HTTPS.
-*/
-package monitors
diff --git a/rackspace/lb/v1/monitors/fixtures.go b/rackspace/lb/v1/monitors/fixtures.go
deleted file mode 100644
index a565abc..0000000
--- a/rackspace/lb/v1/monitors/fixtures.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package monitors
-
-import (
- "fmt"
- "net/http"
- "strconv"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func _rootURL(lbID int) string {
- return "/loadbalancers/" + strconv.Itoa(lbID) + "/healthmonitor"
-}
-
-func mockGetResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "healthMonitor": {
- "type": "CONNECT",
- "delay": 10,
- "timeout": 10,
- "attemptsBeforeDeactivation": 3
- }
-}
- `)
- })
-}
-
-func mockUpdateConnectResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "healthMonitor": {
- "type": "CONNECT",
- "delay": 10,
- "timeout": 10,
- "attemptsBeforeDeactivation": 3
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockUpdateHTTPResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "healthMonitor": {
- "attemptsBeforeDeactivation": 3,
- "bodyRegex": "{regex}",
- "delay": 10,
- "path": "/foo",
- "statusRegex": "200",
- "timeout": 10,
- "type": "HTTPS"
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockDeleteResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
diff --git a/rackspace/lb/v1/monitors/requests.go b/rackspace/lb/v1/monitors/requests.go
deleted file mode 100644
index d4ba276..0000000
--- a/rackspace/lb/v1/monitors/requests.go
+++ /dev/null
@@ -1,160 +0,0 @@
-package monitors
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
-)
-
-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
-// to be used in the main Update operation in this package.
-type UpdateOptsBuilder interface {
- ToMonitorUpdateMap() (map[string]interface{}, error)
-}
-
-// UpdateConnectMonitorOpts represents the options needed to update a CONNECT
-// monitor.
-type UpdateConnectMonitorOpts struct {
- // Required - number of permissible monitor failures before removing a node
- // from rotation. Must be a number between 1 and 10.
- AttemptLimit int
-
- // Required - the minimum number of seconds to wait before executing the
- // health monitor. Must be a number between 1 and 3600.
- Delay int
-
- // Required - maximum number of seconds to wait for a connection to be
- // established before timing out. Must be a number between 1 and 300.
- Timeout int
-}
-
-// ToMonitorUpdateMap produces a map for updating CONNECT monitors.
-func (opts UpdateConnectMonitorOpts) ToMonitorUpdateMap() (map[string]interface{}, error) {
- type m map[string]interface{}
-
- if !gophercloud.IntWithinRange(opts.AttemptLimit, 1, 10) {
- return m{}, errAttemptLimit
- }
- if !gophercloud.IntWithinRange(opts.Delay, 1, 3600) {
- return m{}, errDelay
- }
- if !gophercloud.IntWithinRange(opts.Timeout, 1, 300) {
- return m{}, errTimeout
- }
-
- return m{"healthMonitor": m{
- "attemptsBeforeDeactivation": opts.AttemptLimit,
- "delay": opts.Delay,
- "timeout": opts.Timeout,
- "type": CONNECT,
- }}, nil
-}
-
-// UpdateHTTPMonitorOpts represents the options needed to update a HTTP monitor.
-type UpdateHTTPMonitorOpts struct {
- // Required - number of permissible monitor failures before removing a node
- // from rotation. Must be a number between 1 and 10.
- AttemptLimit int `mapstructure:"attemptsBeforeDeactivation"`
-
- // Required - the minimum number of seconds to wait before executing the
- // health monitor. Must be a number between 1 and 3600.
- Delay int
-
- // Required - maximum number of seconds to wait for a connection to be
- // established before timing out. Must be a number between 1 and 300.
- Timeout int
-
- // Required - a regular expression that will be used to evaluate the contents
- // of the body of the response.
- BodyRegex string
-
- // Required - the HTTP path that will be used in the sample request.
- Path string
-
- // Required - a regular expression that will be used to evaluate the HTTP
- // status code returned in the response.
- StatusRegex string
-
- // Optional - the name of a host for which the health monitors will check.
- HostHeader string
-
- // Required - either HTTP or HTTPS
- Type Type
-}
-
-// ToMonitorUpdateMap produces a map for updating HTTP(S) monitors.
-func (opts UpdateHTTPMonitorOpts) ToMonitorUpdateMap() (map[string]interface{}, error) {
- type m map[string]interface{}
-
- if !gophercloud.IntWithinRange(opts.AttemptLimit, 1, 10) {
- return m{}, errAttemptLimit
- }
- if !gophercloud.IntWithinRange(opts.Delay, 1, 3600) {
- return m{}, errDelay
- }
- if !gophercloud.IntWithinRange(opts.Timeout, 1, 300) {
- return m{}, errTimeout
- }
- if opts.Type != HTTP && opts.Type != HTTPS {
- return m{}, errors.New("Type must either by HTTP or HTTPS")
- }
- if opts.BodyRegex == "" {
- return m{}, errors.New("BodyRegex is a required field")
- }
- if opts.Path == "" {
- return m{}, errors.New("Path is a required field")
- }
- if opts.StatusRegex == "" {
- return m{}, errors.New("StatusRegex is a required field")
- }
-
- json := m{
- "attemptsBeforeDeactivation": opts.AttemptLimit,
- "delay": opts.Delay,
- "timeout": opts.Timeout,
- "type": opts.Type,
- "bodyRegex": opts.BodyRegex,
- "path": opts.Path,
- "statusRegex": opts.StatusRegex,
- }
-
- if opts.HostHeader != "" {
- json["hostHeader"] = opts.HostHeader
- }
-
- return m{"healthMonitor": json}, nil
-}
-
-// Update is the operation responsible for updating a health monitor.
-func Update(c *gophercloud.ServiceClient, id int, opts UpdateOptsBuilder) UpdateResult {
- var res UpdateResult
-
- reqBody, err := opts.ToMonitorUpdateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Put(rootURL(c, id), reqBody, nil, nil)
- return res
-}
-
-// Get is the operation responsible for showing details of a health monitor.
-func Get(c *gophercloud.ServiceClient, id int) GetResult {
- var res GetResult
- _, res.Err = c.Get(rootURL(c, id), &res.Body, nil)
- return res
-}
-
-// Delete is the operation responsible for deleting a health monitor.
-func Delete(c *gophercloud.ServiceClient, id int) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(rootURL(c, id), nil)
- return res
-}
diff --git a/rackspace/lb/v1/monitors/requests_test.go b/rackspace/lb/v1/monitors/requests_test.go
deleted file mode 100644
index 76a60db..0000000
--- a/rackspace/lb/v1/monitors/requests_test.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package monitors
-
-import (
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const lbID = 12345
-
-func TestUpdateCONNECT(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockUpdateConnectResponse(t, lbID)
-
- opts := UpdateConnectMonitorOpts{
- AttemptLimit: 3,
- Delay: 10,
- Timeout: 10,
- }
-
- err := Update(client.ServiceClient(), lbID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestUpdateHTTP(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockUpdateHTTPResponse(t, lbID)
-
- opts := UpdateHTTPMonitorOpts{
- AttemptLimit: 3,
- Delay: 10,
- Timeout: 10,
- BodyRegex: "{regex}",
- Path: "/foo",
- StatusRegex: "200",
- Type: HTTPS,
- }
-
- err := Update(client.ServiceClient(), lbID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetResponse(t, lbID)
-
- m, err := Get(client.ServiceClient(), lbID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &Monitor{
- Type: CONNECT,
- Delay: 10,
- Timeout: 10,
- AttemptLimit: 3,
- }
-
- th.AssertDeepEquals(t, expected, m)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteResponse(t, lbID)
-
- err := Delete(client.ServiceClient(), lbID).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/lb/v1/monitors/results.go b/rackspace/lb/v1/monitors/results.go
deleted file mode 100644
index eec556f..0000000
--- a/rackspace/lb/v1/monitors/results.go
+++ /dev/null
@@ -1,90 +0,0 @@
-package monitors
-
-import (
- "github.com/mitchellh/mapstructure"
-
- "github.com/rackspace/gophercloud"
-)
-
-// Type represents the type of Monitor.
-type Type string
-
-// Useful constants.
-const (
- CONNECT Type = "CONNECT"
- HTTP Type = "HTTP"
- HTTPS Type = "HTTPS"
-)
-
-// Monitor represents a health monitor API resource. A monitor comes in three
-// forms: CONNECT, HTTP or HTTPS.
-//
-// A CONNECT monitor establishes a basic connection to each node on its defined
-// port to ensure that the service is listening properly. The connect monitor
-// is the most basic type of health check and does no post-processing or
-// protocol-specific health checks.
-//
-// HTTP and HTTPS health monitors are generally considered more intelligent and
-// powerful than CONNECT. It is capable of processing an HTTP or HTTPS response
-// to determine the condition of a node. It supports the same basic properties
-// as CONNECT and includes additional attributes that are used to evaluate the
-// HTTP response.
-type Monitor struct {
- // Number of permissible monitor failures before removing a node from
- // rotation.
- AttemptLimit int `mapstructure:"attemptsBeforeDeactivation"`
-
- // The minimum number of seconds to wait before executing the health monitor.
- Delay int
-
- // Maximum number of seconds to wait for a connection to be established
- // before timing out.
- Timeout int
-
- // Type of the health monitor.
- Type Type
-
- // A regular expression that will be used to evaluate the contents of the
- // body of the response.
- BodyRegex string
-
- // The name of a host for which the health monitors will check.
- HostHeader string
-
- // The HTTP path that will be used in the sample request.
- Path string
-
- // A regular expression that will be used to evaluate the HTTP status code
- // returned in the response.
- StatusRegex string
-}
-
-// UpdateResult represents the result of an Update operation.
-type UpdateResult struct {
- gophercloud.ErrResult
-}
-
-// GetResult represents the result of a Get operation.
-type GetResult struct {
- gophercloud.Result
-}
-
-// DeleteResult represents the result of an Delete operation.
-type DeleteResult struct {
- gophercloud.ErrResult
-}
-
-// Extract interprets any GetResult as a Monitor.
-func (r GetResult) Extract() (*Monitor, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- M Monitor `mapstructure:"healthMonitor"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- return &response.M, err
-}
diff --git a/rackspace/lb/v1/monitors/urls.go b/rackspace/lb/v1/monitors/urls.go
deleted file mode 100644
index 0a1e6df..0000000
--- a/rackspace/lb/v1/monitors/urls.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package monitors
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-const (
- path = "loadbalancers"
- monitorPath = "healthmonitor"
-)
-
-func rootURL(c *gophercloud.ServiceClient, lbID int) string {
- return c.ServiceURL(path, strconv.Itoa(lbID), monitorPath)
-}
diff --git a/rackspace/lb/v1/nodes/doc.go b/rackspace/lb/v1/nodes/doc.go
deleted file mode 100644
index 49c4318..0000000
--- a/rackspace/lb/v1/nodes/doc.go
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-Package nodes provides information and interaction with the Node API resource
-for the Rackspace Cloud Load Balancer service.
-
-Nodes are responsible for servicing the requests received through the load
-balancer's virtual IP. A node is usually a virtual machine. By default, the
-load balancer employs a basic health check that ensures the node is listening
-on its defined port. The node is checked at the time of addition and at regular
-intervals as defined by the load balancer's health check configuration. If a
-back-end node is not listening on its port, or does not meet the conditions of
-the defined check, then connections will not be forwarded to the node, and its
-status is changed to OFFLINE. Only nodes that are in an ONLINE status receive
-and can service traffic from the load balancer.
-
-All nodes have an associated status that indicates whether the node is
-ONLINE, OFFLINE, or DRAINING. Only nodes that are in ONLINE status can receive
-and service traffic from the load balancer. The OFFLINE status represents a
-node that cannot accept or service traffic. A node in DRAINING status
-represents a node that stops the traffic manager from sending any additional
-new connections to the node, but honors established sessions. If the traffic
-manager receives a request and session persistence requires that the node is
-used, the traffic manager uses it. The status is determined by the passive or
-active health monitors.
-
-If the WEIGHTED_ROUND_ROBIN load balancer algorithm mode is selected, then the
-caller should assign the relevant weights to the node as part of the weight
-attribute of the node element. When the algorithm of the load balancer is
-changed to WEIGHTED_ROUND_ROBIN and the nodes do not already have an assigned
-weight, the service automatically sets the weight to 1 for all nodes.
-
-One or more secondary nodes can be added to a specified load balancer so that
-if all the primary nodes fail, traffic can be redirected to secondary nodes.
-The type attribute allows configuring the node as either PRIMARY or SECONDARY.
-*/
-package nodes
diff --git a/rackspace/lb/v1/nodes/fixtures.go b/rackspace/lb/v1/nodes/fixtures.go
deleted file mode 100644
index 8899fc5..0000000
--- a/rackspace/lb/v1/nodes/fixtures.go
+++ /dev/null
@@ -1,243 +0,0 @@
-package nodes
-
-import (
- "fmt"
- "net/http"
- "strconv"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func _rootURL(lbID int) string {
- return "/loadbalancers/" + strconv.Itoa(lbID) + "/nodes"
-}
-
-func _nodeURL(lbID, nodeID int) string {
- return _rootURL(lbID) + "/" + strconv.Itoa(nodeID)
-}
-
-func mockListResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "nodes": [
- {
- "id": 410,
- "address": "10.1.1.1",
- "port": 80,
- "condition": "ENABLED",
- "status": "ONLINE",
- "weight": 3,
- "type": "PRIMARY"
- },
- {
- "id": 411,
- "address": "10.1.1.2",
- "port": 80,
- "condition": "ENABLED",
- "status": "ONLINE",
- "weight": 8,
- "type": "SECONDARY"
- }
- ]
-}
- `)
- })
-}
-
-func mockCreateResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "nodes": [
- {
- "address": "10.2.2.3",
- "port": 80,
- "condition": "ENABLED",
- "type": "PRIMARY"
- },
- {
- "address": "10.2.2.4",
- "port": 81,
- "condition": "ENABLED",
- "type": "SECONDARY"
- }
- ]
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusAccepted)
-
- fmt.Fprintf(w, `
-{
- "nodes": [
- {
- "address": "10.2.2.3",
- "id": 185,
- "port": 80,
- "status": "ONLINE",
- "condition": "ENABLED",
- "weight": 1,
- "type": "PRIMARY"
- },
- {
- "address": "10.2.2.4",
- "id": 186,
- "port": 81,
- "status": "ONLINE",
- "condition": "ENABLED",
- "weight": 1,
- "type": "SECONDARY"
- }
- ]
-}
- `)
- })
-}
-
-func mockCreateErrResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "nodes": [
- {
- "address": "10.2.2.3",
- "port": 80,
- "condition": "ENABLED",
- "type": "PRIMARY"
- },
- {
- "address": "10.2.2.4",
- "port": 81,
- "condition": "ENABLED",
- "type": "SECONDARY"
- }
- ]
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(422) // Unprocessable Entity
-
- fmt.Fprintf(w, `
-{
- "code": 422,
- "message": "Load Balancer '%d' has a status of 'PENDING_UPDATE' and is considered immutable."
-}
- `, lbID)
- })
-}
-
-func mockBatchDeleteResponse(t *testing.T, lbID int, ids []int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- r.ParseForm()
-
- for k, v := range ids {
- fids := r.Form["id"]
- th.AssertEquals(t, strconv.Itoa(v), fids[k])
- }
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockDeleteResponse(t *testing.T, lbID, nodeID int) {
- th.Mux.HandleFunc(_nodeURL(lbID, nodeID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockGetResponse(t *testing.T, lbID, nodeID int) {
- th.Mux.HandleFunc(_nodeURL(lbID, nodeID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "node": {
- "id": 410,
- "address": "10.1.1.1",
- "port": 80,
- "condition": "ENABLED",
- "status": "ONLINE",
- "weight": 12,
- "type": "PRIMARY"
- }
-}
- `)
- })
-}
-
-func mockUpdateResponse(t *testing.T, lbID, nodeID int) {
- th.Mux.HandleFunc(_nodeURL(lbID, nodeID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "node": {
- "condition": "DRAINING",
- "weight": 10,
- "type": "SECONDARY"
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockListEventsResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID)+"/events", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "nodeServiceEvents": [
- {
- "detailedMessage": "Node is ok",
- "nodeId": 373,
- "id": 7,
- "type": "UPDATE_NODE",
- "description": "Node '373' status changed to 'ONLINE' for load balancer '323'",
- "category": "UPDATE",
- "severity": "INFO",
- "relativeUri": "/406271/loadbalancers/323/nodes/373/events",
- "accountId": 406271,
- "loadbalancerId": 323,
- "title": "Node Status Updated",
- "author": "Rackspace Cloud",
- "created": "10-30-2012 10:18:23"
- }
- ]
-}
-`)
- })
-}
diff --git a/rackspace/lb/v1/nodes/requests.go b/rackspace/lb/v1/nodes/requests.go
deleted file mode 100644
index 9da376f..0000000
--- a/rackspace/lb/v1/nodes/requests.go
+++ /dev/null
@@ -1,286 +0,0 @@
-package nodes
-
-import (
- "errors"
- "fmt"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List is the operation responsible for returning a paginated collection of
-// load balancer nodes. It requires the node ID, its parent load balancer ID,
-// and optional limit integer (passed in either as a pointer or a nil poitner).
-func List(client *gophercloud.ServiceClient, loadBalancerID int, limit *int) pagination.Pager {
- url := rootURL(client, loadBalancerID)
- if limit != nil {
- url += fmt.Sprintf("?limit=%d", limit)
- }
-
- return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
- return NodePage{pagination.SinglePageBase(r)}
- })
-}
-
-// CreateOptsBuilder is the interface responsible for generating the JSON
-// for a Create operation.
-type CreateOptsBuilder interface {
- ToNodeCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts is a slice of CreateOpt structs, that allow the user to create
-// multiple nodes in a single operation (one node per CreateOpt).
-type CreateOpts []CreateOpt
-
-// CreateOpt represents the options to create a single node.
-type CreateOpt struct {
- // Required - the IP address or CIDR for this back-end node. It can either be
- // a private IP (ServiceNet) or a public IP.
- Address string
-
- // Optional - the port on which traffic is sent and received.
- Port int
-
- // Optional - the condition of the node. See the consts in Results.go.
- Condition Condition
-
- // Optional - the type of the node. See the consts in Results.go.
- Type Type
-
- // Optional - a pointer to an integer between 0 and 100.
- Weight *int
-}
-
-func validateWeight(weight *int) error {
- if weight != nil && (*weight > 100 || *weight < 0) {
- return errors.New("Weight must be a valid int between 0 and 100")
- }
- return nil
-}
-
-// ToNodeCreateMap converts a slice of options into a map that can be used for
-// the JSON.
-func (opts CreateOpts) ToNodeCreateMap() (map[string]interface{}, error) {
- type nodeMap map[string]interface{}
- nodes := []nodeMap{}
-
- for k, v := range opts {
- if v.Address == "" {
- return nodeMap{}, fmt.Errorf("ID is a required attribute, none provided for %d CreateOpt element", k)
- }
- if weightErr := validateWeight(v.Weight); weightErr != nil {
- return nodeMap{}, weightErr
- }
-
- node := make(map[string]interface{})
- node["address"] = v.Address
-
- if v.Port > 0 {
- node["port"] = v.Port
- }
- if v.Condition != "" {
- node["condition"] = v.Condition
- }
- if v.Type != "" {
- node["type"] = v.Type
- }
- if v.Weight != nil {
- node["weight"] = &v.Weight
- }
-
- nodes = append(nodes, node)
- }
-
- return nodeMap{"nodes": nodes}, nil
-}
-
-// Create is the operation responsible for creating a new node on a load
-// balancer. Since every load balancer exists in both ServiceNet and the public
-// Internet, both private and public IP addresses can be used for nodes.
-//
-// If nodes need time to boot up services before they become operational, you
-// can temporarily prevent traffic from being sent to that node by setting the
-// Condition field to DRAINING. Health checks will still be performed; but once
-// your node is ready, you can update its condition to ENABLED and have it
-// handle traffic.
-func Create(client *gophercloud.ServiceClient, loadBalancerID int, opts CreateOptsBuilder) CreateResult {
- var res CreateResult
-
- reqBody, err := opts.ToNodeCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- resp, err := client.Post(rootURL(client, loadBalancerID), reqBody, &res.Body, nil)
-
- if err != nil {
- res.Err = err
- return res
- }
-
- pr := pagination.PageResultFromParsed(resp, res.Body)
- return CreateResult{pagination.SinglePageBase(pr)}
-}
-
-// BulkDelete is the operation responsible for batch deleting multiple nodes in
-// a single operation. It accepts a slice of integer IDs and will remove them
-// from the load balancer. The maximum limit is 10 node removals at once.
-func BulkDelete(c *gophercloud.ServiceClient, loadBalancerID int, nodeIDs []int) DeleteResult {
- var res DeleteResult
-
- if len(nodeIDs) > 10 || len(nodeIDs) == 0 {
- res.Err = errors.New("You must provide a minimum of 1 and a maximum of 10 node IDs")
- return res
- }
-
- url := rootURL(c, loadBalancerID)
- url += gophercloud.IDSliceToQueryString("id", nodeIDs)
-
- _, res.Err = c.Delete(url, nil)
- return res
-}
-
-// Get is the operation responsible for showing details for a single node.
-func Get(c *gophercloud.ServiceClient, lbID, nodeID int) GetResult {
- var res GetResult
- _, res.Err = c.Get(resourceURL(c, lbID, nodeID), &res.Body, nil)
- return res
-}
-
-// UpdateOptsBuilder represents a type that can be converted into a JSON-like
-// map structure.
-type UpdateOptsBuilder interface {
- ToNodeUpdateMap() (map[string]interface{}, error)
-}
-
-// UpdateOpts represent the options for updating an existing node.
-type UpdateOpts struct {
- // Optional - the condition of the node. See the consts in Results.go.
- Condition Condition
-
- // Optional - the type of the node. See the consts in Results.go.
- Type Type
-
- // Optional - a pointer to an integer between 0 and 100.
- Weight *int
-}
-
-// ToNodeUpdateMap converts an options struct into a JSON-like map.
-func (opts UpdateOpts) ToNodeUpdateMap() (map[string]interface{}, error) {
- node := make(map[string]interface{})
-
- if opts.Condition != "" {
- node["condition"] = opts.Condition
- }
- if opts.Weight != nil {
- if weightErr := validateWeight(opts.Weight); weightErr != nil {
- return node, weightErr
- }
- node["weight"] = &opts.Weight
- }
- if opts.Type != "" {
- node["type"] = opts.Type
- }
-
- return map[string]interface{}{"node": node}, nil
-}
-
-// Update is the operation responsible for updating an existing node. A node's
-// IP, port, and status are immutable attributes and cannot be modified.
-func Update(c *gophercloud.ServiceClient, lbID, nodeID int, opts UpdateOptsBuilder) UpdateResult {
- var res UpdateResult
-
- reqBody, err := opts.ToNodeUpdateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Put(resourceURL(c, lbID, nodeID), reqBody, nil, nil)
- return res
-}
-
-// Delete is the operation responsible for permanently deleting a node.
-func Delete(c *gophercloud.ServiceClient, lbID, nodeID int) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(resourceURL(c, lbID, nodeID), nil)
- return res
-}
-
-// ListEventsOptsBuilder allows extensions to add additional parameters to the
-// List request.
-type ListEventsOptsBuilder interface {
- ToEventsListQuery() (string, error)
-}
-
-// ListEventsOpts allows the filtering and sorting of paginated collections through
-// the API.
-type ListEventsOpts struct {
- Marker string `q:"marker"`
- Limit int `q:"limit"`
-}
-
-// ToEventsListQuery formats a ListOpts into a query string.
-func (opts ListEventsOpts) ToEventsListQuery() (string, error) {
- q, err := gophercloud.BuildQueryString(opts)
- if err != nil {
- return "", err
- }
- return q.String(), nil
-}
-
-// ListEvents is the operation responsible for listing all the events
-// associated with the activity between the node and the load balancer. The
-// events report errors found with the node. The detailedMessage provides the
-// detailed reason for the error.
-func ListEvents(client *gophercloud.ServiceClient, loadBalancerID int, opts ListEventsOptsBuilder) pagination.Pager {
- url := eventsURL(client, loadBalancerID)
-
- if opts != nil {
- query, err := opts.ToEventsListQuery()
- if err != nil {
- return pagination.Pager{Err: err}
- }
- url += query
- }
-
- return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
- return NodeEventPage{pagination.SinglePageBase(r)}
- })
-}
-
-// GetByIPPort locates a load balancer node by IP and port.
-func GetByIPPort(
- client *gophercloud.ServiceClient,
- loadBalancerID int,
- address string,
- port int,
-) (*Node, error) {
-
- // nil until found
- var found *Node
-
- List(client, loadBalancerID, nil).EachPage(func(page pagination.Page) (bool, error) {
- lbNodes, err := ExtractNodes(page)
- if err != nil {
- return false, err
- }
-
- for _, trialNode := range lbNodes {
- if trialNode.Address == address && trialNode.Port == port {
- found = &trialNode
- return false, nil
- }
-
- }
-
- return true, nil
- })
-
- if found == nil {
- return nil, errors.New("Unable to get node by IP and Port")
- }
-
- return found, nil
-}
diff --git a/rackspace/lb/v1/nodes/requests_test.go b/rackspace/lb/v1/nodes/requests_test.go
deleted file mode 100644
index a964af8..0000000
--- a/rackspace/lb/v1/nodes/requests_test.go
+++ /dev/null
@@ -1,243 +0,0 @@
-package nodes
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const (
- lbID = 12345
- nodeID = 67890
- nodeID2 = 67891
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListResponse(t, lbID)
-
- count := 0
-
- err := List(client.ServiceClient(), lbID, nil).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNodes(page)
- th.AssertNoErr(t, err)
-
- expected := []Node{
- Node{
- ID: 410,
- Address: "10.1.1.1",
- Port: 80,
- Condition: ENABLED,
- Status: ONLINE,
- Weight: 3,
- Type: PRIMARY,
- },
- Node{
- ID: 411,
- Address: "10.1.1.2",
- Port: 80,
- Condition: ENABLED,
- Status: ONLINE,
- Weight: 8,
- Type: SECONDARY,
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockCreateResponse(t, lbID)
-
- opts := CreateOpts{
- CreateOpt{
- Address: "10.2.2.3",
- Port: 80,
- Condition: ENABLED,
- Type: PRIMARY,
- },
- CreateOpt{
- Address: "10.2.2.4",
- Port: 81,
- Condition: ENABLED,
- Type: SECONDARY,
- },
- }
-
- page := Create(client.ServiceClient(), lbID, opts)
-
- actual, err := page.ExtractNodes()
- th.AssertNoErr(t, err)
-
- expected := []Node{
- Node{
- ID: 185,
- Address: "10.2.2.3",
- Port: 80,
- Condition: ENABLED,
- Status: ONLINE,
- Weight: 1,
- Type: PRIMARY,
- },
- Node{
- ID: 186,
- Address: "10.2.2.4",
- Port: 81,
- Condition: ENABLED,
- Status: ONLINE,
- Weight: 1,
- Type: SECONDARY,
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-}
-
-func TestCreateErr(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockCreateErrResponse(t, lbID)
-
- opts := CreateOpts{
- CreateOpt{
- Address: "10.2.2.3",
- Port: 80,
- Condition: ENABLED,
- Type: PRIMARY,
- },
- CreateOpt{
- Address: "10.2.2.4",
- Port: 81,
- Condition: ENABLED,
- Type: SECONDARY,
- },
- }
-
- page := Create(client.ServiceClient(), lbID, opts)
-
- actual, err := page.ExtractNodes()
- if err == nil {
- t.Fatal("Did not receive expected error from ExtractNodes")
- }
- if actual != nil {
- t.Fatalf("Received non-nil result from failed ExtractNodes: %#v", actual)
- }
-}
-
-func TestBulkDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- ids := []int{nodeID, nodeID2}
-
- mockBatchDeleteResponse(t, lbID, ids)
-
- err := BulkDelete(client.ServiceClient(), lbID, ids).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetResponse(t, lbID, nodeID)
-
- node, err := Get(client.ServiceClient(), lbID, nodeID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &Node{
- ID: 410,
- Address: "10.1.1.1",
- Port: 80,
- Condition: ENABLED,
- Status: ONLINE,
- Weight: 12,
- Type: PRIMARY,
- }
-
- th.AssertDeepEquals(t, expected, node)
-}
-
-func TestUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockUpdateResponse(t, lbID, nodeID)
-
- opts := UpdateOpts{
- Weight: gophercloud.IntToPointer(10),
- Condition: DRAINING,
- Type: SECONDARY,
- }
-
- err := Update(client.ServiceClient(), lbID, nodeID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteResponse(t, lbID, nodeID)
-
- err := Delete(client.ServiceClient(), lbID, nodeID).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestListEvents(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListEventsResponse(t, lbID)
-
- count := 0
-
- pager := ListEvents(client.ServiceClient(), lbID, ListEventsOpts{})
-
- err := pager.EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNodeEvents(page)
- th.AssertNoErr(t, err)
-
- expected := []NodeEvent{
- NodeEvent{
- DetailedMessage: "Node is ok",
- NodeID: 373,
- ID: 7,
- Type: "UPDATE_NODE",
- Description: "Node '373' status changed to 'ONLINE' for load balancer '323'",
- Category: "UPDATE",
- Severity: "INFO",
- RelativeURI: "/406271/loadbalancers/323/nodes/373/events",
- AccountID: 406271,
- LoadBalancerID: 323,
- Title: "Node Status Updated",
- Author: "Rackspace Cloud",
- Created: "10-30-2012 10:18:23",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
diff --git a/rackspace/lb/v1/nodes/results.go b/rackspace/lb/v1/nodes/results.go
deleted file mode 100644
index 57835dc..0000000
--- a/rackspace/lb/v1/nodes/results.go
+++ /dev/null
@@ -1,213 +0,0 @@
-package nodes
-
-import (
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// Node represents a back-end device, usually a virtual machine, that can
-// handle traffic. It is assigned traffic based on its parent load balancer.
-type Node struct {
- // The IP address or CIDR for this back-end node.
- Address string
-
- // The unique ID for this node.
- ID int
-
- // The port on which traffic is sent and received.
- Port int
-
- // The node's status.
- Status Status
-
- // The node's condition.
- Condition Condition
-
- // The priority at which this node will receive traffic if a weighted
- // algorithm is used by its parent load balancer. Ranges from 1 to 100.
- Weight int
-
- // Type of node.
- Type Type
-}
-
-// Type indicates whether the node is of a PRIMARY or SECONDARY nature.
-type Type string
-
-const (
- // PRIMARY nodes are in the normal rotation to receive traffic from the load
- // balancer.
- PRIMARY Type = "PRIMARY"
-
- // SECONDARY nodes are only in the rotation to receive traffic from the load
- // balancer when all the primary nodes fail. This provides a failover feature
- // that automatically routes traffic to the secondary node in the event that
- // the primary node is disabled or in a failing state. Note that active
- // health monitoring must be enabled on the load balancer to enable the
- // failover feature to the secondary node.
- SECONDARY Type = "SECONDARY"
-)
-
-// Condition represents the condition of a node.
-type Condition string
-
-const (
- // ENABLED indicates that the node is permitted to accept new connections.
- ENABLED Condition = "ENABLED"
-
- // DISABLED indicates that the node is not permitted to accept any new
- // connections regardless of session persistence configuration. Existing
- // connections are forcibly terminated.
- DISABLED Condition = "DISABLED"
-
- // DRAINING indicates that the node is allowed to service existing
- // established connections and connections that are being directed to it as a
- // result of the session persistence configuration.
- DRAINING Condition = "DRAINING"
-)
-
-// Status indicates whether the node can accept service traffic. If a node is
-// not listening on its port or does not meet the conditions of the defined
-// active health check for the load balancer, then the load balancer does not
-// forward connections, and its status is listed as OFFLINE.
-type Status string
-
-const (
- // ONLINE indicates that the node is healthy and capable of receiving traffic
- // from the load balancer.
- ONLINE Status = "ONLINE"
-
- // OFFLINE indicates that the node is not in a position to receive service
- // traffic. It is usually switched into this state when a health check is not
- // satisfied with the node's response time.
- OFFLINE Status = "OFFLINE"
-)
-
-// NodePage is the page returned by a pager when traversing over a collection
-// of nodes.
-type NodePage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty checks whether a NodePage struct is empty.
-func (p NodePage) IsEmpty() (bool, error) {
- is, err := ExtractNodes(p)
- if err != nil {
- return true, nil
- }
- return len(is) == 0, nil
-}
-
-func commonExtractNodes(body interface{}) ([]Node, error) {
- var resp struct {
- Nodes []Node `mapstructure:"nodes" json:"nodes"`
- }
-
- err := mapstructure.Decode(body, &resp)
-
- return resp.Nodes, err
-}
-
-// ExtractNodes accepts a Page struct, specifically a NodePage struct, and
-// extracts the elements into a slice of Node structs. In other words, a
-// generic collection is mapped into a relevant slice.
-func ExtractNodes(page pagination.Page) ([]Node, error) {
- return commonExtractNodes(page.(NodePage).Body)
-}
-
-// CreateResult represents the result of a create operation. Since multiple
-// nodes can be added in one operation, this result represents multiple nodes
-// and should be treated as a typical pagination Page. Use its ExtractNodes
-// method to get out a slice of Node structs.
-type CreateResult struct {
- pagination.SinglePageBase
-}
-
-// ExtractNodes extracts a slice of Node structs from a CreateResult.
-func (res CreateResult) ExtractNodes() ([]Node, error) {
- if res.Err != nil {
- return nil, res.Err
- }
- return commonExtractNodes(res.Body)
-}
-
-// DeleteResult represents the result of a delete operation.
-type DeleteResult struct {
- gophercloud.ErrResult
-}
-
-type commonResult struct {
- gophercloud.Result
-}
-
-// GetResult represents the result of a get operation.
-type GetResult struct {
- commonResult
-}
-
-// UpdateResult represents the result of an update operation.
-type UpdateResult struct {
- gophercloud.ErrResult
-}
-
-func (r commonResult) Extract() (*Node, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- Node Node `mapstructure:"node"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- return &response.Node, err
-}
-
-// NodeEvent represents a service event that occurred between a node and a
-// load balancer.
-type NodeEvent struct {
- ID int
- DetailedMessage string
- NodeID int
- Type string
- Description string
- Category string
- Severity string
- RelativeURI string
- AccountID int
- LoadBalancerID int
- Title string
- Author string
- Created string
-}
-
-// NodeEventPage is a concrete type which embeds the common SinglePageBase
-// struct, and is used when traversing node event collections.
-type NodeEventPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty is a concrete function which indicates whether an NodeEventPage is
-// empty or not.
-func (r NodeEventPage) IsEmpty() (bool, error) {
- is, err := ExtractNodeEvents(r)
- if err != nil {
- return true, err
- }
- return len(is) == 0, nil
-}
-
-// ExtractNodeEvents accepts a Page struct, specifically a NodeEventPage
-// struct, and extracts the elements into a slice of NodeEvent structs. In
-// other words, the collection is mapped into a relevant slice.
-func ExtractNodeEvents(page pagination.Page) ([]NodeEvent, error) {
- var resp struct {
- Events []NodeEvent `mapstructure:"nodeServiceEvents" json:"nodeServiceEvents"`
- }
-
- err := mapstructure.Decode(page.(NodeEventPage).Body, &resp)
-
- return resp.Events, err
-}
diff --git a/rackspace/lb/v1/nodes/urls.go b/rackspace/lb/v1/nodes/urls.go
deleted file mode 100644
index 2cefee2..0000000
--- a/rackspace/lb/v1/nodes/urls.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package nodes
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-const (
- lbPath = "loadbalancers"
- nodePath = "nodes"
- eventPath = "events"
-)
-
-func resourceURL(c *gophercloud.ServiceClient, lbID, nodeID int) string {
- return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath, strconv.Itoa(nodeID))
-}
-
-func rootURL(c *gophercloud.ServiceClient, lbID int) string {
- return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath)
-}
-
-func eventsURL(c *gophercloud.ServiceClient, lbID int) string {
- return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath, eventPath)
-}
diff --git a/rackspace/lb/v1/sessions/doc.go b/rackspace/lb/v1/sessions/doc.go
deleted file mode 100644
index dcec0a8..0000000
--- a/rackspace/lb/v1/sessions/doc.go
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-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
-same node. This is common with many web applications that do not inherently
-share application state between back-end servers.
-
-There are two modes to choose from: HTTP_COOKIE and SOURCE_IP. You can only set
-one of the session persistence modes on a load balancer, and it can only
-support one protocol. If you set HTTP_COOKIE mode for an HTTP load balancer, it
-supports session persistence for HTTP requests only. Likewise, if you set
-SOURCE_IP mode for an HTTPS load balancer, it supports session persistence for
-only HTTPS requests.
-
-To support session persistence for both HTTP and HTTPS requests concurrently,
-choose one of the following options:
-
-- Use two load balancers, one configured for session persistence for HTTP
-requests and the other configured for session persistence for HTTPS requests.
-That way, the load balancers support session persistence for both HTTP and
-HTTPS requests concurrently, with each load balancer supporting one of the
-protocols.
-
-- Use one load balancer, configure it for session persistence for HTTP requests,
-and then enable SSL termination for that load balancer. The load balancer
-supports session persistence for both HTTP and HTTPS requests concurrently.
-*/
-package sessions
diff --git a/rackspace/lb/v1/sessions/fixtures.go b/rackspace/lb/v1/sessions/fixtures.go
deleted file mode 100644
index 077ef04..0000000
--- a/rackspace/lb/v1/sessions/fixtures.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package sessions
-
-import (
- "fmt"
- "net/http"
- "strconv"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func _rootURL(id int) string {
- return "/loadbalancers/" + strconv.Itoa(id) + "/sessionpersistence"
-}
-
-func mockGetResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "sessionPersistence": {
- "persistenceType": "HTTP_COOKIE"
- }
-}
-`)
- })
-}
-
-func mockEnableResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "sessionPersistence": {
- "persistenceType": "HTTP_COOKIE"
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- fmt.Fprintf(w, `{}`)
- })
-}
-
-func mockDisableResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
diff --git a/rackspace/lb/v1/sessions/requests.go b/rackspace/lb/v1/sessions/requests.go
deleted file mode 100644
index a93d766..0000000
--- a/rackspace/lb/v1/sessions/requests.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package sessions
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
-)
-
-// CreateOptsBuilder is the interface options structs have to satisfy in order
-// to be used in the main Create operation in this package.
-type CreateOptsBuilder interface {
- ToSPCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts is the common options struct used in this package's Create
-// operation.
-type CreateOpts struct {
- // Required - can either be HTTPCOOKIE or SOURCEIP
- Type Type
-}
-
-// ToSPCreateMap casts a CreateOpts struct to a map.
-func (opts CreateOpts) ToSPCreateMap() (map[string]interface{}, error) {
- sp := make(map[string]interface{})
-
- if opts.Type == "" {
- return sp, errors.New("Type is a required field")
- }
-
- sp["persistenceType"] = opts.Type
- return map[string]interface{}{"sessionPersistence": sp}, nil
-}
-
-// Enable is the operation responsible for enabling session persistence for a
-// particular load balancer.
-func Enable(c *gophercloud.ServiceClient, lbID int, opts CreateOptsBuilder) EnableResult {
- var res EnableResult
-
- reqBody, err := opts.ToSPCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, nil)
- return res
-}
-
-// Get is the operation responsible for showing details of the session
-// persistence configuration for a particular load balancer.
-func Get(c *gophercloud.ServiceClient, lbID int) GetResult {
- var res GetResult
- _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil)
- return res
-}
-
-// Disable is the operation responsible for disabling session persistence for a
-// particular load balancer.
-func Disable(c *gophercloud.ServiceClient, lbID int) DisableResult {
- var res DisableResult
- _, res.Err = c.Delete(rootURL(c, lbID), nil)
- return res
-}
diff --git a/rackspace/lb/v1/sessions/requests_test.go b/rackspace/lb/v1/sessions/requests_test.go
deleted file mode 100644
index f319e54..0000000
--- a/rackspace/lb/v1/sessions/requests_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package sessions
-
-import (
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const lbID = 12345
-
-func TestEnable(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockEnableResponse(t, lbID)
-
- opts := CreateOpts{Type: HTTPCOOKIE}
- err := Enable(client.ServiceClient(), lbID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetResponse(t, lbID)
-
- sp, err := Get(client.ServiceClient(), lbID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &SessionPersistence{Type: HTTPCOOKIE}
- th.AssertDeepEquals(t, expected, sp)
-}
-
-func TestDisable(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDisableResponse(t, lbID)
-
- err := Disable(client.ServiceClient(), lbID).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/lb/v1/sessions/results.go b/rackspace/lb/v1/sessions/results.go
deleted file mode 100644
index fe90e72..0000000
--- a/rackspace/lb/v1/sessions/results.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package sessions
-
-import (
- "github.com/mitchellh/mapstructure"
-
- "github.com/rackspace/gophercloud"
-)
-
-// Type represents the type of session persistence being used.
-type Type string
-
-const (
- // HTTPCOOKIE is a session persistence mechanism that inserts an HTTP cookie
- // and is used to determine the destination back-end node. This is supported
- // for HTTP load balancing only.
- HTTPCOOKIE Type = "HTTP_COOKIE"
-
- // SOURCEIP is a session persistence mechanism that keeps track of the source
- // IP address that is mapped and is able to determine the destination
- // back-end node. This is supported for HTTPS pass-through and non-HTTP load
- // balancing only.
- SOURCEIP Type = "SOURCE_IP"
-)
-
-// SessionPersistence indicates how a load balancer is using session persistence
-type SessionPersistence struct {
- Type Type `mapstructure:"persistenceType"`
-}
-
-// EnableResult represents the result of an enable operation.
-type EnableResult struct {
- gophercloud.ErrResult
-}
-
-// DisableResult represents the result of a disable operation.
-type DisableResult struct {
- gophercloud.ErrResult
-}
-
-// GetResult represents the result of a get operation.
-type GetResult struct {
- gophercloud.Result
-}
-
-// Extract interprets a GetResult as an SP, if possible.
-func (r GetResult) Extract() (*SessionPersistence, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- SP SessionPersistence `mapstructure:"sessionPersistence"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- return &response.SP, err
-}
diff --git a/rackspace/lb/v1/sessions/urls.go b/rackspace/lb/v1/sessions/urls.go
deleted file mode 100644
index c4a896d..0000000
--- a/rackspace/lb/v1/sessions/urls.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package sessions
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-const (
- path = "loadbalancers"
- spPath = "sessionpersistence"
-)
-
-func rootURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id), spPath)
-}
diff --git a/rackspace/lb/v1/ssl/doc.go b/rackspace/lb/v1/ssl/doc.go
deleted file mode 100644
index 6a2c174..0000000
--- a/rackspace/lb/v1/ssl/doc.go
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-Package ssl provides information and interaction with the SSL Termination
-feature of the Rackspace Cloud Load Balancer service.
-
-You may only enable and configure SSL termination on load balancers with
-non-secure protocols, such as HTTP, but not HTTPS.
-
-SSL-terminated load balancers decrypt the traffic at the traffic manager and
-pass unencrypted traffic to the back-end node. Because of this, the customer's
-back-end nodes don't know what protocol the client requested. For this reason,
-the X-Forwarded-Proto (XFP) header has been added for identifying the
-originating protocol of an HTTP request as "http" or "https" depending on what
-protocol the client requested.
-
-Not every service returns certificates in the proper order. Please verify that
-your chain of certificates matches that of walking up the chain from the domain
-to the CA root.
-
-If used for HTTP to HTTPS redirection, the LoadBalancer's securePort attribute
-must be set to 443, and its secureTrafficOnly attribute must be true.
-*/
-package ssl
diff --git a/rackspace/lb/v1/ssl/fixtures.go b/rackspace/lb/v1/ssl/fixtures.go
deleted file mode 100644
index 5a52962..0000000
--- a/rackspace/lb/v1/ssl/fixtures.go
+++ /dev/null
@@ -1,196 +0,0 @@
-package ssl
-
-import (
- "fmt"
- "net/http"
- "strconv"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func _rootURL(id int) string {
- return "/loadbalancers/" + strconv.Itoa(id) + "/ssltermination"
-}
-
-func _certURL(id, certID int) string {
- url := _rootURL(id) + "/certificatemappings"
- if certID > 0 {
- url += "/" + strconv.Itoa(certID)
- }
- return url
-}
-
-func mockGetResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "sslTermination": {
- "certificate": "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- "enabled": true,
- "secureTrafficOnly": false,
- "intermediateCertificate": "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n",
- "securePort": 443
- }
-}
-`)
- })
-}
-
-func mockUpdateResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "sslTermination": {
- "enabled": true,
- "securePort": 443,
- "secureTrafficOnly": false,
- "privateKey": "foo",
- "certificate": "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- "intermediateCertificate": "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n"
- }
-}
- `)
-
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `{}`)
- })
-}
-
-func mockDeleteResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusOK)
- })
-}
-
-func mockListCertsResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_certURL(lbID, 0), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "certificateMappings": [
- {
- "certificateMapping": {
- "id": 123,
- "hostName": "rackspace.com"
- }
- },
- {
- "certificateMapping": {
- "id": 124,
- "hostName": "*.rackspace.com"
- }
- }
- ]
-}
-`)
- })
-}
-
-func mockAddCertResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_certURL(lbID, 0), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "certificateMapping": {
- "hostName": "rackspace.com",
- "privateKey":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAwIudSMpRZx7TS0/AtDVX3DgXwLD9g+XrNaoazlhwhpYALgzJ\nLAbAnOxT6OT0gTpkPus/B7QhW6y6Auf2cdBeW31XoIwPsSoyNhxgErGBxzNARRB9\nlI1HCa1ojFrcULluj4W6rpaOycI5soDBJiJHin/hbZBPZq6vhPCuNP7Ya48Zd/2X\nCQ9ft3XKfmbs1SdrdROIhigse/SGRbMrCorn/vhNIuohr7yOlHG3GcVcUI9k6ZSZ\nBbqF+ZA4ApSF/Q6/cumieEgofhkYbx5fg02s9Jwr4IWnIR2bSHs7UQ6sVgKYzjs7\nPd3Unpa74jFw6/H6shABoO2CIYLotGmQbFgnpwIDAQABAoIBAQCBCQ+PCIclJHNV\ntUzfeCA5ZR4F9JbxHdRTUnxEbOB8UWotckQfTScoAvj4yvdQ42DrCZxj/UOdvFOs\nPufZvlp91bIz1alugWjE+p8n5+2hIaegoTyHoWZKBfxak0myj5KYfHZvKlbmv1ML\nXV4TwEVRfAIG+v87QTY/UUxuF5vR+BpKIbgUJLfPUFFvJUdl84qsJ44pToxaYUd/\nh5YAGC00U4ay1KVSAUnTkkPNZ0lPG/rWU6w6WcTvNRLMd8DzFLTKLOgQfHhbExAF\n+sXPWjWSzbBRP1O7fHqq96QQh4VFiY/7w9W+sDKQyV6Ul17OSXs6aZ4f+lq4rJTI\n1FG96YiBAoGBAO1tiH0h1oWDBYfJB3KJJ6CQQsDGwtHo/DEgznFVP4XwEVbZ98Ha\nBfBCn3sAybbaikyCV1Hwj7kfHMZPDHbrcUSFX7quu/2zPK+wO3lZKXSyu4YsguSa\nRedInN33PpdnlPhLyQdWSuD5sVHJDF6xn22vlyxeILH3ooLg2WOFMPmVAoGBAM+b\nUG/a7iyfpAQKYyuFAsXz6SeFaDY+ZYeX45L112H8Pu+Ie/qzon+bzLB9FIH8GP6+\nQpQgmm/p37U2gD1zChUv7iW6OfQBKk9rWvMpfRF6d7YHquElejhizfTZ+ntBV/VY\ndOYEczxhrdW7keLpatYaaWUy/VboRZmlz/9JGqVLAoGAHfqNmFc0cgk4IowEj7a3\ntTNh6ltub/i+FynwRykfazcDyXaeLPDtfQe8gVh5H8h6W+y9P9BjJVnDVVrX1RAn\nbiJ1EupLPF5sVDapW8ohTOXgfbGTGXBNUUW+4Nv+IDno+mz/RhjkPYHpnM0I7c/5\ntGzOZsC/2hjNgT8I0+MWav0CgYEAuULdJeQVlKalI6HtW2Gn1uRRVJ49H+LQkY6e\nW3+cw2jo9LI0CMWSphNvNrN3wIMp/vHj0fHCP0pSApDvIWbuQXfzKaGko7UCf7rK\nf6GvZRCHkV4IREBAb97j8bMvThxClMNqFfU0rFZyXP+0MOyhFQyertswrgQ6T+Fi\n2mnvKD8CgYAmJHP3NTDRMoMRyAzonJ6nEaGUbAgNmivTaUWMe0+leCvAdwD89gzC\nTKbm3eDUg/6Va3X6ANh3wsfIOe4RXXxcbcFDk9R4zO2M5gfLSjYm5Q87EBZ2hrdj\nM2gLI7dt6thx0J8lR8xRHBEMrVBdgwp0g1gQzo5dAV88/kpkZVps8Q==\n-----END RSA PRIVATE KEY-----\n",
- "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n"
- }
-}
- `)
-
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "certificateMapping": {
- "id": 123,
- "hostName": "rackspace.com",
- "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n"
- }
-}
- `)
- })
-}
-
-func mockGetCertResponse(t *testing.T, lbID, certID int) {
- th.Mux.HandleFunc(_certURL(lbID, certID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "certificateMapping": {
- "id": 123,
- "hostName": "rackspace.com",
- "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n"
- }
-}
-`)
- })
-}
-
-func mockUpdateCertResponse(t *testing.T, lbID, certID int) {
- th.Mux.HandleFunc(_certURL(lbID, certID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "certificateMapping": {
- "hostName": "rackspace.com",
- "privateKey":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAwIudSMpRZx7TS0/AtDVX3DgXwLD9g+XrNaoazlhwhpYALgzJ\nLAbAnOxT6OT0gTpkPus/B7QhW6y6Auf2cdBeW31XoIwPsSoyNhxgErGBxzNARRB9\nlI1HCa1ojFrcULluj4W6rpaOycI5soDBJiJHin/hbZBPZq6vhPCuNP7Ya48Zd/2X\nCQ9ft3XKfmbs1SdrdROIhigse/SGRbMrCorn/vhNIuohr7yOlHG3GcVcUI9k6ZSZ\nBbqF+ZA4ApSF/Q6/cumieEgofhkYbx5fg02s9Jwr4IWnIR2bSHs7UQ6sVgKYzjs7\nPd3Unpa74jFw6/H6shABoO2CIYLotGmQbFgnpwIDAQABAoIBAQCBCQ+PCIclJHNV\ntUzfeCA5ZR4F9JbxHdRTUnxEbOB8UWotckQfTScoAvj4yvdQ42DrCZxj/UOdvFOs\nPufZvlp91bIz1alugWjE+p8n5+2hIaegoTyHoWZKBfxak0myj5KYfHZvKlbmv1ML\nXV4TwEVRfAIG+v87QTY/UUxuF5vR+BpKIbgUJLfPUFFvJUdl84qsJ44pToxaYUd/\nh5YAGC00U4ay1KVSAUnTkkPNZ0lPG/rWU6w6WcTvNRLMd8DzFLTKLOgQfHhbExAF\n+sXPWjWSzbBRP1O7fHqq96QQh4VFiY/7w9W+sDKQyV6Ul17OSXs6aZ4f+lq4rJTI\n1FG96YiBAoGBAO1tiH0h1oWDBYfJB3KJJ6CQQsDGwtHo/DEgznFVP4XwEVbZ98Ha\nBfBCn3sAybbaikyCV1Hwj7kfHMZPDHbrcUSFX7quu/2zPK+wO3lZKXSyu4YsguSa\nRedInN33PpdnlPhLyQdWSuD5sVHJDF6xn22vlyxeILH3ooLg2WOFMPmVAoGBAM+b\nUG/a7iyfpAQKYyuFAsXz6SeFaDY+ZYeX45L112H8Pu+Ie/qzon+bzLB9FIH8GP6+\nQpQgmm/p37U2gD1zChUv7iW6OfQBKk9rWvMpfRF6d7YHquElejhizfTZ+ntBV/VY\ndOYEczxhrdW7keLpatYaaWUy/VboRZmlz/9JGqVLAoGAHfqNmFc0cgk4IowEj7a3\ntTNh6ltub/i+FynwRykfazcDyXaeLPDtfQe8gVh5H8h6W+y9P9BjJVnDVVrX1RAn\nbiJ1EupLPF5sVDapW8ohTOXgfbGTGXBNUUW+4Nv+IDno+mz/RhjkPYHpnM0I7c/5\ntGzOZsC/2hjNgT8I0+MWav0CgYEAuULdJeQVlKalI6HtW2Gn1uRRVJ49H+LQkY6e\nW3+cw2jo9LI0CMWSphNvNrN3wIMp/vHj0fHCP0pSApDvIWbuQXfzKaGko7UCf7rK\nf6GvZRCHkV4IREBAb97j8bMvThxClMNqFfU0rFZyXP+0MOyhFQyertswrgQ6T+Fi\n2mnvKD8CgYAmJHP3NTDRMoMRyAzonJ6nEaGUbAgNmivTaUWMe0+leCvAdwD89gzC\nTKbm3eDUg/6Va3X6ANh3wsfIOe4RXXxcbcFDk9R4zO2M5gfLSjYm5Q87EBZ2hrdj\nM2gLI7dt6thx0J8lR8xRHBEMrVBdgwp0g1gQzo5dAV88/kpkZVps8Q==\n-----END RSA PRIVATE KEY-----\n",
- "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n"
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
-
- fmt.Fprintf(w, `
-{
- "certificateMapping": {
- "id": 123,
- "hostName": "rackspace.com",
- "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n"
- }
-}
- `)
- })
-}
-
-func mockDeleteCertResponse(t *testing.T, lbID, certID int) {
- th.Mux.HandleFunc(_certURL(lbID, certID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusOK)
- })
-}
diff --git a/rackspace/lb/v1/ssl/requests.go b/rackspace/lb/v1/ssl/requests.go
deleted file mode 100644
index bb53ef8..0000000
--- a/rackspace/lb/v1/ssl/requests.go
+++ /dev/null
@@ -1,247 +0,0 @@
-package ssl
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
- "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 Update operation in this package.
-type UpdateOptsBuilder interface {
- ToSSLUpdateMap() (map[string]interface{}, error)
-}
-
-// UpdateOpts is the common options struct used in this package's Update
-// operation.
-type UpdateOpts struct {
- // Required - consult the SSLTermConfig struct for more info.
- SecurePort int
-
- // Required - consult the SSLTermConfig struct for more info.
- PrivateKey string
-
- // Required - consult the SSLTermConfig struct for more info.
- Certificate string
-
- // Required - consult the SSLTermConfig struct for more info.
- IntCertificate string
-
- // Optional - consult the SSLTermConfig struct for more info.
- Enabled *bool
-
- // Optional - consult the SSLTermConfig struct for more info.
- SecureTrafficOnly *bool
-}
-
-// ToSSLUpdateMap casts a CreateOpts struct to a map.
-func (opts UpdateOpts) ToSSLUpdateMap() (map[string]interface{}, error) {
- ssl := make(map[string]interface{})
-
- if opts.SecurePort == 0 {
- return ssl, errors.New("SecurePort needs to be an integer greater than 0")
- }
- if opts.PrivateKey == "" {
- return ssl, errPrivateKey
- }
- if opts.Certificate == "" {
- return ssl, errCertificate
- }
- if opts.IntCertificate == "" {
- return ssl, errIntCertificate
- }
-
- ssl["securePort"] = opts.SecurePort
- ssl["privateKey"] = opts.PrivateKey
- ssl["certificate"] = opts.Certificate
- ssl["intermediateCertificate"] = opts.IntCertificate
-
- if opts.Enabled != nil {
- ssl["enabled"] = &opts.Enabled
- }
-
- if opts.SecureTrafficOnly != nil {
- ssl["secureTrafficOnly"] = &opts.SecureTrafficOnly
- }
-
- return map[string]interface{}{"sslTermination": ssl}, nil
-}
-
-// Update is the operation responsible for updating the SSL Termination
-// configuration for a load balancer.
-func Update(c *gophercloud.ServiceClient, lbID int, opts UpdateOptsBuilder) UpdateResult {
- var res UpdateResult
-
- reqBody, err := opts.ToSSLUpdateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, &gophercloud.RequestOpts{
- OkCodes: []int{200},
- })
- return res
-}
-
-// Get is the operation responsible for showing the details of the SSL
-// Termination configuration for a load balancer.
-func Get(c *gophercloud.ServiceClient, lbID int) GetResult {
- var res GetResult
- _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil)
- return res
-}
-
-// Delete is the operation responsible for deleting the SSL Termination
-// configuration for a load balancer.
-func Delete(c *gophercloud.ServiceClient, lbID int) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(rootURL(c, lbID), &gophercloud.RequestOpts{
- OkCodes: []int{200},
- })
- 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 {
- return CertPage{pagination.LinkedPageBase{PageResult: r}}
- })
-}
-
-// CreateCertOptsBuilder is the interface options structs have to satisfy in
-// order to be used in the AddCert operation in this package.
-type CreateCertOptsBuilder interface {
- ToCertCreateMap() (map[string]interface{}, error)
-}
-
-// CreateCertOpts represents the options used when adding a new certificate mapping.
-type CreateCertOpts struct {
- HostName string
- PrivateKey string
- Certificate string
- IntCertificate string
-}
-
-// ToCertCreateMap will cast an CreateCertOpts struct to a map for JSON serialization.
-func (opts CreateCertOpts) ToCertCreateMap() (map[string]interface{}, error) {
- cm := make(map[string]interface{})
-
- if opts.HostName == "" {
- return cm, errors.New("HostName is a required option")
- }
- if opts.PrivateKey == "" {
- return cm, errPrivateKey
- }
- if opts.Certificate == "" {
- return cm, errCertificate
- }
-
- cm["hostName"] = opts.HostName
- cm["privateKey"] = opts.PrivateKey
- cm["certificate"] = opts.Certificate
-
- if opts.IntCertificate != "" {
- cm["intermediateCertificate"] = opts.IntCertificate
- }
-
- return map[string]interface{}{"certificateMapping": cm}, nil
-}
-
-// CreateCert 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 CreateCert(c *gophercloud.ServiceClient, lbID int, opts CreateCertOptsBuilder) CreateCertResult {
- var res CreateCertResult
-
- reqBody, err := opts.ToCertCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Post(certURL(c, lbID), reqBody, &res.Body, &gophercloud.RequestOpts{
- OkCodes: []int{200},
- })
-
- return res
-}
-
-// GetCert will show the details of an existing SSL certificate.
-func GetCert(c *gophercloud.ServiceClient, lbID, certID int) GetCertResult {
- var res GetCertResult
- _, res.Err = c.Get(certResourceURL(c, lbID, certID), &res.Body, nil)
- 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
- Certificate string
- 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{})
-
- if opts.HostName != "" {
- cm["hostName"] = opts.HostName
- }
- if opts.PrivateKey != "" {
- cm["privateKey"] = opts.PrivateKey
- }
- if opts.Certificate != "" {
- cm["certificate"] = opts.Certificate
- }
- if opts.IntCertificate != "" {
- cm["intermediateCertificate"] = opts.IntCertificate
- }
-
- 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
-
- reqBody, err := opts.ToCertUpdateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Put(certResourceURL(c, lbID, certID), reqBody, &res.Body, nil)
- 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
-
- _, res.Err = c.Delete(certResourceURL(c, lbID, certID), &gophercloud.RequestOpts{
- OkCodes: []int{200},
- })
-
- return res
-}
diff --git a/rackspace/lb/v1/ssl/requests_test.go b/rackspace/lb/v1/ssl/requests_test.go
deleted file mode 100644
index fb14c4a..0000000
--- a/rackspace/lb/v1/ssl/requests_test.go
+++ /dev/null
@@ -1,167 +0,0 @@
-package ssl
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const (
- lbID = 12345
- certID = 67890
-)
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetResponse(t, lbID)
-
- sp, err := Get(client.ServiceClient(), lbID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &SSLTermConfig{
- Certificate: "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- Enabled: true,
- SecureTrafficOnly: false,
- IntCertificate: "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n",
- SecurePort: 443,
- }
- th.AssertDeepEquals(t, expected, sp)
-}
-
-func TestUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockUpdateResponse(t, lbID)
-
- opts := UpdateOpts{
- Enabled: gophercloud.Enabled,
- SecurePort: 443,
- SecureTrafficOnly: gophercloud.Disabled,
- PrivateKey: "foo",
- Certificate: "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- IntCertificate: "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n",
- }
- err := Update(client.ServiceClient(), lbID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteResponse(t, lbID)
-
- err := Delete(client.ServiceClient(), lbID).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestListCerts(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListCertsResponse(t, lbID)
-
- count := 0
-
- err := ListCerts(client.ServiceClient(), lbID).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractCerts(page)
- th.AssertNoErr(t, err)
-
- expected := []Certificate{
- Certificate{ID: 123, HostName: "rackspace.com"},
- Certificate{ID: 124, HostName: "*.rackspace.com"},
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestCreateCert(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockAddCertResponse(t, lbID)
-
- opts := CreateCertOpts{
- HostName: "rackspace.com",
- PrivateKey: "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAwIudSMpRZx7TS0/AtDVX3DgXwLD9g+XrNaoazlhwhpYALgzJ\nLAbAnOxT6OT0gTpkPus/B7QhW6y6Auf2cdBeW31XoIwPsSoyNhxgErGBxzNARRB9\nlI1HCa1ojFrcULluj4W6rpaOycI5soDBJiJHin/hbZBPZq6vhPCuNP7Ya48Zd/2X\nCQ9ft3XKfmbs1SdrdROIhigse/SGRbMrCorn/vhNIuohr7yOlHG3GcVcUI9k6ZSZ\nBbqF+ZA4ApSF/Q6/cumieEgofhkYbx5fg02s9Jwr4IWnIR2bSHs7UQ6sVgKYzjs7\nPd3Unpa74jFw6/H6shABoO2CIYLotGmQbFgnpwIDAQABAoIBAQCBCQ+PCIclJHNV\ntUzfeCA5ZR4F9JbxHdRTUnxEbOB8UWotckQfTScoAvj4yvdQ42DrCZxj/UOdvFOs\nPufZvlp91bIz1alugWjE+p8n5+2hIaegoTyHoWZKBfxak0myj5KYfHZvKlbmv1ML\nXV4TwEVRfAIG+v87QTY/UUxuF5vR+BpKIbgUJLfPUFFvJUdl84qsJ44pToxaYUd/\nh5YAGC00U4ay1KVSAUnTkkPNZ0lPG/rWU6w6WcTvNRLMd8DzFLTKLOgQfHhbExAF\n+sXPWjWSzbBRP1O7fHqq96QQh4VFiY/7w9W+sDKQyV6Ul17OSXs6aZ4f+lq4rJTI\n1FG96YiBAoGBAO1tiH0h1oWDBYfJB3KJJ6CQQsDGwtHo/DEgznFVP4XwEVbZ98Ha\nBfBCn3sAybbaikyCV1Hwj7kfHMZPDHbrcUSFX7quu/2zPK+wO3lZKXSyu4YsguSa\nRedInN33PpdnlPhLyQdWSuD5sVHJDF6xn22vlyxeILH3ooLg2WOFMPmVAoGBAM+b\nUG/a7iyfpAQKYyuFAsXz6SeFaDY+ZYeX45L112H8Pu+Ie/qzon+bzLB9FIH8GP6+\nQpQgmm/p37U2gD1zChUv7iW6OfQBKk9rWvMpfRF6d7YHquElejhizfTZ+ntBV/VY\ndOYEczxhrdW7keLpatYaaWUy/VboRZmlz/9JGqVLAoGAHfqNmFc0cgk4IowEj7a3\ntTNh6ltub/i+FynwRykfazcDyXaeLPDtfQe8gVh5H8h6W+y9P9BjJVnDVVrX1RAn\nbiJ1EupLPF5sVDapW8ohTOXgfbGTGXBNUUW+4Nv+IDno+mz/RhjkPYHpnM0I7c/5\ntGzOZsC/2hjNgT8I0+MWav0CgYEAuULdJeQVlKalI6HtW2Gn1uRRVJ49H+LQkY6e\nW3+cw2jo9LI0CMWSphNvNrN3wIMp/vHj0fHCP0pSApDvIWbuQXfzKaGko7UCf7rK\nf6GvZRCHkV4IREBAb97j8bMvThxClMNqFfU0rFZyXP+0MOyhFQyertswrgQ6T+Fi\n2mnvKD8CgYAmJHP3NTDRMoMRyAzonJ6nEaGUbAgNmivTaUWMe0+leCvAdwD89gzC\nTKbm3eDUg/6Va3X6ANh3wsfIOe4RXXxcbcFDk9R4zO2M5gfLSjYm5Q87EBZ2hrdj\nM2gLI7dt6thx0J8lR8xRHBEMrVBdgwp0g1gQzo5dAV88/kpkZVps8Q==\n-----END RSA PRIVATE KEY-----\n",
- Certificate: "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- IntCertificate: "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n",
- }
-
- cm, err := CreateCert(client.ServiceClient(), lbID, opts).Extract()
- th.AssertNoErr(t, err)
-
- expected := &Certificate{
- ID: 123,
- HostName: "rackspace.com",
- Certificate: "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- IntCertificate: "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n",
- }
- th.AssertDeepEquals(t, expected, cm)
-}
-
-func TestGetCertMapping(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetCertResponse(t, lbID, certID)
-
- sp, err := GetCert(client.ServiceClient(), lbID, certID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &Certificate{
- ID: 123,
- HostName: "rackspace.com",
- Certificate: "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- IntCertificate: "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n",
- }
- th.AssertDeepEquals(t, expected, sp)
-}
-
-func TestUpdateCert(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockUpdateCertResponse(t, lbID, certID)
-
- opts := UpdateCertOpts{
- HostName: "rackspace.com",
- PrivateKey: "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAwIudSMpRZx7TS0/AtDVX3DgXwLD9g+XrNaoazlhwhpYALgzJ\nLAbAnOxT6OT0gTpkPus/B7QhW6y6Auf2cdBeW31XoIwPsSoyNhxgErGBxzNARRB9\nlI1HCa1ojFrcULluj4W6rpaOycI5soDBJiJHin/hbZBPZq6vhPCuNP7Ya48Zd/2X\nCQ9ft3XKfmbs1SdrdROIhigse/SGRbMrCorn/vhNIuohr7yOlHG3GcVcUI9k6ZSZ\nBbqF+ZA4ApSF/Q6/cumieEgofhkYbx5fg02s9Jwr4IWnIR2bSHs7UQ6sVgKYzjs7\nPd3Unpa74jFw6/H6shABoO2CIYLotGmQbFgnpwIDAQABAoIBAQCBCQ+PCIclJHNV\ntUzfeCA5ZR4F9JbxHdRTUnxEbOB8UWotckQfTScoAvj4yvdQ42DrCZxj/UOdvFOs\nPufZvlp91bIz1alugWjE+p8n5+2hIaegoTyHoWZKBfxak0myj5KYfHZvKlbmv1ML\nXV4TwEVRfAIG+v87QTY/UUxuF5vR+BpKIbgUJLfPUFFvJUdl84qsJ44pToxaYUd/\nh5YAGC00U4ay1KVSAUnTkkPNZ0lPG/rWU6w6WcTvNRLMd8DzFLTKLOgQfHhbExAF\n+sXPWjWSzbBRP1O7fHqq96QQh4VFiY/7w9W+sDKQyV6Ul17OSXs6aZ4f+lq4rJTI\n1FG96YiBAoGBAO1tiH0h1oWDBYfJB3KJJ6CQQsDGwtHo/DEgznFVP4XwEVbZ98Ha\nBfBCn3sAybbaikyCV1Hwj7kfHMZPDHbrcUSFX7quu/2zPK+wO3lZKXSyu4YsguSa\nRedInN33PpdnlPhLyQdWSuD5sVHJDF6xn22vlyxeILH3ooLg2WOFMPmVAoGBAM+b\nUG/a7iyfpAQKYyuFAsXz6SeFaDY+ZYeX45L112H8Pu+Ie/qzon+bzLB9FIH8GP6+\nQpQgmm/p37U2gD1zChUv7iW6OfQBKk9rWvMpfRF6d7YHquElejhizfTZ+ntBV/VY\ndOYEczxhrdW7keLpatYaaWUy/VboRZmlz/9JGqVLAoGAHfqNmFc0cgk4IowEj7a3\ntTNh6ltub/i+FynwRykfazcDyXaeLPDtfQe8gVh5H8h6W+y9P9BjJVnDVVrX1RAn\nbiJ1EupLPF5sVDapW8ohTOXgfbGTGXBNUUW+4Nv+IDno+mz/RhjkPYHpnM0I7c/5\ntGzOZsC/2hjNgT8I0+MWav0CgYEAuULdJeQVlKalI6HtW2Gn1uRRVJ49H+LQkY6e\nW3+cw2jo9LI0CMWSphNvNrN3wIMp/vHj0fHCP0pSApDvIWbuQXfzKaGko7UCf7rK\nf6GvZRCHkV4IREBAb97j8bMvThxClMNqFfU0rFZyXP+0MOyhFQyertswrgQ6T+Fi\n2mnvKD8CgYAmJHP3NTDRMoMRyAzonJ6nEaGUbAgNmivTaUWMe0+leCvAdwD89gzC\nTKbm3eDUg/6Va3X6ANh3wsfIOe4RXXxcbcFDk9R4zO2M5gfLSjYm5Q87EBZ2hrdj\nM2gLI7dt6thx0J8lR8xRHBEMrVBdgwp0g1gQzo5dAV88/kpkZVps8Q==\n-----END RSA PRIVATE KEY-----\n",
- Certificate: "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- IntCertificate: "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n",
- }
-
- cm, err := UpdateCert(client.ServiceClient(), lbID, certID, opts).Extract()
- th.AssertNoErr(t, err)
-
- expected := &Certificate{
- ID: 123,
- HostName: "rackspace.com",
- Certificate: "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n",
- IntCertificate: "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n",
- }
- th.AssertDeepEquals(t, expected, cm)
-}
-
-func TestDeleteCert(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteCertResponse(t, lbID, certID)
-
- err := DeleteCert(client.ServiceClient(), lbID, certID).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/lb/v1/ssl/results.go b/rackspace/lb/v1/ssl/results.go
deleted file mode 100644
index ead9fcd..0000000
--- a/rackspace/lb/v1/ssl/results.go
+++ /dev/null
@@ -1,148 +0,0 @@
-package ssl
-
-import (
- "github.com/mitchellh/mapstructure"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// SSLTermConfig represents the SSL configuration for a particular load balancer.
-type SSLTermConfig struct {
- // The port on which the SSL termination load balancer listens for secure
- // traffic. The value must be unique to the existing LB protocol/port
- // combination
- SecurePort int `mapstructure:"securePort"`
-
- // The private key for the SSL certificate which is validated and verified
- // against the provided certificates.
- PrivateKey string `mapstructure:"privatekey"`
-
- // The certificate used for SSL termination, which is validated and verified
- // against the key and intermediate certificate if provided.
- Certificate string
-
- // The intermediate certificate (for the user). The intermediate certificate
- // is validated and verified against the key and certificate credentials
- // provided. A user may only provide this value when accompanied by a
- // Certificate, PrivateKey, and SecurePort. It may not be added or updated as
- // a single attribute in a future operation.
- IntCertificate string `mapstructure:"intermediatecertificate"`
-
- // Determines if the load balancer is enabled to terminate SSL traffic or not.
- // If this is set to false, the load balancer retains its specified SSL
- // attributes but does not terminate SSL traffic.
- Enabled bool
-
- // Determines if the load balancer can only accept secure traffic. If set to
- // true, the load balancer will not accept non-secure traffic.
- SecureTrafficOnly bool
-}
-
-// 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 {
- gophercloud.Result
-}
-
-// Extract interprets a GetResult as a SSLTermConfig struct, if possible.
-func (r GetResult) Extract() (*SSLTermConfig, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- SSL SSLTermConfig `mapstructure:"sslTermination"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- return &response.SSL, err
-}
-
-// Certificate represents an SSL certificate associated with an SSL-terminated
-// HTTP load balancer.
-type Certificate struct {
- ID int
- HostName string
- Certificate string
- IntCertificate string `mapstructure:"intermediateCertificate"`
-}
-
-// CertPage represents a page of certificates.
-type CertPage struct {
- pagination.LinkedPageBase
-}
-
-// IsEmpty checks whether a CertMappingPage struct is empty.
-func (p CertPage) IsEmpty() (bool, error) {
- is, err := ExtractCerts(p)
- if err != nil {
- return true, nil
- }
- return len(is) == 0, nil
-}
-
-// 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 {
- Cert Certificate `mapstructure:"certificateMapping" json:"certificateMapping"`
- }
- var resp struct {
- Certs []NestedMap `mapstructure:"certificateMappings" json:"certificateMappings"`
- }
-
- err := mapstructure.Decode(page.(CertPage).Body, &resp)
-
- slice := []Certificate{}
- for _, cert := range resp.Certs {
- slice = append(slice, cert.Cert)
- }
-
- return slice, err
-}
-
-type certResult struct {
- gophercloud.Result
-}
-
-// Extract interprets a result as a CertMapping struct, if possible.
-func (r certResult) Extract() (*Certificate, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- Cert Certificate `mapstructure:"certificateMapping"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- return &response.Cert, err
-}
-
-// CreateCertResult represents the result of an CreateCert operation.
-type CreateCertResult 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
-}
diff --git a/rackspace/lb/v1/ssl/urls.go b/rackspace/lb/v1/ssl/urls.go
deleted file mode 100644
index aa814b3..0000000
--- a/rackspace/lb/v1/ssl/urls.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package ssl
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-const (
- path = "loadbalancers"
- sslPath = "ssltermination"
- certPath = "certificatemappings"
-)
-
-func rootURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id), sslPath)
-}
-
-func certURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id), sslPath, certPath)
-}
-
-func certResourceURL(c *gophercloud.ServiceClient, id, certID int) string {
- return c.ServiceURL(path, strconv.Itoa(id), sslPath, certPath, strconv.Itoa(certID))
-}
diff --git a/rackspace/lb/v1/throttle/doc.go b/rackspace/lb/v1/throttle/doc.go
deleted file mode 100644
index 1ed605d..0000000
--- a/rackspace/lb/v1/throttle/doc.go
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
-Package throttle provides information and interaction with the Connection
-Throttling feature of the Rackspace Cloud Load Balancer service.
-*/
-package throttle
diff --git a/rackspace/lb/v1/throttle/fixtures.go b/rackspace/lb/v1/throttle/fixtures.go
deleted file mode 100644
index f3e49fa..0000000
--- a/rackspace/lb/v1/throttle/fixtures.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package throttle
-
-import (
- "fmt"
- "net/http"
- "strconv"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func _rootURL(id int) string {
- return "/loadbalancers/" + strconv.Itoa(id) + "/connectionthrottle"
-}
-
-func mockGetResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "connectionThrottle": {
- "maxConnections": 100
- }
-}
-`)
- })
-}
-
-func mockCreateResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "connectionThrottle": {
- "maxConnectionRate": 0,
- "maxConnections": 200,
- "minConnections": 0,
- "rateInterval": 0
- }
-}
- `)
-
- w.WriteHeader(http.StatusAccepted)
- fmt.Fprintf(w, `{}`)
- })
-}
-
-func mockDeleteResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
diff --git a/rackspace/lb/v1/throttle/requests.go b/rackspace/lb/v1/throttle/requests.go
deleted file mode 100644
index 0446b97..0000000
--- a/rackspace/lb/v1/throttle/requests.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package throttle
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
-)
-
-// CreateOptsBuilder is the interface options structs have to satisfy in order
-// to be used in the main Create operation in this package.
-type CreateOptsBuilder interface {
- ToCTCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts is the common options struct used in this package's Create
-// operation.
-type CreateOpts struct {
- // Required - the maximum amount of connections per IP address to allow per LB.
- MaxConnections int
-
- // Deprecated as of v1.22.
- MaxConnectionRate int
-
- // Deprecated as of v1.22.
- MinConnections int
-
- // Deprecated as of v1.22.
- RateInterval int
-}
-
-// ToCTCreateMap casts a CreateOpts struct to a map.
-func (opts CreateOpts) ToCTCreateMap() (map[string]interface{}, error) {
- ct := make(map[string]interface{})
-
- if opts.MaxConnections < 0 || opts.MaxConnections > 100000 {
- return ct, errors.New("MaxConnections must be an int between 0 and 100000")
- }
-
- ct["maxConnections"] = opts.MaxConnections
- ct["maxConnectionRate"] = opts.MaxConnectionRate
- ct["minConnections"] = opts.MinConnections
- ct["rateInterval"] = opts.RateInterval
-
- return map[string]interface{}{"connectionThrottle": ct}, nil
-}
-
-// Create is the operation responsible for creating or updating the connection
-// throttling configuration for a load balancer.
-func Create(c *gophercloud.ServiceClient, lbID int, opts CreateOptsBuilder) CreateResult {
- var res CreateResult
-
- reqBody, err := opts.ToCTCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, nil)
- return res
-}
-
-// Get is the operation responsible for showing the details of the connection
-// throttling configuration for a load balancer.
-func Get(c *gophercloud.ServiceClient, lbID int) GetResult {
- var res GetResult
- _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil)
- return res
-}
-
-// Delete is the operation responsible for deleting the connection throttling
-// configuration for a load balancer.
-func Delete(c *gophercloud.ServiceClient, lbID int) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(rootURL(c, lbID), nil)
- return res
-}
diff --git a/rackspace/lb/v1/throttle/requests_test.go b/rackspace/lb/v1/throttle/requests_test.go
deleted file mode 100644
index 6e9703f..0000000
--- a/rackspace/lb/v1/throttle/requests_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package throttle
-
-import (
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const lbID = 12345
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockCreateResponse(t, lbID)
-
- opts := CreateOpts{MaxConnections: 200}
- err := Create(client.ServiceClient(), lbID, opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockGetResponse(t, lbID)
-
- sp, err := Get(client.ServiceClient(), lbID).Extract()
- th.AssertNoErr(t, err)
-
- expected := &ConnectionThrottle{MaxConnections: 100}
- th.AssertDeepEquals(t, expected, sp)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteResponse(t, lbID)
-
- err := Delete(client.ServiceClient(), lbID).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/lb/v1/throttle/results.go b/rackspace/lb/v1/throttle/results.go
deleted file mode 100644
index db93c6f..0000000
--- a/rackspace/lb/v1/throttle/results.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package throttle
-
-import (
- "github.com/mitchellh/mapstructure"
-
- "github.com/rackspace/gophercloud"
-)
-
-// ConnectionThrottle represents the connection throttle configuration for a
-// particular load balancer.
-type ConnectionThrottle struct {
- MaxConnections int
-}
-
-// 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
-}
-
-// GetResult represents the result of a get operation.
-type GetResult struct {
- gophercloud.Result
-}
-
-// Extract interprets a GetResult as a SP, if possible.
-func (r GetResult) Extract() (*ConnectionThrottle, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var response struct {
- CT ConnectionThrottle `mapstructure:"connectionThrottle"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
-
- return &response.CT, err
-}
diff --git a/rackspace/lb/v1/throttle/urls.go b/rackspace/lb/v1/throttle/urls.go
deleted file mode 100644
index b77f0ac..0000000
--- a/rackspace/lb/v1/throttle/urls.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package throttle
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-const (
- path = "loadbalancers"
- ctPath = "connectionthrottle"
-)
-
-func rootURL(c *gophercloud.ServiceClient, id int) string {
- return c.ServiceURL(path, strconv.Itoa(id), ctPath)
-}
diff --git a/rackspace/lb/v1/vips/doc.go b/rackspace/lb/v1/vips/doc.go
deleted file mode 100644
index 5c3846d..0000000
--- a/rackspace/lb/v1/vips/doc.go
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-Package vips provides information and interaction with the Virtual IP API
-resource for the Rackspace Cloud Load Balancer service.
-
-A virtual IP (VIP) makes a load balancer accessible by clients. The load
-balancing service supports either a public VIP, routable on the public Internet,
-or a ServiceNet address, routable only within the region in which the load
-balancer resides.
-
-All load balancers must have at least one virtual IP associated with them at
-all times.
-*/
-package vips
diff --git a/rackspace/lb/v1/vips/fixtures.go b/rackspace/lb/v1/vips/fixtures.go
deleted file mode 100644
index 158759f..0000000
--- a/rackspace/lb/v1/vips/fixtures.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package vips
-
-import (
- "fmt"
- "net/http"
- "strconv"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func _rootURL(lbID int) string {
- return "/loadbalancers/" + strconv.Itoa(lbID) + "/virtualips"
-}
-
-func mockListResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "virtualIps": [
- {
- "id": 1000,
- "address": "206.10.10.210",
- "type": "PUBLIC"
- }
- ]
-}
- `)
- })
-}
-
-func mockCreateResponse(t *testing.T, lbID int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- th.TestJSONRequest(t, r, `
-{
- "type":"PUBLIC",
- "ipVersion":"IPV6"
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusAccepted)
-
- fmt.Fprintf(w, `
-{
- "address":"fd24:f480:ce44:91bc:1af2:15ff:0000:0002",
- "id":9000134,
- "type":"PUBLIC",
- "ipVersion":"IPV6"
-}
- `)
- })
-}
-
-func mockBatchDeleteResponse(t *testing.T, lbID int, ids []int) {
- th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- r.ParseForm()
-
- for k, v := range ids {
- fids := r.Form["id"]
- th.AssertEquals(t, strconv.Itoa(v), fids[k])
- }
-
- w.WriteHeader(http.StatusAccepted)
- })
-}
-
-func mockDeleteResponse(t *testing.T, lbID, vipID int) {
- url := _rootURL(lbID) + "/" + strconv.Itoa(vipID)
- th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusAccepted)
- })
-}
diff --git a/rackspace/lb/v1/vips/requests.go b/rackspace/lb/v1/vips/requests.go
deleted file mode 100644
index 2bc924f..0000000
--- a/rackspace/lb/v1/vips/requests.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package vips
-
-import (
- "errors"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List is the operation responsible for returning a paginated collection of
-// load balancer virtual IP addresses.
-func List(client *gophercloud.ServiceClient, loadBalancerID int) pagination.Pager {
- url := rootURL(client, loadBalancerID)
- return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
- return VIPPage{pagination.SinglePageBase(r)}
- })
-}
-
-// 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
-// satisfy a basic interface in order for them to be used.
-type CreateOptsBuilder interface {
- ToVIPCreateMap() (map[string]interface{}, error)
-}
-
-// CreateOpts is the common options struct used in this package's Create
-// operation.
-type CreateOpts struct {
- // Optional - the ID of an existing virtual IP. By doing this, you are
- // allowing load balancers to share IPV6 addresses.
- ID string
-
- // Optional - the type of address.
- Type Type
-
- // Optional - the version of address.
- Version Version
-}
-
-// ToVIPCreateMap casts a CreateOpts struct to a map.
-func (opts CreateOpts) ToVIPCreateMap() (map[string]interface{}, error) {
- lb := make(map[string]interface{})
-
- if opts.ID != "" {
- lb["id"] = opts.ID
- }
- if opts.Type != "" {
- lb["type"] = opts.Type
- }
- if opts.Version != "" {
- lb["ipVersion"] = opts.Version
- }
-
- return lb, nil
-}
-
-// Create is the operation responsible for assigning a new Virtual IP to an
-// existing load balancer resource. Currently, only version 6 IP addresses may
-// be added.
-func Create(c *gophercloud.ServiceClient, lbID int, opts CreateOptsBuilder) CreateResult {
- var res CreateResult
-
- reqBody, err := opts.ToVIPCreateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Post(rootURL(c, lbID), reqBody, &res.Body, nil)
- return res
-}
-
-// BulkDelete is the operation responsible for batch deleting multiple VIPs in
-// a single operation. It accepts a slice of integer IDs and will remove them
-// from the load balancer. The maximum limit is 10 VIP removals at once.
-func BulkDelete(c *gophercloud.ServiceClient, loadBalancerID int, vipIDs []int) DeleteResult {
- var res DeleteResult
-
- if len(vipIDs) > 10 || len(vipIDs) == 0 {
- res.Err = errors.New("You must provide a minimum of 1 and a maximum of 10 VIP IDs")
- return res
- }
-
- url := rootURL(c, loadBalancerID)
- url += gophercloud.IDSliceToQueryString("id", vipIDs)
-
- _, res.Err = c.Delete(url, nil)
- return res
-}
-
-// Delete is the operation responsible for permanently deleting a VIP.
-func Delete(c *gophercloud.ServiceClient, lbID, vipID int) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(resourceURL(c, lbID, vipID), nil)
- return res
-}
diff --git a/rackspace/lb/v1/vips/requests_test.go b/rackspace/lb/v1/vips/requests_test.go
deleted file mode 100644
index 74ac461..0000000
--- a/rackspace/lb/v1/vips/requests_test.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package vips
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const (
- lbID = 12345
- vipID = 67890
- vipID2 = 67891
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockListResponse(t, lbID)
-
- count := 0
-
- err := List(client.ServiceClient(), lbID).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractVIPs(page)
- th.AssertNoErr(t, err)
-
- expected := []VIP{
- VIP{ID: 1000, Address: "206.10.10.210", Type: "PUBLIC"},
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- th.AssertNoErr(t, err)
- th.AssertEquals(t, 1, count)
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockCreateResponse(t, lbID)
-
- opts := CreateOpts{
- Type: "PUBLIC",
- Version: "IPV6",
- }
-
- vip, err := Create(client.ServiceClient(), lbID, opts).Extract()
- th.AssertNoErr(t, err)
-
- expected := &VIP{
- Address: "fd24:f480:ce44:91bc:1af2:15ff:0000:0002",
- ID: 9000134,
- Type: "PUBLIC",
- Version: "IPV6",
- }
-
- th.CheckDeepEquals(t, expected, vip)
-}
-
-func TestBulkDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- ids := []int{vipID, vipID2}
-
- mockBatchDeleteResponse(t, lbID, ids)
-
- err := BulkDelete(client.ServiceClient(), lbID, ids).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- mockDeleteResponse(t, lbID, vipID)
-
- err := Delete(client.ServiceClient(), lbID, vipID).ExtractErr()
- th.AssertNoErr(t, err)
-}
diff --git a/rackspace/lb/v1/vips/results.go b/rackspace/lb/v1/vips/results.go
deleted file mode 100644
index 678b2af..0000000
--- a/rackspace/lb/v1/vips/results.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package vips
-
-import (
- "github.com/mitchellh/mapstructure"
-
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// VIP represents a Virtual IP API resource.
-type VIP struct {
- Address string `json:"address,omitempty"`
- ID int `json:"id,omitempty"`
- Type Type `json:"type,omitempty"`
- Version Version `json:"ipVersion,omitempty" mapstructure:"ipVersion"`
-}
-
-// Version represents the version of a VIP.
-type Version string
-
-// Convenient constants to use for type
-const (
- IPV4 Version = "IPV4"
- IPV6 Version = "IPV6"
-)
-
-// Type represents the type of a VIP.
-type Type string
-
-const (
- // PUBLIC indicates a VIP type that is routable on the public Internet.
- PUBLIC Type = "PUBLIC"
-
- // PRIVATE indicates a VIP type that is routable only on ServiceNet.
- PRIVATE Type = "SERVICENET"
-)
-
-// VIPPage is the page returned by a pager when traversing over a collection
-// of VIPs.
-type VIPPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty checks whether a VIPPage struct is empty.
-func (p VIPPage) IsEmpty() (bool, error) {
- is, err := ExtractVIPs(p)
- if err != nil {
- return true, nil
- }
- return len(is) == 0, nil
-}
-
-// ExtractVIPs accepts a Page struct, specifically a VIPPage struct, and
-// extracts the elements into a slice of VIP structs. In other words, a
-// generic collection is mapped into a relevant slice.
-func ExtractVIPs(page pagination.Page) ([]VIP, error) {
- var resp struct {
- VIPs []VIP `mapstructure:"virtualIps" json:"virtualIps"`
- }
-
- err := mapstructure.Decode(page.(VIPPage).Body, &resp)
-
- return resp.VIPs, err
-}
-
-type commonResult struct {
- gophercloud.Result
-}
-
-func (r commonResult) Extract() (*VIP, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- resp := &VIP{}
- err := mapstructure.Decode(r.Body, resp)
-
- return resp, 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
-}
diff --git a/rackspace/lb/v1/vips/urls.go b/rackspace/lb/v1/vips/urls.go
deleted file mode 100644
index 28f063a..0000000
--- a/rackspace/lb/v1/vips/urls.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package vips
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-const (
- lbPath = "loadbalancers"
- vipPath = "virtualips"
-)
-
-func resourceURL(c *gophercloud.ServiceClient, lbID, nodeID int) string {
- return c.ServiceURL(lbPath, strconv.Itoa(lbID), vipPath, strconv.Itoa(nodeID))
-}
-
-func rootURL(c *gophercloud.ServiceClient, lbID int) string {
- return c.ServiceURL(lbPath, strconv.Itoa(lbID), vipPath)
-}
diff --git a/rackspace/networking/v2/common/common_tests.go b/rackspace/networking/v2/common/common_tests.go
deleted file mode 100644
index 129cd63..0000000
--- a/rackspace/networking/v2/common/common_tests.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package common
-
-import (
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-const TokenID = client.TokenID
-
-func ServiceClient() *gophercloud.ServiceClient {
- return client.ServiceClient()
-}
diff --git a/rackspace/networking/v2/networks/delegate.go b/rackspace/networking/v2/networks/delegate.go
deleted file mode 100644
index dcb0855..0000000
--- a/rackspace/networking/v2/networks/delegate.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package networks
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/networking/v2/networks"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager which allows you to iterate over a collection of
-// networks. It accepts a ListOpts struct, which allows you to filter and sort
-// the returned collection for greater efficiency.
-func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, opts)
-}
-
-// Get retrieves a specific network based on its unique ID.
-func Get(c *gophercloud.ServiceClient, networkID string) os.GetResult {
- return os.Get(c, networkID)
-}
-
-// Create accepts a CreateOpts struct and creates a new network using the values
-// provided. This operation does not actually require a request body, i.e. the
-// CreateOpts struct argument can be empty.
-//
-// The tenant ID that is contained in the URI is the tenant that creates the
-// network. An admin user, however, has the option of specifying another tenant
-// ID in the CreateOpts struct.
-func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(c, opts)
-}
-
-// Update accepts a UpdateOpts struct and updates an existing network using the
-// values provided. For more information, see the Create function.
-func Update(c *gophercloud.ServiceClient, networkID string, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(c, networkID, opts)
-}
-
-// Delete accepts a unique ID and deletes the network associated with it.
-func Delete(c *gophercloud.ServiceClient, networkID string) os.DeleteResult {
- return os.Delete(c, networkID)
-}
diff --git a/rackspace/networking/v2/networks/delegate_test.go b/rackspace/networking/v2/networks/delegate_test.go
deleted file mode 100644
index 0b3a6b1..0000000
--- a/rackspace/networking/v2/networks/delegate_test.go
+++ /dev/null
@@ -1,285 +0,0 @@
-package networks
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/networking/v2/networks"
- "github.com/rackspace/gophercloud/pagination"
- fake "github.com/rackspace/gophercloud/rackspace/networking/v2/common"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/networks", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "networks": [
- {
- "status": "ACTIVE",
- "subnets": [
- "54d6f61d-db07-451c-9ab3-b9609b6b6f0b"
- ],
- "name": "private-network",
- "admin_state_up": true,
- "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
- "shared": true,
- "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22"
- },
- {
- "status": "ACTIVE",
- "subnets": [
- "08eae331-0402-425a-923c-34f7cfe39c1b"
- ],
- "name": "private",
- "admin_state_up": true,
- "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
- "shared": true,
- "id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324"
- }
- ]
-}
- `)
- })
-
- client := fake.ServiceClient()
- count := 0
-
- List(client, os.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractNetworks(page)
- if err != nil {
- t.Errorf("Failed to extract networks: %v", err)
- return false, err
- }
-
- expected := []os.Network{
- os.Network{
- Status: "ACTIVE",
- Subnets: []string{"54d6f61d-db07-451c-9ab3-b9609b6b6f0b"},
- Name: "private-network",
- AdminStateUp: true,
- TenantID: "4fd44f30292945e481c7b8a0c8908869",
- Shared: true,
- ID: "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- },
- os.Network{
- Status: "ACTIVE",
- Subnets: []string{"08eae331-0402-425a-923c-34f7cfe39c1b"},
- Name: "private",
- AdminStateUp: true,
- TenantID: "26a7980765d0414dbc1fc1f88cdb7e6e",
- Shared: true,
- ID: "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "network": {
- "status": "ACTIVE",
- "subnets": [
- "54d6f61d-db07-451c-9ab3-b9609b6b6f0b"
- ],
- "name": "private-network",
- "admin_state_up": true,
- "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
- "shared": true,
- "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22"
- }
-}
- `)
- })
-
- n, err := Get(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.Status, "ACTIVE")
- th.AssertDeepEquals(t, n.Subnets, []string{"54d6f61d-db07-451c-9ab3-b9609b6b6f0b"})
- th.AssertEquals(t, n.Name, "private-network")
- th.AssertEquals(t, n.AdminStateUp, true)
- th.AssertEquals(t, n.TenantID, "4fd44f30292945e481c7b8a0c8908869")
- th.AssertEquals(t, n.Shared, true)
- th.AssertEquals(t, n.ID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/networks", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "network": {
- "name": "sample_network",
- "admin_state_up": true
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `
-{
- "network": {
- "status": "ACTIVE",
- "subnets": [],
- "name": "net1",
- "admin_state_up": true,
- "tenant_id": "9bacb3c5d39d41a79512987f338cf177",
- "shared": false,
- "id": "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
- }
-}
- `)
- })
-
- iTrue := true
- options := os.CreateOpts{Name: "sample_network", AdminStateUp: &iTrue}
- n, err := Create(fake.ServiceClient(), options).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.Status, "ACTIVE")
- th.AssertDeepEquals(t, n.Subnets, []string{})
- th.AssertEquals(t, n.Name, "net1")
- th.AssertEquals(t, n.AdminStateUp, true)
- th.AssertEquals(t, n.TenantID, "9bacb3c5d39d41a79512987f338cf177")
- th.AssertEquals(t, n.Shared, false)
- th.AssertEquals(t, n.ID, "4e8e5957-649f-477b-9e5b-f1f75b21c03c")
-}
-
-func TestCreateWithOptionalFields(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/networks", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "network": {
- "name": "sample_network",
- "admin_state_up": true,
- "shared": true,
- "tenant_id": "12345"
- }
-}
- `)
- w.WriteHeader(http.StatusCreated)
- fmt.Fprintf(w, `
-{
- "network": {
- "name": "sample_network",
- "admin_state_up": true,
- "shared": true,
- "tenant_id": "12345"
- }
-}
- `)
- })
-
- iTrue := true
- options := os.CreateOpts{Name: "sample_network", AdminStateUp: &iTrue, Shared: &iTrue, TenantID: "12345"}
- _, err := Create(fake.ServiceClient(), options).Extract()
- th.AssertNoErr(t, err)
-}
-
-func TestUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/networks/4e8e5957-649f-477b-9e5b-f1f75b21c03c", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "network": {
- "name": "new_network_name",
- "admin_state_up": false,
- "shared": true
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "network": {
- "status": "ACTIVE",
- "subnets": [],
- "name": "new_network_name",
- "admin_state_up": false,
- "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
- "shared": true,
- "id": "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
- }
-}
- `)
- })
-
- iTrue := true
- options := os.UpdateOpts{Name: "new_network_name", AdminStateUp: os.Down, Shared: &iTrue}
- n, err := Update(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.Name, "new_network_name")
- th.AssertEquals(t, n.AdminStateUp, false)
- th.AssertEquals(t, n.Shared, true)
- th.AssertEquals(t, n.ID, "4e8e5957-649f-477b-9e5b-f1f75b21c03c")
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/networks/4e8e5957-649f-477b-9e5b-f1f75b21c03c", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-
- res := Delete(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/networking/v2/ports/delegate.go b/rackspace/networking/v2/ports/delegate.go
deleted file mode 100644
index 95728d1..0000000
--- a/rackspace/networking/v2/ports/delegate.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package ports
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/networking/v2/ports"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager which allows you to iterate over a collection of
-// ports. It accepts a ListOpts struct, which allows you to filter and sort
-// the returned collection for greater efficiency.
-//
-// Default policy settings return only those ports that are owned by the tenant
-// who submits the request, unless the request is submitted by a user with
-// administrative rights.
-func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, opts)
-}
-
-// Get retrieves a specific port based on its unique ID.
-func Get(c *gophercloud.ServiceClient, networkID string) os.GetResult {
- return os.Get(c, networkID)
-}
-
-// Create accepts a CreateOpts struct and creates a new network using the values
-// provided. You must remember to provide a NetworkID value.
-//
-// NOTE: Currently the SecurityGroup option is not implemented to work with
-// Rackspace.
-func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(c, opts)
-}
-
-// Update accepts a UpdateOpts struct and updates an existing port using the
-// values provided.
-func Update(c *gophercloud.ServiceClient, networkID string, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(c, networkID, opts)
-}
-
-// Delete accepts a unique ID and deletes the port associated with it.
-func Delete(c *gophercloud.ServiceClient, networkID string) os.DeleteResult {
- return os.Delete(c, networkID)
-}
diff --git a/rackspace/networking/v2/ports/delegate_test.go b/rackspace/networking/v2/ports/delegate_test.go
deleted file mode 100644
index f53ff59..0000000
--- a/rackspace/networking/v2/ports/delegate_test.go
+++ /dev/null
@@ -1,322 +0,0 @@
-package ports
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/networking/v2/ports"
- "github.com/rackspace/gophercloud/pagination"
- fake "github.com/rackspace/gophercloud/rackspace/networking/v2/common"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/ports", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "ports": [
- {
- "status": "ACTIVE",
- "binding:host_id": "devstack",
- "name": "",
- "admin_state_up": true,
- "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3",
- "tenant_id": "",
- "device_owner": "network:router_gateway",
- "mac_address": "fa:16:3e:58:42:ed",
- "fixed_ips": [
- {
- "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062",
- "ip_address": "172.24.4.2"
- }
- ],
- "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b",
- "security_groups": [],
- "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824"
- }
- ]
-}
- `)
- })
-
- count := 0
-
- List(fake.ServiceClient(), os.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractPorts(page)
- if err != nil {
- t.Errorf("Failed to extract subnets: %v", err)
- return false, nil
- }
-
- expected := []os.Port{
- os.Port{
- Status: "ACTIVE",
- Name: "",
- AdminStateUp: true,
- NetworkID: "70c1db1f-b701-45bd-96e0-a313ee3430b3",
- TenantID: "",
- DeviceOwner: "network:router_gateway",
- MACAddress: "fa:16:3e:58:42:ed",
- FixedIPs: []os.IP{
- os.IP{
- SubnetID: "008ba151-0b8c-4a67-98b5-0d2b87666062",
- IPAddress: "172.24.4.2",
- },
- },
- ID: "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b",
- SecurityGroups: []string{},
- DeviceID: "9ae135f4-b6e0-4dad-9e91-3c223e385824",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/ports/46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "port": {
- "status": "ACTIVE",
- "name": "",
- "admin_state_up": true,
- "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7",
- "tenant_id": "7e02058126cc4950b75f9970368ba177",
- "device_owner": "network:router_interface",
- "mac_address": "fa:16:3e:23:fd:d7",
- "fixed_ips": [
- {
- "subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2",
- "ip_address": "10.0.0.1"
- }
- ],
- "id": "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2",
- "security_groups": [],
- "device_id": "5e3898d7-11be-483e-9732-b2f5eccd2b2e"
- }
-}
- `)
- })
-
- n, err := Get(fake.ServiceClient(), "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.Status, "ACTIVE")
- th.AssertEquals(t, n.Name, "")
- th.AssertEquals(t, n.AdminStateUp, true)
- th.AssertEquals(t, n.NetworkID, "a87cc70a-3e15-4acf-8205-9b711a3531b7")
- th.AssertEquals(t, n.TenantID, "7e02058126cc4950b75f9970368ba177")
- th.AssertEquals(t, n.DeviceOwner, "network:router_interface")
- th.AssertEquals(t, n.MACAddress, "fa:16:3e:23:fd:d7")
- th.AssertDeepEquals(t, n.FixedIPs, []os.IP{
- os.IP{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.1"},
- })
- th.AssertEquals(t, n.ID, "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2")
- th.AssertDeepEquals(t, n.SecurityGroups, []string{})
- th.AssertEquals(t, n.Status, "ACTIVE")
- th.AssertEquals(t, n.DeviceID, "5e3898d7-11be-483e-9732-b2f5eccd2b2e")
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/ports", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "port": {
- "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7",
- "name": "private-port",
- "admin_state_up": true,
- "fixed_ips": [
- {
- "subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2",
- "ip_address": "10.0.0.2"
- }
- ],
- "security_groups": ["foo"]
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `
-{
- "port": {
- "status": "DOWN",
- "name": "private-port",
- "allowed_address_pairs": [],
- "admin_state_up": true,
- "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7",
- "tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa",
- "device_owner": "",
- "mac_address": "fa:16:3e:c9:cb:f0",
- "fixed_ips": [
- {
- "subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2",
- "ip_address": "10.0.0.2"
- }
- ],
- "id": "65c0ee9f-d634-4522-8954-51021b570b0d",
- "security_groups": [
- "f0ac4394-7e4a-4409-9701-ba8be283dbc3"
- ],
- "device_id": ""
- }
-}
- `)
- })
-
- asu := true
- options := os.CreateOpts{
- Name: "private-port",
- AdminStateUp: &asu,
- NetworkID: "a87cc70a-3e15-4acf-8205-9b711a3531b7",
- FixedIPs: []os.IP{
- os.IP{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.2"},
- },
- SecurityGroups: []string{"foo"},
- }
- n, err := Create(fake.ServiceClient(), options).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, n.Status, "DOWN")
- th.AssertEquals(t, n.Name, "private-port")
- th.AssertEquals(t, n.AdminStateUp, true)
- th.AssertEquals(t, n.NetworkID, "a87cc70a-3e15-4acf-8205-9b711a3531b7")
- th.AssertEquals(t, n.TenantID, "d6700c0c9ffa4f1cb322cd4a1f3906fa")
- th.AssertEquals(t, n.DeviceOwner, "")
- th.AssertEquals(t, n.MACAddress, "fa:16:3e:c9:cb:f0")
- th.AssertDeepEquals(t, n.FixedIPs, []os.IP{
- os.IP{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.2"},
- })
- th.AssertEquals(t, n.ID, "65c0ee9f-d634-4522-8954-51021b570b0d")
- th.AssertDeepEquals(t, n.SecurityGroups, []string{"f0ac4394-7e4a-4409-9701-ba8be283dbc3"})
-}
-
-func TestRequiredCreateOpts(t *testing.T) {
- res := Create(fake.ServiceClient(), os.CreateOpts{})
- if res.Err == nil {
- t.Fatalf("Expected error, got none")
- }
-}
-
-func TestUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/ports/65c0ee9f-d634-4522-8954-51021b570b0d", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "port": {
- "name": "new_port_name",
- "fixed_ips": [
- {
- "subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2",
- "ip_address": "10.0.0.3"
- }
- ],
- "security_groups": [
- "f0ac4394-7e4a-4409-9701-ba8be283dbc3"
- ]
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "port": {
- "status": "DOWN",
- "name": "new_port_name",
- "admin_state_up": true,
- "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7",
- "tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa",
- "device_owner": "",
- "mac_address": "fa:16:3e:c9:cb:f0",
- "fixed_ips": [
- {
- "subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2",
- "ip_address": "10.0.0.3"
- }
- ],
- "id": "65c0ee9f-d634-4522-8954-51021b570b0d",
- "security_groups": [
- "f0ac4394-7e4a-4409-9701-ba8be283dbc3"
- ],
- "device_id": ""
- }
-}
- `)
- })
-
- options := os.UpdateOpts{
- Name: "new_port_name",
- FixedIPs: []os.IP{
- os.IP{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.3"},
- },
- SecurityGroups: []string{"f0ac4394-7e4a-4409-9701-ba8be283dbc3"},
- }
-
- s, err := Update(fake.ServiceClient(), "65c0ee9f-d634-4522-8954-51021b570b0d", options).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, s.Name, "new_port_name")
- th.AssertDeepEquals(t, s.FixedIPs, []os.IP{
- os.IP{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.3"},
- })
- th.AssertDeepEquals(t, s.SecurityGroups, []string{"f0ac4394-7e4a-4409-9701-ba8be283dbc3"})
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/ports/65c0ee9f-d634-4522-8954-51021b570b0d", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-
- res := Delete(fake.ServiceClient(), "65c0ee9f-d634-4522-8954-51021b570b0d")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/networking/v2/security/doc.go b/rackspace/networking/v2/security/doc.go
deleted file mode 100644
index 31f744c..0000000
--- a/rackspace/networking/v2/security/doc.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// Package security contains functionality to work with security group and
-// security group rules Neutron resources.
-//
-// Security groups and security group rules allows administrators and tenants
-// the ability to specify the type of traffic and direction (ingress/egress)
-// that is allowed to pass through a port. A security group is a container for
-// security group rules.
-//
-// When a port is created in Networking it is associated with a security group.
-// If a security group is not specified the port is associated with a 'default'
-// security group. By default, this group drops all ingress traffic and allows
-// all egress. Rules can be added to this group in order to change the behaviour.
-//
-// The basic characteristics of Neutron Security Groups are:
-//
-// For ingress traffic (to an instance)
-// - Only traffic matched with security group rules are allowed.
-// - When there is no rule defined, all traffic is dropped.
-//
-// For egress traffic (from an instance)
-// - Only traffic matched with security group rules are allowed.
-// - When there is no rule defined, all egress traffic are dropped.
-// - When a new security group is created, rules to allow all egress traffic
-// is automatically added.
-//
-// "default security group" is defined for each tenant.
-// - For the default security group a rule which allows intercommunication
-// among hosts associated with the default security group is defined by default.
-// - As a result, all egress traffic and intercommunication in the default
-// group are allowed and all ingress from outside of the default group is
-// dropped by default (in the default security group).
-package security
diff --git a/rackspace/networking/v2/security/groups/delegate.go b/rackspace/networking/v2/security/groups/delegate.go
deleted file mode 100644
index 1e9a23a..0000000
--- a/rackspace/networking/v2/security/groups/delegate.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package groups
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager which allows you to iterate over a collection of
-// security groups. It accepts a ListOpts struct, which allows you to filter
-// and sort the returned collection for greater efficiency.
-func List(c *gophercloud.ServiceClient, opts os.ListOpts) pagination.Pager {
- return os.List(c, opts)
-}
-
-// Create is an operation which provisions a new security group with default
-// security group rules for the IPv4 and IPv6 ether types.
-func Create(c *gophercloud.ServiceClient, opts os.CreateOpts) os.CreateResult {
- return os.Create(c, opts)
-}
-
-// Get retrieves a particular security group based on its unique ID.
-func Get(c *gophercloud.ServiceClient, id string) os.GetResult {
- return os.Get(c, id)
-}
-
-// Delete will permanently delete a particular security group based on its unique ID.
-func Delete(c *gophercloud.ServiceClient, id string) os.DeleteResult {
- return os.Delete(c, id)
-}
diff --git a/rackspace/networking/v2/security/groups/delegate_test.go b/rackspace/networking/v2/security/groups/delegate_test.go
deleted file mode 100644
index 45cd3ba..0000000
--- a/rackspace/networking/v2/security/groups/delegate_test.go
+++ /dev/null
@@ -1,206 +0,0 @@
-package groups
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- fake "github.com/rackspace/gophercloud/openstack/networking/v2/common"
- osGroups "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups"
- osRules "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/security-groups", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
- {
- "security_groups": [
- {
- "description": "default",
- "id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "name": "default",
- "security_group_rules": [],
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- }
- ]
- }
- `)
- })
-
- count := 0
-
- List(fake.ServiceClient(), osGroups.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := osGroups.ExtractGroups(page)
- if err != nil {
- t.Errorf("Failed to extract secgroups: %v", err)
- return false, err
- }
-
- expected := []osGroups.SecGroup{
- osGroups.SecGroup{
- Description: "default",
- ID: "85cc3048-abc3-43cc-89b3-377341426ac5",
- Name: "default",
- Rules: []osRules.SecGroupRule{},
- TenantID: "e4f50856753b4dc6afee5fa6b9b6c550",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/security-groups", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
- {
- "security_group": {
- "name": "new-webservers",
- "description": "security group for webservers"
- }
- }
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `
- {
- "security_group": {
- "description": "security group for webservers",
- "id": "2076db17-a522-4506-91de-c6dd8e837028",
- "name": "new-webservers",
- "security_group_rules": [
- {
- "direction": "egress",
- "ethertype": "IPv4",
- "id": "38ce2d8e-e8f1-48bd-83c2-d33cb9f50c3d",
- "port_range_max": null,
- "port_range_min": null,
- "protocol": null,
- "remote_group_id": null,
- "remote_ip_prefix": null,
- "security_group_id": "2076db17-a522-4506-91de-c6dd8e837028",
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- },
- {
- "direction": "egress",
- "ethertype": "IPv6",
- "id": "565b9502-12de-4ffd-91e9-68885cff6ae1",
- "port_range_max": null,
- "port_range_min": null,
- "protocol": null,
- "remote_group_id": null,
- "remote_ip_prefix": null,
- "security_group_id": "2076db17-a522-4506-91de-c6dd8e837028",
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- }
- ],
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- }
- }
- `)
- })
-
- opts := osGroups.CreateOpts{Name: "new-webservers", Description: "security group for webservers"}
- _, err := Create(fake.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/security-groups/85cc3048-abc3-43cc-89b3-377341426ac5", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
- {
- "security_group": {
- "description": "default",
- "id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "name": "default",
- "security_group_rules": [
- {
- "direction": "egress",
- "ethertype": "IPv6",
- "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
- "port_range_max": null,
- "port_range_min": null,
- "protocol": null,
- "remote_group_id": null,
- "remote_ip_prefix": null,
- "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- },
- {
- "direction": "egress",
- "ethertype": "IPv4",
- "id": "93aa42e5-80db-4581-9391-3a608bd0e448",
- "port_range_max": null,
- "port_range_min": null,
- "protocol": null,
- "remote_group_id": null,
- "remote_ip_prefix": null,
- "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- }
- ],
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- }
- }
- `)
- })
-
- sg, err := Get(fake.ServiceClient(), "85cc3048-abc3-43cc-89b3-377341426ac5").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, "default", sg.Description)
- th.AssertEquals(t, "85cc3048-abc3-43cc-89b3-377341426ac5", sg.ID)
- th.AssertEquals(t, "default", sg.Name)
- th.AssertEquals(t, 2, len(sg.Rules))
- th.AssertEquals(t, "e4f50856753b4dc6afee5fa6b9b6c550", sg.TenantID)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/security-groups/4ec89087-d057-4e2c-911f-60a3b47ee304", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-
- res := Delete(fake.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/networking/v2/security/rules/delegate.go b/rackspace/networking/v2/security/rules/delegate.go
deleted file mode 100644
index 23b4b31..0000000
--- a/rackspace/networking/v2/security/rules/delegate.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package rules
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager which allows you to iterate over a collection of
-// security group rules. It accepts a ListOpts struct, which allows you to filter
-// and sort the returned collection for greater efficiency.
-func List(c *gophercloud.ServiceClient, opts os.ListOpts) pagination.Pager {
- return os.List(c, opts)
-}
-
-// Create is an operation which provisions a new security group with default
-// security group rules for the IPv4 and IPv6 ether types.
-func Create(c *gophercloud.ServiceClient, opts os.CreateOpts) os.CreateResult {
- return os.Create(c, opts)
-}
-
-// Get retrieves a particular security group based on its unique ID.
-func Get(c *gophercloud.ServiceClient, id string) os.GetResult {
- return os.Get(c, id)
-}
-
-// Delete will permanently delete a particular security group based on its unique ID.
-func Delete(c *gophercloud.ServiceClient, id string) os.DeleteResult {
- return os.Delete(c, id)
-}
diff --git a/rackspace/networking/v2/security/rules/delegate_test.go b/rackspace/networking/v2/security/rules/delegate_test.go
deleted file mode 100644
index 3563fbe..0000000
--- a/rackspace/networking/v2/security/rules/delegate_test.go
+++ /dev/null
@@ -1,236 +0,0 @@
-package rules
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- fake "github.com/rackspace/gophercloud/openstack/networking/v2/common"
- osRules "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/security-group-rules", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
- {
- "security_group_rules": [
- {
- "direction": "egress",
- "ethertype": "IPv6",
- "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
- "port_range_max": null,
- "port_range_min": null,
- "protocol": null,
- "remote_group_id": null,
- "remote_ip_prefix": null,
- "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- },
- {
- "direction": "egress",
- "ethertype": "IPv4",
- "id": "93aa42e5-80db-4581-9391-3a608bd0e448",
- "port_range_max": null,
- "port_range_min": null,
- "protocol": null,
- "remote_group_id": null,
- "remote_ip_prefix": null,
- "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- }
- ]
- }
- `)
- })
-
- count := 0
-
- List(fake.ServiceClient(), osRules.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := osRules.ExtractRules(page)
- if err != nil {
- t.Errorf("Failed to extract secrules: %v", err)
- return false, err
- }
-
- expected := []osRules.SecGroupRule{
- osRules.SecGroupRule{
- Direction: "egress",
- EtherType: "IPv6",
- ID: "3c0e45ff-adaf-4124-b083-bf390e5482ff",
- PortRangeMax: 0,
- PortRangeMin: 0,
- Protocol: "",
- RemoteGroupID: "",
- RemoteIPPrefix: "",
- SecGroupID: "85cc3048-abc3-43cc-89b3-377341426ac5",
- TenantID: "e4f50856753b4dc6afee5fa6b9b6c550",
- },
- osRules.SecGroupRule{
- Direction: "egress",
- EtherType: "IPv4",
- ID: "93aa42e5-80db-4581-9391-3a608bd0e448",
- PortRangeMax: 0,
- PortRangeMin: 0,
- Protocol: "",
- RemoteGroupID: "",
- RemoteIPPrefix: "",
- SecGroupID: "85cc3048-abc3-43cc-89b3-377341426ac5",
- TenantID: "e4f50856753b4dc6afee5fa6b9b6c550",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/security-group-rules", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
- {
- "security_group_rule": {
- "direction": "ingress",
- "port_range_min": 80,
- "ethertype": "IPv4",
- "port_range_max": 80,
- "protocol": "tcp",
- "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "security_group_id": "a7734e61-b545-452d-a3cd-0189cbd9747a"
- }
- }
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `
- {
- "security_group_rule": {
- "direction": "ingress",
- "ethertype": "IPv4",
- "id": "2bc0accf-312e-429a-956e-e4407625eb62",
- "port_range_max": 80,
- "port_range_min": 80,
- "protocol": "tcp",
- "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "remote_ip_prefix": null,
- "security_group_id": "a7734e61-b545-452d-a3cd-0189cbd9747a",
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- }
- }
- `)
- })
-
- opts := osRules.CreateOpts{
- Direction: "ingress",
- PortRangeMin: 80,
- EtherType: "IPv4",
- PortRangeMax: 80,
- Protocol: "tcp",
- RemoteGroupID: "85cc3048-abc3-43cc-89b3-377341426ac5",
- SecGroupID: "a7734e61-b545-452d-a3cd-0189cbd9747a",
- }
- _, err := Create(fake.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
-}
-
-func TestRequiredCreateOpts(t *testing.T) {
- res := Create(fake.ServiceClient(), osRules.CreateOpts{Direction: "something"})
- if res.Err == nil {
- t.Fatalf("Expected error, got none")
- }
- res = Create(fake.ServiceClient(), osRules.CreateOpts{Direction: osRules.DirIngress, EtherType: "something"})
- if res.Err == nil {
- t.Fatalf("Expected error, got none")
- }
- res = Create(fake.ServiceClient(), osRules.CreateOpts{Direction: osRules.DirIngress, EtherType: osRules.Ether4})
- if res.Err == nil {
- t.Fatalf("Expected error, got none")
- }
- res = Create(fake.ServiceClient(), osRules.CreateOpts{Direction: osRules.DirIngress, EtherType: osRules.Ether4, SecGroupID: "something", Protocol: "foo"})
- if res.Err == nil {
- t.Fatalf("Expected error, got none")
- }
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/security-group-rules/3c0e45ff-adaf-4124-b083-bf390e5482ff", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
- {
- "security_group_rule": {
- "direction": "egress",
- "ethertype": "IPv6",
- "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
- "port_range_max": null,
- "port_range_min": null,
- "protocol": null,
- "remote_group_id": null,
- "remote_ip_prefix": null,
- "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
- "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
- }
- }
- `)
- })
-
- sr, err := Get(fake.ServiceClient(), "3c0e45ff-adaf-4124-b083-bf390e5482ff").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, "egress", sr.Direction)
- th.AssertEquals(t, "IPv6", sr.EtherType)
- th.AssertEquals(t, "3c0e45ff-adaf-4124-b083-bf390e5482ff", sr.ID)
- th.AssertEquals(t, 0, sr.PortRangeMax)
- th.AssertEquals(t, 0, sr.PortRangeMin)
- th.AssertEquals(t, "", sr.Protocol)
- th.AssertEquals(t, "", sr.RemoteGroupID)
- th.AssertEquals(t, "", sr.RemoteIPPrefix)
- th.AssertEquals(t, "85cc3048-abc3-43cc-89b3-377341426ac5", sr.SecGroupID)
- th.AssertEquals(t, "e4f50856753b4dc6afee5fa6b9b6c550", sr.TenantID)
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/v2.0/security-group-rules/4ec89087-d057-4e2c-911f-60a3b47ee304", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-
- res := Delete(fake.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/networking/v2/subnets/delegate.go b/rackspace/networking/v2/subnets/delegate.go
deleted file mode 100644
index a7fb7bb..0000000
--- a/rackspace/networking/v2/subnets/delegate.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package subnets
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/networking/v2/subnets"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns a Pager which allows you to iterate over a collection of
-// subnets. It accepts a ListOpts struct, which allows you to filter and sort
-// the returned collection for greater efficiency.
-//
-// Default policy settings return only those subnets that are owned by the tenant
-// who submits the request, unless the request is submitted by a user with
-// administrative rights.
-func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, opts)
-}
-
-// Get retrieves a specific subnet based on its unique ID.
-func Get(c *gophercloud.ServiceClient, networkID string) os.GetResult {
- return os.Get(c, networkID)
-}
-
-// Create accepts a CreateOpts struct and creates a new subnet using the values
-// provided. You must remember to provide a valid NetworkID, CIDR and IP version.
-func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(c, opts)
-}
-
-// Update accepts a UpdateOpts struct and updates an existing subnet using the
-// values provided.
-func Update(c *gophercloud.ServiceClient, networkID string, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(c, networkID, opts)
-}
-
-// Delete accepts a unique ID and deletes the subnet associated with it.
-func Delete(c *gophercloud.ServiceClient, networkID string) os.DeleteResult {
- return os.Delete(c, networkID)
-}
diff --git a/rackspace/networking/v2/subnets/delegate_test.go b/rackspace/networking/v2/subnets/delegate_test.go
deleted file mode 100644
index fafc6fb..0000000
--- a/rackspace/networking/v2/subnets/delegate_test.go
+++ /dev/null
@@ -1,363 +0,0 @@
-package subnets
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/networking/v2/subnets"
- "github.com/rackspace/gophercloud/pagination"
- fake "github.com/rackspace/gophercloud/rackspace/networking/v2/common"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/subnets", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "subnets": [
- {
- "name": "private-subnet",
- "enable_dhcp": true,
- "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
- "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
- "dns_nameservers": [],
- "allocation_pools": [
- {
- "start": "10.0.0.2",
- "end": "10.0.0.254"
- }
- ],
- "host_routes": [],
- "ip_version": 4,
- "gateway_ip": "10.0.0.1",
- "cidr": "10.0.0.0/24",
- "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
- },
- {
- "name": "my_subnet",
- "enable_dhcp": true,
- "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
- "dns_nameservers": [],
- "allocation_pools": [
- {
- "start": "192.0.0.2",
- "end": "192.255.255.254"
- }
- ],
- "host_routes": [],
- "ip_version": 4,
- "gateway_ip": "192.0.0.1",
- "cidr": "192.0.0.0/8",
- "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b"
- }
- ]
-}
- `)
- })
-
- count := 0
-
- List(fake.ServiceClient(), os.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractSubnets(page)
- if err != nil {
- t.Errorf("Failed to extract subnets: %v", err)
- return false, nil
- }
-
- expected := []os.Subnet{
- os.Subnet{
- Name: "private-subnet",
- EnableDHCP: true,
- NetworkID: "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
- TenantID: "26a7980765d0414dbc1fc1f88cdb7e6e",
- DNSNameservers: []string{},
- AllocationPools: []os.AllocationPool{
- os.AllocationPool{
- Start: "10.0.0.2",
- End: "10.0.0.254",
- },
- },
- HostRoutes: []os.HostRoute{},
- IPVersion: 4,
- GatewayIP: "10.0.0.1",
- CIDR: "10.0.0.0/24",
- ID: "08eae331-0402-425a-923c-34f7cfe39c1b",
- },
- os.Subnet{
- Name: "my_subnet",
- EnableDHCP: true,
- NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- TenantID: "4fd44f30292945e481c7b8a0c8908869",
- DNSNameservers: []string{},
- AllocationPools: []os.AllocationPool{
- os.AllocationPool{
- Start: "192.0.0.2",
- End: "192.255.255.254",
- },
- },
- HostRoutes: []os.HostRoute{},
- IPVersion: 4,
- GatewayIP: "192.0.0.1",
- CIDR: "192.0.0.0/8",
- ID: "54d6f61d-db07-451c-9ab3-b9609b6b6f0b",
- },
- }
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
-
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
-}
-
-func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/subnets/54d6f61d-db07-451c-9ab3-b9609b6b6f0b", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
-
- fmt.Fprintf(w, `
-{
- "subnet": {
- "name": "my_subnet",
- "enable_dhcp": true,
- "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
- "dns_nameservers": [],
- "allocation_pools": [
- {
- "start": "192.0.0.2",
- "end": "192.255.255.254"
- }
- ],
- "host_routes": [],
- "ip_version": 4,
- "gateway_ip": "192.0.0.1",
- "cidr": "192.0.0.0/8",
- "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b"
- }
-}
- `)
- })
-
- s, err := Get(fake.ServiceClient(), "54d6f61d-db07-451c-9ab3-b9609b6b6f0b").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, s.Name, "my_subnet")
- th.AssertEquals(t, s.EnableDHCP, true)
- th.AssertEquals(t, s.NetworkID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
- th.AssertEquals(t, s.TenantID, "4fd44f30292945e481c7b8a0c8908869")
- th.AssertDeepEquals(t, s.DNSNameservers, []string{})
- th.AssertDeepEquals(t, s.AllocationPools, []os.AllocationPool{
- os.AllocationPool{
- Start: "192.0.0.2",
- End: "192.255.255.254",
- },
- })
- th.AssertDeepEquals(t, s.HostRoutes, []os.HostRoute{})
- th.AssertEquals(t, s.IPVersion, 4)
- th.AssertEquals(t, s.GatewayIP, "192.0.0.1")
- th.AssertEquals(t, s.CIDR, "192.0.0.0/8")
- th.AssertEquals(t, s.ID, "54d6f61d-db07-451c-9ab3-b9609b6b6f0b")
-}
-
-func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/subnets", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "subnet": {
- "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- "ip_version": 4,
- "cidr": "192.168.199.0/24",
- "dns_nameservers": ["foo"],
- "allocation_pools": [
- {
- "start": "192.168.199.2",
- "end": "192.168.199.254"
- }
- ],
- "host_routes": [{"destination":"","nexthop": "bar"}]
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `
-{
- "subnet": {
- "name": "",
- "enable_dhcp": true,
- "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
- "dns_nameservers": [],
- "allocation_pools": [
- {
- "start": "192.168.199.2",
- "end": "192.168.199.254"
- }
- ],
- "host_routes": [],
- "ip_version": 4,
- "gateway_ip": "192.168.199.1",
- "cidr": "192.168.199.0/24",
- "id": "3b80198d-4f7b-4f77-9ef5-774d54e17126"
- }
-}
- `)
- })
-
- opts := os.CreateOpts{
- NetworkID: "d32019d3-bc6e-4319-9c1d-6722fc136a22",
- IPVersion: 4,
- CIDR: "192.168.199.0/24",
- AllocationPools: []os.AllocationPool{
- os.AllocationPool{
- Start: "192.168.199.2",
- End: "192.168.199.254",
- },
- },
- DNSNameservers: []string{"foo"},
- HostRoutes: []os.HostRoute{
- os.HostRoute{NextHop: "bar"},
- },
- }
- s, err := Create(fake.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, s.Name, "")
- th.AssertEquals(t, s.EnableDHCP, true)
- th.AssertEquals(t, s.NetworkID, "d32019d3-bc6e-4319-9c1d-6722fc136a22")
- th.AssertEquals(t, s.TenantID, "4fd44f30292945e481c7b8a0c8908869")
- th.AssertDeepEquals(t, s.DNSNameservers, []string{})
- th.AssertDeepEquals(t, s.AllocationPools, []os.AllocationPool{
- os.AllocationPool{
- Start: "192.168.199.2",
- End: "192.168.199.254",
- },
- })
- th.AssertDeepEquals(t, s.HostRoutes, []os.HostRoute{})
- th.AssertEquals(t, s.IPVersion, 4)
- th.AssertEquals(t, s.GatewayIP, "192.168.199.1")
- th.AssertEquals(t, s.CIDR, "192.168.199.0/24")
- th.AssertEquals(t, s.ID, "3b80198d-4f7b-4f77-9ef5-774d54e17126")
-}
-
-func TestRequiredCreateOpts(t *testing.T) {
- res := Create(fake.ServiceClient(), os.CreateOpts{})
- if res.Err == nil {
- t.Fatalf("Expected error, got none")
- }
-
- res = Create(fake.ServiceClient(), os.CreateOpts{NetworkID: "foo"})
- if res.Err == nil {
- t.Fatalf("Expected error, got none")
- }
-
- res = Create(fake.ServiceClient(), os.CreateOpts{NetworkID: "foo", CIDR: "bar", IPVersion: 40})
- if res.Err == nil {
- t.Fatalf("Expected error, got none")
- }
-}
-
-func TestUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/subnets/08eae331-0402-425a-923c-34f7cfe39c1b", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Content-Type", "application/json")
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
-{
- "subnet": {
- "name": "my_new_subnet",
- "dns_nameservers": ["foo"],
- "host_routes": [{"destination":"","nexthop": "bar"}]
- }
-}
- `)
-
- w.Header().Add("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
-
- fmt.Fprintf(w, `
-{
- "subnet": {
- "name": "my_new_subnet",
- "enable_dhcp": true,
- "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
- "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
- "dns_nameservers": [],
- "allocation_pools": [
- {
- "start": "10.0.0.2",
- "end": "10.0.0.254"
- }
- ],
- "host_routes": [],
- "ip_version": 4,
- "gateway_ip": "10.0.0.1",
- "cidr": "10.0.0.0/24",
- "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
- }
-}
- `)
- })
-
- opts := os.UpdateOpts{
- Name: "my_new_subnet",
- DNSNameservers: []string{"foo"},
- HostRoutes: []os.HostRoute{
- os.HostRoute{NextHop: "bar"},
- },
- }
- s, err := Update(fake.ServiceClient(), "08eae331-0402-425a-923c-34f7cfe39c1b", opts).Extract()
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, s.Name, "my_new_subnet")
- th.AssertEquals(t, s.ID, "08eae331-0402-425a-923c-34f7cfe39c1b")
-}
-
-func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- th.Mux.HandleFunc("/subnets/08eae331-0402-425a-923c-34f7cfe39c1b", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- w.WriteHeader(http.StatusNoContent)
- })
-
- res := Delete(fake.ServiceClient(), "08eae331-0402-425a-923c-34f7cfe39c1b")
- th.AssertNoErr(t, res.Err)
-}
diff --git a/rackspace/objectstorage/v1/accounts/delegate.go b/rackspace/objectstorage/v1/accounts/delegate.go
deleted file mode 100644
index 9473930..0000000
--- a/rackspace/objectstorage/v1/accounts/delegate.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package accounts
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts"
-)
-
-// Get is a function that retrieves an account's metadata. To extract just the
-// custom metadata, call the ExtractMetadata method on the GetResult. To extract
-// all the headers that are returned (including the metadata), call the
-// ExtractHeader method on the GetResult.
-func Get(c *gophercloud.ServiceClient) os.GetResult {
- return os.Get(c, nil)
-}
-
-// UpdateOpts is a structure that contains parameters for updating, creating, or
-// deleting an account's metadata.
-type UpdateOpts struct {
- Metadata map[string]string
- TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"`
- TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"`
-}
-
-// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers.
-func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) {
- headers, err := gophercloud.BuildHeaders(opts)
- if err != nil {
- return nil, err
- }
- for k, v := range opts.Metadata {
- headers["X-Account-Meta-"+k] = v
- }
- return headers, err
-}
-
-// Update will update an account's metadata with the Metadata in the UpdateOptsBuilder.
-func Update(c *gophercloud.ServiceClient, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(c, opts)
-}
diff --git a/rackspace/objectstorage/v1/accounts/delegate_test.go b/rackspace/objectstorage/v1/accounts/delegate_test.go
deleted file mode 100644
index a1ea98b..0000000
--- a/rackspace/objectstorage/v1/accounts/delegate_test.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package accounts
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestUpdateAccounts(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleUpdateAccountSuccessfully(t)
-
- options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}}
- res := Update(fake.ServiceClient(), options)
- th.CheckNoErr(t, res.Err)
-}
-
-func TestGetAccounts(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- os.HandleGetAccountSuccessfully(t)
-
- expected := map[string]string{"Foo": "bar"}
- actual, err := Get(fake.ServiceClient()).ExtractMetadata()
- th.CheckNoErr(t, err)
- th.CheckDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/objectstorage/v1/accounts/doc.go b/rackspace/objectstorage/v1/accounts/doc.go
deleted file mode 100644
index 293a930..0000000
--- a/rackspace/objectstorage/v1/accounts/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package accounts provides information and interaction with the account
-// API resource for the Rackspace Cloud Files service.
-package accounts
diff --git a/rackspace/objectstorage/v1/bulk/doc.go b/rackspace/objectstorage/v1/bulk/doc.go
deleted file mode 100644
index 9c89e22..0000000
--- a/rackspace/objectstorage/v1/bulk/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package bulk provides functionality for working with bulk operations in the
-// Rackspace Cloud Files service.
-package bulk
diff --git a/rackspace/objectstorage/v1/bulk/requests.go b/rackspace/objectstorage/v1/bulk/requests.go
deleted file mode 100644
index 0aeec15..0000000
--- a/rackspace/objectstorage/v1/bulk/requests.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package bulk
-
-import (
- "net/url"
- "strings"
-
- "github.com/rackspace/gophercloud"
-)
-
-// DeleteOptsBuilder allows extensions to add additional parameters to the
-// Delete request.
-type DeleteOptsBuilder interface {
- ToBulkDeleteBody() (string, error)
-}
-
-// DeleteOpts is a structure that holds parameters for deleting an object.
-type DeleteOpts []string
-
-// ToBulkDeleteBody formats a DeleteOpts into a request body.
-func (opts DeleteOpts) ToBulkDeleteBody() (string, error) {
- return url.QueryEscape(strings.Join(opts, "\n")), nil
-}
-
-// Delete will delete objects or containers in bulk.
-func Delete(c *gophercloud.ServiceClient, opts DeleteOptsBuilder) DeleteResult {
- var res DeleteResult
-
- if opts == nil {
- return res
- }
-
- reqString, err := opts.ToBulkDeleteBody()
- if err != nil {
- res.Err = err
- return res
- }
-
- reqBody := strings.NewReader(reqString)
-
- resp, err := c.Request("DELETE", deleteURL(c), gophercloud.RequestOpts{
- MoreHeaders: map[string]string{"Content-Type": "text/plain"},
- OkCodes: []int{200},
- JSONBody: reqBody,
- JSONResponse: &res.Body,
- })
- if resp != nil {
- res.Header = resp.Header
- }
- res.Err = err
- return res
-}
diff --git a/rackspace/objectstorage/v1/bulk/requests_test.go b/rackspace/objectstorage/v1/bulk/requests_test.go
deleted file mode 100644
index 8b5578e..0000000
--- a/rackspace/objectstorage/v1/bulk/requests_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package bulk
-
-import (
- "fmt"
- "net/http"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestBulkDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.AssertEquals(t, r.URL.RawQuery, "bulk-delete")
-
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `
- {
- "Number Not Found": 1,
- "Response Status": "200 OK",
- "Errors": [],
- "Number Deleted": 1,
- "Response Body": ""
- }
- `)
- })
-
- options := DeleteOpts{"gophercloud-testcontainer1", "gophercloud-testcontainer2"}
- actual, err := Delete(fake.ServiceClient(), options).ExtractBody()
- th.AssertNoErr(t, err)
- th.AssertEquals(t, actual.NumberDeleted, 1)
-}
diff --git a/rackspace/objectstorage/v1/bulk/results.go b/rackspace/objectstorage/v1/bulk/results.go
deleted file mode 100644
index fddc125..0000000
--- a/rackspace/objectstorage/v1/bulk/results.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package bulk
-
-import (
- "github.com/rackspace/gophercloud"
-
- "github.com/mitchellh/mapstructure"
-)
-
-// DeleteResult represents the result of a bulk delete operation.
-type DeleteResult struct {
- gophercloud.Result
-}
-
-// DeleteRespBody is the form of the response body returned by a bulk delete request.
-type DeleteRespBody struct {
- NumberNotFound int `mapstructure:"Number Not Found"`
- ResponseStatus string `mapstructure:"Response Status"`
- Errors []string `mapstructure:"Errors"`
- NumberDeleted int `mapstructure:"Number Deleted"`
- ResponseBody string `mapstructure:"Response Body"`
-}
-
-// ExtractBody will extract the body returned by the bulk extract request.
-func (dr DeleteResult) ExtractBody() (DeleteRespBody, error) {
- var resp DeleteRespBody
- err := mapstructure.Decode(dr.Body, &resp)
- return resp, err
-}
diff --git a/rackspace/objectstorage/v1/bulk/urls.go b/rackspace/objectstorage/v1/bulk/urls.go
deleted file mode 100644
index 2e11203..0000000
--- a/rackspace/objectstorage/v1/bulk/urls.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package bulk
-
-import "github.com/rackspace/gophercloud"
-
-func deleteURL(c *gophercloud.ServiceClient) string {
- return c.Endpoint + "?bulk-delete"
-}
-
-func extractURL(c *gophercloud.ServiceClient, ext string) string {
- return c.Endpoint + "?extract-archive=" + ext
-}
diff --git a/rackspace/objectstorage/v1/bulk/urls_test.go b/rackspace/objectstorage/v1/bulk/urls_test.go
deleted file mode 100644
index 9169e52..0000000
--- a/rackspace/objectstorage/v1/bulk/urls_test.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package bulk
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-const endpoint = "http://localhost:57909/"
-
-func endpointClient() *gophercloud.ServiceClient {
- return &gophercloud.ServiceClient{Endpoint: endpoint}
-}
-
-func TestDeleteURL(t *testing.T) {
- actual := deleteURL(endpointClient())
- expected := endpoint + "?bulk-delete"
- th.CheckEquals(t, expected, actual)
-}
-
-func TestExtractURL(t *testing.T) {
- actual := extractURL(endpointClient(), "tar")
- expected := endpoint + "?extract-archive=tar"
- th.CheckEquals(t, expected, actual)
-}
diff --git a/rackspace/objectstorage/v1/cdncontainers/delegate.go b/rackspace/objectstorage/v1/cdncontainers/delegate.go
deleted file mode 100644
index 89adb83..0000000
--- a/rackspace/objectstorage/v1/cdncontainers/delegate.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package cdncontainers
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// ExtractNames interprets a page of List results when just the container
-// names are requested.
-func ExtractNames(page pagination.Page) ([]string, error) {
- return os.ExtractNames(page)
-}
-
-// ListOpts are options for listing Rackspace CDN containers.
-type ListOpts struct {
- EndMarker string `q:"end_marker"`
- Format string `q:"format"`
- Limit int `q:"limit"`
- Marker string `q:"marker"`
-}
-
-// ToContainerListParams formats a ListOpts into a query string and boolean
-// representing whether to list complete information for each container.
-func (opts ListOpts) ToContainerListParams() (bool, string, error) {
- q, err := gophercloud.BuildQueryString(opts)
- if err != nil {
- return false, "", err
- }
- return false, q.String(), nil
-}
-
-// List is a function that retrieves containers associated with the account as
-// well as account metadata. It returns a pager which can be iterated with the
-// EachPage function.
-func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, opts)
-}
diff --git a/rackspace/objectstorage/v1/cdncontainers/delegate_test.go b/rackspace/objectstorage/v1/cdncontainers/delegate_test.go
deleted file mode 100644
index 02c3c5e..0000000
--- a/rackspace/objectstorage/v1/cdncontainers/delegate_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package cdncontainers
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListCDNContainers(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListContainerNamesSuccessfully(t)
-
- count := 0
- err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNames(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, os.ExpectedListNames, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestGetCDNContainer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetContainerSuccessfully(t)
-
- _, err := Get(fake.ServiceClient(), "testContainer").ExtractMetadata()
- th.CheckNoErr(t, err)
-
-}
-
-func TestUpdateCDNContainer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleUpdateContainerSuccessfully(t)
-
- options := &UpdateOpts{TTL: 3600}
- res := Update(fake.ServiceClient(), "testContainer", options)
- th.CheckNoErr(t, res.Err)
-
-}
diff --git a/rackspace/objectstorage/v1/cdncontainers/doc.go b/rackspace/objectstorage/v1/cdncontainers/doc.go
deleted file mode 100644
index 7b0930e..0000000
--- a/rackspace/objectstorage/v1/cdncontainers/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package cdncontainers provides information and interaction with the CDN
-// Container API resource for the Rackspace Cloud Files service.
-package cdncontainers
diff --git a/rackspace/objectstorage/v1/cdncontainers/requests.go b/rackspace/objectstorage/v1/cdncontainers/requests.go
deleted file mode 100644
index 6acebb0..0000000
--- a/rackspace/objectstorage/v1/cdncontainers/requests.go
+++ /dev/null
@@ -1,161 +0,0 @@
-package cdncontainers
-
-import (
- "strconv"
-
- "github.com/rackspace/gophercloud"
-)
-
-// EnableOptsBuilder allows extensions to add additional parameters to the Enable
-// request.
-type EnableOptsBuilder interface {
- ToCDNContainerEnableMap() (map[string]string, error)
-}
-
-// EnableOpts is a structure that holds options for enabling a CDN container.
-type EnableOpts struct {
- // CDNEnabled indicates whether or not the container is CDN enabled. Set to
- // `true` to enable the container. Note that changing this setting from true
- // to false will disable the container in the CDN but only after the TTL has
- // expired.
- CDNEnabled bool `h:"X-Cdn-Enabled"`
- // TTL is the time-to-live for the container (in seconds).
- TTL int `h:"X-Ttl"`
-}
-
-// ToCDNContainerEnableMap formats an EnableOpts into a map of headers.
-func (opts EnableOpts) ToCDNContainerEnableMap() (map[string]string, error) {
- h, err := gophercloud.BuildHeaders(opts)
- if err != nil {
- return nil, err
- }
- return h, nil
-}
-
-// Enable is a function that enables/disables a CDN container.
-func Enable(c *gophercloud.ServiceClient, containerName string, opts EnableOptsBuilder) EnableResult {
- var res EnableResult
- h := c.AuthenticatedHeaders()
-
- if opts != nil {
- headers, err := opts.ToCDNContainerEnableMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- for k, v := range headers {
- h[k] = v
- }
- }
-
- resp, err := c.Request("PUT", enableURL(c, containerName), gophercloud.RequestOpts{
- MoreHeaders: h,
- OkCodes: []int{201, 202, 204},
- })
- if resp != nil {
- res.Header = resp.Header
- }
- res.Err = err
- return res
-}
-
-// Get is a function that retrieves the metadata of a container. To extract just
-// the custom metadata, pass the GetResult response to the ExtractMetadata
-// function.
-func Get(c *gophercloud.ServiceClient, containerName string) GetResult {
- var res GetResult
- resp, err := c.Request("HEAD", getURL(c, containerName), gophercloud.RequestOpts{
- OkCodes: []int{200, 204},
- })
- if resp != nil {
- res.Header = resp.Header
- }
- res.Err = err
- return res
-}
-
-// State is the state of an option. It is a pointer to a boolean to enable checking for
-// a zero-value of nil instead of false, which is a valid option.
-type State *bool
-
-var (
- iTrue = true
- iFalse = false
-
- // Enabled is used for a true value for options in request bodies.
- Enabled State = &iTrue
- // Disabled is used for a false value for options in request bodies.
- Disabled State = &iFalse
-)
-
-// UpdateOptsBuilder allows extensions to add additional parameters to the
-// Update request.
-type UpdateOptsBuilder interface {
- ToContainerUpdateMap() (map[string]string, error)
-}
-
-// UpdateOpts is a structure that holds parameters for updating, creating, or
-// deleting a container's metadata.
-type UpdateOpts struct {
- // Whether or not to CDN-enable a container. Prefer using XCDNEnabled, which
- // is of type *bool underneath.
- // TODO v2.0: change type to Enabled/Disabled (*bool)
- CDNEnabled bool `h:"X-Cdn-Enabled"`
- // Whether or not to enable log retention. Prefer using XLogRetention, which
- // is of type *bool underneath.
- // TODO v2.0: change type to Enabled/Disabled (*bool)
- LogRetention bool `h:"X-Log-Retention"`
- XCDNEnabled *bool
- XLogRetention *bool
- TTL int `h:"X-Ttl"`
-}
-
-// ToContainerUpdateMap formats a CreateOpts into a map of headers.
-func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) {
- h, err := gophercloud.BuildHeaders(opts)
- if err != nil {
- return nil, err
- }
- h["X-Cdn-Enabled"] = strconv.FormatBool(opts.CDNEnabled)
- h["X-Log-Retention"] = strconv.FormatBool(opts.LogRetention)
-
- if opts.XCDNEnabled != nil {
- h["X-Cdn-Enabled"] = strconv.FormatBool(*opts.XCDNEnabled)
- }
-
- if opts.XLogRetention != nil {
- h["X-Log-Retention"] = strconv.FormatBool(*opts.XLogRetention)
- }
-
- return h, nil
-}
-
-// Update is a function that creates, updates, or deletes a container's
-// metadata.
-func Update(c *gophercloud.ServiceClient, containerName string, opts UpdateOptsBuilder) UpdateResult {
- var res UpdateResult
- h := c.AuthenticatedHeaders()
-
- if opts != nil {
- headers, err := opts.ToContainerUpdateMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- for k, v := range headers {
- h[k] = v
- }
- }
-
- resp, err := c.Request("POST", updateURL(c, containerName), gophercloud.RequestOpts{
- MoreHeaders: h,
- OkCodes: []int{202, 204},
- })
- if resp != nil {
- res.Header = resp.Header
- }
- res.Err = err
- return res
-}
diff --git a/rackspace/objectstorage/v1/cdncontainers/requests_test.go b/rackspace/objectstorage/v1/cdncontainers/requests_test.go
deleted file mode 100644
index 28b963d..0000000
--- a/rackspace/objectstorage/v1/cdncontainers/requests_test.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package cdncontainers
-
-import (
- "net/http"
- "testing"
-
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestEnableCDNContainer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Add("X-Ttl", "259200")
- w.Header().Add("X-Cdn-Enabled", "True")
- w.WriteHeader(http.StatusNoContent)
- })
-
- options := &EnableOpts{CDNEnabled: true, TTL: 259200}
- actual := Enable(fake.ServiceClient(), "testContainer", options)
- th.AssertNoErr(t, actual.Err)
- th.CheckEquals(t, actual.Header["X-Ttl"][0], "259200")
- th.CheckEquals(t, actual.Header["X-Cdn-Enabled"][0], "True")
-}
diff --git a/rackspace/objectstorage/v1/cdncontainers/results.go b/rackspace/objectstorage/v1/cdncontainers/results.go
deleted file mode 100644
index cb0ad30..0000000
--- a/rackspace/objectstorage/v1/cdncontainers/results.go
+++ /dev/null
@@ -1,149 +0,0 @@
-package cdncontainers
-
-import (
- "strings"
- "time"
-
- "github.com/rackspace/gophercloud"
-)
-
-// EnableHeader represents the headers returned in the response from an Enable request.
-type EnableHeader struct {
- CDNIosURI string `mapstructure:"X-Cdn-Ios-Uri"`
- CDNSslURI string `mapstructure:"X-Cdn-Ssl-Uri"`
- CDNStreamingURI string `mapstructure:"X-Cdn-Streaming-Uri"`
- CDNUri string `mapstructure:"X-Cdn-Uri"`
- ContentLength int `mapstructure:"Content-Length"`
- ContentType string `mapstructure:"Content-Type"`
- Date time.Time `mapstructure:"-"`
- TransID string `mapstructure:"X-Trans-Id"`
-}
-
-// EnableResult represents the result of an Enable operation.
-type EnableResult struct {
- gophercloud.HeaderResult
-}
-
-// Extract will return extract an EnableHeader from the response to an Enable
-// request. To obtain a map of headers, call the ExtractHeader method on the EnableResult.
-func (er EnableResult) Extract() (EnableHeader, error) {
- var eh EnableHeader
- if er.Err != nil {
- return eh, er.Err
- }
-
- if err := gophercloud.DecodeHeader(er.Header, &eh); err != nil {
- return eh, err
- }
-
- if date, ok := er.Header["Date"]; ok && len(date) > 0 {
- t, err := time.Parse(time.RFC1123, er.Header["Date"][0])
- if err != nil {
- return eh, err
- }
- eh.Date = t
- }
-
- return eh, nil
-}
-
-// GetHeader represents the headers returned in the response from a Get request.
-type GetHeader struct {
- CDNEnabled bool `mapstructure:"X-Cdn-Enabled"`
- CDNIosURI string `mapstructure:"X-Cdn-Ios-Uri"`
- CDNSslURI string `mapstructure:"X-Cdn-Ssl-Uri"`
- CDNStreamingURI string `mapstructure:"X-Cdn-Streaming-Uri"`
- CDNUri string `mapstructure:"X-Cdn-Uri"`
- ContentLength int `mapstructure:"Content-Length"`
- ContentType string `mapstructure:"Content-Type"`
- Date time.Time `mapstructure:"-"`
- LogRetention bool `mapstructure:"X-Log-Retention"`
- TransID string `mapstructure:"X-Trans-Id"`
- TTL int `mapstructure:"X-Ttl"`
-}
-
-// GetResult represents the result of a Get operation.
-type GetResult struct {
- gophercloud.HeaderResult
-}
-
-// Extract will return a struct of headers returned from a call to Get. To obtain
-// a map of headers, call the ExtractHeader method on the GetResult.
-func (gr GetResult) Extract() (GetHeader, error) {
- var gh GetHeader
- if gr.Err != nil {
- return gh, gr.Err
- }
-
- if err := gophercloud.DecodeHeader(gr.Header, &gh); err != nil {
- return gh, err
- }
-
- if date, ok := gr.Header["Date"]; ok && len(date) > 0 {
- t, err := time.Parse(time.RFC1123, gr.Header["Date"][0])
- if err != nil {
- return gh, err
- }
- gh.Date = t
- }
-
- return gh, nil
-}
-
-// ExtractMetadata is a function that takes a GetResult (of type *http.Response)
-// and returns the custom metadata associated with the container.
-func (gr GetResult) ExtractMetadata() (map[string]string, error) {
- if gr.Err != nil {
- return nil, gr.Err
- }
- metadata := make(map[string]string)
- for k, v := range gr.Header {
- if strings.HasPrefix(k, "X-Container-Meta-") {
- key := strings.TrimPrefix(k, "X-Container-Meta-")
- metadata[key] = v[0]
- }
- }
- return metadata, nil
-}
-
-// UpdateHeader represents the headers returned in the response from a Update request.
-type UpdateHeader struct {
- CDNIosURI string `mapstructure:"X-Cdn-Ios-Uri"`
- CDNSslURI string `mapstructure:"X-Cdn-Ssl-Uri"`
- CDNStreamingURI string `mapstructure:"X-Cdn-Streaming-Uri"`
- CDNUri string `mapstructure:"X-Cdn-Uri"`
- ContentLength int `mapstructure:"Content-Length"`
- ContentType string `mapstructure:"Content-Type"`
- Date time.Time `mapstructure:"-"`
- TransID string `mapstructure:"X-Trans-Id"`
-}
-
-// UpdateResult represents the result of an update operation. To extract the
-// the headers from the HTTP response, you can invoke the 'ExtractHeader'
-// method on the result struct.
-type UpdateResult struct {
- gophercloud.HeaderResult
-}
-
-// Extract will return a struct of headers returned from a call to Update. To obtain
-// a map of headers, call the ExtractHeader method on the UpdateResult.
-func (ur UpdateResult) Extract() (UpdateHeader, error) {
- var uh UpdateHeader
- if ur.Err != nil {
- return uh, ur.Err
- }
-
- if err := gophercloud.DecodeHeader(ur.Header, &uh); err != nil {
- return uh, err
- }
-
- if date, ok := ur.Header["Date"]; ok && len(date) > 0 {
- t, err := time.Parse(time.RFC1123, ur.Header["Date"][0])
- if err != nil {
- return uh, err
- }
- uh.Date = t
- }
-
- return uh, nil
-}
diff --git a/rackspace/objectstorage/v1/cdncontainers/urls.go b/rackspace/objectstorage/v1/cdncontainers/urls.go
deleted file mode 100644
index 541249a..0000000
--- a/rackspace/objectstorage/v1/cdncontainers/urls.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package cdncontainers
-
-import "github.com/rackspace/gophercloud"
-
-func enableURL(c *gophercloud.ServiceClient, containerName string) string {
- return c.ServiceURL(containerName)
-}
-
-func getURL(c *gophercloud.ServiceClient, container string) string {
- return c.ServiceURL(container)
-}
-
-func updateURL(c *gophercloud.ServiceClient, container string) string {
- return getURL(c, container)
-}
diff --git a/rackspace/objectstorage/v1/cdncontainers/urls_test.go b/rackspace/objectstorage/v1/cdncontainers/urls_test.go
deleted file mode 100644
index aa5bfe6..0000000
--- a/rackspace/objectstorage/v1/cdncontainers/urls_test.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package cdncontainers
-
-import (
- "testing"
-
- "github.com/rackspace/gophercloud"
- th "github.com/rackspace/gophercloud/testhelper"
-)
-
-const endpoint = "http://localhost:57909/"
-
-func endpointClient() *gophercloud.ServiceClient {
- return &gophercloud.ServiceClient{Endpoint: endpoint}
-}
-
-func TestEnableURL(t *testing.T) {
- actual := enableURL(endpointClient(), "foo")
- expected := endpoint + "foo"
- th.CheckEquals(t, expected, actual)
-}
diff --git a/rackspace/objectstorage/v1/cdnobjects/delegate.go b/rackspace/objectstorage/v1/cdnobjects/delegate.go
deleted file mode 100644
index e9d2ff1..0000000
--- a/rackspace/objectstorage/v1/cdnobjects/delegate.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package cdnobjects
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects"
-)
-
-// Delete is a function that deletes an object from the CDN.
-func Delete(c *gophercloud.ServiceClient, containerName, objectName string, opts os.DeleteOptsBuilder) os.DeleteResult {
- return os.Delete(c, containerName, objectName, nil)
-}
diff --git a/rackspace/objectstorage/v1/cdnobjects/delegate_test.go b/rackspace/objectstorage/v1/cdnobjects/delegate_test.go
deleted file mode 100644
index b5e04a9..0000000
--- a/rackspace/objectstorage/v1/cdnobjects/delegate_test.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package cdnobjects
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestDeleteCDNObject(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDeleteObjectSuccessfully(t)
-
- res := Delete(fake.ServiceClient(), "testContainer", "testObject", nil)
- th.AssertNoErr(t, res.Err)
-
-}
diff --git a/rackspace/objectstorage/v1/cdnobjects/doc.go b/rackspace/objectstorage/v1/cdnobjects/doc.go
deleted file mode 100644
index 90cd5c9..0000000
--- a/rackspace/objectstorage/v1/cdnobjects/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package cdnobjects provides information and interaction with the CDN
-// Object API resource for the Rackspace Cloud Files service.
-package cdnobjects
diff --git a/rackspace/objectstorage/v1/cdnobjects/request.go b/rackspace/objectstorage/v1/cdnobjects/request.go
deleted file mode 100644
index 540e0cd..0000000
--- a/rackspace/objectstorage/v1/cdnobjects/request.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package cdnobjects
-
-import (
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers"
-)
-
-// CDNURL returns the unique CDN URI for the given container and object.
-func CDNURL(c *gophercloud.ServiceClient, containerName, objectName string) (string, error) {
- h, err := cdncontainers.Get(c, containerName).Extract()
- if err != nil {
- return "", err
- }
- return h.CDNUri + "/" + objectName, nil
-}
diff --git a/rackspace/objectstorage/v1/containers/delegate.go b/rackspace/objectstorage/v1/containers/delegate.go
deleted file mode 100644
index 77ed002..0000000
--- a/rackspace/objectstorage/v1/containers/delegate.go
+++ /dev/null
@@ -1,93 +0,0 @@
-package containers
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// ExtractInfo interprets a page of List results when full container info
-// is requested.
-func ExtractInfo(page pagination.Page) ([]os.Container, error) {
- return os.ExtractInfo(page)
-}
-
-// ExtractNames interprets a page of List results when just the container
-// names are requested.
-func ExtractNames(page pagination.Page) ([]string, error) {
- return os.ExtractNames(page)
-}
-
-// List is a function that retrieves containers associated with the account as
-// well as account metadata. It returns a pager which can be iterated with the
-// EachPage function.
-func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, opts)
-}
-
-// CreateOpts is a structure that holds parameters for creating a container.
-type CreateOpts struct {
- Metadata map[string]string
- ContainerRead string `h:"X-Container-Read"`
- ContainerWrite string `h:"X-Container-Write"`
- VersionsLocation string `h:"X-Versions-Location"`
-}
-
-// ToContainerCreateMap formats a CreateOpts into a map of headers.
-func (opts CreateOpts) ToContainerCreateMap() (map[string]string, error) {
- h, err := gophercloud.BuildHeaders(opts)
- if err != nil {
- return nil, err
- }
- for k, v := range opts.Metadata {
- h["X-Container-Meta-"+k] = v
- }
- return h, nil
-}
-
-// Create is a function that creates a new container.
-func Create(c *gophercloud.ServiceClient, containerName string, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(c, containerName, opts)
-}
-
-// Delete is a function that deletes a container.
-func Delete(c *gophercloud.ServiceClient, containerName string) os.DeleteResult {
- return os.Delete(c, containerName)
-}
-
-// UpdateOpts is a structure that holds parameters for updating or creating a
-// container's metadata.
-type UpdateOpts struct {
- Metadata map[string]string
- ContainerRead string `h:"X-Container-Read"`
- ContainerWrite string `h:"X-Container-Write"`
- ContentType string `h:"Content-Type"`
- DetectContentType bool `h:"X-Detect-Content-Type"`
- RemoveVersionsLocation string `h:"X-Remove-Versions-Location"`
- VersionsLocation string `h:"X-Versions-Location"`
-}
-
-// ToContainerUpdateMap formats a CreateOpts into a map of headers.
-func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) {
- h, err := gophercloud.BuildHeaders(opts)
- if err != nil {
- return nil, err
- }
- for k, v := range opts.Metadata {
- h["X-Container-Meta-"+k] = v
- }
- return h, nil
-}
-
-// Update is a function that creates, updates, or deletes a container's
-// metadata.
-func Update(c *gophercloud.ServiceClient, containerName string, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(c, containerName, opts)
-}
-
-// Get is a function that retrieves the metadata of a container. To extract just
-// the custom metadata, pass the GetResult response to the ExtractMetadata
-// function.
-func Get(c *gophercloud.ServiceClient, containerName string) os.GetResult {
- return os.Get(c, containerName)
-}
diff --git a/rackspace/objectstorage/v1/containers/delegate_test.go b/rackspace/objectstorage/v1/containers/delegate_test.go
deleted file mode 100644
index 7ba4eb2..0000000
--- a/rackspace/objectstorage/v1/containers/delegate_test.go
+++ /dev/null
@@ -1,91 +0,0 @@
-package containers
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListContainerInfo(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListContainerInfoSuccessfully(t)
-
- count := 0
- err := List(fake.ServiceClient(), &os.ListOpts{Full: true}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractInfo(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, os.ExpectedListInfo, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestListContainerNames(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListContainerNamesSuccessfully(t)
-
- count := 0
- err := List(fake.ServiceClient(), &os.ListOpts{Full: false}).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNames(page)
- if err != nil {
- t.Errorf("Failed to extract container names: %v", err)
- return false, err
- }
-
- th.CheckDeepEquals(t, os.ExpectedListNames, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestCreateContainers(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCreateContainerSuccessfully(t)
-
- options := os.CreateOpts{ContentType: "application/json", Metadata: map[string]string{"foo": "bar"}}
- res := Create(fake.ServiceClient(), "testContainer", options)
- th.CheckNoErr(t, res.Err)
- th.CheckEquals(t, "bar", res.Header["X-Container-Meta-Foo"][0])
-
-}
-
-func TestDeleteContainers(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDeleteContainerSuccessfully(t)
-
- res := Delete(fake.ServiceClient(), "testContainer")
- th.CheckNoErr(t, res.Err)
-}
-
-func TestUpdateContainers(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleUpdateContainerSuccessfully(t)
-
- options := &os.UpdateOpts{Metadata: map[string]string{"foo": "bar"}}
- res := Update(fake.ServiceClient(), "testContainer", options)
- th.CheckNoErr(t, res.Err)
-}
-
-func TestGetContainers(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetContainerSuccessfully(t)
-
- _, err := Get(fake.ServiceClient(), "testContainer").ExtractMetadata()
- th.CheckNoErr(t, err)
-}
diff --git a/rackspace/objectstorage/v1/containers/doc.go b/rackspace/objectstorage/v1/containers/doc.go
deleted file mode 100644
index d132a07..0000000
--- a/rackspace/objectstorage/v1/containers/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package containers provides information and interaction with the Container
-// API resource for the Rackspace Cloud Files service.
-package containers
diff --git a/rackspace/objectstorage/v1/objects/delegate.go b/rackspace/objectstorage/v1/objects/delegate.go
deleted file mode 100644
index 94c820b..0000000
--- a/rackspace/objectstorage/v1/objects/delegate.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package objects
-
-import (
- "io"
-
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// ExtractInfo is a function that takes a page of objects and returns their full information.
-func ExtractInfo(page pagination.Page) ([]os.Object, error) {
- return os.ExtractInfo(page)
-}
-
-// ExtractNames is a function that takes a page of objects and returns only their names.
-func ExtractNames(page pagination.Page) ([]string, error) {
- return os.ExtractNames(page)
-}
-
-// List is a function that retrieves objects in the container as
-// well as container metadata. It returns a pager which can be iterated with the
-// EachPage function.
-func List(c *gophercloud.ServiceClient, containerName string, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, containerName, opts)
-}
-
-// Download is a function that retrieves the content and metadata for an object.
-// To extract just the content, pass the DownloadResult response to the
-// ExtractContent function.
-func Download(c *gophercloud.ServiceClient, containerName, objectName string, opts os.DownloadOptsBuilder) os.DownloadResult {
- return os.Download(c, containerName, objectName, opts)
-}
-
-// Create is a function that creates a new object or replaces an existing object.
-func Create(c *gophercloud.ServiceClient, containerName, objectName string, content io.ReadSeeker, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(c, containerName, objectName, content, opts)
-}
-
-// CopyOpts is a structure that holds parameters for copying one object to
-// another.
-type CopyOpts struct {
- Metadata map[string]string
- ContentDisposition string `h:"Content-Disposition"`
- ContentEncoding string `h:"Content-Encoding"`
- ContentLength int `h:"Content-Length"`
- ContentType string `h:"Content-Type"`
- CopyFrom string `h:"X-Copy_From"`
- Destination string `h:"Destination"`
- DetectContentType bool `h:"X-Detect-Content-Type"`
-}
-
-// ToObjectCopyMap formats a CopyOpts into a map of headers.
-func (opts CopyOpts) ToObjectCopyMap() (map[string]string, error) {
- h, err := gophercloud.BuildHeaders(opts)
- if err != nil {
- return nil, err
- }
- for k, v := range opts.Metadata {
- h["X-Object-Meta-"+k] = v
- }
- // `Content-Length` is required and a value of "0" is acceptable, but calling `gophercloud.BuildHeaders`
- // will remove the `Content-Length` header if it's set to 0 (or equivalently not set). This will add
- // the header if it's not already set.
- if _, ok := h["Content-Length"]; !ok {
- h["Content-Length"] = "0"
- }
- return h, nil
-}
-
-// Copy is a function that copies one object to another.
-func Copy(c *gophercloud.ServiceClient, containerName, objectName string, opts os.CopyOptsBuilder) os.CopyResult {
- return os.Copy(c, containerName, objectName, opts)
-}
-
-// Delete is a function that deletes an object.
-func Delete(c *gophercloud.ServiceClient, containerName, objectName string, opts os.DeleteOptsBuilder) os.DeleteResult {
- return os.Delete(c, containerName, objectName, opts)
-}
-
-// Get is a function that retrieves the metadata of an object. To extract just the custom
-// metadata, pass the GetResult response to the ExtractMetadata function.
-func Get(c *gophercloud.ServiceClient, containerName, objectName string, opts os.GetOptsBuilder) os.GetResult {
- return os.Get(c, containerName, objectName, opts)
-}
-
-// Update is a function that creates, updates, or deletes an object's metadata.
-func Update(c *gophercloud.ServiceClient, containerName, objectName string, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(c, containerName, objectName, opts)
-}
-
-func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName string, opts os.CreateTempURLOpts) (string, error) {
- return os.CreateTempURL(c, containerName, objectName, opts)
-}
diff --git a/rackspace/objectstorage/v1/objects/delegate_test.go b/rackspace/objectstorage/v1/objects/delegate_test.go
deleted file mode 100644
index 21cd417..0000000
--- a/rackspace/objectstorage/v1/objects/delegate_test.go
+++ /dev/null
@@ -1,127 +0,0 @@
-package objects
-
-import (
- "strings"
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestDownloadObject(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDownloadObjectSuccessfully(t)
-
- content, err := Download(fake.ServiceClient(), "testContainer", "testObject", nil).ExtractContent()
- th.AssertNoErr(t, err)
- th.CheckEquals(t, string(content), "Successful download with Gophercloud")
-}
-
-func TestListObjectsInfo(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListObjectsInfoSuccessfully(t)
-
- count := 0
- options := &os.ListOpts{Full: true}
- err := List(fake.ServiceClient(), "testContainer", options).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractInfo(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, os.ExpectedListInfo, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestListObjectNames(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListObjectNamesSuccessfully(t)
-
- count := 0
- options := &os.ListOpts{Full: false}
- err := List(fake.ServiceClient(), "testContainer", options).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNames(page)
- if err != nil {
- t.Errorf("Failed to extract container names: %v", err)
- return false, err
- }
-
- th.CheckDeepEquals(t, os.ExpectedListNames, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestCreateObject(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- content := "Did gyre and gimble in the wabe"
- os.HandleCreateTextObjectSuccessfully(t, content)
-
- options := &os.CreateOpts{ContentType: "text/plain"}
- res := Create(fake.ServiceClient(), "testContainer", "testObject", strings.NewReader(content), options)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestCreateObjectWithoutContentType(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- content := "The sky was the color of television, tuned to a dead channel."
- os.HandleCreateTypelessObjectSuccessfully(t, content)
-
- res := Create(fake.ServiceClient(), "testContainer", "testObject", strings.NewReader(content), &os.CreateOpts{})
- th.AssertNoErr(t, res.Err)
-}
-
-func TestCopyObject(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCopyObjectSuccessfully(t)
-
- options := &CopyOpts{Destination: "/newTestContainer/newTestObject"}
- res := Copy(fake.ServiceClient(), "testContainer", "testObject", options)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestDeleteObject(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDeleteObjectSuccessfully(t)
-
- res := Delete(fake.ServiceClient(), "testContainer", "testObject", nil)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestUpdateObject(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleUpdateObjectSuccessfully(t)
-
- options := &os.UpdateOpts{Metadata: map[string]string{"Gophercloud-Test": "objects"}}
- res := Update(fake.ServiceClient(), "testContainer", "testObject", options)
- th.AssertNoErr(t, res.Err)
-}
-
-func TestGetObject(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetObjectSuccessfully(t)
-
- expected := map[string]string{"Gophercloud-Test": "objects"}
- actual, err := Get(fake.ServiceClient(), "testContainer", "testObject", nil).ExtractMetadata()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/objectstorage/v1/objects/doc.go b/rackspace/objectstorage/v1/objects/doc.go
deleted file mode 100644
index 781984b..0000000
--- a/rackspace/objectstorage/v1/objects/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package objects provides information and interaction with the Object
-// API resource for the Rackspace Cloud Files service.
-package objects
diff --git a/rackspace/orchestration/v1/buildinfo/delegate.go b/rackspace/orchestration/v1/buildinfo/delegate.go
deleted file mode 100644
index c834e5c..0000000
--- a/rackspace/orchestration/v1/buildinfo/delegate.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package buildinfo
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo"
-)
-
-// Get retreives build info data for the Heat deployment.
-func Get(c *gophercloud.ServiceClient) os.GetResult {
- return os.Get(c)
-}
diff --git a/rackspace/orchestration/v1/buildinfo/delegate_test.go b/rackspace/orchestration/v1/buildinfo/delegate_test.go
deleted file mode 100644
index b25a690..0000000
--- a/rackspace/orchestration/v1/buildinfo/delegate_test.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package buildinfo
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestGetTemplate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetSuccessfully(t, os.GetOutput)
-
- actual, err := Get(fake.ServiceClient()).Extract()
- th.AssertNoErr(t, err)
-
- expected := os.GetExpected
- th.AssertDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/orchestration/v1/buildinfo/doc.go b/rackspace/orchestration/v1/buildinfo/doc.go
deleted file mode 100644
index 183e8df..0000000
--- a/rackspace/orchestration/v1/buildinfo/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package buildinfo provides build information about heat deployments.
-package buildinfo
diff --git a/rackspace/orchestration/v1/stackevents/delegate.go b/rackspace/orchestration/v1/stackevents/delegate.go
deleted file mode 100644
index 08675de..0000000
--- a/rackspace/orchestration/v1/stackevents/delegate.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package stackevents
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// Find retreives stack events for the given stack name.
-func Find(c *gophercloud.ServiceClient, stackName string) os.FindResult {
- return os.Find(c, stackName)
-}
-
-// List makes a request against the API to list resources for the given stack.
-func List(c *gophercloud.ServiceClient, stackName, stackID string, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, stackName, stackID, opts)
-}
-
-// ListResourceEvents makes a request against the API to list resources for the given stack.
-func ListResourceEvents(c *gophercloud.ServiceClient, stackName, stackID, resourceName string, opts os.ListResourceEventsOptsBuilder) pagination.Pager {
- return os.ListResourceEvents(c, stackName, stackID, resourceName, opts)
-}
-
-// Get retreives data for the given stack resource.
-func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) os.GetResult {
- return os.Get(c, stackName, stackID, resourceName, eventID)
-}
diff --git a/rackspace/orchestration/v1/stackevents/delegate_test.go b/rackspace/orchestration/v1/stackevents/delegate_test.go
deleted file mode 100644
index e1c0bc8..0000000
--- a/rackspace/orchestration/v1/stackevents/delegate_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package stackevents
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestFindEvents(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleFindSuccessfully(t, os.FindOutput)
-
- actual, err := Find(fake.ServiceClient(), "postman_stack").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.FindExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListSuccessfully(t, os.ListOutput)
-
- count := 0
- err := List(fake.ServiceClient(), "hello_world", "49181cd6-169a-4130-9455-31185bbfc5bf", nil).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractEvents(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, os.ListExpected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestListResourceEvents(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListResourceEventsSuccessfully(t, os.ListResourceEventsOutput)
-
- count := 0
- err := ListResourceEvents(fake.ServiceClient(), "hello_world", "49181cd6-169a-4130-9455-31185bbfc5bf", "my_resource", nil).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractEvents(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, os.ListResourceEventsExpected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestGetEvent(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetSuccessfully(t, os.GetOutput)
-
- actual, err := Get(fake.ServiceClient(), "hello_world", "49181cd6-169a-4130-9455-31185bbfc5bf", "my_resource", "93940999-7d40-44ae-8de4-19624e7b8d18").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.GetExpected
- th.AssertDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/orchestration/v1/stackevents/doc.go b/rackspace/orchestration/v1/stackevents/doc.go
deleted file mode 100644
index dfd6ef6..0000000
--- a/rackspace/orchestration/v1/stackevents/doc.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Package stackevents provides operations for finding, listing, and retrieving
-// stack events.
-package stackevents
diff --git a/rackspace/orchestration/v1/stackresources/delegate.go b/rackspace/orchestration/v1/stackresources/delegate.go
deleted file mode 100644
index cb7be28..0000000
--- a/rackspace/orchestration/v1/stackresources/delegate.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package stackresources
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// Find retreives stack resources for the given stack name.
-func Find(c *gophercloud.ServiceClient, stackName string) os.FindResult {
- return os.Find(c, stackName)
-}
-
-// List makes a request against the API to list resources for the given stack.
-func List(c *gophercloud.ServiceClient, stackName, stackID string, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, stackName, stackID, opts)
-}
-
-// Get retreives data for the given stack resource.
-func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) os.GetResult {
- return os.Get(c, stackName, stackID, resourceName)
-}
-
-// Metadata retreives the metadata for the given stack resource.
-func Metadata(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) os.MetadataResult {
- return os.Metadata(c, stackName, stackID, resourceName)
-}
-
-// ListTypes makes a request against the API to list resource types.
-func ListTypes(c *gophercloud.ServiceClient) pagination.Pager {
- return os.ListTypes(c)
-}
-
-// Schema retreives the schema for the given resource type.
-func Schema(c *gophercloud.ServiceClient, resourceType string) os.SchemaResult {
- return os.Schema(c, resourceType)
-}
-
-// Template retreives the template representation for the given resource type.
-func Template(c *gophercloud.ServiceClient, resourceType string) os.TemplateResult {
- return os.Template(c, resourceType)
-}
diff --git a/rackspace/orchestration/v1/stackresources/delegate_test.go b/rackspace/orchestration/v1/stackresources/delegate_test.go
deleted file mode 100644
index 116e44c..0000000
--- a/rackspace/orchestration/v1/stackresources/delegate_test.go
+++ /dev/null
@@ -1,108 +0,0 @@
-package stackresources
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestFindResources(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleFindSuccessfully(t, os.FindOutput)
-
- actual, err := Find(fake.ServiceClient(), "hello_world").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.FindExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestListResources(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListSuccessfully(t, os.ListOutput)
-
- count := 0
- err := List(fake.ServiceClient(), "hello_world", "49181cd6-169a-4130-9455-31185bbfc5bf", nil).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractResources(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, os.ListExpected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestGetResource(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetSuccessfully(t, os.GetOutput)
-
- actual, err := Get(fake.ServiceClient(), "teststack", "0b1771bd-9336-4f2b-ae86-a80f971faf1e", "wordpress_instance").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.GetExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestResourceMetadata(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleMetadataSuccessfully(t, os.MetadataOutput)
-
- actual, err := Metadata(fake.ServiceClient(), "teststack", "0b1771bd-9336-4f2b-ae86-a80f971faf1e", "wordpress_instance").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.MetadataExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestListResourceTypes(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListTypesSuccessfully(t, os.ListTypesOutput)
-
- count := 0
- err := ListTypes(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractResourceTypes(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, os.ListTypesExpected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, 1, count)
-}
-
-func TestGetResourceSchema(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetSchemaSuccessfully(t, os.GetSchemaOutput)
-
- actual, err := Schema(fake.ServiceClient(), "OS::Heat::AResourceName").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.GetSchemaExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestGetResourceTemplate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetTemplateSuccessfully(t, os.GetTemplateOutput)
-
- actual, err := Template(fake.ServiceClient(), "OS::Heat::AResourceName").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.GetTemplateExpected
- th.AssertDeepEquals(t, expected, string(actual))
-}
diff --git a/rackspace/orchestration/v1/stackresources/doc.go b/rackspace/orchestration/v1/stackresources/doc.go
deleted file mode 100644
index e4f8b08..0000000
--- a/rackspace/orchestration/v1/stackresources/doc.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// Package stackresources provides operations for working with stack resources.
-// A resource is a template artifact that represents some component of your
-// desired architecture (a Cloud Server, a group of scaled Cloud Servers, a load
-// balancer, some configuration management system, and so forth).
-package stackresources
diff --git a/rackspace/orchestration/v1/stacks/delegate.go b/rackspace/orchestration/v1/stacks/delegate.go
deleted file mode 100644
index f7e387f..0000000
--- a/rackspace/orchestration/v1/stacks/delegate.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package stacks
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// Create accepts an os.CreateOpts struct and creates a new stack using the values
-// provided.
-func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
- return os.Create(c, opts)
-}
-
-// Adopt accepts an os.AdoptOpts struct and creates a new stack from existing stack
-// resources using the values provided.
-func Adopt(c *gophercloud.ServiceClient, opts os.AdoptOptsBuilder) os.AdoptResult {
- return os.Adopt(c, opts)
-}
-
-// List accepts an os.ListOpts struct and lists stacks based on the options provided.
-func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
- return os.List(c, opts)
-}
-
-// Get retreives a stack based on the stack name and stack ID.
-func Get(c *gophercloud.ServiceClient, stackName, stackID string) os.GetResult {
- return os.Get(c, stackName, stackID)
-}
-
-// Update accepts an os.UpdateOpts struct and updates a stack based on the options provided.
-func Update(c *gophercloud.ServiceClient, stackName, stackID string, opts os.UpdateOptsBuilder) os.UpdateResult {
- return os.Update(c, stackName, stackID, opts)
-}
-
-// Delete deletes a stack based on the stack name and stack ID provided.
-func Delete(c *gophercloud.ServiceClient, stackName, stackID string) os.DeleteResult {
- return os.Delete(c, stackName, stackID)
-}
-
-// Preview provides a preview of a stack based on the options provided.
-func Preview(c *gophercloud.ServiceClient, opts os.PreviewOptsBuilder) os.PreviewResult {
- return os.Preview(c, opts)
-}
-
-// Abandon abandons a stack, keeping the resources available.
-func Abandon(c *gophercloud.ServiceClient, stackName, stackID string) os.AbandonResult {
- return os.Abandon(c, stackName, stackID)
-}
diff --git a/rackspace/orchestration/v1/stacks/delegate_test.go b/rackspace/orchestration/v1/stacks/delegate_test.go
deleted file mode 100644
index 553ae94..0000000
--- a/rackspace/orchestration/v1/stacks/delegate_test.go
+++ /dev/null
@@ -1,870 +0,0 @@
-package stacks
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestCreateStack(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCreateSuccessfully(t, CreateOutput)
-
- createOpts := os.CreateOpts{
- Name: "stackcreated",
- Timeout: 60,
- Template: `{
- "outputs": {
- "db_host": {
- "value": {
- "get_attr": [
- "db",
- "hostname"
- ]
- }
- }
- },
- "heat_template_version": "2014-10-16",
- "description": "HEAT template for creating a Cloud Database.\n",
- "parameters": {
- "db_name": {
- "default": "wordpress",
- "type": "string",
- "description": "the name for the database",
- "constraints": [
- {
- "length": {
- "max": 64,
- "min": 1
- },
- "description": "must be between 1 and 64 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z][a-zA-Z0-9]*",
- "description": "must begin with a letter and contain only alphanumeric characters."
- }
- ]
- },
- "db_instance_name": {
- "default": "Cloud_DB",
- "type": "string",
- "description": "the database instance name"
- },
- "db_username": {
- "default": "admin",
- "hidden": true,
- "type": "string",
- "description": "database admin account username",
- "constraints": [
- {
- "length": {
- "max": 16,
- "min": 1
- },
- "description": "must be between 1 and 16 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z][a-zA-Z0-9]*",
- "description": "must begin with a letter and contain only alphanumeric characters."
- }
- ]
- },
- "db_volume_size": {
- "default": 30,
- "type": "number",
- "description": "database volume size (in GB)",
- "constraints": [
- {
- "range": {
- "max": 1024,
- "min": 1
- },
- "description": "must be between 1 and 1024 GB"
- }
- ]
- },
- "db_flavor": {
- "default": "1GB Instance",
- "type": "string",
- "description": "database instance size",
- "constraints": [
- {
- "description": "must be a valid cloud database flavor",
- "allowed_values": [
- "1GB Instance",
- "2GB Instance",
- "4GB Instance",
- "8GB Instance",
- "16GB Instance"
- ]
- }
- ]
- },
- "db_password": {
- "default": "admin",
- "hidden": true,
- "type": "string",
- "description": "database admin account password",
- "constraints": [
- {
- "length": {
- "max": 41,
- "min": 1
- },
- "description": "must be between 1 and 14 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z0-9]*",
- "description": "must contain only alphanumeric characters."
- }
- ]
- }
- },
- "resources": {
- "db": {
- "type": "OS::Trove::Instance",
- "properties": {
- "flavor": {
- "get_param": "db_flavor"
- },
- "size": {
- "get_param": "db_volume_size"
- },
- "users": [
- {
- "password": {
- "get_param": "db_password"
- },
- "name": {
- "get_param": "db_username"
- },
- "databases": [
- {
- "get_param": "db_name"
- }
- ]
- }
- ],
- "name": {
- "get_param": "db_instance_name"
- },
- "databases": [
- {
- "name": {
- "get_param": "db_name"
- }
- }
- ]
- }
- }
- }
- }`,
- DisableRollback: os.Disable,
- }
- actual, err := Create(fake.ServiceClient(), createOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := CreateExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestCreateStackNewTemplateFormat(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCreateSuccessfully(t, CreateOutput)
-
- createOpts := os.CreateOpts{
- Name: "stackcreated",
- Timeout: 60,
- TemplateOpts: new(os.Template),
- DisableRollback: os.Disable,
- }
- createOpts.TemplateOpts.Bin = []byte(`{
- "outputs": {
- "db_host": {
- "value": {
- "get_attr": [
- "db",
- "hostname"
- ]
- }
- }
- },
- "heat_template_version": "2014-10-16",
- "description": "HEAT template for creating a Cloud Database.\n",
- "parameters": {
- "db_name": {
- "default": "wordpress",
- "type": "string",
- "description": "the name for the database",
- "constraints": [
- {
- "length": {
- "max": 64,
- "min": 1
- },
- "description": "must be between 1 and 64 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z][a-zA-Z0-9]*",
- "description": "must begin with a letter and contain only alphanumeric characters."
- }
- ]
- },
- "db_instance_name": {
- "default": "Cloud_DB",
- "type": "string",
- "description": "the database instance name"
- },
- "db_username": {
- "default": "admin",
- "hidden": true,
- "type": "string",
- "description": "database admin account username",
- "constraints": [
- {
- "length": {
- "max": 16,
- "min": 1
- },
- "description": "must be between 1 and 16 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z][a-zA-Z0-9]*",
- "description": "must begin with a letter and contain only alphanumeric characters."
- }
- ]
- },
- "db_volume_size": {
- "default": 30,
- "type": "number",
- "description": "database volume size (in GB)",
- "constraints": [
- {
- "range": {
- "max": 1024,
- "min": 1
- },
- "description": "must be between 1 and 1024 GB"
- }
- ]
- },
- "db_flavor": {
- "default": "1GB Instance",
- "type": "string",
- "description": "database instance size",
- "constraints": [
- {
- "description": "must be a valid cloud database flavor",
- "allowed_values": [
- "1GB Instance",
- "2GB Instance",
- "4GB Instance",
- "8GB Instance",
- "16GB Instance"
- ]
- }
- ]
- },
- "db_password": {
- "default": "admin",
- "hidden": true,
- "type": "string",
- "description": "database admin account password",
- "constraints": [
- {
- "length": {
- "max": 41,
- "min": 1
- },
- "description": "must be between 1 and 14 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z0-9]*",
- "description": "must contain only alphanumeric characters."
- }
- ]
- }
- },
- "resources": {
- "db": {
- "type": "OS::Trove::Instance",
- "properties": {
- "flavor": {
- "get_param": "db_flavor"
- },
- "size": {
- "get_param": "db_volume_size"
- },
- "users": [
- {
- "password": {
- "get_param": "db_password"
- },
- "name": {
- "get_param": "db_username"
- },
- "databases": [
- {
- "get_param": "db_name"
- }
- ]
- }
- ],
- "name": {
- "get_param": "db_instance_name"
- },
- "databases": [
- {
- "name": {
- "get_param": "db_name"
- }
- }
- ]
- }
- }
- }
- }`)
- actual, err := Create(fake.ServiceClient(), createOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := CreateExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestAdoptStack(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCreateSuccessfully(t, CreateOutput)
-
- adoptOpts := os.AdoptOpts{
- AdoptStackData: `{\"environment\":{\"parameters\":{}}, \"status\":\"COMPLETE\",\"name\": \"trovestack\",\n \"template\": {\n \"outputs\": {\n \"db_host\": {\n \"value\": {\n \"get_attr\": [\n \"db\",\n \"hostname\"\n ]\n }\n }\n },\n \"heat_template_version\": \"2014-10-16\",\n \"description\": \"HEAT template for creating a Cloud Database.\\n\",\n \"parameters\": {\n \"db_instance_name\": {\n \"default\": \"Cloud_DB\",\n \"type\": \"string\",\n \"description\": \"the database instance name\"\n },\n \"db_flavor\": {\n \"default\": \"1GB Instance\",\n \"type\": \"string\",\n \"description\": \"database instance size\",\n \"constraints\": [\n {\n \"description\": \"must be a valid cloud database flavor\",\n \"allowed_values\": [\n \"1GB Instance\",\n \"2GB Instance\",\n \"4GB Instance\",\n \"8GB Instance\",\n \"16GB Instance\"\n ]\n }\n ]\n },\n \"db_password\": {\n \"default\": \"admin\",\n \"hidden\": true,\n \"type\": \"string\",\n \"description\": \"database admin account password\",\n \"constraints\": [\n {\n \"length\": {\n \"max\": 41,\n \"min\": 1\n },\n \"description\": \"must be between 1 and 14 characters\"\n },\n {\n \"allowed_pattern\": \"[a-zA-Z0-9]*\",\n \"description\": \"must contain only alphanumeric characters.\"\n }\n ]\n },\n \"db_name\": {\n \"default\": \"wordpress\",\n \"type\": \"string\",\n \"description\": \"the name for the database\",\n \"constraints\": [\n {\n \"length\": {\n \"max\": 64,\n \"min\": 1\n },\n \"description\": \"must be between 1 and 64 characters\"\n },\n {\n \"allowed_pattern\": \"[a-zA-Z][a-zA-Z0-9]*\",\n \"description\": \"must begin with a letter and contain only alphanumeric characters.\"\n }\n ]\n },\n \"db_username\": {\n \"default\": \"admin\",\n \"hidden\": true,\n \"type\": \"string\",\n \"description\": \"database admin account username\",\n \"constraints\": [\n {\n \"length\": {\n \"max\": 16,\n \"min\": 1\n },\n \"description\": \"must be between 1 and 16 characters\"\n },\n {\n \"allowed_pattern\": \"[a-zA-Z][a-zA-Z0-9]*\",\n \"description\": \"must begin with a letter and contain only alphanumeric characters.\"\n }\n ]\n },\n \"db_volume_size\": {\n \"default\": 30,\n \"type\": \"number\",\n \"description\": \"database volume size (in GB)\",\n \"constraints\": [\n {\n \"range\": {\n \"max\": 1024,\n \"min\": 1\n },\n \"description\": \"must be between 1 and 1024 GB\"\n }\n ]\n }\n },\n \"resources\": {\n \"db\": {\n \"type\": \"OS::Trove::Instance\",\n \"properties\": {\n \"flavor\": {\n \"get_param\": \"db_flavor\"\n },\n \"databases\": [\n {\n \"name\": {\n \"get_param\": \"db_name\"\n }\n }\n ],\n \"users\": [\n {\n \"password\": {\n \"get_param\": \"db_password\"\n },\n \"name\": {\n \"get_param\": \"db_username\"\n },\n \"databases\": [\n {\n \"get_param\": \"db_name\"\n }\n ]\n }\n ],\n \"name\": {\n \"get_param\": \"db_instance_name\"\n },\n \"size\": {\n \"get_param\": \"db_volume_size\"\n }\n }\n }\n }\n },\n \"action\": \"CREATE\",\n \"id\": \"exxxxd-7xx5-4xxb-bxx2-cxxxxxx5\",\n \"resources\": {\n \"db\": {\n \"status\": \"COMPLETE\",\n \"name\": \"db\",\n \"resource_data\": {},\n \"resource_id\": \"exxxx2-9xx0-4xxxb-bxx2-dxxxxxx4\",\n \"action\": \"CREATE\",\n \"type\": \"OS::Trove::Instance\",\n \"metadata\": {}\n }\n }\n},`,
- Name: "stackadopted",
- Timeout: 60,
- Template: `{
- "outputs": {
- "db_host": {
- "value": {
- "get_attr": [
- "db",
- "hostname"
- ]
- }
- }
- },
- "heat_template_version": "2014-10-16",
- "description": "HEAT template for creating a Cloud Database.\n",
- "parameters": {
- "db_name": {
- "default": "wordpress",
- "type": "string",
- "description": "the name for the database",
- "constraints": [
- {
- "length": {
- "max": 64,
- "min": 1
- },
- "description": "must be between 1 and 64 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z][a-zA-Z0-9]*",
- "description": "must begin with a letter and contain only alphanumeric characters."
- }
- ]
- },
- "db_instance_name": {
- "default": "Cloud_DB",
- "type": "string",
- "description": "the database instance name"
- },
- "db_username": {
- "default": "admin",
- "hidden": true,
- "type": "string",
- "description": "database admin account username",
- "constraints": [
- {
- "length": {
- "max": 16,
- "min": 1
- },
- "description": "must be between 1 and 16 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z][a-zA-Z0-9]*",
- "description": "must begin with a letter and contain only alphanumeric characters."
- }
- ]
- },
- "db_volume_size": {
- "default": 30,
- "type": "number",
- "description": "database volume size (in GB)",
- "constraints": [
- {
- "range": {
- "max": 1024,
- "min": 1
- },
- "description": "must be between 1 and 1024 GB"
- }
- ]
- },
- "db_flavor": {
- "default": "1GB Instance",
- "type": "string",
- "description": "database instance size",
- "constraints": [
- {
- "description": "must be a valid cloud database flavor",
- "allowed_values": [
- "1GB Instance",
- "2GB Instance",
- "4GB Instance",
- "8GB Instance",
- "16GB Instance"
- ]
- }
- ]
- },
- "db_password": {
- "default": "admin",
- "hidden": true,
- "type": "string",
- "description": "database admin account password",
- "constraints": [
- {
- "length": {
- "max": 41,
- "min": 1
- },
- "description": "must be between 1 and 14 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z0-9]*",
- "description": "must contain only alphanumeric characters."
- }
- ]
- }
- },
- "resources": {
- "db": {
- "type": "OS::Trove::Instance",
- "properties": {
- "flavor": {
- "get_param": "db_flavor"
- },
- "size": {
- "get_param": "db_volume_size"
- },
- "users": [
- {
- "password": {
- "get_param": "db_password"
- },
- "name": {
- "get_param": "db_username"
- },
- "databases": [
- {
- "get_param": "db_name"
- }
- ]
- }
- ],
- "name": {
- "get_param": "db_instance_name"
- },
- "databases": [
- {
- "name": {
- "get_param": "db_name"
- }
- }
- ]
- }
- }
- }
- }`,
- DisableRollback: os.Disable,
- }
- actual, err := Adopt(fake.ServiceClient(), adoptOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := CreateExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestAdoptStackNewTemplateFormat(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleCreateSuccessfully(t, CreateOutput)
- template := new(os.Template)
- template.Bin = []byte(`{
- "outputs": {
- "db_host": {
- "value": {
- "get_attr": [
- "db",
- "hostname"
- ]
- }
- }
- },
- "heat_template_version": "2014-10-16",
- "description": "HEAT template for creating a Cloud Database.\n",
- "parameters": {
- "db_name": {
- "default": "wordpress",
- "type": "string",
- "description": "the name for the database",
- "constraints": [
- {
- "length": {
- "max": 64,
- "min": 1
- },
- "description": "must be between 1 and 64 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z][a-zA-Z0-9]*",
- "description": "must begin with a letter and contain only alphanumeric characters."
- }
- ]
- },
- "db_instance_name": {
- "default": "Cloud_DB",
- "type": "string",
- "description": "the database instance name"
- },
- "db_username": {
- "default": "admin",
- "hidden": true,
- "type": "string",
- "description": "database admin account username",
- "constraints": [
- {
- "length": {
- "max": 16,
- "min": 1
- },
- "description": "must be between 1 and 16 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z][a-zA-Z0-9]*",
- "description": "must begin with a letter and contain only alphanumeric characters."
- }
- ]
- },
- "db_volume_size": {
- "default": 30,
- "type": "number",
- "description": "database volume size (in GB)",
- "constraints": [
- {
- "range": {
- "max": 1024,
- "min": 1
- },
- "description": "must be between 1 and 1024 GB"
- }
- ]
- },
- "db_flavor": {
- "default": "1GB Instance",
- "type": "string",
- "description": "database instance size",
- "constraints": [
- {
- "description": "must be a valid cloud database flavor",
- "allowed_values": [
- "1GB Instance",
- "2GB Instance",
- "4GB Instance",
- "8GB Instance",
- "16GB Instance"
- ]
- }
- ]
- },
- "db_password": {
- "default": "admin",
- "hidden": true,
- "type": "string",
- "description": "database admin account password",
- "constraints": [
- {
- "length": {
- "max": 41,
- "min": 1
- },
- "description": "must be between 1 and 14 characters"
- },
- {
- "allowed_pattern": "[a-zA-Z0-9]*",
- "description": "must contain only alphanumeric characters."
- }
- ]
- }
- },
- "resources": {
- "db": {
- "type": "OS::Trove::Instance",
- "properties": {
- "flavor": {
- "get_param": "db_flavor"
- },
- "size": {
- "get_param": "db_volume_size"
- },
- "users": [
- {
- "password": {
- "get_param": "db_password"
- },
- "name": {
- "get_param": "db_username"
- },
- "databases": [
- {
- "get_param": "db_name"
- }
- ]
- }
- ],
- "name": {
- "get_param": "db_instance_name"
- },
- "databases": [
- {
- "name": {
- "get_param": "db_name"
- }
- }
- ]
- }
- }
- }
-}`)
-
- adoptOpts := os.AdoptOpts{
- AdoptStackData: `{\"environment\":{\"parameters\":{}}, \"status\":\"COMPLETE\",\"name\": \"trovestack\",\n \"template\": {\n \"outputs\": {\n \"db_host\": {\n \"value\": {\n \"get_attr\": [\n \"db\",\n \"hostname\"\n ]\n }\n }\n },\n \"heat_template_version\": \"2014-10-16\",\n \"description\": \"HEAT template for creating a Cloud Database.\\n\",\n \"parameters\": {\n \"db_instance_name\": {\n \"default\": \"Cloud_DB\",\n \"type\": \"string\",\n \"description\": \"the database instance name\"\n },\n \"db_flavor\": {\n \"default\": \"1GB Instance\",\n \"type\": \"string\",\n \"description\": \"database instance size\",\n \"constraints\": [\n {\n \"description\": \"must be a valid cloud database flavor\",\n \"allowed_values\": [\n \"1GB Instance\",\n \"2GB Instance\",\n \"4GB Instance\",\n \"8GB Instance\",\n \"16GB Instance\"\n ]\n }\n ]\n },\n \"db_password\": {\n \"default\": \"admin\",\n \"hidden\": true,\n \"type\": \"string\",\n \"description\": \"database admin account password\",\n \"constraints\": [\n {\n \"length\": {\n \"max\": 41,\n \"min\": 1\n },\n \"description\": \"must be between 1 and 14 characters\"\n },\n {\n \"allowed_pattern\": \"[a-zA-Z0-9]*\",\n \"description\": \"must contain only alphanumeric characters.\"\n }\n ]\n },\n \"db_name\": {\n \"default\": \"wordpress\",\n \"type\": \"string\",\n \"description\": \"the name for the database\",\n \"constraints\": [\n {\n \"length\": {\n \"max\": 64,\n \"min\": 1\n },\n \"description\": \"must be between 1 and 64 characters\"\n },\n {\n \"allowed_pattern\": \"[a-zA-Z][a-zA-Z0-9]*\",\n \"description\": \"must begin with a letter and contain only alphanumeric characters.\"\n }\n ]\n },\n \"db_username\": {\n \"default\": \"admin\",\n \"hidden\": true,\n \"type\": \"string\",\n \"description\": \"database admin account username\",\n \"constraints\": [\n {\n \"length\": {\n \"max\": 16,\n \"min\": 1\n },\n \"description\": \"must be between 1 and 16 characters\"\n },\n {\n \"allowed_pattern\": \"[a-zA-Z][a-zA-Z0-9]*\",\n \"description\": \"must begin with a letter and contain only alphanumeric characters.\"\n }\n ]\n },\n \"db_volume_size\": {\n \"default\": 30,\n \"type\": \"number\",\n \"description\": \"database volume size (in GB)\",\n \"constraints\": [\n {\n \"range\": {\n \"max\": 1024,\n \"min\": 1\n },\n \"description\": \"must be between 1 and 1024 GB\"\n }\n ]\n }\n },\n \"resources\": {\n \"db\": {\n \"type\": \"OS::Trove::Instance\",\n \"properties\": {\n \"flavor\": {\n \"get_param\": \"db_flavor\"\n },\n \"databases\": [\n {\n \"name\": {\n \"get_param\": \"db_name\"\n }\n }\n ],\n \"users\": [\n {\n \"password\": {\n \"get_param\": \"db_password\"\n },\n \"name\": {\n \"get_param\": \"db_username\"\n },\n \"databases\": [\n {\n \"get_param\": \"db_name\"\n }\n ]\n }\n ],\n \"name\": {\n \"get_param\": \"db_instance_name\"\n },\n \"size\": {\n \"get_param\": \"db_volume_size\"\n }\n }\n }\n }\n },\n \"action\": \"CREATE\",\n \"id\": \"exxxxd-7xx5-4xxb-bxx2-cxxxxxx5\",\n \"resources\": {\n \"db\": {\n \"status\": \"COMPLETE\",\n \"name\": \"db\",\n \"resource_data\": {},\n \"resource_id\": \"exxxx2-9xx0-4xxxb-bxx2-dxxxxxx4\",\n \"action\": \"CREATE\",\n \"type\": \"OS::Trove::Instance\",\n \"metadata\": {}\n }\n }\n},`,
- Name: "stackadopted",
- Timeout: 60,
- TemplateOpts: template,
- DisableRollback: os.Disable,
- }
- actual, err := Adopt(fake.ServiceClient(), adoptOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := CreateExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestListStack(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleListSuccessfully(t, os.FullListOutput)
-
- count := 0
- err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := os.ExtractStacks(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, os.ListExpected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestUpdateStack(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleUpdateSuccessfully(t)
-
- updateOpts := os.UpdateOpts{
- Template: `
- {
- "heat_template_version": "2013-05-23",
- "description": "Simple template to test heat commands",
- "parameters": {
- "flavor": {
- "default": "m1.tiny",
- "type": "string"
- }
- },
- "resources": {
- "hello_world": {
- "type":"OS::Nova::Server",
- "properties": {
- "key_name": "heat_key",
- "flavor": {
- "get_param": "flavor"
- },
- "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
- }
- }
- }
- }`,
- }
- err := Update(fake.ServiceClient(), "gophercloud-test-stack-2", "db6977b2-27aa-4775-9ae7-6213212d4ada", updateOpts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestUpdateStackNewTemplateFormat(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleUpdateSuccessfully(t)
-
- updateOpts := os.UpdateOpts{
- TemplateOpts: new(os.Template),
- }
- updateOpts.TemplateOpts.Bin = []byte(`
- {
- "stack_name": "postman_stack",
- "template": {
- "heat_template_version": "2013-05-23",
- "description": "Simple template to test heat commands",
- "parameters": {
- "flavor": {
- "default": "m1.tiny",
- "type": "string"
- }
- },
- "resources": {
- "hello_world": {
- "type": "OS::Nova::Server",
- "properties": {
- "key_name": "heat_key",
- "flavor": {
- "get_param": "flavor"
- },
- "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
- }
- }
- }
- }
- }`)
- err := Update(fake.ServiceClient(), "gophercloud-test-stack-2", "db6977b2-27aa-4775-9ae7-6213212d4ada", updateOpts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestDeleteStack(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleDeleteSuccessfully(t)
-
- err := Delete(fake.ServiceClient(), "gophercloud-test-stack-2", "db6977b2-27aa-4775-9ae7-6213212d4ada").ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestPreviewStack(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandlePreviewSuccessfully(t, os.GetOutput)
-
- previewOpts := os.PreviewOpts{
- Name: "stackcreated",
- Timeout: 60,
- Template: `
- {
- "stack_name": "postman_stack",
- "template": {
- "heat_template_version": "2013-05-23",
- "description": "Simple template to test heat commands",
- "parameters": {
- "flavor": {
- "default": "m1.tiny",
- "type": "string"
- }
- },
- "resources": {
- "hello_world": {
- "type":"OS::Nova::Server",
- "properties": {
- "key_name": "heat_key",
- "flavor": {
- "get_param": "flavor"
- },
- "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
- }
- }
- }
- }
- }`,
- DisableRollback: os.Disable,
- }
- actual, err := Preview(fake.ServiceClient(), previewOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := os.PreviewExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestPreviewStackNewTemplateFormat(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandlePreviewSuccessfully(t, os.GetOutput)
-
- previewOpts := os.PreviewOpts{
- Name: "stackcreated",
- Timeout: 60,
- TemplateOpts: new(os.Template),
- DisableRollback: os.Disable,
- }
- previewOpts.TemplateOpts.Bin = []byte(`
- {
- "stack_name": "postman_stack",
- "template": {
- "heat_template_version": "2013-05-23",
- "description": "Simple template to test heat commands",
- "parameters": {
- "flavor": {
- "default": "m1.tiny",
- "type": "string"
- }
- },
- "resources": {
- "hello_world": {
- "type": "OS::Nova::Server",
- "properties": {
- "key_name": "heat_key",
- "flavor": {
- "get_param": "flavor"
- },
- "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
- }
- }
- }
- }
- }`)
- actual, err := Preview(fake.ServiceClient(), previewOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := os.PreviewExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestAbandonStack(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleAbandonSuccessfully(t, os.AbandonOutput)
-
- actual, err := Abandon(fake.ServiceClient(), "postman_stack", "16ef0584-4458-41eb-87c8-0dc8d5f66c8").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.AbandonExpected
- th.AssertDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/orchestration/v1/stacks/doc.go b/rackspace/orchestration/v1/stacks/doc.go
deleted file mode 100644
index 19231b5..0000000
--- a/rackspace/orchestration/v1/stacks/doc.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// Package stacks provides operation for working with Heat stacks. A stack is a
-// group of resources (servers, load balancers, databases, and so forth)
-// combined to fulfill a useful purpose. Based on a template, Heat orchestration
-// engine creates an instantiated set of resources (a stack) to run the
-// application framework or component specified (in the template). A stack is a
-// running instance of a template. The result of creating a stack is a deployment
-// of the application framework or component.
-package stacks
diff --git a/rackspace/orchestration/v1/stacks/fixtures.go b/rackspace/orchestration/v1/stacks/fixtures.go
deleted file mode 100644
index c9afeb1..0000000
--- a/rackspace/orchestration/v1/stacks/fixtures.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package stacks
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks"
-)
-
-// CreateExpected represents the expected object from a Create request.
-var CreateExpected = &os.CreatedStack{
- ID: "b663e18a-4767-4cdf-9db5-9c8cc13cc38a",
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "https://ord.orchestration.api.rackspacecloud.com/v1/864477/stacks/stackcreated/b663e18a-4767-4cdf-9db5-9c8cc13cc38a",
- Rel: "self",
- },
- },
-}
-
-// CreateOutput represents the response body from a Create request.
-const CreateOutput = `
-{
- "stack": {
- "id": "b663e18a-4767-4cdf-9db5-9c8cc13cc38a",
- "links": [
- {
- "href": "https://ord.orchestration.api.rackspacecloud.com/v1/864477/stacks/stackcreated/b663e18a-4767-4cdf-9db5-9c8cc13cc38a",
- "rel": "self"
- }
- ]
- }
-}
-`
diff --git a/rackspace/orchestration/v1/stacktemplates/delegate.go b/rackspace/orchestration/v1/stacktemplates/delegate.go
deleted file mode 100644
index 3b5d46e..0000000
--- a/rackspace/orchestration/v1/stacktemplates/delegate.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package stacktemplates
-
-import (
- "github.com/rackspace/gophercloud"
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates"
-)
-
-// Get retreives data for the given stack template.
-func Get(c *gophercloud.ServiceClient, stackName, stackID string) os.GetResult {
- return os.Get(c, stackName, stackID)
-}
-
-// Validate validates the given stack template.
-func Validate(c *gophercloud.ServiceClient, opts os.ValidateOptsBuilder) os.ValidateResult {
- return os.Validate(c, opts)
-}
diff --git a/rackspace/orchestration/v1/stacktemplates/delegate_test.go b/rackspace/orchestration/v1/stacktemplates/delegate_test.go
deleted file mode 100644
index d4d0f8f..0000000
--- a/rackspace/orchestration/v1/stacktemplates/delegate_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package stacktemplates
-
-import (
- "testing"
-
- os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestGetTemplate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleGetSuccessfully(t, os.GetOutput)
-
- actual, err := Get(fake.ServiceClient(), "postman_stack", "16ef0584-4458-41eb-87c8-0dc8d5f66c87").Extract()
- th.AssertNoErr(t, err)
-
- expected := os.GetExpected
- th.AssertDeepEquals(t, expected, string(actual))
-}
-
-func TestValidateTemplate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- os.HandleValidateSuccessfully(t, os.ValidateOutput)
-
- opts := os.ValidateOpts{
- Template: `{
- "Description": "Simple template to test heat commands",
- "Parameters": {
- "flavor": {
- "Default": "m1.tiny",
- "Type": "String",
- "NoEcho": "false",
- "Description": "",
- "Label": "flavor"
- }
- }
- }`,
- }
- actual, err := Validate(fake.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
-
- expected := os.ValidateExpected
- th.AssertDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/orchestration/v1/stacktemplates/doc.go b/rackspace/orchestration/v1/stacktemplates/doc.go
deleted file mode 100644
index 5af0bd6..0000000
--- a/rackspace/orchestration/v1/stacktemplates/doc.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// Package stacktemplates provides operations for working with Heat templates.
-// A Cloud Orchestration template is a portable file, written in a user-readable
-// language, that describes how a set of resources should be assembled and what
-// software should be installed in order to produce a working stack. The template
-// specifies what resources should be used, what attributes can be set, and other
-// parameters that are critical to the successful, repeatable automation of a
-// specific application stack.
-package stacktemplates
diff --git a/rackspace/rackconnect/v3/cloudnetworks/requests.go b/rackspace/rackconnect/v3/cloudnetworks/requests.go
deleted file mode 100644
index 5884303..0000000
--- a/rackspace/rackconnect/v3/cloudnetworks/requests.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package cloudnetworks
-
-import (
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns all cloud networks that are associated with RackConnect. The ID
-// returned for each network is the same as the ID returned by the networks package.
-func List(c *gophercloud.ServiceClient) pagination.Pager {
- url := listURL(c)
- createPage := func(r pagination.PageResult) pagination.Page {
- return CloudNetworkPage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(c, url, createPage)
-}
-
-// Get retrieves a specific cloud network (that is associated with RackConnect)
-// based on its unique ID.
-func Get(c *gophercloud.ServiceClient, id string) GetResult {
- var res GetResult
- _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
- return res
-}
diff --git a/rackspace/rackconnect/v3/cloudnetworks/requests_test.go b/rackspace/rackconnect/v3/cloudnetworks/requests_test.go
deleted file mode 100644
index 10d15dd..0000000
--- a/rackspace/rackconnect/v3/cloudnetworks/requests_test.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package cloudnetworks
-
-import (
- "fmt"
- "net/http"
- "testing"
- "time"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListCloudNetworks(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/cloud_networks", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- fmt.Fprintf(w, `[{
- "cidr": "192.168.100.0/24",
- "created": "2014-05-25T01:23:42Z",
- "id": "07426958-1ebf-4c38-b032-d456820ca21a",
- "name": "RC-CLOUD",
- "updated": "2014-05-25T02:28:44Z"
- }]`)
- })
-
- expected := []CloudNetwork{
- CloudNetwork{
- CIDR: "192.168.100.0/24",
- CreatedAt: time.Date(2014, 5, 25, 1, 23, 42, 0, time.UTC),
- ID: "07426958-1ebf-4c38-b032-d456820ca21a",
- Name: "RC-CLOUD",
- UpdatedAt: time.Date(2014, 5, 25, 2, 28, 44, 0, time.UTC),
- },
- }
-
- count := 0
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractCloudNetworks(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestGetCloudNetwork(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/cloud_networks/07426958-1ebf-4c38-b032-d456820ca21a", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `{
- "cidr": "192.168.100.0/24",
- "created": "2014-05-25T01:23:42Z",
- "id": "07426958-1ebf-4c38-b032-d456820ca21a",
- "name": "RC-CLOUD",
- "updated": "2014-05-25T02:28:44Z"
- }`)
- })
-
- expected := &CloudNetwork{
- CIDR: "192.168.100.0/24",
- CreatedAt: time.Date(2014, 5, 25, 1, 23, 42, 0, time.UTC),
- ID: "07426958-1ebf-4c38-b032-d456820ca21a",
- Name: "RC-CLOUD",
- UpdatedAt: time.Date(2014, 5, 25, 2, 28, 44, 0, time.UTC),
- }
-
- actual, err := Get(fake.ServiceClient(), "07426958-1ebf-4c38-b032-d456820ca21a").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertDeepEquals(t, expected, actual)
-}
diff --git a/rackspace/rackconnect/v3/cloudnetworks/results.go b/rackspace/rackconnect/v3/cloudnetworks/results.go
deleted file mode 100644
index f554a0d..0000000
--- a/rackspace/rackconnect/v3/cloudnetworks/results.go
+++ /dev/null
@@ -1,113 +0,0 @@
-package cloudnetworks
-
-import (
- "fmt"
- "reflect"
- "time"
-
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// CloudNetwork represents a network associated with a RackConnect configuration.
-type CloudNetwork struct {
- // Specifies the ID of the newtork.
- ID string `mapstructure:"id"`
- // Specifies the user-provided name of the network.
- Name string `mapstructure:"name"`
- // Specifies the IP range for this network.
- CIDR string `mapstructure:"cidr"`
- // Specifies the time the network was created.
- CreatedAt time.Time `mapstructure:"-"`
- // Specifies the time the network was last updated.
- UpdatedAt time.Time `mapstructure:"-"`
-}
-
-// CloudNetworkPage is the page returned by a pager when traversing over a
-// collection of CloudNetworks.
-type CloudNetworkPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty returns true if a CloudNetworkPage contains no CloudNetworks.
-func (r CloudNetworkPage) IsEmpty() (bool, error) {
- cns, err := ExtractCloudNetworks(r)
- if err != nil {
- return true, err
- }
- return len(cns) == 0, nil
-}
-
-// ExtractCloudNetworks extracts and returns CloudNetworks. It is used while iterating over
-// a cloudnetworks.List call.
-func ExtractCloudNetworks(page pagination.Page) ([]CloudNetwork, error) {
- var res []CloudNetwork
- casted := page.(CloudNetworkPage).Body
- err := mapstructure.Decode(casted, &res)
-
- var rawNets []interface{}
- switch casted.(type) {
- case interface{}:
- rawNets = casted.([]interface{})
- default:
- return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
- }
-
- for i := range rawNets {
- thisNet := (rawNets[i]).(map[string]interface{})
-
- if t, ok := thisNet["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CreatedAt = creationTime
- }
-
- if t, ok := thisNet["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].UpdatedAt = updatedTime
- }
- }
-
- return res, err
-}
-
-// GetResult represents the result of a Get operation.
-type GetResult struct {
- gophercloud.Result
-}
-
-// Extract is a function that extracts a CloudNetwork from a GetResult.
-func (r GetResult) Extract() (*CloudNetwork, error) {
- if r.Err != nil {
- return nil, r.Err
- }
- var res CloudNetwork
-
- err := mapstructure.Decode(r.Body, &res)
-
- b := r.Body.(map[string]interface{})
-
- if date, ok := b["created"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res.CreatedAt = t
- }
-
- if date, ok := b["updated"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res.UpdatedAt = t
- }
-
- return &res, err
-}
diff --git a/rackspace/rackconnect/v3/cloudnetworks/urls.go b/rackspace/rackconnect/v3/cloudnetworks/urls.go
deleted file mode 100644
index bd6b098..0000000
--- a/rackspace/rackconnect/v3/cloudnetworks/urls.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package cloudnetworks
-
-import "github.com/rackspace/gophercloud"
-
-func listURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL("cloud_networks")
-}
-
-func getURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL("cloud_networks", id)
-}
diff --git a/rackspace/rackconnect/v3/doc.go b/rackspace/rackconnect/v3/doc.go
deleted file mode 100644
index 3a8279e..0000000
--- a/rackspace/rackconnect/v3/doc.go
+++ /dev/null
@@ -1,4 +0,0 @@
-// Package rackconnect allows Rackspace cloud accounts to leverage version 3 of
-// RackConnect, Rackspace's hybrid connectivity solution connecting dedicated
-// and cloud servers.
-package rackconnect
diff --git a/rackspace/rackconnect/v3/lbpools/doc.go b/rackspace/rackconnect/v3/lbpools/doc.go
deleted file mode 100644
index f4319b8..0000000
--- a/rackspace/rackconnect/v3/lbpools/doc.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// Package lbpools provides access to load balancer pools associated with a
-// RackConnect configuration. Load Balancer Pools must be configured in advance
-// by your Network Security team to be eligible for use with RackConnect.
-// If you do not see a pool that you expect to see, contact your Support team
-// for further assistance. The Load Balancer Pool id returned by these calls is
-// automatically generated by the RackConnect automation and will remain constant
-// unless the Load Balancer Pool is renamed on your hardware load balancer.
-// All Load Balancer Pools will currently return a status of ACTIVE. Future
-// features may introduce additional statuses.
-// Node status values are ADDING, ACTIVE, REMOVING, ADD_FAILED, and REMOVE_FAILED.
-// The cloud_servers node count will only include Cloud Servers from the specified
-// cloud account. Any dedicated servers or cloud servers from another cloud account
-// on the same RackConnect Configuration will be counted as external nodes.
-package lbpools
diff --git a/rackspace/rackconnect/v3/lbpools/requests.go b/rackspace/rackconnect/v3/lbpools/requests.go
deleted file mode 100644
index c300c56..0000000
--- a/rackspace/rackconnect/v3/lbpools/requests.go
+++ /dev/null
@@ -1,146 +0,0 @@
-package lbpools
-
-import (
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns all load balancer pools that are associated with RackConnect.
-func List(c *gophercloud.ServiceClient) pagination.Pager {
- url := listURL(c)
- createPage := func(r pagination.PageResult) pagination.Page {
- return PoolPage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(c, url, createPage)
-}
-
-// Get retrieves a specific load balancer pool (that is associated with RackConnect)
-// based on its unique ID.
-func Get(c *gophercloud.ServiceClient, id string) GetResult {
- var res GetResult
- _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
- return res
-}
-
-// ListNodes returns all load balancer pool nodes that are associated with RackConnect
-// for the given LB pool ID.
-func ListNodes(c *gophercloud.ServiceClient, id string) pagination.Pager {
- url := listNodesURL(c, id)
- createPage := func(r pagination.PageResult) pagination.Page {
- return NodePage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(c, url, createPage)
-}
-
-// CreateNode adds the cloud server with the given serverID to the load balancer
-// pool with the given poolID.
-func CreateNode(c *gophercloud.ServiceClient, poolID, serverID string) CreateNodeResult {
- var res CreateNodeResult
- reqBody := map[string]interface{}{
- "cloud_server": map[string]string{
- "id": serverID,
- },
- }
- _, res.Err = c.Post(createNodeURL(c, poolID), reqBody, &res.Body, nil)
- return res
-}
-
-// ListNodesDetails returns all load balancer pool nodes that are associated with RackConnect
-// for the given LB pool ID with all their details.
-func ListNodesDetails(c *gophercloud.ServiceClient, id string) pagination.Pager {
- url := listNodesDetailsURL(c, id)
- createPage := func(r pagination.PageResult) pagination.Page {
- return NodeDetailsPage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(c, url, createPage)
-}
-
-// GetNode retrieves a specific LB pool node (that is associated with RackConnect)
-// based on its unique ID and the LB pool's unique ID.
-func GetNode(c *gophercloud.ServiceClient, poolID, nodeID string) GetNodeResult {
- var res GetNodeResult
- _, res.Err = c.Get(nodeURL(c, poolID, nodeID), &res.Body, nil)
- return res
-}
-
-// DeleteNode removes the node with the given nodeID from the LB pool with the
-// given poolID.
-func DeleteNode(c *gophercloud.ServiceClient, poolID, nodeID string) DeleteNodeResult {
- var res DeleteNodeResult
- _, res.Err = c.Delete(deleteNodeURL(c, poolID, nodeID), nil)
- return res
-}
-
-// GetNodeDetails retrieves a specific LB pool node's details based on its unique
-// ID and the LB pool's unique ID.
-func GetNodeDetails(c *gophercloud.ServiceClient, poolID, nodeID string) GetNodeDetailsResult {
- var res GetNodeDetailsResult
- _, res.Err = c.Get(nodeDetailsURL(c, poolID, nodeID), &res.Body, nil)
- return res
-}
-
-// NodeOpts are options for bulk adding/deleting nodes to LB pools.
-type NodeOpts struct {
- ServerID string
- PoolID string
-}
-
-// NodesOpts are a slice of NodeOpts, passed as options for bulk operations.
-type NodesOpts []NodeOpts
-
-// ToLBPoolCreateNodesMap serializes a NodesOpts into a map to send in the request.
-func (o NodesOpts) ToLBPoolCreateNodesMap() ([]map[string]interface{}, error) {
- m := make([]map[string]interface{}, len(o))
- for i := range o {
- m[i] = map[string]interface{}{
- "cloud_server": map[string]string{
- "id": o[i].ServerID,
- },
- "load_balancer_pool": map[string]string{
- "id": o[i].PoolID,
- },
- }
- }
- return m, nil
-}
-
-// CreateNodes adds the cloud servers with the given serverIDs to the corresponding
-// load balancer pools with the given poolIDs.
-func CreateNodes(c *gophercloud.ServiceClient, opts NodesOpts) CreateNodesResult {
- var res CreateNodesResult
- reqBody, err := opts.ToLBPoolCreateNodesMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Post(createNodesURL(c), reqBody, &res.Body, nil)
- return res
-}
-
-// DeleteNodes removes the cloud servers with the given serverIDs to the corresponding
-// load balancer pools with the given poolIDs.
-func DeleteNodes(c *gophercloud.ServiceClient, opts NodesOpts) DeleteNodesResult {
- var res DeleteNodesResult
- reqBody, err := opts.ToLBPoolCreateNodesMap()
- if err != nil {
- res.Err = err
- return res
- }
-
- _, res.Err = c.Request("DELETE", createNodesURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{204},
- })
- return res
-}
-
-// ListNodesDetailsForServer is similar to ListNodesDetails but only returns nodes
-// for the given serverID.
-func ListNodesDetailsForServer(c *gophercloud.ServiceClient, serverID string) pagination.Pager {
- url := listNodesForServerURL(c, serverID)
- createPage := func(r pagination.PageResult) pagination.Page {
- return NodeDetailsForServerPage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(c, url, createPage)
-}
diff --git a/rackspace/rackconnect/v3/lbpools/requests_test.go b/rackspace/rackconnect/v3/lbpools/requests_test.go
deleted file mode 100644
index 48ebcec..0000000
--- a/rackspace/rackconnect/v3/lbpools/requests_test.go
+++ /dev/null
@@ -1,876 +0,0 @@
-package lbpools
-
-import (
- "fmt"
- "net/http"
- "testing"
- "time"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListPools(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- fmt.Fprintf(w, `[
- {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- "name": "RCv3Test",
- "node_counts": {
- "cloud_servers": 3,
- "external": 4,
- "total": 7
- },
- "port": 80,
- "status": "ACTIVE",
- "status_detail": null,
- "virtual_ip": "203.0.113.5"
- },
- {
- "id": "33021100-4abf-4836-9080-465a6d87ab68",
- "name": "RCv3Test2",
- "node_counts": {
- "cloud_servers": 1,
- "external": 0,
- "total": 1
- },
- "port": 80,
- "status": "ACTIVE",
- "status_detail": null,
- "virtual_ip": "203.0.113.7"
- },
- {
- "id": "b644350a-301b-47b5-a411-c6e0f933c347",
- "name": "RCv3Test3",
- "node_counts": {
- "cloud_servers": 2,
- "external": 3,
- "total": 5
- },
- "port": 443,
- "status": "ACTIVE",
- "status_detail": null,
- "virtual_ip": "203.0.113.15"
- }
- ]`)
- })
-
- expected := []Pool{
- Pool{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- Name: "RCv3Test",
- NodeCounts: struct {
- CloudServers int `mapstructure:"cloud_servers"`
- External int `mapstructure:"external"`
- Total int `mapstructure:"total"`
- }{
- CloudServers: 3,
- External: 4,
- Total: 7,
- },
- Port: 80,
- Status: "ACTIVE",
- VirtualIP: "203.0.113.5",
- },
- Pool{
- ID: "33021100-4abf-4836-9080-465a6d87ab68",
- Name: "RCv3Test2",
- NodeCounts: struct {
- CloudServers int `mapstructure:"cloud_servers"`
- External int `mapstructure:"external"`
- Total int `mapstructure:"total"`
- }{
- CloudServers: 1,
- External: 0,
- Total: 1,
- },
- Port: 80,
- Status: "ACTIVE",
- VirtualIP: "203.0.113.7",
- },
- Pool{
- ID: "b644350a-301b-47b5-a411-c6e0f933c347",
- Name: "RCv3Test3",
- NodeCounts: struct {
- CloudServers int `mapstructure:"cloud_servers"`
- External int `mapstructure:"external"`
- Total int `mapstructure:"total"`
- }{
- CloudServers: 2,
- External: 3,
- Total: 5,
- },
- Port: 443,
- Status: "ACTIVE",
- VirtualIP: "203.0.113.15",
- },
- }
-
- count := 0
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractPools(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestGetLBPool(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `{
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- "name": "RCv3Test",
- "node_counts": {
- "cloud_servers": 3,
- "external": 4,
- "total": 7
- },
- "port": 80,
- "status": "ACTIVE",
- "status_detail": null,
- "virtual_ip": "203.0.113.5"
- }`)
- })
-
- expected := &Pool{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- Name: "RCv3Test",
- NodeCounts: struct {
- CloudServers int `mapstructure:"cloud_servers"`
- External int `mapstructure:"external"`
- Total int `mapstructure:"total"`
- }{
- CloudServers: 3,
- External: 4,
- Total: 7,
- },
- Port: 80,
- Status: "ACTIVE",
- VirtualIP: "203.0.113.5",
- }
-
- actual, err := Get(fake.ServiceClient(), "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestListNodes(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2/nodes", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- fmt.Fprintf(w, `[
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "id": "1860451d-fb89-45b8-b54e-151afceb50e5",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2"
- },
- "status": "ACTIVE",
- "updated": "2014-05-30T03:24:18Z"
- },
- {
- "created": "2014-05-31T08:23:12Z",
- "cloud_server": {
- "id": "f28b870f-a063-498a-8b12-7025e5b1caa6"
- },
- "id": "b70481dd-7edf-4dbb-a44b-41cc7679d4fb",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2"
- },
- "status": "ADDING",
- "updated": "2014-05-31T08:23:26Z"
- },
- {
- "created": "2014-05-31T08:23:18Z",
- "cloud_server": {
- "id": "a3d3a6b3-e4e4-496f-9a3d-5c987163e458"
- },
- "id": "ced9ddc8-6fae-4e72-9457-16ead52b5515",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2"
- },
- "status": "ADD_FAILED",
- "status_detail": "Unable to communicate with network device",
- "updated": "2014-05-31T08:24:36Z"
- }
- ]`)
- })
-
- expected := []Node{
- Node{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- },
- ID: "1860451d-fb89-45b8-b54e-151afceb50e5",
- LoadBalancerPool: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- },
- Status: "ACTIVE",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- },
- Node{
- CreatedAt: time.Date(2014, 5, 31, 8, 23, 12, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "f28b870f-a063-498a-8b12-7025e5b1caa6",
- },
- ID: "b70481dd-7edf-4dbb-a44b-41cc7679d4fb",
- LoadBalancerPool: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- },
- Status: "ADDING",
- UpdatedAt: time.Date(2014, 5, 31, 8, 23, 26, 0, time.UTC),
- },
- Node{
- CreatedAt: time.Date(2014, 5, 31, 8, 23, 18, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "a3d3a6b3-e4e4-496f-9a3d-5c987163e458",
- },
- ID: "ced9ddc8-6fae-4e72-9457-16ead52b5515",
- LoadBalancerPool: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- },
- Status: "ADD_FAILED",
- StatusDetail: "Unable to communicate with network device",
- UpdatedAt: time.Date(2014, 5, 31, 8, 24, 36, 0, time.UTC),
- },
- }
-
- count := 0
- err := ListNodes(fake.ServiceClient(), "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2").EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNodes(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestCreateNode(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2/nodes", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
- {
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- }
- }
- `)
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
- fmt.Fprintf(w, `
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "id": "1860451d-fb89-45b8-b54e-151afceb50e5",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2"
- },
- "status": "ACTIVE",
- "status_detail": null,
- "updated": "2014-05-30T03:24:18Z"
- }
- `)
- })
-
- expected := &Node{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- },
- ID: "1860451d-fb89-45b8-b54e-151afceb50e5",
- LoadBalancerPool: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- },
- Status: "ACTIVE",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- }
-
- actual, err := CreateNode(fake.ServiceClient(), "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2", "d95ae0c4-6ab8-4873-b82f-f8433840cff2").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestListNodesDetails(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2/nodes/details", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- fmt.Fprintf(w, `
- [
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "cloud_network": {
- "cidr": "192.168.100.0/24",
- "created": "2014-05-25T01:23:42Z",
- "id": "07426958-1ebf-4c38-b032-d456820ca21a",
- "name": "RC-CLOUD",
- "private_ip_v4": "192.168.100.5",
- "updated": "2014-05-25T02:28:44Z"
- },
- "created": "2014-05-30T02:18:42Z",
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- "name": "RCv3TestServer1",
- "updated": "2014-05-30T02:19:18Z"
- },
- "id": "1860451d-fb89-45b8-b54e-151afceb50e5",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- "name": "RCv3Test",
- "node_counts": {
- "cloud_servers": 3,
- "external": 4,
- "total": 7
- },
- "port": 80,
- "status": "ACTIVE",
- "status_detail": null,
- "virtual_ip": "203.0.113.5"
- },
- "status": "ACTIVE",
- "status_detail": null,
- "updated": "2014-05-30T03:24:18Z"
- }
- ]
- `)
- })
-
- expected := []NodeDetails{
- NodeDetails{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- CloudNetwork struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_network"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- CloudNetwork: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "07426958-1ebf-4c38-b032-d456820ca21a",
- CIDR: "192.168.100.0/24",
- CreatedAt: time.Date(2014, 5, 25, 1, 23, 42, 0, time.UTC),
- Name: "RC-CLOUD",
- PrivateIPv4: "192.168.100.5",
- UpdatedAt: time.Date(2014, 5, 25, 2, 28, 44, 0, time.UTC),
- },
- CreatedAt: time.Date(2014, 5, 30, 2, 18, 42, 0, time.UTC),
- Name: "RCv3TestServer1",
- UpdatedAt: time.Date(2014, 5, 30, 2, 19, 18, 0, time.UTC),
- },
- ID: "1860451d-fb89-45b8-b54e-151afceb50e5",
- LoadBalancerPool: Pool{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- Name: "RCv3Test",
- NodeCounts: struct {
- CloudServers int `mapstructure:"cloud_servers"`
- External int `mapstructure:"external"`
- Total int `mapstructure:"total"`
- }{
- CloudServers: 3,
- External: 4,
- Total: 7,
- },
- Port: 80,
- Status: "ACTIVE",
- VirtualIP: "203.0.113.5",
- },
- Status: "ACTIVE",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- },
- }
- count := 0
- err := ListNodesDetails(fake.ServiceClient(), "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2").EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNodesDetails(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestGetNode(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2/nodes/1860451d-fb89-45b8-b54e-151afceb50e5", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "id": "1860451d-fb89-45b8-b54e-151afceb50e5",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2"
- },
- "status": "ACTIVE",
- "status_detail": null,
- "updated": "2014-05-30T03:24:18Z"
- }
- `)
- })
-
- expected := &Node{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- },
- ID: "1860451d-fb89-45b8-b54e-151afceb50e5",
- LoadBalancerPool: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- },
- Status: "ACTIVE",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- }
-
- actual, err := GetNode(fake.ServiceClient(), "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2", "1860451d-fb89-45b8-b54e-151afceb50e5").Extract()
- th.AssertNoErr(t, err)
-
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestDeleteNode(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2/nodes/1860451d-fb89-45b8-b54e-151afceb50e5", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusNoContent)
- })
-
- err := DeleteNode(client.ServiceClient(), "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2", "1860451d-fb89-45b8-b54e-151afceb50e5").ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestGetNodeDetails(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2/nodes/d95ae0c4-6ab8-4873-b82f-f8433840cff2/details", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- fmt.Fprintf(w, `
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "cloud_network": {
- "cidr": "192.168.100.0/24",
- "created": "2014-05-25T01:23:42Z",
- "id": "07426958-1ebf-4c38-b032-d456820ca21a",
- "name": "RC-CLOUD",
- "private_ip_v4": "192.168.100.5",
- "updated": "2014-05-25T02:28:44Z"
- },
- "created": "2014-05-30T02:18:42Z",
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- "name": "RCv3TestServer1",
- "updated": "2014-05-30T02:19:18Z"
- },
- "id": "1860451d-fb89-45b8-b54e-151afceb50e5",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- "name": "RCv3Test",
- "node_counts": {
- "cloud_servers": 3,
- "external": 4,
- "total": 7
- },
- "port": 80,
- "status": "ACTIVE",
- "status_detail": null,
- "virtual_ip": "203.0.113.5"
- },
- "status": "ACTIVE",
- "status_detail": null,
- "updated": "2014-05-30T03:24:18Z"
- }
- `)
- })
-
- expected := &NodeDetails{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- CloudNetwork struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_network"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- CloudNetwork: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "07426958-1ebf-4c38-b032-d456820ca21a",
- CIDR: "192.168.100.0/24",
- CreatedAt: time.Date(2014, 5, 25, 1, 23, 42, 0, time.UTC),
- Name: "RC-CLOUD",
- PrivateIPv4: "192.168.100.5",
- UpdatedAt: time.Date(2014, 5, 25, 2, 28, 44, 0, time.UTC),
- },
- CreatedAt: time.Date(2014, 5, 30, 2, 18, 42, 0, time.UTC),
- Name: "RCv3TestServer1",
- UpdatedAt: time.Date(2014, 5, 30, 2, 19, 18, 0, time.UTC),
- },
- ID: "1860451d-fb89-45b8-b54e-151afceb50e5",
- LoadBalancerPool: Pool{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- Name: "RCv3Test",
- NodeCounts: struct {
- CloudServers int `mapstructure:"cloud_servers"`
- External int `mapstructure:"external"`
- Total int `mapstructure:"total"`
- }{
- CloudServers: 3,
- External: 4,
- Total: 7,
- },
- Port: 80,
- Status: "ACTIVE",
- VirtualIP: "203.0.113.5",
- },
- Status: "ACTIVE",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- }
-
- actual, err := GetNodeDetails(fake.ServiceClient(), "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2", "d95ae0c4-6ab8-4873-b82f-f8433840cff2").Extract()
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, expected, actual)
-}
-
-func TestCreateNodes(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/nodes", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
- [
- {
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2"
- }
- },
- {
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "load_balancer_pool": {
- "id": "33021100-4abf-4836-9080-465a6d87ab68"
- }
- }
- ]
- `)
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
- fmt.Fprintf(w, `
- [
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "id": "1860451d-fb89-45b8-b54e-151afceb50e5",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2"
- },
- "status": "ADDING",
- "status_detail": null,
- "updated": null
- },
- {
- "created": "2014-05-31T08:23:12Z",
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "id": "b70481dd-7edf-4dbb-a44b-41cc7679d4fb",
- "load_balancer_pool": {
- "id": "33021100-4abf-4836-9080-465a6d87ab68"
- },
- "status": "ADDING",
- "status_detail": null,
- "updated": null
- }
- ]
- `)
- })
-
- expected := []Node{
- Node{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- },
- ID: "1860451d-fb89-45b8-b54e-151afceb50e5",
- LoadBalancerPool: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- },
- Status: "ADDING",
- },
- Node{
- CreatedAt: time.Date(2014, 5, 31, 8, 23, 12, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- },
- ID: "b70481dd-7edf-4dbb-a44b-41cc7679d4fb",
- LoadBalancerPool: struct {
- ID string `mapstructure:"id"`
- }{
- ID: "33021100-4abf-4836-9080-465a6d87ab68",
- },
- Status: "ADDING",
- },
- }
-
- opts := NodesOpts{
- NodeOpts{
- ServerID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- PoolID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- },
- NodeOpts{
- ServerID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- PoolID: "33021100-4abf-4836-9080-465a6d87ab68",
- },
- }
- actual, err := CreateNodes(fake.ServiceClient(), opts).Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestDeleteNodes(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/nodes", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
- [
- {
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2"
- }
- },
- {
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- },
- "load_balancer_pool": {
- "id": "33021100-4abf-4836-9080-465a6d87ab68"
- }
- }
- ]
- `)
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusNoContent)
- })
-
- opts := NodesOpts{
- NodeOpts{
- ServerID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- PoolID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- },
- NodeOpts{
- ServerID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- PoolID: "33021100-4abf-4836-9080-465a6d87ab68",
- },
- }
- err := DeleteNodes(client.ServiceClient(), opts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestListNodesForServerDetails(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/load_balancer_pools/nodes/details", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- fmt.Fprintf(w, `
- [
- {
- "created": "2014-05-30T03:23:42Z",
- "id": "1860451d-fb89-45b8-b54e-151afceb50e5",
- "load_balancer_pool": {
- "id": "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- "name": "RCv3Test",
- "node_counts": {
- "cloud_servers": 3,
- "external": 4,
- "total": 7
- },
- "port": 80,
- "status": "ACTIVE",
- "status_detail": null,
- "virtual_ip": "203.0.113.5"
- },
- "status": "ACTIVE",
- "status_detail": null,
- "updated": "2014-05-30T03:24:18Z"
- }
- ]
- `)
- })
-
- expected := []NodeDetailsForServer{
- NodeDetailsForServer{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- ID: "1860451d-fb89-45b8-b54e-151afceb50e5",
- LoadBalancerPool: Pool{
- ID: "d6d3aa7c-dfa5-4e61-96ee-1d54ac1075d2",
- Name: "RCv3Test",
- NodeCounts: struct {
- CloudServers int `mapstructure:"cloud_servers"`
- External int `mapstructure:"external"`
- Total int `mapstructure:"total"`
- }{
- CloudServers: 3,
- External: 4,
- Total: 7,
- },
- Port: 80,
- Status: "ACTIVE",
- VirtualIP: "203.0.113.5",
- },
- Status: "ACTIVE",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- },
- }
- count := 0
- err := ListNodesDetailsForServer(fake.ServiceClient(), "07426958-1ebf-4c38-b032-d456820ca21a").EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractNodesDetailsForServer(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
diff --git a/rackspace/rackconnect/v3/lbpools/results.go b/rackspace/rackconnect/v3/lbpools/results.go
deleted file mode 100644
index e5e914b..0000000
--- a/rackspace/rackconnect/v3/lbpools/results.go
+++ /dev/null
@@ -1,505 +0,0 @@
-package lbpools
-
-import (
- "fmt"
- "reflect"
- "time"
-
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// Pool represents a load balancer pool associated with a RackConnect configuration.
-type Pool struct {
- // The unique ID of the load balancer pool.
- ID string `mapstructure:"id"`
- // The name of the load balancer pool.
- Name string `mapstructure:"name"`
- // The node counts associated witht the load balancer pool.
- NodeCounts struct {
- // The number of nodes associated with this LB pool for this account.
- CloudServers int `mapstructure:"cloud_servers"`
- // The number of nodes associated with this LB pool from other accounts.
- External int `mapstructure:"external"`
- // The total number of nodes associated with this LB pool.
- Total int `mapstructure:"total"`
- } `mapstructure:"node_counts"`
- // The port of the LB pool
- Port int `mapstructure:"port"`
- // The status of the LB pool
- Status string `mapstructure:"status"`
- // The details of the status of the LB pool
- StatusDetail string `mapstructure:"status_detail"`
- // The virtual IP of the LB pool
- VirtualIP string `mapstructure:"virtual_ip"`
-}
-
-// PoolPage is the page returned by a pager when traversing over a
-// collection of Pools.
-type PoolPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty returns true if a PoolPage contains no Pools.
-func (r PoolPage) IsEmpty() (bool, error) {
- cns, err := ExtractPools(r)
- if err != nil {
- return true, err
- }
- return len(cns) == 0, nil
-}
-
-// ExtractPools extracts and returns Pools. It is used while iterating over
-// an lbpools.List call.
-func ExtractPools(page pagination.Page) ([]Pool, error) {
- var res []Pool
- err := mapstructure.Decode(page.(PoolPage).Body, &res)
- return res, err
-}
-
-// GetResult represents the result of a Get operation.
-type GetResult struct {
- gophercloud.Result
-}
-
-// Extract is a function that extracts an LBPool from a GetResult.
-func (r GetResult) Extract() (*Pool, error) {
- if r.Err != nil {
- return nil, r.Err
- }
- var res Pool
- err := mapstructure.Decode(r.Body, &res)
- return &res, err
-}
-
-// Node represents a load balancer pool node associated with a RackConnect configuration.
-type Node struct {
- // The unique ID of the LB node.
- ID string `mapstructure:"id"`
- // The cloud server (node) of the load balancer pool.
- CloudServer struct {
- // The cloud server ID.
- ID string `mapstructure:"id"`
- } `mapstructure:"cloud_server"`
- // The load balancer pool.
- LoadBalancerPool struct {
- // The LB pool ID.
- ID string `mapstructure:"id"`
- } `mapstructure:"load_balancer_pool"`
- // The status of the LB pool.
- Status string `mapstructure:"status"`
- // The details of the status of the LB pool.
- StatusDetail string `mapstructure:"status_detail"`
- // The time the LB node was created.
- CreatedAt time.Time `mapstructure:"-"`
- // The time the LB node was last updated.
- UpdatedAt time.Time `mapstructure:"-"`
-}
-
-// NodePage is the page returned by a pager when traversing over a
-// collection of Nodes.
-type NodePage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty returns true if a NodePage contains no Nodes.
-func (r NodePage) IsEmpty() (bool, error) {
- n, err := ExtractNodes(r)
- if err != nil {
- return true, err
- }
- return len(n) == 0, nil
-}
-
-// ExtractNodes extracts and returns a slice of Nodes. It is used while iterating over
-// an lbpools.ListNodes call.
-func ExtractNodes(page pagination.Page) ([]Node, error) {
- var res []Node
- casted := page.(NodePage).Body
- err := mapstructure.Decode(casted, &res)
-
- var rawNodes []interface{}
- switch casted.(type) {
- case interface{}:
- rawNodes = casted.([]interface{})
- default:
- return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
- }
-
- for i := range rawNodes {
- thisNode := (rawNodes[i]).(map[string]interface{})
-
- if t, ok := thisNode["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CreatedAt = creationTime
- }
-
- if t, ok := thisNode["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].UpdatedAt = updatedTime
- }
- }
-
- return res, err
-}
-
-// NodeResult represents a result that can be extracted as a Node.
-type NodeResult struct {
- gophercloud.Result
-}
-
-// CreateNodeResult represents the result of an CreateNode operation.
-type CreateNodeResult struct {
- NodeResult
-}
-
-// GetNodeResult represents the result of an GetNode operation.
-type GetNodeResult struct {
- NodeResult
-}
-
-// Extract is a function that extracts a Node from a NodeResult.
-func (r NodeResult) Extract() (*Node, error) {
- if r.Err != nil {
- return nil, r.Err
- }
- var res Node
- err := mapstructure.Decode(r.Body, &res)
-
- b := r.Body.(map[string]interface{})
-
- if date, ok := b["created"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res.CreatedAt = t
- }
-
- if date, ok := b["updated"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res.UpdatedAt = t
- }
-
- return &res, err
-}
-
-// NodeDetails represents a load balancer pool node associated with a RackConnect configuration
-// with all its details.
-type NodeDetails struct {
- // The unique ID of the LB node.
- ID string `mapstructure:"id"`
- // The cloud server (node) of the load balancer pool.
- CloudServer struct {
- // The cloud server ID.
- ID string `mapstructure:"id"`
- // The name of the server.
- Name string `mapstructure:"name"`
- // The cloud network for the cloud server.
- CloudNetwork struct {
- // The network ID.
- ID string `mapstructure:"id"`
- // The network name.
- Name string `mapstructure:"name"`
- // The network's private IPv4 address.
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- // The IP range for the network.
- CIDR string `mapstructure:"cidr"`
- // The datetime the network was created.
- CreatedAt time.Time `mapstructure:"-"`
- // The last datetime the network was updated.
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_network"`
- // The datetime the server was created.
- CreatedAt time.Time `mapstructure:"-"`
- // The datetime the server was last updated.
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_server"`
- // The load balancer pool.
- LoadBalancerPool Pool `mapstructure:"load_balancer_pool"`
- // The status of the LB pool.
- Status string `mapstructure:"status"`
- // The details of the status of the LB pool.
- StatusDetail string `mapstructure:"status_detail"`
- // The time the LB node was created.
- CreatedAt time.Time `mapstructure:"-"`
- // The time the LB node was last updated.
- UpdatedAt time.Time `mapstructure:"-"`
-}
-
-// NodeDetailsPage is the page returned by a pager when traversing over a
-// collection of NodeDetails.
-type NodeDetailsPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty returns true if a NodeDetailsPage contains no NodeDetails.
-func (r NodeDetailsPage) IsEmpty() (bool, error) {
- n, err := ExtractNodesDetails(r)
- if err != nil {
- return true, err
- }
- return len(n) == 0, nil
-}
-
-// ExtractNodesDetails extracts and returns a slice of NodeDetails. It is used while iterating over
-// an lbpools.ListNodesDetails call.
-func ExtractNodesDetails(page pagination.Page) ([]NodeDetails, error) {
- var res []NodeDetails
- casted := page.(NodeDetailsPage).Body
- err := mapstructure.Decode(casted, &res)
-
- var rawNodesDetails []interface{}
- switch casted.(type) {
- case interface{}:
- rawNodesDetails = casted.([]interface{})
- default:
- return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
- }
-
- for i := range rawNodesDetails {
- thisNodeDetails := (rawNodesDetails[i]).(map[string]interface{})
-
- if t, ok := thisNodeDetails["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CreatedAt = creationTime
- }
-
- if t, ok := thisNodeDetails["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].UpdatedAt = updatedTime
- }
-
- if cs, ok := thisNodeDetails["cloud_server"].(map[string]interface{}); ok {
- if t, ok := cs["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CloudServer.CreatedAt = creationTime
- }
- if t, ok := cs["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CloudServer.UpdatedAt = updatedTime
- }
- if cn, ok := cs["cloud_network"].(map[string]interface{}); ok {
- if t, ok := cn["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CloudServer.CloudNetwork.CreatedAt = creationTime
- }
- if t, ok := cn["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CloudServer.CloudNetwork.UpdatedAt = updatedTime
- }
- }
- }
- }
-
- return res, err
-}
-
-// GetNodeDetailsResult represents the result of an NodeDetails operation.
-type GetNodeDetailsResult struct {
- gophercloud.Result
-}
-
-// Extract is a function that extracts a NodeDetails from a NodeDetailsResult.
-func (r GetNodeDetailsResult) Extract() (*NodeDetails, error) {
- if r.Err != nil {
- return nil, r.Err
- }
- var res NodeDetails
- err := mapstructure.Decode(r.Body, &res)
-
- b := r.Body.(map[string]interface{})
-
- if date, ok := b["created"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res.CreatedAt = t
- }
-
- if date, ok := b["updated"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res.UpdatedAt = t
- }
-
- if cs, ok := b["cloud_server"].(map[string]interface{}); ok {
- if t, ok := cs["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &res, err
- }
- res.CloudServer.CreatedAt = creationTime
- }
- if t, ok := cs["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &res, err
- }
- res.CloudServer.UpdatedAt = updatedTime
- }
- if cn, ok := cs["cloud_network"].(map[string]interface{}); ok {
- if t, ok := cn["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &res, err
- }
- res.CloudServer.CloudNetwork.CreatedAt = creationTime
- }
- if t, ok := cn["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &res, err
- }
- res.CloudServer.CloudNetwork.UpdatedAt = updatedTime
- }
- }
- }
-
- return &res, err
-}
-
-// DeleteNodeResult represents the result of a DeleteNode operation.
-type DeleteNodeResult struct {
- gophercloud.ErrResult
-}
-
-// CreateNodesResult represents the result of a CreateNodes operation.
-type CreateNodesResult struct {
- gophercloud.Result
-}
-
-// Extract is a function that extracts a slice of Nodes from a CreateNodesResult.
-func (r CreateNodesResult) Extract() ([]Node, error) {
- if r.Err != nil {
- return nil, r.Err
- }
- var res []Node
- err := mapstructure.Decode(r.Body, &res)
-
- b := r.Body.([]interface{})
- for i := range b {
- if date, ok := b[i].(map[string]interface{})["created"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res[i].CreatedAt = t
- }
- if date, ok := b[i].(map[string]interface{})["updated"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res[i].UpdatedAt = t
- }
- }
-
- return res, err
-}
-
-// DeleteNodesResult represents the result of a DeleteNodes operation.
-type DeleteNodesResult struct {
- gophercloud.ErrResult
-}
-
-// NodeDetailsForServer represents a load balancer pool node associated with a RackConnect configuration
-// with all its details for a particular server.
-type NodeDetailsForServer struct {
- // The unique ID of the LB node.
- ID string `mapstructure:"id"`
- // The load balancer pool.
- LoadBalancerPool Pool `mapstructure:"load_balancer_pool"`
- // The status of the LB pool.
- Status string `mapstructure:"status"`
- // The details of the status of the LB pool.
- StatusDetail string `mapstructure:"status_detail"`
- // The time the LB node was created.
- CreatedAt time.Time `mapstructure:"-"`
- // The time the LB node was last updated.
- UpdatedAt time.Time `mapstructure:"-"`
-}
-
-// NodeDetailsForServerPage is the page returned by a pager when traversing over a
-// collection of NodeDetailsForServer.
-type NodeDetailsForServerPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty returns true if a NodeDetailsForServerPage contains no NodeDetailsForServer.
-func (r NodeDetailsForServerPage) IsEmpty() (bool, error) {
- n, err := ExtractNodesDetailsForServer(r)
- if err != nil {
- return true, err
- }
- return len(n) == 0, nil
-}
-
-// ExtractNodesDetailsForServer extracts and returns a slice of NodeDetailsForServer. It is used while iterating over
-// an lbpools.ListNodesDetailsForServer call.
-func ExtractNodesDetailsForServer(page pagination.Page) ([]NodeDetailsForServer, error) {
- var res []NodeDetailsForServer
- casted := page.(NodeDetailsForServerPage).Body
- err := mapstructure.Decode(casted, &res)
-
- var rawNodesDetails []interface{}
- switch casted.(type) {
- case interface{}:
- rawNodesDetails = casted.([]interface{})
- default:
- return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
- }
-
- for i := range rawNodesDetails {
- thisNodeDetails := (rawNodesDetails[i]).(map[string]interface{})
-
- if t, ok := thisNodeDetails["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CreatedAt = creationTime
- }
-
- if t, ok := thisNodeDetails["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].UpdatedAt = updatedTime
- }
- }
-
- return res, err
-}
diff --git a/rackspace/rackconnect/v3/lbpools/urls.go b/rackspace/rackconnect/v3/lbpools/urls.go
deleted file mode 100644
index c238239..0000000
--- a/rackspace/rackconnect/v3/lbpools/urls.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package lbpools
-
-import "github.com/rackspace/gophercloud"
-
-var root = "load_balancer_pools"
-
-func listURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL(root)
-}
-
-func getURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL(root, id)
-}
-
-func listNodesURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL(root, id, "nodes")
-}
-
-func createNodeURL(c *gophercloud.ServiceClient, id string) string {
- return listNodesURL(c, id)
-}
-
-func listNodesDetailsURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL(root, id, "nodes", "details")
-}
-
-func nodeURL(c *gophercloud.ServiceClient, poolID, nodeID string) string {
- return c.ServiceURL(root, poolID, "nodes", nodeID)
-}
-
-func deleteNodeURL(c *gophercloud.ServiceClient, poolID, nodeID string) string {
- return nodeURL(c, poolID, nodeID)
-}
-
-func nodeDetailsURL(c *gophercloud.ServiceClient, poolID, nodeID string) string {
- return c.ServiceURL(root, poolID, "nodes", nodeID, "details")
-}
-
-func createNodesURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL(root, "nodes")
-}
-
-func deleteNodesURL(c *gophercloud.ServiceClient) string {
- return createNodesURL(c)
-}
-
-func listNodesForServerURL(c *gophercloud.ServiceClient, serverID string) string {
- return c.ServiceURL(root, "nodes", "details?cloud_server_id="+serverID)
-}
diff --git a/rackspace/rackconnect/v3/publicips/requests.go b/rackspace/rackconnect/v3/publicips/requests.go
deleted file mode 100644
index 1164260..0000000
--- a/rackspace/rackconnect/v3/publicips/requests.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package publicips
-
-import (
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// List returns all public IPs.
-func List(c *gophercloud.ServiceClient) pagination.Pager {
- url := listURL(c)
- createPage := func(r pagination.PageResult) pagination.Page {
- return PublicIPPage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(c, url, createPage)
-}
-
-// Create adds a public IP to the server with the given serverID.
-func Create(c *gophercloud.ServiceClient, serverID string) CreateResult {
- var res CreateResult
- reqBody := map[string]interface{}{
- "cloud_server": map[string]string{
- "id": serverID,
- },
- }
- _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil)
- return res
-}
-
-// ListForServer returns all public IPs for the server with the given serverID.
-func ListForServer(c *gophercloud.ServiceClient, serverID string) pagination.Pager {
- url := listForServerURL(c, serverID)
- createPage := func(r pagination.PageResult) pagination.Page {
- return PublicIPPage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(c, url, createPage)
-}
-
-// Get retrieves the public IP with the given id.
-func Get(c *gophercloud.ServiceClient, id string) GetResult {
- var res GetResult
- _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
- return res
-}
-
-// Delete removes the public IP with the given id.
-func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
- var res DeleteResult
- _, res.Err = c.Delete(deleteURL(c, id), nil)
- return res
-}
diff --git a/rackspace/rackconnect/v3/publicips/requests_test.go b/rackspace/rackconnect/v3/publicips/requests_test.go
deleted file mode 100644
index 61da2b0..0000000
--- a/rackspace/rackconnect/v3/publicips/requests_test.go
+++ /dev/null
@@ -1,378 +0,0 @@
-package publicips
-
-import (
- "fmt"
- "net/http"
- "testing"
- "time"
-
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
- "github.com/rackspace/gophercloud/testhelper/client"
- fake "github.com/rackspace/gophercloud/testhelper/client"
-)
-
-func TestListIPs(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/public_ips", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- fmt.Fprintf(w, `[
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "cloud_network": {
- "cidr": "192.168.100.0/24",
- "created": "2014-05-25T01:23:42Z",
- "id": "07426958-1ebf-4c38-b032-d456820ca21a",
- "name": "RC-CLOUD",
- "private_ip_v4": "192.168.100.5",
- "updated": "2014-05-25T02:28:44Z"
- },
- "created": "2014-05-30T02:18:42Z",
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- "name": "RCv3TestServer1",
- "updated": "2014-05-30T02:19:18Z"
- },
- "id": "2d0f586b-37a7-4ae0-adac-2743d5feb450",
- "public_ip_v4": "203.0.113.110",
- "status": "ACTIVE",
- "status_detail": null,
- "updated": "2014-05-30T03:24:18Z"
- }
- ]`)
- })
-
- expected := []PublicIP{
- PublicIP{
- ID: "2d0f586b-37a7-4ae0-adac-2743d5feb450",
- PublicIPv4: "203.0.113.110",
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- CloudNetwork struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_network"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- CloudNetwork: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "07426958-1ebf-4c38-b032-d456820ca21a",
- CIDR: "192.168.100.0/24",
- CreatedAt: time.Date(2014, 5, 25, 1, 23, 42, 0, time.UTC),
- Name: "RC-CLOUD",
- PrivateIPv4: "192.168.100.5",
- UpdatedAt: time.Date(2014, 5, 25, 2, 28, 44, 0, time.UTC),
- },
- CreatedAt: time.Date(2014, 5, 30, 2, 18, 42, 0, time.UTC),
- Name: "RCv3TestServer1",
- UpdatedAt: time.Date(2014, 5, 30, 2, 19, 18, 0, time.UTC),
- },
- Status: "ACTIVE",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- },
- }
-
- count := 0
- err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractPublicIPs(page)
- th.AssertNoErr(t, err)
-
- th.CheckDeepEquals(t, expected, actual)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
-
-func TestCreateIP(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/public_ips", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
- th.TestJSONRequest(t, r, `
- {
- "cloud_server": {
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2"
- }
- }
- `)
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
- fmt.Fprintf(w, `
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "cloud_network": {
- "cidr": "192.168.100.0/24",
- "created": "2014-05-25T01:23:42Z",
- "id": "07426958-1ebf-4c38-b032-d456820ca21a",
- "name": "RC-CLOUD",
- "private_ip_v4": "192.168.100.5",
- "updated": "2014-05-25T02:28:44Z"
- },
- "created": "2014-05-30T02:18:42Z",
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- "name": "RCv3TestServer1",
- "updated": "2014-05-30T02:19:18Z"
- },
- "id": "2d0f586b-37a7-4ae0-adac-2743d5feb450",
- "status": "ADDING"
- }`)
- })
-
- expected := &PublicIP{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- CloudNetwork struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_network"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- CloudNetwork: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "07426958-1ebf-4c38-b032-d456820ca21a",
- CIDR: "192.168.100.0/24",
- CreatedAt: time.Date(2014, 5, 25, 1, 23, 42, 0, time.UTC),
- Name: "RC-CLOUD",
- PrivateIPv4: "192.168.100.5",
- UpdatedAt: time.Date(2014, 5, 25, 2, 28, 44, 0, time.UTC),
- },
- CreatedAt: time.Date(2014, 5, 30, 2, 18, 42, 0, time.UTC),
- Name: "RCv3TestServer1",
- UpdatedAt: time.Date(2014, 5, 30, 2, 19, 18, 0, time.UTC),
- },
- ID: "2d0f586b-37a7-4ae0-adac-2743d5feb450",
- Status: "ADDING",
- }
-
- actual, err := Create(fake.ServiceClient(), "d95ae0c4-6ab8-4873-b82f-f8433840cff2").Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestGetIP(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/public_ips/2d0f586b-37a7-4ae0-adac-2743d5feb450", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
- fmt.Fprintf(w, `
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "cloud_network": {
- "cidr": "192.168.100.0/24",
- "created": "2014-05-25T01:23:42Z",
- "id": "07426958-1ebf-4c38-b032-d456820ca21a",
- "name": "RC-CLOUD",
- "private_ip_v4": "192.168.100.5",
- "updated": "2014-05-25T02:28:44Z"
- },
- "created": "2014-05-30T02:18:42Z",
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- "name": "RCv3TestServer1",
- "updated": "2014-05-30T02:19:18Z"
- },
- "id": "2d0f586b-37a7-4ae0-adac-2743d5feb450",
- "public_ip_v4": "203.0.113.110",
- "status": "ACTIVE",
- "status_detail": null,
- "updated": "2014-05-30T03:24:18Z"
- }`)
- })
-
- expected := &PublicIP{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- CloudNetwork struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_network"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- CloudNetwork: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "07426958-1ebf-4c38-b032-d456820ca21a",
- CIDR: "192.168.100.0/24",
- CreatedAt: time.Date(2014, 5, 25, 1, 23, 42, 0, time.UTC),
- Name: "RC-CLOUD",
- PrivateIPv4: "192.168.100.5",
- UpdatedAt: time.Date(2014, 5, 25, 2, 28, 44, 0, time.UTC),
- },
- CreatedAt: time.Date(2014, 5, 30, 2, 18, 42, 0, time.UTC),
- Name: "RCv3TestServer1",
- UpdatedAt: time.Date(2014, 5, 30, 2, 19, 18, 0, time.UTC),
- },
- ID: "2d0f586b-37a7-4ae0-adac-2743d5feb450",
- Status: "ACTIVE",
- PublicIPv4: "203.0.113.110",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- }
-
- actual, err := Get(fake.ServiceClient(), "2d0f586b-37a7-4ae0-adac-2743d5feb450").Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestDeleteIP(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/public_ips/2d0f586b-37a7-4ae0-adac-2743d5feb450", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusNoContent)
- })
-
- err := Delete(client.ServiceClient(), "2d0f586b-37a7-4ae0-adac-2743d5feb450").ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestListForServer(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- th.Mux.HandleFunc("/public_ips", func(w http.ResponseWriter, r *http.Request) {
- th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
- th.TestHeader(t, r, "Accept", "application/json")
-
- w.Header().Set("Content-Type", "application/json")
- fmt.Fprintf(w, `
- [
- {
- "created": "2014-05-30T03:23:42Z",
- "cloud_server": {
- "cloud_network": {
- "cidr": "192.168.100.0/24",
- "created": "2014-05-25T01:23:42Z",
- "id": "07426958-1ebf-4c38-b032-d456820ca21a",
- "name": "RC-CLOUD",
- "private_ip_v4": "192.168.100.5",
- "updated": "2014-05-25T02:28:44Z"
- },
- "created": "2014-05-30T02:18:42Z",
- "id": "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- "name": "RCv3TestServer1",
- "updated": "2014-05-30T02:19:18Z"
- },
- "id": "2d0f586b-37a7-4ae0-adac-2743d5feb450",
- "public_ip_v4": "203.0.113.110",
- "status": "ACTIVE",
- "updated": "2014-05-30T03:24:18Z"
- }
- ]`)
- })
-
- expected := []PublicIP{
- PublicIP{
- CreatedAt: time.Date(2014, 5, 30, 3, 23, 42, 0, time.UTC),
- CloudServer: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- CloudNetwork struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_network"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "d95ae0c4-6ab8-4873-b82f-f8433840cff2",
- CloudNetwork: struct {
- ID string `mapstructure:"id"`
- Name string `mapstructure:"name"`
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- CIDR string `mapstructure:"cidr"`
- CreatedAt time.Time `mapstructure:"-"`
- UpdatedAt time.Time `mapstructure:"-"`
- }{
- ID: "07426958-1ebf-4c38-b032-d456820ca21a",
- CIDR: "192.168.100.0/24",
- CreatedAt: time.Date(2014, 5, 25, 1, 23, 42, 0, time.UTC),
- Name: "RC-CLOUD",
- PrivateIPv4: "192.168.100.5",
- UpdatedAt: time.Date(2014, 5, 25, 2, 28, 44, 0, time.UTC),
- },
- CreatedAt: time.Date(2014, 5, 30, 2, 18, 42, 0, time.UTC),
- Name: "RCv3TestServer1",
- UpdatedAt: time.Date(2014, 5, 30, 2, 19, 18, 0, time.UTC),
- },
- ID: "2d0f586b-37a7-4ae0-adac-2743d5feb450",
- Status: "ACTIVE",
- PublicIPv4: "203.0.113.110",
- UpdatedAt: time.Date(2014, 5, 30, 3, 24, 18, 0, time.UTC),
- },
- }
- count := 0
- err := ListForServer(fake.ServiceClient(), "d95ae0c4-6ab8-4873-b82f-f8433840cff2").EachPage(func(page pagination.Page) (bool, error) {
- count++
- actual, err := ExtractPublicIPs(page)
- th.AssertNoErr(t, err)
- th.CheckDeepEquals(t, expected, actual)
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, count, 1)
-}
diff --git a/rackspace/rackconnect/v3/publicips/results.go b/rackspace/rackconnect/v3/publicips/results.go
deleted file mode 100644
index 132cf77..0000000
--- a/rackspace/rackconnect/v3/publicips/results.go
+++ /dev/null
@@ -1,221 +0,0 @@
-package publicips
-
-import (
- "fmt"
- "reflect"
- "time"
-
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
-)
-
-// PublicIP represents a public IP address.
-type PublicIP struct {
- // The unique ID of the public IP.
- ID string `mapstructure:"id"`
- // The IPv4 address of the public IP.
- PublicIPv4 string `mapstructure:"public_ip_v4"`
- // The cloud server (node) of the public IP.
- CloudServer struct {
- // The cloud server ID.
- ID string `mapstructure:"id"`
- // The name of the server.
- Name string `mapstructure:"name"`
- // The cloud network for the cloud server.
- CloudNetwork struct {
- // The network ID.
- ID string `mapstructure:"id"`
- // The network name.
- Name string `mapstructure:"name"`
- // The network's private IPv4 address.
- PrivateIPv4 string `mapstructure:"private_ip_v4"`
- // The IP range for the network.
- CIDR string `mapstructure:"cidr"`
- // The datetime the network was created.
- CreatedAt time.Time `mapstructure:"-"`
- // The last datetime the network was updated.
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_network"`
- // The datetime the server was created.
- CreatedAt time.Time `mapstructure:"-"`
- // The datetime the server was last updated.
- UpdatedAt time.Time `mapstructure:"-"`
- } `mapstructure:"cloud_server"`
- // The status of the public IP.
- Status string `mapstructure:"status"`
- // The details of the status of the public IP.
- StatusDetail string `mapstructure:"status_detail"`
- // The time the public IP was created.
- CreatedAt time.Time `mapstructure:"-"`
- // The time the public IP was last updated.
- UpdatedAt time.Time `mapstructure:"-"`
-}
-
-// PublicIPPage is the page returned by a pager when traversing over a
-// collection of PublicIPs.
-type PublicIPPage struct {
- pagination.SinglePageBase
-}
-
-// IsEmpty returns true if a PublicIPPage contains no PublicIPs.
-func (r PublicIPPage) IsEmpty() (bool, error) {
- n, err := ExtractPublicIPs(r)
- if err != nil {
- return true, err
- }
- return len(n) == 0, nil
-}
-
-// ExtractPublicIPs extracts and returns a slice of PublicIPs. It is used while iterating over
-// a publicips.List call.
-func ExtractPublicIPs(page pagination.Page) ([]PublicIP, error) {
- var res []PublicIP
- casted := page.(PublicIPPage).Body
- err := mapstructure.Decode(casted, &res)
-
- var rawNodesDetails []interface{}
- switch casted.(type) {
- case interface{}:
- rawNodesDetails = casted.([]interface{})
- default:
- return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
- }
-
- for i := range rawNodesDetails {
- thisNodeDetails := (rawNodesDetails[i]).(map[string]interface{})
-
- if t, ok := thisNodeDetails["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CreatedAt = creationTime
- }
-
- if t, ok := thisNodeDetails["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].UpdatedAt = updatedTime
- }
-
- if cs, ok := thisNodeDetails["cloud_server"].(map[string]interface{}); ok {
- if t, ok := cs["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CloudServer.CreatedAt = creationTime
- }
- if t, ok := cs["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CloudServer.UpdatedAt = updatedTime
- }
- if cn, ok := cs["cloud_network"].(map[string]interface{}); ok {
- if t, ok := cn["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CloudServer.CloudNetwork.CreatedAt = creationTime
- }
- if t, ok := cn["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return res, err
- }
- res[i].CloudServer.CloudNetwork.UpdatedAt = updatedTime
- }
- }
- }
- }
-
- return res, err
-}
-
-// PublicIPResult represents a result that can be extracted into a PublicIP.
-type PublicIPResult struct {
- gophercloud.Result
-}
-
-// CreateResult represents the result of a Create operation.
-type CreateResult struct {
- PublicIPResult
-}
-
-// GetResult represents the result of a Get operation.
-type GetResult struct {
- PublicIPResult
-}
-
-// Extract is a function that extracts a PublicIP from a PublicIPResult.
-func (r PublicIPResult) Extract() (*PublicIP, error) {
- if r.Err != nil {
- return nil, r.Err
- }
- var res PublicIP
- err := mapstructure.Decode(r.Body, &res)
-
- b := r.Body.(map[string]interface{})
-
- if date, ok := b["created"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res.CreatedAt = t
- }
-
- if date, ok := b["updated"]; ok && date != nil {
- t, err := time.Parse(time.RFC3339, date.(string))
- if err != nil {
- return nil, err
- }
- res.UpdatedAt = t
- }
-
- if cs, ok := b["cloud_server"].(map[string]interface{}); ok {
- if t, ok := cs["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &res, err
- }
- res.CloudServer.CreatedAt = creationTime
- }
- if t, ok := cs["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &res, err
- }
- res.CloudServer.UpdatedAt = updatedTime
- }
- if cn, ok := cs["cloud_network"].(map[string]interface{}); ok {
- if t, ok := cn["created"].(string); ok && t != "" {
- creationTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &res, err
- }
- res.CloudServer.CloudNetwork.CreatedAt = creationTime
- }
- if t, ok := cn["updated"].(string); ok && t != "" {
- updatedTime, err := time.Parse(time.RFC3339, t)
- if err != nil {
- return &res, err
- }
- res.CloudServer.CloudNetwork.UpdatedAt = updatedTime
- }
- }
- }
-
- return &res, err
-}
-
-// DeleteResult represents the result of a Delete operation.
-type DeleteResult struct {
- gophercloud.ErrResult
-}
diff --git a/rackspace/rackconnect/v3/publicips/urls.go b/rackspace/rackconnect/v3/publicips/urls.go
deleted file mode 100644
index 6f310be..0000000
--- a/rackspace/rackconnect/v3/publicips/urls.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package publicips
-
-import "github.com/rackspace/gophercloud"
-
-var root = "public_ips"
-
-func listURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL(root)
-}
-
-func createURL(c *gophercloud.ServiceClient) string {
- return c.ServiceURL(root)
-}
-
-func listForServerURL(c *gophercloud.ServiceClient, serverID string) string {
- return c.ServiceURL(root + "?cloud_server_id=" + serverID)
-}
-
-func getURL(c *gophercloud.ServiceClient, id string) string {
- return c.ServiceURL(root, id)
-}
-
-func deleteURL(c *gophercloud.ServiceClient, id string) string {
- return getURL(c, id)
-}
diff --git a/results.go b/results.go
index 27fd1b6..8161a89 100644
--- a/results.go
+++ b/results.go
@@ -113,8 +113,8 @@
// RFC3339Milli describes a common time format used by some API responses.
const RFC3339Milli = "2006-01-02T15:04:05.999999Z"
-// Time format used in cloud orchestration
-const STACK_TIME_FMT = "2006-01-02T15:04:05"
+// StackFmtTime is the time format used in Heat (Orchestration).
+const StackFmtTime = "2006-01-02T15:04:05"
/*
Link is an internal type to be used in packages of collection resources that are
@@ -133,7 +133,7 @@
ExtractNextURL is an internal function useful for packages of collection
resources that are paginated in a certain way.
-It attempts attempts to extract the "next" URL from slice of Link structs, or
+It attempts to extract the "next" URL from slice of Link structs, or
"" if no such URL is present.
*/
func ExtractNextURL(links []Link) (string, error) {