From 36cb84d126e87d72a00633e97558bbaac4474eb7 Mon Sep 17 00:00:00 2001 From: akinross Date: Thu, 19 Dec 2024 10:14:40 +0100 Subject: [PATCH] [minor_change] Add resources and datasources to support qosDot1PClass and qosDscpClass and expose them in aci_custom_qos_policy resource and datasource as children --- docs/data-sources/custom_qos_policy.md | 32 + docs/data-sources/dot1p_classifier.md | 67 + docs/data-sources/dscp_to_priority_map.md | 67 + docs/resources/custom_qos_policy.md | 112 ++ docs/resources/dot1p_classifier.md | 147 ++ docs/resources/dscp_to_priority_map.md | 147 ++ .../aci_dot1p_classifier/data-source.tf | 6 + .../aci_dot1p_classifier/provider.tf | 14 + .../aci_dscp_to_priority_map/data-source.tf | 6 + .../aci_dscp_to_priority_map/provider.tf | 14 + .../resource-all-attributes.tf | 50 + .../aci_dot1p_classifier/provider.tf | 14 + .../resource-all-attributes.tf | 25 + .../aci_dot1p_classifier/resource.tf | 6 + .../aci_dscp_to_priority_map/provider.tf | 14 + .../resource-all-attributes.tf | 25 + .../aci_dscp_to_priority_map/resource.tf | 6 + gen/definitions/classes.yaml | 16 + gen/definitions/properties.yaml | 49 + gen/meta/qosDot1PClass.json | 1262 ++++++++++++++ gen/meta/qosDscpClass.json | 1458 +++++++++++++++++ gen/testvars/qosCustomPol.yaml | 102 ++ gen/testvars/qosDot1PClass.yaml | 68 + gen/testvars/qosDscpClass.yaml | 64 + internal/custom_types/qosDot1PClass_from.go | 161 ++ internal/custom_types/qosDot1PClass_prio.go | 159 ++ internal/custom_types/qosDot1PClass_target.go | 175 ++ .../custom_types/qosDot1PClass_targetCos.go | 161 ++ internal/custom_types/qosDot1PClass_to.go | 161 ++ internal/custom_types/qosDscpClass_from.go | 174 ++ internal/custom_types/qosDscpClass_prio.go | 159 ++ internal/custom_types/qosDscpClass_target.go | 175 ++ .../custom_types/qosDscpClass_targetCos.go | 161 ++ internal/custom_types/qosDscpClass_to.go | 174 ++ .../data_source_aci_custom_qos_policy.go | 163 ++ .../data_source_aci_dot1p_classifier.go | 183 +++ .../data_source_aci_dot1p_classifier_test.go | 58 + .../data_source_aci_dscp_to_priority_map.go | 183 +++ ...ta_source_aci_dscp_to_priority_map_test.go | 58 + internal/provider/provider.go | 4 + .../resource_aci_custom_qos_policy.go | 1034 +++++++++++- .../resource_aci_custom_qos_policy_test.go | 328 ++++ .../provider/resource_aci_dot1p_classifier.go | 810 +++++++++ .../resource_aci_dot1p_classifier_test.go | 378 +++++ .../resource_aci_dscp_to_priority_map.go | 810 +++++++++ .../resource_aci_dscp_to_priority_map_test.go | 378 +++++ 46 files changed, 9814 insertions(+), 4 deletions(-) create mode 100644 docs/data-sources/dot1p_classifier.md create mode 100644 docs/data-sources/dscp_to_priority_map.md create mode 100644 docs/resources/dot1p_classifier.md create mode 100644 docs/resources/dscp_to_priority_map.md create mode 100644 examples/data-sources/aci_dot1p_classifier/data-source.tf create mode 100644 examples/data-sources/aci_dot1p_classifier/provider.tf create mode 100644 examples/data-sources/aci_dscp_to_priority_map/data-source.tf create mode 100644 examples/data-sources/aci_dscp_to_priority_map/provider.tf create mode 100644 examples/resources/aci_dot1p_classifier/provider.tf create mode 100644 examples/resources/aci_dot1p_classifier/resource-all-attributes.tf create mode 100644 examples/resources/aci_dot1p_classifier/resource.tf create mode 100644 examples/resources/aci_dscp_to_priority_map/provider.tf create mode 100644 examples/resources/aci_dscp_to_priority_map/resource-all-attributes.tf create mode 100644 examples/resources/aci_dscp_to_priority_map/resource.tf create mode 100644 gen/meta/qosDot1PClass.json create mode 100644 gen/meta/qosDscpClass.json create mode 100644 gen/testvars/qosDot1PClass.yaml create mode 100644 gen/testvars/qosDscpClass.yaml create mode 100644 internal/custom_types/qosDot1PClass_from.go create mode 100644 internal/custom_types/qosDot1PClass_prio.go create mode 100644 internal/custom_types/qosDot1PClass_target.go create mode 100644 internal/custom_types/qosDot1PClass_targetCos.go create mode 100644 internal/custom_types/qosDot1PClass_to.go create mode 100644 internal/custom_types/qosDscpClass_from.go create mode 100644 internal/custom_types/qosDscpClass_prio.go create mode 100644 internal/custom_types/qosDscpClass_target.go create mode 100644 internal/custom_types/qosDscpClass_targetCos.go create mode 100644 internal/custom_types/qosDscpClass_to.go create mode 100644 internal/provider/data_source_aci_dot1p_classifier.go create mode 100644 internal/provider/data_source_aci_dot1p_classifier_test.go create mode 100644 internal/provider/data_source_aci_dscp_to_priority_map.go create mode 100644 internal/provider/data_source_aci_dscp_to_priority_map_test.go create mode 100644 internal/provider/resource_aci_dot1p_classifier.go create mode 100644 internal/provider/resource_aci_dot1p_classifier_test.go create mode 100644 internal/provider/resource_aci_dscp_to_priority_map.go create mode 100644 internal/provider/resource_aci_dscp_to_priority_map_test.go diff --git a/docs/data-sources/custom_qos_policy.md b/docs/data-sources/custom_qos_policy.md index 8b71feba5..71a8e1037 100644 --- a/docs/data-sources/custom_qos_policy.md +++ b/docs/data-sources/custom_qos_policy.md @@ -53,6 +53,38 @@ data "aci_custom_qos_policy" "example_tenant" { * `name_alias` (nameAlias) - (string) The name alias of the Custom Qos Policy object. * `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. * `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. +* `dot1p_classifiers` - (list) A list of Dot1p Classifiers (ACI object [qosDot1PClass](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosDot1PClass/overview)). + * `annotation` (annotation) - (string) The annotation of the Dot1p Classifier object. + * `description` (descr) - (string) The description of the Dot1p Classifier object. + * `from` (from) - (string) The Dot1p priority range starting value. + * `name` (name) - (string) The name of the Dot1p Classifier object. + * `name_alias` (nameAlias) - (string) The name alias of the Dot1p Classifier object. + * `priority` (prio) - (string) The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles. + * `target` (target) - (string) The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported. + * `target_cos` (targetCos) - (string) Target COS to be driven based on the range of input values of DSCP coming into the fabric. + * `to` (to) - (string) The Dot1p priority range ending value. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + * `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `dscp_to_priority_maps` - (list) A list of DSCP to Priority Maps (ACI object [qosDscpClass](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosDscpClass/overview)). + * `annotation` (annotation) - (string) The annotation of the DSCP to Priority Map object. + * `description` (descr) - (string) The description of the DSCP to Priority Map object. + * `from` (from) - (string) The DSCP range starting value. + * `name` (name) - (string) The name of the DSCP to Priority Map object. + * `name_alias` (nameAlias) - (string) The name alias of the DSCP to Priority Map object. + * `priority` (prio) - (string) The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles. + * `target` (target) - (string) The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported. + * `target_cos` (targetCos) - (string) Target COS to be driven based on the range of input values of DSCP coming into the fabric. + * `to` (to) - (string) The DSCP range ending value. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + * `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/dot1p_classifier.md b/docs/data-sources/dot1p_classifier.md new file mode 100644 index 000000000..fca35680a --- /dev/null +++ b/docs/data-sources/dot1p_classifier.md @@ -0,0 +1,67 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "Tenant Policies" +layout: "aci" +page_title: "ACI: aci_dot1p_classifier" +sidebar_current: "docs-aci-data-source-aci_dot1p_classifier" +description: |- + Data source for ACI Dot1p Classifier +--- + +# aci_dot1p_classifier # + +Data source for ACI Dot1p Classifier + +## API Information ## + +* Class: [qosDot1PClass](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosDot1PClass/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Format: `uni/tn-{name}/qoscustom-{name}/dot1P-{from}-{to}` + +## GUI Information ## + +* Location: `Tenants -> Policies -> Protocol -> Custom QoS -> Dot1p Classifiers` + +## Example Usage ## + +```hcl + +data "aci_dot1p_classifier" "example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + from = "1" + to = "2" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_custom_qos_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/custom_qos_policy) ([qosCustomPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosCustomPol/overview)) +* `from` (from) - (string) The Dot1p priority range starting value. + - Valid Values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `unspecified`. +* `to` (to) - (string) The Dot1p priority range ending value. + - Valid Values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `unspecified`. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Dot1p Classifier object. +* `annotation` (annotation) - (string) The annotation of the Dot1p Classifier object. +* `description` (descr) - (string) The description of the Dot1p Classifier object. +* `name` (name) - (string) The name of the Dot1p Classifier object. +* `name_alias` (nameAlias) - (string) The name alias of the Dot1p Classifier object. +* `priority` (prio) - (string) The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles. +* `target` (target) - (string) The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported. +* `target_cos` (targetCos) - (string) Target COS to be driven based on the range of input values of DSCP coming into the fabric. +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/dscp_to_priority_map.md b/docs/data-sources/dscp_to_priority_map.md new file mode 100644 index 000000000..d234c821b --- /dev/null +++ b/docs/data-sources/dscp_to_priority_map.md @@ -0,0 +1,67 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "Tenant Policies" +layout: "aci" +page_title: "ACI: aci_dscp_to_priority_map" +sidebar_current: "docs-aci-data-source-aci_dscp_to_priority_map" +description: |- + Data source for ACI DSCP to Priority Map +--- + +# aci_dscp_to_priority_map # + +Data source for ACI DSCP to Priority Map + +## API Information ## + +* Class: [qosDscpClass](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosDscpClass/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Format: `uni/tn-{name}/qoscustom-{name}/dcsp-{from}-{to}` + +## GUI Information ## + +* Location: `Tenants -> Policies -> Protocol -> Custom QoS -> DSCP to priority map` + +## Example Usage ## + +```hcl + +data "aci_dscp_to_priority_map" "example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + from = "AF11" + to = "AF22" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_custom_qos_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/custom_qos_policy) ([qosCustomPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosCustomPol/overview)) +* `from` (from) - (string) The DSCP range starting value. + - Valid Values: `AF11`, `AF12`, `AF13`, `AF21`, `AF22`, `AF23`, `AF31`, `AF32`, `AF33`, `AF41`, `AF42`, `AF43`, `CS0`, `CS1`, `CS2`, `CS3`, `CS4`, `CS5`, `CS6`, `CS7`, `EF`, `VA`. +* `to` (to) - (string) The DSCP range ending value. + - Valid Values: `AF11`, `AF12`, `AF13`, `AF21`, `AF22`, `AF23`, `AF31`, `AF32`, `AF33`, `AF41`, `AF42`, `AF43`, `CS0`, `CS1`, `CS2`, `CS3`, `CS4`, `CS5`, `CS6`, `CS7`, `EF`, `VA`. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the DSCP to Priority Map object. +* `annotation` (annotation) - (string) The annotation of the DSCP to Priority Map object. +* `description` (descr) - (string) The description of the DSCP to Priority Map object. +* `name` (name) - (string) The name of the DSCP to Priority Map object. +* `name_alias` (nameAlias) - (string) The name alias of the DSCP to Priority Map object. +* `priority` (prio) - (string) The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles. +* `target` (target) - (string) The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported. +* `target_cos` (targetCos) - (string) Target COS to be driven based on the range of input values of DSCP coming into the fabric. +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. diff --git a/docs/resources/custom_qos_policy.md b/docs/resources/custom_qos_policy.md index 6ef6c1ed2..0f3a6abe0 100644 --- a/docs/resources/custom_qos_policy.md +++ b/docs/resources/custom_qos_policy.md @@ -54,6 +54,56 @@ resource "aci_custom_qos_policy" "full_example_tenant" { name_alias = "name_alias_1" owner_key = "owner_key_1" owner_tag = "owner_tag_1" + dot1p_classifiers = [ + { + annotation = "annotation_1" + description = "description_1" + from = "0" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "0" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + ] + dscp_to_priority_maps = [ + { + annotation = "annotation_1" + description = "description_1" + from = "AF11" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "AF11" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + ] annotations = [ { key = "key_0" @@ -92,6 +142,68 @@ All examples for the Custom Qos Policy resource can be found in the [examples](h * `name_alias` (nameAlias) - (string) The name alias of the Custom Qos Policy object. * `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. * `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. +* `dot1p_classifiers` - (list) A list of Dot1p Classifiers (ACI object [qosDot1PClass](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosDot1PClass/overview)). Dot1p Classifiers can also be configured using a separate [aci_dot1p_classifier](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/dot1p_classifier) resource. + #### Required #### + + * `from` (from) - (string) The Dot1p priority range starting value. + * `to` (to) - (string) The Dot1p priority range ending value. + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Dot1p Classifier object. + - Default: `orchestrator:terraform` + * `description` (descr) - (string) The description of the Dot1p Classifier object. + * `name` (name) - (string) The name of the Dot1p Classifier object. + * `name_alias` (nameAlias) - (string) The name alias of the Dot1p Classifier object. + * `priority` (prio) - (string) The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles. + - Default: `unspecified` + - Valid Values: `level1`, `level2`, `level3`, `level4`, `level5`, `level6`, `unspecified`. + * `target` (target) - (string) The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported. + - Default: `unspecified` + - Valid Values: `AF11`, `AF12`, `AF13`, `AF21`, `AF22`, `AF23`, `AF31`, `AF32`, `AF33`, `AF41`, `AF42`, `AF43`, `CS0`, `CS1`, `CS2`, `CS3`, `CS4`, `CS5`, `CS6`, `CS7`, `EF`, `VA`, `unspecified`. + * `target_cos` (targetCos) - (string) Target COS to be driven based on the range of input values of DSCP coming into the fabric. + - Default: `unspecified` + - Valid Values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `unspecified`. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + * `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `dscp_to_priority_maps` - (list) A list of DSCP to Priority Maps (ACI object [qosDscpClass](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosDscpClass/overview)). DSCP to Priority Maps can also be configured using a separate [aci_dscp_to_priority_map](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/dscp_to_priority_map) resource. + #### Required #### + + * `from` (from) - (string) The DSCP range starting value. + * `to` (to) - (string) The DSCP range ending value. + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the DSCP to Priority Map object. + - Default: `orchestrator:terraform` + * `description` (descr) - (string) The description of the DSCP to Priority Map object. + * `name` (name) - (string) The name of the DSCP to Priority Map object. + * `name_alias` (nameAlias) - (string) The name alias of the DSCP to Priority Map object. + * `priority` (prio) - (string) The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles. + - Default: `unspecified` + - Valid Values: `level1`, `level2`, `level3`, `level4`, `level5`, `level6`, `unspecified`. + * `target` (target) - (string) The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported. + - Default: `unspecified` + - Valid Values: `AF11`, `AF12`, `AF13`, `AF21`, `AF22`, `AF23`, `AF31`, `AF32`, `AF33`, `AF41`, `AF42`, `AF43`, `CS0`, `CS1`, `CS2`, `CS3`, `CS4`, `CS5`, `CS6`, `CS7`, `EF`, `VA`, `unspecified`. + * `target_cos` (targetCos) - (string) Target COS to be driven based on the range of input values of DSCP coming into the fabric. + - Default: `unspecified` + - Valid Values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `unspecified`. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + * `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. #### Required #### diff --git a/docs/resources/dot1p_classifier.md b/docs/resources/dot1p_classifier.md new file mode 100644 index 000000000..52a8b8f8e --- /dev/null +++ b/docs/resources/dot1p_classifier.md @@ -0,0 +1,147 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "Tenant Policies" +layout: "aci" +page_title: "ACI: aci_dot1p_classifier" +sidebar_current: "docs-aci-resource-aci_dot1p_classifier" +description: |- + Manages ACI Dot1p Classifier +--- + +# aci_dot1p_classifier # + +Manages ACI Dot1p Classifier + + + +## API Information ## + +* Class: [qosDot1PClass](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosDot1PClass/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Format: `uni/tn-{name}/qoscustom-{name}/dot1P-{from}-{to}` + +## GUI Information ## + +* Location: `Tenants -> Policies -> Protocol -> Custom QoS -> Dot1p Classifiers` + +## Example Usage ## + +The configuration snippet below creates a Dot1p Classifier with only required attributes. + +```hcl + +resource "aci_dot1p_classifier" "example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + from = "1" + to = "2" +} + +``` +The configuration snippet below shows all possible attributes of the Dot1p Classifier. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_dot1p_classifier" "full_example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + annotation = "annotation" + description = "description_1" + from = "1" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "2" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Dot1p Classifier resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_dot1p_classifier) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_custom_qos_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/custom_qos_policy) ([qosCustomPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosCustomPol/overview)) +* `from` (from) - (string) The Dot1p priority range starting value. + - Valid Values: + * `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `unspecified`. + * Or a value in the range of `0` to `8`. +* `to` (to) - (string) The Dot1p priority range ending value. + - Valid Values: + * `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `unspecified`. + * Or a value in the range of `0` to `8`. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Dot1p Classifier object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Dot1p Classifier object. + - Default: `orchestrator:terraform` +* `description` (descr) - (string) The description of the Dot1p Classifier object. +* `name` (name) - (string) The name of the Dot1p Classifier object. +* `name_alias` (nameAlias) - (string) The name alias of the Dot1p Classifier object. +* `priority` (prio) - (string) The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles. + - Default: `unspecified` + - Valid Values: + * `level1`, `level2`, `level3`, `level4`, `level5`, `level6`, `unspecified`. + * Or a value in the range of `0` to `9`. +* `target` (target) - (string) The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported. + - Default: `unspecified` + - Valid Values: + * `AF11`, `AF12`, `AF13`, `AF21`, `AF22`, `AF23`, `AF31`, `AF32`, `AF33`, `AF41`, `AF42`, `AF43`, `CS0`, `CS1`, `CS2`, `CS3`, `CS4`, `CS5`, `CS6`, `CS7`, `EF`, `VA`, `unspecified`. + * Or a value in the range of `0` to `64`. +* `target_cos` (targetCos) - (string) Target COS to be driven based on the range of input values of DSCP coming into the fabric. + - Default: `unspecified` + - Valid Values: + * `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `unspecified`. + * Or a value in the range of `0` to `8`. +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +## Importing + +An existing Dot1p Classifier can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: + +``` +terraform import aci_dot1p_classifier.example_custom_qos_policy uni/tn-{name}/qoscustom-{name}/dot1P-{from}-{to} +``` + +Starting in Terraform version 1.5, an existing Dot1p Classifier can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/tn-{name}/qoscustom-{name}/dot1P-{from}-{to}" + to = aci_dot1p_classifier.example_custom_qos_policy +} +``` diff --git a/docs/resources/dscp_to_priority_map.md b/docs/resources/dscp_to_priority_map.md new file mode 100644 index 000000000..bf9db317a --- /dev/null +++ b/docs/resources/dscp_to_priority_map.md @@ -0,0 +1,147 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "Tenant Policies" +layout: "aci" +page_title: "ACI: aci_dscp_to_priority_map" +sidebar_current: "docs-aci-resource-aci_dscp_to_priority_map" +description: |- + Manages ACI DSCP to Priority Map +--- + +# aci_dscp_to_priority_map # + +Manages ACI DSCP to Priority Map + + + +## API Information ## + +* Class: [qosDscpClass](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosDscpClass/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Format: `uni/tn-{name}/qoscustom-{name}/dcsp-{from}-{to}` + +## GUI Information ## + +* Location: `Tenants -> Policies -> Protocol -> Custom QoS -> DSCP to priority map` + +## Example Usage ## + +The configuration snippet below creates a DSCP to Priority Map with only required attributes. + +```hcl + +resource "aci_dscp_to_priority_map" "example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + from = "AF11" + to = "AF22" +} + +``` +The configuration snippet below shows all possible attributes of the DSCP to Priority Map. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_dscp_to_priority_map" "full_example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + annotation = "annotation" + description = "description_1" + from = "AF11" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "AF22" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the DSCP to Priority Map resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_dscp_to_priority_map) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_custom_qos_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/custom_qos_policy) ([qosCustomPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/qosCustomPol/overview)) +* `from` (from) - (string) The DSCP range starting value. + - Valid Values: + * `AF11`, `AF12`, `AF13`, `AF21`, `AF22`, `AF23`, `AF31`, `AF32`, `AF33`, `AF41`, `AF42`, `AF43`, `CS0`, `CS1`, `CS2`, `CS3`, `CS4`, `CS5`, `CS6`, `CS7`, `EF`, `VA`. + * Or a value in the range of `0` to `63`. +* `to` (to) - (string) The DSCP range ending value. + - Valid Values: + * `AF11`, `AF12`, `AF13`, `AF21`, `AF22`, `AF23`, `AF31`, `AF32`, `AF33`, `AF41`, `AF42`, `AF43`, `CS0`, `CS1`, `CS2`, `CS3`, `CS4`, `CS5`, `CS6`, `CS7`, `EF`, `VA`. + * Or a value in the range of `0` to `63`. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the DSCP to Priority Map object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the DSCP to Priority Map object. + - Default: `orchestrator:terraform` +* `description` (descr) - (string) The description of the DSCP to Priority Map object. +* `name` (name) - (string) The name of the DSCP to Priority Map object. +* `name_alias` (nameAlias) - (string) The name alias of the DSCP to Priority Map object. +* `priority` (prio) - (string) The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles. + - Default: `unspecified` + - Valid Values: + * `level1`, `level2`, `level3`, `level4`, `level5`, `level6`, `unspecified`. + * Or a value in the range of `0` to `9`. +* `target` (target) - (string) The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported. + - Default: `unspecified` + - Valid Values: + * `AF11`, `AF12`, `AF13`, `AF21`, `AF22`, `AF23`, `AF31`, `AF32`, `AF33`, `AF41`, `AF42`, `AF43`, `CS0`, `CS1`, `CS2`, `CS3`, `CS4`, `CS5`, `CS6`, `CS7`, `EF`, `VA`, `unspecified`. + * Or a value in the range of `0` to `64`. +* `target_cos` (targetCos) - (string) Target COS to be driven based on the range of input values of DSCP coming into the fabric. + - Default: `unspecified` + - Valid Values: + * `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `unspecified`. + * Or a value in the range of `0` to `8`. +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +## Importing + +An existing DSCP to Priority Map can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: + +``` +terraform import aci_dscp_to_priority_map.example_custom_qos_policy uni/tn-{name}/qoscustom-{name}/dcsp-{from}-{to} +``` + +Starting in Terraform version 1.5, an existing DSCP to Priority Map can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/tn-{name}/qoscustom-{name}/dcsp-{from}-{to}" + to = aci_dscp_to_priority_map.example_custom_qos_policy +} +``` diff --git a/examples/data-sources/aci_dot1p_classifier/data-source.tf b/examples/data-sources/aci_dot1p_classifier/data-source.tf new file mode 100644 index 000000000..97fbcd37f --- /dev/null +++ b/examples/data-sources/aci_dot1p_classifier/data-source.tf @@ -0,0 +1,6 @@ + +data "aci_dot1p_classifier" "example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + from = "1" + to = "2" +} diff --git a/examples/data-sources/aci_dot1p_classifier/provider.tf b/examples/data-sources/aci_dot1p_classifier/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_dot1p_classifier/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/data-sources/aci_dscp_to_priority_map/data-source.tf b/examples/data-sources/aci_dscp_to_priority_map/data-source.tf new file mode 100644 index 000000000..9317437e0 --- /dev/null +++ b/examples/data-sources/aci_dscp_to_priority_map/data-source.tf @@ -0,0 +1,6 @@ + +data "aci_dscp_to_priority_map" "example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + from = "AF11" + to = "AF22" +} diff --git a/examples/data-sources/aci_dscp_to_priority_map/provider.tf b/examples/data-sources/aci_dscp_to_priority_map/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_dscp_to_priority_map/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_custom_qos_policy/resource-all-attributes.tf b/examples/resources/aci_custom_qos_policy/resource-all-attributes.tf index b819dcc73..0547c620a 100644 --- a/examples/resources/aci_custom_qos_policy/resource-all-attributes.tf +++ b/examples/resources/aci_custom_qos_policy/resource-all-attributes.tf @@ -7,6 +7,56 @@ resource "aci_custom_qos_policy" "full_example_tenant" { name_alias = "name_alias_1" owner_key = "owner_key_1" owner_tag = "owner_tag_1" + dot1p_classifiers = [ + { + annotation = "annotation_1" + description = "description_1" + from = "0" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "0" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + ] + dscp_to_priority_maps = [ + { + annotation = "annotation_1" + description = "description_1" + from = "AF11" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "AF11" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + ] annotations = [ { key = "key_0" diff --git a/examples/resources/aci_dot1p_classifier/provider.tf b/examples/resources/aci_dot1p_classifier/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_dot1p_classifier/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_dot1p_classifier/resource-all-attributes.tf b/examples/resources/aci_dot1p_classifier/resource-all-attributes.tf new file mode 100644 index 000000000..b37117e7c --- /dev/null +++ b/examples/resources/aci_dot1p_classifier/resource-all-attributes.tf @@ -0,0 +1,25 @@ + +resource "aci_dot1p_classifier" "full_example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + annotation = "annotation" + description = "description_1" + from = "1" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "2" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_dot1p_classifier/resource.tf b/examples/resources/aci_dot1p_classifier/resource.tf new file mode 100644 index 000000000..11d21f79f --- /dev/null +++ b/examples/resources/aci_dot1p_classifier/resource.tf @@ -0,0 +1,6 @@ + +resource "aci_dot1p_classifier" "example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + from = "1" + to = "2" +} diff --git a/examples/resources/aci_dscp_to_priority_map/provider.tf b/examples/resources/aci_dscp_to_priority_map/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_dscp_to_priority_map/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_dscp_to_priority_map/resource-all-attributes.tf b/examples/resources/aci_dscp_to_priority_map/resource-all-attributes.tf new file mode 100644 index 000000000..979990452 --- /dev/null +++ b/examples/resources/aci_dscp_to_priority_map/resource-all-attributes.tf @@ -0,0 +1,25 @@ + +resource "aci_dscp_to_priority_map" "full_example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + annotation = "annotation" + description = "description_1" + from = "AF11" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "AF22" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_dscp_to_priority_map/resource.tf b/examples/resources/aci_dscp_to_priority_map/resource.tf new file mode 100644 index 000000000..99a750f34 --- /dev/null +++ b/examples/resources/aci_dscp_to_priority_map/resource.tf @@ -0,0 +1,6 @@ + +resource "aci_dscp_to_priority_map" "example_custom_qos_policy" { + parent_dn = aci_custom_qos_policy.example.id + from = "AF11" + to = "AF22" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index 5fdf62b87..4dc055ad4 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -112,6 +112,22 @@ qosCustomPol: ui_locations: - "Tenants -> Policies -> Protocol -> Custom QoS" sub_category: "Tenant Policies" + children: + - "qosDscpClass" + - "qosDot1PClass" + +qosDscpClass: + resource_name: "dscp_to_priority_map" + ui_locations: + - "Tenants -> Policies -> Protocol -> Custom QoS -> DSCP to priority map" + sub_category: "Tenant Policies" + +qosDot1PClass: + resource_name: "dot1p_classifier" + ui_locations: + - "Tenants -> Policies -> Protocol -> Custom QoS -> Dot1p Classifiers" + sub_category: "Tenant Policies" + fhsTrustCtrlPol: ui_locations: diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index d2cce95c0..a1012cda1 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -68,6 +68,7 @@ global: Tp: "Certificate Authority" Http Ssl Configuration: "HTTPS Service" Http Service: "HTTP Service" + Dscp To: "DSCP to" ignores: - "userdom" @@ -925,6 +926,54 @@ qosCustomPol: - class_name: "fvTenant" parent_dn: "aci_tenant.test.id" +qosDscpClass: + parents: + - class_name: "qosCustomPol" + parent_dependency: "fvTenant" + parent_dn: "aci_custom_qos_policy.test.id" + documentation: + target: "The target of the %s object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported." + test_values: + default: + from: "AF11" + to: "AF22" + all: + from: "CS1" + to: "CS5" + resource_required: + from: "AF11" + to: "AF22" + datasource_required: + from: "AF11" + to: "AF22" + datasource_non_existing: + from: "AF31" + to: "AF42" + +qosDot1PClass: + parents: + - class_name: "qosCustomPol" + parent_dependency: "fvTenant" + parent_dn: "aci_custom_qos_policy.test.id" + documentation: + target: "The target of the %s object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported." + test_values: + default: + from: "1" + to: "2" + all: + from: "4" + to: "5" + resource_required: + from: "1" + to: "2" + datasource_required: + from: "1" + to: "2" + datasource_non_existing: + from: "6" + to: "7" + fhsTrustCtrlPol: default_values: hasDhcpv4Server: "no" diff --git a/gen/meta/qosDot1PClass.json b/gen/meta/qosDot1PClass.json new file mode 100644 index 000000000..4e79b6819 --- /dev/null +++ b/gen/meta/qosDot1PClass.json @@ -0,0 +1,1262 @@ +{ + "qos:Dot1PClass": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Delegate": "", + "qos:RtDefToDot1PClass": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "rbacDom-": "aaa:RbacAnnotation", + "rtDefToDot1PClass": "qos:RtDefToDot1PClass", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "from", + "to" + ], + "rnFormat": "dot1P-{from}-{to}", + "containedBy": { + "qos:CustomPol": "" + }, + "superClasses": [ + "qos:ADot1PClass", + "qos:Classification", + "pol:Comp", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "qos:RtDefToDot1PClass": "qos:Dot1PClassDef" + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/tn-{name}/qoscustom-{name}/dot1P-{from}-{to}" + ], + "writeAccess": [ + "admin", + "tenant-qos" + ], + "readAccess": [ + "admin", + "tenant-qos" + ], + "faults": { + + }, + "events": { + "E4213082": "creation||qos:Dot1PClass", + "E4213083": "modification||qos:Dot1PClass", + "E4213084": "deletion||qos:Dot1PClass" + }, + "stats": { + + }, + "versions": "1.0(1e)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": false, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": false, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + + ], + "classId": "150", + "className": "Dot1PClass", + "classPkg": "qos", + "featureTag": "", + "moCategory": "Regular", + "label": "Dot1P Class to Priority Mapping Policy", + "comment": [ + "The class level for dot1P to prioritize the map." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37284", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(1e)-", + "comment": [ + "Specifies the description of a policy component." + ], + "isConfigurable": true, + "propGlobalId": "5582", + "propLocalId": "28", + "label": "Description", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Described:descr", + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "39423", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "from": { + "versions": "1.0(1e)-", + "comment": [ + "The Dot1p priority range starting value." + ], + "isConfigurable": true, + "propGlobalId": "7084", + "propLocalId": "180", + "label": "from", + "baseType": "scalar:UByte", + "modelType": "qosp:Dot1P", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 8 } + ], + "validValues": [ + { "value": "0", "localName": "0", + "platformFlavors": [ + + ], + "comment": [ + "Background traffic" + ], + "label": "Background "}, + { "value": "1", "localName": "1", + "platformFlavors": [ + + ], + "comment": [ + "Best Effort traffic" + ], + "label": "Best Effort "}, + { "value": "2", "localName": "2", + "platformFlavors": [ + + ], + "comment": [ + "Excellent Effort traffic" + ], + "label": "Excellent Effort "}, + { "value": "3", "localName": "3", + "platformFlavors": [ + + ], + "comment": [ + "Critical Applications traffic" + ], + "label": "Critical Applications "}, + { "value": "4", "localName": "4", + "platformFlavors": [ + + ], + "comment": [ + "Video traffic" + ], + "label": "Video, < 100 ms latency and jitter "}, + { "value": "5", "localName": "5", + "platformFlavors": [ + + ], + "comment": [ + "Voice traffic" + ], + "label": "Voice, < 10 ms latency and jitter "}, + { "value": "6", "localName": "6", + "platformFlavors": [ + + ], + "comment": [ + "Internetwork Control traffic" + ], + "label": "Internetwork Control "}, + { "value": "7", "localName": "7", + "platformFlavors": [ + + ], + "comment": [ + "Network Control traffic" + ], + "label": "Network Control "}, + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "8", "localName": "unspecified", + "platformFlavors": [ + + ], + "comment": [ + "Class of traffic not specified, not a real COS value" + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "4991", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "prio": { + "versions": "1.0(1e)-", + "comment": [ + "Class id" + ], + "isConfigurable": true, + "propGlobalId": "277", + "propLocalId": "172", + "label": "prio", + "baseType": "scalar:Enum8", + "modelType": "qos:TenantPrio", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 9 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "3", "localName": "level1", + "platformFlavors": [ + + ], + "label": "Level1 "}, + { "value": "2", "localName": "level2", + "platformFlavors": [ + + ], + "label": "Level2 "}, + { "value": "1", "localName": "level3", + "platformFlavors": [ + + ], + "comment": [ + "User configurable classes" + ], + "label": "Level3 (Default) "}, + { "value": "9", "localName": "level4", + "platformFlavors": [ + + ], + "label": "Level4 "}, + { "value": "8", "localName": "level5", + "platformFlavors": [ + + ], + "label": "Level5 "}, + { "value": "7", "localName": "level6", + "platformFlavors": [ + + ], + "label": "Level6 "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "target": { + "versions": "1.0(1e)-", + "comment": [ + "Our Fabric only supports DSCP mutation. Dot1P mutation is not supported" + ], + "isConfigurable": true, + "propGlobalId": "271", + "propLocalId": "179", + "label": "target", + "baseType": "scalar:UByte", + "modelType": "qosp:Dscp", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64 } + ], + "validValues": [ + { "value": "10", "localName": "AF11", + "platformFlavors": [ + + ], + "comment": [ + "AF11 low drop" + ], + "label": "AF11 Low Drop "}, + { "value": "12", "localName": "AF12", + "platformFlavors": [ + + ], + "comment": [ + "AF12 medium drop" + ], + "label": "AF12 Medium Drop "}, + { "value": "14", "localName": "AF13", + "platformFlavors": [ + + ], + "comment": [ + "AF13 high drop" + ], + "label": "AF13 High Drop "}, + { "value": "18", "localName": "AF21", + "platformFlavors": [ + + ], + "comment": [ + "AF21 low drop" + ], + "label": "AF21 Low Drop "}, + { "value": "20", "localName": "AF22", + "platformFlavors": [ + + ], + "comment": [ + "AF22 medium drop" + ], + "label": "AF22 Medium Drop "}, + { "value": "22", "localName": "AF23", + "platformFlavors": [ + + ], + "comment": [ + "AF22 high drop" + ], + "label": "AF23 High Drop "}, + { "value": "26", "localName": "AF31", + "platformFlavors": [ + + ], + "comment": [ + "AF31 low drop" + ], + "label": "AF31 Low Drop "}, + { "value": "28", "localName": "AF32", + "platformFlavors": [ + + ], + "comment": [ + "AF32 medium drop" + ], + "label": "AF32 Medium Drop "}, + { "value": "30", "localName": "AF33", + "platformFlavors": [ + + ], + "comment": [ + "AF33 high drop" + ], + "label": "AF33 High Drop "}, + { "value": "34", "localName": "AF41", + "platformFlavors": [ + + ], + "comment": [ + "AF41 low drop" + ], + "label": "AF41 Low Drop "}, + { "value": "36", "localName": "AF42", + "platformFlavors": [ + + ], + "comment": [ + "AF42 medium drop" + ], + "label": "AF42 Medium Drop "}, + { "value": "38", "localName": "AF43", + "platformFlavors": [ + + ], + "comment": [ + "AF42 high drop" + ], + "label": "AF43 High Drop "}, + { "value": "0", "localName": "CS0", + "platformFlavors": [ + + ], + "comment": [ + "CS0" + ], + "label": "CS0 "}, + { "value": "8", "localName": "CS1", + "platformFlavors": [ + + ], + "comment": [ + "CS1" + ], + "label": "CS1 "}, + { "value": "16", "localName": "CS2", + "platformFlavors": [ + + ], + "comment": [ + "CS2" + ], + "label": "CS2 "}, + { "value": "24", "localName": "CS3", + "platformFlavors": [ + + ], + "comment": [ + "CS3" + ], + "label": "CS3 "}, + { "value": "32", "localName": "CS4", + "platformFlavors": [ + + ], + "comment": [ + "CS4" + ], + "label": "CS4 "}, + { "value": "40", "localName": "CS5", + "platformFlavors": [ + + ], + "comment": [ + "CS5" + ], + "label": "CS5 "}, + { "value": "48", "localName": "CS6", + "platformFlavors": [ + + ], + "comment": [ + "CS6" + ], + "label": "CS6 "}, + { "value": "56", "localName": "CS7", + "platformFlavors": [ + + ], + "comment": [ + "CS7" + ], + "label": "CS7 "}, + { "value": "46", "localName": "EF", + "platformFlavors": [ + + ], + "comment": [ + "EF" + ], + "label": "Expedited Forwarding "}, + { "value": "44", "localName": "VA", + "platformFlavors": [ + + ], + "comment": [ + "VA" + ], + "label": "Voice Admit "}, + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "64", "localName": "unspecified", + "platformFlavors": [ + + ], + "comment": [ + "Unspecified" + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "targetCos": { + "versions": "2.1(1h)-", + "comment": [ + "Target COS to be driven based on the range of input values of DSCP coming into the fabric" + ], + "isConfigurable": true, + "propGlobalId": "26215", + "propLocalId": "6214", + "label": "targetCos", + "baseType": "scalar:UByte", + "modelType": "qosp:Dot1P", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 8 } + ], + "validValues": [ + { "value": "0", "localName": "0", + "platformFlavors": [ + + ], + "comment": [ + "Background traffic" + ], + "label": "Background "}, + { "value": "1", "localName": "1", + "platformFlavors": [ + + ], + "comment": [ + "Best Effort traffic" + ], + "label": "Best Effort "}, + { "value": "2", "localName": "2", + "platformFlavors": [ + + ], + "comment": [ + "Excellent Effort traffic" + ], + "label": "Excellent Effort "}, + { "value": "3", "localName": "3", + "platformFlavors": [ + + ], + "comment": [ + "Critical Applications traffic" + ], + "label": "Critical Applications "}, + { "value": "4", "localName": "4", + "platformFlavors": [ + + ], + "comment": [ + "Video traffic" + ], + "label": "Video, < 100 ms latency and jitter "}, + { "value": "5", "localName": "5", + "platformFlavors": [ + + ], + "comment": [ + "Voice traffic" + ], + "label": "Voice, < 10 ms latency and jitter "}, + { "value": "6", "localName": "6", + "platformFlavors": [ + + ], + "comment": [ + "Internetwork Control traffic" + ], + "label": "Internetwork Control "}, + { "value": "7", "localName": "7", + "platformFlavors": [ + + ], + "comment": [ + "Network Control traffic" + ], + "label": "Network Control "}, + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "8", "localName": "unspecified", + "platformFlavors": [ + + ], + "comment": [ + "Class of traffic not specified, not a real COS value" + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "to": { + "versions": "1.0(1e)-", + "comment": [ + "The Dot1p priority range ending value." + ], + "isConfigurable": true, + "propGlobalId": "7083", + "propLocalId": "181", + "label": "to", + "baseType": "scalar:UByte", + "modelType": "qosp:Dot1P", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 8 } + ], + "validValues": [ + { "value": "0", "localName": "0", + "platformFlavors": [ + + ], + "comment": [ + "Background traffic" + ], + "label": "Background "}, + { "value": "1", "localName": "1", + "platformFlavors": [ + + ], + "comment": [ + "Best Effort traffic" + ], + "label": "Best Effort "}, + { "value": "2", "localName": "2", + "platformFlavors": [ + + ], + "comment": [ + "Excellent Effort traffic" + ], + "label": "Excellent Effort "}, + { "value": "3", "localName": "3", + "platformFlavors": [ + + ], + "comment": [ + "Critical Applications traffic" + ], + "label": "Critical Applications "}, + { "value": "4", "localName": "4", + "platformFlavors": [ + + ], + "comment": [ + "Video traffic" + ], + "label": "Video, < 100 ms latency and jitter "}, + { "value": "5", "localName": "5", + "platformFlavors": [ + + ], + "comment": [ + "Voice traffic" + ], + "label": "Voice, < 10 ms latency and jitter "}, + { "value": "6", "localName": "6", + "platformFlavors": [ + + ], + "comment": [ + "Internetwork Control traffic" + ], + "label": "Internetwork Control "}, + { "value": "7", "localName": "7", + "platformFlavors": [ + + ], + "comment": [ + "Network Control traffic" + ], + "label": "Network Control "}, + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "8", "localName": "unspecified", + "platformFlavors": [ + + ], + "comment": [ + "Class of traffic not specified, not a real COS value" + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/meta/qosDscpClass.json b/gen/meta/qosDscpClass.json new file mode 100644 index 000000000..4c59d8f14 --- /dev/null +++ b/gen/meta/qosDscpClass.json @@ -0,0 +1,1458 @@ +{ + "qos:DscpClass": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Delegate": "", + "qos:RtDefToDscpClass": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "rbacDom-": "aaa:RbacAnnotation", + "rtDefToDscpClass": "qos:RtDefToDscpClass", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "from", + "to" + ], + "rnFormat": "dcsp-{from}-{to}", + "containedBy": { + "qos:CustomPol": "" + }, + "superClasses": [ + "qos:ADscpClass", + "qos:Classification", + "pol:Comp", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "qos:RtDefToDscpClass": "qos:DscpClassDef" + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/tn-{name}/qoscustom-{name}/dcsp-{from}-{to}" + ], + "writeAccess": [ + "admin", + "tenant-qos" + ], + "readAccess": [ + "admin", + "tenant-qos" + ], + "faults": { + + }, + "events": { + "E4213085": "creation||qos:DscpClass", + "E4213086": "modification||qos:DscpClass", + "E4213087": "deletion||qos:DscpClass" + }, + "stats": { + + }, + "versions": "1.0(1e)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": false, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": false, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + + ], + "classId": "146", + "className": "DscpClass", + "classPkg": "qos", + "featureTag": "", + "moCategory": "Regular", + "label": "DSCP Class to Priority Mapping Policy", + "comment": [ + "The class level for DSCP to prioritize the map." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37283", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(1e)-", + "comment": [ + "Specifies the description of a policy component." + ], + "isConfigurable": true, + "propGlobalId": "5582", + "propLocalId": "28", + "label": "Description", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Described:descr", + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "39422", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "from": { + "versions": "1.0(1e)-", + "comment": [ + "The DSCP range starting value." + ], + "isConfigurable": true, + "propGlobalId": "7087", + "propLocalId": "180", + "label": "from", + "baseType": "scalar:UByte", + "modelType": "qosp:DscpCP", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63 } + ], + "validValues": [ + { "value": "10", "localName": "AF11", + "platformFlavors": [ + + ], + "comment": [ + "AF11 low drop" + ], + "label": "AF11 Low Drop "}, + { "value": "12", "localName": "AF12", + "platformFlavors": [ + + ], + "comment": [ + "AF12 medium drop" + ], + "label": "AF12 Medium Drop "}, + { "value": "14", "localName": "AF13", + "platformFlavors": [ + + ], + "comment": [ + "AF13 high drop" + ], + "label": "AF13 High Drop "}, + { "value": "18", "localName": "AF21", + "platformFlavors": [ + + ], + "comment": [ + "AF21 low drop" + ], + "label": "AF21 Low Drop "}, + { "value": "20", "localName": "AF22", + "platformFlavors": [ + + ], + "comment": [ + "AF22 medium drop" + ], + "label": "AF22 Medium Drop "}, + { "value": "22", "localName": "AF23", + "platformFlavors": [ + + ], + "comment": [ + "AF22 high drop" + ], + "label": "AF23 High Drop "}, + { "value": "26", "localName": "AF31", + "platformFlavors": [ + + ], + "comment": [ + "AF31 low drop" + ], + "label": "AF31 Low Drop "}, + { "value": "28", "localName": "AF32", + "platformFlavors": [ + + ], + "comment": [ + "AF32 medium drop" + ], + "label": "AF32 Medium Drop "}, + { "value": "30", "localName": "AF33", + "platformFlavors": [ + + ], + "comment": [ + "AF33 high drop" + ], + "label": "AF33 High Drop "}, + { "value": "34", "localName": "AF41", + "platformFlavors": [ + + ], + "comment": [ + "AF41 low drop" + ], + "label": "AF41 Low Drop "}, + { "value": "36", "localName": "AF42", + "platformFlavors": [ + + ], + "comment": [ + "AF42 medium drop" + ], + "label": "AF42 Medium Drop "}, + { "value": "38", "localName": "AF43", + "platformFlavors": [ + + ], + "comment": [ + "AF42 high drop" + ], + "label": "AF43 High Drop "}, + { "value": "0", "localName": "CS0", + "platformFlavors": [ + + ], + "comment": [ + "CS0" + ], + "label": "CS0 "}, + { "value": "8", "localName": "CS1", + "platformFlavors": [ + + ], + "comment": [ + "CS1" + ], + "label": "CS1 "}, + { "value": "16", "localName": "CS2", + "platformFlavors": [ + + ], + "comment": [ + "CS2" + ], + "label": "CS2 "}, + { "value": "24", "localName": "CS3", + "platformFlavors": [ + + ], + "comment": [ + "CS3" + ], + "label": "CS3 "}, + { "value": "32", "localName": "CS4", + "platformFlavors": [ + + ], + "comment": [ + "CS4" + ], + "label": "CS4 "}, + { "value": "40", "localName": "CS5", + "platformFlavors": [ + + ], + "comment": [ + "CS5" + ], + "label": "CS5 "}, + { "value": "48", "localName": "CS6", + "platformFlavors": [ + + ], + "comment": [ + "CS6" + ], + "label": "CS6 "}, + { "value": "56", "localName": "CS7", + "platformFlavors": [ + + ], + "comment": [ + "CS7" + ], + "label": "CS7 "}, + { "value": "46", "localName": "EF", + "platformFlavors": [ + + ], + "comment": [ + "EF" + ], + "label": "Expedited Forwarding "}, + { "value": "44", "localName": "VA", + "platformFlavors": [ + + ], + "comment": [ + "VA" + ], + "label": "Voice Admit "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "4991", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "prio": { + "versions": "1.0(1e)-", + "comment": [ + "Class id" + ], + "isConfigurable": true, + "propGlobalId": "274", + "propLocalId": "172", + "label": "prio", + "baseType": "scalar:Enum8", + "modelType": "qos:TenantPrio", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 9 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "3", "localName": "level1", + "platformFlavors": [ + + ], + "label": "Level1 "}, + { "value": "2", "localName": "level2", + "platformFlavors": [ + + ], + "label": "Level2 "}, + { "value": "1", "localName": "level3", + "platformFlavors": [ + + ], + "comment": [ + "User configurable classes" + ], + "label": "Level3 (Default) "}, + { "value": "9", "localName": "level4", + "platformFlavors": [ + + ], + "label": "Level4 "}, + { "value": "8", "localName": "level5", + "platformFlavors": [ + + ], + "label": "Level5 "}, + { "value": "7", "localName": "level6", + "platformFlavors": [ + + ], + "label": "Level6 "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "target": { + "versions": "1.0(1e)-", + "comment": [ + "Our Fabric only supports DSCP mutation. Dot1P mutation is not supported" + ], + "isConfigurable": true, + "propGlobalId": "271", + "propLocalId": "179", + "label": "target", + "baseType": "scalar:UByte", + "modelType": "qosp:Dscp", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64 } + ], + "validValues": [ + { "value": "10", "localName": "AF11", + "platformFlavors": [ + + ], + "comment": [ + "AF11 low drop" + ], + "label": "AF11 Low Drop "}, + { "value": "12", "localName": "AF12", + "platformFlavors": [ + + ], + "comment": [ + "AF12 medium drop" + ], + "label": "AF12 Medium Drop "}, + { "value": "14", "localName": "AF13", + "platformFlavors": [ + + ], + "comment": [ + "AF13 high drop" + ], + "label": "AF13 High Drop "}, + { "value": "18", "localName": "AF21", + "platformFlavors": [ + + ], + "comment": [ + "AF21 low drop" + ], + "label": "AF21 Low Drop "}, + { "value": "20", "localName": "AF22", + "platformFlavors": [ + + ], + "comment": [ + "AF22 medium drop" + ], + "label": "AF22 Medium Drop "}, + { "value": "22", "localName": "AF23", + "platformFlavors": [ + + ], + "comment": [ + "AF22 high drop" + ], + "label": "AF23 High Drop "}, + { "value": "26", "localName": "AF31", + "platformFlavors": [ + + ], + "comment": [ + "AF31 low drop" + ], + "label": "AF31 Low Drop "}, + { "value": "28", "localName": "AF32", + "platformFlavors": [ + + ], + "comment": [ + "AF32 medium drop" + ], + "label": "AF32 Medium Drop "}, + { "value": "30", "localName": "AF33", + "platformFlavors": [ + + ], + "comment": [ + "AF33 high drop" + ], + "label": "AF33 High Drop "}, + { "value": "34", "localName": "AF41", + "platformFlavors": [ + + ], + "comment": [ + "AF41 low drop" + ], + "label": "AF41 Low Drop "}, + { "value": "36", "localName": "AF42", + "platformFlavors": [ + + ], + "comment": [ + "AF42 medium drop" + ], + "label": "AF42 Medium Drop "}, + { "value": "38", "localName": "AF43", + "platformFlavors": [ + + ], + "comment": [ + "AF42 high drop" + ], + "label": "AF43 High Drop "}, + { "value": "0", "localName": "CS0", + "platformFlavors": [ + + ], + "comment": [ + "CS0" + ], + "label": "CS0 "}, + { "value": "8", "localName": "CS1", + "platformFlavors": [ + + ], + "comment": [ + "CS1" + ], + "label": "CS1 "}, + { "value": "16", "localName": "CS2", + "platformFlavors": [ + + ], + "comment": [ + "CS2" + ], + "label": "CS2 "}, + { "value": "24", "localName": "CS3", + "platformFlavors": [ + + ], + "comment": [ + "CS3" + ], + "label": "CS3 "}, + { "value": "32", "localName": "CS4", + "platformFlavors": [ + + ], + "comment": [ + "CS4" + ], + "label": "CS4 "}, + { "value": "40", "localName": "CS5", + "platformFlavors": [ + + ], + "comment": [ + "CS5" + ], + "label": "CS5 "}, + { "value": "48", "localName": "CS6", + "platformFlavors": [ + + ], + "comment": [ + "CS6" + ], + "label": "CS6 "}, + { "value": "56", "localName": "CS7", + "platformFlavors": [ + + ], + "comment": [ + "CS7" + ], + "label": "CS7 "}, + { "value": "46", "localName": "EF", + "platformFlavors": [ + + ], + "comment": [ + "EF" + ], + "label": "Expedited Forwarding "}, + { "value": "44", "localName": "VA", + "platformFlavors": [ + + ], + "comment": [ + "VA" + ], + "label": "Voice Admit "}, + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "64", "localName": "unspecified", + "platformFlavors": [ + + ], + "comment": [ + "Unspecified" + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "targetCos": { + "versions": "2.1(1h)-", + "comment": [ + "Target COS to be driven based on the range of input values of DSCP coming into the fabric" + ], + "isConfigurable": true, + "propGlobalId": "26215", + "propLocalId": "6214", + "label": "targetCos", + "baseType": "scalar:UByte", + "modelType": "qosp:Dot1P", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 8 } + ], + "validValues": [ + { "value": "0", "localName": "0", + "platformFlavors": [ + + ], + "comment": [ + "Background traffic" + ], + "label": "Background "}, + { "value": "1", "localName": "1", + "platformFlavors": [ + + ], + "comment": [ + "Best Effort traffic" + ], + "label": "Best Effort "}, + { "value": "2", "localName": "2", + "platformFlavors": [ + + ], + "comment": [ + "Excellent Effort traffic" + ], + "label": "Excellent Effort "}, + { "value": "3", "localName": "3", + "platformFlavors": [ + + ], + "comment": [ + "Critical Applications traffic" + ], + "label": "Critical Applications "}, + { "value": "4", "localName": "4", + "platformFlavors": [ + + ], + "comment": [ + "Video traffic" + ], + "label": "Video, < 100 ms latency and jitter "}, + { "value": "5", "localName": "5", + "platformFlavors": [ + + ], + "comment": [ + "Voice traffic" + ], + "label": "Voice, < 10 ms latency and jitter "}, + { "value": "6", "localName": "6", + "platformFlavors": [ + + ], + "comment": [ + "Internetwork Control traffic" + ], + "label": "Internetwork Control "}, + { "value": "7", "localName": "7", + "platformFlavors": [ + + ], + "comment": [ + "Network Control traffic" + ], + "label": "Network Control "}, + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "8", "localName": "unspecified", + "platformFlavors": [ + + ], + "comment": [ + "Class of traffic not specified, not a real COS value" + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "to": { + "versions": "1.0(1e)-", + "comment": [ + "The DSCP range ending value." + ], + "isConfigurable": true, + "propGlobalId": "7086", + "propLocalId": "181", + "label": "to", + "baseType": "scalar:UByte", + "modelType": "qosp:DscpCP", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63 } + ], + "validValues": [ + { "value": "10", "localName": "AF11", + "platformFlavors": [ + + ], + "comment": [ + "AF11 low drop" + ], + "label": "AF11 Low Drop "}, + { "value": "12", "localName": "AF12", + "platformFlavors": [ + + ], + "comment": [ + "AF12 medium drop" + ], + "label": "AF12 Medium Drop "}, + { "value": "14", "localName": "AF13", + "platformFlavors": [ + + ], + "comment": [ + "AF13 high drop" + ], + "label": "AF13 High Drop "}, + { "value": "18", "localName": "AF21", + "platformFlavors": [ + + ], + "comment": [ + "AF21 low drop" + ], + "label": "AF21 Low Drop "}, + { "value": "20", "localName": "AF22", + "platformFlavors": [ + + ], + "comment": [ + "AF22 medium drop" + ], + "label": "AF22 Medium Drop "}, + { "value": "22", "localName": "AF23", + "platformFlavors": [ + + ], + "comment": [ + "AF22 high drop" + ], + "label": "AF23 High Drop "}, + { "value": "26", "localName": "AF31", + "platformFlavors": [ + + ], + "comment": [ + "AF31 low drop" + ], + "label": "AF31 Low Drop "}, + { "value": "28", "localName": "AF32", + "platformFlavors": [ + + ], + "comment": [ + "AF32 medium drop" + ], + "label": "AF32 Medium Drop "}, + { "value": "30", "localName": "AF33", + "platformFlavors": [ + + ], + "comment": [ + "AF33 high drop" + ], + "label": "AF33 High Drop "}, + { "value": "34", "localName": "AF41", + "platformFlavors": [ + + ], + "comment": [ + "AF41 low drop" + ], + "label": "AF41 Low Drop "}, + { "value": "36", "localName": "AF42", + "platformFlavors": [ + + ], + "comment": [ + "AF42 medium drop" + ], + "label": "AF42 Medium Drop "}, + { "value": "38", "localName": "AF43", + "platformFlavors": [ + + ], + "comment": [ + "AF42 high drop" + ], + "label": "AF43 High Drop "}, + { "value": "0", "localName": "CS0", + "platformFlavors": [ + + ], + "comment": [ + "CS0" + ], + "label": "CS0 "}, + { "value": "8", "localName": "CS1", + "platformFlavors": [ + + ], + "comment": [ + "CS1" + ], + "label": "CS1 "}, + { "value": "16", "localName": "CS2", + "platformFlavors": [ + + ], + "comment": [ + "CS2" + ], + "label": "CS2 "}, + { "value": "24", "localName": "CS3", + "platformFlavors": [ + + ], + "comment": [ + "CS3" + ], + "label": "CS3 "}, + { "value": "32", "localName": "CS4", + "platformFlavors": [ + + ], + "comment": [ + "CS4" + ], + "label": "CS4 "}, + { "value": "40", "localName": "CS5", + "platformFlavors": [ + + ], + "comment": [ + "CS5" + ], + "label": "CS5 "}, + { "value": "48", "localName": "CS6", + "platformFlavors": [ + + ], + "comment": [ + "CS6" + ], + "label": "CS6 "}, + { "value": "56", "localName": "CS7", + "platformFlavors": [ + + ], + "comment": [ + "CS7" + ], + "label": "CS7 "}, + { "value": "46", "localName": "EF", + "platformFlavors": [ + + ], + "comment": [ + "EF" + ], + "label": "Expedited Forwarding "}, + { "value": "44", "localName": "VA", + "platformFlavors": [ + + ], + "comment": [ + "VA" + ], + "label": "Voice Admit "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/testvars/qosCustomPol.yaml b/gen/testvars/qosCustomPol.yaml index 6bdec082c..ec1b8e723 100644 --- a/gen/testvars/qosCustomPol.yaml +++ b/gen/testvars/qosCustomPol.yaml @@ -27,6 +27,108 @@ all: owner_tag: "owner_tag_1" children: + dot1p_classifiers: + - annotation: "annotation_1" + description: "description_1" + from: "0" + name: "name_1" + name_alias: "name_alias_1" + priority: "level1" + target: "AF11" + target_cos: "0" + to: "0" + + children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + - annotation: "annotation_2" + description: "description_2" + from: "1" + name: "name_2" + name_alias: "name_alias_2" + priority: "level2" + target: "AF12" + target_cos: "1" + to: "1" + + children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + dscp_to_priority_maps: + - annotation: "annotation_1" + description: "description_1" + from: "AF11" + name: "name_1" + name_alias: "name_alias_1" + priority: "level1" + target: "AF11" + target_cos: "0" + to: "AF11" + + children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + - annotation: "annotation_2" + description: "description_2" + from: "AF12" + name: "name_2" + name_alias: "name_alias_2" + priority: "level2" + target: "AF12" + target_cos: "1" + to: "AF12" + + children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + annotations: - key: "key_0" value: "value_1" diff --git a/gen/testvars/qosDot1PClass.yaml b/gen/testvars/qosDot1PClass.yaml new file mode 100644 index 000000000..569f0d2d5 --- /dev/null +++ b/gen/testvars/qosDot1PClass.yaml @@ -0,0 +1,68 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + + +default: + annotation: "orchestrator:terraform" + description: "" + from: "1" + name: "" + name_alias: "" + priority: "unspecified" + target: "unspecified" + target_cos: "unspecified" + to: "2" + +datasource_non_existing: + from: "6" + to: "7" + +datasource_required: + from: "1" + to: "2" + +resource_required: + from: "1" + to: "2" + +custom_type: + from: "0" + priority: "1" + target: "0" + target_cos: "0" + to: "0" + +all: + annotation: "annotation" + description: "description_1" + from: "4" + name: "name_1" + name_alias: "name_alias_1" + priority: "level1" + target: "AF11" + target_cos: "0" + to: "5" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + +parents: + - class_name: "qosCustomPol" + parent_dependency: "fvTenant" + parent_dn: "aci_custom_qos_policy.test.id" + class_in_parent: false + test_type: both +class_version: 1.0(1e)- diff --git a/gen/testvars/qosDscpClass.yaml b/gen/testvars/qosDscpClass.yaml new file mode 100644 index 000000000..99d114f1d --- /dev/null +++ b/gen/testvars/qosDscpClass.yaml @@ -0,0 +1,64 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + + +default: + annotation: "orchestrator:terraform" + description: "" + name: "" + name_alias: "" + priority: "unspecified" + target: "unspecified" + target_cos: "unspecified" + +datasource_non_existing: + from: "AF31" + to: "AF42" + +datasource_required: + from: "AF11" + to: "AF22" + +resource_required: + from: "AF11" + to: "AF22" + +custom_type: + from: "0" + priority: "1" + target: "0" + target_cos: "0" + to: "0" + +all: + annotation: "annotation" + description: "description_1" + name: "name_1" + name_alias: "name_alias_1" + priority: "level1" + target: "AF11" + target_cos: "0" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + +parents: + - class_name: "qosCustomPol" + parent_dependency: "fvTenant" + parent_dn: "aci_custom_qos_policy.test.id" + class_in_parent: false + test_type: both +class_version: 1.0(1e)- diff --git a/internal/custom_types/qosDot1PClass_from.go b/internal/custom_types/qosDot1PClass_from.go new file mode 100644 index 000000000..9f66f1627 --- /dev/null +++ b/internal/custom_types/qosDot1PClass_from.go @@ -0,0 +1,161 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDot1PClassFrom custom string type. + +var _ basetypes.StringTypable = QosDot1PClassFromStringType{} + +type QosDot1PClassFromStringType struct { + basetypes.StringType +} + +func (t QosDot1PClassFromStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDot1PClassFromStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDot1PClassFromStringType) String() string { + return "QosDot1PClassFromStringType" +} + +func (t QosDot1PClassFromStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDot1PClassFromStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDot1PClassFromStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDot1PClassFromStringType) ValueType(ctx context.Context) attr.Value { + return QosDot1PClassFromStringValue{} +} + +// QosDot1PClassFrom custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDot1PClassFromStringValue{} + +type QosDot1PClassFromStringValue struct { + basetypes.StringValue +} + +func (v QosDot1PClassFromStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDot1PClassFromStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDot1PClassFromStringValue) Type(ctx context.Context) attr.Type { + return QosDot1PClassFromStringType{} +} + +func (v QosDot1PClassFromStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDot1PClassFromStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDot1PClassFromValueMap(v.StringValue) + + newMappedValue := QosDot1PClassFromValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDot1PClassFromStringValue) NamedValueString() string { + return QosDot1PClassFromValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDot1PClassFromValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDot1PClassFromStringNull() QosDot1PClassFromStringValue { + return QosDot1PClassFromStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDot1PClassFromStringUnknown() QosDot1PClassFromStringValue { + return QosDot1PClassFromStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDot1PClassFromStringValue(value string) QosDot1PClassFromStringValue { + return QosDot1PClassFromStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDot1PClassFromStringPointerValue(value *string) QosDot1PClassFromStringValue { + return QosDot1PClassFromStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDot1PClass_prio.go b/internal/custom_types/qosDot1PClass_prio.go new file mode 100644 index 000000000..2633eeee0 --- /dev/null +++ b/internal/custom_types/qosDot1PClass_prio.go @@ -0,0 +1,159 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDot1PClassPrio custom string type. + +var _ basetypes.StringTypable = QosDot1PClassPrioStringType{} + +type QosDot1PClassPrioStringType struct { + basetypes.StringType +} + +func (t QosDot1PClassPrioStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDot1PClassPrioStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDot1PClassPrioStringType) String() string { + return "QosDot1PClassPrioStringType" +} + +func (t QosDot1PClassPrioStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDot1PClassPrioStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDot1PClassPrioStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDot1PClassPrioStringType) ValueType(ctx context.Context) attr.Value { + return QosDot1PClassPrioStringValue{} +} + +// QosDot1PClassPrio custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDot1PClassPrioStringValue{} + +type QosDot1PClassPrioStringValue struct { + basetypes.StringValue +} + +func (v QosDot1PClassPrioStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDot1PClassPrioStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDot1PClassPrioStringValue) Type(ctx context.Context) attr.Type { + return QosDot1PClassPrioStringType{} +} + +func (v QosDot1PClassPrioStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDot1PClassPrioStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDot1PClassPrioValueMap(v.StringValue) + + newMappedValue := QosDot1PClassPrioValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDot1PClassPrioStringValue) NamedValueString() string { + return QosDot1PClassPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDot1PClassPrioValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "unspecified", + "1": "level3", + "2": "level2", + "3": "level1", + "7": "level6", + "8": "level5", + "9": "level4", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDot1PClassPrioStringNull() QosDot1PClassPrioStringValue { + return QosDot1PClassPrioStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDot1PClassPrioStringUnknown() QosDot1PClassPrioStringValue { + return QosDot1PClassPrioStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDot1PClassPrioStringValue(value string) QosDot1PClassPrioStringValue { + return QosDot1PClassPrioStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDot1PClassPrioStringPointerValue(value *string) QosDot1PClassPrioStringValue { + return QosDot1PClassPrioStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDot1PClass_target.go b/internal/custom_types/qosDot1PClass_target.go new file mode 100644 index 000000000..ed276dbfc --- /dev/null +++ b/internal/custom_types/qosDot1PClass_target.go @@ -0,0 +1,175 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDot1PClassTarget custom string type. + +var _ basetypes.StringTypable = QosDot1PClassTargetStringType{} + +type QosDot1PClassTargetStringType struct { + basetypes.StringType +} + +func (t QosDot1PClassTargetStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDot1PClassTargetStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDot1PClassTargetStringType) String() string { + return "QosDot1PClassTargetStringType" +} + +func (t QosDot1PClassTargetStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDot1PClassTargetStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDot1PClassTargetStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDot1PClassTargetStringType) ValueType(ctx context.Context) attr.Value { + return QosDot1PClassTargetStringValue{} +} + +// QosDot1PClassTarget custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDot1PClassTargetStringValue{} + +type QosDot1PClassTargetStringValue struct { + basetypes.StringValue +} + +func (v QosDot1PClassTargetStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDot1PClassTargetStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDot1PClassTargetStringValue) Type(ctx context.Context) attr.Type { + return QosDot1PClassTargetStringType{} +} + +func (v QosDot1PClassTargetStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDot1PClassTargetStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDot1PClassTargetValueMap(v.StringValue) + + newMappedValue := QosDot1PClassTargetValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDot1PClassTargetStringValue) NamedValueString() string { + return QosDot1PClassTargetValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDot1PClassTargetValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "CS0", + "10": "AF11", + "12": "AF12", + "14": "AF13", + "16": "CS2", + "18": "AF21", + "20": "AF22", + "22": "AF23", + "24": "CS3", + "26": "AF31", + "28": "AF32", + "30": "AF33", + "32": "CS4", + "34": "AF41", + "36": "AF42", + "38": "AF43", + "40": "CS5", + "44": "VA", + "46": "EF", + "48": "CS6", + "56": "CS7", + "64": "unspecified", + "8": "CS1", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDot1PClassTargetStringNull() QosDot1PClassTargetStringValue { + return QosDot1PClassTargetStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDot1PClassTargetStringUnknown() QosDot1PClassTargetStringValue { + return QosDot1PClassTargetStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDot1PClassTargetStringValue(value string) QosDot1PClassTargetStringValue { + return QosDot1PClassTargetStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDot1PClassTargetStringPointerValue(value *string) QosDot1PClassTargetStringValue { + return QosDot1PClassTargetStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDot1PClass_targetCos.go b/internal/custom_types/qosDot1PClass_targetCos.go new file mode 100644 index 000000000..bc7bf7170 --- /dev/null +++ b/internal/custom_types/qosDot1PClass_targetCos.go @@ -0,0 +1,161 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDot1PClassTargetCos custom string type. + +var _ basetypes.StringTypable = QosDot1PClassTargetCosStringType{} + +type QosDot1PClassTargetCosStringType struct { + basetypes.StringType +} + +func (t QosDot1PClassTargetCosStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDot1PClassTargetCosStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDot1PClassTargetCosStringType) String() string { + return "QosDot1PClassTargetCosStringType" +} + +func (t QosDot1PClassTargetCosStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDot1PClassTargetCosStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDot1PClassTargetCosStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDot1PClassTargetCosStringType) ValueType(ctx context.Context) attr.Value { + return QosDot1PClassTargetCosStringValue{} +} + +// QosDot1PClassTargetCos custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDot1PClassTargetCosStringValue{} + +type QosDot1PClassTargetCosStringValue struct { + basetypes.StringValue +} + +func (v QosDot1PClassTargetCosStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDot1PClassTargetCosStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDot1PClassTargetCosStringValue) Type(ctx context.Context) attr.Type { + return QosDot1PClassTargetCosStringType{} +} + +func (v QosDot1PClassTargetCosStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDot1PClassTargetCosStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDot1PClassTargetCosValueMap(v.StringValue) + + newMappedValue := QosDot1PClassTargetCosValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDot1PClassTargetCosStringValue) NamedValueString() string { + return QosDot1PClassTargetCosValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDot1PClassTargetCosValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDot1PClassTargetCosStringNull() QosDot1PClassTargetCosStringValue { + return QosDot1PClassTargetCosStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDot1PClassTargetCosStringUnknown() QosDot1PClassTargetCosStringValue { + return QosDot1PClassTargetCosStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDot1PClassTargetCosStringValue(value string) QosDot1PClassTargetCosStringValue { + return QosDot1PClassTargetCosStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDot1PClassTargetCosStringPointerValue(value *string) QosDot1PClassTargetCosStringValue { + return QosDot1PClassTargetCosStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDot1PClass_to.go b/internal/custom_types/qosDot1PClass_to.go new file mode 100644 index 000000000..71a1a6177 --- /dev/null +++ b/internal/custom_types/qosDot1PClass_to.go @@ -0,0 +1,161 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDot1PClassTo custom string type. + +var _ basetypes.StringTypable = QosDot1PClassToStringType{} + +type QosDot1PClassToStringType struct { + basetypes.StringType +} + +func (t QosDot1PClassToStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDot1PClassToStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDot1PClassToStringType) String() string { + return "QosDot1PClassToStringType" +} + +func (t QosDot1PClassToStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDot1PClassToStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDot1PClassToStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDot1PClassToStringType) ValueType(ctx context.Context) attr.Value { + return QosDot1PClassToStringValue{} +} + +// QosDot1PClassTo custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDot1PClassToStringValue{} + +type QosDot1PClassToStringValue struct { + basetypes.StringValue +} + +func (v QosDot1PClassToStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDot1PClassToStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDot1PClassToStringValue) Type(ctx context.Context) attr.Type { + return QosDot1PClassToStringType{} +} + +func (v QosDot1PClassToStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDot1PClassToStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDot1PClassToValueMap(v.StringValue) + + newMappedValue := QosDot1PClassToValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDot1PClassToStringValue) NamedValueString() string { + return QosDot1PClassToValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDot1PClassToValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDot1PClassToStringNull() QosDot1PClassToStringValue { + return QosDot1PClassToStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDot1PClassToStringUnknown() QosDot1PClassToStringValue { + return QosDot1PClassToStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDot1PClassToStringValue(value string) QosDot1PClassToStringValue { + return QosDot1PClassToStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDot1PClassToStringPointerValue(value *string) QosDot1PClassToStringValue { + return QosDot1PClassToStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDscpClass_from.go b/internal/custom_types/qosDscpClass_from.go new file mode 100644 index 000000000..5dd92fc46 --- /dev/null +++ b/internal/custom_types/qosDscpClass_from.go @@ -0,0 +1,174 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDscpClassFrom custom string type. + +var _ basetypes.StringTypable = QosDscpClassFromStringType{} + +type QosDscpClassFromStringType struct { + basetypes.StringType +} + +func (t QosDscpClassFromStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDscpClassFromStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDscpClassFromStringType) String() string { + return "QosDscpClassFromStringType" +} + +func (t QosDscpClassFromStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDscpClassFromStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDscpClassFromStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDscpClassFromStringType) ValueType(ctx context.Context) attr.Value { + return QosDscpClassFromStringValue{} +} + +// QosDscpClassFrom custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDscpClassFromStringValue{} + +type QosDscpClassFromStringValue struct { + basetypes.StringValue +} + +func (v QosDscpClassFromStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDscpClassFromStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDscpClassFromStringValue) Type(ctx context.Context) attr.Type { + return QosDscpClassFromStringType{} +} + +func (v QosDscpClassFromStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDscpClassFromStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDscpClassFromValueMap(v.StringValue) + + newMappedValue := QosDscpClassFromValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDscpClassFromStringValue) NamedValueString() string { + return QosDscpClassFromValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDscpClassFromValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "CS0", + "10": "AF11", + "12": "AF12", + "14": "AF13", + "16": "CS2", + "18": "AF21", + "20": "AF22", + "22": "AF23", + "24": "CS3", + "26": "AF31", + "28": "AF32", + "30": "AF33", + "32": "CS4", + "34": "AF41", + "36": "AF42", + "38": "AF43", + "40": "CS5", + "44": "VA", + "46": "EF", + "48": "CS6", + "56": "CS7", + "8": "CS1", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDscpClassFromStringNull() QosDscpClassFromStringValue { + return QosDscpClassFromStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDscpClassFromStringUnknown() QosDscpClassFromStringValue { + return QosDscpClassFromStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDscpClassFromStringValue(value string) QosDscpClassFromStringValue { + return QosDscpClassFromStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDscpClassFromStringPointerValue(value *string) QosDscpClassFromStringValue { + return QosDscpClassFromStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDscpClass_prio.go b/internal/custom_types/qosDscpClass_prio.go new file mode 100644 index 000000000..021d985ab --- /dev/null +++ b/internal/custom_types/qosDscpClass_prio.go @@ -0,0 +1,159 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDscpClassPrio custom string type. + +var _ basetypes.StringTypable = QosDscpClassPrioStringType{} + +type QosDscpClassPrioStringType struct { + basetypes.StringType +} + +func (t QosDscpClassPrioStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDscpClassPrioStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDscpClassPrioStringType) String() string { + return "QosDscpClassPrioStringType" +} + +func (t QosDscpClassPrioStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDscpClassPrioStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDscpClassPrioStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDscpClassPrioStringType) ValueType(ctx context.Context) attr.Value { + return QosDscpClassPrioStringValue{} +} + +// QosDscpClassPrio custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDscpClassPrioStringValue{} + +type QosDscpClassPrioStringValue struct { + basetypes.StringValue +} + +func (v QosDscpClassPrioStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDscpClassPrioStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDscpClassPrioStringValue) Type(ctx context.Context) attr.Type { + return QosDscpClassPrioStringType{} +} + +func (v QosDscpClassPrioStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDscpClassPrioStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDscpClassPrioValueMap(v.StringValue) + + newMappedValue := QosDscpClassPrioValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDscpClassPrioStringValue) NamedValueString() string { + return QosDscpClassPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDscpClassPrioValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "unspecified", + "1": "level3", + "2": "level2", + "3": "level1", + "7": "level6", + "8": "level5", + "9": "level4", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDscpClassPrioStringNull() QosDscpClassPrioStringValue { + return QosDscpClassPrioStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDscpClassPrioStringUnknown() QosDscpClassPrioStringValue { + return QosDscpClassPrioStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDscpClassPrioStringValue(value string) QosDscpClassPrioStringValue { + return QosDscpClassPrioStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDscpClassPrioStringPointerValue(value *string) QosDscpClassPrioStringValue { + return QosDscpClassPrioStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDscpClass_target.go b/internal/custom_types/qosDscpClass_target.go new file mode 100644 index 000000000..0015bf0ad --- /dev/null +++ b/internal/custom_types/qosDscpClass_target.go @@ -0,0 +1,175 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDscpClassTarget custom string type. + +var _ basetypes.StringTypable = QosDscpClassTargetStringType{} + +type QosDscpClassTargetStringType struct { + basetypes.StringType +} + +func (t QosDscpClassTargetStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDscpClassTargetStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDscpClassTargetStringType) String() string { + return "QosDscpClassTargetStringType" +} + +func (t QosDscpClassTargetStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDscpClassTargetStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDscpClassTargetStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDscpClassTargetStringType) ValueType(ctx context.Context) attr.Value { + return QosDscpClassTargetStringValue{} +} + +// QosDscpClassTarget custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDscpClassTargetStringValue{} + +type QosDscpClassTargetStringValue struct { + basetypes.StringValue +} + +func (v QosDscpClassTargetStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDscpClassTargetStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDscpClassTargetStringValue) Type(ctx context.Context) attr.Type { + return QosDscpClassTargetStringType{} +} + +func (v QosDscpClassTargetStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDscpClassTargetStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDscpClassTargetValueMap(v.StringValue) + + newMappedValue := QosDscpClassTargetValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDscpClassTargetStringValue) NamedValueString() string { + return QosDscpClassTargetValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDscpClassTargetValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "CS0", + "10": "AF11", + "12": "AF12", + "14": "AF13", + "16": "CS2", + "18": "AF21", + "20": "AF22", + "22": "AF23", + "24": "CS3", + "26": "AF31", + "28": "AF32", + "30": "AF33", + "32": "CS4", + "34": "AF41", + "36": "AF42", + "38": "AF43", + "40": "CS5", + "44": "VA", + "46": "EF", + "48": "CS6", + "56": "CS7", + "64": "unspecified", + "8": "CS1", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDscpClassTargetStringNull() QosDscpClassTargetStringValue { + return QosDscpClassTargetStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDscpClassTargetStringUnknown() QosDscpClassTargetStringValue { + return QosDscpClassTargetStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDscpClassTargetStringValue(value string) QosDscpClassTargetStringValue { + return QosDscpClassTargetStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDscpClassTargetStringPointerValue(value *string) QosDscpClassTargetStringValue { + return QosDscpClassTargetStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDscpClass_targetCos.go b/internal/custom_types/qosDscpClass_targetCos.go new file mode 100644 index 000000000..13cfce5db --- /dev/null +++ b/internal/custom_types/qosDscpClass_targetCos.go @@ -0,0 +1,161 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDscpClassTargetCos custom string type. + +var _ basetypes.StringTypable = QosDscpClassTargetCosStringType{} + +type QosDscpClassTargetCosStringType struct { + basetypes.StringType +} + +func (t QosDscpClassTargetCosStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDscpClassTargetCosStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDscpClassTargetCosStringType) String() string { + return "QosDscpClassTargetCosStringType" +} + +func (t QosDscpClassTargetCosStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDscpClassTargetCosStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDscpClassTargetCosStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDscpClassTargetCosStringType) ValueType(ctx context.Context) attr.Value { + return QosDscpClassTargetCosStringValue{} +} + +// QosDscpClassTargetCos custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDscpClassTargetCosStringValue{} + +type QosDscpClassTargetCosStringValue struct { + basetypes.StringValue +} + +func (v QosDscpClassTargetCosStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDscpClassTargetCosStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDscpClassTargetCosStringValue) Type(ctx context.Context) attr.Type { + return QosDscpClassTargetCosStringType{} +} + +func (v QosDscpClassTargetCosStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDscpClassTargetCosStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDscpClassTargetCosValueMap(v.StringValue) + + newMappedValue := QosDscpClassTargetCosValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDscpClassTargetCosStringValue) NamedValueString() string { + return QosDscpClassTargetCosValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDscpClassTargetCosValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "8": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDscpClassTargetCosStringNull() QosDscpClassTargetCosStringValue { + return QosDscpClassTargetCosStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDscpClassTargetCosStringUnknown() QosDscpClassTargetCosStringValue { + return QosDscpClassTargetCosStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDscpClassTargetCosStringValue(value string) QosDscpClassTargetCosStringValue { + return QosDscpClassTargetCosStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDscpClassTargetCosStringPointerValue(value *string) QosDscpClassTargetCosStringValue { + return QosDscpClassTargetCosStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/qosDscpClass_to.go b/internal/custom_types/qosDscpClass_to.go new file mode 100644 index 000000000..d2cb97ccc --- /dev/null +++ b/internal/custom_types/qosDscpClass_to.go @@ -0,0 +1,174 @@ +package customTypes + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// QosDscpClassTo custom string type. + +var _ basetypes.StringTypable = QosDscpClassToStringType{} + +type QosDscpClassToStringType struct { + basetypes.StringType +} + +func (t QosDscpClassToStringType) Equal(o attr.Type) bool { + other, ok := o.(QosDscpClassToStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t QosDscpClassToStringType) String() string { + return "QosDscpClassToStringType" +} + +func (t QosDscpClassToStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := QosDscpClassToStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t QosDscpClassToStringType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { + attrValue, err := t.StringType.ValueFromTerraform(ctx, in) + + if err != nil { + return nil, err + } + + stringValue, ok := attrValue.(basetypes.StringValue) + + if !ok { + return nil, fmt.Errorf("unexpected value type of %T", attrValue) + } + + stringValuable, diags := t.ValueFromString(ctx, stringValue) + + if diags.HasError() { + return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags) + } + + return stringValuable, nil +} + +func (t QosDscpClassToStringType) ValueType(ctx context.Context) attr.Value { + return QosDscpClassToStringValue{} +} + +// QosDscpClassTo custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = QosDscpClassToStringValue{} + +type QosDscpClassToStringValue struct { + basetypes.StringValue +} + +func (v QosDscpClassToStringValue) Equal(o attr.Value) bool { + other, ok := o.(QosDscpClassToStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v QosDscpClassToStringValue) Type(ctx context.Context) attr.Type { + return QosDscpClassToStringType{} +} + +func (v QosDscpClassToStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(QosDscpClassToStringValue) + + if !ok { + diags.AddError( + "Semantic Equality Check Error", + "An unexpected value type was received while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Expected Value Type: "+fmt.Sprintf("%T", v)+"\n"+ + "Got Value Type: "+fmt.Sprintf("%T", newValuable), + ) + + return false, diags + } + + priorMappedValue := QosDscpClassToValueMap(v.StringValue) + + newMappedValue := QosDscpClassToValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v QosDscpClassToStringValue) NamedValueString() string { + return QosDscpClassToValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func QosDscpClassToValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0": "CS0", + "10": "AF11", + "12": "AF12", + "14": "AF13", + "16": "CS2", + "18": "AF21", + "20": "AF22", + "22": "AF23", + "24": "CS3", + "26": "AF31", + "28": "AF32", + "30": "AF33", + "32": "CS4", + "34": "AF41", + "36": "AF42", + "38": "AF43", + "40": "CS5", + "44": "VA", + "46": "EF", + "48": "CS6", + "56": "CS7", + "8": "CS1", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewQosDscpClassToStringNull() QosDscpClassToStringValue { + return QosDscpClassToStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewQosDscpClassToStringUnknown() QosDscpClassToStringValue { + return QosDscpClassToStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewQosDscpClassToStringValue(value string) QosDscpClassToStringValue { + return QosDscpClassToStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewQosDscpClassToStringPointerValue(value *string) QosDscpClassToStringValue { + return QosDscpClassToStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/provider/data_source_aci_custom_qos_policy.go b/internal/provider/data_source_aci_custom_qos_policy.go index 3c1d8b011..4c8a365a1 100644 --- a/internal/provider/data_source_aci_custom_qos_policy.go +++ b/internal/provider/data_source_aci_custom_qos_policy.go @@ -8,6 +8,7 @@ import ( "context" "fmt" + customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -72,6 +73,168 @@ func (d *QosCustomPolDataSource) Schema(ctx context.Context, req datasource.Sche Computed: true, MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, }, + "dot1p_classifiers": schema.SetNestedAttribute{ + MarkdownDescription: `The class level for dot1P to prioritize the map.`, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Dot1p Classifier object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Dot1p Classifier object.`, + }, + "from": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassFromStringType{}, + Computed: true, + MarkdownDescription: `The Dot1p priority range starting value.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the Dot1p Classifier object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Dot1p Classifier object.`, + }, + "priority": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassPrioStringType{}, + Computed: true, + MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`, + }, + "target": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassTargetStringType{}, + Computed: true, + MarkdownDescription: `The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`, + }, + "target_cos": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassTargetCosStringType{}, + Computed: true, + MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`, + }, + "to": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassToStringType{}, + Computed: true, + MarkdownDescription: `The Dot1p priority range ending value.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + }, + }, + "dscp_to_priority_maps": schema.SetNestedAttribute{ + MarkdownDescription: `The class level for DSCP to prioritize the map.`, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the DSCP to Priority Map object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the DSCP to Priority Map object.`, + }, + "from": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassFromStringType{}, + Computed: true, + MarkdownDescription: `The DSCP range starting value.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the DSCP to Priority Map object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the DSCP to Priority Map object.`, + }, + "priority": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassPrioStringType{}, + Computed: true, + MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`, + }, + "target": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassTargetStringType{}, + Computed: true, + MarkdownDescription: `The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`, + }, + "target_cos": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassTargetCosStringType{}, + Computed: true, + MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`, + }, + "to": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassToStringType{}, + Computed: true, + MarkdownDescription: `The DSCP range ending value.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, diff --git a/internal/provider/data_source_aci_dot1p_classifier.go b/internal/provider/data_source_aci_dot1p_classifier.go new file mode 100644 index 000000000..4725de36e --- /dev/null +++ b/internal/provider/data_source_aci_dot1p_classifier.go @@ -0,0 +1,183 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "fmt" + + customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" + "github.com/ciscoecosystem/aci-go-client/v2/client" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &QosDot1PClassDataSource{} + +func NewQosDot1PClassDataSource() datasource.DataSource { + return &QosDot1PClassDataSource{} +} + +// QosDot1PClassDataSource defines the data source implementation. +type QosDot1PClassDataSource struct { + client *client.Client +} + +func (d *QosDot1PClassDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_dot1p_classifier") + resp.TypeName = req.ProviderTypeName + "_dot1p_classifier" + tflog.Debug(ctx, "End metadata of datasource: aci_dot1p_classifier") +} + +func (d *QosDot1PClassDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_dot1p_classifier") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The dot1p_classifier datasource for the 'qosDot1PClass' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Dot1p Classifier object.", + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Dot1p Classifier object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Dot1p Classifier object.`, + }, + "from": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassFromStringType{}, + Required: true, + MarkdownDescription: `The Dot1p priority range starting value.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the Dot1p Classifier object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Dot1p Classifier object.`, + }, + "priority": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassPrioStringType{}, + Computed: true, + MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`, + }, + "target": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassTargetStringType{}, + Computed: true, + MarkdownDescription: `The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`, + }, + "target_cos": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassTargetCosStringType{}, + Computed: true, + MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`, + }, + "to": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassToStringType{}, + Required: true, + MarkdownDescription: `The Dot1p priority range ending value.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_dot1p_classifier") +} + +func (d *QosDot1PClassDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_dot1p_classifier") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + d.client = client + tflog.Debug(ctx, "End configure of datasource: aci_dot1p_classifier") +} + +func (d *QosDot1PClassDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_dot1p_classifier") + var data *QosDot1PClassResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setQosDot1PClassId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetQosDot1PClassAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) + + getAndSetQosDot1PClassAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_dot1p_classifier data source", + fmt.Sprintf("The aci_dot1p_classifier data source with id '%s' has not been found", cachedId), + ) + return + } + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_dot1p_classifier_test.go b/internal/provider/data_source_aci_dot1p_classifier_test.go new file mode 100644 index 000000000..3f2665a8d --- /dev/null +++ b/internal/provider/data_source_aci_dot1p_classifier_test.go @@ -0,0 +1,58 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceQosDot1PClassWithQosCustomPol(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigQosDot1PClassDataSourceDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "from", "1"), + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "to", "2"), + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "name", ""), + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "priority", "unspecified"), + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "target", "unspecified"), + resource.TestCheckResourceAttr("data.aci_dot1p_classifier.test", "target_cos", "unspecified"), + ), + }, + { + Config: testConfigQosDot1PClassNotExistingQosCustomPol, + ExpectError: regexp.MustCompile("Failed to read aci_dot1p_classifier data source"), + }, + }, + }) +} + +const testConfigQosDot1PClassDataSourceDependencyWithQosCustomPol = testConfigQosDot1PClassMinDependencyWithQosCustomPol + ` +data "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "1" + to = "2" + depends_on = [aci_dot1p_classifier.test] +} +` + +const testConfigQosDot1PClassNotExistingQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +data "aci_dot1p_classifier" "test_non_existing" { + parent_dn = aci_custom_qos_policy.test.id + from = "6" + to = "7" +} +` diff --git a/internal/provider/data_source_aci_dscp_to_priority_map.go b/internal/provider/data_source_aci_dscp_to_priority_map.go new file mode 100644 index 000000000..1961aa96e --- /dev/null +++ b/internal/provider/data_source_aci_dscp_to_priority_map.go @@ -0,0 +1,183 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "fmt" + + customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" + "github.com/ciscoecosystem/aci-go-client/v2/client" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &QosDscpClassDataSource{} + +func NewQosDscpClassDataSource() datasource.DataSource { + return &QosDscpClassDataSource{} +} + +// QosDscpClassDataSource defines the data source implementation. +type QosDscpClassDataSource struct { + client *client.Client +} + +func (d *QosDscpClassDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_dscp_to_priority_map") + resp.TypeName = req.ProviderTypeName + "_dscp_to_priority_map" + tflog.Debug(ctx, "End metadata of datasource: aci_dscp_to_priority_map") +} + +func (d *QosDscpClassDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_dscp_to_priority_map") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The dscp_to_priority_map datasource for the 'qosDscpClass' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the DSCP to Priority Map object.", + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the DSCP to Priority Map object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the DSCP to Priority Map object.`, + }, + "from": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassFromStringType{}, + Required: true, + MarkdownDescription: `The DSCP range starting value.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the DSCP to Priority Map object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the DSCP to Priority Map object.`, + }, + "priority": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassPrioStringType{}, + Computed: true, + MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`, + }, + "target": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassTargetStringType{}, + Computed: true, + MarkdownDescription: `The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`, + }, + "target_cos": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassTargetCosStringType{}, + Computed: true, + MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`, + }, + "to": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassToStringType{}, + Required: true, + MarkdownDescription: `The DSCP range ending value.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_dscp_to_priority_map") +} + +func (d *QosDscpClassDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_dscp_to_priority_map") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + d.client = client + tflog.Debug(ctx, "End configure of datasource: aci_dscp_to_priority_map") +} + +func (d *QosDscpClassDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_dscp_to_priority_map") + var data *QosDscpClassResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setQosDscpClassId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetQosDscpClassAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) + + getAndSetQosDscpClassAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_dscp_to_priority_map data source", + fmt.Sprintf("The aci_dscp_to_priority_map data source with id '%s' has not been found", cachedId), + ) + return + } + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_dscp_to_priority_map_test.go b/internal/provider/data_source_aci_dscp_to_priority_map_test.go new file mode 100644 index 000000000..ab293feee --- /dev/null +++ b/internal/provider/data_source_aci_dscp_to_priority_map_test.go @@ -0,0 +1,58 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceQosDscpClassWithQosCustomPol(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigQosDscpClassDataSourceDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "from", "AF11"), + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "to", "AF22"), + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "name", ""), + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "priority", "unspecified"), + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "target", "unspecified"), + resource.TestCheckResourceAttr("data.aci_dscp_to_priority_map.test", "target_cos", "unspecified"), + ), + }, + { + Config: testConfigQosDscpClassNotExistingQosCustomPol, + ExpectError: regexp.MustCompile("Failed to read aci_dscp_to_priority_map data source"), + }, + }, + }) +} + +const testConfigQosDscpClassDataSourceDependencyWithQosCustomPol = testConfigQosDscpClassMinDependencyWithQosCustomPol + ` +data "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" + depends_on = [aci_dscp_to_priority_map.test] +} +` + +const testConfigQosDscpClassNotExistingQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +data "aci_dscp_to_priority_map" "test_non_existing" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF31" + to = "AF42" +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index e19ebd466..b8c77b786 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -260,7 +260,9 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewPkiKeyRingResource, NewPkiTPResource, NewQosCustomPolResource, + NewQosDot1PClassResource, NewQosDppPolResource, + NewQosDscpClassResource, NewRtctrlProfileResource, NewTagAnnotationResource, NewTagTagResource, @@ -325,7 +327,9 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewPkiKeyRingDataSource, NewPkiTPDataSource, NewQosCustomPolDataSource, + NewQosDot1PClassDataSource, NewQosDppPolDataSource, + NewQosDscpClassDataSource, NewRtctrlProfileDataSource, NewTagAnnotationDataSource, NewTagTagDataSource, diff --git a/internal/provider/resource_aci_custom_qos_policy.go b/internal/provider/resource_aci_custom_qos_policy.go index 67eba93aa..88bb6cdc9 100644 --- a/internal/provider/resource_aci_custom_qos_policy.go +++ b/internal/provider/resource_aci_custom_qos_policy.go @@ -9,8 +9,11 @@ import ( "encoding/json" "fmt" + customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -20,6 +23,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -48,6 +52,8 @@ type QosCustomPolResourceModel struct { NameAlias types.String `tfsdk:"name_alias"` OwnerKey types.String `tfsdk:"owner_key"` OwnerTag types.String `tfsdk:"owner_tag"` + QosDot1PClass types.Set `tfsdk:"dot1p_classifiers"` + QosDscpClass types.Set `tfsdk:"dscp_to_priority_maps"` TagAnnotation types.Set `tfsdk:"annotations"` TagTag types.Set `tfsdk:"tags"` } @@ -62,6 +68,174 @@ func getEmptyQosCustomPolResourceModel() *QosCustomPolResourceModel { NameAlias: basetypes.NewStringNull(), OwnerKey: basetypes.NewStringNull(), OwnerTag: basetypes.NewStringNull(), + QosDot1PClass: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "description": types.StringType, + "from": types.StringType, + "name": types.StringType, + "name_alias": types.StringType, + "priority": types.StringType, + "target": types.StringType, + "target_cos": types.StringType, + "to": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationQosDot1PClassQosCustomPolType}, + "tags": types.SetType{ElemType: TagTagQosDot1PClassQosCustomPolType}, + }, + }), + QosDscpClass: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "description": types.StringType, + "from": types.StringType, + "name": types.StringType, + "name_alias": types.StringType, + "priority": types.StringType, + "target": types.StringType, + "target_cos": types.StringType, + "to": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationQosDscpClassQosCustomPolType}, + "tags": types.SetType{ElemType: TagTagQosDscpClassQosCustomPolType}, + }, + }), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +// QosDot1PClassQosCustomPolResourceModel describes the resource data model for the children without relation ships. +type QosDot1PClassQosCustomPolResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + From customTypes.QosDot1PClassFromStringValue `tfsdk:"from"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + Prio customTypes.QosDot1PClassPrioStringValue `tfsdk:"priority"` + Target customTypes.QosDot1PClassTargetStringValue `tfsdk:"target"` + TargetCos customTypes.QosDot1PClassTargetCosStringValue `tfsdk:"target_cos"` + To customTypes.QosDot1PClassToStringValue `tfsdk:"to"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyQosDot1PClassQosCustomPolResourceModel() QosDot1PClassQosCustomPolResourceModel { + return QosDot1PClassQosCustomPolResourceModel{ + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + From: customTypes.NewQosDot1PClassFromStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + Prio: customTypes.NewQosDot1PClassPrioStringNull(), + Target: customTypes.NewQosDot1PClassTargetStringNull(), + TargetCos: customTypes.NewQosDot1PClassTargetCosStringNull(), + To: customTypes.NewQosDot1PClassToStringNull(), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +var QosDot1PClassQosCustomPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "description": types.StringType, + "from": types.StringType, + "name": types.StringType, + "name_alias": types.StringType, + "priority": types.StringType, + "target": types.StringType, + "target_cos": types.StringType, + "to": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationQosDot1PClassQosCustomPolType}, + "tags": types.SetType{ElemType: TagTagQosDot1PClassQosCustomPolType}, + }, +} + +// TagAnnotationQosDot1PClassQosCustomPolResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationQosDot1PClassQosCustomPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationQosDot1PClassQosCustomPolResourceModel() TagAnnotationQosDot1PClassQosCustomPolResourceModel { + return TagAnnotationQosDot1PClassQosCustomPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationQosDot1PClassQosCustomPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagQosDot1PClassQosCustomPolResourceModel describes the resource data model for the children without relation ships. +type TagTagQosDot1PClassQosCustomPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagQosDot1PClassQosCustomPolResourceModel() TagTagQosDot1PClassQosCustomPolResourceModel { + return TagTagQosDot1PClassQosCustomPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagQosDot1PClassQosCustomPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// QosDscpClassQosCustomPolResourceModel describes the resource data model for the children without relation ships. +type QosDscpClassQosCustomPolResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + From customTypes.QosDscpClassFromStringValue `tfsdk:"from"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + Prio customTypes.QosDscpClassPrioStringValue `tfsdk:"priority"` + Target customTypes.QosDscpClassTargetStringValue `tfsdk:"target"` + TargetCos customTypes.QosDscpClassTargetCosStringValue `tfsdk:"target_cos"` + To customTypes.QosDscpClassToStringValue `tfsdk:"to"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyQosDscpClassQosCustomPolResourceModel() QosDscpClassQosCustomPolResourceModel { + return QosDscpClassQosCustomPolResourceModel{ + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + From: customTypes.NewQosDscpClassFromStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + Prio: customTypes.NewQosDscpClassPrioStringNull(), + Target: customTypes.NewQosDscpClassTargetStringNull(), + TargetCos: customTypes.NewQosDscpClassTargetCosStringNull(), + To: customTypes.NewQosDscpClassToStringNull(), TagAnnotation: types.SetNull(types.ObjectType{ AttrTypes: map[string]attr.Type{ "key": types.StringType, @@ -77,6 +251,62 @@ func getEmptyQosCustomPolResourceModel() *QosCustomPolResourceModel { } } +var QosDscpClassQosCustomPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "description": types.StringType, + "from": types.StringType, + "name": types.StringType, + "name_alias": types.StringType, + "priority": types.StringType, + "target": types.StringType, + "target_cos": types.StringType, + "to": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationQosDscpClassQosCustomPolType}, + "tags": types.SetType{ElemType: TagTagQosDscpClassQosCustomPolType}, + }, +} + +// TagAnnotationQosDscpClassQosCustomPolResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationQosDscpClassQosCustomPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationQosDscpClassQosCustomPolResourceModel() TagAnnotationQosDscpClassQosCustomPolResourceModel { + return TagAnnotationQosDscpClassQosCustomPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationQosDscpClassQosCustomPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagQosDscpClassQosCustomPolResourceModel describes the resource data model for the children without relation ships. +type TagTagQosDscpClassQosCustomPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagQosDscpClassQosCustomPolResourceModel() TagTagQosDscpClassQosCustomPolResourceModel { + return TagTagQosDscpClassQosCustomPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagQosDscpClassQosCustomPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + // TagAnnotationQosCustomPolResourceModel describes the resource data model for the children without relation ships. type TagAnnotationQosCustomPolResourceModel struct { Key types.String `tfsdk:"key"` @@ -229,6 +459,344 @@ func (r *QosCustomPolResource) Schema(ctx context.Context, req resource.SchemaRe }, MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, }, + "dot1p_classifiers": schema.SetNestedAttribute{ + MarkdownDescription: `The class level for dot1P to prioritize the map.`, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Dot1p Classifier object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the Dot1p Classifier object.`, + }, + "from": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassFromStringType{}, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"), + validators.InBetweenFromString(0, 8), + ), + }, + MarkdownDescription: `The Dot1p priority range starting value.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name of the Dot1p Classifier object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the Dot1p Classifier object.`, + }, + "priority": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassPrioStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("level1", "level2", "level3", "level4", "level5", "level6", "unspecified"), + validators.InBetweenFromString(0, 9), + ), + }, + MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`, + }, + "target": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassTargetStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA", "unspecified"), + validators.InBetweenFromString(0, 64), + ), + }, + MarkdownDescription: `The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`, + }, + "target_cos": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassTargetCosStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"), + validators.InBetweenFromString(0, 8), + ), + }, + MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`, + }, + "to": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassToStringType{}, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"), + validators.InBetweenFromString(0, 8), + ), + }, + MarkdownDescription: `The Dot1p priority range ending value.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + }, + }, + "dscp_to_priority_maps": schema.SetNestedAttribute{ + MarkdownDescription: `The class level for DSCP to prioritize the map.`, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the DSCP to Priority Map object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the DSCP to Priority Map object.`, + }, + "from": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassFromStringType{}, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA"), + validators.InBetweenFromString(0, 63), + ), + }, + MarkdownDescription: `The DSCP range starting value.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name of the DSCP to Priority Map object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the DSCP to Priority Map object.`, + }, + "priority": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassPrioStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("level1", "level2", "level3", "level4", "level5", "level6", "unspecified"), + validators.InBetweenFromString(0, 9), + ), + }, + MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`, + }, + "target": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassTargetStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA", "unspecified"), + validators.InBetweenFromString(0, 64), + ), + }, + MarkdownDescription: `The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`, + }, + "target_cos": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassTargetCosStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"), + validators.InBetweenFromString(0, 8), + ), + }, + MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`, + }, + "to": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassToStringType{}, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA"), + validators.InBetweenFromString(0, 63), + ), + }, + MarkdownDescription: `The DSCP range ending value.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, @@ -340,13 +908,19 @@ func (r *QosCustomPolResource) Create(ctx context.Context, req resource.CreateRe tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_custom_qos_policy with id '%s'", data.Id.ValueString())) + var qosDot1PClassPlan, qosDot1PClassState []QosDot1PClassQosCustomPolResourceModel + data.QosDot1PClass.ElementsAs(ctx, &qosDot1PClassPlan, false) + stateData.QosDot1PClass.ElementsAs(ctx, &qosDot1PClassState, false) + var qosDscpClassPlan, qosDscpClassState []QosDscpClassQosCustomPolResourceModel + data.QosDscpClass.ElementsAs(ctx, &qosDscpClassPlan, false) + stateData.QosDscpClass.ElementsAs(ctx, &qosDscpClassState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, qosDot1PClassPlan, qosDot1PClassState, qosDscpClassPlan, qosDscpClassState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -406,13 +980,19 @@ func (r *QosCustomPolResource) Update(ctx context.Context, req resource.UpdateRe tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_custom_qos_policy with id '%s'", data.Id.ValueString())) + var qosDot1PClassPlan, qosDot1PClassState []QosDot1PClassQosCustomPolResourceModel + data.QosDot1PClass.ElementsAs(ctx, &qosDot1PClassPlan, false) + stateData.QosDot1PClass.ElementsAs(ctx, &qosDot1PClassState, false) + var qosDscpClassPlan, qosDscpClassState []QosDscpClassQosCustomPolResourceModel + data.QosDscpClass.ElementsAs(ctx, &qosDscpClassPlan, false) + stateData.QosDscpClass.ElementsAs(ctx, &qosDscpClassState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, qosDot1PClassPlan, qosDot1PClassState, qosDscpClassPlan, qosDscpClassState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -466,7 +1046,7 @@ func (r *QosCustomPolResource) ImportState(ctx context.Context, req resource.Imp } func getAndSetQosCustomPolAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *QosCustomPolResourceModel) { - requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "qosCustomPol,tagAnnotation,tagTag"), "GET", nil) + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "qosCustomPol,qosDot1PClass,qosDscpClass,tagAnnotation,tagTag,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil) readData := getEmptyQosCustomPolResourceModel() @@ -501,6 +1081,8 @@ func getAndSetQosCustomPolAttributes(ctx context.Context, diags *diag.Diagnostic readData.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) } } + QosDot1PClassQosCustomPolList := make([]QosDot1PClassQosCustomPolResourceModel, 0) + QosDscpClassQosCustomPolList := make([]QosDscpClassQosCustomPolResourceModel, 0) TagAnnotationQosCustomPolList := make([]TagAnnotationQosCustomPolResourceModel, 0) TagTagQosCustomPolList := make([]TagTagQosCustomPolResourceModel, 0) _, ok := classReadInfo[0].(map[string]interface{})["children"] @@ -509,6 +1091,152 @@ func getAndSetQosCustomPolAttributes(ctx context.Context, diags *diag.Diagnostic for _, child := range children { for childClassName, childClassDetails := range child.(map[string]interface{}) { childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "qosDot1PClass" { + QosDot1PClassQosCustomPol := getEmptyQosDot1PClassQosCustomPolResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + QosDot1PClassQosCustomPol.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "descr" { + QosDot1PClassQosCustomPol.Descr = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "from" { + QosDot1PClassQosCustomPol.From = customTypes.NewQosDot1PClassFromStringValue(childAttributeValue.(string)) + } + if childAttributeName == "name" { + QosDot1PClassQosCustomPol.Name = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "nameAlias" { + QosDot1PClassQosCustomPol.NameAlias = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "prio" { + QosDot1PClassQosCustomPol.Prio = customTypes.NewQosDot1PClassPrioStringValue(childAttributeValue.(string)) + } + if childAttributeName == "target" { + QosDot1PClassQosCustomPol.Target = customTypes.NewQosDot1PClassTargetStringValue(childAttributeValue.(string)) + } + if childAttributeName == "targetCos" { + QosDot1PClassQosCustomPol.TargetCos = customTypes.NewQosDot1PClassTargetCosStringValue(childAttributeValue.(string)) + } + if childAttributeName == "to" { + QosDot1PClassQosCustomPol.To = customTypes.NewQosDot1PClassToStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationQosDot1PClassQosCustomPolList := make([]TagAnnotationQosDot1PClassQosCustomPolResourceModel, 0) + TagTagQosDot1PClassQosCustomPolList := make([]TagTagQosDot1PClassQosCustomPolResourceModel, 0) + childrenOfQosDot1PClassQosCustomPol, childrenOfQosDot1PClassQosCustomPolExist := childClassDetails.(map[string]interface{})["children"] + if childrenOfQosDot1PClassQosCustomPolExist { + for _, childQosDot1PClassQosCustomPol := range childrenOfQosDot1PClassQosCustomPol.([]interface{}) { + for childClassNameQosDot1PClassQosCustomPol, childClassDetailsQosDot1PClassQosCustomPol := range childQosDot1PClassQosCustomPol.(map[string]interface{}) { + if childClassNameQosDot1PClassQosCustomPol == "tagAnnotation" { + TagAnnotationQosDot1PClassQosCustomPol := getEmptyTagAnnotationQosDot1PClassQosCustomPolResourceModel() + tagAnnotationchildAttributeValue := childClassDetailsQosDot1PClassQosCustomPol.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue { + if childAttributeName == "key" { + TagAnnotationQosDot1PClassQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationQosDot1PClassQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationQosDot1PClassQosCustomPolList = append(TagAnnotationQosDot1PClassQosCustomPolList, TagAnnotationQosDot1PClassQosCustomPol) + } + if childClassNameQosDot1PClassQosCustomPol == "tagTag" { + TagTagQosDot1PClassQosCustomPol := getEmptyTagTagQosDot1PClassQosCustomPolResourceModel() + tagTagchildAttributeValue := childClassDetailsQosDot1PClassQosCustomPol.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagTagchildAttributeValue { + if childAttributeName == "key" { + TagTagQosDot1PClassQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagQosDot1PClassQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagQosDot1PClassQosCustomPolList = append(TagTagQosDot1PClassQosCustomPolList, TagTagQosDot1PClassQosCustomPol) + } + } + } + } + TagAnnotationQosDot1PClassQosCustomPolSet, _ := types.SetValueFrom(ctx, TagAnnotationQosDot1PClassQosCustomPolType, TagAnnotationQosDot1PClassQosCustomPolList) + QosDot1PClassQosCustomPol.TagAnnotation = TagAnnotationQosDot1PClassQosCustomPolSet + TagTagQosDot1PClassQosCustomPolSet, _ := types.SetValueFrom(ctx, TagTagQosDot1PClassQosCustomPolType, TagTagQosDot1PClassQosCustomPolList) + QosDot1PClassQosCustomPol.TagTag = TagTagQosDot1PClassQosCustomPolSet + QosDot1PClassQosCustomPolList = append(QosDot1PClassQosCustomPolList, QosDot1PClassQosCustomPol) + } + if childClassName == "qosDscpClass" { + QosDscpClassQosCustomPol := getEmptyQosDscpClassQosCustomPolResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + QosDscpClassQosCustomPol.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "descr" { + QosDscpClassQosCustomPol.Descr = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "from" { + QosDscpClassQosCustomPol.From = customTypes.NewQosDscpClassFromStringValue(childAttributeValue.(string)) + } + if childAttributeName == "name" { + QosDscpClassQosCustomPol.Name = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "nameAlias" { + QosDscpClassQosCustomPol.NameAlias = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "prio" { + QosDscpClassQosCustomPol.Prio = customTypes.NewQosDscpClassPrioStringValue(childAttributeValue.(string)) + } + if childAttributeName == "target" { + QosDscpClassQosCustomPol.Target = customTypes.NewQosDscpClassTargetStringValue(childAttributeValue.(string)) + } + if childAttributeName == "targetCos" { + QosDscpClassQosCustomPol.TargetCos = customTypes.NewQosDscpClassTargetCosStringValue(childAttributeValue.(string)) + } + if childAttributeName == "to" { + QosDscpClassQosCustomPol.To = customTypes.NewQosDscpClassToStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationQosDscpClassQosCustomPolList := make([]TagAnnotationQosDscpClassQosCustomPolResourceModel, 0) + TagTagQosDscpClassQosCustomPolList := make([]TagTagQosDscpClassQosCustomPolResourceModel, 0) + childrenOfQosDscpClassQosCustomPol, childrenOfQosDscpClassQosCustomPolExist := childClassDetails.(map[string]interface{})["children"] + if childrenOfQosDscpClassQosCustomPolExist { + for _, childQosDscpClassQosCustomPol := range childrenOfQosDscpClassQosCustomPol.([]interface{}) { + for childClassNameQosDscpClassQosCustomPol, childClassDetailsQosDscpClassQosCustomPol := range childQosDscpClassQosCustomPol.(map[string]interface{}) { + if childClassNameQosDscpClassQosCustomPol == "tagAnnotation" { + TagAnnotationQosDscpClassQosCustomPol := getEmptyTagAnnotationQosDscpClassQosCustomPolResourceModel() + tagAnnotationchildAttributeValue := childClassDetailsQosDscpClassQosCustomPol.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue { + if childAttributeName == "key" { + TagAnnotationQosDscpClassQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationQosDscpClassQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationQosDscpClassQosCustomPolList = append(TagAnnotationQosDscpClassQosCustomPolList, TagAnnotationQosDscpClassQosCustomPol) + } + if childClassNameQosDscpClassQosCustomPol == "tagTag" { + TagTagQosDscpClassQosCustomPol := getEmptyTagTagQosDscpClassQosCustomPolResourceModel() + tagTagchildAttributeValue := childClassDetailsQosDscpClassQosCustomPol.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagTagchildAttributeValue { + if childAttributeName == "key" { + TagTagQosDscpClassQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagQosDscpClassQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagQosDscpClassQosCustomPolList = append(TagTagQosDscpClassQosCustomPolList, TagTagQosDscpClassQosCustomPol) + } + } + } + } + TagAnnotationQosDscpClassQosCustomPolSet, _ := types.SetValueFrom(ctx, TagAnnotationQosDscpClassQosCustomPolType, TagAnnotationQosDscpClassQosCustomPolList) + QosDscpClassQosCustomPol.TagAnnotation = TagAnnotationQosDscpClassQosCustomPolSet + TagTagQosDscpClassQosCustomPolSet, _ := types.SetValueFrom(ctx, TagTagQosDscpClassQosCustomPolType, TagTagQosDscpClassQosCustomPolList) + QosDscpClassQosCustomPol.TagTag = TagTagQosDscpClassQosCustomPolSet + QosDscpClassQosCustomPolList = append(QosDscpClassQosCustomPolList, QosDscpClassQosCustomPol) + } if childClassName == "tagAnnotation" { TagAnnotationQosCustomPol := getEmptyTagAnnotationQosCustomPolResourceModel() for childAttributeName, childAttributeValue := range childAttributes { @@ -538,6 +1266,10 @@ func getAndSetQosCustomPolAttributes(ctx context.Context, diags *diag.Diagnostic } } } + qosDot1PClassSet, _ := types.SetValueFrom(ctx, readData.QosDot1PClass.ElementType(ctx), QosDot1PClassQosCustomPolList) + readData.QosDot1PClass = qosDot1PClassSet + qosDscpClassSet, _ := types.SetValueFrom(ctx, readData.QosDscpClass.ElementType(ctx), QosDscpClassQosCustomPolList) + readData.QosDscpClass = qosDscpClassSet tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationQosCustomPolList) readData.TagAnnotation = tagAnnotationSet tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagQosCustomPolList) @@ -579,6 +1311,288 @@ func setQosCustomPolId(ctx context.Context, data *QosCustomPolResourceModel) { data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } +func getQosCustomPolQosDot1PClassChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosCustomPolResourceModel, qosDot1PClassQosCustomPolPlan, qosDot1PClassQosCustomPolState []QosDot1PClassQosCustomPolResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.QosDot1PClass.IsNull() && !data.QosDot1PClass.IsUnknown() { + qosDot1PClassIdentifiers := []QosDot1PClassIdentifier{} + for _, qosDot1PClassQosCustomPol := range qosDot1PClassQosCustomPolPlan { + QosDot1PClassQosCustomPolChildren := make([]map[string]interface{}, 0) + childMap := NewAciObject() + if !qosDot1PClassQosCustomPol.Annotation.IsNull() && !qosDot1PClassQosCustomPol.Annotation.IsUnknown() { + childMap.Attributes["annotation"] = qosDot1PClassQosCustomPol.Annotation.ValueString() + } else { + childMap.Attributes["annotation"] = globalAnnotation + } + if !qosDot1PClassQosCustomPol.Descr.IsNull() && !qosDot1PClassQosCustomPol.Descr.IsUnknown() { + childMap.Attributes["descr"] = qosDot1PClassQosCustomPol.Descr.ValueString() + } + if !qosDot1PClassQosCustomPol.From.IsNull() && !qosDot1PClassQosCustomPol.From.IsUnknown() { + childMap.Attributes["from"] = qosDot1PClassQosCustomPol.From.ValueString() + } + if !qosDot1PClassQosCustomPol.Name.IsNull() && !qosDot1PClassQosCustomPol.Name.IsUnknown() { + childMap.Attributes["name"] = qosDot1PClassQosCustomPol.Name.ValueString() + } + if !qosDot1PClassQosCustomPol.NameAlias.IsNull() && !qosDot1PClassQosCustomPol.NameAlias.IsUnknown() { + childMap.Attributes["nameAlias"] = qosDot1PClassQosCustomPol.NameAlias.ValueString() + } + if !qosDot1PClassQosCustomPol.Prio.IsNull() && !qosDot1PClassQosCustomPol.Prio.IsUnknown() { + childMap.Attributes["prio"] = qosDot1PClassQosCustomPol.Prio.ValueString() + } + if !qosDot1PClassQosCustomPol.Target.IsNull() && !qosDot1PClassQosCustomPol.Target.IsUnknown() { + childMap.Attributes["target"] = qosDot1PClassQosCustomPol.Target.ValueString() + } + if !qosDot1PClassQosCustomPol.TargetCos.IsNull() && !qosDot1PClassQosCustomPol.TargetCos.IsUnknown() { + childMap.Attributes["targetCos"] = qosDot1PClassQosCustomPol.TargetCos.ValueString() + } + if !qosDot1PClassQosCustomPol.To.IsNull() && !qosDot1PClassQosCustomPol.To.IsUnknown() { + childMap.Attributes["to"] = qosDot1PClassQosCustomPol.To.ValueString() + } + + var tagAnnotationQosDot1PClassQosCustomPolPlan, tagAnnotationQosDot1PClassQosCustomPolState []TagAnnotationQosDot1PClassQosCustomPolResourceModel + qosDot1PClassQosCustomPol.TagAnnotation.ElementsAs(ctx, &tagAnnotationQosDot1PClassQosCustomPolPlan, false) + for _, tagAnnotationQosDot1PClassQosCustomPolstate := range qosDot1PClassQosCustomPolState { + tagAnnotationQosDot1PClassQosCustomPolstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationQosDot1PClassQosCustomPolState, false) + } + if !qosDot1PClassQosCustomPol.TagAnnotation.IsNull() && !qosDot1PClassQosCustomPol.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationQosDot1PClassQosCustomPol := range tagAnnotationQosDot1PClassQosCustomPolPlan { + tagAnnotationQosDot1PClassQosCustomPolChildMap := NewAciObject() + if !tagAnnotationQosDot1PClassQosCustomPol.Key.IsNull() && !tagAnnotationQosDot1PClassQosCustomPol.Key.IsUnknown() { + tagAnnotationQosDot1PClassQosCustomPolChildMap.Attributes["key"] = tagAnnotationQosDot1PClassQosCustomPol.Key.ValueString() + } + if !tagAnnotationQosDot1PClassQosCustomPol.Value.IsNull() && !tagAnnotationQosDot1PClassQosCustomPol.Value.IsUnknown() { + tagAnnotationQosDot1PClassQosCustomPolChildMap.Attributes["value"] = tagAnnotationQosDot1PClassQosCustomPol.Value.ValueString() + } + QosDot1PClassQosCustomPolChildren = append(QosDot1PClassQosCustomPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationQosDot1PClassQosCustomPolChildMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationQosDot1PClassQosCustomPol.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotationQosDot1PClassQosCustomPol := range tagAnnotationQosDot1PClassQosCustomPolState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotationQosDot1PClassQosCustomPol.Key { + delete = false + break + } + } + if delete { + tagAnnotationQosDot1PClassQosCustomPolChildMapForDelete := NewAciObject() + tagAnnotationQosDot1PClassQosCustomPolChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationQosDot1PClassQosCustomPolChildMapForDelete.Attributes["key"] = tagAnnotationQosDot1PClassQosCustomPol.Key.ValueString() + QosDot1PClassQosCustomPolChildren = append(QosDot1PClassQosCustomPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationQosDot1PClassQosCustomPolChildMapForDelete}) + } + } + } + + var tagTagQosDot1PClassQosCustomPolPlan, tagTagQosDot1PClassQosCustomPolState []TagTagQosDot1PClassQosCustomPolResourceModel + qosDot1PClassQosCustomPol.TagTag.ElementsAs(ctx, &tagTagQosDot1PClassQosCustomPolPlan, false) + for _, tagTagQosDot1PClassQosCustomPolstate := range qosDot1PClassQosCustomPolState { + tagTagQosDot1PClassQosCustomPolstate.TagTag.ElementsAs(ctx, &tagTagQosDot1PClassQosCustomPolState, false) + } + if !qosDot1PClassQosCustomPol.TagTag.IsNull() && !qosDot1PClassQosCustomPol.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagQosDot1PClassQosCustomPol := range tagTagQosDot1PClassQosCustomPolPlan { + tagTagQosDot1PClassQosCustomPolChildMap := NewAciObject() + if !tagTagQosDot1PClassQosCustomPol.Key.IsNull() && !tagTagQosDot1PClassQosCustomPol.Key.IsUnknown() { + tagTagQosDot1PClassQosCustomPolChildMap.Attributes["key"] = tagTagQosDot1PClassQosCustomPol.Key.ValueString() + } + if !tagTagQosDot1PClassQosCustomPol.Value.IsNull() && !tagTagQosDot1PClassQosCustomPol.Value.IsUnknown() { + tagTagQosDot1PClassQosCustomPolChildMap.Attributes["value"] = tagTagQosDot1PClassQosCustomPol.Value.ValueString() + } + QosDot1PClassQosCustomPolChildren = append(QosDot1PClassQosCustomPolChildren, map[string]interface{}{"tagTag": tagTagQosDot1PClassQosCustomPolChildMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagQosDot1PClassQosCustomPol.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTagQosDot1PClassQosCustomPol := range tagTagQosDot1PClassQosCustomPolState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTagQosDot1PClassQosCustomPol.Key { + delete = false + break + } + } + if delete { + tagTagQosDot1PClassQosCustomPolChildMapForDelete := NewAciObject() + tagTagQosDot1PClassQosCustomPolChildMapForDelete.Attributes["status"] = "deleted" + tagTagQosDot1PClassQosCustomPolChildMapForDelete.Attributes["key"] = tagTagQosDot1PClassQosCustomPol.Key.ValueString() + QosDot1PClassQosCustomPolChildren = append(QosDot1PClassQosCustomPolChildren, map[string]interface{}{"tagTag": tagTagQosDot1PClassQosCustomPolChildMapForDelete}) + } + } + } + childMap.Children = QosDot1PClassQosCustomPolChildren + childPayloads = append(childPayloads, map[string]interface{}{"qosDot1PClass": childMap}) + qosDot1PClassIdentifier := QosDot1PClassIdentifier{} + qosDot1PClassIdentifier.From = basetypes.NewStringValue(qosDot1PClassQosCustomPol.From.ValueString()) + qosDot1PClassIdentifier.To = basetypes.NewStringValue(qosDot1PClassQosCustomPol.To.ValueString()) + qosDot1PClassIdentifiers = append(qosDot1PClassIdentifiers, qosDot1PClassIdentifier) + } + for _, qosDot1PClass := range qosDot1PClassQosCustomPolState { + delete := true + for _, qosDot1PClassIdentifier := range qosDot1PClassIdentifiers { + if qosDot1PClassIdentifier.From == basetypes.NewStringValue(qosDot1PClass.From.ValueString()) && + qosDot1PClassIdentifier.To == basetypes.NewStringValue(qosDot1PClass.To.ValueString()) { + delete = false + break + } + } + if delete { + qosDot1PClassChildMapForDelete := NewAciObject() + qosDot1PClassChildMapForDelete.Attributes["status"] = "deleted" + qosDot1PClassChildMapForDelete.Attributes["from"] = qosDot1PClass.From.ValueString() + qosDot1PClassChildMapForDelete.Attributes["to"] = qosDot1PClass.To.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"qosDot1PClass": qosDot1PClassChildMapForDelete}) + } + } + } else { + data.QosDot1PClass = types.SetNull(data.QosDot1PClass.ElementType(ctx)) + } + + return childPayloads +} + +func getQosCustomPolQosDscpClassChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosCustomPolResourceModel, qosDscpClassQosCustomPolPlan, qosDscpClassQosCustomPolState []QosDscpClassQosCustomPolResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.QosDscpClass.IsNull() && !data.QosDscpClass.IsUnknown() { + qosDscpClassIdentifiers := []QosDscpClassIdentifier{} + for _, qosDscpClassQosCustomPol := range qosDscpClassQosCustomPolPlan { + QosDscpClassQosCustomPolChildren := make([]map[string]interface{}, 0) + childMap := NewAciObject() + if !qosDscpClassQosCustomPol.Annotation.IsNull() && !qosDscpClassQosCustomPol.Annotation.IsUnknown() { + childMap.Attributes["annotation"] = qosDscpClassQosCustomPol.Annotation.ValueString() + } else { + childMap.Attributes["annotation"] = globalAnnotation + } + if !qosDscpClassQosCustomPol.Descr.IsNull() && !qosDscpClassQosCustomPol.Descr.IsUnknown() { + childMap.Attributes["descr"] = qosDscpClassQosCustomPol.Descr.ValueString() + } + if !qosDscpClassQosCustomPol.From.IsNull() && !qosDscpClassQosCustomPol.From.IsUnknown() { + childMap.Attributes["from"] = qosDscpClassQosCustomPol.From.ValueString() + } + if !qosDscpClassQosCustomPol.Name.IsNull() && !qosDscpClassQosCustomPol.Name.IsUnknown() { + childMap.Attributes["name"] = qosDscpClassQosCustomPol.Name.ValueString() + } + if !qosDscpClassQosCustomPol.NameAlias.IsNull() && !qosDscpClassQosCustomPol.NameAlias.IsUnknown() { + childMap.Attributes["nameAlias"] = qosDscpClassQosCustomPol.NameAlias.ValueString() + } + if !qosDscpClassQosCustomPol.Prio.IsNull() && !qosDscpClassQosCustomPol.Prio.IsUnknown() { + childMap.Attributes["prio"] = qosDscpClassQosCustomPol.Prio.ValueString() + } + if !qosDscpClassQosCustomPol.Target.IsNull() && !qosDscpClassQosCustomPol.Target.IsUnknown() { + childMap.Attributes["target"] = qosDscpClassQosCustomPol.Target.ValueString() + } + if !qosDscpClassQosCustomPol.TargetCos.IsNull() && !qosDscpClassQosCustomPol.TargetCos.IsUnknown() { + childMap.Attributes["targetCos"] = qosDscpClassQosCustomPol.TargetCos.ValueString() + } + if !qosDscpClassQosCustomPol.To.IsNull() && !qosDscpClassQosCustomPol.To.IsUnknown() { + childMap.Attributes["to"] = qosDscpClassQosCustomPol.To.ValueString() + } + + var tagAnnotationQosDscpClassQosCustomPolPlan, tagAnnotationQosDscpClassQosCustomPolState []TagAnnotationQosDscpClassQosCustomPolResourceModel + qosDscpClassQosCustomPol.TagAnnotation.ElementsAs(ctx, &tagAnnotationQosDscpClassQosCustomPolPlan, false) + for _, tagAnnotationQosDscpClassQosCustomPolstate := range qosDscpClassQosCustomPolState { + tagAnnotationQosDscpClassQosCustomPolstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationQosDscpClassQosCustomPolState, false) + } + if !qosDscpClassQosCustomPol.TagAnnotation.IsNull() && !qosDscpClassQosCustomPol.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationQosDscpClassQosCustomPol := range tagAnnotationQosDscpClassQosCustomPolPlan { + tagAnnotationQosDscpClassQosCustomPolChildMap := NewAciObject() + if !tagAnnotationQosDscpClassQosCustomPol.Key.IsNull() && !tagAnnotationQosDscpClassQosCustomPol.Key.IsUnknown() { + tagAnnotationQosDscpClassQosCustomPolChildMap.Attributes["key"] = tagAnnotationQosDscpClassQosCustomPol.Key.ValueString() + } + if !tagAnnotationQosDscpClassQosCustomPol.Value.IsNull() && !tagAnnotationQosDscpClassQosCustomPol.Value.IsUnknown() { + tagAnnotationQosDscpClassQosCustomPolChildMap.Attributes["value"] = tagAnnotationQosDscpClassQosCustomPol.Value.ValueString() + } + QosDscpClassQosCustomPolChildren = append(QosDscpClassQosCustomPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationQosDscpClassQosCustomPolChildMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationQosDscpClassQosCustomPol.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotationQosDscpClassQosCustomPol := range tagAnnotationQosDscpClassQosCustomPolState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotationQosDscpClassQosCustomPol.Key { + delete = false + break + } + } + if delete { + tagAnnotationQosDscpClassQosCustomPolChildMapForDelete := NewAciObject() + tagAnnotationQosDscpClassQosCustomPolChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationQosDscpClassQosCustomPolChildMapForDelete.Attributes["key"] = tagAnnotationQosDscpClassQosCustomPol.Key.ValueString() + QosDscpClassQosCustomPolChildren = append(QosDscpClassQosCustomPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationQosDscpClassQosCustomPolChildMapForDelete}) + } + } + } + + var tagTagQosDscpClassQosCustomPolPlan, tagTagQosDscpClassQosCustomPolState []TagTagQosDscpClassQosCustomPolResourceModel + qosDscpClassQosCustomPol.TagTag.ElementsAs(ctx, &tagTagQosDscpClassQosCustomPolPlan, false) + for _, tagTagQosDscpClassQosCustomPolstate := range qosDscpClassQosCustomPolState { + tagTagQosDscpClassQosCustomPolstate.TagTag.ElementsAs(ctx, &tagTagQosDscpClassQosCustomPolState, false) + } + if !qosDscpClassQosCustomPol.TagTag.IsNull() && !qosDscpClassQosCustomPol.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagQosDscpClassQosCustomPol := range tagTagQosDscpClassQosCustomPolPlan { + tagTagQosDscpClassQosCustomPolChildMap := NewAciObject() + if !tagTagQosDscpClassQosCustomPol.Key.IsNull() && !tagTagQosDscpClassQosCustomPol.Key.IsUnknown() { + tagTagQosDscpClassQosCustomPolChildMap.Attributes["key"] = tagTagQosDscpClassQosCustomPol.Key.ValueString() + } + if !tagTagQosDscpClassQosCustomPol.Value.IsNull() && !tagTagQosDscpClassQosCustomPol.Value.IsUnknown() { + tagTagQosDscpClassQosCustomPolChildMap.Attributes["value"] = tagTagQosDscpClassQosCustomPol.Value.ValueString() + } + QosDscpClassQosCustomPolChildren = append(QosDscpClassQosCustomPolChildren, map[string]interface{}{"tagTag": tagTagQosDscpClassQosCustomPolChildMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagQosDscpClassQosCustomPol.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTagQosDscpClassQosCustomPol := range tagTagQosDscpClassQosCustomPolState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTagQosDscpClassQosCustomPol.Key { + delete = false + break + } + } + if delete { + tagTagQosDscpClassQosCustomPolChildMapForDelete := NewAciObject() + tagTagQosDscpClassQosCustomPolChildMapForDelete.Attributes["status"] = "deleted" + tagTagQosDscpClassQosCustomPolChildMapForDelete.Attributes["key"] = tagTagQosDscpClassQosCustomPol.Key.ValueString() + QosDscpClassQosCustomPolChildren = append(QosDscpClassQosCustomPolChildren, map[string]interface{}{"tagTag": tagTagQosDscpClassQosCustomPolChildMapForDelete}) + } + } + } + childMap.Children = QosDscpClassQosCustomPolChildren + childPayloads = append(childPayloads, map[string]interface{}{"qosDscpClass": childMap}) + qosDscpClassIdentifier := QosDscpClassIdentifier{} + qosDscpClassIdentifier.From = basetypes.NewStringValue(qosDscpClassQosCustomPol.From.ValueString()) + qosDscpClassIdentifier.To = basetypes.NewStringValue(qosDscpClassQosCustomPol.To.ValueString()) + qosDscpClassIdentifiers = append(qosDscpClassIdentifiers, qosDscpClassIdentifier) + } + for _, qosDscpClass := range qosDscpClassQosCustomPolState { + delete := true + for _, qosDscpClassIdentifier := range qosDscpClassIdentifiers { + if qosDscpClassIdentifier.From == basetypes.NewStringValue(qosDscpClass.From.ValueString()) && + qosDscpClassIdentifier.To == basetypes.NewStringValue(qosDscpClass.To.ValueString()) { + delete = false + break + } + } + if delete { + qosDscpClassChildMapForDelete := NewAciObject() + qosDscpClassChildMapForDelete.Attributes["status"] = "deleted" + qosDscpClassChildMapForDelete.Attributes["from"] = qosDscpClass.From.ValueString() + qosDscpClassChildMapForDelete.Attributes["to"] = qosDscpClass.To.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"qosDscpClass": qosDscpClassChildMapForDelete}) + } + } + } else { + data.QosDscpClass = types.SetNull(data.QosDscpClass.ElementType(ctx)) + } + + return childPayloads +} + func getQosCustomPolTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosCustomPolResourceModel, tagAnnotationQosCustomPolPlan, tagAnnotationQosCustomPolState []TagAnnotationQosCustomPolResourceModel) []map[string]interface{} { childPayloads := []map[string]interface{}{} if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { @@ -657,7 +1671,7 @@ func getQosCustomPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getQosCustomPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosCustomPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel, tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel) *container.Container { +func getQosCustomPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosCustomPolResourceModel, qosDot1PClassPlan, qosDot1PClassState []QosDot1PClassQosCustomPolResourceModel, qosDscpClassPlan, qosDscpClassState []QosDscpClassQosCustomPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel, tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} @@ -666,6 +1680,18 @@ func getQosCustomPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnosti } childPayloads := []map[string]interface{}{} + QosDot1PClasschildPayloads := getQosCustomPolQosDot1PClassChildPayloads(ctx, diags, data, qosDot1PClassPlan, qosDot1PClassState) + if QosDot1PClasschildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, QosDot1PClasschildPayloads...) + + QosDscpClasschildPayloads := getQosCustomPolQosDscpClassChildPayloads(ctx, diags, data, qosDscpClassPlan, qosDscpClassState) + if QosDscpClasschildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, QosDscpClasschildPayloads...) + TagAnnotationchildPayloads := getQosCustomPolTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) if TagAnnotationchildPayloads == nil { return nil diff --git a/internal/provider/resource_aci_custom_qos_policy_test.go b/internal/provider/resource_aci_custom_qos_policy_test.go index b0e384336..ac92debfd 100644 --- a/internal/provider/resource_aci_custom_qos_policy_test.go +++ b/internal/provider/resource_aci_custom_qos_policy_test.go @@ -151,6 +151,42 @@ func TestAccResourceQosCustomPolWithFvTenant(t *testing.T) { resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.from", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.priority", "level1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.target", "AF11"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.target_cos", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.to", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.description", "description_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.from", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.name", "name_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.name_alias", "name_alias_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.priority", "level2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.target", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.target_cos", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.to", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.from", "AF11"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.priority", "level1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.target", "AF11"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.target_cos", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.to", "AF11"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.description", "description_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.from", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.name", "name_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.name_alias", "name_alias_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.priority", "level2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.target", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.target_cos", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.to", "AF12"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.1.key", "key_1"), @@ -178,6 +214,84 @@ func TestAccResourceQosCustomPolWithFvTenant(t *testing.T) { resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.from", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.priority", "level1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.target", "AF11"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.target_cos", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.to", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.description", "description_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.from", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.name", "name_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.name_alias", "name_alias_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.priority", "level2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.target", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.target_cos", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.1.to", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.from", "AF11"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.priority", "level1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.target", "AF11"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.target_cos", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.to", "AF11"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.#", "2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.description", "description_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.from", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.name", "name_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.name_alias", "name_alias_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.priority", "level2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.target", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.target_cos", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.1.to", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.#", "2"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.1.key", "key_1"), @@ -193,6 +307,38 @@ func TestAccResourceQosCustomPolWithFvTenant(t *testing.T) { resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.0.key", "key_1"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.0.value", "test_value"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.annotations.#", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.tags.#", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.description", "description_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.from", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.name", "name_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.name_alias", "name_alias_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.priority", "level2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.target", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.target_cos", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.0.to", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.#", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.annotations.#", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.tags.#", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.description", "description_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.from", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.name", "name_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.name_alias", "name_alias_2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.priority", "level2"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.target", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.target_cos", "1"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.0.to", "AF12"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.#", "1"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.0.key", "key_1"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.0.value", "test_value"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.#", "1"), @@ -204,6 +350,8 @@ func TestAccResourceQosCustomPolWithFvTenant(t *testing.T) { ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dot1p_classifiers.#", "0"), + resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "dscp_to_priority_maps.#", "0"), resource.TestCheckResourceAttr("aci_custom_qos_policy.test", "tags.#", "0"), ), }, @@ -268,6 +416,134 @@ resource "aci_custom_qos_policy" "test" { value = "test_value" }, ] + dot1p_classifiers = [ + { + annotation = "annotation_1" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + description = "description_1" + from = "0" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "0" + }, + { + annotation = "annotation_2" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + description = "description_2" + from = "1" + name = "name_2" + name_alias = "name_alias_2" + priority = "level2" + target = "AF12" + target_cos = "1" + to = "1" + }, + ] + dscp_to_priority_maps = [ + { + annotation = "annotation_1" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + description = "description_1" + from = "AF11" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "AF11" + }, + { + annotation = "annotation_2" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + description = "description_2" + from = "AF12" + name = "name_2" + name_alias = "name_alias_2" + priority = "level2" + target = "AF12" + target_cos = "1" + to = "AF12" + }, + ] tags = [ { key = "key_0" @@ -298,6 +574,56 @@ resource "aci_custom_qos_policy" "test" { value = "test_value" }, ] + dot1p_classifiers = [ + { + annotation = "annotation_2" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] + description = "description_2" + from = "1" + name = "name_2" + name_alias = "name_alias_2" + priority = "level2" + target = "AF12" + target_cos = "1" + to = "1" + }, + ] + dscp_to_priority_maps = [ + { + annotation = "annotation_2" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] + description = "description_2" + from = "AF12" + name = "name_2" + name_alias = "name_alias_2" + priority = "level2" + target = "AF12" + target_cos = "1" + to = "AF12" + }, + ] tags = [ { key = "key_1" @@ -312,6 +638,8 @@ resource "aci_custom_qos_policy" "test" { parent_dn = aci_tenant.test.id name = "test_name" annotations = [] + dot1p_classifiers = [] + dscp_to_priority_maps = [] tags = [] } ` diff --git a/internal/provider/resource_aci_dot1p_classifier.go b/internal/provider/resource_aci_dot1p_classifier.go new file mode 100644 index 000000000..0111ca06a --- /dev/null +++ b/internal/provider/resource_aci_dot1p_classifier.go @@ -0,0 +1,810 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &QosDot1PClassResource{} +var _ resource.ResourceWithImportState = &QosDot1PClassResource{} + +func NewQosDot1PClassResource() resource.Resource { + return &QosDot1PClassResource{} +} + +// QosDot1PClassResource defines the resource implementation. +type QosDot1PClassResource struct { + client *client.Client +} + +// QosDot1PClassResourceModel describes the resource data model. +type QosDot1PClassResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + From customTypes.QosDot1PClassFromStringValue `tfsdk:"from"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + Prio customTypes.QosDot1PClassPrioStringValue `tfsdk:"priority"` + Target customTypes.QosDot1PClassTargetStringValue `tfsdk:"target"` + TargetCos customTypes.QosDot1PClassTargetCosStringValue `tfsdk:"target_cos"` + To customTypes.QosDot1PClassToStringValue `tfsdk:"to"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyQosDot1PClassResourceModel() *QosDot1PClassResourceModel { + return &QosDot1PClassResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + From: customTypes.NewQosDot1PClassFromStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + Prio: customTypes.NewQosDot1PClassPrioStringNull(), + Target: customTypes.NewQosDot1PClassTargetStringNull(), + TargetCos: customTypes.NewQosDot1PClassTargetCosStringNull(), + To: customTypes.NewQosDot1PClassToStringNull(), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +// TagAnnotationQosDot1PClassResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationQosDot1PClassResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationQosDot1PClassResourceModel() TagAnnotationQosDot1PClassResourceModel { + return TagAnnotationQosDot1PClassResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationQosDot1PClassType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagQosDot1PClassResourceModel describes the resource data model for the children without relation ships. +type TagTagQosDot1PClassResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagQosDot1PClassResourceModel() TagTagQosDot1PClassResourceModel { + return TagTagQosDot1PClassResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagQosDot1PClassType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type QosDot1PClassIdentifier struct { + From types.String + To types.String +} + +func (r *QosDot1PClassResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *QosDot1PClassResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.From.IsUnknown() && !planData.To.IsUnknown() { + setQosDot1PClassId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "qosDot1PClass", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *QosDot1PClassResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_dot1p_classifier") + resp.TypeName = req.ProviderTypeName + "_dot1p_classifier" + tflog.Debug(ctx, "End metadata of resource: aci_dot1p_classifier") +} + +func (r *QosDot1PClassResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_dot1p_classifier") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The dot1p_classifier resource for the 'qosDot1PClass' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Dot1p Classifier object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Dot1p Classifier object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Dot1p Classifier object.`, + }, + "from": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassFromStringType{}, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"), + validators.InBetweenFromString(0, 8), + ), + }, + MarkdownDescription: `The Dot1p priority range starting value.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name of the Dot1p Classifier object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Dot1p Classifier object.`, + }, + "priority": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassPrioStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("level1", "level2", "level3", "level4", "level5", "level6", "unspecified"), + validators.InBetweenFromString(0, 9), + ), + }, + MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`, + }, + "target": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassTargetStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA", "unspecified"), + validators.InBetweenFromString(0, 64), + ), + }, + MarkdownDescription: `The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`, + }, + "target_cos": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassTargetCosStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"), + validators.InBetweenFromString(0, 8), + ), + }, + MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`, + }, + "to": schema.StringAttribute{ + CustomType: customTypes.QosDot1PClassToStringType{}, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"), + validators.InBetweenFromString(0, 8), + ), + }, + MarkdownDescription: `The Dot1p priority range ending value.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_dot1p_classifier") +} + +func (r *QosDot1PClassResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_dot1p_classifier") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client + tflog.Debug(ctx, "End configure of resource: aci_dot1p_classifier") +} + +func (r *QosDot1PClassResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_dot1p_classifier") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *QosDot1PClassResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setQosDot1PClassId(ctx, stateData) + } + getAndSetQosDot1PClassAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The qosDot1PClass object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *QosDot1PClassResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if data.Id.IsUnknown() || data.Id.IsNull() { + setQosDot1PClassId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDot1PClassResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagQosDot1PClassResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getQosDot1PClassCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetQosDot1PClassAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) +} + +func (r *QosDot1PClassResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_dot1p_classifier") + var data *QosDot1PClassResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) + + getAndSetQosDot1PClassAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *QosDot1PClassResourceModel + resp.Diagnostics.Append(resp.State.Set(ctx, &emptyData)...) + } else { + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + } + + tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) +} + +func (r *QosDot1PClassResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_dot1p_classifier") + var data *QosDot1PClassResourceModel + var stateData *QosDot1PClassResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDot1PClassResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagQosDot1PClassResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getQosDot1PClassCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetQosDot1PClassAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) +} + +func (r *QosDot1PClassResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_dot1p_classifier") + var data *QosDot1PClassResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "qosDot1PClass", data.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_dot1p_classifier with id '%s'", data.Id.ValueString())) +} + +func (r *QosDot1PClassResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_dot1p_classifier") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *QosDot1PClassResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_dot1p_classifier with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_dot1p_classifier") +} + +func getAndSetQosDot1PClassAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *QosDot1PClassResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "qosDot1PClass,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyQosDot1PClassResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("qosDot1PClass").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("qosDot1PClass").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + readData.Id = basetypes.NewStringValue(attributeValue.(string)) + setQosDot1PClassParentDn(ctx, attributeValue.(string), readData) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "from" { + readData.From = customTypes.NewQosDot1PClassFromStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "prio" { + readData.Prio = customTypes.NewQosDot1PClassPrioStringValue(attributeValue.(string)) + } + if attributeName == "target" { + readData.Target = customTypes.NewQosDot1PClassTargetStringValue(attributeValue.(string)) + } + if attributeName == "targetCos" { + readData.TargetCos = customTypes.NewQosDot1PClassTargetCosStringValue(attributeValue.(string)) + } + if attributeName == "to" { + readData.To = customTypes.NewQosDot1PClassToStringValue(attributeValue.(string)) + } + } + TagAnnotationQosDot1PClassList := make([]TagAnnotationQosDot1PClassResourceModel, 0) + TagTagQosDot1PClassList := make([]TagTagQosDot1PClassResourceModel, 0) + _, ok := classReadInfo[0].(map[string]interface{})["children"] + if ok { + children := classReadInfo[0].(map[string]interface{})["children"].([]interface{}) + for _, child := range children { + for childClassName, childClassDetails := range child.(map[string]interface{}) { + childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "tagAnnotation" { + TagAnnotationQosDot1PClass := getEmptyTagAnnotationQosDot1PClassResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationQosDot1PClass.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationQosDot1PClass.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationQosDot1PClassList = append(TagAnnotationQosDot1PClassList, TagAnnotationQosDot1PClass) + } + if childClassName == "tagTag" { + TagTagQosDot1PClass := getEmptyTagTagQosDot1PClassResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagQosDot1PClass.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagQosDot1PClass.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagQosDot1PClassList = append(TagTagQosDot1PClassList, TagTagQosDot1PClass) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationQosDot1PClassList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagQosDot1PClassList) + readData.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'qosDot1PClass'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getQosDot1PClassRn(ctx context.Context, data *QosDot1PClassResourceModel) string { + return fmt.Sprintf("dot1P-%s-%s", data.From.NamedValueString(), data.To.NamedValueString()) +} + +func setQosDot1PClassParentDn(ctx context.Context, dn string, data *QosDot1PClassResourceModel) { + bracketIndex := 0 + rnIndex := 0 + for i := len(dn) - 1; i >= 0; i-- { + if string(dn[i]) == "]" { + bracketIndex = bracketIndex + 1 + } else if string(dn[i]) == "[" { + bracketIndex = bracketIndex - 1 + } else if string(dn[i]) == "/" && bracketIndex == 0 { + rnIndex = i + break + } + } + data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) +} + +func setQosDot1PClassId(ctx context.Context, data *QosDot1PClassResourceModel) { + rn := getQosDot1PClassRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getQosDot1PClassTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosDot1PClassResourceModel, tagAnnotationQosDot1PClassPlan, tagAnnotationQosDot1PClassState []TagAnnotationQosDot1PClassResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationQosDot1PClass := range tagAnnotationQosDot1PClassPlan { + childMap := NewAciObject() + if !tagAnnotationQosDot1PClass.Key.IsNull() && !tagAnnotationQosDot1PClass.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationQosDot1PClass.Key.ValueString() + } + if !tagAnnotationQosDot1PClass.Value.IsNull() && !tagAnnotationQosDot1PClass.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationQosDot1PClass.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationQosDot1PClass.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationQosDot1PClassState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + tagAnnotationChildMapForDelete := NewAciObject() + tagAnnotationChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} + +func getQosDot1PClassTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosDot1PClassResourceModel, tagTagQosDot1PClassPlan, tagTagQosDot1PClassState []TagTagQosDot1PClassResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagQosDot1PClass := range tagTagQosDot1PClassPlan { + childMap := NewAciObject() + if !tagTagQosDot1PClass.Key.IsNull() && !tagTagQosDot1PClass.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagQosDot1PClass.Key.ValueString() + } + if !tagTagQosDot1PClass.Value.IsNull() && !tagTagQosDot1PClass.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagQosDot1PClass.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagQosDot1PClass.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagQosDot1PClassState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + tagTagChildMapForDelete := NewAciObject() + tagTagChildMapForDelete.Attributes["status"] = "deleted" + tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getQosDot1PClassCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosDot1PClassResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDot1PClassResourceModel, tagTagPlan, tagTagState []TagTagQosDot1PClassResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + + if createType && !globalAllowExistingOnCreate { + payloadMap["attributes"].(map[string]string)["status"] = "created" + } + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getQosDot1PClassTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getQosDot1PClassTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.From.IsNull() && !data.From.IsUnknown() { + payloadMap["attributes"].(map[string]string)["from"] = data.From.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + if !data.Prio.IsNull() && !data.Prio.IsUnknown() { + payloadMap["attributes"].(map[string]string)["prio"] = data.Prio.ValueString() + } + if !data.Target.IsNull() && !data.Target.IsUnknown() { + payloadMap["attributes"].(map[string]string)["target"] = data.Target.ValueString() + } + if !data.TargetCos.IsNull() && !data.TargetCos.IsUnknown() { + payloadMap["attributes"].(map[string]string)["targetCos"] = data.TargetCos.ValueString() + } + if !data.To.IsNull() && !data.To.IsUnknown() { + payloadMap["attributes"].(map[string]string)["to"] = data.To.ValueString() + } + payload, err := json.Marshal(map[string]interface{}{"qosDot1PClass": payloadMap}) + if err != nil { + diags.AddError( + "Marshalling of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + jsonPayload, err := container.ParseJSON(payload) + + if err != nil { + diags.AddError( + "Construction of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + return jsonPayload +} diff --git a/internal/provider/resource_aci_dot1p_classifier_test.go b/internal/provider/resource_aci_dot1p_classifier_test.go new file mode 100644 index 000000000..06cbd08ea --- /dev/null +++ b/internal/provider/resource_aci_dot1p_classifier_test.go @@ -0,0 +1,378 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourceQosDot1PClassWithQosCustomPol(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigQosDot1PClassMinDependencyWithQosCustomPolAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "from", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "from", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "to", "2"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "to", "2"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigQosDot1PClassMinDependencyWithQosCustomPolAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigQosDot1PClassMinDependencyWithQosCustomPolAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "from", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "from", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test", "to", "2"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.allow_test_2", "to", "2"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigQosDot1PClassMinDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "description", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "from", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "name", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "to", "2"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigQosDot1PClassAllDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "from", "4"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "name", "name_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "priority", "level1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target", "AF11"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target_cos", "0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "to", "5"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigQosDot1PClassMinDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "from", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "to", "2"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigQosDot1PClassResetDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "from", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "to", "2"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "description", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "name", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target_cos", "unspecified"), + ), + }, + // Import testing + { + ResourceName: "aci_dot1p_classifier.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigQosDot1PClassChildrenDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "from", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "to", "2"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "description", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "name", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.1.value", "test_value"), + ), + }, + // Refresh State before import testing to ensure that the state is up to date + { + RefreshState: true, + ExpectNonEmptyPlan: false, + }, + // Import testing with children + { + ResourceName: "aci_dot1p_classifier.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigQosDot1PClassChildrenRemoveFromConfigDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigQosDot1PClassChildrenRemoveOneDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigQosDot1PClassChildrenRemoveAllDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "tags.#", "0"), + ), + }, + // Update with minimum config and custom type semantic equivalent values + { + Config: testConfigQosDot1PClassCustomTypeDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "from", "0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "priority", "1"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target", "0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "target_cos", "0"), + resource.TestCheckResourceAttr("aci_dot1p_classifier.test", "to", "0"), + ), + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testConfigQosDot1PClassMinDependencyWithQosCustomPolAllowExisting = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "allow_test" { + parent_dn = aci_custom_qos_policy.test.id + from = "1" + to = "2" +} +resource "aci_dot1p_classifier" "allow_test_2" { + parent_dn = aci_custom_qos_policy.test.id + from = "1" + to = "2" + depends_on = [aci_dot1p_classifier.allow_test] +} +` + +const testConfigQosDot1PClassMinDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "1" + to = "2" +} +` + +const testConfigQosDot1PClassAllDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + annotation = "annotation" + description = "description_1" + from = "4" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" + to = "5" +} +` + +const testConfigQosDot1PClassResetDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + annotation = "orchestrator:terraform" + description = "" + from = "1" + name = "" + name_alias = "" + priority = "unspecified" + target = "unspecified" + target_cos = "unspecified" + to = "2" +} +` +const testConfigQosDot1PClassChildrenDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "1" + to = "2" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigQosDot1PClassChildrenRemoveFromConfigDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "1" + to = "2" +} +` + +const testConfigQosDot1PClassChildrenRemoveOneDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "1" + to = "2" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigQosDot1PClassChildrenRemoveAllDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "1" + to = "2" + annotations = [] + tags = [] +} +` + +const testConfigQosDot1PClassCustomTypeDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dot1p_classifier" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "0" + priority = "1" + target = "0" + target_cos = "0" + to = "0" +} +` diff --git a/internal/provider/resource_aci_dscp_to_priority_map.go b/internal/provider/resource_aci_dscp_to_priority_map.go new file mode 100644 index 000000000..5d2009847 --- /dev/null +++ b/internal/provider/resource_aci_dscp_to_priority_map.go @@ -0,0 +1,810 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &QosDscpClassResource{} +var _ resource.ResourceWithImportState = &QosDscpClassResource{} + +func NewQosDscpClassResource() resource.Resource { + return &QosDscpClassResource{} +} + +// QosDscpClassResource defines the resource implementation. +type QosDscpClassResource struct { + client *client.Client +} + +// QosDscpClassResourceModel describes the resource data model. +type QosDscpClassResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + From customTypes.QosDscpClassFromStringValue `tfsdk:"from"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + Prio customTypes.QosDscpClassPrioStringValue `tfsdk:"priority"` + Target customTypes.QosDscpClassTargetStringValue `tfsdk:"target"` + TargetCos customTypes.QosDscpClassTargetCosStringValue `tfsdk:"target_cos"` + To customTypes.QosDscpClassToStringValue `tfsdk:"to"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyQosDscpClassResourceModel() *QosDscpClassResourceModel { + return &QosDscpClassResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + From: customTypes.NewQosDscpClassFromStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + Prio: customTypes.NewQosDscpClassPrioStringNull(), + Target: customTypes.NewQosDscpClassTargetStringNull(), + TargetCos: customTypes.NewQosDscpClassTargetCosStringNull(), + To: customTypes.NewQosDscpClassToStringNull(), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +// TagAnnotationQosDscpClassResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationQosDscpClassResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationQosDscpClassResourceModel() TagAnnotationQosDscpClassResourceModel { + return TagAnnotationQosDscpClassResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationQosDscpClassType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagQosDscpClassResourceModel describes the resource data model for the children without relation ships. +type TagTagQosDscpClassResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagQosDscpClassResourceModel() TagTagQosDscpClassResourceModel { + return TagTagQosDscpClassResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagQosDscpClassType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type QosDscpClassIdentifier struct { + From types.String + To types.String +} + +func (r *QosDscpClassResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *QosDscpClassResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.From.IsUnknown() && !planData.To.IsUnknown() { + setQosDscpClassId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "qosDscpClass", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *QosDscpClassResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_dscp_to_priority_map") + resp.TypeName = req.ProviderTypeName + "_dscp_to_priority_map" + tflog.Debug(ctx, "End metadata of resource: aci_dscp_to_priority_map") +} + +func (r *QosDscpClassResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_dscp_to_priority_map") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The dscp_to_priority_map resource for the 'qosDscpClass' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the DSCP to Priority Map object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the DSCP to Priority Map object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the DSCP to Priority Map object.`, + }, + "from": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassFromStringType{}, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA"), + validators.InBetweenFromString(0, 63), + ), + }, + MarkdownDescription: `The DSCP range starting value.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name of the DSCP to Priority Map object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the DSCP to Priority Map object.`, + }, + "priority": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassPrioStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("level1", "level2", "level3", "level4", "level5", "level6", "unspecified"), + validators.InBetweenFromString(0, 9), + ), + }, + MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`, + }, + "target": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassTargetStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA", "unspecified"), + validators.InBetweenFromString(0, 64), + ), + }, + MarkdownDescription: `The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`, + }, + "target_cos": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassTargetCosStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"), + validators.InBetweenFromString(0, 8), + ), + }, + MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`, + }, + "to": schema.StringAttribute{ + CustomType: customTypes.QosDscpClassToStringType{}, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA"), + validators.InBetweenFromString(0, 63), + ), + }, + MarkdownDescription: `The DSCP range ending value.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_dscp_to_priority_map") +} + +func (r *QosDscpClassResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_dscp_to_priority_map") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client + tflog.Debug(ctx, "End configure of resource: aci_dscp_to_priority_map") +} + +func (r *QosDscpClassResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_dscp_to_priority_map") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *QosDscpClassResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setQosDscpClassId(ctx, stateData) + } + getAndSetQosDscpClassAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The qosDscpClass object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *QosDscpClassResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if data.Id.IsUnknown() || data.Id.IsNull() { + setQosDscpClassId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDscpClassResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagQosDscpClassResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getQosDscpClassCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetQosDscpClassAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) +} + +func (r *QosDscpClassResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_dscp_to_priority_map") + var data *QosDscpClassResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) + + getAndSetQosDscpClassAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *QosDscpClassResourceModel + resp.Diagnostics.Append(resp.State.Set(ctx, &emptyData)...) + } else { + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + } + + tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) +} + +func (r *QosDscpClassResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_dscp_to_priority_map") + var data *QosDscpClassResourceModel + var stateData *QosDscpClassResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDscpClassResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagQosDscpClassResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getQosDscpClassCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetQosDscpClassAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) +} + +func (r *QosDscpClassResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_dscp_to_priority_map") + var data *QosDscpClassResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "qosDscpClass", data.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_dscp_to_priority_map with id '%s'", data.Id.ValueString())) +} + +func (r *QosDscpClassResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_dscp_to_priority_map") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *QosDscpClassResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_dscp_to_priority_map with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_dscp_to_priority_map") +} + +func getAndSetQosDscpClassAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *QosDscpClassResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "qosDscpClass,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyQosDscpClassResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("qosDscpClass").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("qosDscpClass").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + readData.Id = basetypes.NewStringValue(attributeValue.(string)) + setQosDscpClassParentDn(ctx, attributeValue.(string), readData) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "from" { + readData.From = customTypes.NewQosDscpClassFromStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "prio" { + readData.Prio = customTypes.NewQosDscpClassPrioStringValue(attributeValue.(string)) + } + if attributeName == "target" { + readData.Target = customTypes.NewQosDscpClassTargetStringValue(attributeValue.(string)) + } + if attributeName == "targetCos" { + readData.TargetCos = customTypes.NewQosDscpClassTargetCosStringValue(attributeValue.(string)) + } + if attributeName == "to" { + readData.To = customTypes.NewQosDscpClassToStringValue(attributeValue.(string)) + } + } + TagAnnotationQosDscpClassList := make([]TagAnnotationQosDscpClassResourceModel, 0) + TagTagQosDscpClassList := make([]TagTagQosDscpClassResourceModel, 0) + _, ok := classReadInfo[0].(map[string]interface{})["children"] + if ok { + children := classReadInfo[0].(map[string]interface{})["children"].([]interface{}) + for _, child := range children { + for childClassName, childClassDetails := range child.(map[string]interface{}) { + childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "tagAnnotation" { + TagAnnotationQosDscpClass := getEmptyTagAnnotationQosDscpClassResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationQosDscpClass.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationQosDscpClass.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationQosDscpClassList = append(TagAnnotationQosDscpClassList, TagAnnotationQosDscpClass) + } + if childClassName == "tagTag" { + TagTagQosDscpClass := getEmptyTagTagQosDscpClassResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagQosDscpClass.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagQosDscpClass.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagQosDscpClassList = append(TagTagQosDscpClassList, TagTagQosDscpClass) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationQosDscpClassList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagQosDscpClassList) + readData.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'qosDscpClass'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getQosDscpClassRn(ctx context.Context, data *QosDscpClassResourceModel) string { + return fmt.Sprintf("dcsp-%s-%s", data.From.NamedValueString(), data.To.NamedValueString()) +} + +func setQosDscpClassParentDn(ctx context.Context, dn string, data *QosDscpClassResourceModel) { + bracketIndex := 0 + rnIndex := 0 + for i := len(dn) - 1; i >= 0; i-- { + if string(dn[i]) == "]" { + bracketIndex = bracketIndex + 1 + } else if string(dn[i]) == "[" { + bracketIndex = bracketIndex - 1 + } else if string(dn[i]) == "/" && bracketIndex == 0 { + rnIndex = i + break + } + } + data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) +} + +func setQosDscpClassId(ctx context.Context, data *QosDscpClassResourceModel) { + rn := getQosDscpClassRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getQosDscpClassTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosDscpClassResourceModel, tagAnnotationQosDscpClassPlan, tagAnnotationQosDscpClassState []TagAnnotationQosDscpClassResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationQosDscpClass := range tagAnnotationQosDscpClassPlan { + childMap := NewAciObject() + if !tagAnnotationQosDscpClass.Key.IsNull() && !tagAnnotationQosDscpClass.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationQosDscpClass.Key.ValueString() + } + if !tagAnnotationQosDscpClass.Value.IsNull() && !tagAnnotationQosDscpClass.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationQosDscpClass.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationQosDscpClass.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationQosDscpClassState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + tagAnnotationChildMapForDelete := NewAciObject() + tagAnnotationChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} + +func getQosDscpClassTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosDscpClassResourceModel, tagTagQosDscpClassPlan, tagTagQosDscpClassState []TagTagQosDscpClassResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagQosDscpClass := range tagTagQosDscpClassPlan { + childMap := NewAciObject() + if !tagTagQosDscpClass.Key.IsNull() && !tagTagQosDscpClass.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagQosDscpClass.Key.ValueString() + } + if !tagTagQosDscpClass.Value.IsNull() && !tagTagQosDscpClass.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagQosDscpClass.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagQosDscpClass.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagQosDscpClassState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + tagTagChildMapForDelete := NewAciObject() + tagTagChildMapForDelete.Attributes["status"] = "deleted" + tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getQosDscpClassCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosDscpClassResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDscpClassResourceModel, tagTagPlan, tagTagState []TagTagQosDscpClassResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + + if createType && !globalAllowExistingOnCreate { + payloadMap["attributes"].(map[string]string)["status"] = "created" + } + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getQosDscpClassTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getQosDscpClassTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.From.IsNull() && !data.From.IsUnknown() { + payloadMap["attributes"].(map[string]string)["from"] = data.From.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + if !data.Prio.IsNull() && !data.Prio.IsUnknown() { + payloadMap["attributes"].(map[string]string)["prio"] = data.Prio.ValueString() + } + if !data.Target.IsNull() && !data.Target.IsUnknown() { + payloadMap["attributes"].(map[string]string)["target"] = data.Target.ValueString() + } + if !data.TargetCos.IsNull() && !data.TargetCos.IsUnknown() { + payloadMap["attributes"].(map[string]string)["targetCos"] = data.TargetCos.ValueString() + } + if !data.To.IsNull() && !data.To.IsUnknown() { + payloadMap["attributes"].(map[string]string)["to"] = data.To.ValueString() + } + payload, err := json.Marshal(map[string]interface{}{"qosDscpClass": payloadMap}) + if err != nil { + diags.AddError( + "Marshalling of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + jsonPayload, err := container.ParseJSON(payload) + + if err != nil { + diags.AddError( + "Construction of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + return jsonPayload +} diff --git a/internal/provider/resource_aci_dscp_to_priority_map_test.go b/internal/provider/resource_aci_dscp_to_priority_map_test.go new file mode 100644 index 000000000..a57cbfd2e --- /dev/null +++ b/internal/provider/resource_aci_dscp_to_priority_map_test.go @@ -0,0 +1,378 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourceQosDscpClassWithQosCustomPol(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigQosDscpClassMinDependencyWithQosCustomPolAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "to", "AF22"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "to", "AF22"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "target_cos", "unspecified"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigQosDscpClassMinDependencyWithQosCustomPolAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigQosDscpClassMinDependencyWithQosCustomPolAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "to", "AF22"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "to", "AF22"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.allow_test_2", "target_cos", "unspecified"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigQosDscpClassMinDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "to", "AF22"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "description", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "name", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target_cos", "unspecified"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigQosDscpClassAllDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "to", "AF22"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "name", "name_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "priority", "level1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target_cos", "0"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigQosDscpClassMinDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "to", "AF22"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigQosDscpClassResetDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "to", "AF22"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "description", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "name", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target_cos", "unspecified"), + ), + }, + // Import testing + { + ResourceName: "aci_dscp_to_priority_map.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigQosDscpClassChildrenDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "from", "AF11"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "to", "AF22"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "description", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "name", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "priority", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target_cos", "unspecified"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.1.value", "test_value"), + ), + }, + // Refresh State before import testing to ensure that the state is up to date + { + RefreshState: true, + ExpectNonEmptyPlan: false, + }, + // Import testing with children + { + ResourceName: "aci_dscp_to_priority_map.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigQosDscpClassChildrenRemoveFromConfigDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigQosDscpClassChildrenRemoveOneDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigQosDscpClassChildrenRemoveAllDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "tags.#", "0"), + ), + }, + // Update with minimum config and custom type semantic equivalent values + { + Config: testConfigQosDscpClassCustomTypeDependencyWithQosCustomPol, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "from", "0"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "priority", "1"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target", "0"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "target_cos", "0"), + resource.TestCheckResourceAttr("aci_dscp_to_priority_map.test", "to", "0"), + ), + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testConfigQosDscpClassMinDependencyWithQosCustomPolAllowExisting = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "allow_test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" +} +resource "aci_dscp_to_priority_map" "allow_test_2" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" + depends_on = [aci_dscp_to_priority_map.allow_test] +} +` + +const testConfigQosDscpClassMinDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" +} +` + +const testConfigQosDscpClassAllDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + priority = "level1" + target = "AF11" + target_cos = "0" +} +` + +const testConfigQosDscpClassResetDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" + annotation = "orchestrator:terraform" + description = "" + name = "" + name_alias = "" + priority = "unspecified" + target = "unspecified" + target_cos = "unspecified" +} +` +const testConfigQosDscpClassChildrenDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigQosDscpClassChildrenRemoveFromConfigDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" +} +` + +const testConfigQosDscpClassChildrenRemoveOneDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigQosDscpClassChildrenRemoveAllDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "AF11" + to = "AF22" + annotations = [] + tags = [] +} +` + +const testConfigQosDscpClassCustomTypeDependencyWithQosCustomPol = testConfigQosCustomPolMinDependencyWithFvTenant + ` +resource "aci_dscp_to_priority_map" "test" { + parent_dn = aci_custom_qos_policy.test.id + from = "0" + priority = "1" + target = "0" + target_cos = "0" + to = "0" +} +`