github.com/renier/terraform@v0.7.8-0.20161024133817-eb8a9ef5471a/builtin/providers/openstack/types.go (about) 1 package openstack 2 3 import ( 4 "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" 5 "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" 6 "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" 7 ) 8 9 // NetworkCreateOpts represents the attributes used when creating a new network. 10 type NetworkCreateOpts struct { 11 networks.CreateOpts 12 ValueSpecs map[string]string `json:"value_specs,omitempty"` 13 } 14 15 // ToNetworkCreateMap casts a CreateOpts struct to a map. 16 // It overrides networks.ToNetworkCreateMap to add the ValueSpecs field. 17 func (opts NetworkCreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) { 18 return BuildRequest(opts, "network") 19 } 20 21 // RouterCreateOpts represents the attributes used when creating a new router. 22 type RouterCreateOpts struct { 23 routers.CreateOpts 24 ValueSpecs map[string]string `json:"value_specs,omitempty"` 25 } 26 27 // ToRouterCreateMap casts a CreateOpts struct to a map. 28 // It overrides routers.ToRouterCreateMap to add the ValueSpecs field. 29 func (opts RouterCreateOpts) ToRouterCreateMap() (map[string]interface{}, error) { 30 return BuildRequest(opts, "router") 31 } 32 33 // SubnetCreateOpts represents the attributes used when creating a new subnet. 34 type SubnetCreateOpts struct { 35 subnets.CreateOpts 36 ValueSpecs map[string]string `json:"value_specs,omitempty"` 37 } 38 39 // ToSubnetCreateMap casts a CreateOpts struct to a map. 40 // It overrides subnets.ToSubnetCreateMap to add the ValueSpecs field. 41 func (opts SubnetCreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) { 42 b, err := BuildRequest(opts, "subnet") 43 if err != nil { 44 return nil, err 45 } 46 47 if m := b["subnet"].(map[string]interface{}); m["gateway_ip"] == "" { 48 m["gateway_ip"] = nil 49 } 50 51 return b, nil 52 }