diff --git a/docs/data-sources/poe_interface_policy.md b/docs/data-sources/poe_interface_policy.md new file mode 100644 index 000000000..ef2b2e11e --- /dev/null +++ b/docs/data-sources/poe_interface_policy.md @@ -0,0 +1,73 @@ +--- +# 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_poe_interface_policy" +sidebar_current: "docs-aci-data-source-aci_poe_interface_policy" +description: |- + Data source for ACI PoE Interface Policy +--- + +# aci_poe_interface_policy # + +Data source for ACI PoE Interface Policy + +## API Information ## + +* Class: [poeIfPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/poeIfPol/overview) + +* Supported in ACI versions: 3.0(1k) and later. + +* Distinguished Name Format: `uni/infra/poeIfP-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Policies -> Interface -> PoE` + +## Example Usage ## + +```hcl + +data "aci_poe_interface_policy" "example" { + name = "test_name" +} + +``` + +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the PoE Interface Policy object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the PoE Interface Policy object. +* `admin_st` (adminSt) - (string) The administrative state of the PoE Interface Policy object. This attribute is supported in ACI versions: 4.0(1h) and later. +* `annotation` (annotation) - (string) The annotation of the PoE Interface Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `description` (descr) - (string) The description of the PoE Interface Policy object. +* `maximum_power` (max) - (string) The maximum power in milliwatts that is allowed for the PoE Interface Policy object. The value must be in the range 4000 - 60000. +* `host_mode` (mode) - (string) The host mode of the PoE Interface Policy object. +* `name_alias` (nameAlias) - (string) The name alias of the PoE Interface Policy object. +* `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. +* `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. +* `poe_vlan` (poeVoiceVlan) - (string) The PoE VLAN of the PoE Interface Policy object. This attribute is supported in ACI versions: 4.0(1h) and later. +* `policing_action` (policeAct) - (string) The policing action of the PoE Interface Policy object. +* `port_priority_high` (prioHigh) - (string) Enable high port priority for the PoE Interface Policy object. +* `relation_to_application_epg` - (map) A map of Relation To Application EPG (ACI object [poeRsPoeEpg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/poeRsPoeEpg/overview)) pointing to Application EPG (ACI Object [fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)). This attribute is supported in ACI versions: 4.0(1h) and later. + * `annotation` (annotation) - (string) The annotation of the Relation To Application EPG object. + * `target_dn` (tDn) - (string) The distinguished name (DN) of the EPG object. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + * `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `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/poe_interface_policy.md b/docs/resources/poe_interface_policy.md new file mode 100644 index 000000000..73ce3e3f8 --- /dev/null +++ b/docs/resources/poe_interface_policy.md @@ -0,0 +1,172 @@ +--- +# 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_poe_interface_policy" +sidebar_current: "docs-aci-resource-aci_poe_interface_policy" +description: |- + Manages ACI PoE Interface Policy +--- + +# aci_poe_interface_policy # + +Manages ACI PoE Interface Policy + + + +## API Information ## + +* Class: [poeIfPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/poeIfPol/overview) + +* Supported in ACI versions: 3.0(1k) and later. + +* Distinguished Name Format: `uni/infra/poeIfP-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Policies -> Interface -> PoE` + +## Example Usage ## + +The configuration snippet below creates a PoE Interface Policy with only required attributes. + +```hcl + +resource "aci_poe_interface_policy" "example" { + name = "test_name" +} + +``` +The configuration snippet below shows all possible attributes of the PoE Interface Policy. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_poe_interface_policy" "full_example" { + admin_st = "disabled" + annotation = "annotation" + description = "description_1" + maximum_power = "15400" + host_mode = "never" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + poe_vlan = "vlan-200" + policing_action = "log" + port_priority_high = "yes" + relation_to_application_epg = { + annotation = "annotation_1" + target_dn = aci_application_epg.test_application_epg_0.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the PoE Interface Policy resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_poe_interface_policy) folder. + +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the PoE Interface Policy object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the PoE Interface Policy object. + +### Optional ### + +* `admin_st` (adminSt) - (string) The administrative state of the PoE Interface Policy object. This attribute is supported in ACI versions: 4.0(1h) and later. + - Default: `"disabled"` + - Valid Values: `"disabled"`, `"enabled"`. +* `annotation` (annotation) - (string) The annotation of the PoE Interface Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` +* `description` (descr) - (string) The description of the PoE Interface Policy object. +* `maximum_power` (max) - (string) The maximum power in milliwatts that is allowed for the PoE Interface Policy object. The value must be in the range 4000 - 60000. + - Default: `"30000"` +* `host_mode` (mode) - (string) The host mode of the PoE Interface Policy object. + - Default: `"auto"` + - Valid Values: `"auto"`, `"never"`, `"static"`. +* `name_alias` (nameAlias) - (string) The name alias of the PoE Interface Policy object. +* `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. +* `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. +* `poe_vlan` (poeVoiceVlan) - (string) The PoE VLAN of the PoE Interface Policy object. This attribute is supported in ACI versions: 4.0(1h) and later. + - Default: `"unknown"` +* `policing_action` (policeAct) - (string) The policing action of the PoE Interface Policy object. + - Default: `"err-dis"` + - Valid Values: `"err-dis"`, `"log"`, `"none"`. +* `port_priority_high` (prioHigh) - (string) Enable high port priority for the PoE Interface Policy object. + - Default: `"no"` + - Valid Values: `"no"`, `"yes"`. +* `relation_to_application_epg` - (map) A map of Relation To Application EPG (ACI object [poeRsPoeEpg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/poeRsPoeEpg/overview)) pointing to Application EPG (ACI Object [fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) which can be configured using the [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) resource. This attribute is supported in ACI versions: 4.0(1h) and later. + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation To Application EPG object. + - Default: `"orchestrator:terraform"` + * `target_dn` (tDn) - (string) The distinguished name (DN) of the EPG object. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + * `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + #### Required #### + + * `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 PoE 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_poe_interface_policy.example uni/infra/poeIfP-{name} +``` + +Starting in Terraform version 1.5, an existing PoE Interface Policy can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/infra/poeIfP-{name}" + to = aci_poe_interface_policy.example +} +``` diff --git a/examples/data-sources/aci_poe_interface_policy/data-source.tf b/examples/data-sources/aci_poe_interface_policy/data-source.tf new file mode 100644 index 000000000..35489015b --- /dev/null +++ b/examples/data-sources/aci_poe_interface_policy/data-source.tf @@ -0,0 +1,4 @@ + +data "aci_poe_interface_policy" "example" { + name = "test_name" +} diff --git a/examples/data-sources/aci_poe_interface_policy/provider.tf b/examples/data-sources/aci_poe_interface_policy/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_poe_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_poe_interface_policy/provider.tf b/examples/resources/aci_poe_interface_policy/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_poe_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_poe_interface_policy/resource-all-attributes.tf b/examples/resources/aci_poe_interface_policy/resource-all-attributes.tf new file mode 100644 index 000000000..fceac913e --- /dev/null +++ b/examples/resources/aci_poe_interface_policy/resource-all-attributes.tf @@ -0,0 +1,43 @@ + +resource "aci_poe_interface_policy" "full_example" { + admin_st = "disabled" + annotation = "annotation" + description = "description_1" + maximum_power = "15400" + host_mode = "never" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + poe_vlan = "vlan-200" + policing_action = "log" + port_priority_high = "yes" + relation_to_application_epg = { + annotation = "annotation_1" + target_dn = aci_application_epg.test_application_epg_0.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_poe_interface_policy/resource.tf b/examples/resources/aci_poe_interface_policy/resource.tf new file mode 100644 index 000000000..dcb1983c7 --- /dev/null +++ b/examples/resources/aci_poe_interface_policy/resource.tf @@ -0,0 +1,4 @@ + +resource "aci_poe_interface_policy" "example" { + name = "test_name" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index 567a3256e..13376e6ce 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -1266,3 +1266,17 @@ infraRsAccBndlSubgrp: infraAccBndlSubgrp: resource_name: "leaf_access_bundle_policy_sub_group" + + +poeIfPol: + sub_category: "Access Policies" + ui_locations: + - "Fabric -> Access Policies -> Policies -> Interface -> PoE" + contained_by: + - "polUni" + rn_prepend: "infra" + +poeRsPoeEpg: + resource_name: "relation_to_application_epg" + relationship_classes: + - "fvAEPg" \ No newline at end of file diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 96af5d8a4..d313b550b 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -90,6 +90,7 @@ global: Pc Vpc Override Policy: "PC VPC Override Policy" Fex: "FEX" From Attachable Access Entity Profile To Domains: "To Domains" + Poe: "PoE" ignores: - "userdom" @@ -2895,3 +2896,60 @@ infraRsAccBndlSubgrp: # Response Status Code: 400, Error Code: 182, Error Message: Validation failed PortBlk has a reln to AccBndlSubgrp not contained by AccBndlGrp its parent is associated to. target_dn: "" +poeIfPol: + ignores: + - "consumption" # This field appears only in the 4.2(1) release according to https://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/kb/Cisco-APIC-and-Power-Over-Ethernet_orig.html. + default_values: + prioHigh: "no" + poeVoiceVlan: "unknown" + remove_valid_values: # Removed valid values because they are incorrect in meta. The range is allowed however the valid values are used for UI input list, where that value can be changed. + max: + - "15400" + - "30000" + - "4000" + - "45000" + - "60000" + - "7000" + overwrites: + max: maximum_power + mode: host_mode + poe_voice_vlan: poe_vlan + police_act: policing_action + prio_high: port_priority_high + documentation: + poeVoiceVlan: "The PoE VLAN of the %s object." + mode: "The host mode of the %s object." + policeAct: "The policing action of the %s object." + prioHigh: "Enable high port priority for the %s object." + max: "The maximum power in milliwatts that is allowed for the %s object. The value must be in the range 4000 - 60000." + test_values: + all: + policing_action: "log" + port_priority_high: "yes" + host_mode: "never" + poe_vlan: "vlan-200" + maximum_power: "15400" + +poeRsPoeEpg: + documentation: + tDn: "The distinguished name (DN) of the EPG object." + targets: + - class_name: "fvTenant" + target_dn: "uni/tn-tenant_0" + relation_resource_name: "tenant" + properties: + name: "test_name" + - class_name: "fvAp" + parent_dependency: "fvTenant" + parent_dependency_dn_ref: aci_tenant.test_tenant_0.id + target_dn: "uni/tn-test_name/ap-ap_1" + relation_resource_name: "application_profile" + properties: + name: "test_name" + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dependency_dn_ref: aci_application_profile.test_application_profile_1.id + target_dn: "uni/tn-test_name/ap-test_name/epg-epg_0" + relation_resource_name: "application_epg" + properties: + name: "epg_0" diff --git a/gen/meta/poeIfPol.json b/gen/meta/poeIfPol.json new file mode 100644 index 000000000..0f730e77c --- /dev/null +++ b/gen/meta/poeIfPol.json @@ -0,0 +1,1153 @@ +{ + "poe:IfPol": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "fault:Inst": "", + "health:Inst": "", + "poe:RsPoeEpg": "", + "poe:RtPoeIfPol": "", + "poe:RtPoeIfPolCons": "", + "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", + "fault-": "fault:Inst", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "rspoeEpg": "poe:RsPoeEpg", + "rtinfraPoeIfPol-": "poe:RtPoeIfPol", + "rtl1PoeIfPolCons-": "poe:RtPoeIfPolCons", + "tag-": "tag:Inst", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "poeIfP-{name}", + "containedBy": { + "infra:Infra": "" + }, + "superClasses": [ + "poe:AIfPol", + "fabric:L2IfPol", + "fabric:ProtoIfPol", + "fabric:ProtoPol", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "poe:RtPoeIfPol": "infra:AccPortGrp", + "poe:RtPoeIfPolCons": "l1:EthIf" + }, + "relationTo": { + "poe:RsPoeEpg": "fv:EPg" + }, + "dnFormats": [ + "uni/infra/poeIfP-{name}" + ], + "writeAccess": [ + "access-connectivity", + "access-protocol", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-connectivity", + "access-protocol", + "admin", + "custom-port-privilege", + "ops" + ], + "faults": { + "F3242": "fltPoeIfPolVlanEncapNotPresent" + }, + "events": { + "E4214864": "creation||poe:IfPol", + "E4214865": "modification||poe:IfPol", + "E4214866": "deletion||poe:IfPol" + }, + "stats": { + + }, + "versions": "3.0(1k)-", + "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": true, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + "apic" + ], + "classId": "10931", + "className": "IfPol", + "classPkg": "poe", + "featureTag": "", + "moCategory": "Regular", + "label": "POE Interface Policy", + "comment": [ + "POE Interface Policy" + ], + "properties": { + "adminSt": { + "versions": "4.0(1h)-", + "comment": [ + "Admin State" + ], + "isConfigurable": true, + "propGlobalId": "50097", + "propLocalId": "46", + "label": "Admin State", + "baseType": "scalar:Enum8", + "modelType": "nw:AdminSt", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "disabled", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "2", "localName": "disabled", + "platformFlavors": [ + + ], + "comment": [ + "Disabled" + ], + "label": "Disabled "}, + { "value": "1", "localName": "enabled", + "platformFlavors": [ + + ], + "comment": [ + "Enabled" + ], + "label": "Enabled "} + ], + "default": "disabled", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "" + ], + "isConfigurable": true, + "propGlobalId": "38734", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "consumption": { + "versions": "3.0(1k)-", + "comment": [ + "Consumption" + ], + "isConfigurable": true, + "propGlobalId": "34066", + "propLocalId": "7835", + "label": "Consumption", + "baseType": "scalar:Uint16", + "modelType": "poe:IfPwrCfgWattage", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "poe:If:consumption", + "validators": [ + {"min" : 4000, "max": 60000 } + ], + "validValues": [ + { "value": "4000", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 4000, + "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": [ + "" + ], + "isConfigurable": false, + "propGlobalId": "40873", + "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 + }, + "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 + }, + "max": { + "versions": "3.0(1k)-", + "comment": [ + "The maximum power in milliwatts that is allowed on the interface." + ], + "isConfigurable": true, + "propGlobalId": "34065", + "propLocalId": "1837", + "label": "Maximum Power", + "baseType": "scalar:Uint16", + "modelType": "poe:ModPwrWattage", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "poe:If:max", + "validators": [ + {"min" : 4000, "max": 60000 } + ], + "validValues": [ + { "value": "15400", "localName": "15400", + "platformFlavors": [ + + ], + "label": "Class0, Class3 "}, + { "value": "30000", "localName": "30000", + "platformFlavors": [ + + ], + "label": "Class4 "}, + { "value": "4000", "localName": "4000", + "platformFlavors": [ + + ], + "label": "Class1 "}, + { "value": "45000", "localName": "45000", + "platformFlavors": [ + + ], + "label": "Class5 "}, + { "value": "60000", "localName": "60000", + "platformFlavors": [ + + ], + "label": "Class6 "}, + { "value": "7000", "localName": "7000", + "platformFlavors": [ + + ], + "label": "Class2 "}, + { "value": "30000", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 30000, + "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 + }, + "mode": { + "versions": "3.0(1k)-", + "comment": [ + "The PoE power mode of the interface." + ], + "isConfigurable": true, + "propGlobalId": "34064", + "propLocalId": "14", + "label": "Power Mode", + "baseType": "scalar:Enum8", + "modelType": "poe:PowerMode", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "poe:If:mode", + "validValues": [ + { "value": "2", "localName": "auto", + "platformFlavors": [ + + ], + "comment": [ + "Auto" + ], + "label": "Auto "}, + { "value": "auto", "localName": "defaultValue", + "platformFlavors": [ + + ], + "comment": [ + "Default is Auto" + ], + "label": " "}, + { "value": "1", "localName": "never", + "platformFlavors": [ + + ], + "comment": [ + "Never" + ], + "label": "Never "}, + { "value": "3", "localName": "static", + "platformFlavors": [ + + ], + "comment": [ + "Static" + ], + "label": "Static "} + ], + "default": "auto", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "versions": "3.0(1k)-", + "comment": [ + "Monitoring policy attached to this observable object" + ], + "isConfigurable": false, + "propGlobalId": "34086", + "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": "3.0(1k)-", + "comment": [ + "" + ], + "isConfigurable": true, + "propGlobalId": "34069", + "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 + }, + "poeEpg": { + "versions": "4.0(1h)-", + "comment": [ + "PoE Epg" + ], + "isConfigurable": false, + "propGlobalId": "42452", + "propLocalId": "9163", + "label": "EPG", + "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": true, + "likeProp": "poe:If:poeEpg", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "poeVoiceVlan": { + "versions": "4.0(1h)-", + "comment": [ + "POE VLAN" + ], + "isConfigurable": true, + "propGlobalId": "42451", + "propLocalId": "9162", + "label": "PoE Vlan", + "baseType": "base:Encap", + "modelType": "base:Encap", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "poe:If:poeVoiceVlan", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "policeAct": { + "versions": "3.0(1k)-", + "comment": [ + "Policing Action" + ], + "isConfigurable": true, + "propGlobalId": "34068", + "propLocalId": "7838", + "label": "Policing Action", + "baseType": "scalar:Enum8", + "modelType": "poe:PoliceAct", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "poe:If:policeAct", + "validValues": [ + { "value": "err-dis", "localName": "defaultValue", + "platformFlavors": [ + + ], + "comment": [ + "Default is Error Disable" + ], + "label": " "}, + { "value": "1", "localName": "err-dis", + "platformFlavors": [ + + ], + "comment": [ + "Error Disable" + ], + "label": "Error Disable "}, + { "value": "2", "localName": "log", + "platformFlavors": [ + + ], + "comment": [ + "Log" + ], + "label": "Log "}, + { "value": "0", "localName": "none", + "platformFlavors": [ + + ], + "comment": [ + "None" + ], + "label": "None "} + ], + "default": "err-dis", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "prioHigh": { + "versions": "3.0(1k)-", + "comment": [ + "Port Priority High" + ], + "isConfigurable": true, + "propGlobalId": "34067", + "propLocalId": "7837", + "label": "Port Priority High", + "baseType": "scalar:Bool", + "modelType": "scalar:Bool", + "needsPropDelimiters": false, + "uitype": "boolean", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "poe:If:prioHigh", + "validValues": [ + { "value": "false", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "false", "localName": "no", + "platformFlavors": [ + + ], + "label": "No "}, + { "value": "true", "localName": "yes", + "platformFlavors": [ + + ], + "label": "Yes "} + ], + "default": "false", + "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 + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/meta/poeRsPoeEpg.json b/gen/meta/poeRsPoeEpg.json new file mode 100644 index 000000000..1ecffc44a --- /dev/null +++ b/gen/meta/poeRsPoeEpg.json @@ -0,0 +1,1029 @@ +{ + "poe:RsPoeEpg": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Inst": "", + "health:Inst": "", + "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", + "fault-": "fault:Inst", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "tag-": "tag:Inst", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + + ], + "rnFormat": "rspoeEpg", + "containedBy": { + "poe:IfPol": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "n-to-1", + "fromMo": "poe:IfPol", + "fromRelMo": "poe:RsPoeEpg", + "toMo": "fv:EPg", + "toRelMo": "fv:RtPoeEpg", + "enforceable": true, + "resolvable": false + }, + "dnFormats": [ + "uni/infra/poeIfP-{name}/rspoeEpg" + ], + "writeAccess": [ + "access-connectivity", + "access-protocol", + "admin", + "tenant-epg", + "tenant-network-profile" + ], + "readAccess": [ + "access-connectivity", + "access-protocol", + "admin", + "ops", + "tenant-epg", + "tenant-network-profile" + ], + "faults": { + "F3244": "fltPoeRsPoeEpgResolveFail" + }, + "events": { + "E4215897": "creation||poe:RsPoeEpg", + "E4215898": "modification||poe:RsPoeEpg", + "E4215899": "deletion||poe:RsPoeEpg" + }, + "stats": { + + }, + "versions": "4.0(1h)-", + "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": true, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "regular", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + "apic" + ], + "classId": "13004", + "className": "RsPoeEpg", + "classPkg": "poe", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "PoE EPg", + "comment": [ + "Represents the EPg the interface policy uses" + ], + "properties": { + "annotation": { + "versions": "4.0(1h)-", + "comment": [ + "" + ], + "isConfigurable": true, + "propGlobalId": "44916", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "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": "4.0(1h)-", + "comment": [ + "" + ], + "isConfigurable": false, + "propGlobalId": "44917", + "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 + }, + "forceResolve": { + "versions": "1.0(1e)-", + "comment": [ + "Whether the relation should force pull the target." + ], + "isConfigurable": false, + "propGlobalId": "107", + "propLocalId": "83", + "label": "Force Resolve", + "baseType": "scalar:Bool", + "modelType": "scalar:Bool", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "true", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "false", "localName": "no", + "platformFlavors": [ + + ], + "label": "No "}, + { "value": "true", "localName": "yes", + "platformFlavors": [ + + ], + "label": "Yes "} + ], + "default": "yes", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "versions": "4.0(1h)-", + "comment": [ + "Monitoring policy attached to this observable object" + ], + "isConfigurable": false, + "propGlobalId": "44912", + "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 + }, + "rType": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the type of resolver." + ], + "isConfigurable": false, + "propGlobalId": "106", + "propLocalId": "82", + "label": "Resolver Type", + "baseType": "scalar:Enum8", + "modelType": "reln:ResolverType", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "mo", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "3", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "mo", + "platformFlavors": [ + + ], + "label": "MO "}, + { "value": "2", "localName": "service", + "platformFlavors": [ + + ], + "label": "Service "} + ], + "default": "mo", + "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 + }, + "state": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the state of the relationship." + ], + "isConfigurable": false, + "propGlobalId": "103", + "propLocalId": "26", + "label": "State", + "baseType": "scalar:Enum8", + "modelType": "reln:State", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "5", "localName": "cardinality-violation", + "platformFlavors": [ + + ], + "comment": [ + "cardinality violation - When relations are created such that\n they violate the cardinality, state of the relation would be\n set to this." + ], + "label": "Cardinality Violation "}, + { "value": "unformed", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "formed", + "platformFlavors": [ + + ], + "comment": [ + "the relationship is formed with the target object" + ], + "label": "Formed "}, + { "value": "4", "localName": "invalid-target", + "platformFlavors": [ + + ], + "comment": [ + "invalid target DN" + ], + "label": "Invalid Target "}, + { "value": "2", "localName": "missing-target", + "platformFlavors": [ + + ], + "comment": [ + "target does not exist" + ], + "label": "Missing Target "}, + { "value": "0", "localName": "unformed", + "platformFlavors": [ + + ], + "comment": [ + "the relationship is not formed" + ], + "label": "Unformed "} + ], + "default": "unformed", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "stateQual": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the state qualifier of the relationship." + ], + "isConfigurable": false, + "propGlobalId": "104", + "propLocalId": "80", + "label": "State Qualifier", + "baseType": "scalar:Enum8", + "modelType": "reln:StateQual", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "default-target", + "platformFlavors": [ + + ], + "comment": [ + "target not specified, using default" + ], + "label": "Target Not Specified "}, + { "value": "none", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "mismatch-target", + "platformFlavors": [ + + ], + "comment": [ + "target not found, using default" + ], + "label": "Target Not Found "}, + { "value": "0", "localName": "none", + "platformFlavors": [ + + ], + "comment": [ + "no issue" + ], + "label": "None "} + ], + "default": "none", + "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 + }, + "tCl": { + "versions": "4.0(1h)-", + "comment": [ + "" + ], + "isConfigurable": false, + "propGlobalId": "44905", + "propLocalId": "78", + "label": "Target Class", + "baseType": "scalar:Enum16", + "modelType": "reln:ClassId", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validValues": [ + { "value": "14644", "localName": "cloudEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "14645", "localName": "cloudExtEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "15164", "localName": "cloudISvcEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "18284", "localName": "cloudSvcEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1899", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1467", "localName": "dhcpCRelPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1466", "localName": "dhcpPRelPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1981", "localName": "fvAEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1899", "localName": "fvEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "16474", "localName": "fvESg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "20529", "localName": "fvIntEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "9196", "localName": "fvTnlEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4326", "localName": "infraCEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4325", "localName": "infraPEPg", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1746", "localName": "l2extInstP", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1775", "localName": "l3extInstP", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "5987", "localName": "l3extInstPDef", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "2194", "localName": "mgmtInB", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "}, + { "value": "4694", "localName": "vnsEPpInfo", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "5959", "localName": "vnsREPpInfo", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "5958", "localName": "vnsSDEPpInfo", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "6131", "localName": "vnsSHEPpInfo", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "fvEPg", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "4.0(1h)-", + "comment": [ + "" + ], + "isConfigurable": true, + "propGlobalId": "44904", + "propLocalId": "77", + "label": "Target-dn", + "baseType": "reference:BinRef", + "modelType": "reln:Dn", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tType": { + "versions": "1.0(1e)-", + "comment": [ + "The type of target." + ], + "isConfigurable": false, + "propGlobalId": "105", + "propLocalId": "81", + "label": "Target Type", + "baseType": "scalar:Enum8", + "modelType": "reln:TargetType", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "all", + "platformFlavors": [ + + ], + "label": "All "}, + { "value": "mo", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "mo", + "platformFlavors": [ + + ], + "label": "MO "}, + { "value": "0", "localName": "name", + "platformFlavors": [ + + ], + "label": "Name "} + ], + "default": "mo", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/templates/resource.md.tmpl b/gen/templates/resource.md.tmpl index d34c2b816..cbfca70f7 100644 --- a/gen/templates/resource.md.tmpl +++ b/gen/templates/resource.md.tmpl @@ -123,8 +123,8 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the {{- if eq .ValueType "bitmask"}} * `{{- overwriteProperty .PkgName .SnakeCaseName $.Definitions}}` ({{- .PropertyName}}) - (list) {{.Comment}}{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} {{- if .DefaultValue }} - {{- if eq .DefaultValue "@aci_gen_default_value_overwrite_to_empty_string!"}} - - Default: `""` + {{- if eq .DefaultValue "@aci_gen_default_value_overwrite_to_empty_list!"}} + - Default: `[]` {{- else}} - Default: `"{{ .DefaultValue }}"` {{- end}} @@ -241,6 +241,8 @@ import { {{- if .DefaultValue }} {{- if eq .DefaultValue "@aci_gen_default_value_overwrite_to_empty_string!"}} {{ $indent }}- Default: `""` + {{- else if eq .DefaultValue "@aci_gen_default_value_overwrite_to_empty_list!"}} + {{ $indent }}- Default: `[]` {{- else}} {{ $indent }}- Default: `"{{ .DefaultValue }}"` {{- end}} diff --git a/gen/templates/resource_test.go.tmpl b/gen/templates/resource_test.go.tmpl index 940929783..ddc7fcc7b 100644 --- a/gen/templates/resource_test.go.tmpl +++ b/gen/templates/resource_test.go.tmpl @@ -1290,6 +1290,11 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) { {{- else }} {{- if eq $child_key "target_dn"}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil $child_index false}}"), + {{- else if (isInterfaceSlice $child_value)}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}.#", "{{len $child_value}}"), + {{- range $index, $subvalue := $child_value}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}.{{$index}}", "{{$subvalue}}"), + {{- end}} {{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{$child_value}}"), {{- end}} @@ -1392,9 +1397,14 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) { {{- end }}), {{- end }} {{- else }} - {{- if eq $child_key "target_dn"}} + {{- if eq $child_key "target_dn"}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil $child_index false}}"), - {{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}} + {{- else if (isInterfaceSlice $child_value)}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}.#", "{{len $child_value}}"), + {{- range $index, $subvalue := $child_value}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}.{{$index}}", "{{$subvalue}}"), + {{- end}} + {{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{$child_value}}"), {{- end}} {{- end}} @@ -1496,9 +1506,14 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) { {{- end }}), {{- end }} {{- else }} - {{- if eq $child_key "target_dn"}} + {{- if eq $child_key "target_dn"}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil 1 false}}"), - {{- else}} + {{- else if (isInterfaceSlice $child_value)}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}.#", "{{len $child_value}}"), + {{- range $index, $subvalue := $child_value}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}.{{$index}}", "{{$subvalue}}"), + {{- end}} + {{- else}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}", "{{$child_value}}"), {{- end}} {{- end}} @@ -2508,6 +2523,12 @@ resource "aci_{{$.resourceName}}" "test" { {{- else }} {{- if eq $child_key "target_dn"}}{{$attributeValue := getTestTargetDn $.child_targets $key $child_value true nil $index false}} {{$child_key}} = {{if isReference $attributeValue}}{{$attributeValue}}{{- else if isInterfaceSlice $attributeValue}}{{- if lt 0 (len $attributeValue)}}[{{fromInterfacesToString $attributeValue}}]{{else}}[]{{end}}{{else}}"{{$attributeValue}}"{{end}} + {{- else if (isInterfaceSlice $child_value)}} + {{- if lt 0 (len $child_value)}} + {{$child_key}} = [{{range $index, $subvalue := $child_value}}{{if lt $index (subtract (len $child_value) 1)}}"{{$subvalue}}", {{else}}"{{$subvalue}}"{{end}}{{end}}] + {{- else}} + {{$child_key}} = [] + {{- end}} {{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}} {{$child_key}} = "{{$child_value}}" {{- end}} @@ -2537,7 +2558,7 @@ resource "aci_{{$.resourceName}}" "test" { {{- range $key, $value := $.resource_required}} {{- if eq $key "target_dn" }}{{$attributeValue := getTestTargetDn $.targets $.resourceName $value true nil 0 false}} {{$key}} = {{if isReference $attributeValue}}{{$attributeValue}}{{- else if isInterfaceSlice $attributeValue}}{{- if lt 0 (len $attributeValue)}}[{{fromInterfacesToString $attributeValue}}]{{else}}[]{{end}}{{else}}"{{$attributeValue}}"{{end}} - {{- else }} + {{- else }} {{$key}} = "{{$value}}" {{- end }} {{- end}} @@ -2610,7 +2631,13 @@ resource "aci_{{$.resourceName}}" "test" { {{- else }} {{- if eq $child_key "target_dn"}}{{$attributeValue := getTestTargetDn $.child_targets $key $child_value true nil 1 false}} {{$child_key}} = {{if isReference $attributeValue}}{{$attributeValue}}{{- else if isInterfaceSlice $attributeValue}}{{- if lt 0 (len $attributeValue)}}[{{fromInterfacesToString $attributeValue}}]{{else}}[]{{end}}{{else}}"{{$attributeValue}}"{{end}} - {{- else }} + {{- else if (isInterfaceSlice $child_value)}} + {{- if lt 0 (len $child_value)}} + {{$child_key}} = [{{range $index, $subvalue := $child_value}}{{if lt $index (subtract (len $child_value) 1)}}"{{$subvalue}}", {{else}}"{{$subvalue}}"{{end}}{{end}}] + {{- else}} + {{$child_key}} = [] + {{- end}} + {{- else }} {{$child_key}} = "{{$child_value}}" {{- end}} {{- end}} @@ -3170,16 +3197,16 @@ resource "aci_{{$.resourceName}}" "test" { {{- end }}{{- end }}), {{- end }} {{- else }} - {{- if eq $child_key "target_dn"}} + {{- if eq $child_key "target_dn"}} resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil $child_index false}}"), - {{- else if (isInterfaceSlice $child_value)}} + {{- else if (isInterfaceSlice $child_value)}} resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}.#", "{{len $child_value}}"), - {{- range $index, $subvalue := $child_value}} + {{- range $index, $subvalue := $child_value}} resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}.{{$index}}", "{{$subvalue}}"), - {{- end}} - {{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}} + {{- end}} + {{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}} resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}", "{{$child_value}}"), - {{- end}} + {{- end}} {{- end}} {{- end}} {{- end }} @@ -3196,9 +3223,14 @@ resource "aci_{{$.resourceName}}" "test" { {{- end }}), {{- end }} {{- else }} - {{- if eq $child_key "target_dn"}} + {{- if eq $child_key "target_dn"}} resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_index}}.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil $child_index false}}"), - {{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}} + {{- else if (isInterfaceSlice $child_value)}} + resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}.#", "{{len $child_value}}"), + {{- range $index, $subvalue := $child_value}} + resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}.{{$index}}", "{{$subvalue}}"), + {{- end}} + {{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}} resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_index}}.{{$child_key}}", "{{$child_value}}"), {{- end}} {{- end}} diff --git a/gen/testvars/poeIfPol.yaml b/gen/testvars/poeIfPol.yaml new file mode 100644 index 000000000..5688fd450 --- /dev/null +++ b/gen/testvars/poeIfPol.yaml @@ -0,0 +1,117 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + + +default: + annotation: "orchestrator:terraform" + description: "" + maximum_power: "30000" + host_mode: "auto" + name_alias: "" + owner_key: "" + owner_tag: "" + policing_action: "err-dis" + port_priority_high: "no" + version_mismatch: + 4.0(1h)-: + admin_st: "disabled" + poe_vlan: "unknown" + +datasource_non_existing: + name: "non_existing_name" + +datasource_required: + name: "test_name" + +resource_required: + name: "test_name" + +all: + annotation: "annotation" + description: "description_1" + maximum_power: "15400" + host_mode: "never" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + policing_action: "log" + port_priority_high: "yes" + version_mismatch: + 4.0(1h)-: + admin_st: "disabled" + poe_vlan: "vlan-200" + +children: + relation_to_application_epg: + - annotation: "annotation_1" + target_dn: "target_dn_1" + deletable_child: true + child_required: false + children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + +child_targets: + - class_name: "fvTenant" + target_dn: "uni/tn-tenant_0" + relation_resource_name: "tenant" + static: false + target_dn_ref: "aci_tenant.test_tenant_0.id" + parent_dependency: "" + parent_dependency_dn_ref: "" + target_resource_name: "tenant" + parent_dn_key: "parent_dn" + properties: + name: "test_name" + - class_name: "fvAp" + target_dn: "uni/tn-test_name/ap-ap_1" + relation_resource_name: "application_profile" + static: false + target_dn_ref: "aci_application_profile.test_application_profile_1.id" + parent_dependency: "fvTenant" + parent_dependency_dn_ref: "aci_tenant.test_tenant_0.id" + target_resource_name: "application_profile" + parent_dn_key: "parent_dn" + properties: + name: "test_name" + - class_name: "fvAEPg" + target_dn: "uni/tn-test_name/ap-test_name/epg-epg_0" + relation_resource_name: "application_epg" + static: false + target_dn_ref: "aci_application_epg.test_application_epg_0.id" + parent_dependency: "fvAp" + parent_dependency_dn_ref: "aci_application_profile.test_application_profile_1.id" + target_resource_name: "application_epg" + parent_dn_key: "parent_dn" + properties: + name: "epg_0" + +test_type: apic +class_version: 3.0(1k)- +version_mismatch: true diff --git a/internal/provider/data_source_aci_poe_interface_policy.go b/internal/provider/data_source_aci_poe_interface_policy.go new file mode 100644 index 000000000..3bfd6f5f7 --- /dev/null +++ b/internal/provider/data_source_aci_poe_interface_policy.go @@ -0,0 +1,231 @@ +// 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" + + "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 = &PoeIfPolDataSource{} + +func NewPoeIfPolDataSource() datasource.DataSource { + return &PoeIfPolDataSource{} +} + +// PoeIfPolDataSource defines the data source implementation. +type PoeIfPolDataSource struct { + client *client.Client +} + +func (d *PoeIfPolDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_poe_interface_policy") + resp.TypeName = req.ProviderTypeName + "_poe_interface_policy" + tflog.Debug(ctx, "End metadata of datasource: aci_poe_interface_policy") +} + +func (d *PoeIfPolDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_poe_interface_policy") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The poe_interface_policy datasource for the 'poeIfPol' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the PoE Interface Policy object.", + }, + "admin_st": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The administrative state of the PoE Interface Policy object.`, + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the PoE Interface Policy object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the PoE Interface Policy object.`, + }, + "maximum_power": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The maximum power in milliwatts that is allowed for the PoE Interface Policy object. The value must be in the range 4000 - 60000.`, + }, + "host_mode": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The host mode of the PoE Interface Policy object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the PoE Interface Policy object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the PoE 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.`, + }, + "poe_vlan": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The PoE VLAN of the PoE Interface Policy object.`, + }, + "policing_action": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The policing action of the PoE Interface Policy object.`, + }, + "port_priority_high": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Enable high port priority for the PoE Interface Policy object.`, + }, + "relation_to_application_epg": schema.SingleNestedAttribute{ + MarkdownDescription: `Represents the EPg the interface policy uses`, + Computed: true, + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Application EPG object.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name (DN) of the EPG 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.`, + }, + }, + }, + }, + }, + }, + "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_poe_interface_policy") +} + +func (d *PoeIfPolDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_poe_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_poe_interface_policy") +} + +func (d *PoeIfPolDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_poe_interface_policy") + var data *PoeIfPolResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setPoeIfPolId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetPoeIfPolAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_poe_interface_policy with id '%s'", data.Id.ValueString())) + + getAndSetPoeIfPolAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_poe_interface_policy data source", + fmt.Sprintf("The aci_poe_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_poe_interface_policy with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_poe_interface_policy_test.go b/internal/provider/data_source_aci_poe_interface_policy_test.go new file mode 100644 index 000000000..25f6bfa87 --- /dev/null +++ b/internal/provider/data_source_aci_poe_interface_policy_test.go @@ -0,0 +1,56 @@ +// 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 TestAccDataSourcePoeIfPol(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "3.0(1k)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigPoeIfPolDataSource + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "description", "description_1"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "host_mode", "never"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "maximum_power", "15400"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "policing_action", "log"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "port_priority_high", "yes"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("data.aci_poe_interface_policy.test", "poe_vlan", "vlan-200")), + ), + }, + { + Config: testConfigPoeIfPolNotExisting + testConfigDataSourceSystem, + ExpectError: regexp.MustCompile("Failed to read aci_poe_interface_policy data source"), + }, + }, + }) +} + +const testConfigPoeIfPolDataSource = testConfigPoeIfPolAll + ` +data "aci_poe_interface_policy" "test" { + name = "test_name" + depends_on = [aci_poe_interface_policy.test] +} +` + +const testConfigPoeIfPolNotExisting = testConfigPoeIfPolAll + ` +data "aci_poe_interface_policy" "test_non_existing" { + name = "non_existing_name" +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index d2b05da06..cc031535c 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -284,6 +284,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewPimRouteMapPolResource, NewPkiKeyRingResource, NewPkiTPResource, + NewPoeIfPolResource, NewQosCustomPolResource, NewQosDot1PClassResource, NewQosDppPolResource, @@ -387,6 +388,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewPimRouteMapPolDataSource, NewPkiKeyRingDataSource, NewPkiTPDataSource, + NewPoeIfPolDataSource, NewQosCustomPolDataSource, NewQosDot1PClassDataSource, NewQosDppPolDataSource, diff --git a/internal/provider/resource_aci_poe_interface_policy.go b/internal/provider/resource_aci_poe_interface_policy.go new file mode 100644 index 000000000..7bb293b09 --- /dev/null +++ b/internal/provider/resource_aci_poe_interface_policy.go @@ -0,0 +1,1152 @@ +// 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" + + "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/objectplanmodifier" + "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 = &PoeIfPolResource{} +var _ resource.ResourceWithImportState = &PoeIfPolResource{} + +func NewPoeIfPolResource() resource.Resource { + return &PoeIfPolResource{} +} + +// PoeIfPolResource defines the resource implementation. +type PoeIfPolResource struct { + client *client.Client +} + +// PoeIfPolResourceModel describes the resource data model. +type PoeIfPolResourceModel struct { + Id types.String `tfsdk:"id"` + AdminSt types.String `tfsdk:"admin_st"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Max types.String `tfsdk:"maximum_power"` + Mode types.String `tfsdk:"host_mode"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + PoeVoiceVlan types.String `tfsdk:"poe_vlan"` + PoliceAct types.String `tfsdk:"policing_action"` + PrioHigh types.String `tfsdk:"port_priority_high"` + PoeRsPoeEpg types.Object `tfsdk:"relation_to_application_epg"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyPoeIfPolResourceModel() *PoeIfPolResourceModel { + return &PoeIfPolResourceModel{ + Id: basetypes.NewStringNull(), + AdminSt: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Max: basetypes.NewStringNull(), + Mode: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + PoeVoiceVlan: basetypes.NewStringNull(), + PoliceAct: basetypes.NewStringNull(), + PrioHigh: basetypes.NewStringNull(), + PoeRsPoeEpg: types.ObjectNull(map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationPoeRsPoeEpgPoeIfPolType}, + "tags": types.SetType{ElemType: TagTagPoeRsPoeEpgPoeIfPolType}, + }), + 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, + }, + }), + } +} + +// PoeRsPoeEpgPoeIfPolResourceModel describes the resource data model for the children without relation ships. +type PoeRsPoeEpgPoeIfPolResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyPoeRsPoeEpgPoeIfPolResourceModel() PoeRsPoeEpgPoeIfPolResourceModel { + return PoeRsPoeEpgPoeIfPolResourceModel{ + Annotation: basetypes.NewStringNull(), + TDn: basetypes.NewStringNull(), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +var PoeRsPoeEpgPoeIfPolType = map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationPoeRsPoeEpgPoeIfPolType}, + "tags": types.SetType{ElemType: TagTagPoeRsPoeEpgPoeIfPolType}, +} + +// TagAnnotationPoeRsPoeEpgPoeIfPolResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationPoeRsPoeEpgPoeIfPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationPoeRsPoeEpgPoeIfPolResourceModel() TagAnnotationPoeRsPoeEpgPoeIfPolResourceModel { + return TagAnnotationPoeRsPoeEpgPoeIfPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationPoeRsPoeEpgPoeIfPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagPoeRsPoeEpgPoeIfPolResourceModel describes the resource data model for the children without relation ships. +type TagTagPoeRsPoeEpgPoeIfPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagPoeRsPoeEpgPoeIfPolResourceModel() TagTagPoeRsPoeEpgPoeIfPolResourceModel { + return TagTagPoeRsPoeEpgPoeIfPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagPoeRsPoeEpgPoeIfPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagAnnotationPoeIfPolResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationPoeIfPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationPoeIfPolResourceModel() TagAnnotationPoeIfPolResourceModel { + return TagAnnotationPoeIfPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationPoeIfPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagPoeIfPolResourceModel describes the resource data model for the children without relation ships. +type TagTagPoeIfPolResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagPoeIfPolResourceModel() TagTagPoeIfPolResourceModel { + return TagTagPoeIfPolResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagPoeIfPolType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type PoeIfPolIdentifier struct { + Name types.String +} + +func (r *PoeIfPolResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData, configData *PoeIfPolResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + resp.Diagnostics.Append(req.Config.Get(ctx, &configData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.Name.IsUnknown() { + setPoeIfPolId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "poeIfPol", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + if !configData.PoeRsPoeEpg.IsNull() && stateData != nil { + if IsEmptySingleNestedAttribute(configData.PoeRsPoeEpg.Attributes()) { + PoeRsPoeEpgObject, _ := types.ObjectValueFrom(ctx, PoeRsPoeEpgPoeIfPolType, getEmptyPoeRsPoeEpgPoeIfPolResourceModel()) + planData.PoeRsPoeEpg = PoeRsPoeEpgObject + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *PoeIfPolResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_poe_interface_policy") + resp.TypeName = req.ProviderTypeName + "_poe_interface_policy" + tflog.Debug(ctx, "End metadata of resource: aci_poe_interface_policy") +} + +func (r *PoeIfPolResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_poe_interface_policy") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The poe_interface_policy resource for the 'poeIfPol' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the PoE Interface Policy object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "admin_st": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("disabled", "enabled"), + }, + MarkdownDescription: `The administrative state of the PoE Interface Policy object.`, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the PoE Interface Policy object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the PoE Interface Policy object.`, + }, + "maximum_power": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The maximum power in milliwatts that is allowed for the PoE Interface Policy object. The value must be in the range 4000 - 60000.`, + }, + "host_mode": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("auto", "never", "static"), + }, + MarkdownDescription: `The host mode of the PoE Interface Policy object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the PoE Interface Policy object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the PoE Interface Policy object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + 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.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "poe_vlan": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The PoE VLAN of the PoE Interface Policy object.`, + }, + "policing_action": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("err-dis", "log", "none"), + }, + MarkdownDescription: `The policing action of the PoE Interface Policy object.`, + }, + "port_priority_high": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("no", "yes"), + }, + MarkdownDescription: `Enable high port priority for the PoE Interface Policy object.`, + }, + "relation_to_application_epg": schema.SingleNestedAttribute{ + MarkdownDescription: `Represents the EPg the interface policy uses`, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Relation To Application EPG object.`, + }, + "target_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name (DN) of the EPG object.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_poe_interface_policy") +} + +func (r *PoeIfPolResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_poe_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_poe_interface_policy") +} + +func (r *PoeIfPolResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_poe_interface_policy") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *PoeIfPolResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setPoeIfPolId(ctx, stateData) + } + getAndSetPoeIfPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The poeIfPol object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *PoeIfPolResourceModel + + // 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() { + setPoeIfPolId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_poe_interface_policy with id '%s'", data.Id.ValueString())) + + var poeRsPoeEpgPlan, poeRsPoeEpgState PoeRsPoeEpgPoeIfPolResourceModel + data.PoeRsPoeEpg.As(ctx, &poeRsPoeEpgPlan, basetypes.ObjectAsOptions{}) + stateData.PoeRsPoeEpg.As(ctx, &poeRsPoeEpgState, basetypes.ObjectAsOptions{}) + var tagAnnotationPlan, tagAnnotationState []TagAnnotationPoeIfPolResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagPoeIfPolResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getPoeIfPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, poeRsPoeEpgPlan, poeRsPoeEpgState, 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 + } + + getAndSetPoeIfPolAttributes(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_poe_interface_policy with id '%s'", data.Id.ValueString())) +} + +func (r *PoeIfPolResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_poe_interface_policy") + var data *PoeIfPolResourceModel + + // 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_poe_interface_policy with id '%s'", data.Id.ValueString())) + + getAndSetPoeIfPolAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *PoeIfPolResourceModel + 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_poe_interface_policy with id '%s'", data.Id.ValueString())) +} + +func (r *PoeIfPolResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_poe_interface_policy") + var data *PoeIfPolResourceModel + var stateData *PoeIfPolResourceModel + + // 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_poe_interface_policy with id '%s'", data.Id.ValueString())) + + var poeRsPoeEpgPlan, poeRsPoeEpgState PoeRsPoeEpgPoeIfPolResourceModel + data.PoeRsPoeEpg.As(ctx, &poeRsPoeEpgPlan, basetypes.ObjectAsOptions{}) + stateData.PoeRsPoeEpg.As(ctx, &poeRsPoeEpgState, basetypes.ObjectAsOptions{}) + var tagAnnotationPlan, tagAnnotationState []TagAnnotationPoeIfPolResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagPoeIfPolResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getPoeIfPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, poeRsPoeEpgPlan, poeRsPoeEpgState, 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 + } + + getAndSetPoeIfPolAttributes(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_poe_interface_policy with id '%s'", data.Id.ValueString())) +} + +func (r *PoeIfPolResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_poe_interface_policy") + var data *PoeIfPolResourceModel + + // 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_poe_interface_policy with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "poeIfPol", 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_poe_interface_policy with id '%s'", data.Id.ValueString())) +} + +func (r *PoeIfPolResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_poe_interface_policy") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *PoeIfPolResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_poe_interface_policy with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_poe_interface_policy") +} + +func getAndSetPoeIfPolAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *PoeIfPolResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "poeIfPol,poeRsPoeEpg,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyPoeIfPolResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("poeIfPol").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("poeIfPol").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 == "adminSt" { + readData.AdminSt = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "max" { + readData.Max = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "mode" { + readData.Mode = basetypes.NewStringValue(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 == "poeVoiceVlan" { + readData.PoeVoiceVlan = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "policeAct" && attributeValue.(string) == "" { + readData.PoliceAct = basetypes.NewStringValue("none") + } else if attributeName == "policeAct" { + readData.PoliceAct = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "prioHigh" { + readData.PrioHigh = basetypes.NewStringValue(attributeValue.(string)) + } + } + PoeRsPoeEpgPoeIfPolList := make([]PoeRsPoeEpgPoeIfPolResourceModel, 0) + TagAnnotationPoeIfPolList := make([]TagAnnotationPoeIfPolResourceModel, 0) + TagTagPoeIfPolList := make([]TagTagPoeIfPolResourceModel, 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 == "poeRsPoeEpg" { + PoeRsPoeEpgPoeIfPol := getEmptyPoeRsPoeEpgPoeIfPolResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + PoeRsPoeEpgPoeIfPol.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + PoeRsPoeEpgPoeIfPol.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationPoeRsPoeEpgPoeIfPolList := make([]TagAnnotationPoeRsPoeEpgPoeIfPolResourceModel, 0) + TagTagPoeRsPoeEpgPoeIfPolList := make([]TagTagPoeRsPoeEpgPoeIfPolResourceModel, 0) + childrenOfPoeRsPoeEpgPoeIfPol, childrenOfPoeRsPoeEpgPoeIfPolExist := childClassDetails.(map[string]interface{})["children"] + if childrenOfPoeRsPoeEpgPoeIfPolExist { + for _, childPoeRsPoeEpgPoeIfPol := range childrenOfPoeRsPoeEpgPoeIfPol.([]interface{}) { + for childClassNamePoeRsPoeEpgPoeIfPol, childClassDetailsPoeRsPoeEpgPoeIfPol := range childPoeRsPoeEpgPoeIfPol.(map[string]interface{}) { + if childClassNamePoeRsPoeEpgPoeIfPol == "tagAnnotation" { + TagAnnotationPoeRsPoeEpgPoeIfPol := getEmptyTagAnnotationPoeRsPoeEpgPoeIfPolResourceModel() + tagAnnotationchildAttributeValue := childClassDetailsPoeRsPoeEpgPoeIfPol.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue { + if childAttributeName == "key" { + TagAnnotationPoeRsPoeEpgPoeIfPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationPoeRsPoeEpgPoeIfPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationPoeRsPoeEpgPoeIfPolList = append(TagAnnotationPoeRsPoeEpgPoeIfPolList, TagAnnotationPoeRsPoeEpgPoeIfPol) + } + if childClassNamePoeRsPoeEpgPoeIfPol == "tagTag" { + TagTagPoeRsPoeEpgPoeIfPol := getEmptyTagTagPoeRsPoeEpgPoeIfPolResourceModel() + tagTagchildAttributeValue := childClassDetailsPoeRsPoeEpgPoeIfPol.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagTagchildAttributeValue { + if childAttributeName == "key" { + TagTagPoeRsPoeEpgPoeIfPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagPoeRsPoeEpgPoeIfPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagPoeRsPoeEpgPoeIfPolList = append(TagTagPoeRsPoeEpgPoeIfPolList, TagTagPoeRsPoeEpgPoeIfPol) + } + } + } + } + TagAnnotationPoeRsPoeEpgPoeIfPolSet, _ := types.SetValueFrom(ctx, TagAnnotationPoeRsPoeEpgPoeIfPolType, TagAnnotationPoeRsPoeEpgPoeIfPolList) + PoeRsPoeEpgPoeIfPol.TagAnnotation = TagAnnotationPoeRsPoeEpgPoeIfPolSet + TagTagPoeRsPoeEpgPoeIfPolSet, _ := types.SetValueFrom(ctx, TagTagPoeRsPoeEpgPoeIfPolType, TagTagPoeRsPoeEpgPoeIfPolList) + PoeRsPoeEpgPoeIfPol.TagTag = TagTagPoeRsPoeEpgPoeIfPolSet + PoeRsPoeEpgPoeIfPolList = append(PoeRsPoeEpgPoeIfPolList, PoeRsPoeEpgPoeIfPol) + } + if childClassName == "tagAnnotation" { + TagAnnotationPoeIfPol := getEmptyTagAnnotationPoeIfPolResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationPoeIfPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationPoeIfPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationPoeIfPolList = append(TagAnnotationPoeIfPolList, TagAnnotationPoeIfPol) + } + if childClassName == "tagTag" { + TagTagPoeIfPol := getEmptyTagTagPoeIfPolResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagPoeIfPol.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagPoeIfPol.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagPoeIfPolList = append(TagTagPoeIfPolList, TagTagPoeIfPol) + } + } + } + } + if len(PoeRsPoeEpgPoeIfPolList) == 1 { + poeRsPoeEpgObject, _ := types.ObjectValueFrom(ctx, PoeRsPoeEpgPoeIfPolType, PoeRsPoeEpgPoeIfPolList[0]) + readData.PoeRsPoeEpg = poeRsPoeEpgObject + } else { + poeRsPoeEpgObject, _ := types.ObjectValueFrom(ctx, PoeRsPoeEpgPoeIfPolType, getEmptyPoeRsPoeEpgPoeIfPolResourceModel()) + readData.PoeRsPoeEpg = poeRsPoeEpgObject + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationPoeIfPolList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagPoeIfPolList) + readData.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'poeIfPol'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getPoeIfPolRn(ctx context.Context, data *PoeIfPolResourceModel) string { + return fmt.Sprintf("infra/poeIfP-%s", data.Name.ValueString()) +} + +func setPoeIfPolId(ctx context.Context, data *PoeIfPolResourceModel) { + rn := getPoeIfPolRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", strings.Split([]string{"uni/infra/poeIfP-{name}"}[0], "/")[0], rn)) +} + +func getPoeIfPolPoeRsPoeEpgChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *PoeIfPolResourceModel, poeRsPoeEpgPoeIfPolPlan, poeRsPoeEpgPoeIfPolState PoeRsPoeEpgPoeIfPolResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.PoeRsPoeEpg.IsNull() && !data.PoeRsPoeEpg.IsUnknown() { + PoeRsPoeEpgPoeIfPolChildren := make([]map[string]interface{}, 0) + childMap := NewAciObject() + if !IsEmptySingleNestedAttribute(data.PoeRsPoeEpg.Attributes()) { + if !poeRsPoeEpgPoeIfPolPlan.Annotation.IsUnknown() && !poeRsPoeEpgPoeIfPolPlan.Annotation.IsNull() { + childMap.Attributes["annotation"] = poeRsPoeEpgPoeIfPolPlan.Annotation.ValueString() + } else { + childMap.Attributes["annotation"] = globalAnnotation + } + if !poeRsPoeEpgPoeIfPolPlan.TDn.IsUnknown() && !poeRsPoeEpgPoeIfPolPlan.TDn.IsNull() { + childMap.Attributes["tDn"] = poeRsPoeEpgPoeIfPolPlan.TDn.ValueString() + } + + var tagAnnotationPoeRsPoeEpgPoeIfPolPlan, tagAnnotationPoeRsPoeEpgPoeIfPolState []TagAnnotationPoeRsPoeEpgPoeIfPolResourceModel + poeRsPoeEpgPoeIfPolPlan.TagAnnotation.ElementsAs(ctx, &tagAnnotationPoeRsPoeEpgPoeIfPolPlan, false) + if !poeRsPoeEpgPoeIfPolState.TagAnnotation.IsNull() { + poeRsPoeEpgPoeIfPolState.TagAnnotation.ElementsAs(ctx, &tagAnnotationPoeRsPoeEpgPoeIfPolState, false) + } + if !poeRsPoeEpgPoeIfPolPlan.TagAnnotation.IsNull() && !poeRsPoeEpgPoeIfPolPlan.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationPoeRsPoeEpgPoeIfPol := range tagAnnotationPoeRsPoeEpgPoeIfPolPlan { + tagAnnotationPoeRsPoeEpgPoeIfPolChildMap := NewAciObject() + if !tagAnnotationPoeRsPoeEpgPoeIfPol.Key.IsNull() && !tagAnnotationPoeRsPoeEpgPoeIfPol.Key.IsUnknown() { + tagAnnotationPoeRsPoeEpgPoeIfPolChildMap.Attributes["key"] = tagAnnotationPoeRsPoeEpgPoeIfPol.Key.ValueString() + } + if !tagAnnotationPoeRsPoeEpgPoeIfPol.Value.IsNull() && !tagAnnotationPoeRsPoeEpgPoeIfPol.Value.IsUnknown() { + tagAnnotationPoeRsPoeEpgPoeIfPolChildMap.Attributes["value"] = tagAnnotationPoeRsPoeEpgPoeIfPol.Value.ValueString() + } + PoeRsPoeEpgPoeIfPolChildren = append(PoeRsPoeEpgPoeIfPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationPoeRsPoeEpgPoeIfPolChildMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationPoeRsPoeEpgPoeIfPol.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotationPoeRsPoeEpgPoeIfPol := range tagAnnotationPoeRsPoeEpgPoeIfPolState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotationPoeRsPoeEpgPoeIfPol.Key { + delete = false + break + } + } + if delete { + tagAnnotationPoeRsPoeEpgPoeIfPolChildMapForDelete := NewAciObject() + tagAnnotationPoeRsPoeEpgPoeIfPolChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationPoeRsPoeEpgPoeIfPolChildMapForDelete.Attributes["key"] = tagAnnotationPoeRsPoeEpgPoeIfPol.Key.ValueString() + PoeRsPoeEpgPoeIfPolChildren = append(PoeRsPoeEpgPoeIfPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationPoeRsPoeEpgPoeIfPolChildMapForDelete}) + } + } + } + + var tagTagPoeRsPoeEpgPoeIfPolPlan, tagTagPoeRsPoeEpgPoeIfPolState []TagTagPoeRsPoeEpgPoeIfPolResourceModel + poeRsPoeEpgPoeIfPolPlan.TagTag.ElementsAs(ctx, &tagTagPoeRsPoeEpgPoeIfPolPlan, false) + if !poeRsPoeEpgPoeIfPolState.TagTag.IsNull() { + poeRsPoeEpgPoeIfPolState.TagTag.ElementsAs(ctx, &tagTagPoeRsPoeEpgPoeIfPolState, false) + } + if !poeRsPoeEpgPoeIfPolPlan.TagTag.IsNull() && !poeRsPoeEpgPoeIfPolPlan.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagPoeRsPoeEpgPoeIfPol := range tagTagPoeRsPoeEpgPoeIfPolPlan { + tagTagPoeRsPoeEpgPoeIfPolChildMap := NewAciObject() + if !tagTagPoeRsPoeEpgPoeIfPol.Key.IsNull() && !tagTagPoeRsPoeEpgPoeIfPol.Key.IsUnknown() { + tagTagPoeRsPoeEpgPoeIfPolChildMap.Attributes["key"] = tagTagPoeRsPoeEpgPoeIfPol.Key.ValueString() + } + if !tagTagPoeRsPoeEpgPoeIfPol.Value.IsNull() && !tagTagPoeRsPoeEpgPoeIfPol.Value.IsUnknown() { + tagTagPoeRsPoeEpgPoeIfPolChildMap.Attributes["value"] = tagTagPoeRsPoeEpgPoeIfPol.Value.ValueString() + } + PoeRsPoeEpgPoeIfPolChildren = append(PoeRsPoeEpgPoeIfPolChildren, map[string]interface{}{"tagTag": tagTagPoeRsPoeEpgPoeIfPolChildMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagPoeRsPoeEpgPoeIfPol.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTagPoeRsPoeEpgPoeIfPol := range tagTagPoeRsPoeEpgPoeIfPolState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTagPoeRsPoeEpgPoeIfPol.Key { + delete = false + break + } + } + if delete { + tagTagPoeRsPoeEpgPoeIfPolChildMapForDelete := NewAciObject() + tagTagPoeRsPoeEpgPoeIfPolChildMapForDelete.Attributes["status"] = "deleted" + tagTagPoeRsPoeEpgPoeIfPolChildMapForDelete.Attributes["key"] = tagTagPoeRsPoeEpgPoeIfPol.Key.ValueString() + PoeRsPoeEpgPoeIfPolChildren = append(PoeRsPoeEpgPoeIfPolChildren, map[string]interface{}{"tagTag": tagTagPoeRsPoeEpgPoeIfPolChildMapForDelete}) + } + } + } + childMap.Children = PoeRsPoeEpgPoeIfPolChildren + } else { + childMap.Attributes["status"] = "deleted" + } + childPayloads = append(childPayloads, map[string]interface{}{"poeRsPoeEpg": childMap}) + } else { + PoeRsPoeEpgObject, _ := types.ObjectValueFrom(ctx, PoeRsPoeEpgPoeIfPolType, getEmptyPoeRsPoeEpgPoeIfPolResourceModel()) + data.PoeRsPoeEpg = PoeRsPoeEpgObject + } + + return childPayloads +} + +func getPoeIfPolTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *PoeIfPolResourceModel, tagAnnotationPoeIfPolPlan, tagAnnotationPoeIfPolState []TagAnnotationPoeIfPolResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationPoeIfPol := range tagAnnotationPoeIfPolPlan { + childMap := NewAciObject() + if !tagAnnotationPoeIfPol.Key.IsNull() && !tagAnnotationPoeIfPol.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationPoeIfPol.Key.ValueString() + } + if !tagAnnotationPoeIfPol.Value.IsNull() && !tagAnnotationPoeIfPol.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationPoeIfPol.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationPoeIfPol.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationPoeIfPolState { + 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 getPoeIfPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *PoeIfPolResourceModel, tagTagPoeIfPolPlan, tagTagPoeIfPolState []TagTagPoeIfPolResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagPoeIfPol := range tagTagPoeIfPolPlan { + childMap := NewAciObject() + if !tagTagPoeIfPol.Key.IsNull() && !tagTagPoeIfPol.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagPoeIfPol.Key.ValueString() + } + if !tagTagPoeIfPol.Value.IsNull() && !tagTagPoeIfPol.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagPoeIfPol.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagPoeIfPol.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagPoeIfPolState { + 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 getPoeIfPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *PoeIfPolResourceModel, poeRsPoeEpgPlan, poeRsPoeEpgState PoeRsPoeEpgPoeIfPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPoeIfPolResourceModel, tagTagPlan, tagTagState []TagTagPoeIfPolResourceModel) *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{}{} + + PoeRsPoeEpgchildPayloads := getPoeIfPolPoeRsPoeEpgChildPayloads(ctx, diags, data, poeRsPoeEpgPlan, poeRsPoeEpgState) + if PoeRsPoeEpgchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, PoeRsPoeEpgchildPayloads...) + + TagAnnotationchildPayloads := getPoeIfPolTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getPoeIfPolTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.AdminSt.IsNull() && !data.AdminSt.IsUnknown() { + payloadMap["attributes"].(map[string]string)["adminSt"] = data.AdminSt.ValueString() + } + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.Max.IsNull() && !data.Max.IsUnknown() { + payloadMap["attributes"].(map[string]string)["max"] = data.Max.ValueString() + } + if !data.Mode.IsNull() && !data.Mode.IsUnknown() { + payloadMap["attributes"].(map[string]string)["mode"] = data.Mode.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.PoeVoiceVlan.IsNull() && !data.PoeVoiceVlan.IsUnknown() { + payloadMap["attributes"].(map[string]string)["poeVoiceVlan"] = data.PoeVoiceVlan.ValueString() + } + if !data.PoliceAct.IsNull() && !data.PoliceAct.IsUnknown() { + payloadMap["attributes"].(map[string]string)["policeAct"] = data.PoliceAct.ValueString() + } + if !data.PrioHigh.IsNull() && !data.PrioHigh.IsUnknown() { + payloadMap["attributes"].(map[string]string)["prioHigh"] = data.PrioHigh.ValueString() + } + payload, err := json.Marshal(map[string]interface{}{"poeIfPol": 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_poe_interface_policy_test.go b/internal/provider/resource_aci_poe_interface_policy_test.go new file mode 100644 index 000000000..5d00cd687 --- /dev/null +++ b/internal/provider/resource_aci_poe_interface_policy_test.go @@ -0,0 +1,501 @@ +// 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" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" +) + +func TestAccResourcePoeIfPol(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "3.0(1k)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigPoeIfPolMinAllowExisting + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "port_priority_high", "no"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "port_priority_high", "no"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "poe_vlan", "unknown"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "poe_vlan", "unknown")), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "3.0(1k)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigPoeIfPolMinAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "3.0(1k)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigPoeIfPolMinAllowExisting + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "port_priority_high", "no"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "port_priority_high", "no"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test", "poe_vlan", "unknown"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.allow_test_2", "poe_vlan", "unknown")), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "3.0(1k)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigPoeIfPolMin + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "port_priority_high", "no"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "poe_vlan", "unknown")), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigPoeIfPolAll + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "host_mode", "never"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "maximum_power", "15400"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "policing_action", "log"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "port_priority_high", "yes"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "poe_vlan", "vlan-200")), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigPoeIfPolMin + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "host_mode", "never"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "maximum_power", "15400"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "policing_action", "log"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "port_priority_high", "yes"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "poe_vlan", "vlan-200")), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigPoeIfPolReset + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "port_priority_high", "no"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "poe_vlan", "unknown")), + ), + }, + // Import testing + { + ResourceName: "aci_poe_interface_policy.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigPoeIfPolChildren + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "port_priority_high", "no"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "poe_vlan", "unknown")), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.#", "2"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.#", "2"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.target_dn", "uni/tn-test_name/ap-test_name/epg-epg_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.#", "2"), + ), + }, + // Update with children removed from config + { + Config: testConfigPoeIfPolChildrenRemoveFromConfig + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "port_priority_high", "no"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "poe_vlan", "unknown")), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.annotations.#", "2"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.tags.#", "2"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "relation_to_application_epg.target_dn", "uni/tn-test_name/ap-test_name/epg-epg_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigPoeIfPolChildrenRemoveOne + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "port_priority_high", "no"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "poe_vlan", "unknown")), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.#", "1"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_poe_interface_policy.test", + tfjsonpath.New("relation_to_application_epg"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with all children removed + { + Config: testConfigPoeIfPolChildrenRemoveAll + testConfigDataSourceSystem, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "description", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "host_mode", "auto"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "maximum_power", "30000"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "policing_action", "err-dis"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "port_priority_high", "no"), + composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside", + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "admin_st", "disabled"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "poe_vlan", "unknown")), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_poe_interface_policy.test", "tags.#", "0"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_poe_interface_policy.test", + tfjsonpath.New("relation_to_application_epg"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testChildDependencyConfigPoeIfPol = ` +resource "aci_tenant" "test_tenant_0"{ + name = "test_name" +} +resource "aci_application_profile" "test_application_profile_1"{ + parent_dn = aci_tenant.test_tenant_0.id + name = "test_name" +} +resource "aci_application_epg" "test_application_epg_0"{ + parent_dn = aci_application_profile.test_application_profile_1.id + name = "epg_0" +} +` + +const testConfigPoeIfPolMinAllowExisting = ` +resource "aci_poe_interface_policy" "allow_test" { + name = "test_name" +} +resource "aci_poe_interface_policy" "allow_test_2" { + name = "test_name" + depends_on = [aci_poe_interface_policy.allow_test] +} +` + +const testConfigPoeIfPolMin = ` +resource "aci_poe_interface_policy" "test" { + name = "test_name" +} +` + +const testConfigPoeIfPolAll = ` +resource "aci_poe_interface_policy" "test" { + name = "test_name" + annotation = "annotation" + description = "description_1" + host_mode = "never" + maximum_power = "15400" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + policing_action = "log" + port_priority_high = "yes" + admin_st = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "disabled" : null + poe_vlan = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "vlan-200" : null +} +` + +const testConfigPoeIfPolReset = ` +resource "aci_poe_interface_policy" "test" { + name = "test_name" + annotation = "orchestrator:terraform" + description = "" + host_mode = "auto" + maximum_power = "30000" + name_alias = "" + owner_key = "" + owner_tag = "" + policing_action = "err-dis" + port_priority_high = "no" + admin_st = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "disabled" : null + poe_vlan = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "unknown" : null +} +` +const testConfigPoeIfPolChildren = testChildDependencyConfigPoeIfPol + ` +resource "aci_poe_interface_policy" "test" { + name = "test_name" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_application_epg = { + annotation = "annotation_1" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + target_dn = aci_application_epg.test_application_epg_0.id + } + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + + depends_on = [ + aci_tenant.test_tenant_0, + aci_application_profile.test_application_profile_1, + aci_application_epg.test_application_epg_0, + ] +} +` + +const testConfigPoeIfPolChildrenRemoveFromConfig = testChildDependencyConfigPoeIfPol + ` +resource "aci_poe_interface_policy" "test" { + name = "test_name" +} +` + +const testConfigPoeIfPolChildrenRemoveOne = testChildDependencyConfigPoeIfPol + ` +resource "aci_poe_interface_policy" "test" { + name = "test_name" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_application_epg = {} + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigPoeIfPolChildrenRemoveAll = testChildDependencyConfigPoeIfPol + ` +resource "aci_poe_interface_policy" "test" { + name = "test_name" + annotations = [] + relation_to_application_epg = {} + tags = [] +} +`