Skip to content

Commit

Permalink
Merge pull request #1602 from okta/OKTA-618789-network-zone-status
Browse files Browse the repository at this point in the history
add status to network zone
  • Loading branch information
duytiennguyen-okta authored Jun 26, 2023
2 parents 6d060c1 + 5d7fe5a commit 6134bfe
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/okta_network_zone/basic.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
resource "okta_network_zone" "ip_network_zone_example" {
name = "testAcc_replace_with_uuid"
type = "IP"
status = "ACTIVE"
gateways = ["1.2.3.4/24", "2.3.4.5-2.3.4.15"]
proxies = ["2.2.3.4/24", "3.3.4.5-3.3.4.15"]
}

resource "okta_network_zone" "dynamic_network_zone_example" {
name = "testAcc_replace_with_uuid Dynamic"
type = "DYNAMIC"
status = "ACTIVE"
dynamic_locations = ["US", "AF-BGL"]
}

resource "okta_network_zone" "dynamic_proxy_example" {
name = "testAcc_replace_with_uuid Dynamic Proxy"
type = "DYNAMIC"
status = "ACTIVE"
usage = "BLOCKLIST"
dynamic_proxy_type = "TorAnonymizer"
}
3 changes: 3 additions & 0 deletions examples/okta_network_zone/basic_updated.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
resource "okta_network_zone" "ip_network_zone_example" {
name = "testAcc_replace_with_uuid Updated"
type = "IP"
status = "INACTIVE"
gateways = ["1.2.3.4/24", "2.3.4.5-2.3.4.10"]
usage = "BLOCKLIST"
}

resource "okta_network_zone" "dynamic_network_zone_example" {
name = "testAcc_replace_with_uuid Dynamic Updated"
type = "DYNAMIC"
status = "INACTIVE"
dynamic_locations = ["US", "AF-BGL", "UA-26"]
asns = ["2232"]
}

resource "okta_network_zone" "dynamic_proxy_example" {
name = "testAcc_replace_with_uuid Dynamic Proxy Updated"
type = "DYNAMIC"
status = "INACTIVE"
usage = "POLICY"
dynamic_proxy_type = "NotTorAnonymizer"
}
6 changes: 6 additions & 0 deletions okta/data_source_okta_network_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func dataSourceNetworkZone() *schema.Resource {
Description: "Format of each array value: a string representation of an ASN numeric value",
Elem: &schema.Schema{Type: schema.TypeString},
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: "Network Status - can either be ACTIVE or INACTIVE only",
},
},
}
}
Expand All @@ -87,6 +92,7 @@ func dataSourceNetworkZoneRead(ctx context.Context, d *schema.ResourceData, m in
d.SetId(zone.Id)
_ = d.Set("name", zone.Name)
_ = d.Set("type", zone.Type)
_ = d.Set("status", zone.Status)
_ = d.Set("usage", zone.Usage)
_ = d.Set("dynamic_proxy_type", zone.ProxyType)
_ = d.Set("asns", convertStringSliceToSetNullable(zone.Asns))
Expand Down
13 changes: 11 additions & 2 deletions okta/resource_okta_network_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func resourceNetworkZone() *schema.Resource {
Required: true,
Description: "Type of the Network Zone - can either be IP or DYNAMIC only",
},
"status": {
Type: schema.TypeString,
Optional: true,
Description: "Network Status - can either be ACTIVE or INACTIVE only",
},
"usage": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -93,6 +98,7 @@ func resourceNetworkZoneRead(ctx context.Context, d *schema.ResourceData, m inte
}
_ = d.Set("name", zone.Name)
_ = d.Set("type", zone.Type)
_ = d.Set("status", zone.Status)
_ = d.Set("usage", zone.Usage)
_ = d.Set("dynamic_proxy_type", zone.ProxyType)
_ = d.Set("asns", convertStringSliceToSetNullable(zone.Asns))
Expand Down Expand Up @@ -149,8 +155,7 @@ func buildNetworkZone(d *schema.ResourceData) sdk.NetworkZone {
}
}
}

return sdk.NetworkZone{
networkZone := sdk.NetworkZone{
Asns: convertInterfaceToStringSetNullable(d.Get("asns")),
Name: d.Get("name").(string),
Type: zoneType,
Expand All @@ -160,6 +165,10 @@ func buildNetworkZone(d *schema.ResourceData) sdk.NetworkZone {
ProxyType: proxyType,
Usage: d.Get("usage").(string),
}
if status, ok := d.GetOk("status"); ok {
networkZone.Status = status.(string)
}
return networkZone
}

func buildAddressObjList(values *schema.Set) []*sdk.NetworkZoneAddress {
Expand Down
2 changes: 2 additions & 0 deletions okta/resource_okta_network_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestAccOktaNetworkZone_crud(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", buildResourceName(mgr.Seed)),
resource.TestCheckResourceAttr(resourceName, "type", "IP"),
resource.TestCheckResourceAttr(resourceName, "status", "ACTIVE"),
resource.TestCheckResourceAttr(resourceName, "proxies.#", "2"),
resource.TestCheckResourceAttr(resourceName, "gateways.#", "2"),
resource.TestCheckResourceAttr(resourceName, "usage", "POLICY"),
Expand All @@ -39,6 +40,7 @@ func TestAccOktaNetworkZone_crud(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", fmt.Sprintf("testAcc_%d Updated", mgr.Seed)),
resource.TestCheckResourceAttr(resourceName, "type", "IP"),
resource.TestCheckResourceAttr(resourceName, "status", "INACTIVE"),
resource.TestCheckResourceAttr(resourceName, "proxies.#", "0"),
resource.TestCheckResourceAttr(resourceName, "gateways.#", "2"),
resource.TestCheckResourceAttr(resourceName, "usage", "BLOCKLIST"),
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/network_zone.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ data "okta_network_zone" "example" {

- `type` - Type of the Network Zone.

- `status` - Network Status - can either be ACTIVE or INACTIVE only.

- `dynamic_locations` - Array of locations.

- `dynamic_proxy_type` - Type of proxy being controlled by this dynamic network zone.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/network_zone.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ The following arguments are supported:

- `type` - (Required) Type of the Network Zone - can either be `"IP"` or `"DYNAMIC"` only.

- `status` - (Optional) Network Status - can either be ACTIVE or INACTIVE only.

- `dynamic_locations` - (Optional) Array of locations [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
and [ISO-3166-2](https://en.wikipedia.org/wiki/ISO_3166-2). Format code: countryCode OR countryCode-regionCode.

Expand Down

0 comments on commit 6134bfe

Please sign in to comment.