Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 1 | package external |
| 2 | |
| 3 | import "github.com/rackspace/gophercloud/openstack/networking/v2/networks" |
| 4 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 5 | // 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 Hannaford | a241e31 | 2014-10-01 16:54:33 +0200 | [diff] [blame] | 7 | type AdminState *bool |
| 8 | |
| 9 | // Convenience vars for AdminStateUp values. |
| 10 | var ( |
| 11 | iTrue = true |
| 12 | iFalse = false |
| 13 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 14 | Up AdminState = &iTrue |
| 15 | Down AdminState = &iFalse |
Jamie Hannaford | a241e31 | 2014-10-01 16:54:33 +0200 | [diff] [blame] | 16 | ) |
| 17 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 18 | // 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 Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 21 | type CreateOpts struct { |
| 22 | Parent networks.CreateOpts |
| 23 | External bool |
| 24 | } |
| 25 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 26 | // ToNetworkCreateMap casts a CreateOpts struct to a map. |
Jamie Hannaford | e3bb3f6 | 2014-10-06 09:40:27 +0200 | [diff] [blame] | 27 | func (o CreateOpts) ToNetworkCreateMap() map[string]map[string]interface{} { |
| 28 | outer := o.Parent.ToNetworkCreateMap() |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 29 | |
| 30 | outer["network"]["router:external"] = o.External |
| 31 | |
| 32 | return outer |
| 33 | } |
| 34 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 35 | // 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 Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 38 | type UpdateOpts struct { |
| 39 | Parent networks.UpdateOpts |
| 40 | External bool |
| 41 | } |
| 42 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 43 | // ToNetworkUpdateMap casts an UpdateOpts struct to a map. |
Jamie Hannaford | e3bb3f6 | 2014-10-06 09:40:27 +0200 | [diff] [blame] | 44 | func (o UpdateOpts) ToNetworkUpdateMap() map[string]map[string]interface{} { |
| 45 | outer := o.Parent.ToNetworkUpdateMap() |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 46 | |
| 47 | outer["network"]["router:external"] = o.External |
| 48 | |
| 49 | return outer |
| 50 | } |