Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
seconroy authored Sep 5, 2024
1 parent 520f341 commit 4528943
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Read-Only:
- `dns_application_list_id` (String) DNS Application list ID
- `dns_application_list_version` (Number) DNS Application list version
- `dscp` (Number) DSCP value
- `icmp_message` (String) ICMP Message
- `plp` (String) PLP
- `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
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/ipv4_acl_policy_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Read-Only:
- `destination_ip` (String) Destination IP prefix
- `destination_ports` (String) Destination ports. Single value (0-65535) or ranges separated by spaces.
- `dscp` (Number) DSCP value
- `icmp_message` (String) ICMP Message
- `packet_length` (Number) Packet length
- `priority` (String) PLP - priority
- `protocol` (String) Single value (0-255) or multiple values separated by spaces
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/traffic_data_policy_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Read-Only:
- `dns_application_list_id` (String) DNS Application list ID
- `dns_application_list_version` (Number) DNS Application list version
- `dscp` (Number) DSCP value
- `icmp_message` (String) ICMP Message
- `packet_length` (Number) Packet length
- `plp` (String) PLP
- `protocol` (String) IP Protocol, 0-255 (Single value or multiple values separated by spaces)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Optional:
Required:

- `type` (String) Type of match entry
- Choices: `appList`, `dnsAppList`, `dns`, `dscp`, `plp`, `protocol`, `sourceDataPrefixList`, `sourceIp`, `sourcePort`, `destinationDataPrefixList`, `destinationIp`, `destinationRegion`, `destinationPort`, `trafficTo`
- Choices: `appList`, `dnsAppList`, `dns`, `dscp`, `plp`, `protocol`, `sourceDataPrefixList`, `sourceIp`, `sourcePort`, `destinationDataPrefixList`, `destinationIp`, `destinationRegion`, `destinationPort`, `trafficTo`, `icmpMessage`

Optional:

Expand All @@ -126,6 +126,7 @@ Optional:
- `dns_application_list_version` (Number) DNS Application list version
- `dscp` (Number) DSCP value
- Range: `0`-`63`
- `icmp_message` (String) ICMP Message
- `plp` (String) PLP
- Choices: `low`, `high`
- `protocol` (String) IP Protocol, 0-255 (Single value or multiple values separated by spaces)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ resource "sdwan_custom_control_topology_policy_definition" "example" {

- `description` (String) The description of the policy definition
- `name` (String) The name of the policy definition
- `sequences` (Attributes List) List of sequences (see [below for nested schema](#nestedatt--sequences))

### Optional

- `default_action` (String) Default action, either `accept` or `reject`
- Choices: `accept`, `reject`
- `sequences` (Attributes List) List of sequences (see [below for nested schema](#nestedatt--sequences))

### Read-Only

Expand Down
3 changes: 2 additions & 1 deletion docs/resources/ipv4_acl_policy_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Optional:
Required:

- `type` (String) Type of match entry
- Choices: `dscp`, `sourceIp`, `destinationIp`, `class`, `packetLength`, `plp`, `sourcePort`, `destinationPort`, `sourceDataPrefixList`, `destinationDataPrefixList`, `protocol`, `tcp`
- Choices: `dscp`, `sourceIp`, `destinationIp`, `class`, `packetLength`, `plp`, `sourcePort`, `destinationPort`, `sourceDataPrefixList`, `destinationDataPrefixList`, `protocol`, `tcp`, `icmpMessage`

Optional:

Expand All @@ -134,6 +134,7 @@ Optional:
- `destination_ports` (String) Destination ports. Single value (0-65535) or ranges separated by spaces.
- `dscp` (Number) DSCP value
- Range: `0`-`63`
- `icmp_message` (String) ICMP Message
- `packet_length` (Number) Packet length
- Range: `0`-`65535`
- `priority` (String) PLP - priority
Expand Down
3 changes: 2 additions & 1 deletion docs/resources/traffic_data_policy_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Optional:
Required:

- `type` (String) Type of match entry
- Choices: `appList`, `dnsAppList`, `dns`, `dscp`, `packetLength`, `plp`, `protocol`, `sourceDataPrefixList`, `sourceIp`, `sourcePort`, `destinationDataPrefixList`, `destinationIp`, `destinationRegion`, `destinationPort`, `tcp`, `trafficTo`
- Choices: `appList`, `dnsAppList`, `dns`, `dscp`, `packetLength`, `plp`, `protocol`, `sourceDataPrefixList`, `sourceIp`, `sourcePort`, `destinationDataPrefixList`, `destinationIp`, `destinationRegion`, `destinationPort`, `tcp`, `trafficTo`, `icmpMessage`

Optional:

Expand All @@ -201,6 +201,7 @@ Optional:
- `dns_application_list_version` (Number) DNS Application list version
- `dscp` (Number) DSCP value
- Range: `0`-`63`
- `icmp_message` (String) ICMP Message
- `packet_length` (Number) Packet length
- Range: `0`-`65535`
- `plp` (String) PLP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ attributes:
destinationRegion,
destinationPort,
trafficTo,
icmpMessage
]
description: Type of match entry
example: appList
Expand Down Expand Up @@ -108,6 +109,15 @@ attributes:
type: Version
description: DNS Application list version
exclude_test: true
- model_name: value
tf_name: icmp_message
conditional_attribute:
name: type
value: icmpMessage
type: String
description: ICMP Message
exclude_test: true
example: "echo echo-reply"
- model_name: value
tf_name: dns
conditional_attribute:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ attributes:
- model_name: sequences
tf_name: sequences
type: List
mandatory: true
description: List of sequences
attributes:
- model_name: sequenceId
Expand Down
10 changes: 10 additions & 0 deletions gen/definitions/generic/ipv4_acl_policy_definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ attributes:
destinationDataPrefixList,
protocol,
tcp,
icmpMessage
]
description: Type of match entry
example: dscp
Expand All @@ -107,6 +108,15 @@ attributes:
description: Source IP prefix
exclude_test: true
example: 10.0.0.0/8
- model_name: value
tf_name: icmp_message
conditional_attribute:
name: type
value: icmpMessage
type: String
description: ICMP Message
exclude_test: true
example: "echo echo-reply"
- model_name: value
tf_name: destination_ip
conditional_attribute:
Expand Down
10 changes: 10 additions & 0 deletions gen/definitions/generic/traffic_data_policy_definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ attributes:
destinationPort,
tcp,
trafficTo,
icmpMessage,
]
description: Type of match entry
example: appList
Expand Down Expand Up @@ -128,6 +129,15 @@ attributes:
type: Version
description: DNS Application list version
exclude_test: true
- model_name: value
tf_name: icmp_message
conditional_attribute:
name: type
value: icmpMessage
type: String
description: ICMP Message
exclude_test: true
example: "echo echo-reply"
- model_name: value
tf_name: dns
conditional_attribute:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ func (d *ApplicationAwareRoutingPolicyDefinitionDataSource) Schema(ctx context.C
MarkdownDescription: "DNS Application list version",
Computed: true,
},
"icmp_message": schema.StringAttribute{
MarkdownDescription: "ICMP Message",
Computed: true,
},
"dns": schema.StringAttribute{
MarkdownDescription: "DNS request or response",
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func (d *IPv4ACLPolicyDefinitionDataSource) Schema(ctx context.Context, req data
MarkdownDescription: "Source IP prefix",
Computed: true,
},
"icmp_message": schema.StringAttribute{
MarkdownDescription: "ICMP Message",
Computed: true,
},
"destination_ip": schema.StringAttribute{
MarkdownDescription: "Destination IP prefix",
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func (d *TrafficDataPolicyDefinitionDataSource) Schema(ctx context.Context, req
MarkdownDescription: "DNS Application list version",
Computed: true,
},
"icmp_message": schema.StringAttribute{
MarkdownDescription: "ICMP Message",
Computed: true,
},
"dns": schema.StringAttribute{
MarkdownDescription: "DNS request or response",
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type ApplicationAwareRoutingPolicyDefinitionSequencesMatchEntries struct {
ApplicationListVersion types.Int64 `tfsdk:"application_list_version"`
DnsApplicationListId types.String `tfsdk:"dns_application_list_id"`
DnsApplicationListVersion types.Int64 `tfsdk:"dns_application_list_version"`
IcmpMessage types.String `tfsdk:"icmp_message"`
Dns types.String `tfsdk:"dns"`
Dscp types.Int64 `tfsdk:"dscp"`
Plp types.String `tfsdk:"plp"`
Expand Down Expand Up @@ -136,6 +137,9 @@ func (data ApplicationAwareRoutingPolicyDefinition) toBody(ctx context.Context)
if !childItem.DnsApplicationListId.IsNull() && childItem.Type.ValueString() == "dnsAppList" {
itemChildBody, _ = sjson.Set(itemChildBody, "ref", childItem.DnsApplicationListId.ValueString())
}
if !childItem.IcmpMessage.IsNull() && childItem.Type.ValueString() == "icmpMessage" {
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.IcmpMessage.ValueString())
}
if !childItem.Dns.IsNull() && childItem.Type.ValueString() == "dns" {
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.Dns.ValueString())
}
Expand Down Expand Up @@ -279,6 +283,11 @@ func (data *ApplicationAwareRoutingPolicyDefinition) fromBody(ctx context.Contex
} else {
cItem.DnsApplicationListId = types.StringNull()
}
if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "icmpMessage" {
cItem.IcmpMessage = types.StringValue(ccValue.String())
} else {
cItem.IcmpMessage = types.StringNull()
}
if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "dns" {
cItem.Dns = types.StringValue(ccValue.String())
} else {
Expand Down Expand Up @@ -468,6 +477,9 @@ func (data *ApplicationAwareRoutingPolicyDefinition) hasChanges(ctx context.Cont
if !data.Sequences[i].MatchEntries[ii].DnsApplicationListId.Equal(state.Sequences[i].MatchEntries[ii].DnsApplicationListId) {
hasChanges = true
}
if !data.Sequences[i].MatchEntries[ii].IcmpMessage.Equal(state.Sequences[i].MatchEntries[ii].IcmpMessage) {
hasChanges = true
}
if !data.Sequences[i].MatchEntries[ii].Dns.Equal(state.Sequences[i].MatchEntries[ii].Dns) {
hasChanges = true
}
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/model_sdwan_ipv4_acl_policy_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type IPv4ACLPolicyDefinitionSequencesMatchEntries struct {
Type types.String `tfsdk:"type"`
Dscp types.Int64 `tfsdk:"dscp"`
SourceIp types.String `tfsdk:"source_ip"`
IcmpMessage types.String `tfsdk:"icmp_message"`
DestinationIp types.String `tfsdk:"destination_ip"`
ClassMapId types.String `tfsdk:"class_map_id"`
ClassMapVersion types.Int64 `tfsdk:"class_map_version"`
Expand Down Expand Up @@ -138,6 +139,9 @@ func (data IPv4ACLPolicyDefinition) toBody(ctx context.Context) string {
if !childItem.SourceIp.IsNull() && childItem.Type.ValueString() == "sourceIp" {
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.SourceIp.ValueString())
}
if !childItem.IcmpMessage.IsNull() && childItem.Type.ValueString() == "icmpMessage" {
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.IcmpMessage.ValueString())
}
if !childItem.DestinationIp.IsNull() && childItem.Type.ValueString() == "destinationIp" {
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.DestinationIp.ValueString())
}
Expand Down Expand Up @@ -278,6 +282,11 @@ func (data *IPv4ACLPolicyDefinition) fromBody(ctx context.Context, res gjson.Res
} else {
cItem.SourceIp = types.StringNull()
}
if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "icmpMessage" {
cItem.IcmpMessage = types.StringValue(ccValue.String())
} else {
cItem.IcmpMessage = types.StringNull()
}
if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "destinationIp" {
cItem.DestinationIp = types.StringValue(ccValue.String())
} else {
Expand Down Expand Up @@ -458,6 +467,9 @@ func (data *IPv4ACLPolicyDefinition) hasChanges(ctx context.Context, state *IPv4
if !data.Sequences[i].MatchEntries[ii].SourceIp.Equal(state.Sequences[i].MatchEntries[ii].SourceIp) {
hasChanges = true
}
if !data.Sequences[i].MatchEntries[ii].IcmpMessage.Equal(state.Sequences[i].MatchEntries[ii].IcmpMessage) {
hasChanges = true
}
if !data.Sequences[i].MatchEntries[ii].DestinationIp.Equal(state.Sequences[i].MatchEntries[ii].DestinationIp) {
hasChanges = true
}
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/model_sdwan_traffic_data_policy_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type TrafficDataPolicyDefinitionSequencesMatchEntries struct {
ApplicationListVersion types.Int64 `tfsdk:"application_list_version"`
DnsApplicationListId types.String `tfsdk:"dns_application_list_id"`
DnsApplicationListVersion types.Int64 `tfsdk:"dns_application_list_version"`
IcmpMessage types.String `tfsdk:"icmp_message"`
Dns types.String `tfsdk:"dns"`
Dscp types.Int64 `tfsdk:"dscp"`
PacketLength types.Int64 `tfsdk:"packet_length"`
Expand Down Expand Up @@ -187,6 +188,9 @@ func (data TrafficDataPolicyDefinition) toBody(ctx context.Context) string {
if !childItem.DnsApplicationListId.IsNull() && childItem.Type.ValueString() == "dnsAppList" {
itemChildBody, _ = sjson.Set(itemChildBody, "ref", childItem.DnsApplicationListId.ValueString())
}
if !childItem.IcmpMessage.IsNull() && childItem.Type.ValueString() == "icmpMessage" {
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.IcmpMessage.ValueString())
}
if !childItem.Dns.IsNull() && childItem.Type.ValueString() == "dns" {
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.Dns.ValueString())
}
Expand Down Expand Up @@ -485,6 +489,11 @@ func (data *TrafficDataPolicyDefinition) fromBody(ctx context.Context, res gjson
} else {
cItem.DnsApplicationListId = types.StringNull()
}
if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "icmpMessage" {
cItem.IcmpMessage = types.StringValue(ccValue.String())
} else {
cItem.IcmpMessage = types.StringNull()
}
if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "dns" {
cItem.Dns = types.StringValue(ccValue.String())
} else {
Expand Down Expand Up @@ -902,6 +911,9 @@ func (data *TrafficDataPolicyDefinition) hasChanges(ctx context.Context, state *
if !data.Sequences[i].MatchEntries[ii].DnsApplicationListId.Equal(state.Sequences[i].MatchEntries[ii].DnsApplicationListId) {
hasChanges = true
}
if !data.Sequences[i].MatchEntries[ii].IcmpMessage.Equal(state.Sequences[i].MatchEntries[ii].IcmpMessage) {
hasChanges = true
}
if !data.Sequences[i].MatchEntries[ii].Dns.Equal(state.Sequences[i].MatchEntries[ii].Dns) {
hasChanges = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ func (r *ApplicationAwareRoutingPolicyDefinitionResource) Schema(ctx context.Con
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"type": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Type of match entry").AddStringEnumDescription("appList", "dnsAppList", "dns", "dscp", "plp", "protocol", "sourceDataPrefixList", "sourceIp", "sourcePort", "destinationDataPrefixList", "destinationIp", "destinationRegion", "destinationPort", "trafficTo").String,
MarkdownDescription: helpers.NewAttributeDescription("Type of match entry").AddStringEnumDescription("appList", "dnsAppList", "dns", "dscp", "plp", "protocol", "sourceDataPrefixList", "sourceIp", "sourcePort", "destinationDataPrefixList", "destinationIp", "destinationRegion", "destinationPort", "trafficTo", "icmpMessage").String,
Required: true,
Validators: []validator.String{
stringvalidator.OneOf("appList", "dnsAppList", "dns", "dscp", "plp", "protocol", "sourceDataPrefixList", "sourceIp", "sourcePort", "destinationDataPrefixList", "destinationIp", "destinationRegion", "destinationPort", "trafficTo"),
stringvalidator.OneOf("appList", "dnsAppList", "dns", "dscp", "plp", "protocol", "sourceDataPrefixList", "sourceIp", "sourcePort", "destinationDataPrefixList", "destinationIp", "destinationRegion", "destinationPort", "trafficTo", "icmpMessage"),
},
},
"application_list_id": schema.StringAttribute{
Expand All @@ -140,6 +140,10 @@ func (r *ApplicationAwareRoutingPolicyDefinitionResource) Schema(ctx context.Con
MarkdownDescription: helpers.NewAttributeDescription("DNS Application list version").String,
Optional: true,
},
"icmp_message": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("ICMP Message").String,
Optional: true,
},
"dns": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("DNS request or response").AddStringEnumDescription("request", "response").String,
Optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (r *CustomControlTopologyPolicyDefinitionResource) Schema(ctx context.Conte
},
"sequences": schema.ListNestedAttribute{
MarkdownDescription: helpers.NewAttributeDescription("List of sequences").String,
Required: true,
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ func (r *IPv4ACLPolicyDefinitionResource) Schema(ctx context.Context, req resour
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"type": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Type of match entry").AddStringEnumDescription("dscp", "sourceIp", "destinationIp", "class", "packetLength", "plp", "sourcePort", "destinationPort", "sourceDataPrefixList", "destinationDataPrefixList", "protocol", "tcp").String,
MarkdownDescription: helpers.NewAttributeDescription("Type of match entry").AddStringEnumDescription("dscp", "sourceIp", "destinationIp", "class", "packetLength", "plp", "sourcePort", "destinationPort", "sourceDataPrefixList", "destinationDataPrefixList", "protocol", "tcp", "icmpMessage").String,
Required: true,
Validators: []validator.String{
stringvalidator.OneOf("dscp", "sourceIp", "destinationIp", "class", "packetLength", "plp", "sourcePort", "destinationPort", "sourceDataPrefixList", "destinationDataPrefixList", "protocol", "tcp"),
stringvalidator.OneOf("dscp", "sourceIp", "destinationIp", "class", "packetLength", "plp", "sourcePort", "destinationPort", "sourceDataPrefixList", "destinationDataPrefixList", "protocol", "tcp", "icmpMessage"),
},
},
"dscp": schema.Int64Attribute{
Expand All @@ -145,6 +145,10 @@ func (r *IPv4ACLPolicyDefinitionResource) Schema(ctx context.Context, req resour
MarkdownDescription: helpers.NewAttributeDescription("Source IP prefix").String,
Optional: true,
},
"icmp_message": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("ICMP Message").String,
Optional: true,
},
"destination_ip": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Destination IP prefix").String,
Optional: true,
Expand Down
Loading

0 comments on commit 4528943

Please sign in to comment.