Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 1 | package external |
| 2 | |
Jon Perritt | cf6e524 | 2015-03-04 09:36:19 -0700 | [diff] [blame] | 3 | import ( |
Jon Perritt | e1c6ceb | 2016-03-14 12:09:36 -0500 | [diff] [blame] | 4 | "github.com/gophercloud/gophercloud" |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 5 | "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" |
Jon Perritt | cf6e524 | 2015-03-04 09:36:19 -0700 | [diff] [blame] | 6 | ) |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 7 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 8 | // CreateOpts is the structure used when creating new external network |
| 9 | // resources. It embeds networks.CreateOpts and so inherits all of its required |
| 10 | // and optional fields, with the addition of the External field. |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 11 | type CreateOpts struct { |
Jon Perritt | e1c6ceb | 2016-03-14 12:09:36 -0500 | [diff] [blame] | 12 | networks.CreateOpts |
| 13 | External *bool `json:"router:extenal,omitempty"` |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 14 | } |
| 15 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 16 | // ToNetworkCreateMap casts a CreateOpts struct to a map. |
Jon Perritt | e1c6ceb | 2016-03-14 12:09:36 -0500 | [diff] [blame] | 17 | func (opts CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) { |
| 18 | return gophercloud.BuildRequestBody(opts, "network") |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 19 | } |
| 20 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 21 | // UpdateOpts is the structure used when updating existing external network |
| 22 | // resources. It embeds networks.UpdateOpts and so inherits all of its required |
| 23 | // and optional fields, with the addition of the External field. |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 24 | type UpdateOpts struct { |
| 25 | Parent networks.UpdateOpts |
Jon Perritt | e1c6ceb | 2016-03-14 12:09:36 -0500 | [diff] [blame] | 26 | External *bool `json:"router:extenal,omitempty"` |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 27 | } |
| 28 | |
Jamie Hannaford | ffcd679 | 2014-10-06 15:49:28 +0200 | [diff] [blame] | 29 | // ToNetworkUpdateMap casts an UpdateOpts struct to a map. |
Jon Perritt | e1c6ceb | 2016-03-14 12:09:36 -0500 | [diff] [blame] | 30 | func (opts UpdateOpts) ToNetworkUpdateMap() (map[string]interface{}, error) { |
| 31 | return gophercloud.BuildRequestBody(opts, "network") |
Jamie Hannaford | 7db63f2 | 2014-09-29 11:18:45 +0200 | [diff] [blame] | 32 | } |