Firewall rules bugfixes & enhancements
diff --git a/openstack/networking/v2/extensions/fwaas/rules/requests.go b/openstack/networking/v2/extensions/fwaas/rules/requests.go
index 66f7da4..181a758 100644
--- a/openstack/networking/v2/extensions/fwaas/rules/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/rules/requests.go
@@ -6,15 +6,20 @@
"github.com/rackspace/gophercloud/pagination"
)
+// ListOpts allows the filtering and sorting of paginated collections through
+// the API. Filtering is achieved by passing in struct field values that map to
+// the Firewall rule attributes you want to see returned. SortKey allows you to
+// sort by a particular firewall rule attribute. SortDir sets the direction, and is
+// either `asc' or `desc'. Marker and Limit are used for pagination.
type ListOpts struct {
TenantID string `q:"tenant_id"`
Name string `q:"name"`
Description string `q:"description"`
Protocol string `q:"protocol"`
Action string `q:"action"`
- IpVersion int `q:"ip_version"`
- SourceIpAddress string `q:"source_ip_address"`
- DestinationIpAddress string `q:"destination_ip_address"`
+ IPVersion int `q:"ip_version"`
+ SourceIPAddress string `q:"source_ip_address"`
+ DestinationIPAddress string `q:"destination_ip_address"`
SourcePort string `q:"source_port"`
DestinationPort string `q:"destination_port"`
Enabled bool `q:"enabled"`
@@ -44,51 +49,52 @@
// CreateOpts contains all the values needed to create a new firewall rule.
type CreateOpts struct {
- // Only required if the caller has an admin role and wants to create a firewall rule
- // for another tenant.
- TenantId string
+ // Mandatory
+ Protocol string
+ Action string
+ // Optional
+ TenantID string
Name string
Description string
- Protocol string
- Action string
- IpVersion int
- SourceIpAddress string
- DestinationIpAddress string
+ IPVersion *int
+ SourceIPAddress string
+ DestinationIPAddress string
SourcePort string
DestinationPort string
- Shared bool
- Enabled bool
+ Shared *bool
+ Enabled *bool
}
// Create accepts a CreateOpts struct and uses the values to create a new firewall rule
func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
+
type rule struct {
- TenantId string `json:"tenant_id,omitempty"`
- Name string `json:"name,omitempty"`
- Description string `json:"description,omitempty"`
+ TenantID string `json:"tenant_id,omitempty"`
+ Name string `json:"name"`
+ Description string `json:"description"`
Protocol string `json:"protocol"`
Action string `json:"action"`
- IpVersion int `json:"ip_version,omitempty"`
- SourceIpAddress string `json:"source_ip_address,omitempty"`
- DestinationIpAddress string `json:"destination_ip_address,omitempty"`
+ IPVersion *int `json:"ip_version,omitempty"`
+ SourceIPAddress string `json:"source_ip_address,omitempty"`
+ DestinationIPAddress string `json:"destination_ip_address,omitempty"`
SourcePort string `json:"source_port,omitempty"`
DestinationPort string `json:"destination_port,omitempty"`
- Shared bool `json:"shared,omitempty"`
- Enabled bool `json:"enabled,omitempty"`
+ Shared *bool `json:"shared,omitempty"`
+ Enabled *bool `json:"enabled,omitempty"`
}
type request struct {
Rule rule `json:"firewall_rule"`
}
reqBody := request{Rule: rule{
- TenantId: opts.TenantId,
+ TenantID: opts.TenantID,
Name: opts.Name,
Description: opts.Description,
Protocol: opts.Protocol,
Action: opts.Action,
- IpVersion: opts.IpVersion,
- SourceIpAddress: opts.SourceIpAddress,
- DestinationIpAddress: opts.DestinationIpAddress,
+ IPVersion: opts.IPVersion,
+ SourceIPAddress: opts.SourceIPAddress,
+ DestinationIPAddress: opts.DestinationIPAddress,
SourcePort: opts.SourcePort,
DestinationPort: opts.DestinationPort,
Shared: opts.Shared,
@@ -122,13 +128,13 @@
Description string
Protocol string
Action string
- IpVersion int
- SourceIpAddress string
- DestinationIpAddress string
+ IPVersion *int
+ SourceIPAddress string
+ DestinationIPAddress string
SourcePort string
DestinationPort string
- Shared bool
- Enabled bool
+ Shared *bool
+ Enabled *bool
}
// Update allows firewall policies to be updated.
@@ -136,15 +142,15 @@
type rule struct {
Name string `json:"name"`
Description string `json:"description"`
- Protocol string `json:"protocol,omitempty"`
- Action string `json:"action,omitempty"`
- IpVersion int `json:"ip_version,omitempty"`
- SourceIpAddress string `json:"source_ip_address,omitempty"`
- DestinationIpAddress string `json:"destination_ip_address,omitempty"`
- SourcePort string `json:"source_port,omitempty"`
- DestinationPort string `json:"destination_port,omitempty"`
- Shared bool `json:"shared,omitempty"`
- Enabled bool `json:"enabled,omitempty"`
+ Protocol string `json:"protocol"`
+ Action string `json:"action"`
+ IPVersion *int `json:"ip_version,omitempty"`
+ SourceIPAddress string `json:"source_ip_address"`
+ DestinationIPAddress string `json:"destination_ip_address"`
+ SourcePort string `json:"source_port"`
+ DestinationPort string `json:"destination_port"`
+ Shared *bool `json:"shared,omitempty"`
+ Enabled *bool `json:"enabled,omitempty"`
}
type request struct {
Rule rule `json:"firewall_rule"`
@@ -155,9 +161,9 @@
Description: opts.Description,
Protocol: opts.Protocol,
Action: opts.Action,
- IpVersion: opts.IpVersion,
- SourceIpAddress: opts.SourceIpAddress,
- DestinationIpAddress: opts.DestinationIpAddress,
+ IPVersion: opts.IPVersion,
+ SourceIPAddress: opts.SourceIPAddress,
+ DestinationIPAddress: opts.DestinationIPAddress,
SourcePort: opts.SourcePort,
DestinationPort: opts.DestinationPort,
Shared: opts.Shared,
@@ -171,6 +177,7 @@
ReqBody: &reqBody,
Results: &res.Body,
OkCodes: []int{200},
+ DumpReqJson: true,
})
return res
diff --git a/openstack/networking/v2/extensions/fwaas/rules/results.go b/openstack/networking/v2/extensions/fwaas/rules/results.go
index 2bbb3db..ff3de8a 100644
--- a/openstack/networking/v2/extensions/fwaas/rules/results.go
+++ b/openstack/networking/v2/extensions/fwaas/rules/results.go
@@ -6,19 +6,20 @@
"github.com/rackspace/gophercloud/pagination"
)
+// Rule represents a firewall rule
type Rule struct {
- Id string `json:"id"`
- Name string `json:"name,omitempty"`
- Description string `json:"description,omitempty"`
- Protocol string `json:"protocol"`
- Action string `json:"action"`
- IpVersion int `json:"ip_version,omitempty"`
- SourceIpAddress string `json:"source_ip_address,omitempty"`
- DestinationIpAddress string `json:"destination_ip_address,omitempty"`
- SourcePort string `json:"source_port,omitempty"`
- DestinationPort string `json:"destination_port,omitempty"`
- Shared bool `json:"shared,omitempty"`
- Enabled bool `json:"enabled,omitempty"`
+ ID string `json:"id" mapstructure:"id"`
+ Name string `json:"name,omitempty" mapstructure:"name"`
+ Description string `json:"description,omitempty" mapstructure:"description"`
+ Protocol string `json:"protocol" mapstructure:"protocol"`
+ Action string `json:"action" mapstructure:"action"`
+ IPVersion int `json:"ip_version,omitempty" mapstructure:"ip_version"`
+ SourceIPAddress string `json:"source_ip_address,omitempty" mapstructure:"source_ip_address"`
+ DestinationIPAddress string `json:"destination_ip_address,omitempty" mapstructure:"destination_ip_address"`
+ SourcePort string `json:"source_port,omitempty" mapstructure:"source_port"`
+ DestinationPort string `json:"destination_port,omitempty" mapstructure:"destination_port"`
+ Shared bool `json:"shared,omitempty" mapstructure:"shared"`
+ Enabled bool `json:"enabled,omitempty" mapstructure:"enabled"`
}
// RulePage is the page returned by a pager when traversing over a