Use the ServiceClient to generate URLs.
Add OkCodes to all of the perigee requests.
diff --git a/openstack/storage/v1/accounts/requests.go b/openstack/storage/v1/accounts/requests.go
index 3ffc5f7..d5b623a 100644
--- a/openstack/storage/v1/accounts/requests.go
+++ b/openstack/storage/v1/accounts/requests.go
@@ -22,9 +22,9 @@
h["X-Account-Meta-"+k] = v
}
- url := c.GetAccountURL()
- _, err = perigee.Request("POST", url, perigee.Options{
+ _, err := perigee.Request("POST", getAccountURL(c), perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{204},
})
return err
}
@@ -38,9 +38,9 @@
h[k] = v
}
- url := c.GetAccountURL()
- resp, err := perigee.Request("HEAD", url, perigee.Options{
+ resp, err := perigee.Request("HEAD", getAccountURL(c), perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{204},
})
return &resp.HttpResponse, err
}
diff --git a/openstack/storage/v1/accounts/urls.go b/openstack/storage/v1/accounts/urls.go
new file mode 100644
index 0000000..ae78ff2
--- /dev/null
+++ b/openstack/storage/v1/accounts/urls.go
@@ -0,0 +1,8 @@
+package accounts
+
+import "github.com/rackspace/gophercloud"
+
+// getAccountURL returns the URI for making Account requests.
+func getAccountURL(c *gophercloud.ServiceClient) string {
+ return c.Endpoint
+}
diff --git a/openstack/storage/v1/containers/requests.go b/openstack/storage/v1/containers/requests.go
index d2cec0b..0db691c 100644
--- a/openstack/storage/v1/containers/requests.go
+++ b/openstack/storage/v1/containers/requests.go
@@ -28,10 +28,11 @@
contentType = "text/plain"
}
- url := c.GetAccountURL() + query
+ url := getAccountURL(c) + query
resp, err := perigee.Request("GET", url, perigee.Options{
MoreHeaders: h,
Accept: contentType,
+ OkCodes: []int{200, 204},
})
return &resp.HttpResponse, err
}
@@ -50,9 +51,10 @@
h["X-Container-Meta-"+k] = v
}
- url := c.GetContainerURL(opts.Name)
- _, err = perigee.Request("PUT", url, perigee.Options{
+ url := getContainerURL(c, opts.Name)
+ _, err := perigee.Request("PUT", url, perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{201, 204},
})
if err == nil {
ci = Container{
@@ -88,9 +90,10 @@
h["X-Container-Meta-"+k] = v
}
- url := c.GetContainerURL(opts.Name)
- _, err = perigee.Request("POST", url, perigee.Options{
+ url := getContainerURL(c, opts.Name)
+ _, err := perigee.Request("POST", url, perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{204},
})
return err
}
@@ -104,9 +107,10 @@
h["X-Container-Meta-"+k] = v
}
- url := c.GetContainerURL(opts.Name)
+ url := getContainerURL(c, opts.Name)
resp, err := perigee.Request("HEAD", url, perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{204},
})
return &resp.HttpResponse, err
}
diff --git a/openstack/storage/v1/containers/urls.go b/openstack/storage/v1/containers/urls.go
new file mode 100644
index 0000000..4084bcc
--- /dev/null
+++ b/openstack/storage/v1/containers/urls.go
@@ -0,0 +1,13 @@
+package containers
+
+import "github.com/rackspace/gophercloud"
+
+// getAccountURL returns the URI used to list Containers.
+func getAccountURL(c *gophercloud.ServiceClient) string {
+ return c.Endpoint
+}
+
+// getContainerURL returns the URI for making Container requests.
+func getContainerURL(c *gophercloud.ServiceClient, container string) string {
+ return c.ServiceURL(container)
+}
diff --git a/openstack/storage/v1/objects/requests.go b/openstack/storage/v1/objects/requests.go
index bb9c4ac..931653e 100644
--- a/openstack/storage/v1/objects/requests.go
+++ b/openstack/storage/v1/objects/requests.go
@@ -32,10 +32,11 @@
contentType = "text/plain"
}
- url := c.GetContainerURL(opts.Container) + query
+ url := getContainerURL(c, opts.Container) + query
resp, err := perigee.Request("GET", url, perigee.Options{
MoreHeaders: h,
Accept: contentType,
+ OkCodes: []int{200, 204},
})
return &resp.HttpResponse, err
}
@@ -52,9 +53,10 @@
query := utils.BuildQuery(opts.Params)
- url := c.GetObjectURL(opts.Container, opts.Name) + query
+ url := getObjectURL(c, opts.Container, opts.Name) + query
resp, err := perigee.Request("GET", url, perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{200},
})
return &resp.HttpResponse, err
}
@@ -84,10 +86,11 @@
}
}
- url := c.GetObjectURL(opts.Container, opts.Name) + query
- _, err = perigee.Request("PUT", url, perigee.Options{
+ url := getObjectURL(c, opts.Container, opts.Name) + query
+ _, err := perigee.Request("PUT", url, perigee.Options{
ReqBody: reqBody,
MoreHeaders: h,
+ OkCodes: []int{201},
})
return err
}
@@ -102,9 +105,10 @@
h["Destination"] = fmt.Sprintf("/%s/%s", opts.NewContainer, opts.NewName)
- url := c.GetObjectURL(opts.Container, opts.Name)
- _, err = perigee.Request("COPY", url, perigee.Options{
+ url := getObjectURL(c, opts.Container, opts.Name)
+ _, err := perigee.Request("COPY", url, perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{201},
})
return err
}
@@ -115,9 +119,10 @@
query := utils.BuildQuery(opts.Params)
- url := c.GetObjectURL(opts.Container, opts.Name) + query
- _, err = perigee.Request("DELETE", url, perigee.Options{
+ url := getObjectURL(c, opts.Container, opts.Name) + query
+ _, err := perigee.Request("DELETE", url, perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{204},
})
return err
}
@@ -151,9 +156,10 @@
h["X-Object-Meta-"+k] = v
}
- url := c.GetObjectURL(opts.Container, opts.Name)
- _, err = perigee.Request("POST", url, perigee.Options{
+ url := getObjectURL(c, opts.Container, opts.Name)
+ _, err := perigee.Request("POST", url, perigee.Options{
MoreHeaders: h,
+ OkCodes: []int{202},
})
return err
}
diff --git a/openstack/storage/v1/objects/urls.go b/openstack/storage/v1/objects/urls.go
new file mode 100644
index 0000000..5a52aed
--- /dev/null
+++ b/openstack/storage/v1/objects/urls.go
@@ -0,0 +1,13 @@
+package objects
+
+import "github.com/rackspace/gophercloud"
+
+// getObjectURL returns the URI for making Object requests.
+func getObjectURL(c *gophercloud.ServiceClient, container, object string) string {
+ return c.ServiceURL(container, object)
+}
+
+// getContainerURL returns the URI for making Container requests.
+func getContainerURL(c *gophercloud.ServiceClient, container string) string {
+ return c.ServiceURL(container)
+}