diff --git a/docs/data-sources/service_ipv4_acl_feature.md b/docs/data-sources/service_ipv4_acl_feature.md index 66df6a09..44dcb386 100644 --- a/docs/data-sources/service_ipv4_acl_feature.md +++ b/docs/data-sources/service_ipv4_acl_feature.md @@ -85,7 +85,7 @@ Read-Only: Read-Only: -- `port` (Number) destination port range or individual port number +- `port` (String) destination port range or individual port number @@ -93,4 +93,4 @@ Read-Only: Read-Only: -- `port` (Number) source port range or individual port number +- `port` (String) source port range or individual port number diff --git a/docs/data-sources/service_ipv6_acl_feature.md b/docs/data-sources/service_ipv6_acl_feature.md index 46b4ee98..cb113d2f 100644 --- a/docs/data-sources/service_ipv6_acl_feature.md +++ b/docs/data-sources/service_ipv6_acl_feature.md @@ -83,7 +83,7 @@ Read-Only: Read-Only: -- `port` (Number) destination port range or individual port number +- `port` (String) destination port range or individual port number @@ -91,4 +91,4 @@ Read-Only: Read-Only: -- `port` (Number) source port range or individual port number +- `port` (String) source port range or individual port number diff --git a/docs/data-sources/transport_ipv4_acl_feature.md b/docs/data-sources/transport_ipv4_acl_feature.md index cb9be502..e5dfdd88 100644 --- a/docs/data-sources/transport_ipv4_acl_feature.md +++ b/docs/data-sources/transport_ipv4_acl_feature.md @@ -85,7 +85,7 @@ Read-Only: Read-Only: -- `port` (Number) destination port range or individual port number +- `port` (String) destination port range or individual port number @@ -93,4 +93,4 @@ Read-Only: Read-Only: -- `port` (Number) source port range or individual port number +- `port` (String) source port range or individual port number diff --git a/docs/data-sources/transport_ipv6_acl_feature.md b/docs/data-sources/transport_ipv6_acl_feature.md index 67dea9b2..78ab88fe 100644 --- a/docs/data-sources/transport_ipv6_acl_feature.md +++ b/docs/data-sources/transport_ipv6_acl_feature.md @@ -83,7 +83,7 @@ Read-Only: Read-Only: -- `port` (Number) destination port range or individual port number +- `port` (String) destination port range or individual port number @@ -91,4 +91,4 @@ Read-Only: Read-Only: -- `port` (Number) source port range or individual port number +- `port` (String) source port range or individual port number diff --git a/docs/resources/service_ipv4_acl_feature.md b/docs/resources/service_ipv4_acl_feature.md index 07942475..6abe18d1 100644 --- a/docs/resources/service_ipv4_acl_feature.md +++ b/docs/resources/service_ipv4_acl_feature.md @@ -128,7 +128,7 @@ Optional: Optional: -- `port` (Number) destination port range or individual port number +- `port` (String) destination port range or individual port number @@ -136,7 +136,7 @@ Optional: Optional: -- `port` (Number) source port range or individual port number +- `port` (String) source port range or individual port number ## Import diff --git a/docs/resources/service_ipv6_acl_feature.md b/docs/resources/service_ipv6_acl_feature.md index fb298314..3a1afed7 100644 --- a/docs/resources/service_ipv6_acl_feature.md +++ b/docs/resources/service_ipv6_acl_feature.md @@ -127,7 +127,7 @@ Optional: Optional: -- `port` (Number) destination port range or individual port number +- `port` (String) destination port range or individual port number @@ -135,7 +135,7 @@ Optional: Optional: -- `port` (Number) source port range or individual port number +- `port` (String) source port range or individual port number ## Import diff --git a/docs/resources/transport_ipv4_acl_feature.md b/docs/resources/transport_ipv4_acl_feature.md index 21c452e1..2fe33464 100644 --- a/docs/resources/transport_ipv4_acl_feature.md +++ b/docs/resources/transport_ipv4_acl_feature.md @@ -128,7 +128,7 @@ Optional: Optional: -- `port` (Number) destination port range or individual port number +- `port` (String) destination port range or individual port number @@ -136,7 +136,7 @@ Optional: Optional: -- `port` (Number) source port range or individual port number +- `port` (String) source port range or individual port number ## Import diff --git a/docs/resources/transport_ipv6_acl_feature.md b/docs/resources/transport_ipv6_acl_feature.md index 941cc4cf..3d8ce930 100644 --- a/docs/resources/transport_ipv6_acl_feature.md +++ b/docs/resources/transport_ipv6_acl_feature.md @@ -127,7 +127,7 @@ Optional: Optional: -- `port` (Number) destination port range or individual port number +- `port` (String) destination port range or individual port number @@ -135,7 +135,7 @@ Optional: Optional: -- `port` (Number) source port range or individual port number +- `port` (String) source port range or individual port number ## Import diff --git a/gen/definitions/profile_parcels/service_ipv4_acl.yaml b/gen/definitions/profile_parcels/service_ipv4_acl.yaml index 6191cf7a..871ea725 100644 --- a/gen/definitions/profile_parcels/service_ipv4_acl.yaml +++ b/gen/definitions/profile_parcels/service_ipv4_acl.yaml @@ -54,6 +54,8 @@ attributes: exclude_null: true attributes: - model_name: sourcePort + type: StringInt64 + id: true tf_name: port example: 8000 - model_name: refId @@ -72,6 +74,8 @@ attributes: attributes: - model_name: destinationPort tf_name: port + type: StringInt64 + id: true example: 9000 exclude_test: true - model_name: tcp diff --git a/gen/definitions/profile_parcels/service_ipv6_acl.yaml b/gen/definitions/profile_parcels/service_ipv6_acl.yaml index 24781088..8842ea67 100644 --- a/gen/definitions/profile_parcels/service_ipv6_acl.yaml +++ b/gen/definitions/profile_parcels/service_ipv6_acl.yaml @@ -47,6 +47,8 @@ attributes: attributes: - model_name: sourcePort tf_name: port + type: StringInt64 + id: true example: 8000 - model_name: refId data_path: [destinationDataPrefix, destinationDataPrefixList] @@ -64,6 +66,8 @@ attributes: attributes: - model_name: destinationPort tf_name: port + type: StringInt64 + id: true example: 9000 exclude_test: true - model_name: tcp diff --git a/gen/definitions/profile_parcels/transport_ipv4_acl.yaml b/gen/definitions/profile_parcels/transport_ipv4_acl.yaml index 282ddbbe..8a4f2d6a 100644 --- a/gen/definitions/profile_parcels/transport_ipv4_acl.yaml +++ b/gen/definitions/profile_parcels/transport_ipv4_acl.yaml @@ -55,6 +55,8 @@ attributes: attributes: - model_name: sourcePort tf_name: port + type: StringInt64 + id: true example: 8000 - model_name: refId data_path: [destinationDataPrefix, destinationDataPrefixList] @@ -72,6 +74,8 @@ attributes: attributes: - model_name: destinationPort tf_name: port + type: StringInt64 + id: true example: 9000 exclude_test: true - model_name: tcp diff --git a/gen/definitions/profile_parcels/transport_ipv6_acl.yaml b/gen/definitions/profile_parcels/transport_ipv6_acl.yaml index 0cbb0c38..33eac3b4 100644 --- a/gen/definitions/profile_parcels/transport_ipv6_acl.yaml +++ b/gen/definitions/profile_parcels/transport_ipv6_acl.yaml @@ -47,6 +47,8 @@ attributes: attributes: - model_name: sourcePort tf_name: port + type: StringInt64 + id: true example: 8000 - model_name: refId data_path: [destinationDataPrefix, destinationDataPrefixList] @@ -64,6 +66,8 @@ attributes: attributes: - model_name: destinationPort tf_name: port + type: StringInt64 + id: true example: 9000 exclude_test: true - model_name: tcp diff --git a/gen/generator.go b/gen/generator.go index f572af2b..9f66ceb2 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -464,6 +464,14 @@ func IsInt64ListSet(attribute YamlConfigAttribute) bool { return false } +// Templating helper function to return true if type is StringInt64 +func IsStringInt64(attribute YamlConfigAttribute) bool { + if attribute.Type == "StringInt64" { + return true + } + return false +} + // Templating helper function to return true if type is a list or set with nested elements func IsNestedListSet(attribute YamlConfigAttribute) bool { if (attribute.Type == "List" || attribute.Type == "Set") && attribute.ElementType == "" { @@ -543,6 +551,7 @@ var functions = template.FuncMap{ "isSet": IsSet, "isStringListSet": IsStringListSet, "isInt64ListSet": IsInt64ListSet, + "isStringInt64": IsStringInt64, "isNestedListSet": IsNestedListSet, "isNestedList": IsNestedList, "isNestedSet": IsNestedSet, @@ -800,8 +809,10 @@ func parseProfileParcelAttribute(attr *YamlConfigAttribute, model gjson.Result, } if t.Exists() { - if t.Get("properties.value.type").String() == "string" || t.Get("properties.value.anyOf.0.type").String() == "string" || t.Get("properties.value.oneOf.0.type").String() == "string" { - attr.Type = "String" + if attr.Type == "String" || attr.Type == "StringInt64" || t.Get("properties.value.type").String() == "string" || t.Get("properties.value.anyOf.0.type").String() == "string" || t.Get("properties.value.oneOf.0.type").String() == "string" { + if attr.Type != "StringInt64" { + attr.Type = "String" + } if value := t.Get("properties.value.minLength"); value.Exists() { attr.StringMinLength = value.Int() } @@ -816,9 +827,9 @@ func parseProfileParcelAttribute(attr *YamlConfigAttribute, model gjson.Result, attr.EnumValues = append(attr.EnumValues, v.String()) } } - } else if t.Get("properties.value.type").String() == "boolean" { + } else if attr.Type == "Bool" || t.Get("properties.value.type").String() == "boolean" { attr.Type = "Bool" - } else if t.Get("properties.value.type").String() == "integer" || t.Get("properties.value.type").String() == "number" || t.Get("properties.value.oneOf.0.type").String() == "integer" || t.Get("properties.value.oneOf.0.type").String() == "number" { + } else if attr.Type == "Int64" || t.Get("properties.value.type").String() == "integer" || t.Get("properties.value.type").String() == "number" || t.Get("properties.value.oneOf.0.type").String() == "integer" || t.Get("properties.value.oneOf.0.type").String() == "number" { if value := t.Get("properties.value.multipleOf"); value.Exists() { attr.Type = "Float64" diff --git a/gen/schema/schema.yaml b/gen/schema/schema.yaml index 7b7f9be9..28331d05 100644 --- a/gen/schema/schema.yaml +++ b/gen/schema/schema.yaml @@ -32,7 +32,7 @@ attribute: model_name: str(required=False) # Name of the attribute in the model (payload) response_model_name: str(required=False) # Name of the attribute in the model (response payload) tf_name: str(required=False) # Name of the attribute in the Terraform resource, by default derived from model_name - type: enum('String', 'Int64', 'Bool', 'List', 'Set', 'Version', 'Versions', required=False) # Type of the attribute + type: enum('String', 'Int64', 'StringInt64', 'Bool', 'List', 'Set', 'Version', 'Versions', required=False) # Type of the attribute element_type: enum('String', 'Int64', required=False) # only relevant if type is either 'List' or 'Set' object_type: enum('object', 'tree', 'list', required=False) # Feature template schema object type model_type_string: bool(required=False) # Set to true if element should be added as string to payload diff --git a/gen/templates/profile_parcels/data_source.go b/gen/templates/profile_parcels/data_source.go index f283cf2e..45b2e431 100644 --- a/gen/templates/profile_parcels/data_source.go +++ b/gen/templates/profile_parcels/data_source.go @@ -80,7 +80,7 @@ func (d *{{camelCase .Name}}ProfileParcelDataSource) Schema(ctx context.Context, }, {{- range .Attributes}} {{- if not .Value}} - "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else}}{{.Type}}{{end}}Attribute{ + "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else if isStringInt64 .}}String{{else}}{{.Type}}{{end}}Attribute{ MarkdownDescription: "{{.Description}}", {{- if isListSet .}} ElementType: types.{{.ElementType}}Type, @@ -95,7 +95,7 @@ func (d *{{camelCase .Name}}ProfileParcelDataSource) Schema(ctx context.Context, Attributes: map[string]schema.Attribute{ {{- range .Attributes}} {{- if not .Value}} - "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else}}{{.Type}}{{end}}Attribute{ + "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else if isStringInt64 .}}String{{else}}{{.Type}}{{end}}Attribute{ MarkdownDescription: "{{.Description}}", {{- if isListSet .}} ElementType: types.{{.ElementType}}Type, @@ -106,7 +106,7 @@ func (d *{{camelCase .Name}}ProfileParcelDataSource) Schema(ctx context.Context, Attributes: map[string]schema.Attribute{ {{- range .Attributes}} {{- if not .Value}} - "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else}}{{.Type}}{{end}}Attribute{ + "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else if isStringInt64 .}}String{{else}}{{.Type}}{{end}}Attribute{ MarkdownDescription: "{{.Description}}", {{- if isListSet .}} ElementType: types.{{.ElementType}}Type, @@ -117,7 +117,7 @@ func (d *{{camelCase .Name}}ProfileParcelDataSource) Schema(ctx context.Context, Attributes: map[string]schema.Attribute{ {{- range .Attributes}} {{- if not .Value}} - "{{.TfName}}": schema.{{if isList .}}List{{else if isSet .}}Set{{else}}{{.Type}}{{end}}Attribute{ + "{{.TfName}}": schema.{{if isList .}}List{{else if isSet .}}Set{{else if isStringInt64 .}}String{{else}}{{.Type}}{{end}}Attribute{ MarkdownDescription: "{{.Description}}", {{- if isListSet .}} ElementType: types.{{.ElementType}}Type, diff --git a/gen/templates/profile_parcels/model.go b/gen/templates/profile_parcels/model.go index 84b6412d..4cece5ca 100644 --- a/gen/templates/profile_parcels/model.go +++ b/gen/templates/profile_parcels/model.go @@ -44,6 +44,8 @@ type {{camelCase .Name}} struct { {{- if not .Value}} {{- if isNestedListSet .}} {{toGoName .TfName}} []{{$name}}{{toGoName .TfName}} `tfsdk:"{{.TfName}}"` +{{- else if eq .Type "StringInt64"}} + {{toGoName .TfName}} types.String `tfsdk:"{{.TfName}}"` {{- else}} {{toGoName .TfName}} types.{{.Type}} `tfsdk:"{{.TfName}}"` {{- if .Variable}} @@ -63,6 +65,8 @@ type {{$name}}{{toGoName .TfName}} struct { {{- if not .Value}} {{- if isNestedListSet .}} {{toGoName .TfName}} []{{$name}}{{$childName}}{{toGoName .TfName}} `tfsdk:"{{.TfName}}"` +{{- else if eq .Type "StringInt64"}} + {{toGoName .TfName}} types.String `tfsdk:"{{.TfName}}"` {{- else}} {{toGoName .TfName}} types.{{.Type}} `tfsdk:"{{.TfName}}"` {{- if .Variable}} @@ -89,6 +93,8 @@ type {{$name}}{{$childName}}{{toGoName .TfName}} struct { {{- if not .Value}} {{- if isNestedListSet .}} {{toGoName .TfName}} []{{$name}}{{$childName}}{{$childChildName}}{{toGoName .TfName}} `tfsdk:"{{.TfName}}"` +{{- else if eq .Type "StringInt64"}} + {{toGoName .TfName}} types.String `tfsdk:"{{.TfName}}"` {{- else}} {{toGoName .TfName}} types.{{.Type}} `tfsdk:"{{.TfName}}"` {{- if .Variable}} @@ -119,7 +125,11 @@ type {{$name}}{{$childName}}{{toGoName .TfName}} struct { type {{$name}}{{$childName}}{{$childChildName}}{{toGoName .TfName}} struct { {{- range .Attributes}} {{- if not .Value}} + {{- if eq .Type "StringInt64"}} + {{toGoName .TfName}} types.String `tfsdk:"{{.TfName}}"` + {{- else}} {{toGoName .TfName}} types.{{.Type}} `tfsdk:"{{.TfName}}"` + {{- end}} {{- if .Variable}} {{toGoName .TfName}}Variable types.String `tfsdk:"{{.TfName}}_variable"` {{- end}} @@ -168,7 +178,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType", "default") body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) } - {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly) (not .Reference)}} + {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly) (not .Reference)}} {{if .Variable}} if !data.{{toGoName .TfName}}Variable.IsNull() { if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Type "Bool"}} && data.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && data.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} { @@ -190,8 +200,16 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { data.{{toGoName .TfName}}.ElementsAs(ctx, &values, false) body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", values) {{- else}} + {{- if eq .Type "StringInt64" }} + if numValue, err := strconv.Atoi(data.{{toGoName .TfName}}.ValueString()); err != nil { + body, _ = sjson.Set(body, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", data.{{toGoName .TfName}}.ValueString()) + } else { + body, _ = sjson.Set(body, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", numValue) + } + {{- else}} body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", data.{{toGoName .TfName}}.Value{{.Type}}()) {{- end}} + {{- end}} } } {{- else if isNestedListSet .}} @@ -205,7 +223,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType", "default") itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) } - {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly)}} + {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly)}} {{if .Variable}} if !item.{{toGoName .TfName}}Variable.IsNull() { if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Type "Bool"}} && item.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && item.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} { @@ -227,8 +245,16 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { item.{{toGoName .TfName}}.ElementsAs(ctx, &values, false) itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", values) {{- else}} + {{- if eq .Type "StringInt64" }} + if numValue, err := strconv.Atoi(item.{{toGoName .TfName}}.ValueString()); err != nil { + itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", item.{{toGoName .TfName}}.ValueString()) + } else { + itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", numValue) + } + {{- else}} itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", item.{{toGoName .TfName}}.Value{{.Type}}()) {{- end}} + {{- end}} } } {{- else if isNestedListSet .}} @@ -242,7 +268,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType", "default") itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) } - {{- else if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)}} + {{- else if or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)}} {{if .Variable}} if !childItem.{{toGoName .TfName}}Variable.IsNull() { if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Type "Bool"}} && childItem.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && childItem.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} { @@ -264,8 +290,16 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { childItem.{{toGoName .TfName}}.ElementsAs(ctx, &values, false) itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", values) {{- else}} + {{- if eq .Type "StringInt64" }} + if numValue, err := strconv.Atoi(childItem.{{toGoName .TfName}}.ValueString()); err != nil { + itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", childItem.{{toGoName .TfName}}.ValueString()) + } else { + itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", numValue) + } + {{- else}} itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", childItem.{{toGoName .TfName}}.Value{{.Type}}()) {{- end}} + {{- end}} } } {{- else if isNestedListSet .}} @@ -279,7 +313,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType", "default") itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) } - {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly)}} + {{- else if and (or (eq .Type "String") (eq .Type "StringInt64") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly)}} {{if .Variable}} if !childChildItem.{{toGoName .TfName}}Variable.IsNull() { if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Type "Bool"}} && childChildItem.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && childChildItem.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} { @@ -300,8 +334,16 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { childChildItem.{{toGoName .TfName}}.ElementsAs(ctx, &values, false) itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", values) {{- else}} + {{- if eq .Type "StringInt64" }} + if numValue, err := strconv.Atoi(childChildItem.{{toGoName .TfName}}.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", childChildItem.{{toGoName .TfName}}.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", numValue) + } + {{- else}} itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", childChildItem.{{toGoName .TfName}}.Value{{.Type}}()) {{- end}} + {{- end}} } } {{- end}} @@ -336,15 +378,23 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) path := "payload.data." {{- range .Attributes}} {{- $cname := toGoName .TfName}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if eq .Type "StringInt64"}} + data.{{toGoName .TfName}} = types.StringNull() + {{- else}} data.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) + {{- end}} {{ if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { va := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value") {{if .Variable}}if t.String() == "variable" { data.{{toGoName .TfName}}Variable = types.StringValue(va.String()) } else{{end}} if t.String() == "global" { + {{- if eq .Type "StringInt64" }} + data.{{toGoName .TfName}} = types.StringValue(va.String()) + {{- else}} data.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}} + {{- end}} } } {{- else if isNestedListSet .}} @@ -354,15 +404,23 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) item := {{$name}}{{toGoName .TfName}}{} {{- range .Attributes}} {{- $ccname := toGoName .TfName}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if eq .Type "StringInt64"}} + item.{{toGoName .TfName}} = types.StringNull() + {{- else}} item.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) + {{- end}} {{ if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { va := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value") {{if .Variable}}if t.String() == "variable" { item.{{toGoName .TfName}}Variable = types.StringValue(va.String()) } else{{end}} if t.String() == "global" { + {{- if eq .Type "StringInt64" }} + item.{{toGoName .TfName}} = types.StringValue(va.String()) + {{- else}} item.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}} + {{- end}} } } {{- else if isNestedListSet .}} @@ -371,15 +429,23 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) cValue.ForEach(func(ck, cv gjson.Result) bool { cItem := {{$name}}{{$cname}}{{toGoName .TfName}}{} {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if eq .Type "StringInt64"}} + cItem.{{toGoName .TfName}} = types.StringNull() + {{- else}} cItem.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) + {{- end}} {{ if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { va := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value") {{if .Variable}}if t.String() == "variable" { cItem.{{toGoName .TfName}}Variable = types.StringValue(va.String()) } else{{end}} if t.String() == "global" { + {{- if eq .Type "StringInt64" }} + cItem.{{toGoName .TfName}} = types.StringValue(va.String()) + {{- else}} cItem.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}} + {{- end}} } } {{- else if isNestedListSet .}} @@ -388,15 +454,23 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := {{$name}}{{$cname}}{{$ccname}}{{toGoName .TfName}}{} {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if eq .Type "StringInt64"}} + ccItem.{{toGoName .TfName}} = types.StringNull() + {{- else}} ccItem.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) + {{- end}} {{ if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { va := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value") {{if .Variable}}if t.String() == "variable" { ccItem.{{toGoName .TfName}}Variable = types.StringValue(va.String()) } else{{end}} if t.String() == "global" { + {{- if eq .Type "StringInt64" }} + ccItem.{{toGoName .TfName}} = types.StringValue(va.String()) + {{- else}} ccItem.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}} + {{- end}} } } {{- end}} @@ -432,22 +506,30 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R } path := "payload.data." {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if eq .Type "StringInt64"}} + data.{{toGoName .TfName}} = types.StringNull() + {{- else}} data.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) + {{- end}} {{ if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { va := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value") {{if .Variable}}if t.String() == "variable" { data.{{toGoName .TfName}}Variable = types.StringValue(va.String()) } else{{end}} if t.String() == "global" { + {{- if eq .Type "StringInt64" }} + data.{{toGoName .TfName}} = types.StringValue(va.String()) + {{- else}} data.{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}} + {{- end}} } } {{- else if isNestedListSet .}} {{- $list := (toGoName .TfName)}} for i := range data.{{toGoName .TfName}} { - keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } - keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else if eq .Type "String"}}data.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} } + keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String") (eq .Type "StringInt64")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } + keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else if or (eq .Type "String") (eq .Type "StringInt64")}}data.{{$list}}[i].{{toGoName .TfName}}.ValueString(), {{end}}{{end}}{{end}} } keyValuesVariables := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if .Variable}}data.{{$list}}[i].{{toGoName .TfName}}Variable.ValueString(), {{else}}"", {{end}}{{end}}{{end}} } var r gjson.Result @@ -476,22 +558,30 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R ) {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if eq .Type "StringInt64"}} + data.{{$list}}[i].{{toGoName .TfName}} = types.StringNull() + {{- else}} data.{{$list}}[i].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) + {{- end}} {{ if .Variable}}data.{{$list}}[i].{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := r.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { va := r.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value") {{if .Variable}}if t.String() == "variable" { data.{{$list}}[i].{{toGoName .TfName}}Variable = types.StringValue(va.String()) } else{{end}} if t.String() == "global" { + {{- if eq .Type "StringInt64" }} + data.{{$list}}[i].{{toGoName .TfName}} = types.StringValue(va.String()) + {{- else}} data.{{$list}}[i].{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}} + {{- end}} } } {{- else if isNestedListSet .}} {{- $clist := (toGoName .TfName)}} for ci := range data.{{$list}}[i].{{toGoName .TfName}} { - keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } - keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueBool()), {{else if eq .Type "String"}}data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} } + keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String") (eq .Type "StringInt64")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } + keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueBool()), {{else if or (eq .Type "String") (eq .Type "StringInt64")}}data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueString(), {{end}}{{end}}{{end}} } keyValuesVariables := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if .Variable}}data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}Variable.ValueString(), {{else}}"", {{end}}{{end}}{{end}} } var cr gjson.Result @@ -520,22 +610,30 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R ) {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if eq .Type "StringInt64"}} + data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.StringNull() + {{- else}} data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) + {{- end}} {{ if .Variable}}data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := cr.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { va := cr.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value") {{if .Variable}}if t.String() == "variable" { data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}Variable = types.StringValue(va.String()) } else{{end}} if t.String() == "global" { + {{- if eq .Type "StringInt64" }} + data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.StringValue(va.String()) + {{- else}} data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}} + {{- end}} } } {{- else if isNestedListSet .}} {{- $cclist := (toGoName .TfName)}} for cci := range data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} { - keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } - keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}.ValueBool()), {{else if eq .Type "String"}}data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} } + keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String") (eq .Type "StringInt64")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } + keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}.ValueBool()), {{else if or (eq .Type "String") (eq .Type "StringInt64")}}data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}.ValueString(), {{end}}{{end}}{{end}} } keyValuesVariables := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if .Variable}}data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}Variable.ValueString(), {{else}}"", {{end}}{{end}}{{end}} } var ccr gjson.Result @@ -564,15 +662,23 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R ) {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "StringInt64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} + {{- if eq .Type "StringInt64"}} + data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}} = types.StringNull() + {{- else}} data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) + {{- end}} {{ if .Variable}}data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := ccr.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { va := ccr.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value") {{if .Variable}}if t.String() == "variable" { data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}Variable = types.StringValue(va.String()) } else{{end}} if t.String() == "global" { + {{- if eq .Type "StringInt64" }} + data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}} = types.StringValue(va.String()) + {{- else}} data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}} = {{if isListSet .}}helpers.Get{{.ElementType}}{{.Type}}(va.Array()){{else}}types.{{.Type}}Value(va.{{getGjsonType .Type}}()){{end}} + {{- end}} } } {{- end}} diff --git a/gen/templates/profile_parcels/resource.go b/gen/templates/profile_parcels/resource.go index 684361b1..dfe5abc6 100644 --- a/gen/templates/profile_parcels/resource.go +++ b/gen/templates/profile_parcels/resource.go @@ -86,7 +86,7 @@ func (r *{{camelCase .Name}}ProfileParcelResource) Schema(ctx context.Context, r }, {{- range .Attributes}} {{- if not .Value}} - "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else}}{{.Type}}{{end}}Attribute{ + "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else if isStringInt64 .}}String{{else}}{{.Type}}{{end}}Attribute{ MarkdownDescription: helpers.NewAttributeDescription("{{.Description}}{{if .ConditionalAttribute.Name}}, Attribute conditional on `{{.ConditionalAttribute.Name}}` being equal to `{{.ConditionalAttribute.Value}}`{{end}}") {{- if and (len .EnumValues) (not .IgnoreEnum) -}} .AddStringEnumDescription({{range .EnumValues}}"{{.}}", {{end}}) @@ -152,7 +152,7 @@ func (r *{{camelCase .Name}}ProfileParcelResource) Schema(ctx context.Context, r Attributes: map[string]schema.Attribute{ {{- range .Attributes}} {{- if not .Value}} - "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else}}{{.Type}}{{end}}Attribute{ + "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else if isStringInt64 .}}String{{else}}{{.Type}}{{end}}Attribute{ MarkdownDescription: helpers.NewAttributeDescription("{{.Description}}{{if .ConditionalAttribute.Name}}, Attribute conditional on `{{.ConditionalAttribute.Name}}` being equal to `{{.ConditionalAttribute.Value}}`{{end}}") {{- if and (len .EnumValues) (not .IgnoreEnum) -}} .AddStringEnumDescription({{range .EnumValues}}"{{.}}", {{end}}) @@ -214,7 +214,7 @@ func (r *{{camelCase .Name}}ProfileParcelResource) Schema(ctx context.Context, r Attributes: map[string]schema.Attribute{ {{- range .Attributes}} {{- if not .Value}} - "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else}}{{.Type}}{{end}}Attribute{ + "{{.TfName}}": schema.{{if isNestedListSet .}}{{.Type}}Nested{{else if isList .}}List{{else if isSet .}}Set{{else if isStringInt64 .}}String{{else}}{{.Type}}{{end}}Attribute{ MarkdownDescription: helpers.NewAttributeDescription("{{.Description}}{{if .ConditionalAttribute.Name}}, Attribute conditional on `{{.ConditionalAttribute.Name}}` being equal to `{{.ConditionalAttribute.Value}}`{{end}}") {{- if and (len .EnumValues) (not .IgnoreEnum) -}} .AddStringEnumDescription({{range .EnumValues}}"{{.}}", {{end}}) @@ -276,7 +276,7 @@ func (r *{{camelCase .Name}}ProfileParcelResource) Schema(ctx context.Context, r Attributes: map[string]schema.Attribute{ {{- range .Attributes}} {{- if not .Value}} - "{{.TfName}}": schema.{{if isList .}}List{{else if isSet .}}Set{{else}}{{.Type}}{{end}}Attribute{ + "{{.TfName}}": schema.{{if isList .}}List{{else if isSet .}}Set{{else if isStringInt64 .}}String{{else}}{{.Type}}{{end}}Attribute{ MarkdownDescription: helpers.NewAttributeDescription("{{.Description}}{{if .ConditionalAttribute.Name}}, Attribute conditional on `{{.ConditionalAttribute.Name}}` being equal to `{{.ConditionalAttribute.Value}}`{{end}}") {{- if and (len .EnumValues) (not .IgnoreEnum) -}} .AddStringEnumDescription({{range .EnumValues}}"{{.}}", {{end}}) diff --git a/internal/provider/data_source_sdwan_service_ipv4_acl_feature.go b/internal/provider/data_source_sdwan_service_ipv4_acl_feature.go index 91582552..08953423 100644 --- a/internal/provider/data_source_sdwan_service_ipv4_acl_feature.go +++ b/internal/provider/data_source_sdwan_service_ipv4_acl_feature.go @@ -141,7 +141,7 @@ func (d *ServiceIPv4ACLProfileParcelDataSource) Schema(ctx context.Context, req Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: "source port range or individual port number", Computed: true, }, @@ -165,7 +165,7 @@ func (d *ServiceIPv4ACLProfileParcelDataSource) Schema(ctx context.Context, req Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: "destination port range or individual port number", Computed: true, }, diff --git a/internal/provider/data_source_sdwan_service_ipv6_acl_feature.go b/internal/provider/data_source_sdwan_service_ipv6_acl_feature.go index b953f342..80d1dc21 100644 --- a/internal/provider/data_source_sdwan_service_ipv6_acl_feature.go +++ b/internal/provider/data_source_sdwan_service_ipv6_acl_feature.go @@ -125,7 +125,7 @@ func (d *ServiceIPv6ACLProfileParcelDataSource) Schema(ctx context.Context, req Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: "source port range or individual port number", Computed: true, }, @@ -145,7 +145,7 @@ func (d *ServiceIPv6ACLProfileParcelDataSource) Schema(ctx context.Context, req Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: "destination port range or individual port number", Computed: true, }, diff --git a/internal/provider/data_source_sdwan_transport_ipv4_acl_feature.go b/internal/provider/data_source_sdwan_transport_ipv4_acl_feature.go index e31702fa..6f98352a 100644 --- a/internal/provider/data_source_sdwan_transport_ipv4_acl_feature.go +++ b/internal/provider/data_source_sdwan_transport_ipv4_acl_feature.go @@ -141,7 +141,7 @@ func (d *TransportIPv4ACLProfileParcelDataSource) Schema(ctx context.Context, re Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: "source port range or individual port number", Computed: true, }, @@ -165,7 +165,7 @@ func (d *TransportIPv4ACLProfileParcelDataSource) Schema(ctx context.Context, re Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: "destination port range or individual port number", Computed: true, }, diff --git a/internal/provider/data_source_sdwan_transport_ipv6_acl_feature.go b/internal/provider/data_source_sdwan_transport_ipv6_acl_feature.go index 75a6e665..dcde6643 100644 --- a/internal/provider/data_source_sdwan_transport_ipv6_acl_feature.go +++ b/internal/provider/data_source_sdwan_transport_ipv6_acl_feature.go @@ -125,7 +125,7 @@ func (d *TransportIPv6ACLProfileParcelDataSource) Schema(ctx context.Context, re Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: "source port range or individual port number", Computed: true, }, @@ -145,7 +145,7 @@ func (d *TransportIPv6ACLProfileParcelDataSource) Schema(ctx context.Context, re Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: "destination port range or individual port number", Computed: true, }, diff --git a/internal/provider/model_sdwan_service_ipv4_acl_feature.go b/internal/provider/model_sdwan_service_ipv4_acl_feature.go index 9d0b9f3a..aeb16b3e 100644 --- a/internal/provider/model_sdwan_service_ipv4_acl_feature.go +++ b/internal/provider/model_sdwan_service_ipv4_acl_feature.go @@ -78,10 +78,10 @@ type ServiceIPv4ACLSequencesActions struct { } type ServiceIPv4ACLSequencesMatchEntriesSourcePorts struct { - Port types.Int64 `tfsdk:"port"` + Port types.String `tfsdk:"port"` } type ServiceIPv4ACLSequencesMatchEntriesDestinationPorts struct { - Port types.Int64 `tfsdk:"port"` + Port types.String `tfsdk:"port"` } // End of section. //template:end types @@ -198,7 +198,11 @@ func (data ServiceIPv4ACL) toBody(ctx context.Context) string { if !childChildItem.Port.IsNull() { if true { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.optionType", "global") - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", childChildItem.Port.ValueInt64()) + if numValue, err := strconv.Atoi(childChildItem.Port.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", childChildItem.Port.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", numValue) + } } } itemChildBody, _ = sjson.SetRaw(itemChildBody, "sourcePorts.-1", itemChildChildBody) @@ -229,7 +233,11 @@ func (data ServiceIPv4ACL) toBody(ctx context.Context) string { if !childChildItem.Port.IsNull() { if true { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.optionType", "global") - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", childChildItem.Port.ValueInt64()) + if numValue, err := strconv.Atoi(childChildItem.Port.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", childChildItem.Port.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", numValue) + } } } itemChildBody, _ = sjson.SetRaw(itemChildBody, "destinationPorts.-1", itemChildChildBody) @@ -410,12 +418,12 @@ func (data *ServiceIPv4ACL) fromBody(ctx context.Context, res gjson.Result) { cItem.SourcePorts = make([]ServiceIPv4ACLSequencesMatchEntriesSourcePorts, 0) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := ServiceIPv4ACLSequencesMatchEntriesSourcePorts{} - ccItem.Port = types.Int64Null() + ccItem.Port = types.StringNull() if t := ccv.Get("sourcePort.optionType"); t.Exists() { va := ccv.Get("sourcePort.value") if t.String() == "global" { - ccItem.Port = types.Int64Value(va.Int()) + ccItem.Port = types.StringValue(va.String()) } } cItem.SourcePorts = append(cItem.SourcePorts, ccItem) @@ -444,12 +452,12 @@ func (data *ServiceIPv4ACL) fromBody(ctx context.Context, res gjson.Result) { cItem.DestinationPorts = make([]ServiceIPv4ACLSequencesMatchEntriesDestinationPorts, 0) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := ServiceIPv4ACLSequencesMatchEntriesDestinationPorts{} - ccItem.Port = types.Int64Null() + ccItem.Port = types.StringNull() if t := ccv.Get("destinationPort.optionType"); t.Exists() { va := ccv.Get("destinationPort.value") if t.String() == "global" { - ccItem.Port = types.Int64Value(va.Int()) + ccItem.Port = types.StringValue(va.String()) } } cItem.DestinationPorts = append(cItem.DestinationPorts, ccItem) @@ -699,7 +707,7 @@ func (data *ServiceIPv4ACL) updateFromBody(ctx context.Context, res gjson.Result } for cci := range data.Sequences[i].MatchEntries[ci].SourcePorts { keys := [...]string{"sourcePort"} - keyValues := [...]string{strconv.FormatInt(data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port.ValueInt64(), 10)} + keyValues := [...]string{data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port.ValueString()} keyValuesVariables := [...]string{""} var ccr gjson.Result @@ -726,12 +734,12 @@ func (data *ServiceIPv4ACL) updateFromBody(ctx context.Context, res gjson.Result return true }, ) - data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.Int64Null() + data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.StringNull() if t := ccr.Get("sourcePort.optionType"); t.Exists() { va := ccr.Get("sourcePort.value") if t.String() == "global" { - data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.Int64Value(va.Int()) + data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.StringValue(va.String()) } } } @@ -755,7 +763,7 @@ func (data *ServiceIPv4ACL) updateFromBody(ctx context.Context, res gjson.Result } for cci := range data.Sequences[i].MatchEntries[ci].DestinationPorts { keys := [...]string{"destinationPort"} - keyValues := [...]string{strconv.FormatInt(data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port.ValueInt64(), 10)} + keyValues := [...]string{data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port.ValueString()} keyValuesVariables := [...]string{""} var ccr gjson.Result @@ -782,12 +790,12 @@ func (data *ServiceIPv4ACL) updateFromBody(ctx context.Context, res gjson.Result return true }, ) - data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.Int64Null() + data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.StringNull() if t := ccr.Get("destinationPort.optionType"); t.Exists() { va := ccr.Get("destinationPort.value") if t.String() == "global" { - data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.Int64Value(va.Int()) + data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.StringValue(va.String()) } } } diff --git a/internal/provider/model_sdwan_service_ipv6_acl_feature.go b/internal/provider/model_sdwan_service_ipv6_acl_feature.go index 58847b83..ea1b55ff 100644 --- a/internal/provider/model_sdwan_service_ipv6_acl_feature.go +++ b/internal/provider/model_sdwan_service_ipv6_acl_feature.go @@ -76,10 +76,10 @@ type ServiceIPv6ACLSequencesActions struct { } type ServiceIPv6ACLSequencesMatchEntriesSourcePorts struct { - Port types.Int64 `tfsdk:"port"` + Port types.String `tfsdk:"port"` } type ServiceIPv6ACLSequencesMatchEntriesDestinationPorts struct { - Port types.Int64 `tfsdk:"port"` + Port types.String `tfsdk:"port"` } // End of section. //template:end types @@ -172,7 +172,11 @@ func (data ServiceIPv6ACL) toBody(ctx context.Context) string { if !childChildItem.Port.IsNull() { if true { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.optionType", "global") - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", childChildItem.Port.ValueInt64()) + if numValue, err := strconv.Atoi(childChildItem.Port.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", childChildItem.Port.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", numValue) + } } } itemChildBody, _ = sjson.SetRaw(itemChildBody, "sourcePorts.-1", itemChildChildBody) @@ -197,7 +201,11 @@ func (data ServiceIPv6ACL) toBody(ctx context.Context) string { if !childChildItem.Port.IsNull() { if true { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.optionType", "global") - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", childChildItem.Port.ValueInt64()) + if numValue, err := strconv.Atoi(childChildItem.Port.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", childChildItem.Port.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", numValue) + } } } itemChildBody, _ = sjson.SetRaw(itemChildBody, "destinationPorts.-1", itemChildChildBody) @@ -376,12 +384,12 @@ func (data *ServiceIPv6ACL) fromBody(ctx context.Context, res gjson.Result) { cItem.SourcePorts = make([]ServiceIPv6ACLSequencesMatchEntriesSourcePorts, 0) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := ServiceIPv6ACLSequencesMatchEntriesSourcePorts{} - ccItem.Port = types.Int64Null() + ccItem.Port = types.StringNull() if t := ccv.Get("sourcePort.optionType"); t.Exists() { va := ccv.Get("sourcePort.value") if t.String() == "global" { - ccItem.Port = types.Int64Value(va.Int()) + ccItem.Port = types.StringValue(va.String()) } } cItem.SourcePorts = append(cItem.SourcePorts, ccItem) @@ -408,12 +416,12 @@ func (data *ServiceIPv6ACL) fromBody(ctx context.Context, res gjson.Result) { cItem.DestinationPorts = make([]ServiceIPv6ACLSequencesMatchEntriesDestinationPorts, 0) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := ServiceIPv6ACLSequencesMatchEntriesDestinationPorts{} - ccItem.Port = types.Int64Null() + ccItem.Port = types.StringNull() if t := ccv.Get("destinationPort.optionType"); t.Exists() { va := ccv.Get("destinationPort.value") if t.String() == "global" { - ccItem.Port = types.Int64Value(va.Int()) + ccItem.Port = types.StringValue(va.String()) } } cItem.DestinationPorts = append(cItem.DestinationPorts, ccItem) @@ -661,7 +669,7 @@ func (data *ServiceIPv6ACL) updateFromBody(ctx context.Context, res gjson.Result } for cci := range data.Sequences[i].MatchEntries[ci].SourcePorts { keys := [...]string{"sourcePort"} - keyValues := [...]string{strconv.FormatInt(data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port.ValueInt64(), 10)} + keyValues := [...]string{data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port.ValueString()} keyValuesVariables := [...]string{""} var ccr gjson.Result @@ -688,12 +696,12 @@ func (data *ServiceIPv6ACL) updateFromBody(ctx context.Context, res gjson.Result return true }, ) - data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.Int64Null() + data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.StringNull() if t := ccr.Get("sourcePort.optionType"); t.Exists() { va := ccr.Get("sourcePort.value") if t.String() == "global" { - data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.Int64Value(va.Int()) + data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.StringValue(va.String()) } } } @@ -715,7 +723,7 @@ func (data *ServiceIPv6ACL) updateFromBody(ctx context.Context, res gjson.Result } for cci := range data.Sequences[i].MatchEntries[ci].DestinationPorts { keys := [...]string{"destinationPort"} - keyValues := [...]string{strconv.FormatInt(data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port.ValueInt64(), 10)} + keyValues := [...]string{data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port.ValueString()} keyValuesVariables := [...]string{""} var ccr gjson.Result @@ -742,12 +750,12 @@ func (data *ServiceIPv6ACL) updateFromBody(ctx context.Context, res gjson.Result return true }, ) - data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.Int64Null() + data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.StringNull() if t := ccr.Get("destinationPort.optionType"); t.Exists() { va := ccr.Get("destinationPort.value") if t.String() == "global" { - data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.Int64Value(va.Int()) + data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.StringValue(va.String()) } } } diff --git a/internal/provider/model_sdwan_transport_ipv4_acl_feature.go b/internal/provider/model_sdwan_transport_ipv4_acl_feature.go index 2c65c2ea..98fd1ea8 100644 --- a/internal/provider/model_sdwan_transport_ipv4_acl_feature.go +++ b/internal/provider/model_sdwan_transport_ipv4_acl_feature.go @@ -78,10 +78,10 @@ type TransportIPv4ACLSequencesActions struct { } type TransportIPv4ACLSequencesMatchEntriesSourcePorts struct { - Port types.Int64 `tfsdk:"port"` + Port types.String `tfsdk:"port"` } type TransportIPv4ACLSequencesMatchEntriesDestinationPorts struct { - Port types.Int64 `tfsdk:"port"` + Port types.String `tfsdk:"port"` } // End of section. //template:end types @@ -198,7 +198,11 @@ func (data TransportIPv4ACL) toBody(ctx context.Context) string { if !childChildItem.Port.IsNull() { if true { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.optionType", "global") - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", childChildItem.Port.ValueInt64()) + if numValue, err := strconv.Atoi(childChildItem.Port.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", childChildItem.Port.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", numValue) + } } } itemChildBody, _ = sjson.SetRaw(itemChildBody, "sourcePorts.-1", itemChildChildBody) @@ -229,7 +233,11 @@ func (data TransportIPv4ACL) toBody(ctx context.Context) string { if !childChildItem.Port.IsNull() { if true { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.optionType", "global") - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", childChildItem.Port.ValueInt64()) + if numValue, err := strconv.Atoi(childChildItem.Port.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", childChildItem.Port.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", numValue) + } } } itemChildBody, _ = sjson.SetRaw(itemChildBody, "destinationPorts.-1", itemChildChildBody) @@ -410,12 +418,12 @@ func (data *TransportIPv4ACL) fromBody(ctx context.Context, res gjson.Result) { cItem.SourcePorts = make([]TransportIPv4ACLSequencesMatchEntriesSourcePorts, 0) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := TransportIPv4ACLSequencesMatchEntriesSourcePorts{} - ccItem.Port = types.Int64Null() + ccItem.Port = types.StringNull() if t := ccv.Get("sourcePort.optionType"); t.Exists() { va := ccv.Get("sourcePort.value") if t.String() == "global" { - ccItem.Port = types.Int64Value(va.Int()) + ccItem.Port = types.StringValue(va.String()) } } cItem.SourcePorts = append(cItem.SourcePorts, ccItem) @@ -444,12 +452,12 @@ func (data *TransportIPv4ACL) fromBody(ctx context.Context, res gjson.Result) { cItem.DestinationPorts = make([]TransportIPv4ACLSequencesMatchEntriesDestinationPorts, 0) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := TransportIPv4ACLSequencesMatchEntriesDestinationPorts{} - ccItem.Port = types.Int64Null() + ccItem.Port = types.StringNull() if t := ccv.Get("destinationPort.optionType"); t.Exists() { va := ccv.Get("destinationPort.value") if t.String() == "global" { - ccItem.Port = types.Int64Value(va.Int()) + ccItem.Port = types.StringValue(va.String()) } } cItem.DestinationPorts = append(cItem.DestinationPorts, ccItem) @@ -699,7 +707,7 @@ func (data *TransportIPv4ACL) updateFromBody(ctx context.Context, res gjson.Resu } for cci := range data.Sequences[i].MatchEntries[ci].SourcePorts { keys := [...]string{"sourcePort"} - keyValues := [...]string{strconv.FormatInt(data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port.ValueInt64(), 10)} + keyValues := [...]string{data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port.ValueString()} keyValuesVariables := [...]string{""} var ccr gjson.Result @@ -726,12 +734,12 @@ func (data *TransportIPv4ACL) updateFromBody(ctx context.Context, res gjson.Resu return true }, ) - data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.Int64Null() + data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.StringNull() if t := ccr.Get("sourcePort.optionType"); t.Exists() { va := ccr.Get("sourcePort.value") if t.String() == "global" { - data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.Int64Value(va.Int()) + data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.StringValue(va.String()) } } } @@ -755,7 +763,7 @@ func (data *TransportIPv4ACL) updateFromBody(ctx context.Context, res gjson.Resu } for cci := range data.Sequences[i].MatchEntries[ci].DestinationPorts { keys := [...]string{"destinationPort"} - keyValues := [...]string{strconv.FormatInt(data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port.ValueInt64(), 10)} + keyValues := [...]string{data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port.ValueString()} keyValuesVariables := [...]string{""} var ccr gjson.Result @@ -782,12 +790,12 @@ func (data *TransportIPv4ACL) updateFromBody(ctx context.Context, res gjson.Resu return true }, ) - data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.Int64Null() + data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.StringNull() if t := ccr.Get("destinationPort.optionType"); t.Exists() { va := ccr.Get("destinationPort.value") if t.String() == "global" { - data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.Int64Value(va.Int()) + data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.StringValue(va.String()) } } } diff --git a/internal/provider/model_sdwan_transport_ipv6_acl_feature.go b/internal/provider/model_sdwan_transport_ipv6_acl_feature.go index 3ecc4241..1e09308f 100644 --- a/internal/provider/model_sdwan_transport_ipv6_acl_feature.go +++ b/internal/provider/model_sdwan_transport_ipv6_acl_feature.go @@ -76,10 +76,10 @@ type TransportIPv6ACLSequencesActions struct { } type TransportIPv6ACLSequencesMatchEntriesSourcePorts struct { - Port types.Int64 `tfsdk:"port"` + Port types.String `tfsdk:"port"` } type TransportIPv6ACLSequencesMatchEntriesDestinationPorts struct { - Port types.Int64 `tfsdk:"port"` + Port types.String `tfsdk:"port"` } // End of section. //template:end types @@ -172,7 +172,11 @@ func (data TransportIPv6ACL) toBody(ctx context.Context) string { if !childChildItem.Port.IsNull() { if true { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.optionType", "global") - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", childChildItem.Port.ValueInt64()) + if numValue, err := strconv.Atoi(childChildItem.Port.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", childChildItem.Port.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "sourcePort.value", numValue) + } } } itemChildBody, _ = sjson.SetRaw(itemChildBody, "sourcePorts.-1", itemChildChildBody) @@ -197,7 +201,11 @@ func (data TransportIPv6ACL) toBody(ctx context.Context) string { if !childChildItem.Port.IsNull() { if true { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.optionType", "global") - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", childChildItem.Port.ValueInt64()) + if numValue, err := strconv.Atoi(childChildItem.Port.ValueString()); err != nil { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", childChildItem.Port.ValueString()) + } else { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "destinationPort.value", numValue) + } } } itemChildBody, _ = sjson.SetRaw(itemChildBody, "destinationPorts.-1", itemChildChildBody) @@ -376,12 +384,12 @@ func (data *TransportIPv6ACL) fromBody(ctx context.Context, res gjson.Result) { cItem.SourcePorts = make([]TransportIPv6ACLSequencesMatchEntriesSourcePorts, 0) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := TransportIPv6ACLSequencesMatchEntriesSourcePorts{} - ccItem.Port = types.Int64Null() + ccItem.Port = types.StringNull() if t := ccv.Get("sourcePort.optionType"); t.Exists() { va := ccv.Get("sourcePort.value") if t.String() == "global" { - ccItem.Port = types.Int64Value(va.Int()) + ccItem.Port = types.StringValue(va.String()) } } cItem.SourcePorts = append(cItem.SourcePorts, ccItem) @@ -408,12 +416,12 @@ func (data *TransportIPv6ACL) fromBody(ctx context.Context, res gjson.Result) { cItem.DestinationPorts = make([]TransportIPv6ACLSequencesMatchEntriesDestinationPorts, 0) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := TransportIPv6ACLSequencesMatchEntriesDestinationPorts{} - ccItem.Port = types.Int64Null() + ccItem.Port = types.StringNull() if t := ccv.Get("destinationPort.optionType"); t.Exists() { va := ccv.Get("destinationPort.value") if t.String() == "global" { - ccItem.Port = types.Int64Value(va.Int()) + ccItem.Port = types.StringValue(va.String()) } } cItem.DestinationPorts = append(cItem.DestinationPorts, ccItem) @@ -661,7 +669,7 @@ func (data *TransportIPv6ACL) updateFromBody(ctx context.Context, res gjson.Resu } for cci := range data.Sequences[i].MatchEntries[ci].SourcePorts { keys := [...]string{"sourcePort"} - keyValues := [...]string{strconv.FormatInt(data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port.ValueInt64(), 10)} + keyValues := [...]string{data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port.ValueString()} keyValuesVariables := [...]string{""} var ccr gjson.Result @@ -688,12 +696,12 @@ func (data *TransportIPv6ACL) updateFromBody(ctx context.Context, res gjson.Resu return true }, ) - data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.Int64Null() + data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.StringNull() if t := ccr.Get("sourcePort.optionType"); t.Exists() { va := ccr.Get("sourcePort.value") if t.String() == "global" { - data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.Int64Value(va.Int()) + data.Sequences[i].MatchEntries[ci].SourcePorts[cci].Port = types.StringValue(va.String()) } } } @@ -715,7 +723,7 @@ func (data *TransportIPv6ACL) updateFromBody(ctx context.Context, res gjson.Resu } for cci := range data.Sequences[i].MatchEntries[ci].DestinationPorts { keys := [...]string{"destinationPort"} - keyValues := [...]string{strconv.FormatInt(data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port.ValueInt64(), 10)} + keyValues := [...]string{data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port.ValueString()} keyValuesVariables := [...]string{""} var ccr gjson.Result @@ -742,12 +750,12 @@ func (data *TransportIPv6ACL) updateFromBody(ctx context.Context, res gjson.Resu return true }, ) - data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.Int64Null() + data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.StringNull() if t := ccr.Get("destinationPort.optionType"); t.Exists() { va := ccr.Get("destinationPort.value") if t.String() == "global" { - data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.Int64Value(va.Int()) + data.Sequences[i].MatchEntries[ci].DestinationPorts[cci].Port = types.StringValue(va.String()) } } } diff --git a/internal/provider/resource_sdwan_service_ipv4_acl_feature.go b/internal/provider/resource_sdwan_service_ipv4_acl_feature.go index 34f93f3f..e3253e39 100644 --- a/internal/provider/resource_sdwan_service_ipv4_acl_feature.go +++ b/internal/provider/resource_sdwan_service_ipv4_acl_feature.go @@ -170,7 +170,7 @@ func (r *ServiceIPv4ACLProfileParcelResource) Schema(ctx context.Context, req re Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("source port range or individual port number").String, Optional: true, }, @@ -200,7 +200,7 @@ func (r *ServiceIPv4ACLProfileParcelResource) Schema(ctx context.Context, req re Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("destination port range or individual port number").String, Optional: true, }, diff --git a/internal/provider/resource_sdwan_service_ipv6_acl_feature.go b/internal/provider/resource_sdwan_service_ipv6_acl_feature.go index 25f9df08..869ea65e 100644 --- a/internal/provider/resource_sdwan_service_ipv6_acl_feature.go +++ b/internal/provider/resource_sdwan_service_ipv6_acl_feature.go @@ -158,7 +158,7 @@ func (r *ServiceIPv6ACLProfileParcelResource) Schema(ctx context.Context, req re Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("source port range or individual port number").String, Optional: true, }, @@ -184,7 +184,7 @@ func (r *ServiceIPv6ACLProfileParcelResource) Schema(ctx context.Context, req re Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("destination port range or individual port number").String, Optional: true, }, diff --git a/internal/provider/resource_sdwan_transport_ipv4_acl_feature.go b/internal/provider/resource_sdwan_transport_ipv4_acl_feature.go index 052fdfcf..c980aadb 100644 --- a/internal/provider/resource_sdwan_transport_ipv4_acl_feature.go +++ b/internal/provider/resource_sdwan_transport_ipv4_acl_feature.go @@ -170,7 +170,7 @@ func (r *TransportIPv4ACLProfileParcelResource) Schema(ctx context.Context, req Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("source port range or individual port number").String, Optional: true, }, @@ -200,7 +200,7 @@ func (r *TransportIPv4ACLProfileParcelResource) Schema(ctx context.Context, req Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("destination port range or individual port number").String, Optional: true, }, diff --git a/internal/provider/resource_sdwan_transport_ipv6_acl_feature.go b/internal/provider/resource_sdwan_transport_ipv6_acl_feature.go index 01620bab..4be59ba7 100644 --- a/internal/provider/resource_sdwan_transport_ipv6_acl_feature.go +++ b/internal/provider/resource_sdwan_transport_ipv6_acl_feature.go @@ -158,7 +158,7 @@ func (r *TransportIPv6ACLProfileParcelResource) Schema(ctx context.Context, req Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("source port range or individual port number").String, Optional: true, }, @@ -184,7 +184,7 @@ func (r *TransportIPv6ACLProfileParcelResource) Schema(ctx context.Context, req Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "port": schema.Int64Attribute{ + "port": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("destination port range or individual port number").String, Optional: true, },