From 2937b3fe9f3e956fccf789d14cca09df76715e3f Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Fri, 4 Jul 2025 16:35:57 +0100 Subject: [PATCH 1/7] Resolve issue #426 --- ...ta_source_sdwan_service_lan_vpn_feature.go | 10 ++- ...vice_lan_vpn_interface_ethernet_feature.go | 10 ++- ...port_wan_vpn_interface_ethernet_feature.go | 10 ++- .../model_sdwan_service_lan_vpn_feature.go | 74 ++++++++++++------- ...vice_lan_vpn_interface_ethernet_feature.go | 40 ++++++---- ...port_wan_vpn_interface_ethernet_feature.go | 46 +++++++----- .../resource_sdwan_service_lan_vpn_feature.go | 30 ++++---- ...vice_lan_vpn_interface_ethernet_feature.go | 30 ++++---- ...port_wan_vpn_interface_ethernet_feature.go | 30 ++++---- 9 files changed, 165 insertions(+), 115 deletions(-) diff --git a/internal/provider/data_source_sdwan_service_lan_vpn_feature.go b/internal/provider/data_source_sdwan_service_lan_vpn_feature.go index 1828f7d2c..7fb62cdc0 100644 --- a/internal/provider/data_source_sdwan_service_lan_vpn_feature.go +++ b/internal/provider/data_source_sdwan_service_lan_vpn_feature.go @@ -24,6 +24,7 @@ import ( "net/url" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -961,7 +962,6 @@ func (d *ServiceLANVPNProfileParcelDataSource) Configure(_ context.Context, req // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin read func (d *ServiceLANVPNProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { var config ServiceLANVPN @@ -974,18 +974,20 @@ func (d *ServiceLANVPNProfileParcelDataSource) Read(ctx context.Context, req dat tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + // Get Manager Version + d.client.Authenticate() + currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion)) + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) return } - config.fromBody(ctx, res) + config.fromBody(ctx, res, currentVersion) tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) diags = resp.State.Set(ctx, &config) resp.Diagnostics.Append(diags...) } - -// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go b/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go index 3521303d7..c0328a661 100644 --- a/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go +++ b/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go @@ -24,6 +24,7 @@ import ( "net/url" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -710,7 +711,6 @@ func (d *ServiceLANVPNInterfaceEthernetProfileParcelDataSource) Configure(_ cont // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin read func (d *ServiceLANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { var config ServiceLANVPNInterfaceEthernet @@ -723,18 +723,20 @@ func (d *ServiceLANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + // Get Manager Version + d.client.Authenticate() + currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion)) + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) return } - config.fromBody(ctx, res) + config.fromBody(ctx, res, currentVersion) tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) diags = resp.State.Set(ctx, &config) resp.Diagnostics.Append(diags...) } - -// End of section. //template:end read diff --git a/internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go b/internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go index cd9b8d67e..2600489f8 100644 --- a/internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go +++ b/internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go @@ -24,6 +24,7 @@ import ( "net/url" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -1007,7 +1008,6 @@ func (d *TransportWANVPNInterfaceEthernetProfileParcelDataSource) Configure(_ co // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin read func (d *TransportWANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { var config TransportWANVPNInterfaceEthernet @@ -1020,18 +1020,20 @@ func (d *TransportWANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + // Get Manager Version + d.client.Authenticate() + currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion)) + res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) return } - config.fromBody(ctx, res) + config.fromBody(ctx, res, currentVersion) tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString())) diags = resp.State.Set(ctx, &config) resp.Diagnostics.Append(diags...) } - -// End of section. //template:end read diff --git a/internal/provider/model_sdwan_service_lan_vpn_feature.go b/internal/provider/model_sdwan_service_lan_vpn_feature.go index ffcaceb18..22d1c68a3 100644 --- a/internal/provider/model_sdwan_service_lan_vpn_feature.go +++ b/internal/provider/model_sdwan_service_lan_vpn_feature.go @@ -25,6 +25,7 @@ import ( "strconv" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/tidwall/gjson" "github.com/tidwall/sjson" @@ -32,6 +33,8 @@ import ( // End of section. //template:end imports +var MinServiceLANVPNUpdateVersion = version.Must(version.NewVersion("20.14.0")) + // Section below is generated&owned by "gen/generator.go". //template:begin types type ServiceLANVPN struct { Id types.String `tfsdk:"id"` @@ -328,8 +331,7 @@ func (data ServiceLANVPN) getPath() string { // End of section. //template:end getPath -// Section below is generated&owned by "gen/generator.go". //template:begin toBody -func (data ServiceLANVPN) toBody(ctx context.Context) string { +func (data ServiceLANVPN) toBody(ctx context.Context, currentVersion *version.Version) string { body := "" body, _ = sjson.Set(body, "name", data.Name.ValueString()) body, _ = sjson.Set(body, "description", data.Description.ValueString()) @@ -1203,15 +1205,19 @@ func (data ServiceLANVPN) toBody(ctx context.Context) string { } } + translatedSourceIpRef := "TranslatedSourceIp" + if !currentVersion.LessThan(MinServiceLANVPNUpdateVersion) { + translatedSourceIpRef = "translatedSourceIp" + } if !item.TranslatedSourceIpVariable.IsNull() { if true { - itemBody, _ = sjson.Set(itemBody, "TranslatedSourceIp.optionType", "variable") - itemBody, _ = sjson.Set(itemBody, "TranslatedSourceIp.value", item.TranslatedSourceIpVariable.ValueString()) + itemBody, _ = sjson.Set(itemBody, translatedSourceIpRef+".optionType", "variable") + itemBody, _ = sjson.Set(itemBody, translatedSourceIpRef+".value", item.TranslatedSourceIpVariable.ValueString()) } } else if !item.TranslatedSourceIp.IsNull() { if true { - itemBody, _ = sjson.Set(itemBody, "TranslatedSourceIp.optionType", "global") - itemBody, _ = sjson.Set(itemBody, "TranslatedSourceIp.value", item.TranslatedSourceIp.ValueString()) + itemBody, _ = sjson.Set(itemBody, translatedSourceIpRef+".optionType", "global") + itemBody, _ = sjson.Set(itemBody, translatedSourceIpRef+".value", item.TranslatedSourceIp.ValueString()) } } @@ -1263,15 +1269,19 @@ func (data ServiceLANVPN) toBody(ctx context.Context) string { } } + translatedSourceIpSubnetRef := "TranslatedSourceIp" + if !currentVersion.LessThan(MinServiceLANVPNUpdateVersion) { + translatedSourceIpSubnetRef = "translatedSourceIp" + } if !item.TranslatedSourceIpVariable.IsNull() { if true { - itemBody, _ = sjson.Set(itemBody, "TranslatedSourceIp.optionType", "variable") - itemBody, _ = sjson.Set(itemBody, "TranslatedSourceIp.value", item.TranslatedSourceIpVariable.ValueString()) + itemBody, _ = sjson.Set(itemBody, translatedSourceIpSubnetRef+".optionType", "variable") + itemBody, _ = sjson.Set(itemBody, translatedSourceIpSubnetRef+".value", item.TranslatedSourceIpVariable.ValueString()) } } else if !item.TranslatedSourceIp.IsNull() { if true { - itemBody, _ = sjson.Set(itemBody, "TranslatedSourceIp.optionType", "global") - itemBody, _ = sjson.Set(itemBody, "TranslatedSourceIp.value", item.TranslatedSourceIp.ValueString()) + itemBody, _ = sjson.Set(itemBody, translatedSourceIpSubnetRef+".optionType", "global") + itemBody, _ = sjson.Set(itemBody, translatedSourceIpSubnetRef+".value", item.TranslatedSourceIp.ValueString()) } } @@ -1596,10 +1606,7 @@ func (data ServiceLANVPN) toBody(ctx context.Context) string { return body } -// End of section. //template:end toBody - -// Section below is generated&owned by "gen/generator.go". //template:begin fromBody -func (data *ServiceLANVPN) fromBody(ctx context.Context, res gjson.Result) { +func (data *ServiceLANVPN) fromBody(ctx context.Context, res gjson.Result, currentVersion *version.Version) { data.Name = types.StringValue(res.Get("payload.name").String()) if value := res.Get("payload.description"); value.Exists() && value.String() != "" { data.Description = types.StringValue(value.String()) @@ -2327,8 +2334,12 @@ func (data *ServiceLANVPN) fromBody(ctx context.Context, res gjson.Result) { } item.TranslatedSourceIp = types.StringNull() item.TranslatedSourceIpVariable = types.StringNull() - if t := v.Get("TranslatedSourceIp.optionType"); t.Exists() { - va := v.Get("TranslatedSourceIp.value") + translatedSourceIpRef := "TranslatedSourceIp" + if !currentVersion.LessThan(MinServiceLANVPNUpdateVersion) { + translatedSourceIpRef = "translatedSourceIp" + } + if t := v.Get(translatedSourceIpRef + ".optionType"); t.Exists() { + va := v.Get(translatedSourceIpRef + ".value") if t.String() == "variable" { item.TranslatedSourceIpVariable = types.StringValue(va.String()) } else if t.String() == "global" { @@ -2375,8 +2386,12 @@ func (data *ServiceLANVPN) fromBody(ctx context.Context, res gjson.Result) { } item.TranslatedSourceIp = types.StringNull() item.TranslatedSourceIpVariable = types.StringNull() - if t := v.Get("TranslatedSourceIp.optionType"); t.Exists() { - va := v.Get("TranslatedSourceIp.value") + translatedSourceIpRef := "TranslatedSourceIp" + if !currentVersion.LessThan(MinServiceLANVPNUpdateVersion) { + translatedSourceIpRef = "translatedSourceIp" + } + if t := v.Get(translatedSourceIpRef + ".optionType"); t.Exists() { + va := v.Get(translatedSourceIpRef + ".value") if t.String() == "variable" { item.TranslatedSourceIpVariable = types.StringValue(va.String()) } else if t.String() == "global" { @@ -2693,10 +2708,7 @@ func (data *ServiceLANVPN) fromBody(ctx context.Context, res gjson.Result) { } } -// End of section. //template:end fromBody - -// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody -func (data *ServiceLANVPN) updateFromBody(ctx context.Context, res gjson.Result) { +func (data *ServiceLANVPN) updateFromBody(ctx context.Context, res gjson.Result, currentVersion *version.Version) { data.Name = types.StringValue(res.Get("payload.name").String()) if value := res.Get("payload.description"); value.Exists() && value.String() != "" { data.Description = types.StringValue(value.String()) @@ -3811,8 +3823,12 @@ func (data *ServiceLANVPN) updateFromBody(ctx context.Context, res gjson.Result) } data.NatPortForwards[i].TranslatedSourceIp = types.StringNull() data.NatPortForwards[i].TranslatedSourceIpVariable = types.StringNull() - if t := r.Get("TranslatedSourceIp.optionType"); t.Exists() { - va := r.Get("TranslatedSourceIp.value") + translatedSourceIpRef := "TranslatedSourceIp" + if !currentVersion.LessThan(MinServiceLANVPNUpdateVersion) { + translatedSourceIpRef = "translatedSourceIp" + } + if t := r.Get(translatedSourceIpRef + ".optionType"); t.Exists() { + va := r.Get(translatedSourceIpRef + ".value") if t.String() == "variable" { data.NatPortForwards[i].TranslatedSourceIpVariable = types.StringValue(va.String()) } else if t.String() == "global" { @@ -3883,8 +3899,12 @@ func (data *ServiceLANVPN) updateFromBody(ctx context.Context, res gjson.Result) } data.StaticNats[i].TranslatedSourceIp = types.StringNull() data.StaticNats[i].TranslatedSourceIpVariable = types.StringNull() - if t := r.Get("TranslatedSourceIp.optionType"); t.Exists() { - va := r.Get("TranslatedSourceIp.value") + translatedSourceIpRef := "TranslatedSourceIp" + if !currentVersion.LessThan(MinServiceLANVPNUpdateVersion) { + translatedSourceIpRef = "translatedSourceIp" + } + if t := r.Get(translatedSourceIpRef + ".optionType"); t.Exists() { + va := r.Get(translatedSourceIpRef + ".value") if t.String() == "variable" { data.StaticNats[i].TranslatedSourceIpVariable = types.StringValue(va.String()) } else if t.String() == "global" { @@ -4461,5 +4481,3 @@ func (data *ServiceLANVPN) updateFromBody(ctx context.Context, res gjson.Result) } } } - -// End of section. //template:end updateFromBody diff --git a/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go b/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go index 2c065af65..465797d72 100644 --- a/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go +++ b/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go @@ -25,6 +25,7 @@ import ( "strconv" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/tidwall/gjson" "github.com/tidwall/sjson" @@ -32,6 +33,8 @@ import ( // End of section. //template:end imports +var MinServiceLANVPNInterfaceEthernetUpdateVersion = version.Must(version.NewVersion("20.14.0")) + // Section below is generated&owned by "gen/generator.go". //template:begin types type ServiceLANVPNInterfaceEthernet struct { Id types.String `tfsdk:"id"` @@ -232,8 +235,7 @@ func (data ServiceLANVPNInterfaceEthernet) getPath() string { // End of section. //template:end getPath -// Section below is generated&owned by "gen/generator.go". //template:begin toBody -func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context) string { +func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context, currentVersion *version.Version) string { body := "" body, _ = sjson.Set(body, "name", data.Name.ValueString()) body, _ = sjson.Set(body, "description", data.Description.ValueString()) @@ -549,10 +551,14 @@ func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context) string { } } + natLookBackRef := "natLookback" + if !currentVersion.LessThan(MinServiceLANVPNInterfaceEthernetUpdateVersion) { + natLookBackRef = "natLoopback" + } if !data.Ipv4NatLoopbackVariable.IsNull() { if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.optionType", "variable") - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.value", data.Ipv4NatLoopbackVariable.ValueString()) + body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".optionType", "variable") + body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".value", data.Ipv4NatLoopbackVariable.ValueString()) } } else if data.Ipv4NatLoopback.IsNull() { if true { @@ -1326,10 +1332,7 @@ func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context) string { return body } -// End of section. //template:end toBody - -// Section below is generated&owned by "gen/generator.go". //template:begin fromBody -func (data *ServiceLANVPNInterfaceEthernet) fromBody(ctx context.Context, res gjson.Result) { +func (data *ServiceLANVPNInterfaceEthernet) fromBody(ctx context.Context, res gjson.Result, currentVersion *version.Version) { data.Name = types.StringValue(res.Get("payload.name").String()) if value := res.Get("payload.description"); value.Exists() && value.String() != "" { data.Description = types.StringValue(value.String()) @@ -1577,8 +1580,12 @@ func (data *ServiceLANVPNInterfaceEthernet) fromBody(ctx context.Context, res gj } data.Ipv4NatLoopback = types.StringNull() data.Ipv4NatLoopbackVariable = types.StringNull() - if t := res.Get(path + "natAttributesIpv4.natLookback.optionType"); t.Exists() { - va := res.Get(path + "natAttributesIpv4.natLookback.value") + natLookBackRef := "natLookback" + if !currentVersion.LessThan(MinServiceLANVPNInterfaceEthernetUpdateVersion) { + natLookBackRef = "natLoopback" + } + if t := res.Get(path + "natAttributesIpv4." + natLookBackRef + ".optionType"); t.Exists() { + va := res.Get(path + "natAttributesIpv4." + natLookBackRef + ".value") if t.String() == "variable" { data.Ipv4NatLoopbackVariable = types.StringValue(va.String()) } else if t.String() == "global" { @@ -2133,10 +2140,7 @@ func (data *ServiceLANVPNInterfaceEthernet) fromBody(ctx context.Context, res gj } } -// End of section. //template:end fromBody - -// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody -func (data *ServiceLANVPNInterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Result) { +func (data *ServiceLANVPNInterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Result, currentVersion *version.Version) { data.Name = types.StringValue(res.Get("payload.name").String()) if value := res.Get("payload.description"); value.Exists() && value.String() != "" { data.Description = types.StringValue(value.String()) @@ -2480,8 +2484,12 @@ func (data *ServiceLANVPNInterfaceEthernet) updateFromBody(ctx context.Context, } data.Ipv4NatLoopback = types.StringNull() data.Ipv4NatLoopbackVariable = types.StringNull() - if t := res.Get(path + "natAttributesIpv4.natLookback.optionType"); t.Exists() { - va := res.Get(path + "natAttributesIpv4.natLookback.value") + natLookBackRef := "natLookback" + if !currentVersion.LessThan(MinServiceLANVPNInterfaceEthernetUpdateVersion) { + natLookBackRef = "natLoopback" + } + if t := res.Get(path + "natAttributesIpv4." + natLookBackRef + ".optionType"); t.Exists() { + va := res.Get(path + "natAttributesIpv4." + natLookBackRef + ".value") if t.String() == "variable" { data.Ipv4NatLoopbackVariable = types.StringValue(va.String()) } else if t.String() == "global" { diff --git a/internal/provider/model_sdwan_transport_wan_vpn_interface_ethernet_feature.go b/internal/provider/model_sdwan_transport_wan_vpn_interface_ethernet_feature.go index 820bde268..cb5ca9dd0 100644 --- a/internal/provider/model_sdwan_transport_wan_vpn_interface_ethernet_feature.go +++ b/internal/provider/model_sdwan_transport_wan_vpn_interface_ethernet_feature.go @@ -24,6 +24,7 @@ import ( "net/url" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/tidwall/gjson" "github.com/tidwall/sjson" @@ -31,6 +32,8 @@ import ( // End of section. //template:end imports +var MinTransportWANVPNInterfaceEthernetUpdateVersion = version.Must(version.NewVersion("20.14.0")) + // Section below is generated&owned by "gen/generator.go". //template:begin types type TransportWANVPNInterfaceEthernet struct { Id types.String `tfsdk:"id"` @@ -298,8 +301,7 @@ func (data TransportWANVPNInterfaceEthernet) getPath() string { // End of section. //template:end getPath -// Section below is generated&owned by "gen/generator.go". //template:begin toBody -func (data TransportWANVPNInterfaceEthernet) toBody(ctx context.Context) string { +func (data TransportWANVPNInterfaceEthernet) toBody(ctx context.Context, currentVersion *version.Version) string { body := "" body, _ = sjson.Set(body, "name", data.Name.ValueString()) body, _ = sjson.Set(body, "description", data.Description.ValueString()) @@ -1356,15 +1358,19 @@ func (data TransportWANVPNInterfaceEthernet) toBody(ctx context.Context) string } } + natLookBackRef := "natLookback" + if !currentVersion.LessThan(MinTransportWANVPNInterfaceEthernetUpdateVersion) { + natLookBackRef = "natLoopback" + } if !data.NatLoopbackVariable.IsNull() { if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.optionType", "variable") - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.value", data.NatLoopbackVariable.ValueString()) + body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".optionType", "variable") + body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".value", data.NatLoopbackVariable.ValueString()) } } else if !data.NatLoopback.IsNull() { if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.optionType", "global") - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.value", data.NatLoopback.ValueString()) + body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".optionType", "global") + body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".value", data.NatLoopback.ValueString()) } } @@ -1991,10 +1997,7 @@ func (data TransportWANVPNInterfaceEthernet) toBody(ctx context.Context) string return body } -// End of section. //template:end toBody - -// Section below is generated&owned by "gen/generator.go". //template:begin fromBody -func (data *TransportWANVPNInterfaceEthernet) fromBody(ctx context.Context, res gjson.Result) { +func (data *TransportWANVPNInterfaceEthernet) fromBody(ctx context.Context, res gjson.Result, currentVersion *version.Version) { data.Name = types.StringValue(res.Get("payload.name").String()) if value := res.Get("payload.description"); value.Exists() && value.String() != "" { data.Description = types.StringValue(value.String()) @@ -2690,8 +2693,12 @@ func (data *TransportWANVPNInterfaceEthernet) fromBody(ctx context.Context, res } data.NatLoopback = types.StringNull() data.NatLoopbackVariable = types.StringNull() - if t := res.Get(path + "natAttributesIpv4.natLookback.optionType"); t.Exists() { - va := res.Get(path + "natAttributesIpv4.natLookback.value") + natLookBackRef := "natLookback" + if !currentVersion.LessThan(MinTransportWANVPNInterfaceEthernetUpdateVersion) { + natLookBackRef = "natLoopback" + } + if t := res.Get(path + "natAttributesIpv4." + natLookBackRef + ".optionType"); t.Exists() { + va := res.Get(path + "natAttributesIpv4." + natLookBackRef + ".value") if t.String() == "variable" { data.NatLoopbackVariable = types.StringValue(va.String()) } else if t.String() == "global" { @@ -3154,10 +3161,7 @@ func (data *TransportWANVPNInterfaceEthernet) fromBody(ctx context.Context, res } } -// End of section. //template:end fromBody - -// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody -func (data *TransportWANVPNInterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Result) { +func (data *TransportWANVPNInterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Result, currentVersion *version.Version) { data.Name = types.StringValue(res.Get("payload.name").String()) if value := res.Get("payload.description"); value.Exists() && value.String() != "" { data.Description = types.StringValue(value.String()) @@ -3949,8 +3953,12 @@ func (data *TransportWANVPNInterfaceEthernet) updateFromBody(ctx context.Context } data.NatLoopback = types.StringNull() data.NatLoopbackVariable = types.StringNull() - if t := res.Get(path + "natAttributesIpv4.natLookback.optionType"); t.Exists() { - va := res.Get(path + "natAttributesIpv4.natLookback.value") + natLookBackRef := "natLookback" + if !currentVersion.LessThan(MinTransportWANVPNInterfaceEthernetUpdateVersion) { + natLookBackRef = "natLoopback" + } + if t := res.Get(path + "natAttributesIpv4." + natLookBackRef + ".optionType"); t.Exists() { + va := res.Get(path + "natAttributesIpv4." + natLookBackRef + ".value") if t.String() == "variable" { data.NatLoopbackVariable = types.StringValue(va.String()) } else if t.String() == "global" { @@ -4484,5 +4492,3 @@ func (data *TransportWANVPNInterfaceEthernet) updateFromBody(ctx context.Context } } } - -// End of section. //template:end updateFromBody diff --git a/internal/provider/resource_sdwan_service_lan_vpn_feature.go b/internal/provider/resource_sdwan_service_lan_vpn_feature.go index 8fb6886ab..e87c1f382 100644 --- a/internal/provider/resource_sdwan_service_lan_vpn_feature.go +++ b/internal/provider/resource_sdwan_service_lan_vpn_feature.go @@ -27,6 +27,7 @@ import ( "sync" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" @@ -1129,7 +1130,6 @@ func (r *ServiceLANVPNProfileParcelResource) Configure(_ context.Context, req re // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ServiceLANVPNProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan ServiceLANVPN @@ -1142,8 +1142,12 @@ func (r *ServiceLANVPNProfileParcelResource) Create(ctx context.Context, req res tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + // Create object - body := plan.toBody(ctx) + body := plan.toBody(ctx, currentVersion) res, err := r.client.Post(plan.getPath(), body) if err != nil { @@ -1162,9 +1166,6 @@ func (r *ServiceLANVPNProfileParcelResource) Create(ctx context.Context, req res helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end create - -// Section below is generated&owned by "gen/generator.go". //template:begin read func (r *ServiceLANVPNProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state ServiceLANVPN @@ -1177,6 +1178,10 @@ func (r *ServiceLANVPNProfileParcelResource) Read(ctx context.Context, req resou tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) if res.Get("error.message").String() == "Invalid feature Id" { resp.State.RemoveResource(ctx) @@ -1193,9 +1198,9 @@ func (r *ServiceLANVPNProfileParcelResource) Read(ctx context.Context, req resou } if imp { - state.fromBody(ctx, res) + state.fromBody(ctx, res, currentVersion) } else { - state.updateFromBody(ctx, res) + state.updateFromBody(ctx, res, currentVersion) } if state.Version.IsNull() { state.Version = types.Int64Value(0) @@ -1209,9 +1214,6 @@ func (r *ServiceLANVPNProfileParcelResource) Read(ctx context.Context, req resou helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end read - -// Section below is generated&owned by "gen/generator.go". //template:begin update func (r *ServiceLANVPNProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var plan, state ServiceLANVPN @@ -1230,7 +1232,11 @@ func (r *ServiceLANVPNProfileParcelResource) Update(ctx context.Context, req res tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) - body := plan.toBody(ctx) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + + body := plan.toBody(ctx, currentVersion) res, err := r.client.Put(plan.getPath()+"/"+url.QueryEscape(plan.Id.ValueString()), body) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) @@ -1245,8 +1251,6 @@ func (r *ServiceLANVPNProfileParcelResource) Update(ctx context.Context, req res resp.Diagnostics.Append(diags...) } -// End of section. //template:end update - // Section below is generated&owned by "gen/generator.go". //template:begin delete func (r *ServiceLANVPNProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state ServiceLANVPN diff --git a/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature.go b/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature.go index 7c954847e..0f847fe3a 100644 --- a/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature.go +++ b/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature.go @@ -27,6 +27,7 @@ import ( "sync" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" @@ -849,7 +850,6 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Configure(_ contex // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan ServiceLANVPNInterfaceEthernet @@ -862,8 +862,12 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Create(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + // Create object - body := plan.toBody(ctx) + body := plan.toBody(ctx, currentVersion) res, err := r.client.Post(plan.getPath(), body) if err != nil { @@ -882,9 +886,6 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Create(ctx context helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end create - -// Section below is generated&owned by "gen/generator.go". //template:begin read func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state ServiceLANVPNInterfaceEthernet @@ -897,6 +898,10 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Read(ctx context.C tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) if res.Get("error.message").String() == "Invalid feature Id" { resp.State.RemoveResource(ctx) @@ -913,9 +918,9 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Read(ctx context.C } if imp { - state.fromBody(ctx, res) + state.fromBody(ctx, res, currentVersion) } else { - state.updateFromBody(ctx, res) + state.updateFromBody(ctx, res, currentVersion) } if state.Version.IsNull() { state.Version = types.Int64Value(0) @@ -929,9 +934,6 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Read(ctx context.C helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end read - -// Section below is generated&owned by "gen/generator.go". //template:begin update func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var plan, state ServiceLANVPNInterfaceEthernet @@ -950,7 +952,11 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Update(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) - body := plan.toBody(ctx) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + + body := plan.toBody(ctx, currentVersion) res, err := r.client.Put(plan.getPath()+"/"+url.QueryEscape(plan.Id.ValueString()), body) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) @@ -965,8 +971,6 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Update(ctx context resp.Diagnostics.Append(diags...) } -// End of section. //template:end update - // Section below is generated&owned by "gen/generator.go". //template:begin delete func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state ServiceLANVPNInterfaceEthernet diff --git a/internal/provider/resource_sdwan_transport_wan_vpn_interface_ethernet_feature.go b/internal/provider/resource_sdwan_transport_wan_vpn_interface_ethernet_feature.go index 2ec226fc2..70d829406 100644 --- a/internal/provider/resource_sdwan_transport_wan_vpn_interface_ethernet_feature.go +++ b/internal/provider/resource_sdwan_transport_wan_vpn_interface_ethernet_feature.go @@ -27,6 +27,7 @@ import ( "sync" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" @@ -1182,7 +1183,6 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Configure(_ cont // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan TransportWANVPNInterfaceEthernet @@ -1195,8 +1195,12 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Create(ctx conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + // Create object - body := plan.toBody(ctx) + body := plan.toBody(ctx, currentVersion) res, err := r.client.Post(plan.getPath(), body) if err != nil { @@ -1215,9 +1219,6 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Create(ctx conte helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end create - -// Section below is generated&owned by "gen/generator.go". //template:begin read func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state TransportWANVPNInterfaceEthernet @@ -1230,6 +1231,10 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Read(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) if res.Get("error.message").String() == "Invalid feature Id" { resp.State.RemoveResource(ctx) @@ -1246,9 +1251,9 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Read(ctx context } if imp { - state.fromBody(ctx, res) + state.fromBody(ctx, res, currentVersion) } else { - state.updateFromBody(ctx, res) + state.updateFromBody(ctx, res, currentVersion) } if state.Version.IsNull() { state.Version = types.Int64Value(0) @@ -1262,9 +1267,6 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Read(ctx context helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end read - -// Section below is generated&owned by "gen/generator.go". //template:begin update func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var plan, state TransportWANVPNInterfaceEthernet @@ -1283,7 +1285,11 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Update(ctx conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) - body := plan.toBody(ctx) + // Get Manager Version + r.client.Authenticate() + currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) + + body := plan.toBody(ctx, currentVersion) res, err := r.client.Put(plan.getPath()+"/"+url.QueryEscape(plan.Id.ValueString()), body) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) @@ -1298,8 +1304,6 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Update(ctx conte resp.Diagnostics.Append(diags...) } -// End of section. //template:end update - // Section below is generated&owned by "gen/generator.go". //template:begin delete func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state TransportWANVPNInterfaceEthernet From c23c61343cdc62a7b67d869d43fdeee52d25d1bf Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Wed, 9 Jul 2025 22:03:24 +0100 Subject: [PATCH 2/7] Remove nat type defaults to match transport wan vpn interface etherne --- ...vice_lan_vpn_interface_ethernet_feature.md | 17 ++------ .../resource.tf | 17 ++------ .../service_lan_vpn_interface_ethernet.yaml | 24 ++++++++++++ ...lan_vpn_interface_ethernet_feature_test.go | 16 -------- ...vice_lan_vpn_interface_ethernet_feature.go | 39 ++++--------------- ...lan_vpn_interface_ethernet_feature_test.go | 16 -------- 6 files changed, 37 insertions(+), 92 deletions(-) diff --git a/docs/resources/service_lan_vpn_interface_ethernet_feature.md b/docs/resources/service_lan_vpn_interface_ethernet_feature.md index 570f48079..700c09094 100644 --- a/docs/resources/service_lan_vpn_interface_ethernet_feature.md +++ b/docs/resources/service_lan_vpn_interface_ethernet_feature.md @@ -44,20 +44,9 @@ resource "sdwan_service_lan_vpn_interface_ethernet_feature" "example" { ipv4_nat_range_end = "4.5.6.7" ipv4_nat_prefix_length = 1 ipv4_nat_overload = true - ipv4_nat_loopback = "123" - ipv4_nat_udp_timeout = 123 - ipv4_nat_tcp_timeout = 123 - static_nats = [ - { - source_ip = "1.2.3.4" - translate_ip = "2.3.4.5" - direction = "inside" - source_vpn = 0 - } - ] - ipv6_nat = true - nat64 = false - acl_shaping_rate = 12 + ipv6_nat = true + nat64 = false + acl_shaping_rate = 12 ipv6_vrrps = [ { group_id = 1 diff --git a/examples/resources/sdwan_service_lan_vpn_interface_ethernet_feature/resource.tf b/examples/resources/sdwan_service_lan_vpn_interface_ethernet_feature/resource.tf index e4877fa1d..fec72ad4d 100644 --- a/examples/resources/sdwan_service_lan_vpn_interface_ethernet_feature/resource.tf +++ b/examples/resources/sdwan_service_lan_vpn_interface_ethernet_feature/resource.tf @@ -27,20 +27,9 @@ resource "sdwan_service_lan_vpn_interface_ethernet_feature" "example" { ipv4_nat_range_end = "4.5.6.7" ipv4_nat_prefix_length = 1 ipv4_nat_overload = true - ipv4_nat_loopback = "123" - ipv4_nat_udp_timeout = 123 - ipv4_nat_tcp_timeout = 123 - static_nats = [ - { - source_ip = "1.2.3.4" - translate_ip = "2.3.4.5" - direction = "inside" - source_vpn = 0 - } - ] - ipv6_nat = true - nat64 = false - acl_shaping_rate = 12 + ipv6_nat = true + nat64 = false + acl_shaping_rate = 12 ipv6_vrrps = [ { group_id = 1 diff --git a/gen/definitions/profile_parcels/service_lan_vpn_interface_ethernet.yaml b/gen/definitions/profile_parcels/service_lan_vpn_interface_ethernet.yaml index 9aa4b1b40..99de93274 100644 --- a/gen/definitions/profile_parcels/service_lan_vpn_interface_ethernet.yaml +++ b/gen/definitions/profile_parcels/service_lan_vpn_interface_ethernet.yaml @@ -108,34 +108,58 @@ attributes: - model_name: rangeStart tf_name: ipv4_nat_range_start data_path: [natAttributesIpv4, natPool] + exclude_null: true + # conditional_attribute: + # name: Ipv4NatType + # value: pool example: 1.2.3.4 - model_name: rangeEnd tf_name: ipv4_nat_range_end data_path: [natAttributesIpv4, natPool] + exclude_null: true + # conditional_attribute: + # name: Ipv4NatType + # value: pool example: 4.5.6.7 - model_name: prefixLength tf_name: ipv4_nat_prefix_length data_path: [natAttributesIpv4, natPool] + exclude_null: true + # conditional_attribute: + # name: Ipv4NatType + # value: pool example: 1 - model_name: overload tf_name: ipv4_nat_overload data_path: [natAttributesIpv4, natPool] + exclude_null: true + # conditional_attribute: + # name: Ipv4NatType + # value: pool example: true - model_name: natLookback tf_name: ipv4_nat_loopback data_path: [natAttributesIpv4] + exclude_test: true + exclude_null: true + # conditional_attribute: + # name: Ipv4NatType + # value: loopback example: 123 - model_name: udpTimeout tf_name: ipv4_nat_udp_timeout data_path: [natAttributesIpv4] + exclude_test: true example: 123 - model_name: tcpTimeout tf_name: ipv4_nat_tcp_timeout data_path: [natAttributesIpv4] + exclude_test: true example: 123 - model_name: newStaticNat tf_name: static_nats data_path: [natAttributesIpv4] + exclude_test: true attributes: - model_name: sourceIp id: true diff --git a/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature_test.go b/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature_test.go index a36f8beb8..1c3408e03 100644 --- a/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature_test.go +++ b/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature_test.go @@ -48,13 +48,6 @@ func TestAccDataSourceSdwanServiceLANVPNInterfaceEthernetProfileParcel(t *testin checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_range_end", "4.5.6.7")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_prefix_length", "1")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_overload", "true")) - checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_loopback", "123")) - checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_udp_timeout", "123")) - checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_tcp_timeout", "123")) - checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.source_ip", "1.2.3.4")) - checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.translate_ip", "2.3.4.5")) - checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.direction", "inside")) - checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.source_vpn", "0")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv6_nat", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "nat64", "false")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "acl_shaping_rate", "12")) @@ -167,15 +160,6 @@ func testAccDataSourceSdwanServiceLANVPNInterfaceEthernetProfileParcelConfig() s config += ` ipv4_nat_range_end = "4.5.6.7"` + "\n" config += ` ipv4_nat_prefix_length = 1` + "\n" config += ` ipv4_nat_overload = true` + "\n" - config += ` ipv4_nat_loopback = "123"` + "\n" - config += ` ipv4_nat_udp_timeout = 123` + "\n" - config += ` ipv4_nat_tcp_timeout = 123` + "\n" - config += ` static_nats = [{` + "\n" - config += ` source_ip = "1.2.3.4"` + "\n" - config += ` translate_ip = "2.3.4.5"` + "\n" - config += ` direction = "inside"` + "\n" - config += ` source_vpn = 0` + "\n" - config += ` }]` + "\n" config += ` ipv6_nat = true` + "\n" config += ` nat64 = false` + "\n" config += ` acl_shaping_rate = 12` + "\n" diff --git a/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go b/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go index 465797d72..ef7247201 100644 --- a/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go +++ b/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go @@ -488,12 +488,7 @@ func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context, currentVe body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeStart.optionType", "variable") body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeStart.value", data.Ipv4NatRangeStartVariable.ValueString()) } - } else if data.Ipv4NatRangeStart.IsNull() { - if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeStart.optionType", "default") - - } - } else { + } else if !data.Ipv4NatRangeStart.IsNull() { if true { body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeStart.optionType", "global") body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeStart.value", data.Ipv4NatRangeStart.ValueString()) @@ -505,12 +500,7 @@ func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context, currentVe body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeEnd.optionType", "variable") body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeEnd.value", data.Ipv4NatRangeEndVariable.ValueString()) } - } else if data.Ipv4NatRangeEnd.IsNull() { - if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeEnd.optionType", "default") - - } - } else { + } else if !data.Ipv4NatRangeEnd.IsNull() { if true { body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeEnd.optionType", "global") body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.rangeEnd.value", data.Ipv4NatRangeEnd.ValueString()) @@ -522,12 +512,7 @@ func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context, currentVe body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.prefixLength.optionType", "variable") body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.prefixLength.value", data.Ipv4NatPrefixLengthVariable.ValueString()) } - } else if data.Ipv4NatPrefixLength.IsNull() { - if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.prefixLength.optionType", "default") - - } - } else { + } else if !data.Ipv4NatPrefixLength.IsNull() { if true { body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.prefixLength.optionType", "global") body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.prefixLength.value", data.Ipv4NatPrefixLength.ValueInt64()) @@ -539,12 +524,7 @@ func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context, currentVe body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.overload.optionType", "variable") body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.overload.value", data.Ipv4NatOverloadVariable.ValueString()) } - } else if data.Ipv4NatOverload.IsNull() { - if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.overload.optionType", "default") - body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.overload.value", true) - } - } else { + } else if !data.Ipv4NatOverload.IsNull() { if true { body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.overload.optionType", "global") body, _ = sjson.Set(body, path+"natAttributesIpv4.natPool.overload.value", data.Ipv4NatOverload.ValueBool()) @@ -560,15 +540,10 @@ func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context, currentVe body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".optionType", "variable") body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".value", data.Ipv4NatLoopbackVariable.ValueString()) } - } else if data.Ipv4NatLoopback.IsNull() { - if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.optionType", "default") - - } - } else { + } else if !data.Ipv4NatLoopback.IsNull() { if true { - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.optionType", "global") - body, _ = sjson.Set(body, path+"natAttributesIpv4.natLookback.value", data.Ipv4NatLoopback.ValueString()) + body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".optionType", "global") + body, _ = sjson.Set(body, path+"natAttributesIpv4."+natLookBackRef+".value", data.Ipv4NatLoopback.ValueString()) } } diff --git a/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature_test.go b/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature_test.go index f0d454892..6e73266c9 100644 --- a/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature_test.go +++ b/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature_test.go @@ -48,13 +48,6 @@ func TestAccSdwanServiceLANVPNInterfaceEthernetProfileParcel(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_range_end", "4.5.6.7")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_prefix_length", "1")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_overload", "true")) - checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_loopback", "123")) - checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_udp_timeout", "123")) - checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_tcp_timeout", "123")) - checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.source_ip", "1.2.3.4")) - checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.translate_ip", "2.3.4.5")) - checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.direction", "inside")) - checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.source_vpn", "0")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv6_nat", "true")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "nat64", "false")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_service_lan_vpn_interface_ethernet_feature.test", "acl_shaping_rate", "12")) @@ -187,15 +180,6 @@ func testAccSdwanServiceLANVPNInterfaceEthernetProfileParcelConfig_all() string config += ` ipv4_nat_range_end = "4.5.6.7"` + "\n" config += ` ipv4_nat_prefix_length = 1` + "\n" config += ` ipv4_nat_overload = true` + "\n" - config += ` ipv4_nat_loopback = "123"` + "\n" - config += ` ipv4_nat_udp_timeout = 123` + "\n" - config += ` ipv4_nat_tcp_timeout = 123` + "\n" - config += ` static_nats = [{` + "\n" - config += ` source_ip = "1.2.3.4"` + "\n" - config += ` translate_ip = "2.3.4.5"` + "\n" - config += ` direction = "inside"` + "\n" - config += ` source_vpn = 0` + "\n" - config += ` }]` + "\n" config += ` ipv6_nat = true` + "\n" config += ` nat64 = false` + "\n" config += ` acl_shaping_rate = 12` + "\n" From 5470674e88a69e06b58c104f133a9287cf6e5a31 Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Fri, 8 Aug 2025 12:47:12 +0100 Subject: [PATCH 3/7] Remove default tracker value from 20.14+ --- ...del_sdwan_service_lan_vpn_interface_ethernet_feature.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go b/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go index ef7247201..931d392da 100644 --- a/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go +++ b/internal/provider/model_sdwan_service_lan_vpn_interface_ethernet_feature.go @@ -1243,9 +1243,10 @@ func (data ServiceLANVPNInterfaceEthernet) toBody(ctx context.Context, currentVe body, _ = sjson.Set(body, path+"advanced.tracker.value", data.TrackerVariable.ValueString()) } } else if data.Tracker.IsNull() { - if true { - body, _ = sjson.Set(body, path+"advanced.tracker.optionType", "default") - + if currentVersion.LessThan(MinServiceLANVPNUpdateVersion) { + if true { + body, _ = sjson.Set(body, path+"advanced.tracker.optionType", "default") + } } } else { if true { From 029b9a66df6749f9fe7eeeb332fe0f84cea291dd Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Fri, 8 Aug 2025 16:35:10 +0100 Subject: [PATCH 4/7] Resolve comments --- internal/provider/resource_sdwan_service_lan_vpn_feature.go | 3 --- ...esource_sdwan_service_lan_vpn_interface_ethernet_feature.go | 3 --- ...ource_sdwan_transport_wan_vpn_interface_ethernet_feature.go | 3 --- 3 files changed, 9 deletions(-) diff --git a/internal/provider/resource_sdwan_service_lan_vpn_feature.go b/internal/provider/resource_sdwan_service_lan_vpn_feature.go index e87c1f382..d863353f4 100644 --- a/internal/provider/resource_sdwan_service_lan_vpn_feature.go +++ b/internal/provider/resource_sdwan_service_lan_vpn_feature.go @@ -1143,7 +1143,6 @@ func (r *ServiceLANVPNProfileParcelResource) Create(ctx context.Context, req res tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) // Create object @@ -1179,7 +1178,6 @@ func (r *ServiceLANVPNProfileParcelResource) Read(ctx context.Context, req resou tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) @@ -1233,7 +1231,6 @@ func (r *ServiceLANVPNProfileParcelResource) Update(ctx context.Context, req res tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) body := plan.toBody(ctx, currentVersion) diff --git a/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature.go b/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature.go index 0f847fe3a..dd03dc4e5 100644 --- a/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature.go +++ b/internal/provider/resource_sdwan_service_lan_vpn_interface_ethernet_feature.go @@ -863,7 +863,6 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Create(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) // Create object @@ -899,7 +898,6 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Read(ctx context.C tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) @@ -953,7 +951,6 @@ func (r *ServiceLANVPNInterfaceEthernetProfileParcelResource) Update(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) body := plan.toBody(ctx, currentVersion) diff --git a/internal/provider/resource_sdwan_transport_wan_vpn_interface_ethernet_feature.go b/internal/provider/resource_sdwan_transport_wan_vpn_interface_ethernet_feature.go index 479b4dad8..776f4dfda 100644 --- a/internal/provider/resource_sdwan_transport_wan_vpn_interface_ethernet_feature.go +++ b/internal/provider/resource_sdwan_transport_wan_vpn_interface_ethernet_feature.go @@ -1196,7 +1196,6 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Create(ctx conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) // Create object @@ -1232,7 +1231,6 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Read(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Name.String())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) res, err := r.client.Get(state.getPath() + "/" + url.QueryEscape(state.Id.ValueString())) @@ -1286,7 +1284,6 @@ func (r *TransportWANVPNInterfaceEthernetProfileParcelResource) Update(ctx conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) // Get Manager Version - r.client.Authenticate() currentVersion := version.Must(version.NewVersion(r.client.ManagerVersion)) body := plan.toBody(ctx, currentVersion) From 8b7c1991a2ad520e7f22eae13a8df6958e30f4c4 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt <79086712+danischm@users.noreply.github.com> Date: Fri, 8 Aug 2025 19:14:03 +0200 Subject: [PATCH 5/7] Update data_source_sdwan_service_lan_vpn_feature.go --- internal/provider/data_source_sdwan_service_lan_vpn_feature.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/provider/data_source_sdwan_service_lan_vpn_feature.go b/internal/provider/data_source_sdwan_service_lan_vpn_feature.go index 7fb62cdc0..05e49c955 100644 --- a/internal/provider/data_source_sdwan_service_lan_vpn_feature.go +++ b/internal/provider/data_source_sdwan_service_lan_vpn_feature.go @@ -975,7 +975,6 @@ func (d *ServiceLANVPNProfileParcelDataSource) Read(ctx context.Context, req dat tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) // Get Manager Version - d.client.Authenticate() currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion)) res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) From 632b9f28b542c217086cd11621de686bfb5b8aef Mon Sep 17 00:00:00 2001 From: Daniel Schmidt <79086712+danischm@users.noreply.github.com> Date: Fri, 8 Aug 2025 19:14:55 +0200 Subject: [PATCH 6/7] Update data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go --- ...ta_source_sdwan_service_lan_vpn_interface_ethernet_feature.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go b/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go index c0328a661..3d6f826b7 100644 --- a/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go +++ b/internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go @@ -724,7 +724,6 @@ func (d *ServiceLANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) // Get Manager Version - d.client.Authenticate() currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion)) res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString())) From e274a41bcbcd5a88091eea5e955cd6a897c4a64b Mon Sep 17 00:00:00 2001 From: Daniel Schmidt <79086712+danischm@users.noreply.github.com> Date: Fri, 8 Aug 2025 19:15:19 +0200 Subject: [PATCH 7/7] Update data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go --- ..._source_sdwan_transport_wan_vpn_interface_ethernet_feature.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go b/internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go index 2600489f8..e65c4a740 100644 --- a/internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go +++ b/internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go @@ -1021,7 +1021,6 @@ func (d *TransportWANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) // Get Manager Version - d.client.Authenticate() currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion)) res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString()))