blob: 2f04593db958d11eb8c62d110f5b322892b7c923 [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.
Jon Perritt04851d32014-10-14 02:07:13 -050027func (o CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) {
28 outer, err := o.Parent.ToNetworkCreateMap()
29 if err != nil {
30 return nil, err
31 }
Jamie Hannaford7db63f22014-09-29 11:18:45 +020032
Jon Perritt04851d32014-10-14 02:07:13 -050033 outer["network"].(map[string]interface{})["router:external"] = o.External
Jamie Hannaford7db63f22014-09-29 11:18:45 +020034
Jon Perritt04851d32014-10-14 02:07:13 -050035 return outer, nil
Jamie Hannaford7db63f22014-09-29 11:18:45 +020036}
37
Jamie Hannafordffcd6792014-10-06 15:49:28 +020038// UpdateOpts is the structure used when updating existing external network
39// resources. It embeds networks.UpdateOpts and so inherits all of its required
40// and optional fields, with the addition of the External field.
Jamie Hannaford7db63f22014-09-29 11:18:45 +020041type UpdateOpts struct {
42 Parent networks.UpdateOpts
43 External bool
44}
45
Jamie Hannafordffcd6792014-10-06 15:49:28 +020046// ToNetworkUpdateMap casts an UpdateOpts struct to a map.
Jon Perritt04851d32014-10-14 02:07:13 -050047func (o UpdateOpts) ToNetworkUpdateMap() (map[string]interface{}, error) {
48 outer, err := o.Parent.ToNetworkUpdateMap()
49 if err != nil {
50 return nil, err
51 }
Jamie Hannaford7db63f22014-09-29 11:18:45 +020052
Jon Perritt04851d32014-10-14 02:07:13 -050053 outer["network"].(map[string]interface{})["router:external"] = o.External
Jamie Hannaford7db63f22014-09-29 11:18:45 +020054
Jon Perritt04851d32014-10-14 02:07:13 -050055 return outer, nil
Jamie Hannaford7db63f22014-09-29 11:18:45 +020056}