struct tags for networking v2
diff --git a/openstack/networking/v2/extensions/external/requests.go b/openstack/networking/v2/extensions/external/requests.go
index da47926..f626f66 100644
--- a/openstack/networking/v2/extensions/external/requests.go
+++ b/openstack/networking/v2/extensions/external/requests.go
@@ -1,51 +1,21 @@
package external
import (
- "time"
-
+ "github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
)
-// AdminState gives users a solid type to work with for create and update
-// operations. It is recommended that users use the `Up` and `Down` enums.
-type AdminState *bool
-
-// Convenience vars for AdminStateUp values.
-var (
- iTrue = true
- iFalse = false
-
- Up AdminState = &iTrue
- Down AdminState = &iFalse
-)
-
// CreateOpts is the structure used when creating new external network
// resources. It embeds networks.CreateOpts and so inherits all of its required
// and optional fields, with the addition of the External field.
type CreateOpts struct {
- Parent networks.CreateOpts
- External bool
+ networks.CreateOpts
+ External *bool `json:"router:extenal,omitempty"`
}
// ToNetworkCreateMap casts a CreateOpts struct to a map.
-func (o CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) {
-
- // DO NOT REMOVE. Though this line seemingly does nothing of value, it is a
- // splint to prevent the unit test from failing on Go Tip. We suspect it is a
- // compiler issue that will hopefully be worked out prior to our next release.
- // Again, for all the unit tests to pass, this line is necessary and sufficient
- // at the moment. We should reassess after the Go 1.5 release to determine
- // if this line is still needed.
- time.Sleep(0 * time.Millisecond)
-
- outer, err := o.Parent.ToNetworkCreateMap()
- if err != nil {
- return nil, err
- }
-
- outer["network"].(map[string]interface{})["router:external"] = o.External
-
- return outer, nil
+func (opts CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) {
+ return gophercloud.BuildRequestBody(opts, "network")
}
// UpdateOpts is the structure used when updating existing external network
@@ -53,17 +23,10 @@
// and optional fields, with the addition of the External field.
type UpdateOpts struct {
Parent networks.UpdateOpts
- External bool
+ External *bool `json:"router:extenal,omitempty"`
}
// ToNetworkUpdateMap casts an UpdateOpts struct to a map.
-func (o UpdateOpts) ToNetworkUpdateMap() (map[string]interface{}, error) {
- outer, err := o.Parent.ToNetworkUpdateMap()
- if err != nil {
- return nil, err
- }
-
- outer["network"].(map[string]interface{})["router:external"] = o.External
-
- return outer, nil
+func (opts UpdateOpts) ToNetworkUpdateMap() (map[string]interface{}, error) {
+ return gophercloud.BuildRequestBody(opts, "network")
}