Skip to content

Commit 0164979

Browse files
committed
Import empty lists of bulk resources as null
1 parent b8c8421 commit 0164979

17 files changed

+72
-72
lines changed

gen/templates/bulk/model_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,13 +649,13 @@ func (data *Resource{{camelCase .BulkName}}) fromBodyImport(ctx context.Context,
649649
{{- end}}
650650
}
651651
{{- else if isListSet .}}
652-
if value := res.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); value.Exists() && value.Value() != nil {
652+
if value := res.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
653653
data.{{toGoName .TfName}} = helpers.Get{{.ElementType}}{{.Type}}(value.Array())
654654
} else {
655655
data.{{toGoName .TfName}} = types.{{.Type}}Null(types.{{.ElementType}}Type)
656656
}
657657
{{- else if isNestedListSetMap .}}
658-
if value := res{{if .ModelName}}.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"){{end}}; value.Exists() && value.Value() != nil {
658+
if value := res{{if .ModelName}}.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"){{end}}; value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
659659
{{- if isNestedMap .}}
660660
data.{{toGoName .TfName}} = make(map[string]Resource{{.GoTypeBulkName}})
661661
{{- else}}

internal/provider/model_resource_meraki_appliance_prefix_delegated_statics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func (data *ResourceAppliancePrefixDelegatedStatics) fromBodyImport(ctx context.
242242
} else {
243243
data.OriginType = types.StringNull()
244244
}
245-
if value := res.Get("origin.interfaces"); value.Exists() && value.Value() != nil {
245+
if value := res.Get("origin.interfaces"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
246246
data.OriginInterfaces = helpers.GetStringList(value.Array())
247247
} else {
248248
data.OriginInterfaces = types.ListNull(types.StringType)

internal/provider/model_resource_meraki_appliance_ssids.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ func (data *ResourceApplianceSSIDs) fromBodyImport(ctx context.Context, res mera
451451
} else {
452452
data.Dot11wRequired = types.BoolNull()
453453
}
454-
if value := res.Get("radiusServers"); value.Exists() && value.Value() != nil {
454+
if value := res.Get("radiusServers"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
455455
data.RadiusServers = make([]ResourceApplianceSSIDsRadiusServers, 0)
456456
value.ForEach(func(k, res gjson.Result) bool {
457457
parent := &data

internal/provider/model_resource_meraki_appliance_vlans.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ func (data *ResourceApplianceVLANs) fromBodyImport(ctx context.Context, res mera
860860
} else {
861861
data.VpnNatSubnet = types.StringNull()
862862
}
863-
if value := res.Get("fixedIpAssignments"); value.Exists() && value.Value() != nil {
863+
if value := res.Get("fixedIpAssignments"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
864864
data.FixedIpAssignments = make(map[string]ResourceApplianceVLANsFixedIpAssignments)
865865
value.ForEach(func(k, res gjson.Result) bool {
866866
parent := &data
@@ -884,7 +884,7 @@ func (data *ResourceApplianceVLANs) fromBodyImport(ctx context.Context, res mera
884884
} else {
885885
data.Ipv6Enabled = types.BoolNull()
886886
}
887-
if value := res.Get("ipv6.prefixAssignments"); value.Exists() && value.Value() != nil {
887+
if value := res.Get("ipv6.prefixAssignments"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
888888
data.Ipv6PrefixAssignments = make([]ResourceApplianceVLANsIpv6PrefixAssignments, 0)
889889
value.ForEach(func(k, res gjson.Result) bool {
890890
parent := &data
@@ -909,7 +909,7 @@ func (data *ResourceApplianceVLANs) fromBodyImport(ctx context.Context, res mera
909909
} else {
910910
data.OriginType = types.StringNull()
911911
}
912-
if value := res.Get("origin.interfaces"); value.Exists() && value.Value() != nil {
912+
if value := res.Get("origin.interfaces"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
913913
data.OriginInterfaces = helpers.GetStringList(value.Array())
914914
} else {
915915
data.OriginInterfaces = types.ListNull(types.StringType)
@@ -923,7 +923,7 @@ func (data *ResourceApplianceVLANs) fromBodyImport(ctx context.Context, res mera
923923
} else {
924924
data.MandatoryDhcpEnabled = types.BoolNull()
925925
}
926-
if value := res.Get("dhcpOptions"); value.Exists() && value.Value() != nil {
926+
if value := res.Get("dhcpOptions"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
927927
data.DhcpOptions = make([]ResourceApplianceVLANsDhcpOptions, 0)
928928
value.ForEach(func(k, res gjson.Result) bool {
929929
parent := &data
@@ -947,12 +947,12 @@ func (data *ResourceApplianceVLANs) fromBodyImport(ctx context.Context, res mera
947947
return true
948948
})
949949
}
950-
if value := res.Get("dhcpRelayServerIps"); value.Exists() && value.Value() != nil {
950+
if value := res.Get("dhcpRelayServerIps"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
951951
data.DhcpRelayServerIps = helpers.GetStringList(value.Array())
952952
} else {
953953
data.DhcpRelayServerIps = types.ListNull(types.StringType)
954954
}
955-
if value := res.Get("reservedIpRanges"); value.Exists() && value.Value() != nil {
955+
if value := res.Get("reservedIpRanges"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
956956
data.ReservedIpRanges = make([]ResourceApplianceVLANsReservedIpRanges, 0)
957957
value.ForEach(func(k, res gjson.Result) bool {
958958
parent := &data

internal/provider/model_resource_meraki_network_group_policies.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
12001200
} else {
12011201
data.BonjourForwardingSettings = types.StringNull()
12021202
}
1203-
if value := res.Get("bonjourForwarding.rules"); value.Exists() && value.Value() != nil {
1203+
if value := res.Get("bonjourForwarding.rules"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
12041204
data.BonjourForwardingRules = make([]ResourceNetworkGroupPoliciesBonjourForwardingRules, 0)
12051205
value.ForEach(func(k, res gjson.Result) bool {
12061206
parent := &data
@@ -1215,7 +1215,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
12151215
} else {
12161216
data.VlanId = types.StringNull()
12171217
}
1218-
if value := res.Get("services"); value.Exists() && value.Value() != nil {
1218+
if value := res.Get("services"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
12191219
data.Services = helpers.GetStringSet(value.Array())
12201220
} else {
12211221
data.Services = types.SetNull(types.StringType)
@@ -1229,7 +1229,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
12291229
} else {
12301230
data.ContentFilteringAllowedUrlPatternsSettings = types.StringNull()
12311231
}
1232-
if value := res.Get("contentFiltering.allowedUrlPatterns.patterns"); value.Exists() && value.Value() != nil {
1232+
if value := res.Get("contentFiltering.allowedUrlPatterns.patterns"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
12331233
data.ContentFilteringAllowedUrlPatterns = helpers.GetStringSet(value.Array())
12341234
} else {
12351235
data.ContentFilteringAllowedUrlPatterns = types.SetNull(types.StringType)
@@ -1239,7 +1239,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
12391239
} else {
12401240
data.ContentFilteringBlockedUrlCategoriesSettings = types.StringNull()
12411241
}
1242-
if value := res.Get("contentFiltering.blockedUrlCategories.categories"); value.Exists() && value.Value() != nil {
1242+
if value := res.Get("contentFiltering.blockedUrlCategories.categories"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
12431243
data.ContentFilteringBlockedUrlCategories = helpers.GetStringSet(value.Array())
12441244
} else {
12451245
data.ContentFilteringBlockedUrlCategories = types.SetNull(types.StringType)
@@ -1249,7 +1249,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
12491249
} else {
12501250
data.ContentFilteringBlockedUrlPatternsSettings = types.StringNull()
12511251
}
1252-
if value := res.Get("contentFiltering.blockedUrlPatterns.patterns"); value.Exists() && value.Value() != nil {
1252+
if value := res.Get("contentFiltering.blockedUrlPatterns.patterns"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
12531253
data.ContentFilteringBlockedUrlPatterns = helpers.GetStringSet(value.Array())
12541254
} else {
12551255
data.ContentFilteringBlockedUrlPatterns = types.SetNull(types.StringType)
@@ -1259,7 +1259,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
12591259
} else {
12601260
data.FirewallAndTrafficShapingSettings = types.StringNull()
12611261
}
1262-
if value := res.Get("firewallAndTrafficShaping.l3FirewallRules"); value.Exists() && value.Value() != nil {
1262+
if value := res.Get("firewallAndTrafficShaping.l3FirewallRules"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
12631263
data.L3FirewallRules = make([]ResourceNetworkGroupPoliciesL3FirewallRules, 0)
12641264
value.ForEach(func(k, res gjson.Result) bool {
12651265
parent := &data
@@ -1293,7 +1293,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
12931293
return true
12941294
})
12951295
}
1296-
if value := res.Get("firewallAndTrafficShaping.l7FirewallRules"); value.Exists() && value.Value() != nil {
1296+
if value := res.Get("firewallAndTrafficShaping.l7FirewallRules"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
12971297
data.L7FirewallRules = make([]ResourceNetworkGroupPoliciesL7FirewallRules, 0)
12981298
value.ForEach(func(k, res gjson.Result) bool {
12991299
parent := &data
@@ -1317,7 +1317,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
13171317
return true
13181318
})
13191319
}
1320-
if value := res.Get("firewallAndTrafficShaping.trafficShapingRules"); value.Exists() && value.Value() != nil {
1320+
if value := res.Get("firewallAndTrafficShaping.trafficShapingRules"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
13211321
data.TrafficShapingRules = make([]ResourceNetworkGroupPoliciesTrafficShapingRules, 0)
13221322
value.ForEach(func(k, res gjson.Result) bool {
13231323
parent := &data
@@ -1347,7 +1347,7 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re
13471347
} else {
13481348
data.PerClientBandwidthLimitsBandwidthLimitsLimitUp = types.Int64Null()
13491349
}
1350-
if value := res.Get("definitions"); value.Exists() && value.Value() != nil {
1350+
if value := res.Get("definitions"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
13511351
data.Definitions = make([]ResourceNetworkGroupPoliciesTrafficShapingRulesDefinitions, 0)
13521352
value.ForEach(func(k, res gjson.Result) bool {
13531353
parent := &data

internal/provider/model_resource_meraki_network_meraki_auth_users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func (data *ResourceNetworkMerakiAuthUsers) fromBodyImport(ctx context.Context,
339339
} else {
340340
data.Name = types.StringNull()
341341
}
342-
if value := res.Get("authorizations"); value.Exists() && value.Value() != nil {
342+
if value := res.Get("authorizations"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
343343
data.Authorizations = make([]ResourceNetworkMerakiAuthUsersAuthorizations, 0)
344344
value.ForEach(func(k, res gjson.Result) bool {
345345
parent := &data

internal/provider/model_resource_meraki_network_webhook_payload_templates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func (data *ResourceNetworkWebhookPayloadTemplates) fromBodyImport(ctx context.C
330330
} else {
331331
data.Name = types.StringNull()
332332
}
333-
if value := res.Get("headers"); value.Exists() && value.Value() != nil {
333+
if value := res.Get("headers"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
334334
data.Headers = make([]ResourceNetworkWebhookPayloadTemplatesHeaders, 0)
335335
value.ForEach(func(k, res gjson.Result) bool {
336336
parent := &data

internal/provider/model_resource_meraki_organization_adaptive_policies.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (data *ResourceOrganizationAdaptivePolicies) fromBodyImport(ctx context.Con
362362
} else {
363363
data.SourceGroupSgt = types.Int64Null()
364364
}
365-
if value := res.Get("acls"); value.Exists() && value.Value() != nil {
365+
if value := res.Get("acls"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
366366
data.Acls = make([]ResourceOrganizationAdaptivePoliciesAcls, 0)
367367
value.ForEach(func(k, res gjson.Result) bool {
368368
parent := &data

internal/provider/model_resource_meraki_organization_adaptive_policy_groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (data *ResourceOrganizationAdaptivePolicyGroups) fromBodyImport(ctx context
310310
} else {
311311
data.Sgt = types.Int64Null()
312312
}
313-
if value := res.Get("policyObjects"); value.Exists() && value.Value() != nil {
313+
if value := res.Get("policyObjects"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
314314
data.PolicyObjects = make([]ResourceOrganizationAdaptivePolicyGroupsPolicyObjects, 0)
315315
value.ForEach(func(k, res gjson.Result) bool {
316316
parent := &data

internal/provider/model_resource_meraki_organization_policy_object_groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (data *ResourceOrganizationPolicyObjectGroups) fromBodyImport(ctx context.C
222222
} else {
223223
data.Name = types.StringNull()
224224
}
225-
if value := res.Get("objectIds"); value.Exists() && value.Value() != nil {
225+
if value := res.Get("objectIds"); value.Exists() && value.Value() != nil && len(value.Array()) > 0 {
226226
data.ObjectIds = helpers.GetInt64Set(value.Array())
227227
} else {
228228
data.ObjectIds = types.SetNull(types.Int64Type)

0 commit comments

Comments
 (0)