remove mapstructure from blockstorage,cdn,compute,db pkgs
diff --git a/openstack/cdn/v1/base/results.go b/openstack/cdn/v1/base/results.go
index 4e1b524..2dfde7d 100644
--- a/openstack/cdn/v1/base/results.go
+++ b/openstack/cdn/v1/base/results.go
@@ -1,10 +1,6 @@
package base
-import (
- "errors"
-
- "github.com/gophercloud/gophercloud"
-)
+import "github.com/gophercloud/gophercloud"
// HomeDocument is a resource that contains all the resources for the CDN API.
type HomeDocument map[string]interface{}
@@ -16,17 +12,9 @@
// Extract is a function that accepts a result and extracts a home document resource.
func (r GetResult) Extract() (*HomeDocument, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- submap, ok := r.Body.(map[string]interface{})["resources"]
- if !ok {
- return nil, errors.New("Unexpected HomeDocument structure")
- }
- casted := HomeDocument(submap.(map[string]interface{}))
-
- return &casted, nil
+ var s HomeDocument
+ err := r.ExtractInto(&s)
+ return &s, err
}
// PingResult represents the result of a Ping operation.
diff --git a/openstack/cdn/v1/flavors/results.go b/openstack/cdn/v1/flavors/results.go
index 45308bc..1b15dbc 100644
--- a/openstack/cdn/v1/flavors/results.go
+++ b/openstack/cdn/v1/flavors/results.go
@@ -1,7 +1,6 @@
package flavors
import (
- "github.com/mitchellh/mapstructure"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
@@ -10,20 +9,20 @@
type Provider struct {
// Specifies the name of the provider. The name must not exceed 64 bytes in
// length and is limited to unicode, digits, underscores, and hyphens.
- Provider string `mapstructure:"provider"`
+ Provider string `json:"provider"`
// Specifies a list with an href where rel is provider_url.
- Links []gophercloud.Link `mapstructure:"links"`
+ Links []gophercloud.Link `json:"links"`
}
// Flavor represents a mapping configuration to a CDN provider.
type Flavor struct {
// Specifies the name of the flavor. The name must not exceed 64 bytes in
// length and is limited to unicode, digits, underscores, and hyphens.
- ID string `mapstructure:"id"`
+ ID string `json:"id"`
// Specifies the list of providers mapped to this flavor.
- Providers []Provider `mapstructure:"providers"`
+ Providers []Provider `json:"providers"`
// Specifies the self-navigating JSON document paths.
- Links []gophercloud.Link `mapstructure:"links"`
+ Links []gophercloud.Link `json:"links"`
}
// FlavorPage is the page returned by a pager when traversing over a
@@ -44,12 +43,12 @@
// ExtractFlavors extracts and returns Flavors. It is used while iterating over
// a flavors.List call.
func ExtractFlavors(page pagination.Page) ([]Flavor, error) {
- var response struct {
+ r := page.(FlavorPage)
+ var s struct {
Flavors []Flavor `json:"flavors"`
}
-
- err := mapstructure.Decode(page.(FlavorPage).Body, &response)
- return response.Flavors, err
+ err := r.ExtractInto(&s)
+ return s.Flavors, err
}
// GetResult represents the result of a get operation.
@@ -59,13 +58,7 @@
// Extract is a function that extracts a flavor from a GetResult.
func (r GetResult) Extract() (*Flavor, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var res Flavor
-
- err := mapstructure.Decode(r.Body, &res)
-
- return &res, err
+ var s Flavor
+ err := r.ExtractInto(&s)
+ return &s, err
}
diff --git a/openstack/cdn/v1/services/results.go b/openstack/cdn/v1/services/results.go
index a214944..e37fafa 100644
--- a/openstack/cdn/v1/services/results.go
+++ b/openstack/cdn/v1/services/results.go
@@ -3,18 +3,16 @@
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
-
- "github.com/mitchellh/mapstructure"
)
// Domain represents a domain used by users to access their website.
type Domain struct {
// Specifies the domain used to access the assets on their website, for which
// a CNAME is given to the CDN provider.
- Domain string `mapstructure:"domain" json:"domain"`
+ Domain string `json:"domain"`
// Specifies the protocol used to access the assets on this domain. Only "http"
// or "https" are currently allowed. The default is "http".
- Protocol string `mapstructure:"protocol" json:"protocol,omitempty"`
+ Protocol string `json:"protocol,omitempty"`
}
func (d Domain) toPatchValue() interface{} {
@@ -56,23 +54,23 @@
// OriginRule represents a rule that defines when an origin should be accessed.
type OriginRule struct {
// Specifies the name of this rule.
- Name string `mapstructure:"name" json:"name"`
+ Name string `json:"name"`
// Specifies the request URL this rule should match for this origin to be used. Regex is supported.
- RequestURL string `mapstructure:"request_url" json:"request_url"`
+ RequestURL string `json:"request_url"`
}
// Origin specifies a list of origin domains or IP addresses where the original assets are stored.
type Origin struct {
// Specifies the URL or IP address to pull origin content from.
- Origin string `mapstructure:"origin" json:"origin"`
+ Origin string `json:"origin"`
// Specifies the port used to access the origin. The default is port 80.
- Port int `mapstructure:"port" json:"port,omitempty"`
+ Port int `json:"port"`
// Specifies whether or not to use HTTPS to access the origin. The default
// is false.
- SSL bool `mapstructure:"ssl" json:"ssl"`
+ SSL bool `json:"ssl"`
// Specifies a collection of rules that define the conditions when this origin
// should be accessed. If there is more than one origin, the rules parameter is required.
- Rules []OriginRule `mapstructure:"rules" json:"rules,omitempty"`
+ Rules []OriginRule `json:"rules,omitempty"`
}
func (o Origin) toPatchValue() interface{} {
@@ -121,19 +119,19 @@
// TTLRule specifies a rule that determines if a TTL should be applied to an asset.
type TTLRule struct {
// Specifies the name of this rule.
- Name string `mapstructure:"name" json:"name"`
+ Name string `json:"name"`
// Specifies the request URL this rule should match for this TTL to be used. Regex is supported.
- RequestURL string `mapstructure:"request_url" json:"request_url"`
+ RequestURL string `json:"request_url"`
}
// CacheRule specifies the TTL rules for the assets under this service.
type CacheRule struct {
// Specifies the name of this caching rule. Note: 'default' is a reserved name used for the default TTL setting.
- Name string `mapstructure:"name" json:"name"`
+ Name string `json:"name"`
// Specifies the TTL to apply.
- TTL int `mapstructure:"ttl" json:"ttl"`
+ TTL int `json:"ttl"`
// Specifies a collection of rules that determine if this TTL should be applied to an asset.
- Rules []TTLRule `mapstructure:"rules" json:"rules,omitempty"`
+ Rules []TTLRule `json:"rules,omitempty"`
}
func (c CacheRule) toPatchValue() interface{} {
@@ -179,48 +177,48 @@
// RestrictionRule specifies a rule that determines if this restriction should be applied to an asset.
type RestrictionRule struct {
// Specifies the name of this rule.
- Name string `mapstructure:"name" json:"name"`
+ Name string `json:"name"`
// Specifies the http host that requests must come from.
- Referrer string `mapstructure:"referrer" json:"referrer,omitempty"`
+ Referrer string `json:"referrer"`
}
// Restriction specifies a restriction that defines who can access assets (content from the CDN cache).
type Restriction struct {
// Specifies the name of this restriction.
- Name string `mapstructure:"name" json:"name"`
+ Name string `json:"name"`
// Specifies a collection of rules that determine if this TTL should be applied to an asset.
- Rules []RestrictionRule `mapstructure:"rules" json:"rules"`
+ Rules []RestrictionRule `json:"rules"`
}
// Error specifies an error that occurred during the previous service action.
type Error struct {
// Specifies an error message detailing why there is an error.
- Message string `mapstructure:"message"`
+ Message string `json:"message"`
}
// Service represents a CDN service resource.
type Service struct {
// Specifies the service ID that represents distributed content. The value is
// a UUID, such as 96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0, that is generated by the server.
- ID string `mapstructure:"id"`
+ ID string `json:"id"`
// Specifies the name of the service.
- Name string `mapstructure:"name"`
+ Name string `json:"name"`
// Specifies a list of domains used by users to access their website.
- Domains []Domain `mapstructure:"domains"`
+ Domains []Domain `json:"domains"`
// Specifies a list of origin domains or IP addresses where the original assets are stored.
- Origins []Origin `mapstructure:"origins"`
+ Origins []Origin `json:"origins"`
// Specifies the TTL rules for the assets under this service. Supports wildcards for fine grained control.
- Caching []CacheRule `mapstructure:"caching"`
+ Caching []CacheRule `json:"caching"`
// Specifies the restrictions that define who can access assets (content from the CDN cache).
- Restrictions []Restriction `mapstructure:"restrictions" json:"restrictions,omitempty"`
+ Restrictions []Restriction `json:"restrictions"`
// Specifies the CDN provider flavor ID to use. For a list of flavors, see the operation to list the available flavors.
- FlavorID string `mapstructure:"flavor_id"`
+ FlavorID string `json:"flavor_id"`
// Specifies the current status of the service.
- Status string `mapstructure:"status"`
+ Status string `json:"status"`
// Specifies the list of errors that occurred during the previous service action.
- Errors []Error `mapstructure:"errors"`
+ Errors []Error `json:"errors"`
// Specifies the self-navigating JSON document paths.
- Links []gophercloud.Link `mapstructure:"links"`
+ Links []gophercloud.Link `json:"links"`
}
// ServicePage is the page returned by a pager when traversing over a
@@ -252,12 +250,12 @@
// ExtractServices is a function that takes a ListResult and returns the services' information.
func ExtractServices(page pagination.Page) ([]Service, error) {
- var response struct {
- Services []Service `mapstructure:"services"`
+ r := page.(ServicePage)
+ var s struct {
+ Services []Service `json:"services"`
}
-
- err := mapstructure.Decode(page.(ServicePage).Body, &response)
- return response.Services, err
+ err := r.ExtractInto(&s)
+ return s.Services, err
}
// CreateResult represents the result of a Create operation.
@@ -283,15 +281,9 @@
// Extract is a function that extracts a service from a GetResult.
func (r GetResult) Extract() (*Service, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var res Service
-
- err := mapstructure.Decode(r.Body, &res)
-
- return &res, err
+ var s Service
+ err := r.ExtractInto(&s)
+ return &s, err
}
// UpdateResult represents the result of a Update operation.