From 7c8724bc5c17210204ab354201e4b17a7dc57d2f Mon Sep 17 00:00:00 2001 From: Mateusz Filipowicz Date: Fri, 7 Feb 2025 11:02:48 +0100 Subject: [PATCH] feat: support excluded_network_ids on port profile resource --- internal/provider/resource_port_profile.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/provider/resource_port_profile.go b/internal/provider/resource_port_profile.go index f1e810a..02424b1 100644 --- a/internal/provider/resource_port_profile.go +++ b/internal/provider/resource_port_profile.go @@ -66,6 +66,12 @@ func resourcePortProfile() *schema.Resource { Optional: true, Default: false, }, + "excluded_network_ids": { + Description: "List of network IDs to exclude on the port profile when forward is set to customize.", + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "forward": { Description: "The type forwarding to use for the port profile. Can be `all`, `native`, `customize` or `disabled`.", Type: schema.TypeString, @@ -158,7 +164,7 @@ func resourcePortProfile() *schema.Resource { ValidateFunc: validation.IntBetween(0, 100), }, "speed": { - Description: "The link speed to set for the port profile. Can be one of `10`, `100`, `1000`, `2500`, `5000`, `10000`, `20000`, `25000`, `40000`, `50000` or `100000`", + Description: "The link speed to set for the port profile in Mbps. Can be one of `10`, `100`, `1000`, `2500`, `5000`, `10000`, `20000`, `25000`, `40000`, `50000` or `100000`. When `autoneg` is true, this setting is ignored.", Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntInSlice([]int{10, 100, 1000, 2500, 5000, 10000, 20000, 25000, 40000, 50000, 100000}), @@ -276,12 +282,18 @@ func resourcePortProfileGetResourceData(d *schema.ResourceData) (*unifi.PortProf return nil, err } + excludedNetworkIDs, err := setToStringSlice(d.Get("excluded_network_ids").(*schema.Set)) + if err != nil { + return nil, err + } + return &unifi.PortProfile{ Autoneg: d.Get("autoneg").(bool), Dot1XCtrl: d.Get("dot1x_ctrl").(string), Dot1XIDleTimeout: d.Get("dot1x_idle_timeout").(int), EgressRateLimitKbps: d.Get("egress_rate_limit_kbps").(int), EgressRateLimitKbpsEnabled: d.Get("egress_rate_limit_kbps_enabled").(bool), + ExcludedNetworkIDs: excludedNetworkIDs, Forward: d.Get("forward").(string), FullDuplex: d.Get("full_duplex").(bool), Isolation: d.Get("isolation").(bool), @@ -321,6 +333,7 @@ func resourcePortProfileSetResourceData(resp *unifi.PortProfile, d *schema.Resou d.Set("dot1x_idle_timeout", resp.Dot1XIDleTimeout) d.Set("egress_rate_limit_kbps", resp.EgressRateLimitKbps) d.Set("egress_rate_limit_kbps_enabled", resp.EgressRateLimitKbpsEnabled) + d.Set("excluded_network_ids", stringSliceToSet(resp.ExcludedNetworkIDs)) d.Set("forward", resp.Forward) d.Set("full_duplex", resp.FullDuplex) d.Set("isolation", resp.Isolation)