remove mapstructure from identity,networking,objectstorage,orchestration,pagination
diff --git a/openstack/networking/v2/extensions/external/results.go b/openstack/networking/v2/extensions/external/results.go
index c5d5f14..2c5173a 100644
--- a/openstack/networking/v2/extensions/external/results.go
+++ b/openstack/networking/v2/extensions/external/results.go
@@ -1,7 +1,6 @@
package external
import (
- "github.com/mitchellh/mapstructure"
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
"github.com/gophercloud/gophercloud/pagination"
)
@@ -10,72 +9,69 @@
// "external-net" extension.
type NetworkExternal struct {
// UUID for the network
- ID string `mapstructure:"id" json:"id"`
+ ID string `json:"id"`
// Human-readable name for the network. Might not be unique.
- Name string `mapstructure:"name" json:"name"`
+ Name string `json:"name"`
// The administrative state of network. If false (down), the network does not forward packets.
- AdminStateUp bool `mapstructure:"admin_state_up" json:"admin_state_up"`
+ AdminStateUp bool `json:"admin_state_up"`
// Indicates whether network is currently operational. Possible values include
// `ACTIVE', `DOWN', `BUILD', or `ERROR'. Plug-ins might define additional values.
- Status string `mapstructure:"status" json:"status"`
+ Status string `json:"status"`
// Subnets associated with this network.
- Subnets []string `mapstructure:"subnets" json:"subnets"`
+ Subnets []string `json:"subnets"`
// Owner of network. Only admin users can specify a tenant_id other than its own.
- TenantID string `mapstructure:"tenant_id" json:"tenant_id"`
+ TenantID string `json:"tenant_id"`
// Specifies whether the network resource can be accessed by any tenant or not.
- Shared bool `mapstructure:"shared" json:"shared"`
+ Shared bool `json:"shared"`
// Specifies whether the network is an external network or not.
- External bool `mapstructure:"router:external" json:"router:external"`
-}
-
-func commonExtract(e error, response interface{}) (*NetworkExternal, error) {
- if e != nil {
- return nil, e
- }
-
- var res struct {
- Network *NetworkExternal `json:"network"`
- }
-
- err := mapstructure.Decode(response, &res)
-
- return res.Network, err
+ External bool `json:"router:external"`
}
// ExtractGet decorates a GetResult struct returned from a networks.Get()
// function with extended attributes.
func ExtractGet(r networks.GetResult) (*NetworkExternal, error) {
- return commonExtract(r.Err, r.Body)
+ var s struct {
+ Network *NetworkExternal `json:"network"`
+ }
+ err := r.ExtractInto(&s)
+ return s.Network, err
}
// ExtractCreate decorates a CreateResult struct returned from a networks.Create()
// function with extended attributes.
func ExtractCreate(r networks.CreateResult) (*NetworkExternal, error) {
- return commonExtract(r.Err, r.Body)
+ var s struct {
+ Network *NetworkExternal `json:"network"`
+ }
+ err := r.ExtractInto(&s)
+ return s.Network, err
}
// ExtractUpdate decorates a UpdateResult struct returned from a
// networks.Update() function with extended attributes.
func ExtractUpdate(r networks.UpdateResult) (*NetworkExternal, error) {
- return commonExtract(r.Err, r.Body)
+ var s struct {
+ Network *NetworkExternal `json:"network"`
+ }
+ err := r.ExtractInto(&s)
+ return s.Network, err
}
// ExtractList accepts a Page struct, specifically a NetworkPage struct, and
// extracts the elements into a slice of NetworkExternal structs. In other
// words, a generic collection is mapped into a relevant slice.
func ExtractList(page pagination.Page) ([]NetworkExternal, error) {
- var resp struct {
- Networks []NetworkExternal `mapstructure:"networks" json:"networks"`
+ r := page.(networks.NetworkPage)
+ var s struct {
+ Networks []NetworkExternal `json:"networks" json:"networks"`
}
-
- err := mapstructure.Decode(page.(networks.NetworkPage).Body, &resp)
-
- return resp.Networks, err
+ err := r.ExtractInto(&s)
+ return s.Networks, err
}