Skip to content

Commit

Permalink
fix org_wlan resource following v0.2.12 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmunzer committed Dec 18, 2024
1 parent 13f5abf commit 35831dc
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 47 deletions.
32 changes: 19 additions & 13 deletions internal/resource_org_wlan/sdk_to_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand All @@ -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())
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/resource_org_wlan/sdk_to_terraform_airwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 12 additions & 12 deletions internal/resource_org_wlan/sdk_to_terraform_app_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 0 additions & 3 deletions internal/resource_org_wlan/sdk_to_terraform_dynamic_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
12 changes: 4 additions & 8 deletions internal/resource_org_wlan/sdk_to_terraform_radius.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/resource_org_wlan/sdk_to_terraform_rateset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion internal/resource_org_wlan/terraform_to_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
}
Expand Down
1 change: 1 addition & 0 deletions internal/resource_org_wlan/terraform_to_sdk_radsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion internal/resource_site_wlan/sdk_to_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

1 comment on commit 35831dc

@tmunzer
Copy link
Collaborator Author

@tmunzer tmunzer commented on 35831dc Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix fox #66 and #63

Please sign in to comment.