1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
package portsecurity
import (
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
)
// PortCreateOptsExt adds port security options to the base ports.CreateOpts.
type PortCreateOptsExt struct {
ports.CreateOptsBuilder
// PortSecurityEnabled toggles port security on a port.
PortSecurityEnabled *bool `json:"port_security_enabled,omitempty"`
}
// ToPortCreateMap casts a CreateOpts struct to a map.
func (opts PortCreateOptsExt) ToPortCreateMap() (map[string]interface{}, error) {
base, err := opts.CreateOptsBuilder.ToPortCreateMap()
if err != nil {
return nil, err
}
port := base["port"].(map[string]interface{})
if opts.PortSecurityEnabled != nil {
port["port_security_enabled"] = &opts.PortSecurityEnabled
}
return base, nil
}
// PortUpdateOptsExt adds port security options to the base ports.UpdateOpts.
type PortUpdateOptsExt struct {
ports.UpdateOptsBuilder
// PortSecurityEnabled toggles port security on a port.
PortSecurityEnabled *bool `json:"port_security_enabled,omitempty"`
}
// ToPortUpdateMap casts a UpdateOpts struct to a map.
func (opts PortUpdateOptsExt) ToPortUpdateMap() (map[string]interface{}, error) {
base, err := opts.UpdateOptsBuilder.ToPortUpdateMap()
if err != nil {
return nil, err
}
port := base["port"].(map[string]interface{})
if opts.PortSecurityEnabled != nil {
port["port_security_enabled"] = &opts.PortSecurityEnabled
}
return base, nil
}
// NetworkCreateOptsExt adds port security options to the base
// networks.CreateOpts.
type NetworkCreateOptsExt struct {
networks.CreateOptsBuilder
// PortSecurityEnabled toggles port security on a port.
PortSecurityEnabled *bool `json:"port_security_enabled,omitempty"`
}
// ToNetworkCreateMap casts a CreateOpts struct to a map.
func (opts NetworkCreateOptsExt) ToNetworkCreateMap() (map[string]interface{}, error) {
base, err := opts.CreateOptsBuilder.ToNetworkCreateMap()
if err != nil {
return nil, err
}
network := base["network"].(map[string]interface{})
if opts.PortSecurityEnabled != nil {
network["port_security_enabled"] = &opts.PortSecurityEnabled
}
return base, nil
}
// NetworkUpdateOptsExt adds port security options to the base
// networks.UpdateOpts.
type NetworkUpdateOptsExt struct {
networks.UpdateOptsBuilder
// PortSecurityEnabled toggles port security on a port.
PortSecurityEnabled *bool `json:"port_security_enabled,omitempty"`
}
// ToNetworkUpdateMap casts a UpdateOpts struct to a map.
func (opts NetworkUpdateOptsExt) ToNetworkUpdateMap() (map[string]interface{}, error) {
base, err := opts.UpdateOptsBuilder.ToNetworkUpdateMap()
if err != nil {
return nil, err
}
network := base["network"].(map[string]interface{})
if opts.PortSecurityEnabled != nil {
network["port_security_enabled"] = &opts.PortSecurityEnabled
}
return base, nil
}
|