Shifting common v1 functionality to root pkg
diff --git a/rackspace/lb/v1/acl/requests.go b/rackspace/lb/v1/acl/requests.go
index d0623f5..e1e92ac 100644
--- a/rackspace/lb/v1/acl/requests.go
+++ b/rackspace/lb/v1/acl/requests.go
@@ -7,7 +7,6 @@
"github.com/racker/perigee"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
- "github.com/rackspace/gophercloud/rackspace/lb/v1"
)
// List is the operation responsible for returning a paginated collection of
@@ -96,7 +95,7 @@
}
url := rootURL(c, loadBalancerID)
- url += v1.IDSliceToQueryString("id", itemIDs)
+ url += gophercloud.IDSliceToQueryString("id", itemIDs)
_, res.Err = perigee.Request("DELETE", url, perigee.Options{
MoreHeaders: c.AuthenticatedHeaders(),
diff --git a/rackspace/lb/v1/common.go b/rackspace/lb/v1/common.go
deleted file mode 100644
index 1f33709..0000000
--- a/rackspace/lb/v1/common.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package v1
-
-import (
- "fmt"
- "strconv"
-)
-
-// IDSliceToQueryString takes a slice of elements and converts them into a query
-// string. For example, if name=foo and slice=[]int{20, 40, 60}, then the
-// result would be `?name=20&name=40&name=60'
-func IDSliceToQueryString(name string, ids []int) string {
- str := ""
- for k, v := range ids {
- if k == 0 {
- str += "?"
- } else {
- str += "&"
- }
- str += fmt.Sprintf("%s=%s", name, strconv.Itoa(v))
- }
- return str
-}
-
-// WithinRange returns TRUE if an integer falls within a defined range, and
-// FALSE if not.
-func WithinRange(val, min, max int) bool {
- return val > min && val < max
-}
diff --git a/rackspace/lb/v1/lbs/requests.go b/rackspace/lb/v1/lbs/requests.go
index 2d57520..eae54d1 100644
--- a/rackspace/lb/v1/lbs/requests.go
+++ b/rackspace/lb/v1/lbs/requests.go
@@ -8,7 +8,6 @@
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
- "github.com/rackspace/gophercloud/rackspace/lb/v1"
"github.com/rackspace/gophercloud/rackspace/lb/v1/acl"
"github.com/rackspace/gophercloud/rackspace/lb/v1/monitors"
"github.com/rackspace/gophercloud/rackspace/lb/v1/nodes"
@@ -271,7 +270,7 @@
}
url := rootURL(c)
- url += v1.IDSliceToQueryString("id", ids)
+ url += gophercloud.IDSliceToQueryString("id", ids)
_, res.Err = perigee.Request("DELETE", url, perigee.Options{
MoreHeaders: c.AuthenticatedHeaders(),
diff --git a/rackspace/lb/v1/monitors/requests.go b/rackspace/lb/v1/monitors/requests.go
index aa6ec5b..cfc35d2 100644
--- a/rackspace/lb/v1/monitors/requests.go
+++ b/rackspace/lb/v1/monitors/requests.go
@@ -6,7 +6,6 @@
"github.com/racker/perigee"
"github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/rackspace/lb/v1"
)
var (
@@ -41,13 +40,13 @@
func (opts UpdateConnectMonitorOpts) ToMonitorUpdateMap() (map[string]interface{}, error) {
type m map[string]interface{}
- if !v1.WithinRange(opts.AttemptLimit, 1, 10) {
+ if !gophercloud.IntWithinRange(opts.AttemptLimit, 1, 10) {
return m{}, errAttemptLimit
}
- if !v1.WithinRange(opts.Delay, 1, 3600) {
+ if !gophercloud.IntWithinRange(opts.Delay, 1, 3600) {
return m{}, errDelay
}
- if !v1.WithinRange(opts.Timeout, 1, 300) {
+ if !gophercloud.IntWithinRange(opts.Timeout, 1, 300) {
return m{}, errTimeout
}
@@ -95,13 +94,13 @@
func (opts UpdateHTTPMonitorOpts) ToMonitorUpdateMap() (map[string]interface{}, error) {
type m map[string]interface{}
- if !v1.WithinRange(opts.AttemptLimit, 1, 10) {
+ if !gophercloud.IntWithinRange(opts.AttemptLimit, 1, 10) {
return m{}, errAttemptLimit
}
- if !v1.WithinRange(opts.Delay, 1, 3600) {
+ if !gophercloud.IntWithinRange(opts.Delay, 1, 3600) {
return m{}, errDelay
}
- if !v1.WithinRange(opts.Timeout, 1, 300) {
+ if !gophercloud.IntWithinRange(opts.Timeout, 1, 300) {
return m{}, errTimeout
}
if opts.Type != HTTP && opts.Type != HTTPS {
diff --git a/rackspace/lb/v1/nodes/requests.go b/rackspace/lb/v1/nodes/requests.go
index 1c3765a..bfd0aed 100644
--- a/rackspace/lb/v1/nodes/requests.go
+++ b/rackspace/lb/v1/nodes/requests.go
@@ -7,7 +7,6 @@
"github.com/racker/perigee"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
- "github.com/rackspace/gophercloud/rackspace/lb/v1"
)
// List is the operation responsible for returning a paginated collection of
@@ -146,7 +145,7 @@
}
url := rootURL(c, loadBalancerID)
- url += v1.IDSliceToQueryString("id", nodeIDs)
+ url += gophercloud.IDSliceToQueryString("id", nodeIDs)
_, res.Err = perigee.Request("DELETE", url, perigee.Options{
MoreHeaders: c.AuthenticatedHeaders(),
diff --git a/rackspace/lb/v1/vips/requests.go b/rackspace/lb/v1/vips/requests.go
index 7401362..42f0c1d 100644
--- a/rackspace/lb/v1/vips/requests.go
+++ b/rackspace/lb/v1/vips/requests.go
@@ -7,7 +7,6 @@
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
- "github.com/rackspace/gophercloud/rackspace/lb/v1"
)
// List is the operation responsible for returning a paginated collection of
@@ -92,7 +91,7 @@
}
url := rootURL(c, loadBalancerID)
- url += v1.IDSliceToQueryString("id", vipIDs)
+ url += gophercloud.IDSliceToQueryString("id", vipIDs)
_, res.Err = perigee.Request("DELETE", url, perigee.Options{
MoreHeaders: c.AuthenticatedHeaders(),