diff --git a/docs/data-sources/transport_management_vpn_profile_parcel.md b/docs/data-sources/transport_management_vpn_profile_parcel.md index ad1076c9..d5e5244e 100644 --- a/docs/data-sources/transport_management_vpn_profile_parcel.md +++ b/docs/data-sources/transport_management_vpn_profile_parcel.md @@ -77,6 +77,7 @@ Read-Only: Read-Only: +- `gateway` (String) Gateway - `nat` (String) IPv6 Nat - `nat_variable` (String) Variable name - `next_hops` (Attributes List) IPv6 Route Gateway Next Hop (see [below for nested schema](#nestedatt--ipv6_static_routes--next_hops)) diff --git a/docs/resources/transport_management_vpn_profile_parcel.md b/docs/resources/transport_management_vpn_profile_parcel.md index 5fd65793..103676e3 100644 --- a/docs/resources/transport_management_vpn_profile_parcel.md +++ b/docs/resources/transport_management_vpn_profile_parcel.md @@ -46,7 +46,8 @@ resource "sdwan_transport_management_vpn_profile_parcel" "example" { ] ipv6_static_routes = [ { - prefix = "2002::/16" + prefix = "2002::/16" + gateway = "next_hop" next_hops = [ { address = "2001:0:0:1::1" @@ -126,11 +127,13 @@ Optional: Optional: -- `nat` (String) IPv6 Nat +- `gateway` (String) Gateway + - Choices: `next_hop`, `null0`, `nat` +- `nat` (String) IPv6 Nat, Attribute conditional on `gateway` being equal to `nat` - Choices: `NAT64`, `NAT66` - `nat_variable` (String) Variable name -- `next_hops` (Attributes List) IPv6 Route Gateway Next Hop (see [below for nested schema](#nestedatt--ipv6_static_routes--next_hops)) -- `null0` (Boolean) IPv6 Route Gateway Next Hop +- `next_hops` (Attributes List) IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `next_hop` (see [below for nested schema](#nestedatt--ipv6_static_routes--next_hops)) +- `null0` (Boolean) IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `null0` - `prefix` (String) Prefix - `prefix_variable` (String) Variable name @@ -143,6 +146,7 @@ Optional: - `address_variable` (String) Variable name - `administrative_distance` (Number) Administrative distance - Range: `1`-`254` + - Default value: `1` - `administrative_distance_variable` (String) Variable name diff --git a/examples/resources/sdwan_transport_management_vpn_profile_parcel/resource.tf b/examples/resources/sdwan_transport_management_vpn_profile_parcel/resource.tf index 2c8b737a..b740ee08 100644 --- a/examples/resources/sdwan_transport_management_vpn_profile_parcel/resource.tf +++ b/examples/resources/sdwan_transport_management_vpn_profile_parcel/resource.tf @@ -29,7 +29,8 @@ resource "sdwan_transport_management_vpn_profile_parcel" "example" { ] ipv6_static_routes = [ { - prefix = "2002::/16" + prefix = "2002::/16" + gateway = "next_hop" next_hops = [ { address = "2001:0:0:1::1" diff --git a/gen/definitions/profile_parcels/transport_management_vpn.yaml b/gen/definitions/profile_parcels/transport_management_vpn.yaml index 1cc5c0f9..aa2016b3 100644 --- a/gen/definitions/profile_parcels/transport_management_vpn.yaml +++ b/gen/definitions/profile_parcels/transport_management_vpn.yaml @@ -65,11 +65,15 @@ attributes: - model_name: distance tf_name: administrative_distance example: 1 + default_value: 1 + default_value_present: true - model_name: distance tf_name: administrative_distance conditional_attribute: name: gateway value: null0 + default_value: 1 + default_value_present: true example: 1 - model_name: ipv6Route tf_name: ipv6_static_routes @@ -77,10 +81,19 @@ attributes: - model_name: prefix id: true example: 2002::/16 + - tf_name: gateway + type: String + tf_only: true + description: Gateway + enum_values: [next_hop, null0, nat] + example: next_hop - model_name: nextHop tf_name: next_hops data_path: [oneOfIpRoute, nextHopContainer] mandatory: true + conditional_attribute: + name: gateway + value: next_hop attributes: - model_name: address id: true @@ -88,13 +101,21 @@ attributes: - model_name: distance tf_name: administrative_distance example: 1 + default_value: 1 + default_value_present: true - model_name: null0 data_path: [oneOfIpRoute] exclude_test: true + conditional_attribute: + name: gateway + value: null0 example: true - model_name: nat data_path: [oneOfIpRoute] exclude_test: true + conditional_attribute: + name: gateway + value: nat example: NAT64 test_prerequisites: | diff --git a/gen/templates/profile_parcels/model.go b/gen/templates/profile_parcels/model.go index e3f7682c..45d41fb3 100644 --- a/gen/templates/profile_parcels/model.go +++ b/gen/templates/profile_parcels/model.go @@ -165,7 +165,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 .Reference)}} + {{- else if and (or (eq .Type "String") (eq .Type "Int64") (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}} { @@ -200,7 +200,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 or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)}} + {{- else if and (or (eq .Type "String") (eq .Type "Int64") (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}} { @@ -270,7 +270,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 or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)}} + {{- else if and (or (eq .Type "String") (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}} { @@ -325,7 +325,7 @@ 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 .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -343,7 +343,7 @@ 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 .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} item.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -360,7 +360,7 @@ 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 .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} cItem.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -377,7 +377,7 @@ 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 .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} ccItem.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -421,7 +421,7 @@ 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 .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -462,7 +462,7 @@ 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 .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{$list}}[i].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}data.{{$list}}[i].{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := r.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -503,7 +503,7 @@ 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 .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{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() { @@ -544,7 +544,7 @@ 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 .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{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() { diff --git a/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel.go b/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel.go index a4b18350..910d08d0 100644 --- a/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel.go +++ b/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel.go @@ -217,6 +217,10 @@ func (d *TransportManagementVPNProfileParcelDataSource) Schema(ctx context.Conte MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, Computed: true, }, + "gateway": schema.StringAttribute{ + MarkdownDescription: "Gateway", + Computed: true, + }, "next_hops": schema.ListNestedAttribute{ MarkdownDescription: "IPv6 Route Gateway Next Hop", Computed: true, diff --git a/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel_test.go b/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel_test.go index b1444294..ada8ae8d 100644 --- a/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel_test.go @@ -46,6 +46,7 @@ func TestAccDataSourceSdwanTransportManagementVPNProfileParcel(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv4_static_routes.0.next_hops.0.administrative_distance", "1")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv4_static_routes.0.administrative_distance", "1")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.prefix", "2002::/16")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.gateway", "next_hop")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.next_hops.0.address", "2001:0:0:1::1")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.next_hops.0.administrative_distance", "1")) resource.Test(t, resource.TestCase{ @@ -100,6 +101,7 @@ func testAccDataSourceSdwanTransportManagementVPNProfileParcelConfig() string { config += ` }]` + "\n" config += ` ipv6_static_routes = [{` + "\n" config += ` prefix = "2002::/16"` + "\n" + config += ` gateway = "next_hop"` + "\n" config += ` next_hops = [{` + "\n" config += ` address = "2001:0:0:1::1"` + "\n" config += ` administrative_distance = 1` + "\n" diff --git a/internal/provider/model_sdwan_transport_management_vpn_profile_parcel.go b/internal/provider/model_sdwan_transport_management_vpn_profile_parcel.go index f3716690..f61c417b 100644 --- a/internal/provider/model_sdwan_transport_management_vpn_profile_parcel.go +++ b/internal/provider/model_sdwan_transport_management_vpn_profile_parcel.go @@ -74,6 +74,7 @@ type TransportManagementVPNIpv4StaticRoutes struct { type TransportManagementVPNIpv6StaticRoutes struct { Prefix types.String `tfsdk:"prefix"` PrefixVariable types.String `tfsdk:"prefix_variable"` + Gateway types.String `tfsdk:"gateway"` NextHops []TransportManagementVPNIpv6StaticRoutesNextHops `tfsdk:"next_hops"` Null0 types.Bool `tfsdk:"null0"` Nat types.String `tfsdk:"nat"` @@ -349,7 +350,7 @@ func (data TransportManagementVPN) toBody(ctx context.Context) string { itemBody, _ = sjson.Set(itemBody, "prefix.value", item.Prefix.ValueString()) } } - if true { + if true && item.Gateway.ValueString() == "next_hop" { for _, childItem := range item.NextHops { itemChildBody := "" @@ -371,7 +372,12 @@ func (data TransportManagementVPN) toBody(ctx context.Context) string { itemChildBody, _ = sjson.Set(itemChildBody, "distance.optionType", "variable") itemChildBody, _ = sjson.Set(itemChildBody, "distance.value", childItem.AdministrativeDistanceVariable.ValueString()) } - } else if !childItem.AdministrativeDistance.IsNull() { + } else if childItem.AdministrativeDistance.IsNull() { + if true { + itemChildBody, _ = sjson.Set(itemChildBody, "distance.optionType", "default") + itemChildBody, _ = sjson.Set(itemChildBody, "distance.value", 1) + } + } else { if true { itemChildBody, _ = sjson.Set(itemChildBody, "distance.optionType", "global") itemChildBody, _ = sjson.Set(itemChildBody, "distance.value", childItem.AdministrativeDistance.ValueInt64()) @@ -381,19 +387,19 @@ func (data TransportManagementVPN) toBody(ctx context.Context) string { } } if !item.Null0.IsNull() { - if true { + if true && item.Gateway.ValueString() == "null0" { itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.null0.optionType", "global") itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.null0.value", item.Null0.ValueBool()) } } if !item.NatVariable.IsNull() { - if true { + if true && item.Gateway.ValueString() == "nat" { itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.optionType", "variable") itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.value", item.NatVariable.ValueString()) } } else if !item.Nat.IsNull() { - if true { + if true && item.Gateway.ValueString() == "nat" { itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.optionType", "global") itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.value", item.Nat.ValueString()) } diff --git a/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel.go b/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel.go index a7a84964..893f5537 100644 --- a/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel.go +++ b/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel.go @@ -248,8 +248,15 @@ func (r *TransportManagementVPNProfileParcelResource) Schema(ctx context.Context MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, Optional: true, }, + "gateway": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Gateway").AddStringEnumDescription("next_hop", "null0", "nat").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("next_hop", "null0", "nat"), + }, + }, "next_hops": schema.ListNestedAttribute{ - MarkdownDescription: helpers.NewAttributeDescription("IPv6 Route Gateway Next Hop").String, + MarkdownDescription: helpers.NewAttributeDescription("IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `next_hop`").String, Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -262,7 +269,7 @@ func (r *TransportManagementVPNProfileParcelResource) Schema(ctx context.Context Optional: true, }, "administrative_distance": schema.Int64Attribute{ - MarkdownDescription: helpers.NewAttributeDescription("Administrative distance").AddIntegerRangeDescription(1, 254).String, + MarkdownDescription: helpers.NewAttributeDescription("Administrative distance").AddIntegerRangeDescription(1, 254).AddDefaultValueDescription("1").String, Optional: true, Validators: []validator.Int64{ int64validator.Between(1, 254), @@ -276,11 +283,11 @@ func (r *TransportManagementVPNProfileParcelResource) Schema(ctx context.Context }, }, "null0": schema.BoolAttribute{ - MarkdownDescription: helpers.NewAttributeDescription("IPv6 Route Gateway Next Hop").String, + MarkdownDescription: helpers.NewAttributeDescription("IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `null0`").String, Optional: true, }, "nat": schema.StringAttribute{ - MarkdownDescription: helpers.NewAttributeDescription("IPv6 Nat").AddStringEnumDescription("NAT64", "NAT66").String, + MarkdownDescription: helpers.NewAttributeDescription("IPv6 Nat, Attribute conditional on `gateway` being equal to `nat`").AddStringEnumDescription("NAT64", "NAT66").String, Optional: true, Validators: []validator.String{ stringvalidator.OneOf("NAT64", "NAT66"), diff --git a/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel_test.go b/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel_test.go index 2f784abf..b68dca9a 100644 --- a/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel_test.go @@ -46,6 +46,7 @@ func TestAccSdwanTransportManagementVPNProfileParcel(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv4_static_routes.0.next_hops.0.administrative_distance", "1")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv4_static_routes.0.administrative_distance", "1")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.prefix", "2002::/16")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.gateway", "next_hop")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.next_hops.0.address", "2001:0:0:1::1")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.next_hops.0.administrative_distance", "1")) resource.Test(t, resource.TestCase{ @@ -115,6 +116,7 @@ func testAccSdwanTransportManagementVPNProfileParcelConfig_all() string { config += ` }]` + "\n" config += ` ipv6_static_routes = [{` + "\n" config += ` prefix = "2002::/16"` + "\n" + config += ` gateway = "next_hop"` + "\n" config += ` next_hops = [{` + "\n" config += ` address = "2001:0:0:1::1"` + "\n" config += ` administrative_distance = 1` + "\n"