diff --git a/CHANGELOG.md b/CHANGELOG.md index 367a920b..83f7a0de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Add `speed_nonegotiate` attribute to `iosxe_interface_ethernet` resource and data source - Add `service_policy_input` and `service_policy_output` attributes to `iosxe_interface_ethernet` resource and data source - Add `classes` and `description` attributes to `iosxe_policy_map` resource and data source +- Add `match_dscp` attribute to `iosxe_class_map` resource and data source ## 0.5.4 diff --git a/docs/data-sources/class_map.md b/docs/data-sources/class_map.md index 0abf3485..52ba0f6c 100644 --- a/docs/data-sources/class_map.md +++ b/docs/data-sources/class_map.md @@ -37,6 +37,7 @@ data "iosxe_class_map" "example" { - `match_authorization_status_authorized` (Boolean) authorized - `match_authorization_status_unauthorized` (Boolean) unauthorized - `match_authorizing_method_priority_greater_than` (List of Number) greater than +- `match_dscp` (List of String) Match DSCP in IP(v4) and IPv6 packets - `match_method_dot1x` (Boolean) dot1x - `match_method_mab` (Boolean) mab - `match_result_type_aaa_timeout` (Boolean) aaa timeout type diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 1daf1dd7..e1dacf25 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -13,6 +13,7 @@ description: |- - Add `speed_nonegotiate` attribute to `iosxe_interface_ethernet` resource and data source - Add `service_policy_input` and `service_policy_output` attributes to `iosxe_interface_ethernet` resource and data source - Add `classes` and `description` attributes to `iosxe_policy_map` resource and data source +- Add `match_dscp` attribute to `iosxe_class_map` resource and data source ## 0.5.4 diff --git a/docs/resources/class_map.md b/docs/resources/class_map.md index cffbc0aa..c163714f 100644 --- a/docs/resources/class_map.md +++ b/docs/resources/class_map.md @@ -52,6 +52,7 @@ resource "iosxe_class_map" "example" { - `match_authorization_status_authorized` (Boolean) authorized - `match_authorization_status_unauthorized` (Boolean) unauthorized - `match_authorizing_method_priority_greater_than` (List of Number) greater than +- `match_dscp` (List of String) Match DSCP in IP(v4) and IPv6 packets - `match_method_dot1x` (Boolean) dot1x - `match_method_mab` (Boolean) mab - `match_result_type_aaa_timeout` (Boolean) aaa timeout type diff --git a/gen/definitions/class_map.yaml b/gen/definitions/class_map.yaml index 0df9759c..17c55f02 100644 --- a/gen/definitions/class_map.yaml +++ b/gen/definitions/class_map.yaml @@ -41,6 +41,9 @@ attributes: example: true - yang_name: match/result-type/method/mab/authoritative example: true + - yang_name: match/dscp + example: 8 + exclude_test: true - yang_name: description example: My description exclude_test: true diff --git a/internal/provider/data_source_iosxe_class_map.go b/internal/provider/data_source_iosxe_class_map.go index 4d994ab5..1e1e9060 100644 --- a/internal/provider/data_source_iosxe_class_map.go +++ b/internal/provider/data_source_iosxe_class_map.go @@ -132,6 +132,11 @@ func (d *ClassMapDataSource) Schema(ctx context.Context, req datasource.SchemaRe MarkdownDescription: "failure type", Computed: true, }, + "match_dscp": schema.ListAttribute{ + MarkdownDescription: "Match DSCP in IP(v4) and IPv6 packets", + ElementType: types.StringType, + Computed: true, + }, "description": schema.StringAttribute{ MarkdownDescription: "Class-Map description", Computed: true, diff --git a/internal/provider/model_iosxe_class_map.go b/internal/provider/model_iosxe_class_map.go index 4b7d4b34..1b5d12c8 100644 --- a/internal/provider/model_iosxe_class_map.go +++ b/internal/provider/model_iosxe_class_map.go @@ -52,6 +52,7 @@ type ClassMap struct { MatchResultTypeMethodDot1xMethodTimeout types.Bool `tfsdk:"match_result_type_method_dot1x_method_timeout"` MatchMethodMab types.Bool `tfsdk:"match_method_mab"` MatchResultTypeMethodMabAuthoritative types.Bool `tfsdk:"match_result_type_method_mab_authoritative"` + MatchDscp types.List `tfsdk:"match_dscp"` Description types.String `tfsdk:"description"` } @@ -73,6 +74,7 @@ type ClassMapData struct { MatchResultTypeMethodDot1xMethodTimeout types.Bool `tfsdk:"match_result_type_method_dot1x_method_timeout"` MatchMethodMab types.Bool `tfsdk:"match_method_mab"` MatchResultTypeMethodMabAuthoritative types.Bool `tfsdk:"match_result_type_method_mab_authoritative"` + MatchDscp types.List `tfsdk:"match_dscp"` Description types.String `tfsdk:"description"` } type ClassMapMatchActivatedServiceTemplates struct { @@ -164,6 +166,11 @@ func (data ClassMap) toBody(ctx context.Context) string { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"match.result-type.method.mab.authoritative", map[string]string{}) } } + if !data.MatchDscp.IsNull() && !data.MatchDscp.IsUnknown() { + var values []string + data.MatchDscp.ElementsAs(ctx, &values, false) + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"match.dscp", values) + } if !data.Description.IsNull() && !data.Description.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"description", data.Description.ValueString()) } @@ -322,6 +329,11 @@ func (data *ClassMap) updateFromBody(ctx context.Context, res gjson.Result) { } else { data.MatchResultTypeMethodMabAuthoritative = types.BoolNull() } + if value := res.Get(prefix + "match.dscp"); value.Exists() && !data.MatchDscp.IsNull() { + data.MatchDscp = helpers.GetStringList(value.Array()) + } else { + data.MatchDscp = types.ListNull(types.StringType) + } if value := res.Get(prefix + "description"); value.Exists() && !data.Description.IsNull() { data.Description = types.StringValue(value.String()) } else { @@ -406,6 +418,11 @@ func (data *ClassMapData) fromBody(ctx context.Context, res gjson.Result) { } else { data.MatchResultTypeMethodMabAuthoritative = types.BoolValue(false) } + if value := res.Get(prefix + "match.dscp"); value.Exists() { + data.MatchDscp = helpers.GetStringList(value.Array()) + } else { + data.MatchDscp = types.ListNull(types.StringType) + } if value := res.Get(prefix + "description"); value.Exists() { data.Description = types.StringValue(value.String()) } @@ -495,6 +512,27 @@ func (data *ClassMap) getDeletedItems(ctx context.Context, state ClassMap) []str if !state.MatchResultTypeMethodMabAuthoritative.IsNull() && data.MatchResultTypeMethodMabAuthoritative.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/match/result-type/method/mab/authoritative", state.getPath())) } + if !state.MatchDscp.IsNull() { + if data.MatchDscp.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/match/dscp", state.getPath())) + } else { + var dataValues, stateValues []string + data.MatchDscp.ElementsAs(ctx, &dataValues, false) + state.MatchDscp.ElementsAs(ctx, &stateValues, false) + for _, v := range stateValues { + found := false + for _, vv := range dataValues { + if v == vv { + found = true + break + } + } + if !found { + deletedItems = append(deletedItems, fmt.Sprintf("%v/match/dscp=%v", state.getPath(), v)) + } + } + } + } if !state.Description.IsNull() && data.Description.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath())) } @@ -583,6 +621,9 @@ func (data *ClassMap) getDeletePaths(ctx context.Context) []string { if !data.MatchResultTypeMethodMabAuthoritative.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/match/result-type/method/mab/authoritative", data.getPath())) } + if !data.MatchDscp.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/match/dscp", data.getPath())) + } if !data.Description.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/description", data.getPath())) } diff --git a/internal/provider/resource_iosxe_class_map.go b/internal/provider/resource_iosxe_class_map.go index f65a9190..596f7a95 100644 --- a/internal/provider/resource_iosxe_class_map.go +++ b/internal/provider/resource_iosxe_class_map.go @@ -146,6 +146,11 @@ func (r *ClassMapResource) Schema(ctx context.Context, req resource.SchemaReques MarkdownDescription: helpers.NewAttributeDescription("failure type").String, Optional: true, }, + "match_dscp": schema.ListAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Match DSCP in IP(v4) and IPv6 packets").String, + ElementType: types.StringType, + Optional: true, + }, "description": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Class-Map description").String, Optional: true, diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 1daf1dd7..e1dacf25 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -13,6 +13,7 @@ description: |- - Add `speed_nonegotiate` attribute to `iosxe_interface_ethernet` resource and data source - Add `service_policy_input` and `service_policy_output` attributes to `iosxe_interface_ethernet` resource and data source - Add `classes` and `description` attributes to `iosxe_policy_map` resource and data source +- Add `match_dscp` attribute to `iosxe_class_map` resource and data source ## 0.5.4