Skip to content

Commit 2acb4f2

Browse files
authored
fix: Fixed zia_file_type_control_rules url_categories attribute (#449)
* fix: Fixed and Applied Codex best practices
1 parent ff00537 commit 2acb4f2

File tree

73 files changed

+653
-629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+653
-629
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 4.3.3 (June, 30 2025)
4+
5+
### Notes
6+
7+
- Release date: **(June, 30 2025)**
8+
- Supported Terraform version: **v1.x**
9+
10+
### Bug Fixes
11+
12+
- [PR #449](https://github.com/zscaler/terraform-provider-zia/pull/449) - Fixed attribute `url_categories` in `zia_file_type_control_rules` expanding function.
13+
314
## 4.3.2 (June, 23 2025)
415

516
### Notes

GNUmakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ test\:integration\:zscalertwo:
196196
build13: GOOS=$(shell go env GOOS)
197197
build13: GOARCH=$(shell go env GOARCH)
198198
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
199-
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/4.3.2/$(GOOS)_$(GOARCH)
199+
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/4.3.3/$(GOOS)_$(GOARCH)
200200
else
201-
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/4.3.2/$(GOOS)_$(GOARCH)
201+
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/4.3.3/$(GOOS)_$(GOARCH)
202202
endif
203203
build13: fmtcheck
204204
@echo "==> Installing plugin to $(DESTINATION)"
205205
@mkdir -p $(DESTINATION)
206-
go build -o $(DESTINATION)/terraform-provider-zia_v4.3.2
206+
go build -o $(DESTINATION)/terraform-provider-zia_v4.3.3
207207

208208
coverage: test
209209
@echo "✓ Opening coverage for unit tests ..."

cli/ziaActivator.go

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package main
22

3-
/*
43
import (
4+
"context"
55
"fmt"
66
"log"
77
"os"
88
"runtime"
9+
"strings"
910

10-
client "github.com/zscaler/zscaler-sdk-go/v2/zia"
11-
"github.com/zscaler/zscaler-sdk-go/v2/zia/services"
12-
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/activation"
11+
"github.com/zscaler/zscaler-sdk-go/v3/zscaler"
12+
"github.com/zscaler/zscaler-sdk-go/v3/zscaler/zia"
13+
"github.com/zscaler/zscaler-sdk-go/v3/zscaler/zia/services/activation"
1314
)
1415

1516
func getEnvVarOrFail(k string) string {
@@ -21,34 +22,79 @@ func getEnvVarOrFail(k string) string {
2122
}
2223

2324
func main() {
24-
log.Printf("[INFO] Initializing ZIA client\n")
25-
26-
// Here, rather than setting up the client configuration from the external library,
27-
// we'll simply gather the required details for initializing the client
28-
username := getEnvVarOrFail("ZIA_USERNAME")
29-
password := getEnvVarOrFail("ZIA_PASSWORD")
30-
apiKey := getEnvVarOrFail("ZIA_API_KEY")
31-
ziaCloud := getEnvVarOrFail("ZIA_CLOUD")
32-
userAgent := fmt.Sprintf("(%s %s) cli/ziaActivator", runtime.GOOS, runtime.GOARCH)
33-
34-
// Now, we'll use the local SDK's NewClient method to get the client instance
35-
cli, err := client.NewClient(username, password, apiKey, ziaCloud, userAgent)
36-
if err != nil {
37-
log.Fatalf("[ERROR] Failed Initializing ZIA client: %v\n", err)
25+
log.Printf("[INFO] Initializing ZIA activation client")
26+
27+
useLegacy := strings.ToLower(os.Getenv("ZSCALER_USE_LEGACY_CLIENT")) == "true"
28+
29+
var (
30+
service *zscaler.Service
31+
err error
32+
)
33+
34+
if useLegacy {
35+
log.Printf("[INFO] Using Legacy Client mode")
36+
37+
username := getEnvVarOrFail("ZIA_USERNAME")
38+
password := getEnvVarOrFail("ZIA_PASSWORD")
39+
apiKey := getEnvVarOrFail("ZIA_API_KEY")
40+
cloud := getEnvVarOrFail("ZIA_CLOUD")
41+
42+
ziaCfg, err := zia.NewConfiguration(
43+
zia.WithZiaUsername(username),
44+
zia.WithZiaPassword(password),
45+
zia.WithZiaAPIKey(apiKey),
46+
zia.WithZiaCloud(cloud),
47+
zia.WithUserAgent(fmt.Sprintf("(%s %s) cli/ziaActivator", runtime.GOOS, runtime.GOARCH)),
48+
)
49+
if err != nil {
50+
log.Fatalf("Error creating ZIA configuration: %v", err)
51+
}
52+
53+
service, err = zscaler.NewLegacyZiaClient(ziaCfg)
54+
if err != nil {
55+
log.Fatalf("Error creating ZIA legacy client: %v", err)
56+
}
57+
} else {
58+
log.Printf("[INFO] Using OneAPI Client mode")
59+
60+
clientID := getEnvVarOrFail("ZSCALER_CLIENT_ID")
61+
clientSecret := getEnvVarOrFail("ZSCALER_CLIENT_SECRET")
62+
vanityDomain := getEnvVarOrFail("ZSCALER_VANITY_DOMAIN")
63+
cloud := getEnvVarOrFail("ZSCALER_CLOUD")
64+
65+
cfg, err := zscaler.NewConfiguration(
66+
zscaler.WithClientID(clientID),
67+
zscaler.WithClientSecret(clientSecret),
68+
zscaler.WithVanityDomain(vanityDomain),
69+
zscaler.WithZscalerCloud(cloud),
70+
zscaler.WithUserAgentExtra(fmt.Sprintf("(%s %s) cli/ziaActivator", runtime.GOOS, runtime.GOARCH)),
71+
)
72+
if err != nil {
73+
log.Fatalf("[ERROR] Failed to build OneAPI configuration: %v", err)
74+
}
75+
76+
service, err = zscaler.NewOneAPIClient(cfg)
77+
if err != nil {
78+
log.Fatalf("[ERROR] Failed to initialize OneAPI client: %v", err)
79+
}
3880
}
3981

40-
service := services.New(cli)
41-
resp, err := activation.CreateActivation(service, activation.Activation{
42-
Status: "active",
82+
ctx := context.Background()
83+
84+
resp, err := activation.CreateActivation(ctx, service, activation.Activation{
85+
Status: "ACTIVE",
4386
})
4487
if err != nil {
45-
log.Printf("[ERROR] Activation Failed: %v\n", err)
46-
} else {
47-
log.Printf("[INFO] Activation succeeded: %#v\n", resp)
88+
log.Fatalf("[ERROR] Activation Failed: %v", err)
4889
}
4990

50-
log.Printf("[INFO] Destroying session: %#v\n", resp)
51-
_ = cli.Logout()
52-
os.Exit(0)
91+
log.Printf("[INFO] Activation succeeded: %#v\n", resp)
92+
93+
// Perform logout if using Legacy Client
94+
if useLegacy && service.LegacyClient != nil && service.LegacyClient.ZiaClient != nil {
95+
log.Printf("[INFO] Destroying session...\n")
96+
if err := service.LegacyClient.ZiaClient.Logout(ctx); err != nil {
97+
log.Printf("[WARN] Logout failed: %v\n", err)
98+
}
99+
}
53100
}
54-
*/

docs/guides/release-notes.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,21 @@ description: |-
1212
Track all ZIA Terraform provider's releases. New resources, features, and bug fixes will be tracked here.
1313

1414
---
15-
``Last updated: v4.3.2``
15+
``Last updated: v4.3.3``
1616

1717
---
1818

19+
## 4.3.3 (June, 30 2025)
20+
21+
### Notes
22+
23+
- Release date: **(June, 30 2025)**
24+
- Supported Terraform version: **v1.x**
25+
26+
### Bug Fixes
27+
28+
- [PR #449](https://github.com/zscaler/terraform-provider-zia/pull/449) - Fixed attribute `url_categories` in `zia_file_type_control_rules` expanding function.
29+
1930
## 4.3.2 (June, 23 2025)
2031

2132
### Notes

docs/guides/zia_activator.md

Lines changed: 96 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,104 @@ subcategory: "Activation"
88
# ZIA Activator Configuration
99

1010
```go
11-
package main
12-
13-
import (
14-
"fmt"
15-
"log"
16-
"os"
17-
"runtime"
18-
19-
client "github.com/zscaler/zscaler-sdk-go/v2/zia"
20-
"github.com/zscaler/zscaler-sdk-go/v2/zia/services"
21-
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/activation"
22-
)
23-
24-
func getEnvVarOrFail(k string) string {
25-
if v := os.Getenv(k); v != "" {
26-
return v
27-
}
28-
log.Fatalf("[ERROR] Couldn't find environment variable %s\n", k)
29-
return ""
30-
}
31-
32-
func main() {
33-
log.Printf("[INFO] Initializing ZIA client\n")
34-
35-
// Here, rather than setting up the client configuration from the external library,
36-
// we'll simply gather the required details for initializing the client
37-
username := getEnvVarOrFail("ZIA_USERNAME")
38-
password := getEnvVarOrFail("ZIA_PASSWORD")
39-
apiKey := getEnvVarOrFail("ZIA_API_KEY")
40-
ziaCloud := getEnvVarOrFail("ZIA_CLOUD")
41-
userAgent := fmt.Sprintf("(%s %s) cli/ziaActivator", runtime.GOOS, runtime.GOARCH)
42-
43-
// Now, we'll use the local SDK's NewClient method to get the client instance
44-
cli, err := client.NewClient(username, password, apiKey, ziaCloud, userAgent)
45-
if err != nil {
46-
log.Fatalf("[ERROR] Failed Initializing ZIA client: %v\n", err)
11+
package main
12+
13+
import (
14+
"context"
15+
"fmt"
16+
"log"
17+
"os"
18+
"runtime"
19+
"strings"
20+
21+
"github.com/zscaler/zscaler-sdk-go/v3/zscaler"
22+
"github.com/zscaler/zscaler-sdk-go/v3/zscaler/zia"
23+
"github.com/zscaler/zscaler-sdk-go/v3/zscaler/zia/services/activation"
24+
)
25+
26+
func getEnvVarOrFail(k string) string {
27+
if v := os.Getenv(k); v != "" {
28+
return v
29+
}
30+
log.Fatalf("[ERROR] Couldn't find environment variable %s\n", k)
31+
return ""
4732
}
4833

49-
service := services.New(cli)
50-
resp, err := activation.CreateActivation(service, activation.Activation{
51-
Status: "active",
52-
})
53-
if err != nil {
54-
log.Printf("[ERROR] Activation Failed: %v\n", err)
55-
} else {
34+
func main() {
35+
log.Printf("[INFO] Initializing ZIA activation client")
36+
37+
useLegacy := strings.ToLower(os.Getenv("ZSCALER_USE_LEGACY_CLIENT")) == "true"
38+
39+
var (
40+
service *zscaler.Service
41+
err error
42+
)
43+
44+
if useLegacy {
45+
log.Printf("[INFO] Using Legacy Client mode")
46+
47+
username := getEnvVarOrFail("ZIA_USERNAME")
48+
password := getEnvVarOrFail("ZIA_PASSWORD")
49+
apiKey := getEnvVarOrFail("ZIA_API_KEY")
50+
cloud := getEnvVarOrFail("ZIA_CLOUD")
51+
52+
ziaCfg, err := zia.NewConfiguration(
53+
zia.WithZiaUsername(username),
54+
zia.WithZiaPassword(password),
55+
zia.WithZiaAPIKey(apiKey),
56+
zia.WithZiaCloud(cloud),
57+
zia.WithUserAgent(fmt.Sprintf("(%s %s) cli/ziaActivator", runtime.GOOS, runtime.GOARCH)),
58+
)
59+
if err != nil {
60+
log.Fatalf("Error creating ZIA configuration: %v", err)
61+
}
62+
63+
service, err = zscaler.NewLegacyZiaClient(ziaCfg)
64+
if err != nil {
65+
log.Fatalf("Error creating ZIA legacy client: %v", err)
66+
}
67+
} else {
68+
log.Printf("[INFO] Using OneAPI Client mode")
69+
70+
clientID := getEnvVarOrFail("ZSCALER_CLIENT_ID")
71+
clientSecret := getEnvVarOrFail("ZSCALER_CLIENT_SECRET")
72+
vanityDomain := getEnvVarOrFail("ZSCALER_VANITY_DOMAIN")
73+
cloud := getEnvVarOrFail("ZSCALER_CLOUD")
74+
75+
cfg, err := zscaler.NewConfiguration(
76+
zscaler.WithClientID(clientID),
77+
zscaler.WithClientSecret(clientSecret),
78+
zscaler.WithVanityDomain(vanityDomain),
79+
zscaler.WithZscalerCloud(cloud),
80+
zscaler.WithUserAgentExtra(fmt.Sprintf("(%s %s) cli/ziaActivator", runtime.GOOS, runtime.GOARCH)),
81+
)
82+
if err != nil {
83+
log.Fatalf("[ERROR] Failed to build OneAPI configuration: %v", err)
84+
}
85+
86+
service, err = zscaler.NewOneAPIClient(cfg)
87+
if err != nil {
88+
log.Fatalf("[ERROR] Failed to initialize OneAPI client: %v", err)
89+
}
90+
}
91+
92+
ctx := context.Background()
93+
94+
resp, err := activation.CreateActivation(ctx, service, activation.Activation{
95+
Status: "ACTIVE",
96+
})
97+
if err != nil {
98+
log.Fatalf("[ERROR] Activation Failed: %v", err)
99+
}
100+
56101
log.Printf("[INFO] Activation succeeded: %#v\n", resp)
57-
}
58102

59-
log.Printf("[INFO] Destroying session: %#v\n", resp)
60-
_ = cli.Logout()
61-
os.Exit(0)
62-
}
103+
// Perform logout if using Legacy Client
104+
if useLegacy && service.LegacyClient != nil && service.LegacyClient.ZiaClient != nil {
105+
log.Printf("[INFO] Destroying session...\n")
106+
if err := service.LegacyClient.ZiaClient.Logout(ctx); err != nil {
107+
log.Printf("[WARN] Logout failed: %v\n", err)
108+
}
109+
}
110+
}
63111
```

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ Before starting with this Terraform provider you must create an API Client in th
268268

269269
* `http_proxy` - (Optional) This is a custom URL endpoint that can be used for unit testing or local caching proxies. Can also be sourced from the `ZSCALER_HTTP_PROXY` environment variable.
270270

271-
* `parallelism` - (Optional) Number of concurrent requests to make within a resource where bulk operations are not possible. [Learn More](https://help.zscaler.com/oneapi/understanding-rate-limiting)
271+
* `parallelism` - (Optional) Number of concurrent requests to make within a resource where bulk operations are not possible. The provider creates a worker pool of this size to serialize API calls. The default is `1`. [Learn More](https://help.zscaler.com/oneapi/understanding-rate-limiting)
272272

273273
* `max_retries` - (Optional) Maximum number of retries to attempt before returning an error, the default is `5`.
274274

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/hashicorp/go-hclog v1.6.3
99
github.com/hashicorp/terraform-plugin-sdk v1.17.2
1010
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
11-
github.com/zscaler/zscaler-sdk-go/v3 v3.5.1
11+
github.com/zscaler/zscaler-sdk-go/v3 v3.5.2
1212
)
1313

1414
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRK
394394
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
395395
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
396396
github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
397-
github.com/zscaler/zscaler-sdk-go/v3 v3.5.1 h1:nGlfRQu2YFJFi/9ibgqfVGz5riX+DhlqRBxQ1ypVkqk=
398-
github.com/zscaler/zscaler-sdk-go/v3 v3.5.1/go.mod h1:QyWbdooucR7zkSJNz/Yp+PzZa/wrbhQr2xmAJJkUziY=
397+
github.com/zscaler/zscaler-sdk-go/v3 v3.5.2 h1:gjIQDlDbM8JRiPaESXjgxpg51gQ34Jn0SQKbRm4DDbY=
398+
github.com/zscaler/zscaler-sdk-go/v3 v3.5.2/go.mod h1:QyWbdooucR7zkSJNz/Yp+PzZa/wrbhQr2xmAJJkUziY=
399399
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
400400
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
401401
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func main() {
2020
if len(os.Args) > 1 && os.Args[1] == "debug" {
2121
debug = true
2222
}
23-
log.Printf(`ZPA Terraform Provider
23+
log.Printf(`ZIA Terraform Provider
2424
2525
Version %s
2626

scripts/changelog-links.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ else
2424
SED="sed -i.bak -r -e"
2525
fi
2626

27-
PROVIDER_URL="https:\/\/github.com\/willguibr\/terraform-provider-zia\/issues"
27+
PROVIDER_URL="https:\/\/github.com\/zscaler\/terraform-provider-zia\/issues"
2828

2929
$SED "s/GH-([0-9]+)/\[#\1\]\($PROVIDER_URL\/\1\)/g" -e 's/\[\[#(.+)([0-9])\)]$/(\[#\1\2))/g' CHANGELOG.md
3030

0 commit comments

Comments
 (0)