Use solid types for *bool attributes
diff --git a/openstack/networking/v2/extensions/fwaas/firewalls/requests.go b/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
index 950c14d..a1df87b 100644
--- a/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
@@ -6,6 +6,24 @@
"github.com/rackspace/gophercloud/pagination"
)
+// AdminState gives users a solid type to work with for create and update
+// operations. It is recommended that users use the `Up` and `Down` enums.
+type AdminState *bool
+
+// Shared gives users a solid type to work with for create and update
+// operations. It is recommended that users use the `Yes` and `No` enums.
+type Shared *bool
+
+// Convenience vars for AdminStateUp and Shared values.
+var (
+ iTrue = true
+ iFalse = false
+ Up AdminState = &iTrue
+ Down AdminState = &iFalse
+ Yes Shared = &iTrue
+ No Shared = &iFalse
+)
+
type ListOpts struct {
TenantID string `q:"tenant_id"`
Name string `q:"name"`
diff --git a/openstack/networking/v2/extensions/fwaas/firewalls/requests_test.go b/openstack/networking/v2/extensions/fwaas/firewalls/requests_test.go
index 8a0b3ca..316a939 100644
--- a/openstack/networking/v2/extensions/fwaas/firewalls/requests_test.go
+++ b/openstack/networking/v2/extensions/fwaas/firewalls/requests_test.go
@@ -133,13 +133,11 @@
`)
})
- adminStateTrue := true
-
options := CreateOpts{
TenantID: "b4eedccc6fb74fa8a7ad6b08382b852b",
Name: "fw",
Description: "OpenStack firewall",
- AdminStateUp: &adminStateTrue,
+ AdminStateUp: Up,
PolicyID: "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c",
}
_, err := Create(fake.ServiceClient(), options).Extract()
@@ -222,15 +220,13 @@
`)
})
- adminStateFalse := false
-
name := "fw"
description := ""
options := UpdateOpts{
Name: &name,
Description: &description,
- AdminStateUp: &adminStateFalse,
+ AdminStateUp: Down,
PolicyID: "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c",
}
diff --git a/openstack/networking/v2/extensions/fwaas/policies/requests.go b/openstack/networking/v2/extensions/fwaas/policies/requests.go
index 260b728..fec7c2e 100644
--- a/openstack/networking/v2/extensions/fwaas/policies/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/policies/requests.go
@@ -6,6 +6,18 @@
"github.com/rackspace/gophercloud/pagination"
)
+// Binary gives users a solid type to work with for create and update
+// operations. It is recommended that users use the `Yes` and `No` enums
+type Binary *bool
+
+// Convenience vars for Audited and Shared values.
+var (
+ iTrue = true
+ iFalse = false
+ Yes Binary = &iTrue
+ No Binary = &iFalse
+)
+
type ListOpts struct {
TenantID string `q:"tenant_id"`
Name string `q:"name"`
diff --git a/openstack/networking/v2/extensions/fwaas/policies/requests_test.go b/openstack/networking/v2/extensions/fwaas/policies/requests_test.go
index 3dbaddb..dda393c 100644
--- a/openstack/networking/v2/extensions/fwaas/policies/requests_test.go
+++ b/openstack/networking/v2/extensions/fwaas/policies/requests_test.go
@@ -150,15 +150,12 @@
`)
})
- shared := false
- audited := true
-
options := CreateOpts{
TenantID: "9145d91459d248b1b02fdaca97c6a75d",
Name: "policy",
Description: "Firewall policy",
- Shared: &shared,
- Audited: &audited,
+ Shared: No,
+ Audited: Yes,
Rules: []string{
"98a58c87-76be-ae7c-a74e-b77fffb88d95",
"11a58c87-76be-ae7c-a74e-b77fffb88a32",
diff --git a/openstack/networking/v2/extensions/fwaas/rules/requests.go b/openstack/networking/v2/extensions/fwaas/rules/requests.go
index 18690b7..18e37ad 100644
--- a/openstack/networking/v2/extensions/fwaas/rules/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/rules/requests.go
@@ -6,6 +6,18 @@
"github.com/rackspace/gophercloud/pagination"
)
+// Binary gives users a solid type to work with for create and update
+// operations. It is recommended that users use the `Yes` and `No` enums
+type Binary *bool
+
+// Convenience vars for Enabled and Shared values.
+var (
+ iTrue = true
+ iFalse = false
+ Yes Binary = &iTrue
+ No Binary = &iFalse
+)
+
// 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
diff --git a/openstack/networking/v2/extensions/fwaas/rules/requests_test.go b/openstack/networking/v2/extensions/fwaas/rules/requests_test.go
index 91dcaf7..dee7327 100644
--- a/openstack/networking/v2/extensions/fwaas/rules/requests_test.go
+++ b/openstack/networking/v2/extensions/fwaas/rules/requests_test.go
@@ -261,7 +261,8 @@
"source_ip_address": null,
"source_port": null,
"name": "ssh_form_any",
- "action": "allow"
+ "action": "allow",
+ "enabled": false
}
}
`)
@@ -283,7 +284,7 @@
"id": "f03bd950-6c56-4f5e-a307-45967078f507",
"name": "ssh_form_any",
"tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61",
- "enabled": true,
+ "enabled": false,
"action": "allow",
"ip_version": 4,
"shared": false
@@ -307,6 +308,7 @@
SourceIPAddress: &empty,
SourcePort: &empty,
Action: "allow",
+ Enabled: No,
}
_, err := Update(fake.ServiceClient(), "f03bd950-6c56-4f5e-a307-45967078f507", options).Extract()