Skip to content

Commit 9f1a416

Browse files
authored
[UX2.0] Resolve Import Issue (#486)
1 parent a45a9cc commit 9f1a416

File tree

77 files changed

+301
-230
lines changed

Some content is hidden

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

77 files changed

+301
-230
lines changed

gen/templates/profile_parcels/model.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,12 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
399399
data.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}}
400400
{{- end}}
401401
}
402+
{{- if ne .ConditionalAttribute.Name ""}}
403+
data.{{toGoName .ConditionalAttribute.Name}} = {{if eq .ConditionalAttribute.Type "Bool"}}types.BoolValue({{.ConditionalAttribute.Value}}){{else}}types.StringValue("{{.ConditionalAttribute.Value}}"){{end}}
404+
{{- end}}
402405
}
403406
{{- else if isNestedListSet .}}
404-
if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); value.Exists() {
407+
if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); value.Exists() && len(value.Array()) > 0 {
405408
data.{{toGoName .TfName}} = make([]{{$name}}{{toGoName .TfName}}, 0)
406409
value.ForEach(func(k, v gjson.Result) bool {
407410
item := {{$name}}{{toGoName .TfName}}{}
@@ -428,9 +431,12 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
428431
item.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}}
429432
{{- end}}
430433
}
434+
{{- if ne .ConditionalAttribute.Name ""}}
435+
item.{{toGoName .ConditionalAttribute.Name}} = {{if eq .ConditionalAttribute.Type "Bool"}}types.BoolValue({{.ConditionalAttribute.Value}}){{else}}types.StringValue("{{.ConditionalAttribute.Value}}"){{end}}
436+
{{- end}}
431437
}
432438
{{- else if isNestedListSet .}}
433-
if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); cValue.Exists() {
439+
if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); cValue.Exists() && len(cValue.Array()) > 0 {
434440
item.{{toGoName .TfName}} = make([]{{$name}}{{$cname}}{{toGoName .TfName}}, 0)
435441
cValue.ForEach(func(ck, cv gjson.Result) bool {
436442
cItem := {{$name}}{{$cname}}{{toGoName .TfName}}{}
@@ -456,9 +462,12 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
456462
cItem.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}}
457463
{{- end}}
458464
}
465+
{{- if ne .ConditionalAttribute.Name ""}}
466+
cItem.{{toGoName .ConditionalAttribute.Name}} = {{if eq .ConditionalAttribute.Type "Bool"}}types.BoolValue({{.ConditionalAttribute.Value}}){{else}}types.StringValue("{{.ConditionalAttribute.Value}}"){{end}}
467+
{{- end}}
459468
}
460469
{{- else if isNestedListSet .}}
461-
if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); ccValue.Exists() {
470+
if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); ccValue.Exists() && len(ccValue.Array()) > 0{
462471
cItem.{{toGoName .TfName}} = make([]{{$name}}{{$cname}}{{$ccname}}{{toGoName .TfName}}, 0)
463472
ccValue.ForEach(func(cck, ccv gjson.Result) bool {
464473
ccItem := {{$name}}{{$cname}}{{$ccname}}{{toGoName .TfName}}{}
@@ -484,24 +493,36 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
484493
ccItem.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}}
485494
{{- end}}
486495
}
496+
{{- if ne .ConditionalAttribute.Name ""}}
497+
ccItem.{{toGoName .ConditionalAttribute.Name}} = {{if eq .ConditionalAttribute.Type "Bool"}}types.BoolValue({{.ConditionalAttribute.Value}}){{else}}types.StringValue("{{.ConditionalAttribute.Value}}"){{end}}
498+
{{- end}}
487499
}
488500
{{- end}}
489501
{{- end}}
490502
cItem.{{toGoName .TfName}} = append(cItem.{{toGoName .TfName}}, ccItem)
491503
return true
492504
})
505+
{{- if ne .ConditionalAttribute.Name ""}}
506+
cItem.{{toGoName .ConditionalAttribute.Name}} = {{if eq .ConditionalAttribute.Type "Bool"}}types.BoolValue({{.ConditionalAttribute.Value}}){{else}}types.StringValue("{{.ConditionalAttribute.Value}}"){{end}}
507+
{{- end}}
493508
}
494509
{{- end}}
495510
{{- end}}
496511
item.{{toGoName .TfName}} = append(item.{{toGoName .TfName}}, cItem)
497512
return true
498513
})
514+
{{- if ne .ConditionalAttribute.Name ""}}
515+
item.{{toGoName .ConditionalAttribute.Name}} = {{if eq .ConditionalAttribute.Type "Bool"}}types.BoolValue({{.ConditionalAttribute.Value}}){{else}}types.StringValue("{{.ConditionalAttribute.Value}}"){{end}}
516+
{{- end}}
499517
}
500518
{{- end}}
501519
{{- end}}
502520
data.{{toGoName .TfName}} = append(data.{{toGoName .TfName}}, item)
503521
return true
504522
})
523+
{{- if ne .ConditionalAttribute.Name ""}}
524+
data.{{toGoName .ConditionalAttribute.Name}} = {{if eq .ConditionalAttribute.Type "Bool"}}types.BoolValue({{.ConditionalAttribute.Value}}){{else}}types.StringValue("{{.ConditionalAttribute.Value}}"){{end}}
525+
{{- end}}
505526
}
506527
{{- end}}
507528
{{- end}}

internal/provider/model_sdwan_application_priority_qos_policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (data *ApplicationPriorityQoS) fromBody(ctx context.Context, res gjson.Resu
148148
data.TargetInterface = helpers.GetStringSet(va.Array())
149149
}
150150
}
151-
if value := res.Get(path + "qosMap.qosSchedulers"); value.Exists() {
151+
if value := res.Get(path + "qosMap.qosSchedulers"); value.Exists() && len(value.Array()) > 0 {
152152
data.QosSchedulers = make([]ApplicationPriorityQoSQosSchedulers, 0)
153153
value.ForEach(func(k, v gjson.Result) bool {
154154
item := ApplicationPriorityQoSQosSchedulers{}

internal/provider/model_sdwan_application_priority_traffic_policy_policy.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ func (data *ApplicationPriorityTrafficPolicy) fromBody(ctx context.Context, res
797797
data.Direction = types.StringValue(va.String())
798798
}
799799
}
800-
if value := res.Get(path + "sequences"); value.Exists() {
800+
if value := res.Get(path + "sequences"); value.Exists() && len(value.Array()) > 0 {
801801
data.Sequences = make([]ApplicationPriorityTrafficPolicySequences, 0)
802802
value.ForEach(func(k, v gjson.Result) bool {
803803
item := ApplicationPriorityTrafficPolicySequences{}
@@ -833,7 +833,7 @@ func (data *ApplicationPriorityTrafficPolicy) fromBody(ctx context.Context, res
833833
item.Protocol = types.StringValue(va.String())
834834
}
835835
}
836-
if cValue := v.Get("match.entries"); cValue.Exists() {
836+
if cValue := v.Get("match.entries"); cValue.Exists() && len(cValue.Array()) > 0 {
837837
item.MatchEntries = make([]ApplicationPriorityTrafficPolicySequencesMatchEntries, 0)
838838
cValue.ForEach(func(ck, cv gjson.Result) bool {
839839
cItem := ApplicationPriorityTrafficPolicySequencesMatchEntries{}
@@ -1041,11 +1041,11 @@ func (data *ApplicationPriorityTrafficPolicy) fromBody(ctx context.Context, res
10411041
return true
10421042
})
10431043
}
1044-
if cValue := v.Get("actions"); cValue.Exists() {
1044+
if cValue := v.Get("actions"); cValue.Exists() && len(cValue.Array()) > 0 {
10451045
item.Actions = make([]ApplicationPriorityTrafficPolicySequencesActions, 0)
10461046
cValue.ForEach(func(ck, cv gjson.Result) bool {
10471047
cItem := ApplicationPriorityTrafficPolicySequencesActions{}
1048-
if ccValue := cv.Get("slaClass"); ccValue.Exists() {
1048+
if ccValue := cv.Get("slaClass"); ccValue.Exists() && len(ccValue.Array()) > 0 {
10491049
cItem.SlaClasses = make([]ApplicationPriorityTrafficPolicySequencesActionsSlaClasses, 0)
10501050
ccValue.ForEach(func(cck, ccv gjson.Result) bool {
10511051
ccItem := ApplicationPriorityTrafficPolicySequencesActionsSlaClasses{}
@@ -1117,7 +1117,7 @@ func (data *ApplicationPriorityTrafficPolicy) fromBody(ctx context.Context, res
11171117
cItem.BackupSlaPreferredColor = helpers.GetStringSet(va.Array())
11181118
}
11191119
}
1120-
if ccValue := cv.Get("set"); ccValue.Exists() {
1120+
if ccValue := cv.Get("set"); ccValue.Exists() && len(ccValue.Array()) > 0 {
11211121
cItem.SetParameters = make([]ApplicationPriorityTrafficPolicySequencesActionsSetParameters, 0)
11221122
ccValue.ForEach(func(cck, ccv gjson.Result) bool {
11231123
ccItem := ApplicationPriorityTrafficPolicySequencesActionsSetParameters{}

internal/provider/model_sdwan_dns_security_policy.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ func (data *DNSSecurity) fromBody(ctx context.Context, res gjson.Result) {
205205
if t.String() == "global" {
206206
data.DnsServerIp = types.StringValue(va.String())
207207
}
208+
data.MatchAllVpn = types.BoolValue(true)
208209
}
209210
data.LocalDomainBypassEnabled = types.BoolNull()
210211

@@ -230,7 +231,7 @@ func (data *DNSSecurity) fromBody(ctx context.Context, res gjson.Result) {
230231
data.ChildOrgId = types.StringValue(va.String())
231232
}
232233
}
233-
if value := res.Get(path + "targetVpns"); value.Exists() {
234+
if value := res.Get(path + "targetVpns"); value.Exists() && len(value.Array()) > 0 {
234235
data.TargetVpns = make([]DNSSecurityTargetVpns, 0)
235236
value.ForEach(func(k, v gjson.Result) bool {
236237
item := DNSSecurityTargetVpns{}
@@ -277,6 +278,7 @@ func (data *DNSSecurity) fromBody(ctx context.Context, res gjson.Result) {
277278
data.TargetVpns = append(data.TargetVpns, item)
278279
return true
279280
})
281+
data.MatchAllVpn = types.BoolValue(false)
280282
}
281283
}
282284

internal/provider/model_sdwan_other_thousandeyes_feature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (data *OtherThousandEyes) fromBody(ctx context.Context, res gjson.Result) {
248248
data.Description = types.StringNull()
249249
}
250250
path := "payload.data."
251-
if value := res.Get(path + "virtualApplication"); value.Exists() {
251+
if value := res.Get(path + "virtualApplication"); value.Exists() && len(value.Array()) > 0 {
252252
data.VirtualApplication = make([]OtherThousandEyesVirtualApplication, 0)
253253
value.ForEach(func(k, v gjson.Result) bool {
254254
item := OtherThousandEyesVirtualApplication{}

internal/provider/model_sdwan_other_ucse_feature.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ func (data *OtherUCSE) fromBody(ctx context.Context, res gjson.Result) {
284284
if t.String() == "global" {
285285
data.AccessPortSharedType = types.StringValue(va.String())
286286
}
287+
data.AccessPortDedicated = types.BoolValue(false)
287288
}
288289
data.AccessPortSharedFailoverType = types.StringNull()
289290

@@ -292,6 +293,7 @@ func (data *OtherUCSE) fromBody(ctx context.Context, res gjson.Result) {
292293
if t.String() == "global" {
293294
data.AccessPortSharedFailoverType = types.StringValue(va.String())
294295
}
296+
data.AccessPortDedicated = types.BoolValue(false)
295297
}
296298
data.Ipv4Address = types.StringNull()
297299
data.Ipv4AddressVariable = types.StringNull()
@@ -333,7 +335,7 @@ func (data *OtherUCSE) fromBody(ctx context.Context, res gjson.Result) {
333335
data.AssignPriority = types.Int64Value(va.Int())
334336
}
335337
}
336-
if value := res.Get(path + "interface"); value.Exists() {
338+
if value := res.Get(path + "interface"); value.Exists() && len(value.Array()) > 0 {
337339
data.Interfaces = make([]OtherUCSEInterfaces, 0)
338340
value.ForEach(func(k, v gjson.Result) bool {
339341
item := OtherUCSEInterfaces{}

internal/provider/model_sdwan_policy_object_app_probe_class.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ func (data *PolicyObjectAppProbeClass) fromBody(ctx context.Context, res gjson.R
119119
data.Description = types.StringNull()
120120
}
121121
path := "payload.data."
122-
if value := res.Get(path + "entries"); value.Exists() {
122+
if value := res.Get(path + "entries"); value.Exists() && len(value.Array()) > 0 {
123123
data.Entries = make([]PolicyObjectAppProbeClassEntries, 0)
124124
value.ForEach(func(k, v gjson.Result) bool {
125125
item := PolicyObjectAppProbeClassEntries{}
126-
if cValue := v.Get("map"); cValue.Exists() {
126+
if cValue := v.Get("map"); cValue.Exists() && len(cValue.Array()) > 0 {
127127
item.Map = make([]PolicyObjectAppProbeClassEntriesMap, 0)
128128
cValue.ForEach(func(ck, cv gjson.Result) bool {
129129
cItem := PolicyObjectAppProbeClassEntriesMap{}

internal/provider/model_sdwan_policy_object_application_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (data *PolicyObjectApplicationList) fromBody(ctx context.Context, res gjson
100100
data.Description = types.StringNull()
101101
}
102102
path := "payload.data."
103-
if value := res.Get(path + "entries"); value.Exists() {
103+
if value := res.Get(path + "entries"); value.Exists() && len(value.Array()) > 0 {
104104
data.Entries = make([]PolicyObjectApplicationListEntries, 0)
105105
value.ForEach(func(k, v gjson.Result) bool {
106106
item := PolicyObjectApplicationListEntries{}

internal/provider/model_sdwan_policy_object_as_path_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (data *PolicyObjectASPathList) fromBody(ctx context.Context, res gjson.Resu
108108
data.AsPathListId = types.Int64Value(va.Int())
109109
}
110110
}
111-
if value := res.Get(path + "entries"); value.Exists() {
111+
if value := res.Get(path + "entries"); value.Exists() && len(value.Array()) > 0 {
112112
data.Entries = make([]PolicyObjectASPathListEntries, 0)
113113
value.ForEach(func(k, v gjson.Result) bool {
114114
item := PolicyObjectASPathListEntries{}

internal/provider/model_sdwan_policy_object_class_map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (data *PolicyObjectClassMap) fromBody(ctx context.Context, res gjson.Result
9393
data.Description = types.StringNull()
9494
}
9595
path := "payload.data."
96-
if value := res.Get(path + "entries"); value.Exists() {
96+
if value := res.Get(path + "entries"); value.Exists() && len(value.Array()) > 0 {
9797
data.Entries = make([]PolicyObjectClassMapEntries, 0)
9898
value.ForEach(func(k, v gjson.Result) bool {
9999
item := PolicyObjectClassMapEntries{}

0 commit comments

Comments
 (0)