1414*/}}
1515{{- define "SchemaFieldsFW"}}
1616{{- if .FlattenObject -}}
17- {{- range $prop := .ResourceMetadata.OrderProperties .UserProperties -}}
17+ {{- range $prop := .ResourceMetadata.OrderProperties .UserProperties -}}
1818 {{ template "SchemaFieldsFW" $prop }}
19- {{ end -}}
19+ {{ end -}}
2020{{- else -}}
21+ {{- if eq .Type "NestedObject" -}}
22+ "{{underscore .Name -}}": schema.SingleNestedAttribute{
23+ Attributes: map[string]schema.Attribute{
24+ {{- range $prop := .ResourceMetadata.OrderProperties $.UserProperties }}
25+ {{ template "SchemaFieldsFW" $prop -}}
26+ {{- end }}
27+ },
28+ {{- else if eq .Type "Array" -}}
29+ {{- if eq .ItemType.Type "NestedObject" -}}
30+ {{- if .IsSet -}}
31+ "{{underscore .Name -}}": schema.SetNestedAttribute{
32+ NestedObject: schema.NestedAttributeObject{
33+ Attributes: map[string]schema.Attribute{
34+ {{- range $prop := .ResourceMetadata.OrderProperties $.ItemType.UserProperties }}
35+ {{ template "SchemaFieldsFW" $prop -}}
36+ {{- end }}
37+ },
38+ },
39+ {{- else -}}
40+ "{{underscore .Name -}}": schema.ListNestedAttribute{
41+ NestedObject: schema.NestedAttributeObject{
42+ Attributes: map[string]schema.Attribute{
43+ {{- range $prop := .ResourceMetadata.OrderProperties $.ItemType.UserProperties }}
44+ {{ template "SchemaFieldsFW" $prop -}}
45+ {{- end }}
46+ },
47+ },
48+ {{- end -}}
49+ {{- else -}}
50+ {{- if .IsSet -}}
51+ "{{underscore .Name -}}": schema.SetAttribute{
52+ ElementType: {{ if or (eq .ItemType.Type "Enum") (eq .ItemType.Type "ResourceRef") }}types.StringType{{ else }}types.{{ .ItemType.GetFWType }}Type{{ end }},
53+ {{- else -}}
54+ "{{underscore .Name -}}": schema.ListAttribute{
55+ ElementType: {{ if or (eq .ItemType.Type "Enum") (eq .ItemType.Type "ResourceRef") }}types.StringType{{ else }}types.{{ .ItemType.GetFWType }}Type{{ end }},
56+ {{- end -}}
57+ {{- end -}}
58+ {{- else if hasPrefix .Type "KeyValue" -}}
59+ "{{underscore .Name -}}": schema.MapAttribute{
60+ ElementType: types.StringType,
61+ {{- else if eq .Type "Map" -}}
62+ {{- if eq .ValueType.Type "NestedObject" -}}
63+ "{{underscore .Name -}}": schema.MapNestedAttribute{
64+ NestedObject: schema.NestedAttributeObject{
65+ Attributes: map[string]schema.Attribute{
66+ {{- range $prop := .ResourceMetadata.OrderProperties $.ValueType.UserProperties }}
67+ {{ template "SchemaFieldsFW" $prop -}}
68+ {{- end }}
69+ },
70+ },
71+ {{- else -}}
72+ "{{underscore .Name -}}": schema.MapAttribute{
73+ ElementType: {{ if or (eq .ValueType.Type "Enum") (eq .ValueType.Type "ResourceRef") }}types.StringType{{ else }}types.{{ .ValueType.GetFWType }}Type{{ end }},
74+ {{- end -}}
75+ {{- else -}}
2176"{{underscore .Name -}}": schema.{{.GetFWType}}Attribute{
22- {{ if .DefaultFromApi -}}
23- Optional: true,
24- Computed: true,
25- {{ else if .Required -}}
77+ {{- if eq .GetFWType "List" -}}
78+ ElementType: {{ if or (eq .ItemType.Type "Enum") (eq .ItemType.Type "ResourceRef") }}types.StringType{{ else }}types.{{ .ItemType.GetFWType }}Type{{ end }},
79+ {{- else if eq .GetFWType "Set" -}}
80+ ElementType: {{ if or (eq .ItemType.Type "Enum") (eq .ItemType.Type "ResourceRef") }}types.StringType{{ else }}types.{{ .ItemType.GetFWType }}Type{{ end }},
81+ {{- end }}
82+ {{- end }}
83+
84+ {{- if .DefaultFromApi }}
85+ Optional: true,
86+ Computed: true,
87+ {{- else if .Required }}
2688 Required: true,
27- {{ else if .Output - }}
89+ {{- else if .Output }}
2890 Computed: true,
29- {{ else - }}
91+ {{- else }}
3092 Optional: true,
31- {{ end - }}
32- {{ if .DeprecationMessage - }}
93+ {{- end }}
94+ {{- if .DeprecationMessage }}
3395 DeprecationMessage: "{{ .DeprecationMessage }}",
34- {{ end - }}
35- {{ if .Sensitive - }}
96+ {{- end }}
97+ {{- if .Sensitive }}
3698 Sensitive: true,
37- {{ end -}}
38- {{ if or .IsForceNew .DefaultFromApi -}}
39- PlanModifiers: []planmodifier.{{.GetFWType}}{
40-
41- {{ if .IsForceNew -}}
42- {{lower .GetFWType}}planmodifier.RequiresReplace(),
43- {{ end -}}
44-
45- {{ if .DefaultFromApi -}}
46- {{lower .GetFWType}}planmodifier.UseStateForUnknown(),
47- {{ end -}}
48- },
49- {{ end -}}
99+ {{- end }}
100+ {{- if or .IsForceNew .DefaultFromApi }}
101+ PlanModifiers: []planmodifier.{{.GetFWType}}{
102+ {{- if .IsForceNew }}
103+ {{lower .GetFWType}}planmodifier.RequiresReplace(),
104+ {{- end }}
105+ {{- if .DefaultFromApi }}
106+ {{lower .GetFWType}}planmodifier.UseStateForUnknown(),
107+ {{- end }}
108+ },
109+ {{- end }}
50110},
51111{{- end -}}
52112{{- end -}}
0 commit comments