blob: afdd428a3358aa919193006fa91d58f92f0c97a7 [file] [log] [blame]
Jamie Hannaford7db63f22014-09-29 11:18:45 +02001package external
2
3import "github.com/rackspace/gophercloud/openstack/networking/v2/networks"
4
Jamie Hannafordffcd6792014-10-06 15:49:28 +02005// AdminState gives users a solid type to work with for create and update
6// operations. It is recommended that users use the `Up` and `Down` enums.
Jamie Hannaforda241e312014-10-01 16:54:33 +02007type AdminState *bool
8
9// Convenience vars for AdminStateUp values.
10var (
11 iTrue = true
12 iFalse = false
13
Jamie Hannafordffcd6792014-10-06 15:49:28 +020014 Up AdminState = &iTrue
15 Down AdminState = &iFalse
Jamie Hannaforda241e312014-10-01 16:54:33 +020016)
17
Jamie Hannafordffcd6792014-10-06 15:49:28 +020018// CreateOpts is the structure used when creating new external network
19// resources. It embeds networks.CreateOpts and so inherits all of its required
20// and optional fields, with the addition of the External field.
Jamie Hannaford7db63f22014-09-29 11:18:45 +020021type CreateOpts struct {
22 Parent networks.CreateOpts
23 External bool
24}
25
Jamie Hannafordffcd6792014-10-06 15:49:28 +020026// ToNetworkCreateMap casts a CreateOpts struct to a map.
Jamie Hannaforde3bb3f62014-10-06 09:40:27 +020027func (o CreateOpts) ToNetworkCreateMap() map[string]map[string]interface{} {
28 outer := o.Parent.ToNetworkCreateMap()
Jamie Hannaford7db63f22014-09-29 11:18:45 +020029
30 outer["network"]["router:external"] = o.External
31
32 return outer
33}
34
Jamie Hannafordffcd6792014-10-06 15:49:28 +020035// UpdateOpts is the structure used when updating existing external network
36// resources. It embeds networks.UpdateOpts and so inherits all of its required
37// and optional fields, with the addition of the External field.
Jamie Hannaford7db63f22014-09-29 11:18:45 +020038type UpdateOpts struct {
39 Parent networks.UpdateOpts
40 External bool
41}
42
Jamie Hannafordffcd6792014-10-06 15:49:28 +020043// ToNetworkUpdateMap casts an UpdateOpts struct to a map.
Jamie Hannaforde3bb3f62014-10-06 09:40:27 +020044func (o UpdateOpts) ToNetworkUpdateMap() map[string]map[string]interface{} {
45 outer := o.Parent.ToNetworkUpdateMap()
Jamie Hannaford7db63f22014-09-29 11:18:45 +020046
47 outer["network"]["router:external"] = o.External
48
49 return outer
50}