Skip to content

Commit

Permalink
Resolve Issue #288 and #292 (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
seconroy authored Aug 7, 2024
1 parent 2588aaf commit 9875d4a
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/data-sources/traffic_data_policy_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Read-Only:
- `log` (Boolean) Enable logging
- `loss_correction` (String) Loss correction
- `loss_correction_fec` (String) Loss correction FEC
- `loss_correction_fec_threshold` (Number) Loss correction FEC threshold
- `loss_correction_fec_threshold` (String) Loss correction FEC threshold
- `loss_correction_packet_duplication` (String) Loss correction packet duplication
- `nat_parameters` (Attributes List) List of NAT parameters (see [below for nested schema](#nestedatt--sequences--action_entries--nat_parameters))
- `nat_pool` (String) NAT pool
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/feature_device_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Required:

- `id` (String) Feature template ID
- `type` (String) Feature template type
- Choices: `cisco_system`, `cisco_logging`, `cedge_aaa`, `cisco_bfd`, `cisco_omp`, `cisco_security`, `cisco_banner`, `cisco_snmp`, `cedge_global`, `cli-template`, `cisco_sig_credentials`, `switchport`, `cisco_thousandeyes`, `cisco_vpn`
- Choices: `cisco_system`, `cisco_logging`, `cedge_aaa`, `cisco_bfd`, `cisco_omp`, `cisco_security`, `cisco_banner`, `cisco_snmp`, `cedge_global`, `cli-template`, `cisco_sig_credentials`, `switchport`, `cisco_thousandeyes`, `cisco_vpn`, `virtual-application-utd`

Optional:

Expand Down
3 changes: 1 addition & 2 deletions docs/resources/traffic_data_policy_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ Optional:
- Choices: `fecAdaptive`, `fecAlways`, `packetDuplication`
- `loss_correction_fec` (String) Loss correction FEC
- Choices: `fecAdaptive`, `fecAlways`, `packetDuplication`
- `loss_correction_fec_threshold` (Number) Loss correction FEC threshold
- Range: `1`-`5`
- `loss_correction_fec_threshold` (String) Loss correction FEC threshold
- `loss_correction_packet_duplication` (String) Loss correction packet duplication
- Choices: `fecAdaptive`, `fecAlways`, `packetDuplication`
- `nat_parameters` (Attributes List) List of NAT parameters (see [below for nested schema](#nestedatt--sequences--action_entries--nat_parameters))
Expand Down
2 changes: 1 addition & 1 deletion gen/definitions/generic/feature_device_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ attributes:
tf_name: type
type: String
mandatory: true
enum_values: [cisco_system, cisco_logging, cedge_aaa, cisco_bfd, cisco_omp, cisco_security, cisco_banner, cisco_snmp, cedge_global, cli-template, cisco_sig_credentials, switchport, cisco_thousandeyes, cisco_vpn]
enum_values: [cisco_system, cisco_logging, cedge_aaa, cisco_bfd, cisco_omp, cisco_security, cisco_banner, cisco_snmp, cedge_global, cli-template, cisco_sig_credentials, switchport, cisco_thousandeyes, cisco_vpn, virtual-application-utd]
ignore_enum: true
description: Feature template type
example: cisco_system
Expand Down
4 changes: 1 addition & 3 deletions gen/definitions/generic/traffic_data_policy_definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,8 @@ attributes:
conditional_attribute:
name: type
value: lossProtectFec
type: Int64
type: String
description: Loss correction FEC threshold
min_int: 1
max_int: 5
example: 2
exclude_test: true
- model_name: field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (d *TrafficDataPolicyDefinitionDataSource) Schema(ctx context.Context, req
MarkdownDescription: "Loss correction packet duplication",
Computed: true,
},
"loss_correction_fec_threshold": schema.Int64Attribute{
"loss_correction_fec_threshold": schema.StringAttribute{
MarkdownDescription: "Loss correction FEC threshold",
Computed: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type TrafficDataPolicyDefinitionSequencesActionEntries struct {
LossCorrection types.String `tfsdk:"loss_correction"`
LossCorrectionFec types.String `tfsdk:"loss_correction_fec"`
LossCorrectionPacketDuplication types.String `tfsdk:"loss_correction_packet_duplication"`
LossCorrectionFecThreshold types.Int64 `tfsdk:"loss_correction_fec_threshold"`
LossCorrectionFecThreshold types.String `tfsdk:"loss_correction_fec_threshold"`
NatPool types.String `tfsdk:"nat_pool"`
NatPoolId types.Int64 `tfsdk:"nat_pool_id"`
RedirectDns types.String `tfsdk:"redirect_dns"`
Expand Down Expand Up @@ -272,7 +272,7 @@ func (data TrafficDataPolicyDefinition) toBody(ctx context.Context) string {
itemChildBody, _ = sjson.Set(itemChildBody, "parameter", childItem.LossCorrectionPacketDuplication.ValueString())
}
if !childItem.LossCorrectionFecThreshold.IsNull() && childItem.Type.ValueString() == "lossProtectFec" {
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.LossCorrectionFecThreshold.ValueInt64())
itemChildBody, _ = sjson.Set(itemChildBody, "value", childItem.LossCorrectionFecThreshold.ValueString())
}
if !childItem.NatPool.IsNull() && childItem.Type.ValueString() == "nat" {
itemChildBody, _ = sjson.Set(itemChildBody, "parameter.field", childItem.NatPool.ValueString())
Expand Down Expand Up @@ -621,9 +621,9 @@ func (data *TrafficDataPolicyDefinition) fromBody(ctx context.Context, res gjson
cItem.LossCorrectionPacketDuplication = types.StringNull()
}
if ccValue := cv.Get("value"); ccValue.Exists() && cItem.Type.ValueString() == "lossProtectFec" {
cItem.LossCorrectionFecThreshold = types.Int64Value(ccValue.Int())
cItem.LossCorrectionFecThreshold = types.StringValue(ccValue.String())
} else {
cItem.LossCorrectionFecThreshold = types.Int64Null()
cItem.LossCorrectionFecThreshold = types.StringNull()
}
if ccValue := cv.Get("parameter.field"); ccValue.Exists() && cItem.Type.ValueString() == "nat" {
cItem.NatPool = types.StringValue(ccValue.String())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (r *FeatureDeviceTemplateResource) Schema(ctx context.Context, req resource
Optional: true,
},
"type": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Feature template type").AddStringEnumDescription("cisco_system", "cisco_logging", "cedge_aaa", "cisco_bfd", "cisco_omp", "cisco_security", "cisco_banner", "cisco_snmp", "cedge_global", "cli-template", "cisco_sig_credentials", "switchport", "cisco_thousandeyes", "cisco_vpn").String,
MarkdownDescription: helpers.NewAttributeDescription("Feature template type").AddStringEnumDescription("cisco_system", "cisco_logging", "cedge_aaa", "cisco_bfd", "cisco_omp", "cisco_security", "cisco_banner", "cisco_snmp", "cedge_global", "cli-template", "cisco_sig_credentials", "switchport", "cisco_thousandeyes", "cisco_vpn", "virtual-application-utd").String,
Required: true,
},
"sub_templates": schema.SetNestedAttribute{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,9 @@ func (r *TrafficDataPolicyDefinitionResource) Schema(ctx context.Context, req re
stringvalidator.OneOf("fecAdaptive", "fecAlways", "packetDuplication"),
},
},
"loss_correction_fec_threshold": schema.Int64Attribute{
MarkdownDescription: helpers.NewAttributeDescription("Loss correction FEC threshold").AddIntegerRangeDescription(1, 5).String,
"loss_correction_fec_threshold": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Loss correction FEC threshold").String,
Optional: true,
Validators: []validator.Int64{
int64validator.Between(1, 5),
},
},
"nat_pool": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("NAT pool").AddStringEnumDescription("pool").String,
Expand Down

0 comments on commit 9875d4a

Please sign in to comment.