Skip to content

Commit

Permalink
update the way to retrieve vlan_id string value from SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
tmunzer committed Dec 24, 2024
1 parent dde597f commit 8345add
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion internal/resource_org_network/sdk_to_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_org_network
import (
"context"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
mist_transform "github.com/Juniper/terraform-provider-mist/internal/commons/utils"

"github.com/tmunzer/mistapi-go/mistapi/models"
Expand Down Expand Up @@ -74,7 +75,7 @@ func SdkToTerraform(ctx context.Context, data models.Network) (OrgNetworkModel,
tenants = TenantSdkToTerraform(ctx, &diags, data.Tenants)
}
if data.VlanId != nil {
vlan_id = types.StringValue(data.VlanId.String())
vlan_id = mist_api.VlanAsString(*data.VlanId)
}
if data.VpnAccess != nil && len(data.VpnAccess) > 0 {
vpn_access = VpnSdkToTerraform(ctx, &diags, data.VpnAccess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_org_networktemplate
import (
"context"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
"github.com/tmunzer/mistapi-go/mistapi/models"

"github.com/hashicorp/terraform-plugin-framework/attr"
Expand Down Expand Up @@ -42,7 +43,7 @@ func NetworksSdkToTerraform(ctx context.Context, diags *diag.Diagnostics, m map[
if d.Subnet6 != nil {
subnet6 = types.StringValue(*d.Subnet6)
}
vlan_id = types.StringValue(d.VlanId.String())
vlan_id = mist_api.VlanAsString(d.VlanId)

data_map_attr_type := NetworksValue{}.AttributeTypes(ctx)
data_map_value := map[string]attr.Value{
Expand Down
3 changes: 2 additions & 1 deletion internal/resource_org_setting/sdk_to_terraform_synthetic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_org_setting
import (
"context"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
mist_transform "github.com/Juniper/terraform-provider-mist/internal/commons/utils"
"github.com/tmunzer/mistapi-go/mistapi/models"

Expand Down Expand Up @@ -30,7 +31,7 @@ func syntheticTestVlanSdkToTerraform(ctx context.Context, diags *diag.Diagnostic
if d.VlanIds != nil {
var items []attr.Value
for _, item := range d.VlanIds {
items = append(items, types.StringValue(item.String()))
items = append(items, mist_api.VlanAsString(item))
}
vlan_ids, _ = types.ListValue(basetypes.StringType{}, items)
}
Expand Down
5 changes: 3 additions & 2 deletions internal/resource_org_wlan/sdk_to_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"strings"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
mist_transform "github.com/Juniper/terraform-provider-mist/internal/commons/utils"

"github.com/tmunzer/mistapi-go/mistapi/models"
Expand Down Expand Up @@ -458,7 +459,7 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag.
}

if data.VlanId != nil {
vlan_id = types.StringValue(string(data.VlanId.String()))
vlan_id = mist_api.VlanAsString(*data.VlanId)
}

if data.VlanIds != nil {
Expand All @@ -469,7 +470,7 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (OrgWlanModel, diag.
}
} else if vlan_ids_as_list, ok := data.VlanIds.AsArrayOfVlanIdWithVariable2(); ok {
for _, v := range *vlan_ids_as_list {
list = append(list, types.StringValue(v.String()))
list = append(list, mist_api.VlanAsString(v))
}
}
r, e := types.ListValue(basetypes.StringType{}, list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_site_networktemplate
import (
"context"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
"github.com/tmunzer/mistapi-go/mistapi/models"

"github.com/hashicorp/terraform-plugin-framework/attr"
Expand Down Expand Up @@ -42,7 +43,7 @@ func NetworksSdkToTerraform(ctx context.Context, diags *diag.Diagnostics, m map[
if d.Subnet6 != nil {
subnet6 = types.StringValue(*d.Subnet6)
}
vlan_id = types.StringValue(d.VlanId.String())
vlan_id = mist_api.VlanAsString(d.VlanId)

data_map_attr_type := NetworksValue{}.AttributeTypes(ctx)
data_map_value := map[string]attr.Value{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_site_setting
import (
"context"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
"github.com/tmunzer/mistapi-go/mistapi/models"

"github.com/hashicorp/terraform-plugin-framework/attr"
Expand All @@ -21,7 +22,7 @@ func criticalUrlMonitoringMonitorSdkToTerraform(ctx context.Context, diags *diag
url = types.StringValue(*d.Url)
}
if d.VlanId != nil {
vlan_id = types.StringValue(d.VlanId.String())
vlan_id = mist_api.VlanAsString(*d.VlanId)
}

data_map_attr_type := MonitorsValue{}.AttributeTypes(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_site_setting
import (
"context"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
"github.com/tmunzer/mistapi-go/mistapi/models"

"github.com/hashicorp/terraform-plugin-framework/attr"
Expand Down Expand Up @@ -51,7 +52,7 @@ func synthteticTestVlansSdkToTerraform(ctx context.Context, diags *diag.Diagnost
if d.VlanIds != nil {
var items []attr.Value
for _, item := range d.VlanIds {
items = append(items, types.StringValue(item.String()))
items = append(items, mist_api.VlanAsString(item))
}
vlan_ids, _ = types.ListValue(basetypes.StringType{}, items)
}
Expand Down
5 changes: 3 additions & 2 deletions internal/resource_site_wlan/sdk_to_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"strings"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
mist_transform "github.com/Juniper/terraform-provider-mist/internal/commons/utils"

"github.com/tmunzer/mistapi-go/mistapi/models"
Expand Down Expand Up @@ -458,7 +459,7 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (SiteWlanModel, diag
}

if data.VlanId != nil {
vlan_id = types.StringValue(string(data.VlanId.String()))
vlan_id = mist_api.VlanAsString(*data.VlanId)
}

if data.VlanIds != nil {
Expand All @@ -469,7 +470,7 @@ func SdkToTerraform(ctx context.Context, data *models.Wlan) (SiteWlanModel, diag
}
} else if vlan_ids_as_list, ok := data.VlanIds.AsArrayOfVlanIdWithVariable2(); ok {
for _, v := range *vlan_ids_as_list {
list = append(list, types.StringValue(v.String()))
list = append(list, mist_api.VlanAsString(v))
}
}
r, e := types.ListValue(basetypes.StringType{}, list)
Expand Down

0 comments on commit 8345add

Please sign in to comment.