Skip to content

Commit

Permalink
Fix resources import by ID (#130)
Browse files Browse the repository at this point in the history
* fix resources import by ID

* remove comment
  • Loading branch information
amazzalel-habib authored Sep 26, 2022
1 parent b164e21 commit b865e61
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 51 deletions.
5 changes: 2 additions & 3 deletions zia/resource_zia_admin_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ func resourceAdminUsers() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("admin_id", id)
_ = d.Set("admin_id", idInt)
} else {
resp, err := zClient.adminuserrolemgmt.GetAdminUsersByLoginName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_dlp_dictionaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ func resourceDLPDictionaries() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("dictionary_id", id)
_ = d.Set("dictionary_id", idInt)
} else {
resp, err := zClient.dlpdictionaries.GetByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_dlp_notification_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ func resourceDLPNotificationTemplates() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("template_id", id)
_ = d.Set("template_id", idInt)
} else {
resp, err := zClient.dlp_notification_templates.GetByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_dlp_web_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceDlpWebRules() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("rule_id", id)
_ = d.Set("rule_id", idInt)
} else {
resp, err := zClient.dlp_web_rules.GetByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_firewall_filtering_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceFirewallFilteringRules() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("rule_id", id)
_ = d.Set("rule_id", idInt)
} else {
resp, err := zClient.filteringrules.GetByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_fw_filtering_ip_destination_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceFWIPDestinationGroups() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("ip_destination_id", id)
_ = d.Set("ip_destination_id", idInt)
} else {
resp, err := zClient.ipdestinationgroups.GetByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_fw_filtering_ip_source_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceFWIPSourceGroups() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("ip_source_group_id", id)
_ = d.Set("ip_source_group_id", idInt)
} else {
resp, err := zClient.ipsourcegroups.GetByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_fw_filtering_network_application_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceFWNetworkApplicationGroups() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("app_id", id)
_ = d.Set("app_id", idInt)
} else {
resp, err := zClient.networkapplications.GetNetworkApplicationGroupsByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_fw_filtering_network_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceFWNetworkServices() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("network_service_id", id)
_ = d.Set("network_service_id", idInt)
} else {
resp, err := zClient.networkservices.GetByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_fw_filtering_network_services_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceFWNetworkServiceGroups() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("network_service_group_id", id)
_ = d.Set("network_service_group_id", idInt)
} else {
resp, err := zClient.networkservices.GetNetworkServiceGroupsByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_location_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceLocationManagement() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("location_id", id)
_ = d.Set("location_id", idInt)
} else {
resp, err := zClient.locationmanagement.GetLocationByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_rule_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceRuleLabels() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("rule_label_id", id)
_ = d.Set("rule_label_id", idInt)
} else {
resp, err := zClient.rule_labels.GetRuleLabelByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_traffic_forwarding_static_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceTrafficForwardingStaticIP() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("static_ip_id", id)
_ = d.Set("static_ip_id", idInt)
} else {
resp, err := zClient.staticips.GetByIPAddress(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_traffic_forwarding_vpn_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceTrafficForwardingVPNCredentials() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("vpn_credental_id", id)
_ = d.Set("vpn_credental_id", idInt)
} else {
fqdn, err := zClient.vpncredentials.GetByFQDN(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_url_categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceURLCategories() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("url_category_id", id)
_ = d.Set("url_category_id", idInt)
} else {
resp, err := zClient.urlcategories.GetCustomURLCategories(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_url_filtering_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ func resourceURLFilteringRules() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("rule_id", id)
_ = d.Set("rule_id", idInt)
} else {
resp, err := zClient.urlfilteringpolicies.GetByName(id)
if err == nil {
Expand Down
5 changes: 2 additions & 3 deletions zia/resource_zia_user_management_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func resourceUserManagement() *schema.Resource {
zClient := m.(*Client)

id := d.Id()
_, parseIDErr := strconv.ParseInt(id, 10, 64)
idInt, parseIDErr := strconv.ParseInt(id, 10, 64)
if parseIDErr == nil {
// assume if the passed value is an int
_ = d.Set("user_id", id)
_ = d.Set("user_id", idInt)
} else {
resp, err := zClient.usermanagement.GetUserByName(id)
if err == nil {
Expand Down

0 comments on commit b865e61

Please sign in to comment.