github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/fwaas/routerinsertion/requests.go (about) 1 package routerinsertion 2 3 import ( 4 "github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/fwaas/firewalls" 5 ) 6 7 // CreateOptsExt adds the RouterIDs option to the base CreateOpts. 8 type CreateOptsExt struct { 9 firewalls.CreateOptsBuilder 10 RouterIDs []string `json:"router_ids"` 11 } 12 13 // ToFirewallCreateMap adds router_ids to the base firewall creation options. 14 func (opts CreateOptsExt) ToFirewallCreateMap() (map[string]interface{}, error) { 15 base, err := opts.CreateOptsBuilder.ToFirewallCreateMap() 16 if err != nil { 17 return nil, err 18 } 19 20 firewallMap := base["firewall"].(map[string]interface{}) 21 firewallMap["router_ids"] = opts.RouterIDs 22 23 return base, nil 24 } 25 26 // UpdateOptsExt adds the RouterIDs option to the base UpdateOpts. 27 type UpdateOptsExt struct { 28 firewalls.UpdateOptsBuilder 29 RouterIDs []string `json:"router_ids"` 30 } 31 32 // ToFirewallUpdateMap adds router_ids to the base firewall update options. 33 func (opts UpdateOptsExt) ToFirewallUpdateMap() (map[string]interface{}, error) { 34 base, err := opts.UpdateOptsBuilder.ToFirewallUpdateMap() 35 if err != nil { 36 return nil, err 37 } 38 39 firewallMap := base["firewall"].(map[string]interface{}) 40 firewallMap["router_ids"] = opts.RouterIDs 41 42 return base, nil 43 }