diff --git a/internal/resource_device_switch/terraform_to_sdk_switch_matching.go b/internal/resource_device_switch/terraform_to_sdk_port_config.go similarity index 100% rename from internal/resource_device_switch/terraform_to_sdk_switch_matching.go rename to internal/resource_device_switch/terraform_to_sdk_port_config.go diff --git a/internal/resource_org_networktemplate/org_networktemplate_resource_gen.go b/internal/resource_org_networktemplate/org_networktemplate_resource_gen.go index 95cf08e..a8759f6 100644 --- a/internal/resource_org_networktemplate/org_networktemplate_resource_gen.go +++ b/internal/resource_org_networktemplate/org_networktemplate_resource_gen.go @@ -2665,6 +2665,7 @@ func OrgNetworktemplateResourceSchema(ctx context.Context) schema.Schema { Computed: true, Description: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", MarkdownDescription: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", + Default: listdefault.StaticValue(basetypes.NewListValueMust(basetypes.StringType{}, []attr.Value{})), }, "input_port_ids_egress": schema.ListAttribute{ ElementType: types.StringType, @@ -2672,6 +2673,7 @@ func OrgNetworktemplateResourceSchema(ctx context.Context) schema.Schema { Computed: true, Description: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", MarkdownDescription: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", + Default: listdefault.StaticValue(basetypes.NewListValueMust(basetypes.StringType{}, []attr.Value{})), }, "input_port_ids_ingress": schema.ListAttribute{ ElementType: types.StringType, @@ -2679,6 +2681,7 @@ func OrgNetworktemplateResourceSchema(ctx context.Context) schema.Schema { Computed: true, Description: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", MarkdownDescription: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", + Default: listdefault.StaticValue(basetypes.NewListValueMust(basetypes.StringType{}, []attr.Value{})), }, "output_network": schema.StringAttribute{ Optional: true, diff --git a/internal/resource_org_networktemplate/sdk_to_terraform_switch_matching.go b/internal/resource_org_networktemplate/sdk_to_terraform_switch_matching.go index 39b543d..eb02b2c 100644 --- a/internal/resource_org_networktemplate/sdk_to_terraform_switch_matching.go +++ b/internal/resource_org_networktemplate/sdk_to_terraform_switch_matching.go @@ -25,13 +25,13 @@ func switchMatchingRulesPortMirroringSdkToTerraform(ctx context.Context, diags * var output_network basetypes.StringValue var output_port_id basetypes.StringValue - if d.InputNetworksIngress != nil && len(d.InputNetworksIngress) > 0 { + if d.InputNetworksIngress != nil { input_networks_ingress = mist_transform.ListOfStringSdkToTerraform(ctx, d.InputNetworksIngress) } - if d.InputPortIdsEgress != nil && len(d.InputPortIdsEgress) > 0 { + if d.InputPortIdsEgress != nil { input_port_ids_egress = mist_transform.ListOfStringSdkToTerraform(ctx, d.InputPortIdsEgress) } - if d.InputPortIdsIngress != nil && len(d.InputPortIdsIngress) > 0 { + if d.InputPortIdsIngress != nil { input_port_ids_ingress = mist_transform.ListOfStringSdkToTerraform(ctx, d.InputPortIdsIngress) } if d.OutputNetwork != nil { diff --git a/internal/resource_org_networktemplate/terraform_to_sdk_switch_matching.go b/internal/resource_org_networktemplate/terraform_to_sdk_switch_matching.go index 87d57c1..97323b5 100644 --- a/internal/resource_org_networktemplate/terraform_to_sdk_switch_matching.go +++ b/internal/resource_org_networktemplate/terraform_to_sdk_switch_matching.go @@ -37,6 +37,9 @@ func switchMatchingRulesPortMirroringTerraformToSdk(ctx context.Context, diags * item_obj.InputPortIdsIngress = make([]string, 0) } + if plan_obj.OutputNetwork.ValueStringPointer() != nil { + item_obj.OutputNetwork = models.ToPointer(plan_obj.OutputNetwork.ValueString()) + } if plan_obj.OutputPortId.ValueStringPointer() != nil { item_obj.OutputPortId = models.ToPointer(plan_obj.OutputPortId.ValueString()) } diff --git a/internal/resource_site_networktemplate/sdk_to_terraform_switch_matching.go b/internal/resource_site_networktemplate/sdk_to_terraform_switch_matching.go index a4e17cc..5aa4ec3 100644 --- a/internal/resource_site_networktemplate/sdk_to_terraform_switch_matching.go +++ b/internal/resource_site_networktemplate/sdk_to_terraform_switch_matching.go @@ -25,13 +25,13 @@ func switchMatchingRulesPortMirroringSdkToTerraform(ctx context.Context, diags * var output_network basetypes.StringValue var output_port_id basetypes.StringValue - if d.InputNetworksIngress != nil && len(d.InputNetworksIngress) > 0 { + if d.InputNetworksIngress != nil { input_networks_ingress = mist_transform.ListOfStringSdkToTerraform(ctx, d.InputNetworksIngress) } - if d.InputPortIdsEgress != nil && len(d.InputPortIdsEgress) > 0 { + if d.InputPortIdsEgress != nil { input_port_ids_egress = mist_transform.ListOfStringSdkToTerraform(ctx, d.InputPortIdsEgress) } - if d.InputPortIdsIngress != nil && len(d.InputPortIdsIngress) > 0 { + if d.InputPortIdsIngress != nil { input_port_ids_ingress = mist_transform.ListOfStringSdkToTerraform(ctx, d.InputPortIdsIngress) } if d.OutputNetwork != nil { diff --git a/internal/resource_site_networktemplate/site_networktemplate_resource_gen.go b/internal/resource_site_networktemplate/site_networktemplate_resource_gen.go index 9b932c3..241f209 100644 --- a/internal/resource_site_networktemplate/site_networktemplate_resource_gen.go +++ b/internal/resource_site_networktemplate/site_networktemplate_resource_gen.go @@ -2653,6 +2653,7 @@ func SiteNetworktemplateResourceSchema(ctx context.Context) schema.Schema { Computed: true, Description: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", MarkdownDescription: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", + Default: listdefault.StaticValue(basetypes.NewListValueMust(basetypes.StringType{}, []attr.Value{})), }, "input_port_ids_egress": schema.ListAttribute{ ElementType: types.StringType, @@ -2660,6 +2661,7 @@ func SiteNetworktemplateResourceSchema(ctx context.Context) schema.Schema { Computed: true, Description: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", MarkdownDescription: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", + Default: listdefault.StaticValue(basetypes.NewListValueMust(basetypes.StringType{}, []attr.Value{})), }, "input_port_ids_ingress": schema.ListAttribute{ ElementType: types.StringType, @@ -2667,6 +2669,7 @@ func SiteNetworktemplateResourceSchema(ctx context.Context) schema.Schema { Computed: true, Description: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", MarkdownDescription: "at least one of the `input_port_ids_ingress`, `input_port_ids_egress` or `input_networks_ingress ` should be specified", + Default: listdefault.StaticValue(basetypes.NewListValueMust(basetypes.StringType{}, []attr.Value{})), }, "output_network": schema.StringAttribute{ Optional: true, diff --git a/internal/resource_site_networktemplate/terraform_to_sdk_switch_matching.go b/internal/resource_site_networktemplate/terraform_to_sdk_switch_matching.go index c05b766..678c1f8 100644 --- a/internal/resource_site_networktemplate/terraform_to_sdk_switch_matching.go +++ b/internal/resource_site_networktemplate/terraform_to_sdk_switch_matching.go @@ -37,6 +37,9 @@ func switchMatchingRulesPortMirroringTerraformToSdk(ctx context.Context, diags * item_obj.InputPortIdsIngress = make([]string, 0) } + if plan_obj.OutputNetwork.ValueStringPointer() != nil { + item_obj.OutputNetwork = models.ToPointer(plan_obj.OutputNetwork.ValueString()) + } if plan_obj.OutputPortId.ValueStringPointer() != nil { item_obj.OutputPortId = models.ToPointer(plan_obj.OutputPortId.ValueString()) }