From 311f2f7140f76859f99aca72a3c2150f763c72aa Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Mon, 11 Dec 2023 11:14:19 +0000 Subject: [PATCH 1/4] Resolve issue #119 --- CHANGELOG.md | 1 + .../traffic_data_policy_definition.md | 6 ++--- docs/guides/changelog.md | 1 + .../traffic_data_policy_definition.md | 9 +++---- .../traffic_data_policy_definition.yaml | 21 +++++----------- ...ce_sdwan_traffic_data_policy_definition.go | 12 +++++----- ...el_sdwan_traffic_data_policy_definition.go | 24 +++++++++---------- ...ce_sdwan_traffic_data_policy_definition.go | 21 +++++----------- templates/guides/changelog.md.tmpl | 1 + 9 files changed, 39 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b0d61ea..65de5556 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Add `sdwan_system_aaa_profile_parcel` resource and data source - Add `sdwan_system_banner_profile_parcel` resource and data source - Add `sdwan_system_bfd_profile_parcel` resource and data source +- BREAKING CHANGE: convert `protocol`, `source_port`, `destination_port` attribute of `sdwan_traffic_data_policy_definition` to Strings to support multiple values ## 0.2.11 diff --git a/docs/data-sources/traffic_data_policy_definition.md b/docs/data-sources/traffic_data_policy_definition.md index 21b3ab83..70d4fa51 100644 --- a/docs/data-sources/traffic_data_policy_definition.md +++ b/docs/data-sources/traffic_data_policy_definition.md @@ -124,7 +124,7 @@ Read-Only: - `destination_data_prefix_list_id` (String) Destination Data Prefix list ID - `destination_data_prefix_list_version` (Number) Destination Data Prefix list version - `destination_ip` (String) Destination IP -- `destination_port` (Number) Destination port +- `destination_port` (String) Destination port, 0-65535 (Single value, range or multiple values separated by spaces) - `destination_region` (String) Destination region - `dns` (String) DNS request or response - `dns_application_list_id` (String) DNS Application list ID @@ -132,11 +132,11 @@ Read-Only: - `dscp` (Number) DSCP value - `packet_length` (Number) Packet length - `plp` (String) PLP -- `protocol` (Number) IP Protocol +- `protocol` (String) IP Protocol, 0-255 (Single value or multiple values separated by spaces) - `source_data_prefix_list_id` (String) Source Data Prefix list ID - `source_data_prefix_list_version` (Number) Source Data Prefix list version - `source_ip` (String) Source IP -- `source_port` (Number) Source port +- `source_port` (String) Source port, 0-65535 (Single value, range or multiple values separated by spaces) - `tcp` (String) TCP flags - `traffic_to` (String) Traffic to - `type` (String) Type of match entry diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 768b3c08..0315e923 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -16,6 +16,7 @@ description: |- - Add `sdwan_system_aaa_profile_parcel` resource and data source - Add `sdwan_system_banner_profile_parcel` resource and data source - Add `sdwan_system_bfd_profile_parcel` resource and data source +- BREAKING CHANGE: convert `protocol`, `source_port`, `destination_port` attribute of `sdwan_traffic_data_policy_definition` to Strings to support multiple values ## 0.2.11 diff --git a/docs/resources/traffic_data_policy_definition.md b/docs/resources/traffic_data_policy_definition.md index c498ff43..c0b699e6 100644 --- a/docs/resources/traffic_data_policy_definition.md +++ b/docs/resources/traffic_data_policy_definition.md @@ -188,8 +188,7 @@ Optional: - `destination_data_prefix_list_id` (String) Destination Data Prefix list ID - `destination_data_prefix_list_version` (Number) Destination Data Prefix list version - `destination_ip` (String) Destination IP -- `destination_port` (Number) Destination port - - Range: `0`-`65535` +- `destination_port` (String) Destination port, 0-65535 (Single value, range or multiple values separated by spaces) - `destination_region` (String) Destination region - Choices: `primary-region`, `secondary-region`, `other-region` - `dns` (String) DNS request or response @@ -202,13 +201,11 @@ Optional: - Range: `0`-`65535` - `plp` (String) PLP - Choices: `low`, `high` -- `protocol` (Number) IP Protocol - - Range: `0`-`255` +- `protocol` (String) IP Protocol, 0-255 (Single value or multiple values separated by spaces) - `source_data_prefix_list_id` (String) Source Data Prefix list ID - `source_data_prefix_list_version` (Number) Source Data Prefix list version - `source_ip` (String) Source IP -- `source_port` (Number) Source port - - Range: `0`-`65535` +- `source_port` (String) Source port, 0-65535 (Single value, range or multiple values separated by spaces) - `tcp` (String) TCP flags - Choices: `syn` - `traffic_to` (String) Traffic to diff --git a/gen/definitions/generic/traffic_data_policy_definition.yaml b/gen/definitions/generic/traffic_data_policy_definition.yaml index 5d1099fc..1b0d2c7b 100644 --- a/gen/definitions/generic/traffic_data_policy_definition.yaml +++ b/gen/definitions/generic/traffic_data_policy_definition.yaml @@ -175,11 +175,8 @@ attributes: conditional_attribute: name: type value: protocol - type: Int64 - model_type_string: true - description: IP Protocol - min_int: 0 - max_int: 255 + type: String + description: IP Protocol, 0-255 (Single value or multiple values separated by spaces) example: 10 exclude_test: true - model_name: ref @@ -210,11 +207,8 @@ attributes: conditional_attribute: name: type value: sourcePort - type: Int64 - model_type_string: true - description: Source port - min_int: 0 - max_int: 65535 + type: String + description: Source port, 0-65535 (Single value, range or multiple values separated by spaces) example: 10 exclude_test: true - model_name: ref @@ -245,11 +239,8 @@ attributes: conditional_attribute: name: type value: destinationPort - type: Int64 - model_type_string: true - description: Destination port - min_int: 0 - max_int: 65535 + type: String + description: Destination port, 0-65535 (Single value, range or multiple values separated by spaces) example: 100 exclude_test: true - model_name: value diff --git a/internal/provider/data_source_sdwan_traffic_data_policy_definition.go b/internal/provider/data_source_sdwan_traffic_data_policy_definition.go index bd6007b7..c6e91c0f 100644 --- a/internal/provider/data_source_sdwan_traffic_data_policy_definition.go +++ b/internal/provider/data_source_sdwan_traffic_data_policy_definition.go @@ -139,8 +139,8 @@ func (d *TrafficDataPolicyDefinitionDataSource) Schema(ctx context.Context, req MarkdownDescription: "PLP", Computed: true, }, - "protocol": schema.Int64Attribute{ - MarkdownDescription: "IP Protocol", + "protocol": schema.StringAttribute{ + MarkdownDescription: "IP Protocol, 0-255 (Single value or multiple values separated by spaces)", Computed: true, }, "source_data_prefix_list_id": schema.StringAttribute{ @@ -155,8 +155,8 @@ func (d *TrafficDataPolicyDefinitionDataSource) Schema(ctx context.Context, req MarkdownDescription: "Source IP", Computed: true, }, - "source_port": schema.Int64Attribute{ - MarkdownDescription: "Source port", + "source_port": schema.StringAttribute{ + MarkdownDescription: "Source port, 0-65535 (Single value, range or multiple values separated by spaces)", Computed: true, }, "destination_data_prefix_list_id": schema.StringAttribute{ @@ -171,8 +171,8 @@ func (d *TrafficDataPolicyDefinitionDataSource) Schema(ctx context.Context, req MarkdownDescription: "Destination IP", Computed: true, }, - "destination_port": schema.Int64Attribute{ - MarkdownDescription: "Destination port", + "destination_port": schema.StringAttribute{ + MarkdownDescription: "Destination port, 0-65535 (Single value, range or multiple values separated by spaces)", Computed: true, }, "destination_region": schema.StringAttribute{ diff --git a/internal/provider/model_sdwan_traffic_data_policy_definition.go b/internal/provider/model_sdwan_traffic_data_policy_definition.go index c8784392..ac1fcc8e 100644 --- a/internal/provider/model_sdwan_traffic_data_policy_definition.go +++ b/internal/provider/model_sdwan_traffic_data_policy_definition.go @@ -57,15 +57,15 @@ type TrafficDataPolicyDefinitionSequencesMatchEntries struct { Dscp types.Int64 `tfsdk:"dscp"` PacketLength types.Int64 `tfsdk:"packet_length"` Plp types.String `tfsdk:"plp"` - Protocol types.Int64 `tfsdk:"protocol"` + Protocol types.String `tfsdk:"protocol"` SourceDataPrefixListId types.String `tfsdk:"source_data_prefix_list_id"` SourceDataPrefixListVersion types.Int64 `tfsdk:"source_data_prefix_list_version"` SourceIp types.String `tfsdk:"source_ip"` - SourcePort types.Int64 `tfsdk:"source_port"` + SourcePort types.String `tfsdk:"source_port"` DestinationDataPrefixListId types.String `tfsdk:"destination_data_prefix_list_id"` DestinationDataPrefixListVersion types.Int64 `tfsdk:"destination_data_prefix_list_version"` DestinationIp types.String `tfsdk:"destination_ip"` - DestinationPort types.Int64 `tfsdk:"destination_port"` + DestinationPort types.String `tfsdk:"destination_port"` DestinationRegion types.String `tfsdk:"destination_region"` Tcp types.String `tfsdk:"tcp"` TrafficTo types.String `tfsdk:"traffic_to"` @@ -182,7 +182,7 @@ func (data TrafficDataPolicyDefinition) toBody(ctx context.Context) string { itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.Plp.ValueString()) } if !childItem.Protocol.IsNull() && childItem.Type.ValueString() == "protocol" { - itemChildBody, _ = sjson.Set(itemChildBody, "value", fmt.Sprint(childItem.Protocol.ValueInt64())) + itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.Protocol.ValueString()) } if !childItem.SourceDataPrefixListId.IsNull() && childItem.Type.ValueString() == "sourceDataPrefixList" { itemChildBody, _ = sjson.Set(itemChildBody, "ref", childItem.SourceDataPrefixListId.ValueString()) @@ -191,7 +191,7 @@ func (data TrafficDataPolicyDefinition) toBody(ctx context.Context) string { itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.SourceIp.ValueString()) } if !childItem.SourcePort.IsNull() && childItem.Type.ValueString() == "sourcePort" { - itemChildBody, _ = sjson.Set(itemChildBody, "value", fmt.Sprint(childItem.SourcePort.ValueInt64())) + itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.SourcePort.ValueString()) } if !childItem.DestinationDataPrefixListId.IsNull() && childItem.Type.ValueString() == "destinationDataPrefixList" { itemChildBody, _ = sjson.Set(itemChildBody, "ref", childItem.DestinationDataPrefixListId.ValueString()) @@ -200,7 +200,7 @@ func (data TrafficDataPolicyDefinition) toBody(ctx context.Context) string { itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.DestinationIp.ValueString()) } if !childItem.DestinationPort.IsNull() && childItem.Type.ValueString() == "destinationPort" { - itemChildBody, _ = sjson.Set(itemChildBody, "value", fmt.Sprint(childItem.DestinationPort.ValueInt64())) + itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.DestinationPort.ValueString()) } if !childItem.DestinationRegion.IsNull() && childItem.Type.ValueString() == "destinationRegion" { itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.DestinationRegion.ValueString()) @@ -486,9 +486,9 @@ func (data *TrafficDataPolicyDefinition) fromBody(ctx context.Context, res gjson cItem.Plp = types.StringNull() } if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "protocol" { - cItem.Protocol = types.Int64Value(ccValue.Int()) + cItem.Protocol = types.StringValue(ccValue.String()) } else { - cItem.Protocol = types.Int64Null() + cItem.Protocol = types.StringNull() } if ccValue := cv.Get("ref"); ccValue.Exists() && cItem.Type.ValueString() == "sourceDataPrefixList" { cItem.SourceDataPrefixListId = types.StringValue(ccValue.String()) @@ -501,9 +501,9 @@ func (data *TrafficDataPolicyDefinition) fromBody(ctx context.Context, res gjson cItem.SourceIp = types.StringNull() } if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "sourcePort" { - cItem.SourcePort = types.Int64Value(ccValue.Int()) + cItem.SourcePort = types.StringValue(ccValue.String()) } else { - cItem.SourcePort = types.Int64Null() + cItem.SourcePort = types.StringNull() } if ccValue := cv.Get("ref"); ccValue.Exists() && cItem.Type.ValueString() == "destinationDataPrefixList" { cItem.DestinationDataPrefixListId = types.StringValue(ccValue.String()) @@ -516,9 +516,9 @@ func (data *TrafficDataPolicyDefinition) fromBody(ctx context.Context, res gjson cItem.DestinationIp = types.StringNull() } if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "destinationPort" { - cItem.DestinationPort = types.Int64Value(ccValue.Int()) + cItem.DestinationPort = types.StringValue(ccValue.String()) } else { - cItem.DestinationPort = types.Int64Null() + cItem.DestinationPort = types.StringNull() } if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "destinationRegion" { cItem.DestinationRegion = types.StringValue(ccValue.String()) diff --git a/internal/provider/resource_sdwan_traffic_data_policy_definition.go b/internal/provider/resource_sdwan_traffic_data_policy_definition.go index 5577e4ac..5cc9242d 100644 --- a/internal/provider/resource_sdwan_traffic_data_policy_definition.go +++ b/internal/provider/resource_sdwan_traffic_data_policy_definition.go @@ -178,12 +178,9 @@ func (r *TrafficDataPolicyDefinitionResource) Schema(ctx context.Context, req re stringvalidator.OneOf("low", "high"), }, }, - "protocol": schema.Int64Attribute{ - MarkdownDescription: helpers.NewAttributeDescription("IP Protocol").AddIntegerRangeDescription(0, 255).String, + "protocol": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("IP Protocol, 0-255 (Single value or multiple values separated by spaces)").String, Optional: true, - Validators: []validator.Int64{ - int64validator.Between(0, 255), - }, }, "source_data_prefix_list_id": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Source Data Prefix list ID").String, @@ -197,12 +194,9 @@ func (r *TrafficDataPolicyDefinitionResource) Schema(ctx context.Context, req re MarkdownDescription: helpers.NewAttributeDescription("Source IP").String, Optional: true, }, - "source_port": schema.Int64Attribute{ - MarkdownDescription: helpers.NewAttributeDescription("Source port").AddIntegerRangeDescription(0, 65535).String, + "source_port": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Source port, 0-65535 (Single value, range or multiple values separated by spaces)").String, Optional: true, - Validators: []validator.Int64{ - int64validator.Between(0, 65535), - }, }, "destination_data_prefix_list_id": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Destination Data Prefix list ID").String, @@ -216,12 +210,9 @@ func (r *TrafficDataPolicyDefinitionResource) Schema(ctx context.Context, req re MarkdownDescription: helpers.NewAttributeDescription("Destination IP").String, Optional: true, }, - "destination_port": schema.Int64Attribute{ - MarkdownDescription: helpers.NewAttributeDescription("Destination port").AddIntegerRangeDescription(0, 65535).String, + "destination_port": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Destination port, 0-65535 (Single value, range or multiple values separated by spaces)").String, Optional: true, - Validators: []validator.Int64{ - int64validator.Between(0, 65535), - }, }, "destination_region": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Destination region").AddStringEnumDescription("primary-region", "secondary-region", "other-region").String, diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 768b3c08..0315e923 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -16,6 +16,7 @@ description: |- - Add `sdwan_system_aaa_profile_parcel` resource and data source - Add `sdwan_system_banner_profile_parcel` resource and data source - Add `sdwan_system_bfd_profile_parcel` resource and data source +- BREAKING CHANGE: convert `protocol`, `source_port`, `destination_port` attribute of `sdwan_traffic_data_policy_definition` to Strings to support multiple values ## 0.2.11 From e66e0b409653ff36022cb30bdf19fb095b3de42a Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Mon, 11 Dec 2023 16:20:33 +0000 Subject: [PATCH 2/4] Resolve issue #120 --- .../traffic_data_policy_definition.md | 2 ++ .../traffic_data_policy_definition.md | 2 ++ .../traffic_data_policy_definition.yaml | 20 ++++++++++++++++ ...ce_sdwan_traffic_data_policy_definition.go | 8 +++++++ ...el_sdwan_traffic_data_policy_definition.go | 24 +++++++++++++++++++ ...ce_sdwan_traffic_data_policy_definition.go | 8 +++++++ 6 files changed, 64 insertions(+) diff --git a/docs/data-sources/traffic_data_policy_definition.md b/docs/data-sources/traffic_data_policy_definition.md index 70d4fa51..1d0f4891 100644 --- a/docs/data-sources/traffic_data_policy_definition.md +++ b/docs/data-sources/traffic_data_policy_definition.md @@ -102,6 +102,8 @@ Read-Only: - `service_tloc_ip` (String) Service TLOC IP address - `service_tloc_list_id` (String) Service TLOC list ID - `service_tloc_list_version` (Number) Service TLOC list version +- `service_tloc_local` (String) Service TLOC Local, Any value (including an empty string) will enable this feature +- `service_tloc_restrict` (String) Service TLOC Restrict, Any value (including an empty string) will enable this feature - `service_type` (String) Service type - `service_vpn_id` (Number) Service VPN ID - `tloc_color` (String) TLOC color diff --git a/docs/resources/traffic_data_policy_definition.md b/docs/resources/traffic_data_policy_definition.md index c0b699e6..d854d59a 100644 --- a/docs/resources/traffic_data_policy_definition.md +++ b/docs/resources/traffic_data_policy_definition.md @@ -158,6 +158,8 @@ Optional: - `service_tloc_ip` (String) Service TLOC IP address - `service_tloc_list_id` (String) Service TLOC list ID - `service_tloc_list_version` (Number) Service TLOC list version +- `service_tloc_local` (String) Service TLOC Local, Any value (including an empty string) will enable this feature +- `service_tloc_restrict` (String) Service TLOC Restrict, Any value (including an empty string) will enable this feature - `service_type` (String) Service type - Choices: `FW`, `IDP`, `IDS`, `netsvc1`, `netsvc2`, `netsvc3`, `netsvc4`, `netsvc5` - `service_vpn_id` (Number) Service VPN ID diff --git a/gen/definitions/generic/traffic_data_policy_definition.yaml b/gen/definitions/generic/traffic_data_policy_definition.yaml index 1b0d2c7b..90e122ec 100644 --- a/gen/definitions/generic/traffic_data_policy_definition.yaml +++ b/gen/definitions/generic/traffic_data_policy_definition.yaml @@ -690,6 +690,26 @@ attributes: description: Service TLOC IP address example: 1.2.3.4 exclude_test: true + - model_name: local + data_path: [value] + tf_name: service_tloc_local + conditional_attribute: + name: type + value: service + type: String + description: Service TLOC Local, Any value (including an empty string) will enable this feature + example: "" + exclude_test: true + - model_name: restrict + data_path: [value] + tf_name: service_tloc_restrict + conditional_attribute: + name: type + value: service + type: String + description: Service TLOC Restrict, Any value (including an empty string) will enable this feature + example: "" + exclude_test: true - model_name: color data_path: [value, tloc] tf_name: service_tloc_color diff --git a/internal/provider/data_source_sdwan_traffic_data_policy_definition.go b/internal/provider/data_source_sdwan_traffic_data_policy_definition.go index c6e91c0f..66185e04 100644 --- a/internal/provider/data_source_sdwan_traffic_data_policy_definition.go +++ b/internal/provider/data_source_sdwan_traffic_data_policy_definition.go @@ -356,6 +356,14 @@ func (d *TrafficDataPolicyDefinitionDataSource) Schema(ctx context.Context, req MarkdownDescription: "Service TLOC IP address", Computed: true, }, + "service_tloc_local": schema.StringAttribute{ + MarkdownDescription: "Service TLOC Local, Any value (including an empty string) will enable this feature", + Computed: true, + }, + "service_tloc_restrict": schema.StringAttribute{ + MarkdownDescription: "Service TLOC Restrict, Any value (including an empty string) will enable this feature", + Computed: true, + }, "service_tloc_color": schema.StringAttribute{ MarkdownDescription: "Service TLOC color", Computed: true, diff --git a/internal/provider/model_sdwan_traffic_data_policy_definition.go b/internal/provider/model_sdwan_traffic_data_policy_definition.go index ac1fcc8e..166aa956 100644 --- a/internal/provider/model_sdwan_traffic_data_policy_definition.go +++ b/internal/provider/model_sdwan_traffic_data_policy_definition.go @@ -115,6 +115,8 @@ type TrafficDataPolicyDefinitionSequencesActionEntriesSetParameters struct { ServiceTlocListId types.String `tfsdk:"service_tloc_list_id"` ServiceTlocListVersion types.Int64 `tfsdk:"service_tloc_list_version"` ServiceTlocIp types.String `tfsdk:"service_tloc_ip"` + ServiceTlocLocal types.String `tfsdk:"service_tloc_local"` + ServiceTlocRestrict types.String `tfsdk:"service_tloc_restrict"` ServiceTlocColor types.String `tfsdk:"service_tloc_color"` ServiceTlocEncapsulation types.String `tfsdk:"service_tloc_encapsulation"` VpnId types.Int64 `tfsdk:"vpn_id"` @@ -359,6 +361,12 @@ func (data TrafficDataPolicyDefinition) toBody(ctx context.Context) string { if !childChildItem.ServiceTlocIp.IsNull() && childChildItem.Type.ValueString() == "service" { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "value.tloc.ip", childChildItem.ServiceTlocIp.ValueString()) } + if !childChildItem.ServiceTlocLocal.IsNull() && childChildItem.Type.ValueString() == "service" { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "value.local", childChildItem.ServiceTlocLocal.ValueString()) + } + if !childChildItem.ServiceTlocRestrict.IsNull() && childChildItem.Type.ValueString() == "service" { + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "value.restrict", childChildItem.ServiceTlocRestrict.ValueString()) + } if !childChildItem.ServiceTlocColor.IsNull() && childChildItem.Type.ValueString() == "service" { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "value.tloc.color", childChildItem.ServiceTlocColor.ValueString()) } @@ -754,6 +762,16 @@ func (data *TrafficDataPolicyDefinition) fromBody(ctx context.Context, res gjson } else { ccItem.ServiceTlocIp = types.StringNull() } + if cccValue := ccv.Get("value.local"); cccValue.Exists() && ccItem.Type.ValueString() == "service" { + ccItem.ServiceTlocLocal = types.StringValue(cccValue.String()) + } else { + ccItem.ServiceTlocLocal = types.StringNull() + } + if cccValue := ccv.Get("value.restrict"); cccValue.Exists() && ccItem.Type.ValueString() == "service" { + ccItem.ServiceTlocRestrict = types.StringValue(cccValue.String()) + } else { + ccItem.ServiceTlocRestrict = types.StringNull() + } if cccValue := ccv.Get("value.tloc.color"); cccValue.Exists() && ccItem.Type.ValueString() == "service" { ccItem.ServiceTlocColor = types.StringValue(cccValue.String()) } else { @@ -1011,6 +1029,12 @@ func (data *TrafficDataPolicyDefinition) hasChanges(ctx context.Context, state * if !data.Sequences[i].ActionEntries[ii].SetParameters[iii].ServiceTlocIp.Equal(state.Sequences[i].ActionEntries[ii].SetParameters[iii].ServiceTlocIp) { hasChanges = true } + if !data.Sequences[i].ActionEntries[ii].SetParameters[iii].ServiceTlocLocal.Equal(state.Sequences[i].ActionEntries[ii].SetParameters[iii].ServiceTlocLocal) { + hasChanges = true + } + if !data.Sequences[i].ActionEntries[ii].SetParameters[iii].ServiceTlocRestrict.Equal(state.Sequences[i].ActionEntries[ii].SetParameters[iii].ServiceTlocRestrict) { + hasChanges = true + } if !data.Sequences[i].ActionEntries[ii].SetParameters[iii].ServiceTlocColor.Equal(state.Sequences[i].ActionEntries[ii].SetParameters[iii].ServiceTlocColor) { hasChanges = true } diff --git a/internal/provider/resource_sdwan_traffic_data_policy_definition.go b/internal/provider/resource_sdwan_traffic_data_policy_definition.go index 5cc9242d..c197a655 100644 --- a/internal/provider/resource_sdwan_traffic_data_policy_definition.go +++ b/internal/provider/resource_sdwan_traffic_data_policy_definition.go @@ -446,6 +446,14 @@ func (r *TrafficDataPolicyDefinitionResource) Schema(ctx context.Context, req re MarkdownDescription: helpers.NewAttributeDescription("Service TLOC IP address").String, Optional: true, }, + "service_tloc_local": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Service TLOC Local, Any value (including an empty string) will enable this feature").String, + Optional: true, + }, + "service_tloc_restrict": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Service TLOC Restrict, Any value (including an empty string) will enable this feature").String, + Optional: true, + }, "service_tloc_color": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Service TLOC color").String, Optional: true, From edfdf72121f4f07ba2045a7364f70b0f3bc23940 Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Thu, 14 Dec 2023 10:49:45 +0000 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 1 + docs/guides/changelog.md | 1 + templates/guides/changelog.md.tmpl | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65de5556..d93ce00e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Add `sdwan_system_banner_profile_parcel` resource and data source - Add `sdwan_system_bfd_profile_parcel` resource and data source - BREAKING CHANGE: convert `protocol`, `source_port`, `destination_port` attribute of `sdwan_traffic_data_policy_definition` to Strings to support multiple values +- Fix issue with `sdwan_traffic_data_policy_definition` not supporting local and restrict options ## 0.2.11 diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 0315e923..32d1419f 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -17,6 +17,7 @@ description: |- - Add `sdwan_system_banner_profile_parcel` resource and data source - Add `sdwan_system_bfd_profile_parcel` resource and data source - BREAKING CHANGE: convert `protocol`, `source_port`, `destination_port` attribute of `sdwan_traffic_data_policy_definition` to Strings to support multiple values +- Fix issue with `sdwan_traffic_data_policy_definition` not supporting local and restrict options ## 0.2.11 diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 0315e923..32d1419f 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -17,6 +17,7 @@ description: |- - Add `sdwan_system_banner_profile_parcel` resource and data source - Add `sdwan_system_bfd_profile_parcel` resource and data source - BREAKING CHANGE: convert `protocol`, `source_port`, `destination_port` attribute of `sdwan_traffic_data_policy_definition` to Strings to support multiple values +- Fix issue with `sdwan_traffic_data_policy_definition` not supporting local and restrict options ## 0.2.11 From 7620614f12787f55a83eb3d3ae125bf6c987753f Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Thu, 14 Dec 2023 11:13:03 +0000 Subject: [PATCH 4/4] Fix failing test issue --- .../generic/traffic_data_policy_definition.yaml | 11 +++++++++++ ...ource_sdwan_traffic_data_policy_definition_test.go | 11 +++++++++-- ...ource_sdwan_traffic_data_policy_definition_test.go | 11 +++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/gen/definitions/generic/traffic_data_policy_definition.yaml b/gen/definitions/generic/traffic_data_policy_definition.yaml index 90e122ec..1ea7876e 100644 --- a/gen/definitions/generic/traffic_data_policy_definition.yaml +++ b/gen/definitions/generic/traffic_data_policy_definition.yaml @@ -107,6 +107,7 @@ attributes: type: String description: Application list ID example: e3aad846-abb9-425f-aaa8-9ed17b9c8d7c + test_value: sdwan_application_list_policy_object.test.id - tf_name: application_list_version tf_only: true type: Version @@ -783,3 +784,13 @@ attributes: description: Fallback example: true exclude_test: true + +test_prerequisites: | + resource "sdwan_application_list_policy_object" "test" { + name = "TF_TEST" + entries = [ + { + application = "netflix" + } + ] + } diff --git a/internal/provider/data_source_sdwan_traffic_data_policy_definition_test.go b/internal/provider/data_source_sdwan_traffic_data_policy_definition_test.go index f5992d07..56ef13a4 100644 --- a/internal/provider/data_source_sdwan_traffic_data_policy_definition_test.go +++ b/internal/provider/data_source_sdwan_traffic_data_policy_definition_test.go @@ -42,7 +42,6 @@ func TestAccDataSourceSdwanTrafficDataPolicyDefinition(t *testing.T) { resource.TestCheckResourceAttr("data.sdwan_traffic_data_policy_definition.test", "sequences.0.ip_type", "ipv4"), resource.TestCheckResourceAttr("data.sdwan_traffic_data_policy_definition.test", "sequences.0.base_action", "accept"), resource.TestCheckResourceAttr("data.sdwan_traffic_data_policy_definition.test", "sequences.0.match_entries.0.type", "appList"), - resource.TestCheckResourceAttr("data.sdwan_traffic_data_policy_definition.test", "sequences.0.match_entries.0.application_list_id", "e3aad846-abb9-425f-aaa8-9ed17b9c8d7c"), resource.TestCheckResourceAttr("data.sdwan_traffic_data_policy_definition.test", "sequences.0.action_entries.0.type", "log"), resource.TestCheckResourceAttr("data.sdwan_traffic_data_policy_definition.test", "sequences.0.action_entries.0.log", "true"), ), @@ -52,6 +51,14 @@ func TestAccDataSourceSdwanTrafficDataPolicyDefinition(t *testing.T) { } const testAccDataSourceSdwanTrafficDataPolicyDefinitionConfig = ` +resource "sdwan_application_list_policy_object" "test" { + name = "TF_TEST" + entries = [ + { + application = "netflix" + } + ] +} resource "sdwan_traffic_data_policy_definition" "test" { name = "Example" @@ -65,7 +72,7 @@ resource "sdwan_traffic_data_policy_definition" "test" { base_action = "accept" match_entries = [{ type = "appList" - application_list_id = "e3aad846-abb9-425f-aaa8-9ed17b9c8d7c" + application_list_id = sdwan_application_list_policy_object.test.id }] action_entries = [{ type = "log" diff --git a/internal/provider/resource_sdwan_traffic_data_policy_definition_test.go b/internal/provider/resource_sdwan_traffic_data_policy_definition_test.go index 838aba89..077e8184 100644 --- a/internal/provider/resource_sdwan_traffic_data_policy_definition_test.go +++ b/internal/provider/resource_sdwan_traffic_data_policy_definition_test.go @@ -42,7 +42,6 @@ func TestAccSdwanTrafficDataPolicyDefinition(t *testing.T) { resource.TestCheckResourceAttr("sdwan_traffic_data_policy_definition.test", "sequences.0.ip_type", "ipv4"), resource.TestCheckResourceAttr("sdwan_traffic_data_policy_definition.test", "sequences.0.base_action", "accept"), resource.TestCheckResourceAttr("sdwan_traffic_data_policy_definition.test", "sequences.0.match_entries.0.type", "appList"), - resource.TestCheckResourceAttr("sdwan_traffic_data_policy_definition.test", "sequences.0.match_entries.0.application_list_id", "e3aad846-abb9-425f-aaa8-9ed17b9c8d7c"), resource.TestCheckResourceAttr("sdwan_traffic_data_policy_definition.test", "sequences.0.action_entries.0.type", "log"), resource.TestCheckResourceAttr("sdwan_traffic_data_policy_definition.test", "sequences.0.action_entries.0.log", "true"), ), @@ -52,6 +51,14 @@ func TestAccSdwanTrafficDataPolicyDefinition(t *testing.T) { } const testAccSdwanTrafficDataPolicyDefinitionConfig = ` +resource "sdwan_application_list_policy_object" "test" { + name = "TF_TEST" + entries = [ + { + application = "netflix" + } + ] +} resource "sdwan_traffic_data_policy_definition" "test" { @@ -66,7 +73,7 @@ resource "sdwan_traffic_data_policy_definition" "test" { base_action = "accept" match_entries = [{ type = "appList" - application_list_id = "e3aad846-abb9-425f-aaa8-9ed17b9c8d7c" + application_list_id = sdwan_application_list_policy_object.test.id }] action_entries = [{ type = "log"