diff --git a/internal/resource_org_wlan/sdk_to_terraform.go b/internal/resource_org_wlan/sdk_to_terraform.go index 127787d..7e97632 100644 --- a/internal/resource_org_wlan/sdk_to_terraform.go +++ b/internal/resource_org_wlan/sdk_to_terraform.go @@ -20,19 +20,19 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag. var acct_immediate_update types.Bool = types.BoolValue(false) var acct_interim_interval types.Int64 - var acct_servers types.List = types.ListNull(AcctServersValue{}.Type(ctx)) + var acct_servers types.List = types.ListValueMust(AcctServersValue{}.Type(ctx), []attr.Value{}) var airwatch AirwatchValue = NewAirwatchValueNull() var allow_ipv6_ndp types.Bool = types.BoolValue(true) var allow_mdns types.Bool = types.BoolValue(false) var allow_ssdp types.Bool = types.BoolValue(false) - var ap_ids types.List = mist_transform.ListOfUuidSdkToTerraformEmpty(ctx) + var ap_ids types.List = types.ListNull(types.StringType) var app_limit AppLimitValue = NewAppLimitValueNull() var app_qos AppQosValue = NewAppQosValueNull() var apply_to types.String var arp_filter types.Bool var auth AuthValue = NewAuthValueNull() var auth_server_selection types.String - var auth_servers types.List = types.ListNull(AuthServersValue{}.Type(ctx)) + var auth_servers types.List = types.ListValueMust(AuthServersValue{}.Type(ctx), []attr.Value{}) var auth_servers_nas_id types.String var auth_servers_nas_ip types.String var auth_servers_retries types.Int64 @@ -47,7 +47,7 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag. var client_limit_down_enabled types.Bool var client_limit_up types.Int64 var client_limit_up_enabled types.Bool - var coa_servers types.List = types.ListNull(CoaServersValue{}.Type(ctx)) + var coa_servers types.List = types.ListValueMust(CoaServersValue{}.Type(ctx), []attr.Value{}) var disable_11ax types.Bool var disable_ht_vht_rates types.Bool var disable_uapsd types.Bool @@ -80,18 +80,18 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag. var max_num_clients types.Int64 var mist_nac MistNacValue = NewMistNacValueNull() var msp_id types.String = types.StringValue("") - var mxtunnel_ids types.List = mist_transform.ListOfStringSdkToTerraformEmpty(ctx) - var mxtunnel_name types.List = mist_transform.ListOfStringSdkToTerraformEmpty(ctx) + var mxtunnel_ids types.List = types.ListNull(types.StringType) + var mxtunnel_name types.List = types.ListNull(types.StringType) var no_static_dns types.Bool var no_static_ip types.Bool var org_id types.String var portal PortalValue = NewPortalValueNull() var portal_allowed_hostnames types.List = mist_transform.ListOfStringSdkToTerraformEmpty(ctx) var portal_allowed_subnets types.List = mist_transform.ListOfStringSdkToTerraformEmpty(ctx) - var portal_api_secret types.String + var portal_api_secret types.String = types.StringValue("") var portal_denied_hostnames types.List = mist_transform.ListOfStringSdkToTerraformEmpty(ctx) var portal_image types.String = types.StringValue("not_present") - var portal_sso_url types.String + var portal_sso_url types.String = types.StringValue("") var qos QosValue var radsec RadsecValue = NewRadsecValueNull() var rateset types.Map = types.MapNull(RatesetValue{}.Type(ctx)) @@ -122,8 +122,10 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag. acct_interim_interval = types.Int64Value(int64(*data.AcctInterimInterval)) } - if data.AcctServers != nil { + if len(data.AcctServers) > 0 { acct_servers = radiusServersAcctSdkToTerraform(ctx, &diags, data.AcctServers) + } else { + types.ListValueMust(AcctServersValue{}.Type(ctx), make([]attr.Value, 0)) } if data.Airwatch != nil { @@ -142,7 +144,7 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag. allow_ssdp = types.BoolValue(*data.AllowSsdp) } - if data.ApIds.IsValueSet() && data.ApIds.Value() != nil { + if data.ApIds.IsValueSet() && len(*data.ApIds.Value()) > 0 { ap_ids = mist_transform.ListOfUuidSdkToTerraform(ctx, *data.ApIds.Value()) } @@ -170,8 +172,10 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag. auth_server_selection = types.StringValue(string(*data.AuthServerSelection)) } - if data.AuthServers != nil { + if len(data.AuthServers) > 0 { auth_servers = radiusServersAuthSdkToTerraform(ctx, &diags, data.AuthServers) + } else { + auth_servers = types.ListValueMust(AuthServersValue{}.Type(ctx), make([]attr.Value, 0)) } if data.AuthServersNasId.IsValueSet() && data.AuthServersNasId.Value() != nil { @@ -232,6 +236,8 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag. if len(data.CoaServers) > 0 { coa_servers = coaServersSdkToTerraform(ctx, &diags, data.CoaServers) + } else { + coa_servers = types.ListValueMust(CoaServersValue{}.Type(ctx), make([]attr.Value, 0)) } if data.Disable11ax != nil { @@ -362,11 +368,11 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag. msp_id = types.StringValue(data.MspId.String()) } - if data.MxtunnelIds != nil { + if len(data.MxtunnelIds) > 0 { mxtunnel_ids = mist_transform.ListOfStringSdkToTerraform(ctx, data.MxtunnelIds) } - if data.MxtunnelName != nil { + if len(data.MxtunnelName) > 0 { mxtunnel_name = mist_transform.ListOfStringSdkToTerraform(ctx, data.MxtunnelName) } diff --git a/internal/resource_org_wlan/sdk_to_terraform_airwatch.go b/internal/resource_org_wlan/sdk_to_terraform_airwatch.go index 7b9e44e..199af6f 100644 --- a/internal/resource_org_wlan/sdk_to_terraform_airwatch.go +++ b/internal/resource_org_wlan/sdk_to_terraform_airwatch.go @@ -14,7 +14,7 @@ import ( func airwatchSdkToTerraform(ctx context.Context, diags *diag.Diagnostics, d *models.WlanAirwatch) AirwatchValue { var api_key basetypes.StringValue var console_url basetypes.StringValue - var enabled basetypes.BoolValue = types.BoolValue(false) + var enabled basetypes.BoolValue var password basetypes.StringValue var username basetypes.StringValue diff --git a/internal/resource_org_wlan/sdk_to_terraform_app_limit.go b/internal/resource_org_wlan/sdk_to_terraform_app_limit.go index df29c10..455a450 100644 --- a/internal/resource_org_wlan/sdk_to_terraform_app_limit.go +++ b/internal/resource_org_wlan/sdk_to_terraform_app_limit.go @@ -16,23 +16,23 @@ func appLimitSdkToTerraform(ctx context.Context, diags *diag.Diagnostics, d *mod var enabled basetypes.BoolValue var wxtag_ids basetypes.MapValue = types.MapNull(types.Int64Type) - if d != nil && d.Apps != nil && len(d.Apps) > 0 { - app_limit_attr := make(map[string]attr.Value) - for k, v := range d.Apps { - app_limit_attr[k] = types.Int64Value(int64(v)) - } - apps = types.MapValueMust(types.Int64Type, app_limit_attr) + //if d != nil && d.Apps != nil && len(d.Apps) > 0 { + app_limit_attr := make(map[string]attr.Value) + for k, v := range d.Apps { + app_limit_attr[k] = types.Int64Value(int64(v)) } + apps = types.MapValueMust(types.Int64Type, app_limit_attr) + //} if d != nil && d.Enabled != nil { enabled = types.BoolValue(*d.Enabled) } - if d != nil && d.WxtagIds != nil && len(d.WxtagIds) > 0 { - wxtag_limit_attr := make(map[string]attr.Value) - for k, v := range d.WxtagIds { - wxtag_limit_attr[k] = types.Int64Value(int64(v)) - } - wxtag_ids = types.MapValueMust(types.Int64Type, wxtag_limit_attr) + //if d != nil && d.WxtagIds != nil && len(d.WxtagIds) > 0 { + wxtag_limit_attr := make(map[string]attr.Value) + for k, v := range d.WxtagIds { + wxtag_limit_attr[k] = types.Int64Value(int64(v)) } + wxtag_ids = types.MapValueMust(types.Int64Type, wxtag_limit_attr) + //} data_map_attr_type := AppLimitValue{}.AttributeTypes(ctx) data_map_value := map[string]attr.Value{ diff --git a/internal/resource_org_wlan/sdk_to_terraform_dns_server_rewrite.go b/internal/resource_org_wlan/sdk_to_terraform_dns_server_rewrite.go index 03cf736..88d38f0 100644 --- a/internal/resource_org_wlan/sdk_to_terraform_dns_server_rewrite.go +++ b/internal/resource_org_wlan/sdk_to_terraform_dns_server_rewrite.go @@ -19,14 +19,13 @@ func dnsServerRewriteSdkToTerraform(ctx context.Context, diags *diag.Diagnostics if d != nil && d.Enabled != nil { enabled = types.BoolValue(*d.Enabled) } + radius_groups_values := make(map[string]attr.Value) if d != nil && d.RadiusGroups != nil && len(d.RadiusGroups) > 0 { - radius_groups_values := make(map[string]attr.Value) for k, v := range d.RadiusGroups { radius_groups_values[k] = types.StringValue(v) } - radius_groups = types.MapValueMust(types.StringType, radius_groups_values) - } + radius_groups = types.MapValueMust(types.StringType, radius_groups_values) data_map_attr_type := DnsServerRewriteValue{}.AttributeTypes(ctx) data_map_value := map[string]attr.Value{ diff --git a/internal/resource_org_wlan/sdk_to_terraform_dynamic_vlan.go b/internal/resource_org_wlan/sdk_to_terraform_dynamic_vlan.go index c8ed24a..0a43b1f 100644 --- a/internal/resource_org_wlan/sdk_to_terraform_dynamic_vlan.go +++ b/internal/resource_org_wlan/sdk_to_terraform_dynamic_vlan.go @@ -43,7 +43,6 @@ func dynamicVlanSdkToTerraform(ctx context.Context, diags *diag.Diagnostics, d * if d != nil && d.Enabled != nil { enabled = types.BoolValue(*d.Enabled) } - if d != nil && d.LocalVlanIds != nil { var list []attr.Value for _, v := range d.LocalVlanIds { @@ -53,11 +52,9 @@ func dynamicVlanSdkToTerraform(ctx context.Context, diags *diag.Diagnostics, d * diags.Append(e...) local_vlan_ids = r } - if d != nil && d.Type != nil { type_dynamic_vlan = types.StringValue(string(*d.Type)) } - if d != nil && d.Vlans != nil { vlans_attr := make(map[string]attr.Value) for k, v := range d.Vlans { diff --git a/internal/resource_org_wlan/sdk_to_terraform_radius.go b/internal/resource_org_wlan/sdk_to_terraform_radius.go index dc32fea..b0fa469 100644 --- a/internal/resource_org_wlan/sdk_to_terraform_radius.go +++ b/internal/resource_org_wlan/sdk_to_terraform_radius.go @@ -38,7 +38,6 @@ func radiusServersAcctSdkToTerraform(ctx context.Context, diags *diag.Diagnostic port = types.Int64Value(int64(*d.Port)) } - data_map_attr_type := AcctServersValue{}.AttributeTypes(ctx) data_map_value := map[string]attr.Value{ "host": host, "keywrap_enabled": keywrap_enabled, @@ -48,14 +47,13 @@ func radiusServersAcctSdkToTerraform(ctx context.Context, diags *diag.Diagnostic "port": port, "secret": secret, } - data, e := NewAcctServersValue(data_map_attr_type, data_map_value) + data, e := NewAcctServersValue(AcctServersValue{}.AttributeTypes(ctx), data_map_value) diags.Append(e...) acct_value_list = append(acct_value_list, data) } - acct_state_list_type := AcctServersValue{}.Type(ctx) - acct_state_list, e := types.ListValueFrom(ctx, acct_state_list_type, acct_value_list) + acct_state_list, e := types.ListValueFrom(ctx, AcctServersValue{}.Type(ctx), acct_value_list) diags.Append(e...) return acct_state_list @@ -92,7 +90,6 @@ func radiusServersAuthSdkToTerraform(ctx context.Context, diags *diag.Diagnostic require_message_authenticator = types.BoolValue(*d.RequireMessageAuthenticator) } - data_map_attr_type := AuthServersValue{}.AttributeTypes(ctx) data_map_value := map[string]attr.Value{ "host": host, "keywrap_enabled": keywrap_enabled, @@ -103,14 +100,13 @@ func radiusServersAuthSdkToTerraform(ctx context.Context, diags *diag.Diagnostic "require_message_authenticator": require_message_authenticator, "secret": secret, } - data, e := NewAuthServersValue(data_map_attr_type, data_map_value) + data, e := NewAuthServersValue(AuthServersValue{}.AttributeTypes(ctx), data_map_value) diags.Append(e...) auth_value_list = append(auth_value_list, data) } - auth_state_list_type := AuthServersValue{}.Type(ctx) - auth_state_list, e := types.ListValueFrom(ctx, auth_state_list_type, auth_value_list) + auth_state_list, e := types.ListValueFrom(ctx, AuthServersValue{}.Type(ctx), auth_value_list) diags.Append(e...) return auth_state_list diff --git a/internal/resource_org_wlan/sdk_to_terraform_rateset.go b/internal/resource_org_wlan/sdk_to_terraform_rateset.go index a020340..616d651 100644 --- a/internal/resource_org_wlan/sdk_to_terraform_rateset.go +++ b/internal/resource_org_wlan/sdk_to_terraform_rateset.go @@ -55,6 +55,7 @@ func bandRatesetSkToTerraform(ctx context.Context, diags *diag.Diagnostics, d mo func ratesetSkToTerraform(ctx context.Context, diags *diag.Diagnostics, m map[string]models.WlanDatarates) basetypes.MapValue { state_value_map := make(map[string]attr.Value) + for k, d := range m { state_value_map[k] = bandRatesetSkToTerraform(ctx, diags, d) } diff --git a/internal/resource_org_wlan/terraform_to_sdk.go b/internal/resource_org_wlan/terraform_to_sdk.go index 8d3bf1f..b77d7e4 100644 --- a/internal/resource_org_wlan/terraform_to_sdk.go +++ b/internal/resource_org_wlan/terraform_to_sdk.go @@ -15,10 +15,11 @@ import ( func TerraformToSdk(ctx context.Context, plan *OrgWlanModel) (*models.Wlan, diag.Diagnostics) { var diags diag.Diagnostics - unset := make(map[string]interface{}) data := models.Wlan{} data.Ssid = plan.Ssid.ValueString() + unset := make(map[string]interface{}) + if len(plan.TemplateId.ValueString()) > 0 { data.TemplateId = models.NewOptional(models.ToPointer(uuid.MustParse(plan.TemplateId.ValueString()))) } diff --git a/internal/resource_org_wlan/terraform_to_sdk_radsec.go b/internal/resource_org_wlan/terraform_to_sdk_radsec.go index 26e6d4f..33b303f 100644 --- a/internal/resource_org_wlan/terraform_to_sdk_radsec.go +++ b/internal/resource_org_wlan/terraform_to_sdk_radsec.go @@ -46,6 +46,7 @@ func radsecTerraformToSdk(ctx context.Context, diags *diag.Diagnostics, d Radsec if d.ServerName.ValueStringPointer() != nil { data.ServerName = d.ServerName.ValueStringPointer() } + servers := radsecServersTerraformToSdk(ctx, diags, d.Servers) data.Servers = servers diff --git a/internal/resource_site_wlan/sdk_to_terraform.go b/internal/resource_site_wlan/sdk_to_terraform.go index c4b8161..4c181e6 100644 --- a/internal/resource_site_wlan/sdk_to_terraform.go +++ b/internal/resource_site_wlan/sdk_to_terraform.go @@ -144,7 +144,7 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (SiteWlanModel, diag allow_ssdp = types.BoolValue(*data.AllowSsdp) } - if data.ApIds.IsValueSet() && data.ApIds.Value() != nil { + if data.ApIds.IsValueSet() && len(*data.ApIds.Value()) > 0 { ap_ids = mist_transform.ListOfUuidSdkToTerraform(ctx, *data.ApIds.Value()) } diff --git a/internal/resource_site_wlan/sdk_to_terraform_dns_server_rewrite.go b/internal/resource_site_wlan/sdk_to_terraform_dns_server_rewrite.go index 8f2f4a7..14b1601 100644 --- a/internal/resource_site_wlan/sdk_to_terraform_dns_server_rewrite.go +++ b/internal/resource_site_wlan/sdk_to_terraform_dns_server_rewrite.go @@ -19,15 +19,14 @@ func dnsServerRewriteSdkToTerraform(ctx context.Context, diags *diag.Diagnostics if d != nil && d.Enabled != nil { enabled = types.BoolValue(*d.Enabled) } - //if d != nil && d.RadiusGroups != nil && len(d.RadiusGroups) > 0 { radius_groups_values := make(map[string]attr.Value) - for k, v := range d.RadiusGroups { - radius_groups_values[k] = types.StringValue(v) + if d != nil && d.RadiusGroups != nil && len(d.RadiusGroups) > 0 { + for k, v := range d.RadiusGroups { + radius_groups_values[k] = types.StringValue(v) + } } radius_groups = types.MapValueMust(types.StringType, radius_groups_values) - //} - data_map_attr_type := DnsServerRewriteValue{}.AttributeTypes(ctx) data_map_value := map[string]attr.Value{ "enabled": enabled,