//go:build ignore
// Code generated by "gen/generator.go"; DO NOT EDIT.

package provider

import (
	"context"
	"fmt"
	"strconv"

	"github.com/hashicorp/terraform-plugin-framework/types"
	"github.com/hashicorp/terraform-plugin-log/tflog"
	"github.com/netascode/terraform-provider-sdwan/internal/provider/helpers"
	"github.com/tidwall/gjson"
	"github.com/tidwall/sjson"
)

{{- $name := camelCase .Name}}
type {{camelCase .Name}} struct {
	Id types.String `tfsdk:"id"`
	Version types.Int64 `tfsdk:"version"`
	TemplateType types.String `tfsdk:"template_type"`
	Name types.String `tfsdk:"name"`
	Description types.String `tfsdk:"description"`
	DeviceTypes types.List `tfsdk:"device_types"`
{{- range .Attributes}}
{{- if eq .Type "List"}}
	{{toGoName .TfName}} []{{$name}}{{toGoName .TfName}} `tfsdk:"{{.TfName}}"`
{{- else if eq .Type "ListString"}}
	{{toGoName .TfName}} types.List `tfsdk:"{{.TfName}}"`
{{- if .Variable}}
	{{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"`
{{- end}}
{{- else}}
	{{toGoName .TfName}} types.{{.Type}} `tfsdk:"{{.TfName}}"`
{{- if .Variable}}
	{{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"`
{{- end}}
{{- end}}
{{- end}}
}

{{ range .Attributes}}
{{- $childName := toGoName .TfName}}
{{- if eq .Type "List"}}
type {{$name}}{{toGoName .TfName}} struct {
	Optional types.Bool `tfsdk:"optional"`
{{- range .Attributes}}
{{- if eq .Type "List"}}
	{{toGoName .TfName}} []{{$name}}{{$childName}}{{toGoName .TfName}} `tfsdk:"{{.TfName}}"`
{{- else if eq .Type "ListString"}}
	{{toGoName .TfName}} types.List `tfsdk:"{{.TfName}}"`
{{- if .Variable}}
	{{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"`
{{- end}}
{{- else}}
	{{toGoName .TfName}} types.{{.Type}} `tfsdk:"{{.TfName}}"`
{{- if .Variable}}
	{{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"`
{{- end}}
{{- end}}
{{- end}}
}
{{- end}}
{{ end}}

{{ range .Attributes}}
{{- $childName := toGoName .TfName}}
{{- if eq .Type "List"}}
{{ range .Attributes}}
{{- $childChildName := toGoName .TfName}}
{{- if eq .Type "List"}}
type {{$name}}{{$childName}}{{toGoName .TfName}} struct {
	Optional types.Bool `tfsdk:"optional"`
{{- range .Attributes}}
{{- if eq .Type "List"}}
	{{toGoName .TfName}} []{{$name}}{{$childName}}{{$childChildName}}{{toGoName .TfName}} `tfsdk:"{{.TfName}}"`
{{- else if eq .Type "ListString"}}
	{{toGoName .TfName}} types.List `tfsdk:"{{.TfName}}"`
{{- if .Variable}}
	{{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"`
{{- end}}
{{- else}}
	{{toGoName .TfName}} types.{{.Type}} `tfsdk:"{{.TfName}}"`
{{- if .Variable}}
	{{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"`
{{- end}}
{{- end}}
{{- end}}
}
{{- end}}
{{- end}}
{{- end}}
{{ end}}

{{ range .Attributes}}
{{- $childName := toGoName .TfName}}
{{- if eq .Type "List"}}
{{ range .Attributes}}
{{- $childChildName := toGoName .TfName}}
{{- if eq .Type "List"}}
{{ range .Attributes}}
{{- if eq .Type "List"}}
type {{$name}}{{$childName}}{{$childChildName}}{{toGoName .TfName}} struct {
	Optional types.Bool `tfsdk:"optional"`
{{- range .Attributes}}
{{- if eq .Type "ListString"}}
	{{toGoName .TfName}} types.List `tfsdk:"{{.TfName}}"`
{{- if .Variable}}
	{{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"`
{{- end}}
{{- else}}
	{{toGoName .TfName}} types.{{.Type}} `tfsdk:"{{.TfName}}"`
{{- if .Variable}}
	{{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"`
{{- end}}
{{- end}}
{{- end}}
}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
{{ end}}

func (data {{camelCase .Name}}) getModel() string {
	return "{{.Model}}"
}

func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
	body := ""

	var device_types []string
	data.DeviceTypes.ElementsAs(ctx, &device_types, false)
	body, _ = sjson.Set(body, "deviceType", device_types)
	body, _ = sjson.Set(body, "factoryDefault", false)
	body, _ = sjson.Set(body, "templateDescription", data.Description.ValueString())
	body, _ = sjson.Set(body, "templateMinVersion", "15.0.0")
	body, _ = sjson.Set(body, "templateName", data.Name.ValueString())
	body, _ = sjson.Set(body, "templateType", "{{.Model}}")
	body, _ = sjson.Set(body, "templateDefinition", map[string]interface{}{})

	path := "templateDefinition."
	{{- range .Attributes}}
	{{- if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64")}}
	{{if .Variable}}
	if !data.{{toGoName .TfName}}Variable.IsNull() {
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", data.{{toGoName .TfName}}Variable.ValueString())
	} else
	{{- end}} if data.{{toGoName .TfName}}.IsNull() {
		{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
		{{- else if and (.DataPath) (not .ExcludeIgnore)}}
		body, _ = sjson.Set(body, path+"{{path .DataPath}}", map[string]interface{}{})
		{{- end}}
	} else {
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", data.{{toGoName .TfName}}.Value{{.Type}}())
	}
	{{- else if eq .Type "Bool"}}
	{{if .Variable}}
	if !data.{{toGoName .TfName}}Variable.IsNull() {
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", data.{{toGoName .TfName}}Variable.ValueString())
	} else
	{{- end}} if data.{{toGoName .TfName}}.IsNull() {
		{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
		{{- else if and (.DataPath) (not .ExcludeIgnore)}}
		body, _ = sjson.Set(body, path+"{{path .DataPath}}", map[string]interface{}{})
		{{- end}}
	} else {
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", strconv.FormatBool(data.{{toGoName .TfName}}.ValueBool()))
	}
	{{- else if eq .Type "ListString"}}
	{{if .Variable}}
	if !data.{{toGoName .TfName}}Variable.IsNull() {
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", data.{{toGoName .TfName}}Variable.ValueString())
	} else
	{{- end}} if data.{{toGoName .TfName}}.IsNull() {
		{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
		{{- else if and (.DataPath) (not .ExcludeIgnore)}}
		body, _ = sjson.Set(body, path+"{{path .DataPath}}", map[string]interface{}{})
		{{- end}}
	} else {
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
		var values []string
		data.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", values)
	}
	{{- else if eq .Type "List"}}
	if len(data.{{toGoName .TfName}}) > 0 {
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipPrimaryKey", []string{ {{range .Keys}}"{{.}}",{{end}} })
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", []interface{}{})
	} else {
		{{- if not .ExcludeIgnore}}
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipPrimaryKey", []string{ {{range .Keys}}"{{.}}",{{end}} })
		body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", []interface{}{})
		{{- end}}
	}
	for _, item := range data.{{toGoName .TfName}} {
		itemBody := ""
		itemAttributes := make([]string, 0)
		{{- range .Attributes}}
		itemAttributes = append(itemAttributes, "{{.ModelName}}")
		{{- if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64")}}
		{{if .Variable}}
		if !item.{{toGoName .TfName}}Variable.IsNull() {
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", item.{{toGoName .TfName}}Variable.ValueString())
		} else
		{{- end}} if item.{{toGoName .TfName}}.IsNull() {
			{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
			{{- else if and (.DataPath) (not .ExcludeIgnore)}}
			itemBody, _ = sjson.Set(itemBody, "{{path .DataPath}}", map[string]interface{}{})
			{{- end}}
		} else {
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", item.{{toGoName .TfName}}.Value{{.Type}}())
		}
		{{- else if eq .Type "Bool"}}
		{{if .Variable}}
		if !item.{{toGoName .TfName}}Variable.IsNull() {
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", item.{{toGoName .TfName}}Variable.ValueString())
		} else
		{{- end}} if item.{{toGoName .TfName}}.IsNull() {
			{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
			{{- else if and (.DataPath) (not .ExcludeIgnore)}}
			itemBody, _ = sjson.Set(itemBody, "{{path .DataPath}}", map[string]interface{}{})
			{{- end}}
		} else {
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", strconv.FormatBool(item.{{toGoName .TfName}}.ValueBool()))
		}
		{{- else if eq .Type "ListString"}}
		{{if .Variable}}
		if !item.{{toGoName .TfName}}Variable.IsNull() {
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", item.{{toGoName .TfName}}Variable.ValueString())
		} else
		{{- end}} if item.{{toGoName .TfName}}.IsNull() {
			{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
			{{- else if and (.DataPath) (not .ExcludeIgnore)}}
			itemBody, _ = sjson.Set(itemBody, "{{path .DataPath}}", map[string]interface{}{})
			{{- end}}
		} else {
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
			var values []string
			item.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", values)
		}
		{{- else if eq .Type "List"}}
		if len(item.{{toGoName .TfName}}) > 0 {
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipPrimaryKey", []string{ {{range .Keys}}"{{.}}",{{end}} })
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", []interface{}{})
		} else {
			{{- if not .ExcludeIgnore}}
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipPrimaryKey", []string{ {{range .Keys}}"{{.}}",{{end}} })
			itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", []interface{}{})
			{{- end}}
		}
		for _, childItem := range item.{{toGoName .TfName}} {
			itemChildBody := ""
			itemChildAttributes := make([]string, 0)
			{{- range .Attributes}}
			itemChildAttributes = append(itemChildAttributes, "{{.ModelName}}")
			{{- if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64")}}
			{{if .Variable}}
			if !childItem.{{toGoName .TfName}}Variable.IsNull() {
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childItem.{{toGoName .TfName}}Variable.ValueString())
			} else
			{{- end}} if childItem.{{toGoName .TfName}}.IsNull() {
				{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
				{{- else if and (.DataPath) (not .ExcludeIgnore)}}
				itemChildBody, _ = sjson.Set(itemChildBody, "{{path .DataPath}}", map[string]interface{}{})
				{{- end}}
			} else {
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", childItem.{{toGoName .TfName}}.Value{{.Type}}())
			}
			{{- else if eq .Type "Bool"}}
			{{if .Variable}}
			if !childItem.{{toGoName .TfName}}Variable.IsNull() {
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childItem.{{toGoName .TfName}}Variable.ValueString())
			} else
			{{- end}} if childItem.{{toGoName .TfName}}.IsNull() {
				{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
				{{- else if and (.DataPath) (not .ExcludeIgnore)}}
				itemChildBody, _ = sjson.Set(itemChildBody, "{{path .DataPath}}", map[string]interface{}{})
				{{- end}}
			} else {
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", strconv.FormatBool(childItem.{{toGoName .TfName}}.ValueBool()))
			}
			{{- else if eq .Type "ListString"}}
			{{if .Variable}}
			if !childItem.{{toGoName .TfName}}Variable.IsNull() {
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childItem.{{toGoName .TfName}}Variable.ValueString())
			} else
			{{- end}} if childItem.{{toGoName .TfName}}.IsNull() {
				{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
				{{- else if and (.DataPath) (not .ExcludeIgnore)}}
				itemChildBody, _ = sjson.Set(itemChildBody, "{{path .DataPath}}", map[string]interface{}{})
				{{- end}}
			} else {
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
				var values []string
				childItem.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", values)
			}
			{{- else if eq .Type "List"}}
			if len(childItem.{{toGoName .TfName}}) > 0 {
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipPrimaryKey", []string{ {{range .Keys}}"{{.}}",{{end}} })
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", []interface{}{})
			} else {
				{{- if not .ExcludeIgnore}}
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipPrimaryKey", []string{ {{range .Keys}}"{{.}}",{{end}} })
				itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", []interface{}{})
				{{- end}}
			}
			for _, childChildItem := range childItem.{{toGoName .TfName}} {
				itemChildChildBody := ""
				itemChildChildAttributes := make([]string, 0)
				{{- range .Attributes}}
				itemChildChildAttributes = append(itemChildChildAttributes, "{{.ModelName}}")
				{{- if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64")}}
				{{if .Variable}}
				if !childChildItem.{{toGoName .TfName}}Variable.IsNull() {
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childChildItem.{{toGoName .TfName}}Variable.ValueString())
				} else
				{{- end}} if childChildItem.{{toGoName .TfName}}.IsNull() {
					{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
					{{- else if and (.DataPath) (not .ExcludeIgnore)}}
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{path .DataPath}}", map[string]interface{}{})
					{{- end}}
				} else {
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", childChildItem.{{toGoName .TfName}}.Value{{.Type}}())
				}
				{{- else if eq .Type "Bool"}}
				{{if .Variable}}
				if !childChildItem.{{toGoName .TfName}}Variable.IsNull() {
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childChildItem.{{toGoName .TfName}}Variable.ValueString())
				} else
				{{- end}} if childChildItem.{{toGoName .TfName}}.IsNull() {
					{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
					{{- else if and (.DataPath) (not .ExcludeIgnore)}}
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{path .DataPath}}", map[string]interface{}{})
					{{- end}}
				} else {
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", strconv.FormatBool(childChildItem.{{toGoName .TfName}}.ValueBool()))
				}
				{{- else if eq .Type "ListString"}}
				{{if .Variable}}
				if !childChildItem.{{toGoName .TfName}}Variable.IsNull() {
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childChildItem.{{toGoName .TfName}}Variable.ValueString())
				} else
				{{- end}} if childChildItem.{{toGoName .TfName}}.IsNull() {
					{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
					{{- else if and (.DataPath) (not .ExcludeIgnore)}}
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{path .DataPath}}", map[string]interface{}{})
					{{- end}}
				} else {
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
					var values []string
					childChildItem.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", values)
				}
				{{- end}}
				{{- end}}
				if !childChildItem.Optional.IsNull() {
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "vipOptional", childChildItem.Optional.ValueBool())
					itemChildChildBody, _ = sjson.Set(itemChildChildBody, "priority-order", itemChildChildAttributes)
				}
				itemChildBody, _ = sjson.SetRaw(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue.-1", itemChildChildBody)
			}
			{{- end}}
			{{- end}}
			if !childItem.Optional.IsNull() {
				itemChildBody, _ = sjson.Set(itemChildBody, "vipOptional", childItem.Optional.ValueBool())
				itemChildBody, _ = sjson.Set(itemChildBody, "priority-order", itemChildAttributes)
			}
			itemBody, _ = sjson.SetRaw(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue.-1", itemChildBody)
		}
		{{- end}}
		{{- end}}
		if !item.Optional.IsNull() {
			itemBody, _ = sjson.Set(itemBody, "vipOptional", item.Optional.ValueBool())
			itemBody, _ = sjson.Set(itemBody, "priority-order", itemAttributes)
		}
		body, _ = sjson.SetRaw(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue.-1", itemBody)
	}
	{{- end}}
	{{- end}}
	return body
}

func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) {
	if value := res.Get("deviceType"); value.Exists() {
		data.DeviceTypes = helpers.GetStringList(value.Array())
	} else {
		data.DeviceTypes = types.ListNull(types.StringType)
	}
	if value := res.Get("templateDescription"); value.Exists() && value.String() != "" {
		data.Description = types.StringValue(value.String())
	} else {
		data.Description = types.StringNull()
	}
	if value := res.Get("templateName"); value.Exists() {
		data.Name = types.StringValue(value.String())
	} else {
		data.Name = types.StringNull()
	}
	if value := res.Get("templateType"); value.Exists() {
		data.TemplateType = types.StringValue(value.String())
	} else {
		data.TemplateType = types.StringNull()
	}

	path := "templateDefinition."
	{{- range .Attributes}}
	{{- $cname := toGoName .TfName}}
	{{- if eq .Type "String"}}
	if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); value.Exists() {
		if value.String() == "variableName" {
			data.{{toGoName .TfName}} = types.StringNull()
			{{if .Variable}}
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
			data.{{toGoName .TfName}}Variable = types.StringValue(v.String())
			{{end}}
		} else if value.String() == "ignore" {
			data.{{toGoName .TfName}} = types.StringNull()
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		} else if value.String() == "constant" {
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
			data.{{toGoName .TfName}} = types.StringValue(v.String())
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		}
	} else {
		data.{{toGoName .TfName}} = types.StringNull()
		{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
	}
	{{- else if eq .Type "Int64"}}
	if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); value.Exists() {
		if value.String() == "variableName" {
			data.{{toGoName .TfName}} = types.Int64Null()
			{{if .Variable}}
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
			data.{{toGoName .TfName}}Variable = types.StringValue(v.String())
			{{end}}
		} else if value.String() == "ignore" {
			data.{{toGoName .TfName}} = types.Int64Null()
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		} else if value.String() == "constant" {
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
			data.{{toGoName .TfName}} = types.Int64Value(v.Int())
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		}
	} else {
		data.{{toGoName .TfName}} = types.Int64Null()
		{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
	}
	{{- else if eq .Type "Float64"}}
	if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); value.Exists() {
		if value.String() == "variableName" {
			data.{{toGoName .TfName}} = types.Float64Null()
			{{if .Variable}}
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
			data.{{toGoName .TfName}}Variable = types.StringValue(v.String())
			{{end}}
		} else if value.String() == "ignore" {
			data.{{toGoName .TfName}} = types.Float64Null()
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		} else if value.String() == "constant" {
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
			data.{{toGoName .TfName}} = types.Float64Value(v.Float())
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		}
	} else {
		data.{{toGoName .TfName}} = types.Float64Null()
		{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
	}
	{{- else if eq .Type "Bool"}}
	if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); value.Exists() {
		if value.String() == "variableName" {
			data.{{toGoName .TfName}} = types.BoolNull()
			{{if .Variable}}
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
			data.{{toGoName .TfName}}Variable = types.StringValue(v.String())
			{{end}}
		} else if value.String() == "ignore" {
			data.{{toGoName .TfName}} = types.BoolNull()
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		} else if value.String() == "constant" {
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
			data.{{toGoName .TfName}} = types.BoolValue(v.Bool())
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		}
	} else {
		data.{{toGoName .TfName}} = types.BoolNull()
		{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
	}
	{{- else if eq .Type "ListString"}}
	if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); len(value.Array()) > 0 {
		if value.String() == "variableName" {
			data.{{toGoName .TfName}} = types.ListNull(types.StringType)
			{{if .Variable}}
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
			data.{{toGoName .TfName}}Variable = types.StringValue(v.String())
			{{end}}
		} else if value.String() == "ignore" {
			data.{{toGoName .TfName}} = types.ListNull(types.StringType)
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		} else if value.String() == "constant" {
			v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
			data.{{toGoName .TfName}} = helpers.GetStringList(v.Array())
			{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
		}
	} else {
		data.{{toGoName .TfName}} = types.ListNull(types.StringType)
		{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
	}
	{{- else if eq .Type "List"}}
	if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue"); len(value.Array()) > 0 {
		data.{{toGoName .TfName}} = make([]{{$name}}{{toGoName .TfName}}, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := {{$name}}{{toGoName .TfName}}{}
			if cValue := v.Get("vipOptional"); cValue.Exists() {
				item.Optional = types.BoolValue(cValue.Bool())
			} else {
				item.Optional = types.BoolNull()
			}
			{{- range .Attributes}}
			{{- $ccname := toGoName .TfName}}
			{{- if eq .Type "String"}}
			if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); cValue.Exists() {
				if cValue.String() == "variableName" {
					item.{{toGoName .TfName}} = types.StringNull()
					{{if .Variable}}
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
					item.{{toGoName .TfName}}Variable = types.StringValue(cv.String())
					{{end}}
				} else if cValue.String() == "ignore" {
					item.{{toGoName .TfName}} = types.StringNull()
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				} else if cValue.String() == "constant" {
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
					item.{{toGoName .TfName}} = types.StringValue(cv.String())
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				}
			} else {
				item.{{toGoName .TfName}} = types.StringNull()
				{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
			}
			{{- else if eq .Type "Int64"}}
			if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); cValue.Exists() {
				if cValue.String() == "variableName" {
					item.{{toGoName .TfName}} = types.Int64Null()
					{{if .Variable}}
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
					item.{{toGoName .TfName}}Variable = types.StringValue(cv.String())
					{{end}}
				} else if cValue.String() == "ignore" {
					item.{{toGoName .TfName}} = types.Int64Null()
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				} else if cValue.String() == "constant" {
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
					item.{{toGoName .TfName}} = types.Int64Value(cv.Int())
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				}
			} else {
				item.{{toGoName .TfName}} = types.Int64Null()
				{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
			}
			{{- else if eq .Type "Float64"}}
			if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); cValue.Exists() {
				if cValue.String() == "variableName" {
					item.{{toGoName .TfName}} = types.Float64Null()
					{{if .Variable}}
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
					item.{{toGoName .TfName}}Variable = types.StringValue(cv.String())
					{{end}}
				} else if cValue.String() == "ignore" {
					item.{{toGoName .TfName}} = types.Float64Null()
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				} else if cValue.String() == "constant" {
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
					item.{{toGoName .TfName}} = types.Float64Value(cv.Float())
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				}
			} else {
				item.{{toGoName .TfName}} = types.Float64Null()
				{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
			}
			{{- else if eq .Type "Bool"}}
			if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); cValue.Exists() {
				if cValue.String() == "variableName" {
					item.{{toGoName .TfName}} = types.BoolNull()
					{{if .Variable}}
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
					item.{{toGoName .TfName}}Variable = types.StringValue(cv.String())
					{{end}}
				} else if cValue.String() == "ignore" {
					item.{{toGoName .TfName}} = types.BoolNull()
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				} else if cValue.String() == "constant" {
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
					item.{{toGoName .TfName}} = types.BoolValue(cv.Bool())
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				}
			} else {
				item.{{toGoName .TfName}} = types.BoolNull()
				{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
			}
			{{- else if eq .Type "ListString"}}
			if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); len(cValue.Array()) > 0 {
				if cValue.String() == "variableName" {
					item.{{toGoName .TfName}} = types.ListNull(types.StringType)
					{{if .Variable}}
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
					item.{{toGoName .TfName}}Variable = types.StringValue(cv.String())
					{{end}}
				} else if cValue.String() == "ignore" {
					item.{{toGoName .TfName}} = types.ListNull(types.StringType)
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				} else if cValue.String() == "constant" {
					cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
					item.{{toGoName .TfName}} = helpers.GetStringList(cv.Array())
					{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
				}
			} else {
				item.{{toGoName .TfName}} = types.ListNull(types.StringType)
				{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
			}
			{{- else if eq .Type "List"}}
			if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue"); len(cValue.Array()) > 0 {
				item.{{toGoName .TfName}} = make([]{{$name}}{{$cname}}{{toGoName .TfName}}, 0)
				cValue.ForEach(func(ck, cv gjson.Result) bool {
					cItem := {{$name}}{{$cname}}{{toGoName .TfName}}{}
					if ccValue := cv.Get("vipOptional"); ccValue.Exists() {
						cItem.Optional = types.BoolValue(ccValue.Bool())
					} else {
						cItem.Optional = types.BoolNull()
					}
					{{- range .Attributes}}
					{{- if eq .Type "String"}}
					if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); ccValue.Exists() {
						if ccValue.String() == "variableName" {
							cItem.{{toGoName .TfName}} = types.StringNull()
							{{if .Variable}}
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
							cItem.{{toGoName .TfName}}Variable = types.StringValue(ccv.String())
							{{end}}
						} else if ccValue.String() == "ignore" {
							cItem.{{toGoName .TfName}} = types.StringNull()
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						} else if ccValue.String() == "constant" {
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
							cItem.{{toGoName .TfName}} = types.StringValue(ccv.String())
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						}
					} else {
						cItem.{{toGoName .TfName}} = types.StringNull()
						{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
					}
					{{- else if eq .Type "Int64"}}
					if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); ccValue.Exists() {
						if ccValue.String() == "variableName" {
							cItem.{{toGoName .TfName}} = types.Int64Null()
							{{if .Variable}}
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
							cItem.{{toGoName .TfName}}Variable = types.StringValue(ccv.String())
							{{end}}
						} else if ccValue.String() == "ignore" {
							cItem.{{toGoName .TfName}} = types.Int64Null()
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						} else if ccValue.String() == "constant" {
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
							cItem.{{toGoName .TfName}} = types.Int64Value(ccv.Int())
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						}
					} else {
						cItem.{{toGoName .TfName}} = types.Int64Null()
						{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
					}
					{{- else if eq .Type "Float64"}}
					if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); ccValue.Exists() {
						if ccValue.String() == "variableName" {
							cItem.{{toGoName .TfName}} = types.Float64Null()
							{{if .Variable}}
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
							cItem.{{toGoName .TfName}}Variable = types.StringValue(ccv.String())
							{{end}}
						} else if ccValue.String() == "ignore" {
							cItem.{{toGoName .TfName}} = types.Float64Null()
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						} else if ccValue.String() == "constant" {
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
							cItem.{{toGoName .TfName}} = types.Float64Value(ccv.Float())
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						}
					} else {
						cItem.{{toGoName .TfName}} = types.Float64Null()
						{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
					}
					{{- else if eq .Type "Bool"}}
					if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); ccValue.Exists() {
						if ccValue.String() == "variableName" {
							cItem.{{toGoName .TfName}} = types.BoolNull()
							{{if .Variable}}
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
							cItem.{{toGoName .TfName}}Variable = types.StringValue(ccv.String())
							{{end}}
						} else if ccValue.String() == "ignore" {
							cItem.{{toGoName .TfName}} = types.BoolNull()
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						} else if ccValue.String() == "constant" {
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
							cItem.{{toGoName .TfName}} = types.BoolValue(ccv.Bool())
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						}
					} else {
						cItem.{{toGoName .TfName}} = types.BoolNull()
						{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
					}
					{{- else if eq .Type "ListString"}}
					if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); len(ccValue.Array()) > 0 {
						if ccValue.String() == "variableName" {
							cItem.{{toGoName .TfName}} = types.ListNull(types.StringType)
							{{if .Variable}}
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
							cItem.{{toGoName .TfName}}Variable = types.StringValue(ccv.String())
							{{end}}
						} else if ccValue.String() == "ignore" {
							cItem.{{toGoName .TfName}} = types.ListNull(types.StringType)
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						} else if ccValue.String() == "constant" {
							ccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
							cItem.{{toGoName .TfName}} = helpers.GetStringList(ccv.Array())
							{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
						}
					} else {
						cItem.{{toGoName .TfName}} = types.ListNull(types.StringType)
						{{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
					}
					{{- else if eq .Type "List"}}
					if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue"); len(ccValue.Array()) > 0 {
						cItem.{{toGoName .TfName}} = make([]{{$name}}{{$cname}}{{$ccname}}{{toGoName .TfName}}, 0)
						ccValue.ForEach(func(cck, ccv gjson.Result) bool {
							ccItem := {{$name}}{{$cname}}{{$ccname}}{{toGoName .TfName}}{}
							if cccValue := ccv.Get("vipOptional"); cccValue.Exists() {
								ccItem.Optional = types.BoolValue(cccValue.Bool())
							} else {
								ccItem.Optional = types.BoolNull()
							}
							{{- range .Attributes}}
							{{- if eq .Type "String"}}
							if cccValue := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); cccValue.Exists() {
								if cccValue.String() == "variableName" {
									ccItem.{{toGoName .TfName}} = types.StringNull()
									{{if .Variable}}
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
									ccItem.{{toGoName .TfName}}Variable = types.StringValue(cccv.String())
									{{end}}
								} else if cccValue.String() == "ignore" {
									ccItem.{{toGoName .TfName}} = types.StringNull()
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								} else if cccValue.String() == "constant" {
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
									ccItem.{{toGoName .TfName}} = types.StringValue(cccv.String())
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								}
							} else {
								ccItem.{{toGoName .TfName}} = types.StringNull()
								{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
							}
							{{- else if eq .Type "Int64"}}
							if cccValue := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); cccValue.Exists() {
								if cccValue.String() == "variableName" {
									ccItem.{{toGoName .TfName}} = types.Int64Null()
									{{if .Variable}}
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
									ccItem.{{toGoName .TfName}}Variable = types.StringValue(cccv.String())
									{{end}}
								} else if cccValue.String() == "ignore" {
									ccItem.{{toGoName .TfName}} = types.Int64Null()
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								} else if cccValue.String() == "constant" {
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
									ccItem.{{toGoName .TfName}} = types.Int64Value(cccv.Int())
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								}
							} else {
								ccItem.{{toGoName .TfName}} = types.Int64Null()
								{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
							}
							{{- else if eq .Type "Float64"}}
							if cccValue := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); cccValue.Exists() {
								if cccValue.String() == "variableName" {
									ccItem.{{toGoName .TfName}} = types.Float64Null()
									{{if .Variable}}
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
									ccItem.{{toGoName .TfName}}Variable = types.StringValue(cccv.String())
									{{end}}
								} else if cccValue.String() == "ignore" {
									ccItem.{{toGoName .TfName}} = types.Float64Null()
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								} else if cccValue.String() == "constant" {
									cccv := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
									ccItem.{{toGoName .TfName}} = types.Float64Value(cccv.Float())
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								}
							} else {
								ccItem.{{toGoName .TfName}} = types.Float64Null()
								{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
							}
							{{- else if eq .Type "Bool"}}
							if cccValue := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); cccValue.Exists() {
								if cccValue.String() == "variableName" {
									ccItem.{{toGoName .TfName}} = types.BoolNull()
									{{if .Variable}}
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
									ccItem.{{toGoName .TfName}}Variable = types.StringValue(cccv.String())
									{{end}}
								} else if cccValue.String() == "ignore" {
									ccItem.{{toGoName .TfName}} = types.BoolNull()
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								} else if cccValue.String() == "constant" {
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
									ccItem.{{toGoName .TfName}} = types.BoolValue(cccv.Bool())
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								}
							} else {
								ccItem.{{toGoName .TfName}} = types.BoolNull()
								{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
							}
							{{- else if eq .Type "ListString"}}
							if cccValue := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipType"); len(cccValue.Array()) > 0 {
								if cccValue.String() == "variableName" {
									ccItem.{{toGoName .TfName}} = types.ListNull(types.StringType)
									{{if .Variable}}
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
									ccItem.{{toGoName .TfName}}Variable = types.StringValue(cccv.String())
									{{end}}
								} else if cccValue.String() == "ignore" {
									ccItem.{{toGoName .TfName}} = types.ListNull(types.StringType)
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								} else if cccValue.String() == "constant" {
									cccv := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipValue")
									ccItem.{{toGoName .TfName}} = helpers.GetStringList(cccv.Array())
									{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
								}
							} else {
								ccItem.{{toGoName .TfName}} = types.ListNull(types.StringType)
								{{if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
							}
							{{- end}}
							{{- end}}
							cItem.{{toGoName .TfName}} = append(cItem.{{toGoName .TfName}}, ccItem)
							return true
						})
					}
					{{- end}}
					{{- end}}
					item.{{toGoName .TfName}} = append(item.{{toGoName .TfName}}, cItem)
					return true
				})
			}
			{{- end}}
			{{- end}}
			data.{{toGoName .TfName}} = append(data.{{toGoName .TfName}}, item)
			return true
		})
	}
	{{- end}}
	{{- end}}
}

func (data *{{camelCase .Name}}) hasChanges(ctx context.Context, state *{{camelCase .Name}}) bool {
	hasChanges := false
	{{- range .Attributes}}
	{{- $name := toGoName .TfName}}
	{{- if and (not .Value) (not .TfOnly)}}
	{{- if ne .Type "List"}}
	if !data.{{toGoName .TfName}}.Equal(state.{{toGoName .TfName}}) {
		hasChanges = true
	}
	{{- else}}
	if len(data.{{toGoName .TfName}}) != len(state.{{toGoName .TfName}}) {
		hasChanges = true
	} else {
		for i := range data.{{toGoName .TfName}} {
			{{- range .Attributes}}
			{{- $cname := toGoName .TfName}}
			{{- if and (not .Value) (not .TfOnly)}}
			{{- if ne .Type "List"}}
			if !data.{{$name}}[i].{{toGoName .TfName}}.Equal(state.{{$name}}[i].{{toGoName .TfName}}) {
				hasChanges = true
			}
			{{- else}}
			if len(data.{{$name}}[i].{{toGoName .TfName}}) != len(state.{{$name}}[i].{{toGoName .TfName}}) {
				hasChanges = true
			} else {
				for ii := range data.{{$name}}[i].{{toGoName .TfName}} {
					{{- range .Attributes}}
					{{- $ccname := toGoName .TfName}}
					{{- if and (not .Value) (not .TfOnly)}}
					{{- if ne .Type "List"}}
					if !data.{{$name}}[i].{{$cname}}[ii].{{toGoName .TfName}}.Equal(state.{{$name}}[i].{{$cname}}[ii].{{toGoName .TfName}}) {
						hasChanges = true
					}
					{{- else}}
					if len(data.{{$name}}[i].{{$cname}}[ii].{{toGoName .TfName}}) != len(state.{{$name}}[i].{{$cname}}[ii].{{toGoName .TfName}}) {
						hasChanges = true
					} else {
						for iii := range data.{{$name}}[i].{{$cname}}[ii].{{toGoName .TfName}} {
							{{- range .Attributes}}
							{{- if and (not .Value) (not .TfOnly)}}
							if !data.{{$name}}[i].{{$cname}}[ii].{{$ccname}}[iii].{{toGoName .TfName}}.Equal(state.{{$name}}[i].{{$cname}}[ii].{{$ccname}}[iii].{{toGoName .TfName}}) {
								hasChanges = true
							}
							{{- end}}
							{{- end}}
						}
					}
					{{- end}}
					{{- end}}
					{{- end}}
				}
			}
			{{- end}}
			{{- end}}
			{{- end}}
		}
	}
	{{- end}}
	{{- end}}
	{{- end}}
	return hasChanges
}
