diff --git a/docs/data-sources/storm_control_interface_policy.md b/docs/data-sources/storm_control_interface_policy.md new file mode 100644 index 000000000..0d1c11f7b --- /dev/null +++ b/docs/data-sources/storm_control_interface_policy.md @@ -0,0 +1,77 @@ +--- +# 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: "Access Policies" +layout: "aci" +page_title: "ACI: aci_storm_control_interface_policy" +sidebar_current: "docs-aci-data-source-aci_storm_control_interface_policy" +description: |- + Data source for ACI Storm Control Interface Policy +--- + +# aci_storm_control_interface_policy # + +Data source for ACI Storm Control Interface Policy + +## API Information ## + +* Class: [stormctrlIfPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/stormctrlIfPol/overview) + +* Supported in ACI versions: 1.0(2j) and later. + +* Distinguished Name Format: `uni/infra/stormctrlifp-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Policies -> Interface -> Storm Control` + +## Example Usage ## + +```hcl + +data "aci_storm_control_interface_policy" "example" { + name = "test_name" +} + +``` + +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the Storm Control Interface Policy object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Storm Control Interface Policy object. +* `annotation` (annotation) - (string) The annotation of the Storm Control Interface Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `broadcast_burst_rate_packets_per_second` (bcBurstPps) - (string) The broadcast burst interval rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `broadcast_burst_rate_percentage` (bcBurstRate) - (string) The broadcast burst rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `broadcast_rate_percentage` (bcRate) - (string) The broadcast rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `broadcast_rate_packets_per_second` (bcRatePps) - (string) The broadcast rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `burst_rate_packets_per_second` (burstPps) - (string) The burst interval rate in packets per second for the Storm Control Interface Policy object. +* `burst_rate_percentage` (burstRate) - (string) The burst rate in percentage for the Storm Control Interface Policy object. +* `description` (descr) - (string) The description of the Storm Control Interface Policy object. +* `unicast_multicast_broadcast` (isUcMcBcStormPktCfgValid) - (string) Configure the Storm Control Interface Policy object for unicast, multicast, and broadcast. Use 'Valid' when enabling the object for unicast, multicast, and broadcast. This attribute is supported in ACI versions: 2.3(1e) and later. +* `multicast_burst_rate_packets_per_second` (mcBurstPps) - (string) The multicast burst interval rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `multicast_burst_rate_percentage` (mcBurstRate) - (string) The multicast burst rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `multicast_rate_percentage` (mcRate) - (string) The multicast rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `multicast_rate_packets_per_second` (mcRatePps) - (string) The multicast rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `name_alias` (nameAlias) - (string) The name alias of the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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. +* `rate_percentage` (rate) - (string) The rate in percentage for the Storm Control Interface Policy object. +* `rate_packets_per_second` (ratePps) - (string) The rate in packets per second for the Storm Control Interface Policy object. +* `action` (stormCtrlAction) - (string) The action of the Storm Control Interface Policy object. This attribute is supported in ACI versions: 4.1(1i) and later. +* `soak_count` (stormCtrlSoakInstCount) - (string) The soak count for the Storm Control Interface Policy object. The value must be in the range 3 - 10. This attribute is supported in ACI versions: 4.1(1i) and later. +* `unicast_burst_rate_packets_per_second` (uucBurstPps) - (string) The unicast burst interval rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `unicast_burst_rate_percentage` (uucBurstRate) - (string) The unicast burst rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `unicast_rate_percentage` (uucRate) - (string) The unicast rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `unicast_rate_packets_per_second` (uucRatePps) - (string) The unicast rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. +* `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/storm_control_interface_policy.md b/docs/resources/storm_control_interface_policy.md new file mode 100644 index 000000000..25912123f --- /dev/null +++ b/docs/resources/storm_control_interface_policy.md @@ -0,0 +1,217 @@ +--- +# 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: "Access Policies" +layout: "aci" +page_title: "ACI: aci_storm_control_interface_policy" +sidebar_current: "docs-aci-resource-aci_storm_control_interface_policy" +description: |- + Manages ACI Storm Control Interface Policy +--- + +# aci_storm_control_interface_policy # + +Manages ACI Storm Control Interface Policy + + + +## API Information ## + +* Class: [stormctrlIfPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/stormctrlIfPol/overview) + +* Supported in ACI versions: 1.0(2j) and later. + +* Distinguished Name Format: `uni/infra/stormctrlifp-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Policies -> Interface -> Storm Control` + +## Example Usage ## + +The configuration snippet below creates a Storm Control Interface Policy with only required attributes. + +```hcl + +resource "aci_storm_control_interface_policy" "example" { + name = "test_name" +} + +``` +The configuration snippet below shows all possible attributes of the Storm Control Interface Policy. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_storm_control_interface_policy" "full_example" { + annotation = "annotation" + broadcast_burst_rate_packets_per_second = "11" + broadcast_burst_rate_percentage = "100.000000" + broadcast_rate_percentage = "100.000000" + broadcast_rate_packets_per_second = "10" + burst_rate_packets_per_second = "unspecified" + burst_rate_percentage = "100.000000" + description = "description_1" + unicast_multicast_broadcast = "Valid" + multicast_burst_rate_packets_per_second = "13" + multicast_burst_rate_percentage = "100.000000" + multicast_rate_percentage = "100.000000" + multicast_rate_packets_per_second = "12" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + rate_percentage = "100.000000" + rate_packets_per_second = "unspecified" + action = "drop" + soak_count = "3" + unicast_burst_rate_packets_per_second = "15" + unicast_burst_rate_percentage = "100.000000" + unicast_rate_percentage = "100.000000" + unicast_rate_packets_per_second = "14" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Storm Control Interface Policy resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_storm_control_interface_policy) folder. + +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the Storm Control Interface Policy object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Storm Control Interface Policy object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Storm Control Interface Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` +* `broadcast_burst_rate_packets_per_second` (bcBurstPps) - (string) The broadcast burst interval rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"unspecified"` + - Valid Values: + * `"unspecified"`. + * Or a value in the range of `0` to `390625000`. +* `broadcast_burst_rate_percentage` (bcBurstRate) - (string) The broadcast burst rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"100.000000"` + - Valid Values: + * A value in the range of `0` to `100`. +* `broadcast_rate_percentage` (bcRate) - (string) The broadcast rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"100.000000"` + - Valid Values: + * A value in the range of `0` to `100`. +* `broadcast_rate_packets_per_second` (bcRatePps) - (string) The broadcast rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"unspecified"` + - Valid Values: + * `"unspecified"`. + * Or a value in the range of `0` to `390625000`. +* `burst_rate_packets_per_second` (burstPps) - (string) The burst interval rate in packets per second for the Storm Control Interface Policy object. + - Default: `"unspecified"` + - Valid Values: + * `"unspecified"`. + * Or a value in the range of `0` to `390625000`. +* `burst_rate_percentage` (burstRate) - (string) The burst rate in percentage for the Storm Control Interface Policy object. + - Default: `"100.000000"` + - Valid Values: + * A value in the range of `0` to `100`. +* `description` (descr) - (string) The description of the Storm Control Interface Policy object. +* `unicast_multicast_broadcast` (isUcMcBcStormPktCfgValid) - (string) Configure the Storm Control Interface Policy object for unicast, multicast, and broadcast. Use 'Valid' when enabling the object for unicast, multicast, and broadcast. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"Invalid"` + - Valid Values: `"Invalid"`, `"Valid"`. +* `multicast_burst_rate_packets_per_second` (mcBurstPps) - (string) The multicast burst interval rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"unspecified"` + - Valid Values: + * `"unspecified"`. + * Or a value in the range of `0` to `390625000`. +* `multicast_burst_rate_percentage` (mcBurstRate) - (string) The multicast burst rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"100.000000"` + - Valid Values: + * A value in the range of `0` to `100`. +* `multicast_rate_percentage` (mcRate) - (string) The multicast rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"100.000000"` + - Valid Values: + * A value in the range of `0` to `100`. +* `multicast_rate_packets_per_second` (mcRatePps) - (string) The multicast rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"unspecified"` + - Valid Values: + * `"unspecified"`. + * Or a value in the range of `0` to `390625000`. +* `name_alias` (nameAlias) - (string) The name alias of the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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. +* `rate_percentage` (rate) - (string) The rate in percentage for the Storm Control Interface Policy object. + - Default: `"100.000000"` + - Valid Values: + * A value in the range of `0` to `100`. +* `rate_packets_per_second` (ratePps) - (string) The rate in packets per second for the Storm Control Interface Policy object. + - Default: `"unspecified"` + - Valid Values: + * `"unspecified"`. + * Or a value in the range of `0` to `390625000`. +* `action` (stormCtrlAction) - (string) The action of the Storm Control Interface Policy object. This attribute is supported in ACI versions: 4.1(1i) and later. + - Default: `"drop"` + - Valid Values: `"drop"`, `"shutdown"`. +* `soak_count` (stormCtrlSoakInstCount) - (string) The soak count for the Storm Control Interface Policy object. The value must be in the range 3 - 10. This attribute is supported in ACI versions: 4.1(1i) and later. + - Default: `"3"` +* `unicast_burst_rate_packets_per_second` (uucBurstPps) - (string) The unicast burst interval rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"unspecified"` + - Valid Values: + * `"unspecified"`. + * Or a value in the range of `0` to `390625000`. +* `unicast_burst_rate_percentage` (uucBurstRate) - (string) The unicast burst rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"100.000000"` + - Valid Values: + * A value in the range of `0` to `100`. +* `unicast_rate_percentage` (uucRate) - (string) The unicast rate in percentage for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"100.000000"` + - Valid Values: + * A value in the range of `0` to `100`. +* `unicast_rate_packets_per_second` (uucRatePps) - (string) The unicast rate in packets per second for the Storm Control Interface Policy object. This attribute is supported in ACI versions: 2.3(1e) and later. + - Default: `"unspecified"` + - Valid Values: + * `"unspecified"`. + * Or a value in the range of `0` to `390625000`. +* `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 Storm Control Interface Policy 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_storm_control_interface_policy.example uni/infra/stormctrlifp-{name} +``` + +Starting in Terraform version 1.5, an existing Storm Control Interface Policy can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/infra/stormctrlifp-{name}" + to = aci_storm_control_interface_policy.example +} +``` diff --git a/examples/data-sources/aci_storm_control_interface_policy/data-source.tf b/examples/data-sources/aci_storm_control_interface_policy/data-source.tf new file mode 100644 index 000000000..9cd8fb9e6 --- /dev/null +++ b/examples/data-sources/aci_storm_control_interface_policy/data-source.tf @@ -0,0 +1,4 @@ + +data "aci_storm_control_interface_policy" "example" { + name = "test_name" +} diff --git a/examples/data-sources/aci_storm_control_interface_policy/provider.tf b/examples/data-sources/aci_storm_control_interface_policy/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_storm_control_interface_policy/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_storm_control_interface_policy/provider.tf b/examples/resources/aci_storm_control_interface_policy/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_storm_control_interface_policy/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_storm_control_interface_policy/resource-all-attributes.tf b/examples/resources/aci_storm_control_interface_policy/resource-all-attributes.tf new file mode 100644 index 000000000..3ee68aa39 --- /dev/null +++ b/examples/resources/aci_storm_control_interface_policy/resource-all-attributes.tf @@ -0,0 +1,40 @@ + +resource "aci_storm_control_interface_policy" "full_example" { + annotation = "annotation" + broadcast_burst_rate_packets_per_second = "11" + broadcast_burst_rate_percentage = "100.000000" + broadcast_rate_percentage = "100.000000" + broadcast_rate_packets_per_second = "10" + burst_rate_packets_per_second = "unspecified" + burst_rate_percentage = "100.000000" + description = "description_1" + unicast_multicast_broadcast = "Valid" + multicast_burst_rate_packets_per_second = "13" + multicast_burst_rate_percentage = "100.000000" + multicast_rate_percentage = "100.000000" + multicast_rate_packets_per_second = "12" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + rate_percentage = "100.000000" + rate_packets_per_second = "unspecified" + action = "drop" + soak_count = "3" + unicast_burst_rate_packets_per_second = "15" + unicast_burst_rate_percentage = "100.000000" + unicast_rate_percentage = "100.000000" + unicast_rate_packets_per_second = "14" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_storm_control_interface_policy/resource.tf b/examples/resources/aci_storm_control_interface_policy/resource.tf new file mode 100644 index 000000000..8140efd2e --- /dev/null +++ b/examples/resources/aci_storm_control_interface_policy/resource.tf @@ -0,0 +1,4 @@ + +resource "aci_storm_control_interface_policy" "example" { + name = "test_name" +} diff --git a/gen/definitions/classes/stormctrlIfPol.yaml b/gen/definitions/classes/stormctrlIfPol.yaml new file mode 100644 index 000000000..d17c383d6 --- /dev/null +++ b/gen/definitions/classes/stormctrlIfPol.yaml @@ -0,0 +1,7 @@ +contained_by: + - polUni +resource_name: storm_control_interface_policy +rn_prepend: infra +sub_category: Access Policies +ui_locations: + - Fabric -> Access Policies -> Policies -> Interface -> Storm Control diff --git a/gen/definitions/properties/stormctrlIfPol.yaml b/gen/definitions/properties/stormctrlIfPol.yaml new file mode 100644 index 000000000..b8bfba617 --- /dev/null +++ b/gen/definitions/properties/stormctrlIfPol.yaml @@ -0,0 +1,81 @@ +default_values: + bcBurstRate: "100.000000" + bcRate: "100.000000" + burstRate: "100.000000" + mcBurstRate: "100.000000" + mcRate: "100.000000" + rate: "100.000000" + uucBurstRate: "100.000000" + uucRate: "100.000000" +documentation: + bcBurstPps: The broadcast burst interval rate in packets per second for the %s object. + bcBurstRate: The broadcast burst rate in percentage for the %s object. + bcRate: The broadcast rate in percentage for the %s object. + bcRatePps: The broadcast rate in packets per second for the %s object. + burstPps: The burst interval rate in packets per second for the %s object. + burstRate: The burst rate in percentage for the %s object. + isUcMcBcStormPktCfgValid: Configure the %s object for unicast, multicast, and broadcast. Use 'Valid' when enabling the object for unicast, multicast, and broadcast. + mcBurstPps: The multicast burst interval rate in packets per second for the %s object. + mcBurstRate: The multicast burst rate in percentage for the %s object. + mcRate: The multicast rate in percentage for the %s object. + mcRatePps: The multicast rate in packets per second for the %s object. + rate: The rate in percentage for the %s object. + ratePps: The rate in packets per second for the %s object. + stormCtrlAction: The action of the %s object. + stormCtrlSoakInstCount: The soak count for the %s object. The value must be in the range 3 - 10. + uucBurstPps: The unicast burst interval rate in packets per second for the %s object. + uucBurstRate: The unicast burst rate in percentage for the %s object. + uucRate: The unicast rate in percentage for the %s object. + uucRatePps: The unicast rate in packets per second for the %s object. +ignores: + - type +overwrites: + bc_burst_pps: broadcast_burst_rate_packets_per_second + bc_burst_rate: broadcast_burst_rate_percentage + bc_rate: broadcast_rate_percentage + bc_rate_pps: broadcast_rate_packets_per_second + burst_pps: burst_rate_packets_per_second + burst_rate: burst_rate_percentage + is_uc_mc_bc_storm_pkt_cfg_valid: unicast_multicast_broadcast + mc_burst_pps: multicast_burst_rate_packets_per_second + mc_burst_rate: multicast_burst_rate_percentage + mc_rate: multicast_rate_percentage + mc_rate_pps: multicast_rate_packets_per_second + rate: rate_percentage + rate_pps: rate_packets_per_second + storm_ctrl_action: action + storm_ctrl_soak_inst_count: soak_count + uuc_burst_pps: unicast_burst_rate_packets_per_second + uuc_burst_rate: unicast_burst_rate_percentage + uuc_rate: unicast_rate_percentage + uuc_rate_pps: unicast_rate_packets_per_second +required_by_custom_type_in_test: + - isUcMcBcStormPktCfgValid +static_custom_type: + bcBurstRate: rounded_percentage + bcRate: rounded_percentage + burstRate: rounded_percentage + mcBurstRate: rounded_percentage + mcRate: rounded_percentage + rate: rounded_percentage + uucBurstRate: rounded_percentage + uucRate: rounded_percentage +test_values: + all: + broadcast_burst_rate_packets_per_second: "11" + broadcast_rate_packets_per_second: "10" + multicast_burst_rate_packets_per_second: "13" + multicast_rate_packets_per_second: "12" + unicast_burst_rate_packets_per_second: "15" + unicast_multicast_broadcast: Valid + unicast_rate_packets_per_second: "14" + custom_type: + broadcast_burst_rate_percentage: "100.000000" + broadcast_rate_percentage: "90" + burst_rate_percentage: "100.000000" + multicast_burst_rate_percentage: "95.4556" + multicast_rate_percentage: "80.1" + rate_percentage: "100.000000" + unicast_burst_rate_percentage: "64.736" + unicast_multicast_broadcast: Valid + unicast_rate_percentage: "50.56" diff --git a/gen/generator.go b/gen/generator.go index 3a952887d..db0bd4486 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -77,6 +77,10 @@ const ( const providerName = "aci" const pubhupDevnetBaseUrl = "https://pubhub.devnetcloud.com/media/model-doc-latest/docs" +var staticCustomTypeMap = map[string]string{ + "rounded_percentage": "RoundedPercentage", +} + // Function map used during template rendering in order to call functions from the template // The map contains a key which is the name of the function used in the template and a value which is the function itself // The functions itself are defined in the current file @@ -1164,7 +1168,7 @@ func cleanDirectories() { cleanDirectory(resourcesDocsPath, []string{}) cleanDirectory(datasourcesDocsPath, []string{"system.md"}) cleanDirectory(testVarsPath, []string{}) - cleanDirectory("./internal/custom_types", []string{}) + cleanDirectory("./internal/custom_types", []string{"roundedPercentage.go"}) // The *ExamplesPath directories are removed and recreated to ensure all previously rendered files are removed // The provider example file is not removed because it contains static provider configuration @@ -1341,7 +1345,7 @@ func main() { } model.TestVars = testVarsMap for propertyName, property := range model.Properties { - if property.HasCustomType { + if property.HasCustomType && property.StaticCustomType == "" { renderTemplate("custom_type.go.tmpl", fmt.Sprintf("%s_%s.go", model.PkgName, propertyName), "./internal/custom_types", property) } } @@ -1547,12 +1551,14 @@ type Property struct { Validators []interface{} IdentifyProperties []Property // Below booleans are used during template rendering to determine correct rendering the go code - IsNaming bool - CreateOnly bool - IsRequired bool - IgnoreInTest bool - ReadOnly bool - HasCustomType bool + IsNaming bool + CreateOnly bool + IsRequired bool + IgnoreInTest bool + ReadOnly bool + HasCustomType bool + IncludeInCustomTypeTest bool + StaticCustomType string } // A Definitions represents the ACI class and property definitions as defined in the definitions YAML files @@ -2206,6 +2212,14 @@ func (m *Model) SetClassProperties(classDetails interface{}) { } } + staticCustomType := GetStaticCustomType(m.PkgName, propertyName, m.Definitions) + if staticCustomType != "" { + property.StaticCustomType = staticCustomTypeMap[staticCustomType] + property.HasCustomType = true + m.HasCustomTypeProperties = true + } + property.IncludeInCustomTypeTest = IncludeInCustomTypeTest(m.PkgName, propertyName, m.Definitions) + defaultValueOverwrite := GetDefaultValues(m.PkgName, propertyName, m.Definitions) if defaultValueOverwrite != "" { property.DefaultValue = defaultValueOverwrite @@ -3442,6 +3456,36 @@ func GetDefaultValues(classPkgName, propertyName string, definitions Definitions return "" } +func GetStaticCustomType(classPkgName, propertyName string, definitions Definitions) string { + if classDetails, ok := definitions.Properties[classPkgName]; ok { + for key, value := range classDetails.(map[string]interface{}) { + if key == "static_custom_type" { + for k, v := range value.(map[interface{}]interface{}) { + if k.(string) == propertyName { + return v.(string) + } + } + } + } + } + return "" +} + +func IncludeInCustomTypeTest(classPkgName, propertyName string, definitions Definitions) bool { + if classDetails, ok := definitions.Properties[classPkgName]; ok { + for key, value := range classDetails.(map[string]interface{}) { + if key == "required_by_custom_type_in_test" { + for _, v := range value.([]interface{}) { + if v.(string) == propertyName { + return true + } + } + } + } + } + return false +} + func IsInterfaceSlice(input interface{}) bool { _, ok := input.([]interface{}) return ok diff --git a/gen/meta/stormctrlIfPol.json b/gen/meta/stormctrlIfPol.json new file mode 100644 index 000000000..3a7cf3ab4 --- /dev/null +++ b/gen/meta/stormctrlIfPol.json @@ -0,0 +1,1631 @@ +{ + "stormctrl:IfPol": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "stormctrl:RtStormctrlIfPol": "", + "stormctrl:RtStormctrlIfPolCons": "", + "tag:AliasDelInst": "", + "tag:AliasInst": "", + "tag:Annotation": "", + "tag:ExtMngdInst": "", + "tag:Inst": "", + "tag:Tag": "" + }, + "rnMap": { + "alias": "tag:AliasInst", + "aliasdel-": "tag:AliasDelInst", + "annotationKey-": "tag:Annotation", + "extmngd": "tag:ExtMngdInst", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "rtinfraStormctrlIfPol-": "stormctrl:RtStormctrlIfPol", + "rtl1StormctrlIfPolCons-": "stormctrl:RtStormctrlIfPolCons", + "tag-": "tag:Inst", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "stormctrlifp-{name}", + "containedBy": { + "infra:Infra": "" + }, + "superClasses": [ + "fabric:L1IfPol", + "fabric:ProtoIfPol", + "fabric:ProtoPol", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "stormctrl:RtStormctrlIfPol": "infra:AccGrp", + "stormctrl:RtStormctrlIfPolCons": "l1:EthIf" + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/infra/stormctrlifp-{name}" + ], + "writeAccess": [ + "access-connectivity", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-connectivity", + "admin", + "custom-port-privilege", + "ops" + ], + "faults": { + + }, + "events": { + "E4213202": "creation||stormctrl:IfPol", + "E4213203": "modification||stormctrl:IfPol", + "E4213204": "deletion||stormctrl:IfPol" + }, + "stats": { + + }, + "versions": "1.0(2j)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": true, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + "apic" + ], + "classId": "5606", + "className": "IfPol", + "classPkg": "stormctrl", + "featureTag": "", + "moCategory": "Regular", + "label": "Storm Control Interface Policy", + "comment": [ + "The storm control interface policy. A traffic storm occurs when packets flood the LAN, creating excessive traffic and degrading network performance. You can use the traffic storm control feature to prevent disruptions on ports by a broadcast, multicast, or unknown unicast traffic storm on physical interfaces." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38131", + "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 + }, + "bcBurstPps": { + "versions": "2.3(1e)-", + "comment": [ + "burst rate in pps" + ], + "isConfigurable": true, + "propGlobalId": "30013", + "propLocalId": "7434", + "label": "Broadcast Max burst size", + "baseType": "scalar:Uint32", + "modelType": "l1:StormCtrlPps", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:bcBurstPps", + "validators": [ + {"min" : 0, "max": 390625000 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0xffffffff", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "bcBurstRate": { + "versions": "2.3(1e)-", + "comment": [ + "burst rate in % (upto 1 decimal)" + ], + "isConfigurable": true, + "propGlobalId": "30011", + "propLocalId": "7432", + "label": "Broadcast Max burst size", + "baseType": "scalar:Float", + "modelType": "l1:StormCtrlRate", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:bcBurstRate", + "validators": [ + {"min" : 0, "max": 100 } + ], + "validValues": [ + { "value": "100", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 100, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "bcRate": { + "versions": "2.3(1e)-", + "comment": [ + "rate in % (upto 1 decimal)" + ], + "isConfigurable": true, + "propGlobalId": "30010", + "propLocalId": "7431", + "label": "Broadcast Traffic rate", + "baseType": "scalar:Float", + "modelType": "l1:StormCtrlRate", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:bcRate", + "validators": [ + {"min" : 0, "max": 100 } + ], + "validValues": [ + { "value": "100", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 100, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "bcRatePps": { + "versions": "2.3(1e)-", + "comment": [ + "rate in pps" + ], + "isConfigurable": true, + "propGlobalId": "30012", + "propLocalId": "7433", + "label": "Broadcast Traffic rate", + "baseType": "scalar:Uint32", + "modelType": "l1:StormCtrlPps", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:bcRatePps", + "validators": [ + {"min" : 0, "max": 390625000 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0xffffffff", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "burstPps": { + "versions": "1.0(2j)-", + "comment": [ + "The packets per second (PPS) burst interval rate for the storm control policy. During this interval, the traffic level which is expressed as packets flowing per second through the port, is then compared with the traffic storm control level that you configured. When the ingress traffic reaches the traffic storm control level that is configured on the port, traffic storm control drops the traffic until the interval ends." + ], + "isConfigurable": true, + "propGlobalId": "16486", + "propLocalId": "4320", + "label": "Max burst size", + "baseType": "scalar:Uint32", + "modelType": "l1:StormCtrlPps", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:burstPps", + "validators": [ + {"min" : 0, "max": 390625000 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0xffffffff", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "burstRate": { + "versions": "1.0(2j)-", + "comment": [ + "The traffic burst rate percentage." + ], + "isConfigurable": true, + "propGlobalId": "16484", + "propLocalId": "4318", + "label": "Max burst size", + "baseType": "scalar:Float", + "modelType": "l1:StormCtrlRate", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:burstRate", + "validators": [ + {"min" : 0, "max": 100 } + ], + "validValues": [ + { "value": "100", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 100, + "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 a description of the policy definition." + ], + "isConfigurable": true, + "propGlobalId": "5579", + "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": "40270", + "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 + }, + "isUcMcBcStormPktCfgValid": { + "versions": "2.3(1e)-", + "isConfigurable": true, + "propGlobalId": "30294", + "propLocalId": "7536", + "label": "Packet Type Uc/bc/Mc Config Valid (Yes/No)", + "baseType": "scalar:Enum8", + "modelType": "l1:StormCtrlCfgValid", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:isUcMcBcStormPktCfgValid", + "validValues": [ + { "value": "0", "localName": "Invalid", + "platformFlavors": [ + + ], + "label": "All Types "}, + { "value": "1", "localName": "Valid", + "platformFlavors": [ + + ], + "label": "Unicast, Broadcast, Multicast "}, + { "value": "Invalid", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "Invalid", + "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 + }, + "mcBurstPps": { + "versions": "2.3(1e)-", + "comment": [ + "burst rate in pps" + ], + "isConfigurable": true, + "propGlobalId": "30017", + "propLocalId": "7438", + "label": "Multicast Max burst size", + "baseType": "scalar:Uint32", + "modelType": "l1:StormCtrlPps", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:mcBurstPps", + "validators": [ + {"min" : 0, "max": 390625000 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0xffffffff", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "mcBurstRate": { + "versions": "2.3(1e)-", + "comment": [ + "burst rate in % (upto 1 decimal)" + ], + "isConfigurable": true, + "propGlobalId": "30015", + "propLocalId": "7436", + "label": "Multicast Max burst size", + "baseType": "scalar:Float", + "modelType": "l1:StormCtrlRate", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:mcBurstRate", + "validators": [ + {"min" : 0, "max": 100 } + ], + "validValues": [ + { "value": "100", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 100, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "mcRate": { + "versions": "2.3(1e)-", + "comment": [ + "rate in % (upto 1 decimal)" + ], + "isConfigurable": true, + "propGlobalId": "30014", + "propLocalId": "7435", + "label": "Multicast Traffic rate", + "baseType": "scalar:Float", + "modelType": "l1:StormCtrlRate", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:mcRate", + "validators": [ + {"min" : 0, "max": 100 } + ], + "validValues": [ + { "value": "100", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 100, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "mcRatePps": { + "versions": "2.3(1e)-", + "comment": [ + "rate in pps" + ], + "isConfigurable": true, + "propGlobalId": "30016", + "propLocalId": "7437", + "label": "Multicast Traffic rate", + "baseType": "scalar:Uint32", + "modelType": "l1:StormCtrlPps", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:mcRatePps", + "validators": [ + {"min" : 0, "max": 390625000 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0xffffffff", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "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 + }, + "monPolDn": { + "versions": "1.1(1j)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "19821", + "propLocalId": "228", + "label": "Monitoring Policy", + "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 + }, + "name": { + "versions": "1.0(2j)-", + "comment": [ + "The storm control policy name." + ], + "isConfigurable": true, + "propGlobalId": "16523", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 1, "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 + }, + "ownerKey": { + "versions": "1.0(1e)-", + "comment": [ + "The key for enabling clients to own their data for entity correlation." + ], + "isConfigurable": true, + "propGlobalId": "15230", + "propLocalId": "4100", + "label": "ownerKey", + "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": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "ownerTag": { + "versions": "1.0(1e)-", + "comment": [ + "A tag for enabling clients to add their own data. For example, to indicate who created this object." + ], + "isConfigurable": true, + "propGlobalId": "15231", + "propLocalId": "4101", + "label": "ownerTag", + "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": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rate": { + "versions": "1.0(2j)-", + "comment": [ + "The traffic rate percentage." + ], + "isConfigurable": true, + "propGlobalId": "16483", + "propLocalId": "985", + "label": "Traffic rate", + "baseType": "scalar:Float", + "modelType": "l1:StormCtrlRate", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:rate", + "validators": [ + {"min" : 0, "max": 100 } + ], + "validValues": [ + { "value": "100", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 100, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "ratePps": { + "versions": "1.0(2j)-", + "comment": [ + "The packets per second (PPS) interval rate for the storm control policy. During this interval, the traffic level which is expressed as packets flowing per second through the port, is then compared with the traffic storm control level that you configured. When the ingress traffic reaches the traffic storm control level that is configured on the port, traffic storm control drops the traffic until the interval ends." + ], + "isConfigurable": true, + "propGlobalId": "16485", + "propLocalId": "4319", + "label": "Tarffic rate", + "baseType": "scalar:Uint32", + "modelType": "l1:StormCtrlPps", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:ratePps", + "validators": [ + {"min" : 0, "max": 390625000 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0xffffffff", "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 + }, + "stormCtrlAction": { + "versions": "4.1(1i)-", + "comment": [ + "action drop/shutdown" + ], + "isConfigurable": true, + "propGlobalId": "45503", + "propLocalId": "10082", + "label": "StormCtrlAction", + "baseType": "scalar:Enum8", + "modelType": "l1:StormCtrlActionT", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:stormCtrlAction", + "validValues": [ + { "value": "drop", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "drop", + "platformFlavors": [ + + ], + "label": "Drop "}, + { "value": "1", "localName": "shutdown", + "platformFlavors": [ + + ], + "label": "Shutdown "} + ], + "default": "drop", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "stormCtrlSoakInstCount": { + "versions": "4.1(1i)-", + "comment": [ + "Instances required to declare port shutdown" + ], + "isConfigurable": true, + "propGlobalId": "45504", + "propLocalId": "10083", + "label": "StormCtrlSoakInstCount", + "baseType": "scalar:Uint16", + "modelType": "l1:StormCtrlSoakInstCount", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:stormCtrlSoakInstCount", + "validators": [ + {"min" : 3, "max": 10 } + ], + "validValues": [ + { "value": "3", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 3, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "type": { + "versions": "1.0(2j)-", + "comment": [ + "The storm control interface policy type. The policy type prevents disruptions on ports by a broadcast, multicast, or unknown unicast traffic storm on physical interfaces. The policy type is set to ALL types of traffic by default and can not be changed." + ], + "isConfigurable": true, + "propGlobalId": "16482", + "propLocalId": "33", + "label": "Packet Type", + "baseType": "scalar:Enum8", + "modelType": "l1:PktT", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:type", + "validValues": [ + { "value": "4", "localName": "all", + "platformFlavors": [ + + ], + "label": "all "}, + { "value": "1", "localName": "bcast", + "platformFlavors": [ + + ], + "label": "bcast "}, + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "3", "localName": "mcast", + "platformFlavors": [ + + ], + "label": "mcast "}, + { "value": "2", "localName": "unk-ucast", + "platformFlavors": [ + + ], + "label": "unk-ucast "} + ], + "default": "all", + "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 + }, + "uucBurstPps": { + "versions": "2.3(1e)-", + "comment": [ + "burst rate in pps" + ], + "isConfigurable": true, + "propGlobalId": "30009", + "propLocalId": "7430", + "label": "Unknown Unicast Max burst size", + "baseType": "scalar:Uint32", + "modelType": "l1:StormCtrlPps", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:uucBurstPps", + "validators": [ + {"min" : 0, "max": 390625000 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0xffffffff", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uucBurstRate": { + "versions": "2.3(1e)-", + "comment": [ + "burst rate in % (upto 1 decimal)" + ], + "isConfigurable": true, + "propGlobalId": "30007", + "propLocalId": "7428", + "label": "Unknown Unicast Max burst size", + "baseType": "scalar:Float", + "modelType": "l1:StormCtrlRate", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:uucBurstRate", + "validators": [ + {"min" : 0, "max": 100 } + ], + "validValues": [ + { "value": "100", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 100, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uucRate": { + "versions": "2.3(1e)-", + "comment": [ + "rate in % (upto 1 decimal)" + ], + "isConfigurable": true, + "propGlobalId": "30006", + "propLocalId": "7427", + "label": "Unknown Unicast Traffic rate", + "baseType": "scalar:Float", + "modelType": "l1:StormCtrlRate", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:uucRate", + "validators": [ + {"min" : 0, "max": 100 } + ], + "validValues": [ + { "value": "100", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 100, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uucRatePps": { + "versions": "2.3(1e)-", + "comment": [ + "rate in pps" + ], + "isConfigurable": true, + "propGlobalId": "30008", + "propLocalId": "7429", + "label": "Unknown Unicast Traffic rate", + "baseType": "scalar:Uint32", + "modelType": "l1:StormCtrlPps", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "l1:StormCtrlP:uucRatePps", + "validators": [ + {"min" : 0, "max": 390625000 } + ], + "validValues": [ + { "value": "unspecified", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0xffffffff", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/templates/datasource.go.tmpl b/gen/templates/datasource.go.tmpl index fa0941a87..5fe4900d6 100644 --- a/gen/templates/datasource.go.tmpl +++ b/gen/templates/datasource.go.tmpl @@ -116,7 +116,7 @@ func (d *{{.ResourceClassName}}DataSource) Schema(ctx context.Context, req datas {{- if .IsNaming}} "{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}": schema.StringAttribute{ {{- if .HasCustomType}} - CustomType: customTypes.{{.ResourceClassName}}{{.Name}}StringType{}, + CustomType: customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringType{}, {{- end}} Required: true, {{- if .ValidValues}} @@ -133,7 +133,7 @@ func (d *{{.ResourceClassName}}DataSource) Schema(ctx context.Context, req datas },{{else}} "{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}": schema.StringAttribute{ {{- if .HasCustomType}} - CustomType: customTypes.{{.ResourceClassName}}{{.Name}}StringType{}, + CustomType: customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringType{}, {{- end}} Computed: true, MarkdownDescription: `{{.Comment}}`, @@ -279,7 +279,7 @@ func (d *{{.ResourceClassName}}DataSource) Read(ctx context.Context, req datasou },{{else}} "{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}": schema.StringAttribute{ {{- if .HasCustomType}} - CustomType: customTypes.{{.ResourceClassName}}{{.Name}}StringType{}, + CustomType: customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringType{}, {{- end}} Computed: true, MarkdownDescription: `{{.Comment}}`, diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index 211668f19..275908983 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -57,7 +57,7 @@ type {{.ResourceClassName}}ResourceModel struct { {{- else if eq .Name "Id"}} {{.ResourceClassName}}{{ .Name }} types.String `tfsdk:"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}"` {{- else if .HasCustomType}} - {{ .Name }} customTypes.{{.ResourceClassName}}{{.Name}}StringValue `tfsdk:"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}"` + {{ .Name }} customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue `tfsdk:"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}"` {{- else}} {{ .Name }} types.String `tfsdk:"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}"` {{- end}} @@ -95,7 +95,7 @@ func getEmpty{{.ResourceClassName}}ResourceModel() *{{.ResourceClassName}}Resour {{- else if eq .Name "Id"}} {{.ResourceClassName}}{{ .Name }}: basetypes.NewStringNull(), {{- else if .HasCustomType}} - {{ .Name }}: customTypes.New{{.ResourceClassName}}{{.Name}}StringNull(), + {{ .Name }}: customTypes.New{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringNull(), {{- else}} {{ .Name }}: basetypes.NewStringNull(), {{- end}} @@ -299,7 +299,7 @@ func (r *{{.ResourceClassName}}Resource) UpgradeState(ctx context.Context) map[i {{- range .Properties}} {{- if isLegacyAttribute .Name $.LegacyAttributes}} {{- if .HasCustomType}} - {{ .Name }}: customTypes.{{.ResourceClassName}}{{.Name}}StringValue{ StringValue: priorStateData.{{ .Name }} }, + {{ .Name }}: customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue{ StringValue: priorStateData.{{ .Name }} }, {{- else}} {{ .Name }}: priorStateData.{{ .Name }}, {{- end}} @@ -457,7 +457,7 @@ func (r *{{.ResourceClassName}}Resource) UpgradeState(ctx context.Context) map[i {{- if eq $AttributeName ""}} {{ .Name }}: basetypes.NewStringNull(), {{- else if .HasCustomType}} - {{ .Name }}: customTypes.{{.ResourceClassName}}{{.Name}}StringValue{StringValue: priorStateData{{.ResourceClassName}}.{{ $AttributeName }}}, + {{ .Name }}: customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue{StringValue: priorStateData{{.ResourceClassName}}.{{ $AttributeName }}}, {{- else}} {{ .Name }}: priorStateData{{.ResourceClassName}}.{{ $AttributeName }}, {{- end}} @@ -516,7 +516,7 @@ func (r *{{.ResourceClassName}}Resource) UpgradeState(ctx context.Context) map[i {{- $AttributeName := getLegacyChildAttribute $PkgName $Overwrite . $.LegacyAttributes $.LegacyBlocks}} {{- if eq $AttributeName ""}} {{- if .HasCustomType}} - {{ .Name }}: customTypes.New{{.ResourceClassName}}{{.Name}}StringNull(), + {{ .Name }}: customTypes.New{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringNull(), {{- else}} {{ .Name }}: basetypes.NewStringNull(), {{- end}} @@ -1043,7 +1043,7 @@ func (r *{{.ResourceClassName}}Resource) ModifyPlan(ctx context.Context, req res {{ .ResourceClassName }}.{{ .Name }} = planData.Annotation {{- else if ne .DefaultValue ""}} {{- if .HasCustomType}} - {{ .ResourceClassName }}.{{ .Name }} = customTypes.New{{.ResourceClassName}}{{.Name}}StringUnknown() + {{ .ResourceClassName }}.{{ .Name }} = customTypes.New{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringUnknown() {{- else}} {{ .ResourceClassName }}.{{ .Name }} = basetypes.NewStringUnknown() {{- end}} @@ -1122,7 +1122,7 @@ func (r *{{.ResourceClassName}}Resource) ModifyPlan(ctx context.Context, req res {{ .Name }}: planData.{{ .Name }}, {{- else if and (ne $AttributeName "") (not (isNewNamedClassAttribute $Overwrite)) }} {{- if .HasCustomType}} - {{ .Name }}: customTypes.{{.ResourceClassName}}{{.Name}}StringValue{StringValue: attributeValue.{{ .Name }}}, + {{ .Name }}: customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue{StringValue: attributeValue.{{ .Name }}}, {{- else}} {{ .Name }}: attributeValue.{{ .Name }}, {{- end}} @@ -1136,13 +1136,13 @@ func (r *{{.ResourceClassName}}Resource) ModifyPlan(ctx context.Context, req res {{- $AttributeName := getLegacyChildAttribute .PkgName $Overwrite . $.LegacyAttributes $.LegacyBlocks}} if !attributeValue.{{ .Name }}.IsNull() { {{- if .HasCustomType}} - {{ .ResourceClassName }}.{{ .Name }} = customTypes.{{.ResourceClassName}}{{.Name}}StringValue{StringValue: attributeValue.{{ .Name }}} + {{ .ResourceClassName }}.{{ .Name }} = customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue{StringValue: attributeValue.{{ .Name }}} {{- else}} {{ .ResourceClassName }}.{{ .Name }} = attributeValue.{{ .Name }} {{- end}} } else { {{- if .HasCustomType}} - {{ .ResourceClassName }}.{{ .Name }} = customTypes.{{.ResourceClassName}}{{.Name}}StringValue{StringValue: basetypes.NewStringUnknown()} + {{ .ResourceClassName }}.{{ .Name }} = customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue{StringValue: basetypes.NewStringUnknown()} {{- else}} {{ .ResourceClassName }}.{{ .Name }} = basetypes.NewStringUnknown() {{- end}} @@ -1602,7 +1602,7 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc {{- else}} "{{$OverwritePropertyName}}": schema.StringAttribute{ {{- if .HasCustomType}} - CustomType: customTypes.{{.ResourceClassName}}{{.Name}}StringType{}, + CustomType: customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringType{}, {{- end}} {{- if or .IsNaming .IsRequired}} {{- if ne $LegacyAttributeName ""}} @@ -1644,7 +1644,9 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc {{- if .HasCustomType}} Validators: []validator.String{ stringvalidator.Any( + {{- if .ValidValues}} stringvalidator.OneOf({{- validatorStringCustomType .ValidValues .ValidValuesMap}}), + {{- end}} validators.InBetweenFromString({{- index .Validators 0 "min"}}, {{- index .Validators 0 "max"}}), ), }, @@ -2091,7 +2093,7 @@ func getAndSet{{.ResourceClassName}}Attributes(ctx context.Context, diags *diag. {{- else}} if attributeName == "{{.PropertyName}}" { {{- if .HasCustomType}} - readData.{{.Name}} = customTypes.New{{.ResourceClassName}}{{.Name}}StringValue(attributeValue.(string)) + readData.{{.Name}} = customTypes.New{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue(attributeValue.(string)) {{- else}} readData.{{- if eq .Name "Id"}}{{.ResourceClassName}}{{ .Name }}{{- else}}{{.Name}}{{- end}} = basetypes.NewStringValue(attributeValue.(string)) {{- end}} @@ -2161,7 +2163,7 @@ func getAndSet{{.ResourceClassName}}Attributes(ctx context.Context, diags *diag. {{- else}} if childAttributeName == "{{.PropertyName}}" { {{- if .HasCustomType}} - {{.ResourceClassName}}{{$.ResourceClassName}}.{{.Name}} = customTypes.New{{.ResourceClassName}}{{.Name}}StringValue(childAttributeValue.(string)) + {{.ResourceClassName}}{{$.ResourceClassName}}.{{.Name}} = customTypes.New{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue(childAttributeValue.(string)) {{- else}} {{.ResourceClassName}}{{$.ResourceClassName}}.{{- if eq .Name "Id"}}{{.ResourceClassName}}{{ .Name }}{{- else}}{{.Name}}{{- end}} = basetypes.NewStringValue(childAttributeValue.(string)) {{- end}} @@ -2586,7 +2588,7 @@ type {{.ResourceClassName}}{{.ParentHierarchy}}ResourceModel struct { {{- else if eq .Name "Id"}} {{.ResourceClassName}}{{ .Name }} types.String `tfsdk:"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}"` {{- else if .HasCustomType}} - {{ .Name }} customTypes.{{.ResourceClassName}}{{.Name}}StringValue `tfsdk:"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}"` + {{ .Name }} customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringValue `tfsdk:"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}"` {{- else}} {{ .Name }} types.String `tfsdk:"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}"` {{- end}} @@ -2608,7 +2610,7 @@ func getEmpty{{.ResourceClassName}}{{.ParentHierarchy}}ResourceModel() {{.Resour {{- else if eq .Name "Id"}} {{.ResourceClassName}}{{ .Name }}: basetypes.NewStringNull(), {{- else if .HasCustomType}} - {{ .Name }}: customTypes.New{{.ResourceClassName}}{{.Name}}StringNull(), + {{ .Name }}: customTypes.New{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringNull(), {{- else}} {{ .Name }}: basetypes.NewStringNull(), {{- end}} @@ -2717,7 +2719,7 @@ func {{.ResourceClassName}}{{.ParentHierarchy}}SetToSetNullWhenStateIsNullPlanIs {{- if eq .ValueType "bitmask"}} planSetValues[index].{{ .Name }} = basetypes.NewSetNull(types.StringType) {{- else if .HasCustomType}} - planSetValues[index].{{ .Name }} = customTypes.New{{.ResourceClassName}}{{.Name}}StringNull() + planSetValues[index].{{ .Name }} = customTypes.New{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringNull() {{- else}} planSetValues[index].{{ .Name }} = basetypes.NewStringNull() {{- end}} @@ -2864,7 +2866,7 @@ func {{.ResourceClassName}}{{.ParentHierarchy}}SetToSetNullWhenStateIsNullPlanIs {{- else}} "{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}": schema.StringAttribute{ {{- if .HasCustomType}} - CustomType: customTypes.{{.ResourceClassName}}{{.Name}}StringType{}, + CustomType: customTypes.{{- if .StaticCustomType}}{{.StaticCustomType}}{{else}}{{.ResourceClassName}}{{.Name}}{{- end}}StringType{}, {{- end}} {{- if and (or .IsNaming .IsRequired) (not $.TemplateProperties.HasReadOnlyProperties)}} Required: true, @@ -2884,7 +2886,9 @@ func {{.ResourceClassName}}{{.ParentHierarchy}}SetToSetNullWhenStateIsNullPlanIs {{- if .HasCustomType}} Validators: []validator.String{ stringvalidator.Any( - stringvalidator.OneOf({{- validatorStringCustomType .ValidValues .ValidValuesMap}}), + {{- if .ValidValues}} + stringvalidator.OneOf({{- validatorStringCustomType .ValidValues .ValidValuesMap}}), + {{- end}} validators.InBetweenFromString({{- index .Validators 0 "min"}}, {{- index .Validators 0 "max"}}), ), }, diff --git a/gen/templates/resource.md.tmpl b/gen/templates/resource.md.tmpl index cbfca70f7..79b776b63 100644 --- a/gen/templates/resource.md.tmpl +++ b/gen/templates/resource.md.tmpl @@ -79,8 +79,10 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the * `{{- overwriteProperty .PkgName .SnakeCaseName $.Definitions}}` ({{- .PropertyName}}) - (string) {{.Comment}}{{if ne .NamedPropertyClass ""}}{{$RName := getResourceName .NamedPropertyClass $.Definitions}} This attribute can be referenced from a [resource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/{{$RName}}) with `aci_{{$RName}}.example.name` or from a [datasource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/data-sources/{{$RName}}) with `data.aci_{{$RName}}.example.name`.{{end}}{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} {{- if and .HasCustomType (hasCustomTypeDocs .PkgName .Name $.Definitions)}}{{$i := 1}}{{$length := len .ValidValues}} - Valid Values: + {{- if .ValidValues}} *{{ range .ValidValues}} `"{{ . }}"`{{ if ne $length $i}}{{$i = add $i 1}}, {{- else}}.{{- end}}{{- end}} - * Or a value in the range of `{{ printf "%.0f" (index .Validators 0 "min") }}` to `{{ printf "%.0f" (index .Validators 0 "max") }}`. + {{- end}} + * {{if .ValidValues}}Or a{{else}}A{{end}} value in the range of `{{ printf "%.0f" (index .Validators 0 "min") }}` to `{{ printf "%.0f" (index .Validators 0 "max") }}`. {{- else if .ValidValues }}{{$i := 1}}{{$length := len .ValidValues}} - Valid Values:{{ range .ValidValues}} `"{{ . }}"`{{ if ne $length $i}}{{$i = add $i 1}}, {{- else}}.{{- end}}{{- end}} {{- end}} @@ -143,8 +145,10 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the {{- end}} {{- if and .HasCustomType (hasCustomTypeDocs .PkgName .Name $.Definitions)}}{{$i := 1}}{{$length := len .ValidValues}} - Valid Values: + {{- if .ValidValues}} *{{ range .ValidValues}} `"{{ . }}"`{{ if ne $length $i}}{{$i = add $i 1}}, {{- else}}.{{- end}}{{- end}} - * Or a value in the range of `{{ printf "%.0f" (index .Validators 0 "min") }}` to `{{ printf "%.0f" (index .Validators 0 "max") }}`. + {{- end}} + * {{if .ValidValues}}Or a{{else}}A{{end}} value in the range of `{{ printf "%.0f" (index .Validators 0 "min") }}` to `{{ printf "%.0f" (index .Validators 0 "max") }}`. {{- else if .ValidValues }}{{$i := 1}}{{$length := len .ValidValues}} - Valid Values:{{ range .ValidValues}} `"{{ . }}"`{{ if ne $length $i}}{{$i = add $i 1}}, {{- else}}.{{- end}}{{- end}} {{- end}} @@ -221,8 +225,10 @@ import { {{ $indent }}* `{{- overwriteProperty .PkgName .SnakeCaseName $.Definitions}}` ({{- .PropertyName}}) - (string) {{.Comment}}{{if ne .NamedPropertyClass ""}}{{$RName := getResourceName .NamedPropertyClass $.Definitions}} This attribute can be referenced from a [resource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/{{$RName}}) with `aci_{{$RName}}.example.name` or from a [datasource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/data-sources/{{$RName}}) with `data.aci_{{$RName}}.example.name`.{{end}}{{if ne $childVersion .Versions}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} {{- if and .HasCustomType (hasCustomTypeDocs .PkgName .Name $.Definitions)}}{{$i := 1}}{{$length := len .ValidValues}} {{ $indent }} - Valid Values: + {{- if .ValidValues}} {{ $indent }} *{{ range .ValidValues}} `"{{ . }}"`{{ if ne $length $i}}{{$i = add $i 1}}, {{- else}}.{{- end}}{{- end}} - {{ $indent }} * Or a value in the range of `{{ printf "%.0f" (index .Validators 0 "min") }}` to `{{ printf "%.0f" (index .Validators 0 "max") }}`. + {{- end}} + {{ $indent }} * {{if .ValidValues}}Or a{{else}}A{{end}} value in the range of `{{ printf "%.0f" (index .Validators 0 "min") }}` to `{{ printf "%.0f" (index .Validators 0 "max") }}`. {{- else if .ValidValues }}{{$i := 1}}{{$length := len .ValidValues}} {{ $indent }} - Valid Values:{{ range .ValidValues}} `"{{ . }}"`{{ if ne $length $i}}{{$i = add $i 1}}, {{- else}}.{{- end}}{{- end}} {{- end}} diff --git a/gen/templates/testvars.yaml.tmpl b/gen/templates/testvars.yaml.tmpl index 77e2b4aab..1d1e6afa4 100644 --- a/gen/templates/testvars.yaml.tmpl +++ b/gen/templates/testvars.yaml.tmpl @@ -141,8 +141,10 @@ resource_required: custom_type: {{- range .Properties}}{{$testValue := createTestValue .SnakeCaseName}}{{$overwritePropertyName := overwriteProperty .PkgName .SnakeCaseName $.Definitions}} - {{- if .HasCustomType}} + {{- if and .HasCustomType (not .StaticCustomType)}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: {{$validValuesMap := .ValidValuesMap}}{{range $key, $value := $validValuesMap}}{{- if or (ne $value "unspecified") (eq (len $validValuesMap) 1)}}"{{$key}}"{{break}}{{end}}{{end}} + {{- else if or (and .HasCustomType .StaticCustomType) .IncludeInCustomTypeTest }} + {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: "{{overwritePropertyValue .PkgName $overwritePropertyName $testValue "custom_type" 0 $.Definitions}}" {{- else if or .IsNaming (or .IsRequired (isRequiredInTestValue .PkgName $overwritePropertyName $.Definitions "resource_required"))}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: "{{overwritePropertyValue .PkgName $overwritePropertyName $testValue "resource_required" 0 $.Definitions}}" {{- end}} diff --git a/gen/testvars/stormctrlIfPol.yaml b/gen/testvars/stormctrlIfPol.yaml new file mode 100644 index 000000000..e13716ee9 --- /dev/null +++ b/gen/testvars/stormctrlIfPol.yaml @@ -0,0 +1,109 @@ +# 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" + broadcast_burst_rate_packets_per_second: "unspecified" + broadcast_burst_rate_percentage: "100.000000" + broadcast_rate_percentage: "100.000000" + broadcast_rate_packets_per_second: "unspecified" + burst_rate_packets_per_second: "unspecified" + burst_rate_percentage: "100.000000" + description: "" + unicast_multicast_broadcast: "Invalid" + multicast_burst_rate_packets_per_second: "unspecified" + multicast_burst_rate_percentage: "100.000000" + multicast_rate_percentage: "100.000000" + multicast_rate_packets_per_second: "unspecified" + name_alias: "" + owner_key: "" + owner_tag: "" + rate_percentage: "100.000000" + rate_packets_per_second: "unspecified" + unicast_burst_rate_packets_per_second: "unspecified" + unicast_burst_rate_percentage: "100.000000" + unicast_rate_percentage: "100.000000" + unicast_rate_packets_per_second: "unspecified" + version_mismatch: + 4.1(1i)-: + action: "drop" + soak_count: "3" + +datasource_non_existing: + name: "non_existing_name" + +datasource_required: + name: "test_name" + +resource_required: + name: "test_name" + +custom_type: + broadcast_burst_rate_packets_per_second: "0xffffffff" + broadcast_burst_rate_percentage: "100.000000" + broadcast_rate_percentage: "90" + broadcast_rate_packets_per_second: "0xffffffff" + burst_rate_packets_per_second: "0xffffffff" + burst_rate_percentage: "100.000000" + unicast_multicast_broadcast: "Valid" + multicast_burst_rate_packets_per_second: "0xffffffff" + multicast_burst_rate_percentage: "95.4556" + multicast_rate_percentage: "80.1" + multicast_rate_packets_per_second: "0xffffffff" + name: "test_name" + rate_percentage: "100.000000" + rate_packets_per_second: "0xffffffff" + unicast_burst_rate_packets_per_second: "0xffffffff" + unicast_burst_rate_percentage: "64.736" + unicast_rate_percentage: "50.56" + unicast_rate_packets_per_second: "0xffffffff" + +all: + annotation: "annotation" + broadcast_burst_rate_packets_per_second: "11" + broadcast_burst_rate_percentage: "100.000000" + broadcast_rate_percentage: "100.000000" + broadcast_rate_packets_per_second: "10" + burst_rate_packets_per_second: "unspecified" + burst_rate_percentage: "100.000000" + description: "description_1" + unicast_multicast_broadcast: "Valid" + multicast_burst_rate_packets_per_second: "13" + multicast_burst_rate_percentage: "100.000000" + multicast_rate_percentage: "100.000000" + multicast_rate_packets_per_second: "12" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + rate_percentage: "100.000000" + rate_packets_per_second: "unspecified" + unicast_burst_rate_packets_per_second: "15" + unicast_burst_rate_percentage: "100.000000" + unicast_rate_percentage: "100.000000" + unicast_rate_packets_per_second: "14" + version_mismatch: + 4.1(1i)-: + action: "drop" + soak_count: "3" + +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" + + +test_type: apic +class_version: 1.0(2j)- +version_mismatch: true diff --git a/internal/custom_types/roundedPercentage.go b/internal/custom_types/roundedPercentage.go new file mode 100644 index 000000000..16d552587 --- /dev/null +++ b/internal/custom_types/roundedPercentage.go @@ -0,0 +1,175 @@ +package customTypes + +import ( + "context" + "fmt" + "strconv" + "strings" + + "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" +) + +// RoundedPercentage custom string type. + +var _ basetypes.StringTypable = RoundedPercentageStringType{} + +type RoundedPercentageStringType struct { + basetypes.StringType +} + +func (t RoundedPercentageStringType) Equal(o attr.Type) bool { + other, ok := o.(RoundedPercentageStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t RoundedPercentageStringType) String() string { + return "RoundedPercentageStringType" +} + +func (t RoundedPercentageStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := RoundedPercentageStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t RoundedPercentageStringType) 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 RoundedPercentageStringType) ValueType(ctx context.Context) attr.Value { + return RoundedPercentageStringValue{} +} + +// RoundedPercentage custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = RoundedPercentageStringValue{} + +type RoundedPercentageStringValue struct { + basetypes.StringValue +} + +func (v RoundedPercentageStringValue) Equal(o attr.Value) bool { + other, ok := o.(RoundedPercentageStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v RoundedPercentageStringValue) Type(ctx context.Context) attr.Type { + return RoundedPercentageStringType{} +} + +func (v RoundedPercentageStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(RoundedPercentageStringValue) + + 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, err := RoundPercentageValue(v.StringValue) + + if err != nil { + addRoudingError(err, &diags) + } + + newMappedValue, err := RoundPercentageValue(newValue.StringValue) + + if err != nil { + addRoudingError(err, &diags) + } + + return priorMappedValue.Equal(newMappedValue), diags +} + +func addRoudingError(err error, diags *diag.Diagnostics) { + + if err != nil { + diags.AddError( + "Semantic Equality Check Error", + "Rounding of percentage value failed while performing semantic equality checks. "+ + "Please report this to the provider developers.\n\n"+ + "Error: "+fmt.Sprintf("%v", err), + ) + } +} + +func (v RoundedPercentageStringValue) NamedValueString() string { + roundedPercentage, _ := RoundPercentageValue(v.StringValue) + return roundedPercentage.ValueString() +} + +func RoundPercentageValue(value basetypes.StringValue) (basetypes.StringValue, error) { + + percentage, err := strconv.ParseFloat(strings.TrimSpace(value.ValueString()), 64) + + if err != nil { + return basetypes.NewStringNull(), err + } + + return basetypes.NewStringValue(strconv.FormatFloat(percentage, 'f', 2, 64)), err +} + +func NewRoundedPercentageStringNull() RoundedPercentageStringValue { + return RoundedPercentageStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewRoundedPercentageStringUnknown() RoundedPercentageStringValue { + return RoundedPercentageStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewRoundedPercentageStringValue(value string) RoundedPercentageStringValue { + return RoundedPercentageStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewRoundedPercentageStringPointerValue(value *string) RoundedPercentageStringValue { + return RoundedPercentageStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/stormctrlIfPol_bcBurstPps.go b/internal/custom_types/stormctrlIfPol_bcBurstPps.go new file mode 100644 index 000000000..7728b0129 --- /dev/null +++ b/internal/custom_types/stormctrlIfPol_bcBurstPps.go @@ -0,0 +1,153 @@ +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" +) + +// StormctrlIfPolBcBurstPps custom string type. + +var _ basetypes.StringTypable = StormctrlIfPolBcBurstPpsStringType{} + +type StormctrlIfPolBcBurstPpsStringType struct { + basetypes.StringType +} + +func (t StormctrlIfPolBcBurstPpsStringType) Equal(o attr.Type) bool { + other, ok := o.(StormctrlIfPolBcBurstPpsStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t StormctrlIfPolBcBurstPpsStringType) String() string { + return "StormctrlIfPolBcBurstPpsStringType" +} + +func (t StormctrlIfPolBcBurstPpsStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := StormctrlIfPolBcBurstPpsStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t StormctrlIfPolBcBurstPpsStringType) 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 StormctrlIfPolBcBurstPpsStringType) ValueType(ctx context.Context) attr.Value { + return StormctrlIfPolBcBurstPpsStringValue{} +} + +// StormctrlIfPolBcBurstPps custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = StormctrlIfPolBcBurstPpsStringValue{} + +type StormctrlIfPolBcBurstPpsStringValue struct { + basetypes.StringValue +} + +func (v StormctrlIfPolBcBurstPpsStringValue) Equal(o attr.Value) bool { + other, ok := o.(StormctrlIfPolBcBurstPpsStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v StormctrlIfPolBcBurstPpsStringValue) Type(ctx context.Context) attr.Type { + return StormctrlIfPolBcBurstPpsStringType{} +} + +func (v StormctrlIfPolBcBurstPpsStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(StormctrlIfPolBcBurstPpsStringValue) + + 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 := StormctrlIfPolBcBurstPpsValueMap(v.StringValue) + + newMappedValue := StormctrlIfPolBcBurstPpsValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v StormctrlIfPolBcBurstPpsStringValue) NamedValueString() string { + return StormctrlIfPolBcBurstPpsValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func StormctrlIfPolBcBurstPpsValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0xffffffff": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewStormctrlIfPolBcBurstPpsStringNull() StormctrlIfPolBcBurstPpsStringValue { + return StormctrlIfPolBcBurstPpsStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewStormctrlIfPolBcBurstPpsStringUnknown() StormctrlIfPolBcBurstPpsStringValue { + return StormctrlIfPolBcBurstPpsStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewStormctrlIfPolBcBurstPpsStringValue(value string) StormctrlIfPolBcBurstPpsStringValue { + return StormctrlIfPolBcBurstPpsStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewStormctrlIfPolBcBurstPpsStringPointerValue(value *string) StormctrlIfPolBcBurstPpsStringValue { + return StormctrlIfPolBcBurstPpsStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/stormctrlIfPol_bcRatePps.go b/internal/custom_types/stormctrlIfPol_bcRatePps.go new file mode 100644 index 000000000..33f32eadf --- /dev/null +++ b/internal/custom_types/stormctrlIfPol_bcRatePps.go @@ -0,0 +1,153 @@ +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" +) + +// StormctrlIfPolBcRatePps custom string type. + +var _ basetypes.StringTypable = StormctrlIfPolBcRatePpsStringType{} + +type StormctrlIfPolBcRatePpsStringType struct { + basetypes.StringType +} + +func (t StormctrlIfPolBcRatePpsStringType) Equal(o attr.Type) bool { + other, ok := o.(StormctrlIfPolBcRatePpsStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t StormctrlIfPolBcRatePpsStringType) String() string { + return "StormctrlIfPolBcRatePpsStringType" +} + +func (t StormctrlIfPolBcRatePpsStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := StormctrlIfPolBcRatePpsStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t StormctrlIfPolBcRatePpsStringType) 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 StormctrlIfPolBcRatePpsStringType) ValueType(ctx context.Context) attr.Value { + return StormctrlIfPolBcRatePpsStringValue{} +} + +// StormctrlIfPolBcRatePps custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = StormctrlIfPolBcRatePpsStringValue{} + +type StormctrlIfPolBcRatePpsStringValue struct { + basetypes.StringValue +} + +func (v StormctrlIfPolBcRatePpsStringValue) Equal(o attr.Value) bool { + other, ok := o.(StormctrlIfPolBcRatePpsStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v StormctrlIfPolBcRatePpsStringValue) Type(ctx context.Context) attr.Type { + return StormctrlIfPolBcRatePpsStringType{} +} + +func (v StormctrlIfPolBcRatePpsStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(StormctrlIfPolBcRatePpsStringValue) + + 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 := StormctrlIfPolBcRatePpsValueMap(v.StringValue) + + newMappedValue := StormctrlIfPolBcRatePpsValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v StormctrlIfPolBcRatePpsStringValue) NamedValueString() string { + return StormctrlIfPolBcRatePpsValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func StormctrlIfPolBcRatePpsValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0xffffffff": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewStormctrlIfPolBcRatePpsStringNull() StormctrlIfPolBcRatePpsStringValue { + return StormctrlIfPolBcRatePpsStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewStormctrlIfPolBcRatePpsStringUnknown() StormctrlIfPolBcRatePpsStringValue { + return StormctrlIfPolBcRatePpsStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewStormctrlIfPolBcRatePpsStringValue(value string) StormctrlIfPolBcRatePpsStringValue { + return StormctrlIfPolBcRatePpsStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewStormctrlIfPolBcRatePpsStringPointerValue(value *string) StormctrlIfPolBcRatePpsStringValue { + return StormctrlIfPolBcRatePpsStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/stormctrlIfPol_burstPps.go b/internal/custom_types/stormctrlIfPol_burstPps.go new file mode 100644 index 000000000..dd5c5c0a5 --- /dev/null +++ b/internal/custom_types/stormctrlIfPol_burstPps.go @@ -0,0 +1,153 @@ +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" +) + +// StormctrlIfPolBurstPps custom string type. + +var _ basetypes.StringTypable = StormctrlIfPolBurstPpsStringType{} + +type StormctrlIfPolBurstPpsStringType struct { + basetypes.StringType +} + +func (t StormctrlIfPolBurstPpsStringType) Equal(o attr.Type) bool { + other, ok := o.(StormctrlIfPolBurstPpsStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t StormctrlIfPolBurstPpsStringType) String() string { + return "StormctrlIfPolBurstPpsStringType" +} + +func (t StormctrlIfPolBurstPpsStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := StormctrlIfPolBurstPpsStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t StormctrlIfPolBurstPpsStringType) 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 StormctrlIfPolBurstPpsStringType) ValueType(ctx context.Context) attr.Value { + return StormctrlIfPolBurstPpsStringValue{} +} + +// StormctrlIfPolBurstPps custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = StormctrlIfPolBurstPpsStringValue{} + +type StormctrlIfPolBurstPpsStringValue struct { + basetypes.StringValue +} + +func (v StormctrlIfPolBurstPpsStringValue) Equal(o attr.Value) bool { + other, ok := o.(StormctrlIfPolBurstPpsStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v StormctrlIfPolBurstPpsStringValue) Type(ctx context.Context) attr.Type { + return StormctrlIfPolBurstPpsStringType{} +} + +func (v StormctrlIfPolBurstPpsStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(StormctrlIfPolBurstPpsStringValue) + + 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 := StormctrlIfPolBurstPpsValueMap(v.StringValue) + + newMappedValue := StormctrlIfPolBurstPpsValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v StormctrlIfPolBurstPpsStringValue) NamedValueString() string { + return StormctrlIfPolBurstPpsValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func StormctrlIfPolBurstPpsValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0xffffffff": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewStormctrlIfPolBurstPpsStringNull() StormctrlIfPolBurstPpsStringValue { + return StormctrlIfPolBurstPpsStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewStormctrlIfPolBurstPpsStringUnknown() StormctrlIfPolBurstPpsStringValue { + return StormctrlIfPolBurstPpsStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewStormctrlIfPolBurstPpsStringValue(value string) StormctrlIfPolBurstPpsStringValue { + return StormctrlIfPolBurstPpsStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewStormctrlIfPolBurstPpsStringPointerValue(value *string) StormctrlIfPolBurstPpsStringValue { + return StormctrlIfPolBurstPpsStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/stormctrlIfPol_mcBurstPps.go b/internal/custom_types/stormctrlIfPol_mcBurstPps.go new file mode 100644 index 000000000..85fa9a065 --- /dev/null +++ b/internal/custom_types/stormctrlIfPol_mcBurstPps.go @@ -0,0 +1,153 @@ +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" +) + +// StormctrlIfPolMcBurstPps custom string type. + +var _ basetypes.StringTypable = StormctrlIfPolMcBurstPpsStringType{} + +type StormctrlIfPolMcBurstPpsStringType struct { + basetypes.StringType +} + +func (t StormctrlIfPolMcBurstPpsStringType) Equal(o attr.Type) bool { + other, ok := o.(StormctrlIfPolMcBurstPpsStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t StormctrlIfPolMcBurstPpsStringType) String() string { + return "StormctrlIfPolMcBurstPpsStringType" +} + +func (t StormctrlIfPolMcBurstPpsStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := StormctrlIfPolMcBurstPpsStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t StormctrlIfPolMcBurstPpsStringType) 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 StormctrlIfPolMcBurstPpsStringType) ValueType(ctx context.Context) attr.Value { + return StormctrlIfPolMcBurstPpsStringValue{} +} + +// StormctrlIfPolMcBurstPps custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = StormctrlIfPolMcBurstPpsStringValue{} + +type StormctrlIfPolMcBurstPpsStringValue struct { + basetypes.StringValue +} + +func (v StormctrlIfPolMcBurstPpsStringValue) Equal(o attr.Value) bool { + other, ok := o.(StormctrlIfPolMcBurstPpsStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v StormctrlIfPolMcBurstPpsStringValue) Type(ctx context.Context) attr.Type { + return StormctrlIfPolMcBurstPpsStringType{} +} + +func (v StormctrlIfPolMcBurstPpsStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(StormctrlIfPolMcBurstPpsStringValue) + + 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 := StormctrlIfPolMcBurstPpsValueMap(v.StringValue) + + newMappedValue := StormctrlIfPolMcBurstPpsValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v StormctrlIfPolMcBurstPpsStringValue) NamedValueString() string { + return StormctrlIfPolMcBurstPpsValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func StormctrlIfPolMcBurstPpsValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0xffffffff": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewStormctrlIfPolMcBurstPpsStringNull() StormctrlIfPolMcBurstPpsStringValue { + return StormctrlIfPolMcBurstPpsStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewStormctrlIfPolMcBurstPpsStringUnknown() StormctrlIfPolMcBurstPpsStringValue { + return StormctrlIfPolMcBurstPpsStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewStormctrlIfPolMcBurstPpsStringValue(value string) StormctrlIfPolMcBurstPpsStringValue { + return StormctrlIfPolMcBurstPpsStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewStormctrlIfPolMcBurstPpsStringPointerValue(value *string) StormctrlIfPolMcBurstPpsStringValue { + return StormctrlIfPolMcBurstPpsStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/stormctrlIfPol_mcRatePps.go b/internal/custom_types/stormctrlIfPol_mcRatePps.go new file mode 100644 index 000000000..14f7ee829 --- /dev/null +++ b/internal/custom_types/stormctrlIfPol_mcRatePps.go @@ -0,0 +1,153 @@ +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" +) + +// StormctrlIfPolMcRatePps custom string type. + +var _ basetypes.StringTypable = StormctrlIfPolMcRatePpsStringType{} + +type StormctrlIfPolMcRatePpsStringType struct { + basetypes.StringType +} + +func (t StormctrlIfPolMcRatePpsStringType) Equal(o attr.Type) bool { + other, ok := o.(StormctrlIfPolMcRatePpsStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t StormctrlIfPolMcRatePpsStringType) String() string { + return "StormctrlIfPolMcRatePpsStringType" +} + +func (t StormctrlIfPolMcRatePpsStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := StormctrlIfPolMcRatePpsStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t StormctrlIfPolMcRatePpsStringType) 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 StormctrlIfPolMcRatePpsStringType) ValueType(ctx context.Context) attr.Value { + return StormctrlIfPolMcRatePpsStringValue{} +} + +// StormctrlIfPolMcRatePps custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = StormctrlIfPolMcRatePpsStringValue{} + +type StormctrlIfPolMcRatePpsStringValue struct { + basetypes.StringValue +} + +func (v StormctrlIfPolMcRatePpsStringValue) Equal(o attr.Value) bool { + other, ok := o.(StormctrlIfPolMcRatePpsStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v StormctrlIfPolMcRatePpsStringValue) Type(ctx context.Context) attr.Type { + return StormctrlIfPolMcRatePpsStringType{} +} + +func (v StormctrlIfPolMcRatePpsStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(StormctrlIfPolMcRatePpsStringValue) + + 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 := StormctrlIfPolMcRatePpsValueMap(v.StringValue) + + newMappedValue := StormctrlIfPolMcRatePpsValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v StormctrlIfPolMcRatePpsStringValue) NamedValueString() string { + return StormctrlIfPolMcRatePpsValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func StormctrlIfPolMcRatePpsValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0xffffffff": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewStormctrlIfPolMcRatePpsStringNull() StormctrlIfPolMcRatePpsStringValue { + return StormctrlIfPolMcRatePpsStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewStormctrlIfPolMcRatePpsStringUnknown() StormctrlIfPolMcRatePpsStringValue { + return StormctrlIfPolMcRatePpsStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewStormctrlIfPolMcRatePpsStringValue(value string) StormctrlIfPolMcRatePpsStringValue { + return StormctrlIfPolMcRatePpsStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewStormctrlIfPolMcRatePpsStringPointerValue(value *string) StormctrlIfPolMcRatePpsStringValue { + return StormctrlIfPolMcRatePpsStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/stormctrlIfPol_ratePps.go b/internal/custom_types/stormctrlIfPol_ratePps.go new file mode 100644 index 000000000..e6d481656 --- /dev/null +++ b/internal/custom_types/stormctrlIfPol_ratePps.go @@ -0,0 +1,153 @@ +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" +) + +// StormctrlIfPolRatePps custom string type. + +var _ basetypes.StringTypable = StormctrlIfPolRatePpsStringType{} + +type StormctrlIfPolRatePpsStringType struct { + basetypes.StringType +} + +func (t StormctrlIfPolRatePpsStringType) Equal(o attr.Type) bool { + other, ok := o.(StormctrlIfPolRatePpsStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t StormctrlIfPolRatePpsStringType) String() string { + return "StormctrlIfPolRatePpsStringType" +} + +func (t StormctrlIfPolRatePpsStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := StormctrlIfPolRatePpsStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t StormctrlIfPolRatePpsStringType) 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 StormctrlIfPolRatePpsStringType) ValueType(ctx context.Context) attr.Value { + return StormctrlIfPolRatePpsStringValue{} +} + +// StormctrlIfPolRatePps custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = StormctrlIfPolRatePpsStringValue{} + +type StormctrlIfPolRatePpsStringValue struct { + basetypes.StringValue +} + +func (v StormctrlIfPolRatePpsStringValue) Equal(o attr.Value) bool { + other, ok := o.(StormctrlIfPolRatePpsStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v StormctrlIfPolRatePpsStringValue) Type(ctx context.Context) attr.Type { + return StormctrlIfPolRatePpsStringType{} +} + +func (v StormctrlIfPolRatePpsStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(StormctrlIfPolRatePpsStringValue) + + 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 := StormctrlIfPolRatePpsValueMap(v.StringValue) + + newMappedValue := StormctrlIfPolRatePpsValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v StormctrlIfPolRatePpsStringValue) NamedValueString() string { + return StormctrlIfPolRatePpsValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func StormctrlIfPolRatePpsValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0xffffffff": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewStormctrlIfPolRatePpsStringNull() StormctrlIfPolRatePpsStringValue { + return StormctrlIfPolRatePpsStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewStormctrlIfPolRatePpsStringUnknown() StormctrlIfPolRatePpsStringValue { + return StormctrlIfPolRatePpsStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewStormctrlIfPolRatePpsStringValue(value string) StormctrlIfPolRatePpsStringValue { + return StormctrlIfPolRatePpsStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewStormctrlIfPolRatePpsStringPointerValue(value *string) StormctrlIfPolRatePpsStringValue { + return StormctrlIfPolRatePpsStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/stormctrlIfPol_uucBurstPps.go b/internal/custom_types/stormctrlIfPol_uucBurstPps.go new file mode 100644 index 000000000..f1665518b --- /dev/null +++ b/internal/custom_types/stormctrlIfPol_uucBurstPps.go @@ -0,0 +1,153 @@ +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" +) + +// StormctrlIfPolUucBurstPps custom string type. + +var _ basetypes.StringTypable = StormctrlIfPolUucBurstPpsStringType{} + +type StormctrlIfPolUucBurstPpsStringType struct { + basetypes.StringType +} + +func (t StormctrlIfPolUucBurstPpsStringType) Equal(o attr.Type) bool { + other, ok := o.(StormctrlIfPolUucBurstPpsStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t StormctrlIfPolUucBurstPpsStringType) String() string { + return "StormctrlIfPolUucBurstPpsStringType" +} + +func (t StormctrlIfPolUucBurstPpsStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := StormctrlIfPolUucBurstPpsStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t StormctrlIfPolUucBurstPpsStringType) 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 StormctrlIfPolUucBurstPpsStringType) ValueType(ctx context.Context) attr.Value { + return StormctrlIfPolUucBurstPpsStringValue{} +} + +// StormctrlIfPolUucBurstPps custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = StormctrlIfPolUucBurstPpsStringValue{} + +type StormctrlIfPolUucBurstPpsStringValue struct { + basetypes.StringValue +} + +func (v StormctrlIfPolUucBurstPpsStringValue) Equal(o attr.Value) bool { + other, ok := o.(StormctrlIfPolUucBurstPpsStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v StormctrlIfPolUucBurstPpsStringValue) Type(ctx context.Context) attr.Type { + return StormctrlIfPolUucBurstPpsStringType{} +} + +func (v StormctrlIfPolUucBurstPpsStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(StormctrlIfPolUucBurstPpsStringValue) + + 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 := StormctrlIfPolUucBurstPpsValueMap(v.StringValue) + + newMappedValue := StormctrlIfPolUucBurstPpsValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v StormctrlIfPolUucBurstPpsStringValue) NamedValueString() string { + return StormctrlIfPolUucBurstPpsValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func StormctrlIfPolUucBurstPpsValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0xffffffff": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewStormctrlIfPolUucBurstPpsStringNull() StormctrlIfPolUucBurstPpsStringValue { + return StormctrlIfPolUucBurstPpsStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewStormctrlIfPolUucBurstPpsStringUnknown() StormctrlIfPolUucBurstPpsStringValue { + return StormctrlIfPolUucBurstPpsStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewStormctrlIfPolUucBurstPpsStringValue(value string) StormctrlIfPolUucBurstPpsStringValue { + return StormctrlIfPolUucBurstPpsStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewStormctrlIfPolUucBurstPpsStringPointerValue(value *string) StormctrlIfPolUucBurstPpsStringValue { + return StormctrlIfPolUucBurstPpsStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/custom_types/stormctrlIfPol_uucRatePps.go b/internal/custom_types/stormctrlIfPol_uucRatePps.go new file mode 100644 index 000000000..3ffaee296 --- /dev/null +++ b/internal/custom_types/stormctrlIfPol_uucRatePps.go @@ -0,0 +1,153 @@ +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" +) + +// StormctrlIfPolUucRatePps custom string type. + +var _ basetypes.StringTypable = StormctrlIfPolUucRatePpsStringType{} + +type StormctrlIfPolUucRatePpsStringType struct { + basetypes.StringType +} + +func (t StormctrlIfPolUucRatePpsStringType) Equal(o attr.Type) bool { + other, ok := o.(StormctrlIfPolUucRatePpsStringType) + + if !ok { + return false + } + + return t.StringType.Equal(other.StringType) +} + +func (t StormctrlIfPolUucRatePpsStringType) String() string { + return "StormctrlIfPolUucRatePpsStringType" +} + +func (t StormctrlIfPolUucRatePpsStringType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) { + value := StormctrlIfPolUucRatePpsStringValue{ + StringValue: in, + } + + return value, nil +} + +func (t StormctrlIfPolUucRatePpsStringType) 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 StormctrlIfPolUucRatePpsStringType) ValueType(ctx context.Context) attr.Value { + return StormctrlIfPolUucRatePpsStringValue{} +} + +// StormctrlIfPolUucRatePps custom string value. + +var _ basetypes.StringValuableWithSemanticEquals = StormctrlIfPolUucRatePpsStringValue{} + +type StormctrlIfPolUucRatePpsStringValue struct { + basetypes.StringValue +} + +func (v StormctrlIfPolUucRatePpsStringValue) Equal(o attr.Value) bool { + other, ok := o.(StormctrlIfPolUucRatePpsStringValue) + + if !ok { + return false + } + + return v.StringValue.Equal(other.StringValue) +} + +func (v StormctrlIfPolUucRatePpsStringValue) Type(ctx context.Context) attr.Type { + return StormctrlIfPolUucRatePpsStringType{} +} + +func (v StormctrlIfPolUucRatePpsStringValue) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) { + var diags diag.Diagnostics + + newValue, ok := newValuable.(StormctrlIfPolUucRatePpsStringValue) + + 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 := StormctrlIfPolUucRatePpsValueMap(v.StringValue) + + newMappedValue := StormctrlIfPolUucRatePpsValueMap(newValue.StringValue) + + return priorMappedValue.Equal(newMappedValue), diags +} + +func (v StormctrlIfPolUucRatePpsStringValue) NamedValueString() string { + return StormctrlIfPolUucRatePpsValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + +func StormctrlIfPolUucRatePpsValueMap(value basetypes.StringValue) basetypes.StringValue { + matchMap := map[string]string{ + "0xffffffff": "unspecified", + } + + if val, ok := matchMap[value.ValueString()]; ok { + return basetypes.NewStringValue(val) + } + + return value +} + +func NewStormctrlIfPolUucRatePpsStringNull() StormctrlIfPolUucRatePpsStringValue { + return StormctrlIfPolUucRatePpsStringValue{ + StringValue: basetypes.NewStringNull(), + } +} + +func NewStormctrlIfPolUucRatePpsStringUnknown() StormctrlIfPolUucRatePpsStringValue { + return StormctrlIfPolUucRatePpsStringValue{ + StringValue: basetypes.NewStringUnknown(), + } +} + +func NewStormctrlIfPolUucRatePpsStringValue(value string) StormctrlIfPolUucRatePpsStringValue { + return StormctrlIfPolUucRatePpsStringValue{ + StringValue: basetypes.NewStringValue(value), + } +} + +func NewStormctrlIfPolUucRatePpsStringPointerValue(value *string) StormctrlIfPolUucRatePpsStringValue { + return StormctrlIfPolUucRatePpsStringValue{ + StringValue: basetypes.NewStringPointerValue(value), + } +} diff --git a/internal/provider/data_source_aci_storm_control_interface_policy.go b/internal/provider/data_source_aci_storm_control_interface_policy.go new file mode 100644 index 000000000..5c692aa2f --- /dev/null +++ b/internal/provider/data_source_aci_storm_control_interface_policy.go @@ -0,0 +1,254 @@ +// 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 = &StormctrlIfPolDataSource{} + +func NewStormctrlIfPolDataSource() datasource.DataSource { + return &StormctrlIfPolDataSource{} +} + +// StormctrlIfPolDataSource defines the data source implementation. +type StormctrlIfPolDataSource struct { + client *client.Client +} + +func (d *StormctrlIfPolDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_storm_control_interface_policy") + resp.TypeName = req.ProviderTypeName + "_storm_control_interface_policy" + tflog.Debug(ctx, "End metadata of datasource: aci_storm_control_interface_policy") +} + +func (d *StormctrlIfPolDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_storm_control_interface_policy") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The storm_control_interface_policy datasource for the 'stormctrlIfPol' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Storm Control Interface Policy object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Storm Control Interface Policy object.`, + }, + "broadcast_burst_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolBcBurstPpsStringType{}, + Computed: true, + MarkdownDescription: `The broadcast burst interval rate in packets per second for the Storm Control Interface Policy object.`, + }, + "broadcast_burst_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Computed: true, + MarkdownDescription: `The broadcast burst rate in percentage for the Storm Control Interface Policy object.`, + }, + "broadcast_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Computed: true, + MarkdownDescription: `The broadcast rate in percentage for the Storm Control Interface Policy object.`, + }, + "broadcast_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolBcRatePpsStringType{}, + Computed: true, + MarkdownDescription: `The broadcast rate in packets per second for the Storm Control Interface Policy object.`, + }, + "burst_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolBurstPpsStringType{}, + Computed: true, + MarkdownDescription: `The burst interval rate in packets per second for the Storm Control Interface Policy object.`, + }, + "burst_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Computed: true, + MarkdownDescription: `The burst rate in percentage for the Storm Control Interface Policy object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Storm Control Interface Policy object.`, + }, + "unicast_multicast_broadcast": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Configure the Storm Control Interface Policy object for unicast, multicast, and broadcast. Use 'Valid' when enabling the object for unicast, multicast, and broadcast.`, + }, + "multicast_burst_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolMcBurstPpsStringType{}, + Computed: true, + MarkdownDescription: `The multicast burst interval rate in packets per second for the Storm Control Interface Policy object.`, + }, + "multicast_burst_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Computed: true, + MarkdownDescription: `The multicast burst rate in percentage for the Storm Control Interface Policy object.`, + }, + "multicast_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Computed: true, + MarkdownDescription: `The multicast rate in percentage for the Storm Control Interface Policy object.`, + }, + "multicast_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolMcRatePpsStringType{}, + Computed: true, + MarkdownDescription: `The multicast rate in packets per second for the Storm Control Interface Policy object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Storm Control Interface Policy object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Storm Control Interface Policy object.`, + }, + "owner_key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, + }, + "owner_tag": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Computed: true, + MarkdownDescription: `The rate in percentage for the Storm Control Interface Policy object.`, + }, + "rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolRatePpsStringType{}, + Computed: true, + MarkdownDescription: `The rate in packets per second for the Storm Control Interface Policy object.`, + }, + "action": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The action of the Storm Control Interface Policy object.`, + }, + "soak_count": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The soak count for the Storm Control Interface Policy object. The value must be in the range 3 - 10.`, + }, + "unicast_burst_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolUucBurstPpsStringType{}, + Computed: true, + MarkdownDescription: `The unicast burst interval rate in packets per second for the Storm Control Interface Policy object.`, + }, + "unicast_burst_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Computed: true, + MarkdownDescription: `The unicast burst rate in percentage for the Storm Control Interface Policy object.`, + }, + "unicast_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Computed: true, + MarkdownDescription: `The unicast rate in percentage for the Storm Control Interface Policy object.`, + }, + "unicast_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolUucRatePpsStringType{}, + Computed: true, + MarkdownDescription: `The unicast rate in packets per second for the Storm Control Interface Policy object.`, + }, + "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_storm_control_interface_policy") +} + +func (d *StormctrlIfPolDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_storm_control_interface_policy") + // 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_storm_control_interface_policy") +} + +func (d *StormctrlIfPolDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_storm_control_interface_policy") + var data *StormctrlIfPolResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setStormctrlIfPolId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetStormctrlIfPolAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_storm_control_interface_policy with id '%s'", data.Id.ValueString())) + + getAndSetStormctrlIfPolAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_storm_control_interface_policy data source", + fmt.Sprintf("The aci_storm_control_interface_policy 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_storm_control_interface_policy with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_storm_control_interface_policy_test.go b/internal/provider/data_source_aci_storm_control_interface_policy_test.go new file mode 100644 index 000000000..4ba22c0ed --- /dev/null +++ b/internal/provider/data_source_aci_storm_control_interface_policy_test.go @@ -0,0 +1,69 @@ +// 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 TestAccDataSourceStormctrlIfPol(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(2j)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigStormctrlIfPolDataSource + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "11"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "10"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "description", "description_1"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "13"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "12"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "15"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Valid"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "14"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("data.aci_storm_control_interface_policy.test", "soak_count", "3")), + ), + }, + { + Config: testConfigStormctrlIfPolNotExisting + testConfigDataSourceSystem, + ExpectError: regexp.MustCompile("Failed to read aci_storm_control_interface_policy data source"), + }, + }, + }) +} + +const testConfigStormctrlIfPolDataSource = testConfigStormctrlIfPolAll + ` +data "aci_storm_control_interface_policy" "test" { + name = "test_name" + depends_on = [aci_storm_control_interface_policy.test] +} +` + +const testConfigStormctrlIfPolNotExisting = testConfigStormctrlIfPolAll + ` +data "aci_storm_control_interface_policy" "test_non_existing" { + name = "non_existing_name" +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 254787e2f..fb8f3eac7 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -294,6 +294,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewQosDscpClassResource, NewQosSdIfPolResource, NewRtctrlProfileResource, + NewStormctrlIfPolResource, NewSynceEthIfPolResource, NewTagAnnotationResource, NewTagTagResource, @@ -403,6 +404,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewQosDscpClassDataSource, NewQosSdIfPolDataSource, NewRtctrlProfileDataSource, + NewStormctrlIfPolDataSource, NewSynceEthIfPolDataSource, NewTagAnnotationDataSource, NewTagTagDataSource, diff --git a/internal/provider/resource_aci_storm_control_interface_policy.go b/internal/provider/resource_aci_storm_control_interface_policy.go new file mode 100644 index 000000000..2ce0ac884 --- /dev/null +++ b/internal/provider/resource_aci_storm_control_interface_policy.go @@ -0,0 +1,1130 @@ +// 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" + "strings" + + 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 = &StormctrlIfPolResource{} +var _ resource.ResourceWithImportState = &StormctrlIfPolResource{} + +func NewStormctrlIfPolResource() resource.Resource { + return &StormctrlIfPolResource{} +} + +// StormctrlIfPolResource defines the resource implementation. +type StormctrlIfPolResource struct { + client *client.Client +} + +// StormctrlIfPolResourceModel describes the resource data model. +type StormctrlIfPolResourceModel struct { + Id types.String `tfsdk:"id"` + Annotation types.String `tfsdk:"annotation"` + BcBurstPps customTypes.StormctrlIfPolBcBurstPpsStringValue `tfsdk:"broadcast_burst_rate_packets_per_second"` + BcBurstRate customTypes.RoundedPercentageStringValue `tfsdk:"broadcast_burst_rate_percentage"` + BcRate customTypes.RoundedPercentageStringValue `tfsdk:"broadcast_rate_percentage"` + BcRatePps customTypes.StormctrlIfPolBcRatePpsStringValue `tfsdk:"broadcast_rate_packets_per_second"` + BurstPps customTypes.StormctrlIfPolBurstPpsStringValue `tfsdk:"burst_rate_packets_per_second"` + BurstRate customTypes.RoundedPercentageStringValue `tfsdk:"burst_rate_percentage"` + Descr types.String `tfsdk:"description"` + IsUcMcBcStormPktCfgValid types.String `tfsdk:"unicast_multicast_broadcast"` + McBurstPps customTypes.StormctrlIfPolMcBurstPpsStringValue `tfsdk:"multicast_burst_rate_packets_per_second"` + McBurstRate customTypes.RoundedPercentageStringValue `tfsdk:"multicast_burst_rate_percentage"` + McRate customTypes.RoundedPercentageStringValue `tfsdk:"multicast_rate_percentage"` + McRatePps customTypes.StormctrlIfPolMcRatePpsStringValue `tfsdk:"multicast_rate_packets_per_second"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + Rate customTypes.RoundedPercentageStringValue `tfsdk:"rate_percentage"` + RatePps customTypes.StormctrlIfPolRatePpsStringValue `tfsdk:"rate_packets_per_second"` + StormCtrlAction types.String `tfsdk:"action"` + StormCtrlSoakInstCount types.String `tfsdk:"soak_count"` + UucBurstPps customTypes.StormctrlIfPolUucBurstPpsStringValue `tfsdk:"unicast_burst_rate_packets_per_second"` + UucBurstRate customTypes.RoundedPercentageStringValue `tfsdk:"unicast_burst_rate_percentage"` + UucRate customTypes.RoundedPercentageStringValue `tfsdk:"unicast_rate_percentage"` + UucRatePps customTypes.StormctrlIfPolUucRatePpsStringValue `tfsdk:"unicast_rate_packets_per_second"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyStormctrlIfPolResourceModel() *StormctrlIfPolResourceModel { + return &StormctrlIfPolResourceModel{ + Id: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + BcBurstPps: customTypes.NewStormctrlIfPolBcBurstPpsStringNull(), + BcBurstRate: customTypes.NewRoundedPercentageStringNull(), + BcRate: customTypes.NewRoundedPercentageStringNull(), + BcRatePps: customTypes.NewStormctrlIfPolBcRatePpsStringNull(), + BurstPps: customTypes.NewStormctrlIfPolBurstPpsStringNull(), + BurstRate: customTypes.NewRoundedPercentageStringNull(), + Descr: basetypes.NewStringNull(), + IsUcMcBcStormPktCfgValid: basetypes.NewStringNull(), + McBurstPps: customTypes.NewStormctrlIfPolMcBurstPpsStringNull(), + McBurstRate: customTypes.NewRoundedPercentageStringNull(), + McRate: customTypes.NewRoundedPercentageStringNull(), + McRatePps: customTypes.NewStormctrlIfPolMcRatePpsStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + Rate: customTypes.NewRoundedPercentageStringNull(), + RatePps: customTypes.NewStormctrlIfPolRatePpsStringNull(), + StormCtrlAction: basetypes.NewStringNull(), + StormCtrlSoakInstCount: basetypes.NewStringNull(), + UucBurstPps: customTypes.NewStormctrlIfPolUucBurstPpsStringNull(), + UucBurstRate: customTypes.NewRoundedPercentageStringNull(), + UucRate: customTypes.NewRoundedPercentageStringNull(), + UucRatePps: customTypes.NewStormctrlIfPolUucRatePpsStringNull(), + 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, + }, + }), + } +} + +// TagAnnotationStormctrlIfPolResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationStormctrlIfPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationStormctrlIfPolResourceModel() TagAnnotationStormctrlIfPolResourceModel { + return TagAnnotationStormctrlIfPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationStormctrlIfPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagStormctrlIfPolResourceModel describes the resource data model for the children without relation ships. +type TagTagStormctrlIfPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagStormctrlIfPolResourceModel() TagTagStormctrlIfPolResourceModel { + return TagTagStormctrlIfPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagStormctrlIfPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type StormctrlIfPolIdentifier struct { + Name types.String +} + +func (r *StormctrlIfPolResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *StormctrlIfPolResourceModel + 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.Name.IsUnknown() { + setStormctrlIfPolId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "stormctrlIfPol", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *StormctrlIfPolResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_storm_control_interface_policy") + resp.TypeName = req.ProviderTypeName + "_storm_control_interface_policy" + tflog.Debug(ctx, "End metadata of resource: aci_storm_control_interface_policy") +} + +func (r *StormctrlIfPolResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_storm_control_interface_policy") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The storm_control_interface_policy resource for the 'stormctrlIfPol' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Storm Control Interface Policy object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Storm Control Interface Policy object.`, + }, + "broadcast_burst_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolBcBurstPpsStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0xffffffff", "unspecified"), + validators.InBetweenFromString(0, 3.90625e+08), + ), + }, + MarkdownDescription: `The broadcast burst interval rate in packets per second for the Storm Control Interface Policy object.`, + }, + "broadcast_burst_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + validators.InBetweenFromString(0, 100), + ), + }, + MarkdownDescription: `The broadcast burst rate in percentage for the Storm Control Interface Policy object.`, + }, + "broadcast_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + validators.InBetweenFromString(0, 100), + ), + }, + MarkdownDescription: `The broadcast rate in percentage for the Storm Control Interface Policy object.`, + }, + "broadcast_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolBcRatePpsStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0xffffffff", "unspecified"), + validators.InBetweenFromString(0, 3.90625e+08), + ), + }, + MarkdownDescription: `The broadcast rate in packets per second for the Storm Control Interface Policy object.`, + }, + "burst_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolBurstPpsStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0xffffffff", "unspecified"), + validators.InBetweenFromString(0, 3.90625e+08), + ), + }, + MarkdownDescription: `The burst interval rate in packets per second for the Storm Control Interface Policy object.`, + }, + "burst_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + validators.InBetweenFromString(0, 100), + ), + }, + MarkdownDescription: `The burst rate in percentage for the Storm Control Interface Policy object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Storm Control Interface Policy object.`, + }, + "unicast_multicast_broadcast": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("Invalid", "Valid"), + }, + MarkdownDescription: `Configure the Storm Control Interface Policy object for unicast, multicast, and broadcast. Use 'Valid' when enabling the object for unicast, multicast, and broadcast.`, + }, + "multicast_burst_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolMcBurstPpsStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0xffffffff", "unspecified"), + validators.InBetweenFromString(0, 3.90625e+08), + ), + }, + MarkdownDescription: `The multicast burst interval rate in packets per second for the Storm Control Interface Policy object.`, + }, + "multicast_burst_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + validators.InBetweenFromString(0, 100), + ), + }, + MarkdownDescription: `The multicast burst rate in percentage for the Storm Control Interface Policy object.`, + }, + "multicast_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + validators.InBetweenFromString(0, 100), + ), + }, + MarkdownDescription: `The multicast rate in percentage for the Storm Control Interface Policy object.`, + }, + "multicast_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolMcRatePpsStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0xffffffff", "unspecified"), + validators.InBetweenFromString(0, 3.90625e+08), + ), + }, + MarkdownDescription: `The multicast rate in packets per second for the Storm Control Interface Policy object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Storm Control Interface Policy object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Storm Control Interface Policy object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, + }, + "owner_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + validators.InBetweenFromString(0, 100), + ), + }, + MarkdownDescription: `The rate in percentage for the Storm Control Interface Policy object.`, + }, + "rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolRatePpsStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0xffffffff", "unspecified"), + validators.InBetweenFromString(0, 3.90625e+08), + ), + }, + MarkdownDescription: `The rate in packets per second for the Storm Control Interface Policy object.`, + }, + "action": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("drop", "shutdown"), + }, + MarkdownDescription: `The action of the Storm Control Interface Policy object.`, + }, + "soak_count": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The soak count for the Storm Control Interface Policy object. The value must be in the range 3 - 10.`, + }, + "unicast_burst_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolUucBurstPpsStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0xffffffff", "unspecified"), + validators.InBetweenFromString(0, 3.90625e+08), + ), + }, + MarkdownDescription: `The unicast burst interval rate in packets per second for the Storm Control Interface Policy object.`, + }, + "unicast_burst_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + validators.InBetweenFromString(0, 100), + ), + }, + MarkdownDescription: `The unicast burst rate in percentage for the Storm Control Interface Policy object.`, + }, + "unicast_rate_percentage": schema.StringAttribute{ + CustomType: customTypes.RoundedPercentageStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + validators.InBetweenFromString(0, 100), + ), + }, + MarkdownDescription: `The unicast rate in percentage for the Storm Control Interface Policy object.`, + }, + "unicast_rate_packets_per_second": schema.StringAttribute{ + CustomType: customTypes.StormctrlIfPolUucRatePpsStringType{}, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.Any( + stringvalidator.OneOf("0xffffffff", "unspecified"), + validators.InBetweenFromString(0, 3.90625e+08), + ), + }, + MarkdownDescription: `The unicast rate in packets per second for the Storm Control Interface Policy object.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseNonNullStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseNonNullStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseNonNullStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_storm_control_interface_policy") +} + +func (r *StormctrlIfPolResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_storm_control_interface_policy") + // 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_storm_control_interface_policy") +} + +func (r *StormctrlIfPolResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_storm_control_interface_policy") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *StormctrlIfPolResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setStormctrlIfPolId(ctx, stateData) + } + getAndSetStormctrlIfPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The stormctrlIfPol object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *StormctrlIfPolResourceModel + + // 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() { + setStormctrlIfPolId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_storm_control_interface_policy with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationStormctrlIfPolResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagStormctrlIfPolResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getStormctrlIfPolCreateJsonPayload(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 + } + + getAndSetStormctrlIfPolAttributes(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_storm_control_interface_policy with id '%s'", data.Id.ValueString())) +} + +func (r *StormctrlIfPolResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_storm_control_interface_policy") + var data *StormctrlIfPolResourceModel + + // 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_storm_control_interface_policy with id '%s'", data.Id.ValueString())) + + getAndSetStormctrlIfPolAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *StormctrlIfPolResourceModel + 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_storm_control_interface_policy with id '%s'", data.Id.ValueString())) +} + +func (r *StormctrlIfPolResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_storm_control_interface_policy") + var data *StormctrlIfPolResourceModel + var stateData *StormctrlIfPolResourceModel + + // 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_storm_control_interface_policy with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationStormctrlIfPolResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagStormctrlIfPolResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getStormctrlIfPolCreateJsonPayload(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 + } + + getAndSetStormctrlIfPolAttributes(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_storm_control_interface_policy with id '%s'", data.Id.ValueString())) +} + +func (r *StormctrlIfPolResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_storm_control_interface_policy") + var data *StormctrlIfPolResourceModel + + // 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_storm_control_interface_policy with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "stormctrlIfPol", 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_storm_control_interface_policy with id '%s'", data.Id.ValueString())) +} + +func (r *StormctrlIfPolResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_storm_control_interface_policy") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *StormctrlIfPolResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_storm_control_interface_policy with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_storm_control_interface_policy") +} + +func getAndSetStormctrlIfPolAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *StormctrlIfPolResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "stormctrlIfPol,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyStormctrlIfPolResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("stormctrlIfPol").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("stormctrlIfPol").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)) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "bcBurstPps" { + readData.BcBurstPps = customTypes.NewStormctrlIfPolBcBurstPpsStringValue(attributeValue.(string)) + } + if attributeName == "bcBurstRate" { + readData.BcBurstRate = customTypes.NewRoundedPercentageStringValue(attributeValue.(string)) + } + if attributeName == "bcRate" { + readData.BcRate = customTypes.NewRoundedPercentageStringValue(attributeValue.(string)) + } + if attributeName == "bcRatePps" { + readData.BcRatePps = customTypes.NewStormctrlIfPolBcRatePpsStringValue(attributeValue.(string)) + } + if attributeName == "burstPps" { + readData.BurstPps = customTypes.NewStormctrlIfPolBurstPpsStringValue(attributeValue.(string)) + } + if attributeName == "burstRate" { + readData.BurstRate = customTypes.NewRoundedPercentageStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "isUcMcBcStormPktCfgValid" { + readData.IsUcMcBcStormPktCfgValid = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "mcBurstPps" { + readData.McBurstPps = customTypes.NewStormctrlIfPolMcBurstPpsStringValue(attributeValue.(string)) + } + if attributeName == "mcBurstRate" { + readData.McBurstRate = customTypes.NewRoundedPercentageStringValue(attributeValue.(string)) + } + if attributeName == "mcRate" { + readData.McRate = customTypes.NewRoundedPercentageStringValue(attributeValue.(string)) + } + if attributeName == "mcRatePps" { + readData.McRatePps = customTypes.NewStormctrlIfPolMcRatePpsStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + readData.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + readData.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rate" { + readData.Rate = customTypes.NewRoundedPercentageStringValue(attributeValue.(string)) + } + if attributeName == "ratePps" { + readData.RatePps = customTypes.NewStormctrlIfPolRatePpsStringValue(attributeValue.(string)) + } + if attributeName == "stormCtrlAction" { + readData.StormCtrlAction = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "stormCtrlSoakInstCount" { + readData.StormCtrlSoakInstCount = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "uucBurstPps" { + readData.UucBurstPps = customTypes.NewStormctrlIfPolUucBurstPpsStringValue(attributeValue.(string)) + } + if attributeName == "uucBurstRate" { + readData.UucBurstRate = customTypes.NewRoundedPercentageStringValue(attributeValue.(string)) + } + if attributeName == "uucRate" { + readData.UucRate = customTypes.NewRoundedPercentageStringValue(attributeValue.(string)) + } + if attributeName == "uucRatePps" { + readData.UucRatePps = customTypes.NewStormctrlIfPolUucRatePpsStringValue(attributeValue.(string)) + } + } + TagAnnotationStormctrlIfPolList := make([]TagAnnotationStormctrlIfPolResourceModel, 0) + TagTagStormctrlIfPolList := make([]TagTagStormctrlIfPolResourceModel, 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" { + TagAnnotationStormctrlIfPol := getEmptyTagAnnotationStormctrlIfPolResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationStormctrlIfPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationStormctrlIfPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationStormctrlIfPolList = append(TagAnnotationStormctrlIfPolList, TagAnnotationStormctrlIfPol) + } + if childClassName == "tagTag" { + TagTagStormctrlIfPol := getEmptyTagTagStormctrlIfPolResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagStormctrlIfPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagStormctrlIfPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagStormctrlIfPolList = append(TagTagStormctrlIfPolList, TagTagStormctrlIfPol) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationStormctrlIfPolList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagStormctrlIfPolList) + readData.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'stormctrlIfPol'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getStormctrlIfPolRn(ctx context.Context, data *StormctrlIfPolResourceModel) string { + return fmt.Sprintf("infra/stormctrlifp-%s", data.Name.ValueString()) +} + +func setStormctrlIfPolId(ctx context.Context, data *StormctrlIfPolResourceModel) { + rn := getStormctrlIfPolRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", strings.Split([]string{"uni/infra/stormctrlifp-{name}"}[0], "/")[0], rn)) +} + +func getStormctrlIfPolTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *StormctrlIfPolResourceModel, tagAnnotationStormctrlIfPolPlan, tagAnnotationStormctrlIfPolState []TagAnnotationStormctrlIfPolResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationStormctrlIfPol := range tagAnnotationStormctrlIfPolPlan { + childMap := NewAciObject() + if !tagAnnotationStormctrlIfPol.Key.IsNull() && !tagAnnotationStormctrlIfPol.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationStormctrlIfPol.Key.ValueString() + } + if !tagAnnotationStormctrlIfPol.Value.IsNull() && !tagAnnotationStormctrlIfPol.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationStormctrlIfPol.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationStormctrlIfPol.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationStormctrlIfPolState { + 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 getStormctrlIfPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *StormctrlIfPolResourceModel, tagTagStormctrlIfPolPlan, tagTagStormctrlIfPolState []TagTagStormctrlIfPolResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagStormctrlIfPol := range tagTagStormctrlIfPolPlan { + childMap := NewAciObject() + if !tagTagStormctrlIfPol.Key.IsNull() && !tagTagStormctrlIfPol.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagStormctrlIfPol.Key.ValueString() + } + if !tagTagStormctrlIfPol.Value.IsNull() && !tagTagStormctrlIfPol.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagStormctrlIfPol.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagStormctrlIfPol.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagStormctrlIfPolState { + 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 getStormctrlIfPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *StormctrlIfPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationStormctrlIfPolResourceModel, tagTagPlan, tagTagState []TagTagStormctrlIfPolResourceModel) *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 := getStormctrlIfPolTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getStormctrlIfPolTagTagChildPayloads(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.BcBurstPps.IsNull() && !data.BcBurstPps.IsUnknown() { + payloadMap["attributes"].(map[string]string)["bcBurstPps"] = data.BcBurstPps.ValueString() + } + if !data.BcBurstRate.IsNull() && !data.BcBurstRate.IsUnknown() { + payloadMap["attributes"].(map[string]string)["bcBurstRate"] = data.BcBurstRate.ValueString() + } + if !data.BcRate.IsNull() && !data.BcRate.IsUnknown() { + payloadMap["attributes"].(map[string]string)["bcRate"] = data.BcRate.ValueString() + } + if !data.BcRatePps.IsNull() && !data.BcRatePps.IsUnknown() { + payloadMap["attributes"].(map[string]string)["bcRatePps"] = data.BcRatePps.ValueString() + } + if !data.BurstPps.IsNull() && !data.BurstPps.IsUnknown() { + payloadMap["attributes"].(map[string]string)["burstPps"] = data.BurstPps.ValueString() + } + if !data.BurstRate.IsNull() && !data.BurstRate.IsUnknown() { + payloadMap["attributes"].(map[string]string)["burstRate"] = data.BurstRate.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.IsUcMcBcStormPktCfgValid.IsNull() && !data.IsUcMcBcStormPktCfgValid.IsUnknown() { + payloadMap["attributes"].(map[string]string)["isUcMcBcStormPktCfgValid"] = data.IsUcMcBcStormPktCfgValid.ValueString() + } + if !data.McBurstPps.IsNull() && !data.McBurstPps.IsUnknown() { + payloadMap["attributes"].(map[string]string)["mcBurstPps"] = data.McBurstPps.ValueString() + } + if !data.McBurstRate.IsNull() && !data.McBurstRate.IsUnknown() { + payloadMap["attributes"].(map[string]string)["mcBurstRate"] = data.McBurstRate.ValueString() + } + if !data.McRate.IsNull() && !data.McRate.IsUnknown() { + payloadMap["attributes"].(map[string]string)["mcRate"] = data.McRate.ValueString() + } + if !data.McRatePps.IsNull() && !data.McRatePps.IsUnknown() { + payloadMap["attributes"].(map[string]string)["mcRatePps"] = data.McRatePps.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.OwnerKey.IsNull() && !data.OwnerKey.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerKey"] = data.OwnerKey.ValueString() + } + if !data.OwnerTag.IsNull() && !data.OwnerTag.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerTag"] = data.OwnerTag.ValueString() + } + if !data.Rate.IsNull() && !data.Rate.IsUnknown() { + payloadMap["attributes"].(map[string]string)["rate"] = data.Rate.ValueString() + } + if !data.RatePps.IsNull() && !data.RatePps.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ratePps"] = data.RatePps.ValueString() + } + if !data.StormCtrlAction.IsNull() && !data.StormCtrlAction.IsUnknown() { + payloadMap["attributes"].(map[string]string)["stormCtrlAction"] = data.StormCtrlAction.ValueString() + } + if !data.StormCtrlSoakInstCount.IsNull() && !data.StormCtrlSoakInstCount.IsUnknown() { + payloadMap["attributes"].(map[string]string)["stormCtrlSoakInstCount"] = data.StormCtrlSoakInstCount.ValueString() + } + if !data.UucBurstPps.IsNull() && !data.UucBurstPps.IsUnknown() { + payloadMap["attributes"].(map[string]string)["uucBurstPps"] = data.UucBurstPps.ValueString() + } + if !data.UucBurstRate.IsNull() && !data.UucBurstRate.IsUnknown() { + payloadMap["attributes"].(map[string]string)["uucBurstRate"] = data.UucBurstRate.ValueString() + } + if !data.UucRate.IsNull() && !data.UucRate.IsUnknown() { + payloadMap["attributes"].(map[string]string)["uucRate"] = data.UucRate.ValueString() + } + if !data.UucRatePps.IsNull() && !data.UucRatePps.IsUnknown() { + payloadMap["attributes"].(map[string]string)["uucRatePps"] = data.UucRatePps.ValueString() + } + payload, err := json.Marshal(map[string]interface{}{"stormctrlIfPol": 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_storm_control_interface_policy_test.go b/internal/provider/resource_aci_storm_control_interface_policy_test.go new file mode 100644 index 000000000..bc5be7102 --- /dev/null +++ b/internal/provider/resource_aci_storm_control_interface_policy_test.go @@ -0,0 +1,631 @@ +// 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 TestAccResourceStormctrlIfPol(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(2j)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigStormctrlIfPolMinAllowExisting + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "soak_count", "3"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "soak_count", "3")), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(2j)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigStormctrlIfPolMinAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(2j)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigStormctrlIfPolMinAllowExisting + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "unicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test", "soak_count", "3"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.allow_test_2", "soak_count", "3")), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(2j)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigStormctrlIfPolMin + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "soak_count", "3")), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigStormctrlIfPolAll + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "11"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "10"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "13"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "12"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "15"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Valid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "14"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "soak_count", "3")), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigStormctrlIfPolMin + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "11"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "10"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "13"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "12"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "15"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Valid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "14"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "soak_count", "3")), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigStormctrlIfPolReset + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "soak_count", "3")), + ), + }, + // Import testing + { + ResourceName: "aci_storm_control_interface_policy.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigStormctrlIfPolChildren + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "soak_count", "3")), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.#", "2"), + ), + }, + // Update with children removed from config + { + Config: testConfigStormctrlIfPolChildrenRemoveFromConfig + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "soak_count", "3")), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigStormctrlIfPolChildrenRemoveOne + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "soak_count", "3")), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigStormctrlIfPolChildrenRemoveAll + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Invalid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "unspecified"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "100.000000"), + composeAggregateTestCheckFuncWithVersion(t, "4.1(1i)-", "inside", + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "action", "drop"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "soak_count", "3")), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "tags.#", "0"), + ), + }, + // Update with minimum config and custom type semantic equivalent values + { + Config: testConfigStormctrlIfPolCustomType, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_packets_per_second", "0xffffffff"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_packets_per_second", "0xffffffff"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "broadcast_rate_percentage", "90"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_packets_per_second", "0xffffffff"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "burst_rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_packets_per_second", "0xffffffff"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_burst_rate_percentage", "95.4556"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_packets_per_second", "0xffffffff"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "multicast_rate_percentage", "80.1"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_packets_per_second", "0xffffffff"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "rate_percentage", "100.000000"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_packets_per_second", "0xffffffff"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_burst_rate_percentage", "64.736"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_multicast_broadcast", "Valid"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_packets_per_second", "0xffffffff"), + resource.TestCheckResourceAttr("aci_storm_control_interface_policy.test", "unicast_rate_percentage", "50.56"), + ), + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testConfigStormctrlIfPolMinAllowExisting = ` +resource "aci_storm_control_interface_policy" "allow_test" { + name = "test_name" +} +resource "aci_storm_control_interface_policy" "allow_test_2" { + name = "test_name" + depends_on = [aci_storm_control_interface_policy.allow_test] +} +` + +const testConfigStormctrlIfPolMin = ` +resource "aci_storm_control_interface_policy" "test" { + name = "test_name" +} +` + +const testConfigStormctrlIfPolAll = ` +resource "aci_storm_control_interface_policy" "test" { + name = "test_name" + annotation = "annotation" + broadcast_burst_rate_packets_per_second = "11" + broadcast_burst_rate_percentage = "100.000000" + broadcast_rate_packets_per_second = "10" + broadcast_rate_percentage = "100.000000" + burst_rate_packets_per_second = "unspecified" + burst_rate_percentage = "100.000000" + description = "description_1" + multicast_burst_rate_packets_per_second = "13" + multicast_burst_rate_percentage = "100.000000" + multicast_rate_packets_per_second = "12" + multicast_rate_percentage = "100.000000" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + rate_packets_per_second = "unspecified" + rate_percentage = "100.000000" + unicast_burst_rate_packets_per_second = "15" + unicast_burst_rate_percentage = "100.000000" + unicast_multicast_broadcast = "Valid" + unicast_rate_packets_per_second = "14" + unicast_rate_percentage = "100.000000" + action = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.1(1i)-") ? "drop" : null + soak_count = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.1(1i)-") ? "3" : null +} +` + +const testConfigStormctrlIfPolReset = ` +resource "aci_storm_control_interface_policy" "test" { + name = "test_name" + annotation = "orchestrator:terraform" + broadcast_burst_rate_packets_per_second = "unspecified" + broadcast_burst_rate_percentage = "100.000000" + broadcast_rate_packets_per_second = "unspecified" + broadcast_rate_percentage = "100.000000" + burst_rate_packets_per_second = "unspecified" + burst_rate_percentage = "100.000000" + description = "" + multicast_burst_rate_packets_per_second = "unspecified" + multicast_burst_rate_percentage = "100.000000" + multicast_rate_packets_per_second = "unspecified" + multicast_rate_percentage = "100.000000" + name_alias = "" + owner_key = "" + owner_tag = "" + rate_packets_per_second = "unspecified" + rate_percentage = "100.000000" + unicast_burst_rate_packets_per_second = "unspecified" + unicast_burst_rate_percentage = "100.000000" + unicast_multicast_broadcast = "Invalid" + unicast_rate_packets_per_second = "unspecified" + unicast_rate_percentage = "100.000000" + action = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.1(1i)-") ? "drop" : null + soak_count = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.1(1i)-") ? "3" : null +} +` +const testConfigStormctrlIfPolChildren = ` +resource "aci_storm_control_interface_policy" "test" { + name = "test_name" + 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 testConfigStormctrlIfPolChildrenRemoveFromConfig = ` +resource "aci_storm_control_interface_policy" "test" { + name = "test_name" +} +` + +const testConfigStormctrlIfPolChildrenRemoveOne = ` +resource "aci_storm_control_interface_policy" "test" { + name = "test_name" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigStormctrlIfPolChildrenRemoveAll = ` +resource "aci_storm_control_interface_policy" "test" { + name = "test_name" + annotations = [] + tags = [] +} +` + +const testConfigStormctrlIfPolCustomType = ` +resource "aci_storm_control_interface_policy" "test" { + broadcast_burst_rate_packets_per_second = "0xffffffff" + broadcast_burst_rate_percentage = "100.000000" + broadcast_rate_packets_per_second = "0xffffffff" + broadcast_rate_percentage = "90" + burst_rate_packets_per_second = "0xffffffff" + burst_rate_percentage = "100.000000" + multicast_burst_rate_packets_per_second = "0xffffffff" + multicast_burst_rate_percentage = "95.4556" + multicast_rate_packets_per_second = "0xffffffff" + multicast_rate_percentage = "80.1" + name = "test_name" + rate_packets_per_second = "0xffffffff" + rate_percentage = "100.000000" + unicast_burst_rate_packets_per_second = "0xffffffff" + unicast_burst_rate_percentage = "64.736" + unicast_multicast_broadcast = "Valid" + unicast_rate_packets_per_second = "0xffffffff" + unicast_rate_percentage = "50.56" +} +`