From aeef569f90f45ba2ba27b00aab2e12797f36d304 Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Thu, 27 Jun 2024 14:07:41 -0400 Subject: [PATCH 01/11] [minor_change] Add Resource and Datasource for Host Path Selector (infraHPathS). --- docs/data-sources/host_path_selector.md | 66 ++ docs/resources/host_path_selector.md | 127 +++ .../aci_host_path_selector/data-source.tf | 4 + .../aci_host_path_selector/provider.tf | 14 + .../aci_host_path_selector/provider.tf | 14 + .../resource-all-attributes.tf | 21 + .../aci_host_path_selector/resource.tf | 4 + gen/definitions/classes.yaml | 4 + gen/definitions/properties.yaml | 17 + gen/meta/infraHPathS.json | 786 ++++++++++++++++++ gen/testvars/infraHPathS.yaml | 43 + .../data_source_aci_host_path_selector.go | 170 ++++ ...data_source_aci_host_path_selector_test.go | 50 ++ .../resource_aci_host_path_selector.go | 625 ++++++++++++++ .../resource_aci_host_path_selector_test.go | 240 ++++++ 15 files changed, 2185 insertions(+) create mode 100644 docs/data-sources/host_path_selector.md create mode 100644 docs/resources/host_path_selector.md create mode 100644 examples/data-sources/aci_host_path_selector/data-source.tf create mode 100644 examples/data-sources/aci_host_path_selector/provider.tf create mode 100644 examples/resources/aci_host_path_selector/provider.tf create mode 100644 examples/resources/aci_host_path_selector/resource-all-attributes.tf create mode 100644 examples/resources/aci_host_path_selector/resource.tf create mode 100644 gen/meta/infraHPathS.json create mode 100644 gen/testvars/infraHPathS.yaml create mode 100644 internal/provider/data_source_aci_host_path_selector.go create mode 100644 internal/provider/data_source_aci_host_path_selector_test.go create mode 100644 internal/provider/resource_aci_host_path_selector.go create mode 100644 internal/provider/resource_aci_host_path_selector_test.go diff --git a/docs/data-sources/host_path_selector.md b/docs/data-sources/host_path_selector.md new file mode 100644 index 000000000..f8bdd1216 --- /dev/null +++ b/docs/data-sources/host_path_selector.md @@ -0,0 +1,66 @@ +--- +# 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: "Generic" +layout: "aci" +page_title: "ACI: aci_host_path_selector" +sidebar_current: "docs-aci-data-source-aci_host_path_selector" +description: |- + Data source for Host Path Selector +--- + +# aci_host_path_selector # + +Data source for Host Path Selector + +## API Information ## + +* Class: [infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview) + +* Supported in ACI versions: 1.1(1j) and later. + +* Distinguished Name Format: `uni/infra/hpaths-{name}` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## + +```hcl + +data "aci_host_path_selector" "example" { + name = "host_path_selector" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - The distinguished name (DN) of classes below can be used but currently there is no available resource for it: + - [infraInfra](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraInfra/overview) + + - Default: `uni/infra` + +* `name` (name) - (string) The name of the Host Path Selector object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Host Path Selector object. +* `annotation` (annotation) - (string) The annotation of the Host Path Selector object. +* `description` (descr) - (string) The description of the Host Path Selector object. +* `name_alias` (nameAlias) - (string) The name alias of the Host Path Selector 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. + +* `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/host_path_selector.md b/docs/resources/host_path_selector.md new file mode 100644 index 000000000..a60cf5192 --- /dev/null +++ b/docs/resources/host_path_selector.md @@ -0,0 +1,127 @@ +--- +# 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: "Generic" +layout: "aci" +page_title: "ACI: aci_host_path_selector" +sidebar_current: "docs-aci-resource-aci_host_path_selector" +description: |- + Manages ACI Host Path Selector +--- + +# aci_host_path_selector # + +Manages ACI Host Path Selector + + + +## API Information ## + +* Class: [infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview) + +* Supported in ACI versions: 1.1(1j) and later. + +* Distinguished Name Format: `uni/infra/hpaths-{name}` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## + +The configuration snippet below creates a Host Path Selector with only required attributes. + +```hcl + +resource "aci_host_path_selector" "example" { + name = "host_path_selector" +} + +``` +The configuration snippet below shows all possible attributes of the Host Path Selector. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_host_path_selector" "full_example" { + annotation = "annotation" + description = "description" + name = "host_path_selector" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Host Path Selector resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_host_path_selector) folder. + +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the Host Path Selector object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Host Path Selector object. + +### Optional ### +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - The distinguished name (DN) of classes below can be used but currently there is no available resource for it: + - [infraInfra](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraInfra/overview) + + - Default: `uni/infra` + +* `annotation` (annotation) - (string) The annotation of the Host Path Selector object. + - Default: `orchestrator:terraform` +* `description` (descr) - (string) The description of the Host Path Selector object. +* `name_alias` (nameAlias) - (string) The name alias of the Host Path Selector 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. + +* `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 Host Path Selector 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_host_path_selector.example uni/infra/hpaths-{name} +``` + +Starting in Terraform version 1.5, an existing Host Path Selector can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/infra/hpaths-{name}" + to = aci_host_path_selector.example +} +``` diff --git a/examples/data-sources/aci_host_path_selector/data-source.tf b/examples/data-sources/aci_host_path_selector/data-source.tf new file mode 100644 index 000000000..19a11528f --- /dev/null +++ b/examples/data-sources/aci_host_path_selector/data-source.tf @@ -0,0 +1,4 @@ + +data "aci_host_path_selector" "example" { + name = "host_path_selector" +} diff --git a/examples/data-sources/aci_host_path_selector/provider.tf b/examples/data-sources/aci_host_path_selector/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_host_path_selector/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_host_path_selector/provider.tf b/examples/resources/aci_host_path_selector/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_host_path_selector/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_host_path_selector/resource-all-attributes.tf b/examples/resources/aci_host_path_selector/resource-all-attributes.tf new file mode 100644 index 000000000..0f6159d53 --- /dev/null +++ b/examples/resources/aci_host_path_selector/resource-all-attributes.tf @@ -0,0 +1,21 @@ + +resource "aci_host_path_selector" "full_example" { + annotation = "annotation" + description = "description" + name = "host_path_selector" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_host_path_selector/resource.tf b/examples/resources/aci_host_path_selector/resource.tf new file mode 100644 index 000000000..f32f9050d --- /dev/null +++ b/examples/resources/aci_host_path_selector/resource.tf @@ -0,0 +1,4 @@ + +resource "aci_host_path_selector" "example" { + name = "host_path_selector" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index b475280bf..a7e4deaa3 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -567,5 +567,9 @@ fvIpAttr: - "uni/tn-{name}/ap-{name}/epg-{name}/crtrn/ipattr-{name}" contained_by: - "fvCrtrn" + physDomP: resource_name: "physical_domain" + +infraHPathS: + resource_name: "host_path_selector" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 5a3d73233..a25f93f01 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -928,3 +928,20 @@ rtctrlProfile: documentation: autoContinue: "The route_map_continue applies a continue statement for all user-configured sequences (contexts) in a given BGP route profile so that switches will continue to find matches with subsequent user-configured sequences in the route map. Without the continue statement, after a route matches one of the sequences in a route map, switches will not continue to check other sequences." type: "The type of the %s object. Use combinable when pervasive subnets (fvSubnet) and external subnets (l3extSubnet) should be combined with a route profile and merged into a single route map or route map entry. Use global when the route profile is the only source of information to generate a route map, this will overwrite other policy attributes." + +infraHPathS: + default_values: + parent_dn: "uni/infra" + test_values: + default: + name: "host_path_selector_default" + resource_required: + name: "host_path_selector" + datasource_required: + name: "host_path_selector" + datasource_non_existing: + name: "host_path_selector_non_existing" + parents: + - class_name: "infraInfra" + parent_dependency: "" + parent_dn: "uni/infra" diff --git a/gen/meta/infraHPathS.json b/gen/meta/infraHPathS.json new file mode 100644 index 000000000..f54679035 --- /dev/null +++ b/gen/meta/infraHPathS.json @@ -0,0 +1,786 @@ +{ + "infra:HPathS": { + "contains": { + "aaa:RbacAnnotation": "", + "fabric:RtToFabricPathS": "", + "fabric:RtToInfraPathS": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "infra:RsHPathAtt": "", + "infra:RsPathToAccBaseGrp": "", + "infra:SelectorIssues": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "rsHPathAtt-": "infra:RsHPathAtt", + "rspathToAccBaseGrp": "infra:RsPathToAccBaseGrp", + "rtinfraToInfraPathS-": "fabric:RtToInfraPathS", + "rttoFabricPathS-": "fabric:RtToFabricPathS", + "selectorissues": "infra:SelectorIssues", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "hpaths-{name}", + "containedBy": { + "infra:Infra": "" + }, + "superClasses": [ + "infra:APathS", + "fabric:APathS", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "fabric:RtToFabricPathS": "fabric:NodeCfg", + "fabric:RtToInfraPathS": "infra:NodeCfg" + }, + "relationTo": { + "infra:RsHPathAtt": "fabric:PathEp", + "infra:RsPathToAccBaseGrp": "infra:AccBaseGrp" + }, + "dnFormats": [ + "uni/infra/hpaths-{name}" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "custom-port-privilege" + ], + "faults": { + + }, + "events": { + "E4212236": "creation||infra:HPathS", + "E4212237": "modification||infra:HPathS", + "E4212238": "deletion||infra:HPathS" + }, + "stats": { + + }, + "versions": "1.1(1j)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": true, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + "apic" + ], + "classId": "6105", + "className": "HPathS", + "classPkg": "infra", + "featureTag": "", + "moCategory": "Regular", + "label": "Host Path Selector", + "comment": [ + "" + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38184", + "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 + }, + "creator": { + "versions": "5.2(8d)-5.2(8e),6.0(2h)-", + "isConfigurable": false, + "propGlobalId": "69215", + "propLocalId": "14578", + "label": "MO creator origin", + "baseType": "scalar:Enum8", + "modelType": "fabric:CreatorType", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "1", "localName": "SYSTEM", + "platformFlavors": [ + + ], + "label": "system maintained "}, + { "value": "0", "localName": "USER", + "platformFlavors": [ + + ], + "label": "created by the user "}, + { "value": "USER", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "USER", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(1e)-", + "comment": [ + "Specifies a description of the policy definition." + ], + "isConfigurable": true, + "propGlobalId": "5579", + "propLocalId": "28", + "label": "Description", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Described:descr", + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40323", + "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 + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "versions": "1.1(1j)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "18171", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.1(1j)-", + "comment": [ + "The name of the object." + ], + "isConfigurable": true, + "propGlobalId": "18138", + "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": 128, + "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 + }, + "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/testvars/infraHPathS.yaml b/gen/testvars/infraHPathS.yaml new file mode 100644 index 000000000..d440bed6a --- /dev/null +++ b/gen/testvars/infraHPathS.yaml @@ -0,0 +1,43 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + description: "" + name_alias: "" + owner_key: "" + owner_tag: "" + +datasource_non_existing: + name: "host_path_selector_non_existing" + +datasource_required: + name: "host_path_selector" + +resource_required: + name: "host_path_selector" + +all: + annotation: "annotation" + description: "description" + name_alias: "name_alias" + owner_key: "owner_key" + owner_tag: "owner_tag" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + +parents: diff --git a/internal/provider/data_source_aci_host_path_selector.go b/internal/provider/data_source_aci_host_path_selector.go new file mode 100644 index 000000000..85862d7cb --- /dev/null +++ b/internal/provider/data_source_aci_host_path_selector.go @@ -0,0 +1,170 @@ +// 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-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &InfraHPathSDataSource{} + +func NewInfraHPathSDataSource() datasource.DataSource { + return &InfraHPathSDataSource{} +} + +// InfraHPathSDataSource defines the data source implementation. +type InfraHPathSDataSource struct { + client *client.Client +} + +func (d *InfraHPathSDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_host_path_selector") + resp.TypeName = req.ProviderTypeName + "_host_path_selector" + tflog.Debug(ctx, "End metadata of datasource: aci_host_path_selector") +} + +func (d *InfraHPathSDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_host_path_selector") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The host_path_selector datasource for the 'infraHPathS' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Host Path Selector object.", + }, + "parent_dn": schema.StringAttribute{ + Optional: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Host Path Selector object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Host Path Selector object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Host Path Selector object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Host Path Selector 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.`, + }, + "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_host_path_selector") +} + +func (d *InfraHPathSDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_host_path_selector") + // 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_host_path_selector") +} + +func (d *InfraHPathSDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_host_path_selector") + var data *InfraHPathSResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if data.ParentDn.IsNull() || data.ParentDn.IsUnknown() { + data.ParentDn = basetypes.NewStringValue("uni/infra") + } + + setInfraHPathSId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraHPathSAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_host_path_selector with id '%s'", data.Id.ValueString())) + + getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_host_path_selector data source", + fmt.Sprintf("The aci_host_path_selector 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_host_path_selector with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_host_path_selector_test.go b/internal/provider/data_source_aci_host_path_selector_test.go new file mode 100644 index 000000000..58a62edf9 --- /dev/null +++ b/internal/provider/data_source_aci_host_path_selector_test.go @@ -0,0 +1,50 @@ +// 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 TestAccDataSourceInfraHPathS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraHPathSDataSource, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "description", "description"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_tag", "owner_tag"), + ), + }, + { + Config: testConfigInfraHPathSNotExisting, + ExpectError: regexp.MustCompile("Failed to read aci_host_path_selector data source"), + }, + }, + }) +} + +const testConfigInfraHPathSDataSource = testConfigInfraHPathSAll + ` +data "aci_host_path_selector" "test" { + name = "host_path_selector" + depends_on = [aci_host_path_selector.test] +} +` + +const testConfigInfraHPathSNotExisting = testConfigInfraHPathSAll + ` +data "aci_host_path_selector" "test" { + name = "host_path_selector_non_existing" + depends_on = [aci_host_path_selector.test] +} +` diff --git a/internal/provider/resource_aci_host_path_selector.go b/internal/provider/resource_aci_host_path_selector.go new file mode 100644 index 000000000..9a7aaca11 --- /dev/null +++ b/internal/provider/resource_aci_host_path_selector.go @@ -0,0 +1,625 @@ +// 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" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/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 = &InfraHPathSResource{} +var _ resource.ResourceWithImportState = &InfraHPathSResource{} + +func NewInfraHPathSResource() resource.Resource { + return &InfraHPathSResource{} +} + +// InfraHPathSResource defines the resource implementation. +type InfraHPathSResource struct { + client *client.Client +} + +// InfraHPathSResourceModel describes the resource data model. +type InfraHPathSResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +// TagAnnotationInfraHPathSResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraHPathSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +// TagTagInfraHPathSResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraHPathSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +type InfraHPathSIdentifier struct { + Name types.String +} + +func (r *InfraHPathSResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_host_path_selector") + resp.TypeName = req.ProviderTypeName + "_host_path_selector" + tflog.Debug(ctx, "End metadata of resource: aci_host_path_selector") +} + +func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_host_path_selector") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The host_path_selector resource for the 'infraHPathS' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Host Path Selector object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + Default: stringdefault.StaticString("uni/infra"), + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Host Path Selector object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the Host Path Selector object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Host Path Selector object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the Host Path Selector object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + 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(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this 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.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_host_path_selector") +} + +func (r *InfraHPathSResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_host_path_selector") + // 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_host_path_selector") +} + +func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_host_path_selector") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraHPathSResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + setInfraHPathSId(ctx, stateData) + getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *InfraHPathSResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setInfraHPathSId(ctx, data) + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetInfraHPathSAttributes(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_host_path_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPathSResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_host_path_selector") + var data *InfraHPathSResourceModel + + // 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_host_path_selector with id '%s'", data.Id.ValueString())) + + getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraHPathSResourceModel + 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_host_path_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPathSResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_host_path_selector") + var data *InfraHPathSResourceModel + var stateData *InfraHPathSResourceModel + + // 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_host_path_selector with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetInfraHPathSAttributes(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_host_path_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPathSResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_host_path_selector") + var data *InfraHPathSResourceModel + + // 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_host_path_selector with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraHPathS", 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_host_path_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPathSResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_host_path_selector") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraHPathSResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_host_path_selector with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_host_path_selector") +} + +func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraHPathSResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "infraHPathS,tagAnnotation,tagTag"), "GET", nil) + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraHPathS").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraHPathS").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + data.Id = basetypes.NewStringValue(attributeValue.(string)) + setInfraHPathSParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + data.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + data.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + data.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + data.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + data.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationInfraHPathSList := make([]TagAnnotationInfraHPathSResourceModel, 0) + TagTagInfraHPathSList := make([]TagTagInfraHPathSResourceModel, 0) + _, ok := classReadInfo[0].(map[string]interface{})["children"] + if ok { + children := classReadInfo[0].(map[string]interface{})["children"].([]interface{}) + for _, child := range children { + for childClassName, childClassDetails := range child.(map[string]interface{}) { + childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "tagAnnotation" { + TagAnnotationInfraHPathS := TagAnnotationInfraHPathSResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraHPathS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraHPathS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationInfraHPathSList = append(TagAnnotationInfraHPathSList, TagAnnotationInfraHPathS) + } + if childClassName == "tagTag" { + TagTagInfraHPathS := TagTagInfraHPathSResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraHPathS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraHPathS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagInfraHPathSList = append(TagTagInfraHPathSList, TagTagInfraHPathS) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationInfraHPathSList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagInfraHPathSList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraHPathS'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getInfraHPathSRn(ctx context.Context, data *InfraHPathSResourceModel) string { + rn := "hpaths-{name}" + for _, identifier := range []string{"name"} { + fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) + fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() + rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) + } + return rn +} + +func setInfraHPathSParentDn(ctx context.Context, dn string, data *InfraHPathSResourceModel) { + bracketIndex := 0 + rnIndex := 0 + for i := len(dn) - 1; i >= 0; i-- { + if string(dn[i]) == "]" { + bracketIndex = bracketIndex + 1 + } else if string(dn[i]) == "[" { + bracketIndex = bracketIndex - 1 + } else if string(dn[i]) == "/" && bracketIndex == 0 { + rnIndex = i + break + } + } + data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) +} + +func setInfraHPathSId(ctx context.Context, data *InfraHPathSResourceModel) { + rn := getInfraHPathSRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraHPathSTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotation := range tagAnnotationPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagAnnotation.Key.IsUnknown() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func getInfraHPathSTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTag := range tagTagPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagTag.Key.IsUnknown() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getInfraHPathSTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraHPathSTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.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() + } + + payload, err := json.Marshal(map[string]interface{}{"infraHPathS": 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_host_path_selector_test.go b/internal/provider/resource_aci_host_path_selector_test.go new file mode 100644 index 000000000..4978541cb --- /dev/null +++ b/internal/provider/resource_aci_host_path_selector_test.go @@ -0,0 +1,240 @@ +// 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 ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourceInfraHPathS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPathSMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraHPathSAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraHPathSMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraHPathSReset, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_host_path_selector.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + ), + }, + // Update with children + { + Config: testConfigInfraHPathSChildren, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "2"), + ), + }, + // Update with children removed from config + { + Config: testConfigInfraHPathSChildrenRemoveFromConfig, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraHPathSChildrenRemoveOne, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigInfraHPathSChildrenRemoveAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigInfraHPathSMin = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" +} +` + +const testConfigInfraHPathSAll = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotation = "annotation" + description = "description" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" +} +` + +const testConfigInfraHPathSReset = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraHPathSChildren = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigInfraHPathSChildrenRemoveFromConfig = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" +} +` + +const testConfigInfraHPathSChildrenRemoveOne = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigInfraHPathSChildrenRemoveAll = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotations = [] + tags = [] +} +` From 560d3c09cb9cb78a2f1970aa05871b67a98754ab Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Tue, 2 Jul 2024 16:55:27 -0400 Subject: [PATCH 02/11] [ignore] Re generate files after rebase. --- internal/provider/provider.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 3254708cc..f5c872714 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -229,6 +229,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvRsSecInheritedResource, NewFvSCrtrnResource, NewFvVmAttrResource, + NewInfraHPathSResource, NewL3extConsLblResource, NewL3extProvLblResource, NewL3extRsOutToFBRGroupResource, From 1026a6a18387b0b4995371a23be04b95ae6d520e Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Wed, 31 Jul 2024 09:40:48 -0400 Subject: [PATCH 03/11] [ignore] Regenerate resource and resource_test for InfraHPathS. --- internal/provider/provider.go | 1 + .../resource_aci_host_path_selector.go | 50 +++++++++++-- .../resource_aci_host_path_selector_test.go | 75 +++++++++++++++++++ 3 files changed, 121 insertions(+), 5 deletions(-) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f5c872714..400f7b6a7 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -280,6 +280,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvRsSecInheritedDataSource, NewFvSCrtrnDataSource, NewFvVmAttrDataSource, + NewInfraHPathSDataSource, NewL3extConsLblDataSource, NewL3extProvLblDataSource, NewL3extRsOutToFBRGroupDataSource, diff --git a/internal/provider/resource_aci_host_path_selector.go b/internal/provider/resource_aci_host_path_selector.go index 9a7aaca11..c118b61cb 100644 --- a/internal/provider/resource_aci_host_path_selector.go +++ b/internal/provider/resource_aci_host_path_selector.go @@ -69,6 +69,31 @@ type InfraHPathSIdentifier struct { Name types.String } +func (r *InfraHPathSResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *InfraHPathSResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { + setInfraHPathSId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "infraHPathS", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + func (r *InfraHPathSResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { tflog.Debug(ctx, "Start metadata of resource: aci_host_path_selector") resp.TypeName = req.ProviderTypeName + "_host_path_selector" @@ -232,8 +257,17 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *InfraHPathSResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setInfraHPathSId(ctx, stateData) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setInfraHPathSId(ctx, stateData) + } getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The infraHPathS object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } var data *InfraHPathSResourceModel @@ -244,7 +278,9 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq return } - setInfraHPathSId(ctx, data) + if data.Id.IsUnknown() || data.Id.IsNull() { + setInfraHPathSId(ctx, data) + } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) @@ -254,7 +290,7 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -319,7 +355,7 @@ func (r *InfraHPathSResource) Update(ctx context.Context, req resource.UpdateReq var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -566,9 +602,13 @@ func getInfraHPathSTagTagChildPayloads(ctx context.Context, diags *diag.Diagnost return childPayloads } -func getInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) *container.Container { +func getInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} + + if createType && !globalAllowExistingOnCreate { + payloadMap["attributes"].(map[string]string)["status"] = "created" + } childPayloads := []map[string]interface{}{} TagAnnotationchildPayloads := getInfraHPathSTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) diff --git a/internal/provider/resource_aci_host_path_selector_test.go b/internal/provider/resource_aci_host_path_selector_test.go index 4978541cb..a087d2ac5 100644 --- a/internal/provider/resource_aci_host_path_selector_test.go +++ b/internal/provider/resource_aci_host_path_selector_test.go @@ -5,6 +5,7 @@ package provider import ( + "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -12,6 +13,70 @@ import ( func TestAccResourceInfraHPathS(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPathSMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "owner_tag", ""), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPathSMinAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPathSMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "owner_tag", ""), + ), + }, + }, + }) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, @@ -154,6 +219,16 @@ func TestAccResourceInfraHPathS(t *testing.T) { }) } +const testConfigInfraHPathSMinAllowExisting = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" +} +resource "aci_host_path_selector" "test_2" { + name = "host_path_selector" + depends_on = [aci_host_path_selector.test] +} +` + const testConfigInfraHPathSMin = ` resource "aci_host_path_selector" "test" { name = "host_path_selector" From 7b8e3c2033eba3c3b0cf7c3af70dbb746dd859dd Mon Sep 17 00:00:00 2001 From: akinross Date: Wed, 31 Jul 2024 11:12:17 -0400 Subject: [PATCH 04/11] [ignore] Cherry-pick Akini's modifications to migration and target_dn changes from his EPG migration PRs. Removed all EPG's related information from definitions. --- .../relation_to_consumed_contract.md | 5 - .../relation_to_imported_contract.md | 5 - .../relation_to_intra_epg_contract.md | 5 - .../relation_to_provided_contract.md | 5 - docs/resources/host_path_selector.md | 8 +- .../relation_to_consumed_contract.md | 28 +---- docs/resources/relation_to_contract_master.md | 4 +- .../relation_to_imported_contract.md | 28 +---- .../relation_to_intra_epg_contract.md | 27 +---- .../relation_to_provided_contract.md | 29 +---- .../data-source.tf | 5 - .../data-source.tf | 5 - .../data-source.tf | 5 - .../data-source.tf | 5 - .../resource-all-attributes.tf | 8 +- .../resource-all-attributes.tf | 19 ---- .../resource.tf | 5 - .../resource-all-attributes.tf | 19 ---- .../resource.tf | 5 - .../resource-all-attributes.tf | 18 --- .../resource.tf | 5 - .../resource-all-attributes.tf | 20 ---- .../resource.tf | 5 - gen/definitions/classes.yaml | 8 +- gen/definitions/properties.yaml | 26 ----- gen/testvars/fvRsCons.yaml | 4 - gen/testvars/fvRsConsIf.yaml | 4 - gen/testvars/fvRsIntraEpg.yaml | 4 - gen/testvars/fvRsProv.yaml | 4 - gen/testvars/fvRsSecInherited.yaml | 6 - gen/testvars/infraHPathS.yaml | 12 +- ...data_source_aci_host_path_selector_test.go | 9 +- ..._aci_relation_to_consumed_contract_test.go | 36 ------ ...ce_aci_relation_to_contract_master_test.go | 21 ---- ..._aci_relation_to_imported_contract_test.go | 36 ------ ...aci_relation_to_intra_epg_contract_test.go | 35 ------ ..._aci_relation_to_provided_contract_test.go | 37 ------ .../resource_aci_host_path_selector.go | 60 +++++++++- .../resource_aci_host_path_selector_test.go | 106 ++++++++---------- 39 files changed, 132 insertions(+), 544 deletions(-) diff --git a/docs/data-sources/relation_to_consumed_contract.md b/docs/data-sources/relation_to_consumed_contract.md index dbcbc54d0..5a654e16c 100644 --- a/docs/data-sources/relation_to_consumed_contract.md +++ b/docs/data-sources/relation_to_consumed_contract.md @@ -39,11 +39,6 @@ Data source for ACI Relation To Consumed Contract ```hcl -data "aci_relation_to_consumed_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - data "aci_relation_to_consumed_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/docs/data-sources/relation_to_imported_contract.md b/docs/data-sources/relation_to_imported_contract.md index b625ba581..78ea561a5 100644 --- a/docs/data-sources/relation_to_imported_contract.md +++ b/docs/data-sources/relation_to_imported_contract.md @@ -39,11 +39,6 @@ Data source for ACI Relation To Imported Contract ```hcl -data "aci_relation_to_imported_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - imported_contract_name = aci_imported_contract.example.name -} - data "aci_relation_to_imported_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id imported_contract_name = aci_imported_contract.example.name diff --git a/docs/data-sources/relation_to_intra_epg_contract.md b/docs/data-sources/relation_to_intra_epg_contract.md index 7d25e4511..5fa95b6da 100644 --- a/docs/data-sources/relation_to_intra_epg_contract.md +++ b/docs/data-sources/relation_to_intra_epg_contract.md @@ -37,11 +37,6 @@ Data source for ACI Relation To Intra EPG Contract ```hcl -data "aci_relation_to_intra_epg_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - data "aci_relation_to_intra_epg_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/docs/data-sources/relation_to_provided_contract.md b/docs/data-sources/relation_to_provided_contract.md index 9e385f3dc..c008e5a55 100644 --- a/docs/data-sources/relation_to_provided_contract.md +++ b/docs/data-sources/relation_to_provided_contract.md @@ -39,11 +39,6 @@ Data source for ACI Relation To Provided Contract ```hcl -data "aci_relation_to_provided_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - data "aci_relation_to_provided_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/docs/resources/host_path_selector.md b/docs/resources/host_path_selector.md index a60cf5192..4c3550a5e 100644 --- a/docs/resources/host_path_selector.md +++ b/docs/resources/host_path_selector.md @@ -47,11 +47,11 @@ The configuration snippet below shows all possible attributes of the Host Path S resource "aci_host_path_selector" "full_example" { annotation = "annotation" - description = "description" + description = "description_1" name = "host_path_selector" - name_alias = "name_alias" - owner_key = "owner_key" - owner_tag = "owner_tag" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" annotations = [ { key = "key_0" diff --git a/docs/resources/relation_to_consumed_contract.md b/docs/resources/relation_to_consumed_contract.md index cf07494bf..a647a7f6c 100644 --- a/docs/resources/relation_to_consumed_contract.md +++ b/docs/resources/relation_to_consumed_contract.md @@ -43,11 +43,6 @@ The configuration snippet below creates a Relation To Consumed Contract with onl ```hcl -resource "aci_relation_to_consumed_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - resource "aci_relation_to_consumed_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name @@ -60,25 +55,6 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl -resource "aci_relation_to_consumed_contract" "full_example_application_epg" { - parent_dn = aci_application_epg.example.id - annotation = "annotation" - priority = "level1" - contract_name = aci_contract.example.name - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - resource "aci_relation_to_consumed_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" @@ -162,7 +138,7 @@ All examples for the Relation To Consumed Contract resource can be found in the An existing Relation To Consumed Contract 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_relation_to_consumed_contract.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rscons-{tnVzBrCPName} +terraform import aci_relation_to_consumed_contract.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rscons-{tnVzBrCPName} ``` Starting in Terraform version 1.5, an existing Relation To Consumed Contract can be imported @@ -171,6 +147,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rscons-{tnVzBrCPName}" - to = aci_relation_to_consumed_contract.example_application_epg + to = aci_relation_to_consumed_contract.example_endpoint_security_group } ``` diff --git a/docs/resources/relation_to_contract_master.md b/docs/resources/relation_to_contract_master.md index 61c02cf34..f07784c60 100644 --- a/docs/resources/relation_to_contract_master.md +++ b/docs/resources/relation_to_contract_master.md @@ -157,7 +157,7 @@ All examples for the Relation To Contract Master resource can be found in the [e An existing Relation To Contract Master 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_relation_to_contract_master.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rssecInherited-[{tDn}] +terraform import aci_relation_to_contract_master.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rssecInherited-[{tDn}] ``` Starting in Terraform version 1.5, an existing Relation To Contract Master can be imported @@ -166,6 +166,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rssecInherited-[{tDn}]" - to = aci_relation_to_contract_master.example_application_epg + to = aci_relation_to_contract_master.example_endpoint_security_group } ``` diff --git a/docs/resources/relation_to_imported_contract.md b/docs/resources/relation_to_imported_contract.md index 5003b7b3b..e81d249aa 100644 --- a/docs/resources/relation_to_imported_contract.md +++ b/docs/resources/relation_to_imported_contract.md @@ -43,11 +43,6 @@ The configuration snippet below creates a Relation To Imported Contract with onl ```hcl -resource "aci_relation_to_imported_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - imported_contract_name = aci_imported_contract.example.name -} - resource "aci_relation_to_imported_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id imported_contract_name = aci_imported_contract.example.name @@ -60,25 +55,6 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl -resource "aci_relation_to_imported_contract" "full_example_application_epg" { - parent_dn = aci_application_epg.example.id - annotation = "annotation" - priority = "level1" - imported_contract_name = aci_imported_contract.example.name - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - resource "aci_relation_to_imported_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" @@ -162,7 +138,7 @@ All examples for the Relation To Imported Contract resource can be found in the An existing Relation To Imported Contract 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_relation_to_imported_contract.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rsconsIf-{tnVzCPIfName} +terraform import aci_relation_to_imported_contract.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rsconsIf-{tnVzCPIfName} ``` Starting in Terraform version 1.5, an existing Relation To Imported Contract can be imported @@ -171,6 +147,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rsconsIf-{tnVzCPIfName}" - to = aci_relation_to_imported_contract.example_application_epg + to = aci_relation_to_imported_contract.example_endpoint_security_group } ``` diff --git a/docs/resources/relation_to_intra_epg_contract.md b/docs/resources/relation_to_intra_epg_contract.md index bd2cef540..8fe70ab71 100644 --- a/docs/resources/relation_to_intra_epg_contract.md +++ b/docs/resources/relation_to_intra_epg_contract.md @@ -41,11 +41,6 @@ The configuration snippet below creates a Relation To Intra EPG Contract with on ```hcl -resource "aci_relation_to_intra_epg_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - resource "aci_relation_to_intra_epg_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name @@ -58,24 +53,6 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl -resource "aci_relation_to_intra_epg_contract" "full_example_application_epg" { - parent_dn = aci_application_epg.example.id - annotation = "annotation" - contract_name = aci_contract.example.name - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - resource "aci_relation_to_intra_epg_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" @@ -155,7 +132,7 @@ All examples for the Relation To Intra EPG Contract resource can be found in the An existing Relation To Intra EPG Contract 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_relation_to_intra_epg_contract.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rsintraEpg-{tnVzBrCPName} +terraform import aci_relation_to_intra_epg_contract.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rsintraEpg-{tnVzBrCPName} ``` Starting in Terraform version 1.5, an existing Relation To Intra EPG Contract can be imported @@ -164,6 +141,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rsintraEpg-{tnVzBrCPName}" - to = aci_relation_to_intra_epg_contract.example_application_epg + to = aci_relation_to_intra_epg_contract.example_endpoint_security_group } ``` diff --git a/docs/resources/relation_to_provided_contract.md b/docs/resources/relation_to_provided_contract.md index de5b27199..a1d07f041 100644 --- a/docs/resources/relation_to_provided_contract.md +++ b/docs/resources/relation_to_provided_contract.md @@ -43,11 +43,6 @@ The configuration snippet below creates a Relation To Provided Contract with onl ```hcl -resource "aci_relation_to_provided_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - resource "aci_relation_to_provided_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name @@ -60,26 +55,6 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl -resource "aci_relation_to_provided_contract" "full_example_application_epg" { - parent_dn = aci_application_epg.example.id - annotation = "annotation" - match_criteria = "All" - priority = "level1" - contract_name = aci_contract.example.name - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - resource "aci_relation_to_provided_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" @@ -167,7 +142,7 @@ All examples for the Relation To Provided Contract resource can be found in the An existing Relation To Provided Contract 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_relation_to_provided_contract.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rsprov-{tnVzBrCPName} +terraform import aci_relation_to_provided_contract.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rsprov-{tnVzBrCPName} ``` Starting in Terraform version 1.5, an existing Relation To Provided Contract can be imported @@ -176,6 +151,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rsprov-{tnVzBrCPName}" - to = aci_relation_to_provided_contract.example_application_epg + to = aci_relation_to_provided_contract.example_endpoint_security_group } ``` diff --git a/examples/data-sources/aci_relation_to_consumed_contract/data-source.tf b/examples/data-sources/aci_relation_to_consumed_contract/data-source.tf index fa20f256d..17035cdc8 100644 --- a/examples/data-sources/aci_relation_to_consumed_contract/data-source.tf +++ b/examples/data-sources/aci_relation_to_consumed_contract/data-source.tf @@ -1,9 +1,4 @@ -data "aci_relation_to_consumed_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - data "aci_relation_to_consumed_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/data-sources/aci_relation_to_imported_contract/data-source.tf b/examples/data-sources/aci_relation_to_imported_contract/data-source.tf index 79a46318b..e14328780 100644 --- a/examples/data-sources/aci_relation_to_imported_contract/data-source.tf +++ b/examples/data-sources/aci_relation_to_imported_contract/data-source.tf @@ -1,9 +1,4 @@ -data "aci_relation_to_imported_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - imported_contract_name = aci_imported_contract.example.name -} - data "aci_relation_to_imported_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id imported_contract_name = aci_imported_contract.example.name diff --git a/examples/data-sources/aci_relation_to_intra_epg_contract/data-source.tf b/examples/data-sources/aci_relation_to_intra_epg_contract/data-source.tf index 5f68b8bb6..f376bcdb7 100644 --- a/examples/data-sources/aci_relation_to_intra_epg_contract/data-source.tf +++ b/examples/data-sources/aci_relation_to_intra_epg_contract/data-source.tf @@ -1,9 +1,4 @@ -data "aci_relation_to_intra_epg_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - data "aci_relation_to_intra_epg_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/data-sources/aci_relation_to_provided_contract/data-source.tf b/examples/data-sources/aci_relation_to_provided_contract/data-source.tf index 3d1435998..10285f243 100644 --- a/examples/data-sources/aci_relation_to_provided_contract/data-source.tf +++ b/examples/data-sources/aci_relation_to_provided_contract/data-source.tf @@ -1,9 +1,4 @@ -data "aci_relation_to_provided_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - data "aci_relation_to_provided_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/resources/aci_host_path_selector/resource-all-attributes.tf b/examples/resources/aci_host_path_selector/resource-all-attributes.tf index 0f6159d53..885de1fcd 100644 --- a/examples/resources/aci_host_path_selector/resource-all-attributes.tf +++ b/examples/resources/aci_host_path_selector/resource-all-attributes.tf @@ -1,11 +1,11 @@ resource "aci_host_path_selector" "full_example" { annotation = "annotation" - description = "description" + description = "description_1" name = "host_path_selector" - name_alias = "name_alias" - owner_key = "owner_key" - owner_tag = "owner_tag" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" annotations = [ { key = "key_0" diff --git a/examples/resources/aci_relation_to_consumed_contract/resource-all-attributes.tf b/examples/resources/aci_relation_to_consumed_contract/resource-all-attributes.tf index 31e99c329..417565166 100644 --- a/examples/resources/aci_relation_to_consumed_contract/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_consumed_contract/resource-all-attributes.tf @@ -1,23 +1,4 @@ -resource "aci_relation_to_consumed_contract" "full_example_application_epg" { - parent_dn = aci_application_epg.example.id - annotation = "annotation" - priority = "level1" - contract_name = aci_contract.example.name - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - resource "aci_relation_to_consumed_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" diff --git a/examples/resources/aci_relation_to_consumed_contract/resource.tf b/examples/resources/aci_relation_to_consumed_contract/resource.tf index 8bc891d2f..5f12d8de7 100644 --- a/examples/resources/aci_relation_to_consumed_contract/resource.tf +++ b/examples/resources/aci_relation_to_consumed_contract/resource.tf @@ -1,9 +1,4 @@ -resource "aci_relation_to_consumed_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - resource "aci_relation_to_consumed_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/resources/aci_relation_to_imported_contract/resource-all-attributes.tf b/examples/resources/aci_relation_to_imported_contract/resource-all-attributes.tf index e18cafd6c..b0940f894 100644 --- a/examples/resources/aci_relation_to_imported_contract/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_imported_contract/resource-all-attributes.tf @@ -1,23 +1,4 @@ -resource "aci_relation_to_imported_contract" "full_example_application_epg" { - parent_dn = aci_application_epg.example.id - annotation = "annotation" - priority = "level1" - imported_contract_name = aci_imported_contract.example.name - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - resource "aci_relation_to_imported_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" diff --git a/examples/resources/aci_relation_to_imported_contract/resource.tf b/examples/resources/aci_relation_to_imported_contract/resource.tf index c8ff249c4..018bd948f 100644 --- a/examples/resources/aci_relation_to_imported_contract/resource.tf +++ b/examples/resources/aci_relation_to_imported_contract/resource.tf @@ -1,9 +1,4 @@ -resource "aci_relation_to_imported_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - imported_contract_name = aci_imported_contract.example.name -} - resource "aci_relation_to_imported_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id imported_contract_name = aci_imported_contract.example.name diff --git a/examples/resources/aci_relation_to_intra_epg_contract/resource-all-attributes.tf b/examples/resources/aci_relation_to_intra_epg_contract/resource-all-attributes.tf index bc6161c18..f9e32ba29 100644 --- a/examples/resources/aci_relation_to_intra_epg_contract/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_intra_epg_contract/resource-all-attributes.tf @@ -1,22 +1,4 @@ -resource "aci_relation_to_intra_epg_contract" "full_example_application_epg" { - parent_dn = aci_application_epg.example.id - annotation = "annotation" - contract_name = aci_contract.example.name - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - resource "aci_relation_to_intra_epg_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" diff --git a/examples/resources/aci_relation_to_intra_epg_contract/resource.tf b/examples/resources/aci_relation_to_intra_epg_contract/resource.tf index cef4e5b71..e9f7a1e1c 100644 --- a/examples/resources/aci_relation_to_intra_epg_contract/resource.tf +++ b/examples/resources/aci_relation_to_intra_epg_contract/resource.tf @@ -1,9 +1,4 @@ -resource "aci_relation_to_intra_epg_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - resource "aci_relation_to_intra_epg_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/resources/aci_relation_to_provided_contract/resource-all-attributes.tf b/examples/resources/aci_relation_to_provided_contract/resource-all-attributes.tf index bed3f2f79..1a7273859 100644 --- a/examples/resources/aci_relation_to_provided_contract/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_provided_contract/resource-all-attributes.tf @@ -1,24 +1,4 @@ -resource "aci_relation_to_provided_contract" "full_example_application_epg" { - parent_dn = aci_application_epg.example.id - annotation = "annotation" - match_criteria = "All" - priority = "level1" - contract_name = aci_contract.example.name - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - resource "aci_relation_to_provided_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" diff --git a/examples/resources/aci_relation_to_provided_contract/resource.tf b/examples/resources/aci_relation_to_provided_contract/resource.tf index d4fba1dba..e23fb09ae 100644 --- a/examples/resources/aci_relation_to_provided_contract/resource.tf +++ b/examples/resources/aci_relation_to_provided_contract/resource.tf @@ -1,9 +1,4 @@ -resource "aci_relation_to_provided_contract" "example_application_epg" { - parent_dn = aci_application_epg.example.id - contract_name = aci_contract.example.name -} - resource "aci_relation_to_provided_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index a7e4deaa3..efaa4900e 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -406,7 +406,6 @@ fvRsScope: fvRsCons: resource_name: "relation_to_consumed_contract" example_classes: - - "fvAEPg" - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rscons-{tnVzBrCPName}" @@ -424,7 +423,6 @@ fvRsCons: fvRsProv: resource_name: "relation_to_provided_contract" example_classes: - - "fvAEPg" - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rsprov-{tnVzBrCPName}" @@ -442,7 +440,6 @@ fvRsProv: fvRsConsIf: resource_name: "relation_to_imported_contract" example_classes: - - "fvAEPg" - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rsconsIf-{tnVzCPIfName}" @@ -475,8 +472,7 @@ fvRsProtBy: fvRsIntraEpg: resource_name: "relation_to_intra_epg_contract" example_classes: - - "fvAEPg" - - "fvESg" + - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rsintraEpg-{tnVzBrCPName}" - "uni/tn-{name}/ap-{name}/esg-{name}/rsintraEpg-{tnVzBrCPName}" @@ -491,10 +487,8 @@ fvRsIntraEpg: fvRsSecInherited: resource_name: "relation_to_contract_master" example_classes: - - "fvAEPg" - "fvESg" relationship_classes: - - "fvAEPg" - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rssecInherited-[{tDn}]" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index a25f93f01..6f00fea19 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -405,8 +405,6 @@ fvRsCons: parents: - class_name: "fvESg" parent_dependency: "fvAp" - - class_name: "fvAEPg" - parent_dependency: "fvAp" fvRsProv: ignores: @@ -414,15 +412,11 @@ fvRsProv: parents: - class_name: "fvESg" parent_dependency: "fvAp" - - class_name: "fvAEPg" - parent_dependency: "fvAp" fvRsConsIf: parents: - class_name: "fvESg" parent_dependency: "fvAp" - - class_name: "fvAEPg" - parent_dependency: "fvAp" fvRsProtBy: parents: @@ -439,15 +433,9 @@ fvRsIntraEpg: parents: - class_name: "fvESg" parent_dependency: "fvAp" - - class_name: "fvAEPg" - parent_dependency: "fvAp" fvRsSecInherited: parents: - - class_name: "fvAEPg" - parent_dependency: "fvAp" - target_classes: - - "fvAEPg" - class_name: "fvESg" parent_dependency: "fvAp" target_classes: @@ -467,20 +455,6 @@ fvRsSecInherited: relation_resource_name: "contract_master" properties: name: "esg_1" - - class_name: "fvAEPg" - parent_dependency: "fvAp" - overwrite_parent_dn_key: "application_profile_dn" - target_dn: "uni/tn-test_tenant/ap-test_ap/epg-epg_2" - relation_resource_name: "contract_master" - properties: - name: "epg_2" - - class_name: "fvAEPg" - parent_dependency: "fvAp" - overwrite_parent_dn_key: "application_profile_dn" - target_dn: "uni/tn-test_tenant/ap-test_ap/epg-epg_3" - relation_resource_name: "contract_master" - properties: - name: "epg_3" fvCrtrn: overwrites: diff --git a/gen/testvars/fvRsCons.yaml b/gen/testvars/fvRsCons.yaml index a96cb3cb9..889ac3560 100644 --- a/gen/testvars/fvRsCons.yaml +++ b/gen/testvars/fvRsCons.yaml @@ -35,10 +35,6 @@ children: value: "test_value" parents: - - class_name: "fvAEPg" - parent_dependency: "fvAp" - parent_dn: "aci_application_epg.test.id" - class_in_parent: false - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/fvRsConsIf.yaml b/gen/testvars/fvRsConsIf.yaml index ea9e6798d..6f6604474 100644 --- a/gen/testvars/fvRsConsIf.yaml +++ b/gen/testvars/fvRsConsIf.yaml @@ -35,10 +35,6 @@ children: value: "test_value" parents: - - class_name: "fvAEPg" - parent_dependency: "fvAp" - parent_dn: "aci_application_epg.test.id" - class_in_parent: false - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/fvRsIntraEpg.yaml b/gen/testvars/fvRsIntraEpg.yaml index 50e6d6792..092839858 100644 --- a/gen/testvars/fvRsIntraEpg.yaml +++ b/gen/testvars/fvRsIntraEpg.yaml @@ -33,10 +33,6 @@ children: value: "test_value" parents: - - class_name: "fvAEPg" - parent_dependency: "fvAp" - parent_dn: "aci_application_epg.test.id" - class_in_parent: false - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/fvRsProv.yaml b/gen/testvars/fvRsProv.yaml index ca0aaba9c..7cc0eeb9d 100644 --- a/gen/testvars/fvRsProv.yaml +++ b/gen/testvars/fvRsProv.yaml @@ -37,10 +37,6 @@ children: value: "test_value" parents: - - class_name: "fvAEPg" - parent_dependency: "fvAp" - parent_dn: "aci_application_epg.test.id" - class_in_parent: false - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/fvRsSecInherited.yaml b/gen/testvars/fvRsSecInherited.yaml index 1da67d6d7..1bb8350d7 100644 --- a/gen/testvars/fvRsSecInherited.yaml +++ b/gen/testvars/fvRsSecInherited.yaml @@ -33,12 +33,6 @@ children: value: "test_value" parents: - - class_name: "fvAEPg" - parent_dependency: "fvAp" - parent_dn: "aci_application_epg.test.id" - class_in_parent: false - target_classes: - - "fvAEPg" - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/infraHPathS.yaml b/gen/testvars/infraHPathS.yaml index d440bed6a..33fbef238 100644 --- a/gen/testvars/infraHPathS.yaml +++ b/gen/testvars/infraHPathS.yaml @@ -20,10 +20,10 @@ resource_required: all: annotation: "annotation" - description: "description" - name_alias: "name_alias" - owner_key: "owner_key" - owner_tag: "owner_tag" + description: "description_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" children: annotations: @@ -31,13 +31,13 @@ children: value: "value_1" - key: "key_1" - value: "value_2" + value: "test_value" tags: - key: "key_0" value: "value_1" - key: "key_1" - value: "value_2" + value: "test_value" parents: diff --git a/internal/provider/data_source_aci_host_path_selector_test.go b/internal/provider/data_source_aci_host_path_selector_test.go index 58a62edf9..c641bdd36 100644 --- a/internal/provider/data_source_aci_host_path_selector_test.go +++ b/internal/provider/data_source_aci_host_path_selector_test.go @@ -21,10 +21,10 @@ func TestAccDataSourceInfraHPathS(t *testing.T) { Config: testConfigInfraHPathSDataSource, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "annotation", "annotation"), - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "description", "description"), - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "name_alias", "name_alias"), - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_key", "owner_key"), - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_tag", "owner_tag"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "description", "description_1"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_tag", "owner_tag_1"), ), }, { @@ -45,6 +45,5 @@ data "aci_host_path_selector" "test" { const testConfigInfraHPathSNotExisting = testConfigInfraHPathSAll + ` data "aci_host_path_selector" "test" { name = "host_path_selector_non_existing" - depends_on = [aci_host_path_selector.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_consumed_contract_test.go b/internal/provider/data_source_aci_relation_to_consumed_contract_test.go index 15cab183f..cddef022a 100644 --- a/internal/provider/data_source_aci_relation_to_consumed_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_consumed_contract_test.go @@ -11,28 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) -func TestAccDataSourceFvRsConsWithFvAEPg(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testConfigFvRsConsDataSourceDependencyWithFvAEPg, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.aci_relation_to_consumed_contract.test", "contract_name", "test_tn_vz_br_cp_name"), - resource.TestCheckResourceAttr("data.aci_relation_to_consumed_contract.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("data.aci_relation_to_consumed_contract.test", "priority", "unspecified"), - ), - }, - { - Config: testConfigFvRsConsNotExistingFvAEPg, - ExpectError: regexp.MustCompile("Failed to read aci_relation_to_consumed_contract data source"), - }, - }, - }) -} func TestAccDataSourceFvRsConsWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -56,20 +34,6 @@ func TestAccDataSourceFvRsConsWithFvESg(t *testing.T) { }) } -const testConfigFvRsConsDataSourceDependencyWithFvAEPg = testConfigFvRsConsMinDependencyWithFvAEPg + ` -data "aci_relation_to_consumed_contract" "test" { - parent_dn = aci_application_epg.test.id - contract_name = "test_tn_vz_br_cp_name" - depends_on = [aci_relation_to_consumed_contract.test] -} -` - -const testConfigFvRsConsNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` -data "aci_relation_to_consumed_contract" "test_non_existing" { - parent_dn = aci_application_epg.test.id - contract_name = "non_existing_tn_vz_br_cp_name" -} -` const testConfigFvRsConsDataSourceDependencyWithFvESg = testConfigFvRsConsMinDependencyWithFvESg + ` data "aci_relation_to_consumed_contract" "test" { parent_dn = aci_endpoint_security_group.test.id diff --git a/internal/provider/data_source_aci_relation_to_contract_master_test.go b/internal/provider/data_source_aci_relation_to_contract_master_test.go index af13936d4..951416b4b 100644 --- a/internal/provider/data_source_aci_relation_to_contract_master_test.go +++ b/internal/provider/data_source_aci_relation_to_contract_master_test.go @@ -11,27 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) -func TestAccDataSourceFvRsSecInheritedWithFvAEPg(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testConfigFvRsSecInheritedDataSourceDependencyWithFvAEPg, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.aci_relation_to_contract_master.test", "target_dn", "uni/tn-test_tenant/ap-test_ap/epg-epg_2"), - resource.TestCheckResourceAttr("data.aci_relation_to_contract_master.test", "annotation", "orchestrator:terraform"), - ), - }, - { - Config: testConfigFvRsSecInheritedNotExistingFvAEPg, - ExpectError: regexp.MustCompile("Failed to read aci_relation_to_contract_master data source"), - }, - }, - }) -} func TestAccDataSourceFvRsSecInheritedWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ diff --git a/internal/provider/data_source_aci_relation_to_imported_contract_test.go b/internal/provider/data_source_aci_relation_to_imported_contract_test.go index a63066e2c..ef04cabac 100644 --- a/internal/provider/data_source_aci_relation_to_imported_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_imported_contract_test.go @@ -11,28 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) -func TestAccDataSourceFvRsConsIfWithFvAEPg(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testConfigFvRsConsIfDataSourceDependencyWithFvAEPg, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.aci_relation_to_imported_contract.test", "imported_contract_name", "test_tn_vz_cp_if_name"), - resource.TestCheckResourceAttr("data.aci_relation_to_imported_contract.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("data.aci_relation_to_imported_contract.test", "priority", "unspecified"), - ), - }, - { - Config: testConfigFvRsConsIfNotExistingFvAEPg, - ExpectError: regexp.MustCompile("Failed to read aci_relation_to_imported_contract data source"), - }, - }, - }) -} func TestAccDataSourceFvRsConsIfWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -56,20 +34,6 @@ func TestAccDataSourceFvRsConsIfWithFvESg(t *testing.T) { }) } -const testConfigFvRsConsIfDataSourceDependencyWithFvAEPg = testConfigFvRsConsIfMinDependencyWithFvAEPg + ` -data "aci_relation_to_imported_contract" "test" { - parent_dn = aci_application_epg.test.id - imported_contract_name = "test_tn_vz_cp_if_name" - depends_on = [aci_relation_to_imported_contract.test] -} -` - -const testConfigFvRsConsIfNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` -data "aci_relation_to_imported_contract" "test_non_existing" { - parent_dn = aci_application_epg.test.id - imported_contract_name = "non_existing_tn_vz_cp_if_name" -} -` const testConfigFvRsConsIfDataSourceDependencyWithFvESg = testConfigFvRsConsIfMinDependencyWithFvESg + ` data "aci_relation_to_imported_contract" "test" { parent_dn = aci_endpoint_security_group.test.id diff --git a/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go b/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go index 617798ccd..72304f9a7 100644 --- a/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go @@ -11,27 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) -func TestAccDataSourceFvRsIntraEpgWithFvAEPg(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testConfigFvRsIntraEpgDataSourceDependencyWithFvAEPg, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.aci_relation_to_intra_epg_contract.test", "contract_name", "test_tn_vz_br_cp_name"), - resource.TestCheckResourceAttr("data.aci_relation_to_intra_epg_contract.test", "annotation", "orchestrator:terraform"), - ), - }, - { - Config: testConfigFvRsIntraEpgNotExistingFvAEPg, - ExpectError: regexp.MustCompile("Failed to read aci_relation_to_intra_epg_contract data source"), - }, - }, - }) -} func TestAccDataSourceFvRsIntraEpgWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -54,20 +33,6 @@ func TestAccDataSourceFvRsIntraEpgWithFvESg(t *testing.T) { }) } -const testConfigFvRsIntraEpgDataSourceDependencyWithFvAEPg = testConfigFvRsIntraEpgMinDependencyWithFvAEPg + ` -data "aci_relation_to_intra_epg_contract" "test" { - parent_dn = aci_application_epg.test.id - contract_name = "test_tn_vz_br_cp_name" - depends_on = [aci_relation_to_intra_epg_contract.test] -} -` - -const testConfigFvRsIntraEpgNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` -data "aci_relation_to_intra_epg_contract" "test_non_existing" { - parent_dn = aci_application_epg.test.id - contract_name = "non_existing_tn_vz_br_cp_name" -} -` const testConfigFvRsIntraEpgDataSourceDependencyWithFvESg = testConfigFvRsIntraEpgMinDependencyWithFvESg + ` data "aci_relation_to_intra_epg_contract" "test" { parent_dn = aci_endpoint_security_group.test.id diff --git a/internal/provider/data_source_aci_relation_to_provided_contract_test.go b/internal/provider/data_source_aci_relation_to_provided_contract_test.go index 0331bab61..696c358f5 100644 --- a/internal/provider/data_source_aci_relation_to_provided_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_provided_contract_test.go @@ -11,29 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) -func TestAccDataSourceFvRsProvWithFvAEPg(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testConfigFvRsProvDataSourceDependencyWithFvAEPg, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.aci_relation_to_provided_contract.test", "contract_name", "test_tn_vz_br_cp_name"), - resource.TestCheckResourceAttr("data.aci_relation_to_provided_contract.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("data.aci_relation_to_provided_contract.test", "match_criteria", "AtleastOne"), - resource.TestCheckResourceAttr("data.aci_relation_to_provided_contract.test", "priority", "unspecified"), - ), - }, - { - Config: testConfigFvRsProvNotExistingFvAEPg, - ExpectError: regexp.MustCompile("Failed to read aci_relation_to_provided_contract data source"), - }, - }, - }) -} func TestAccDataSourceFvRsProvWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -58,20 +35,6 @@ func TestAccDataSourceFvRsProvWithFvESg(t *testing.T) { }) } -const testConfigFvRsProvDataSourceDependencyWithFvAEPg = testConfigFvRsProvMinDependencyWithFvAEPg + ` -data "aci_relation_to_provided_contract" "test" { - parent_dn = aci_application_epg.test.id - contract_name = "test_tn_vz_br_cp_name" - depends_on = [aci_relation_to_provided_contract.test] -} -` - -const testConfigFvRsProvNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` -data "aci_relation_to_provided_contract" "test_non_existing" { - parent_dn = aci_application_epg.test.id - contract_name = "non_existing_tn_vz_br_cp_name" -} -` const testConfigFvRsProvDataSourceDependencyWithFvESg = testConfigFvRsProvMinDependencyWithFvESg + ` data "aci_relation_to_provided_contract" "test" { parent_dn = aci_endpoint_security_group.test.id diff --git a/internal/provider/resource_aci_host_path_selector.go b/internal/provider/resource_aci_host_path_selector.go index c118b61cb..2decf6388 100644 --- a/internal/provider/resource_aci_host_path_selector.go +++ b/internal/provider/resource_aci_host_path_selector.go @@ -13,6 +13,7 @@ import ( "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" + "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" @@ -53,18 +54,57 @@ type InfraHPathSResourceModel struct { TagTag types.Set `tfsdk:"tags"` } +func getEmptyInfraHPathSResourceModel() *InfraHPathSResourceModel { + return &InfraHPathSResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: 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, + }, + }), + } +} + // TagAnnotationInfraHPathSResourceModel describes the resource data model for the children without relation ships. type TagAnnotationInfraHPathSResourceModel struct { Key types.String `tfsdk:"key"` Value types.String `tfsdk:"value"` } +func getEmptyTagAnnotationInfraHPathSResourceModel() TagAnnotationInfraHPathSResourceModel { + return TagAnnotationInfraHPathSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + // TagTagInfraHPathSResourceModel describes the resource data model for the children without relation ships. type TagTagInfraHPathSResourceModel struct { Key types.String `tfsdk:"key"` Value types.String `tfsdk:"value"` } +func getEmptyTagTagInfraHPathSResourceModel() TagTagInfraHPathSResourceModel { + return TagTagInfraHPathSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + type InfraHPathSIdentifier struct { Name types.String } @@ -129,6 +169,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, Default: stringdefault.StaticString(globalAnnotation), MarkdownDescription: `The annotation of the Host Path Selector object.`, @@ -138,6 +179,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, MarkdownDescription: `The description of the Host Path Selector object.`, }, @@ -145,6 +187,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), stringplanmodifier.RequiresReplace(), }, MarkdownDescription: `The name of the Host Path Selector object.`, @@ -154,6 +197,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, MarkdownDescription: `The name alias of the Host Path Selector object.`, }, @@ -162,6 +206,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, }, @@ -170,6 +215,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq 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.`, }, @@ -411,6 +457,8 @@ func (r *InfraHPathSResource) ImportState(ctx context.Context, req resource.Impo func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraHPathSResourceModel) { requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "infraHPathS,tagAnnotation,tagTag"), "GET", nil) + *data = *getEmptyInfraHPathSResourceModel() + if diags.HasError() { return } @@ -451,7 +499,7 @@ func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics for childClassName, childClassDetails := range child.(map[string]interface{}) { childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) if childClassName == "tagAnnotation" { - TagAnnotationInfraHPathS := TagAnnotationInfraHPathSResourceModel{} + TagAnnotationInfraHPathS := getEmptyTagAnnotationInfraHPathSResourceModel() for childAttributeName, childAttributeValue := range childAttributes { if childAttributeName == "key" { TagAnnotationInfraHPathS.Key = basetypes.NewStringValue(childAttributeValue.(string)) @@ -463,7 +511,7 @@ func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics TagAnnotationInfraHPathSList = append(TagAnnotationInfraHPathSList, TagAnnotationInfraHPathS) } if childClassName == "tagTag" { - TagTagInfraHPathS := TagTagInfraHPathSResourceModel{} + TagTagInfraHPathS := getEmptyTagTagInfraHPathSResourceModel() for childAttributeName, childAttributeValue := range childAttributes { if childAttributeName == "key" { TagTagInfraHPathS.Key = basetypes.NewStringValue(childAttributeValue.(string)) @@ -530,10 +578,10 @@ func getInfraHPathSTagAnnotationChildPayloads(ctx context.Context, diags *diag.D tagAnnotationIdentifiers := []TagAnnotationIdentifier{} for _, tagAnnotation := range tagAnnotationPlan { childMap := map[string]map[string]interface{}{"attributes": {}} - if !tagAnnotation.Key.IsUnknown() { + if !tagAnnotation.Key.IsUnknown() && !tagAnnotation.Key.IsNull() { childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() } - if !tagAnnotation.Value.IsUnknown() { + if !tagAnnotation.Value.IsUnknown() && !tagAnnotation.Value.IsNull() { childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() } childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) @@ -569,10 +617,10 @@ func getInfraHPathSTagTagChildPayloads(ctx context.Context, diags *diag.Diagnost tagTagIdentifiers := []TagTagIdentifier{} for _, tagTag := range tagTagPlan { childMap := map[string]map[string]interface{}{"attributes": {}} - if !tagTag.Key.IsUnknown() { + if !tagTag.Key.IsUnknown() && !tagTag.Key.IsNull() { childMap["attributes"]["key"] = tagTag.Key.ValueString() } - if !tagTag.Value.IsUnknown() { + if !tagTag.Value.IsUnknown() && !tagTag.Value.IsNull() { childMap["attributes"]["value"] = tagTag.Value.ValueString() } childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) diff --git a/internal/provider/resource_aci_host_path_selector_test.go b/internal/provider/resource_aci_host_path_selector_test.go index a087d2ac5..3563e8757 100644 --- a/internal/provider/resource_aci_host_path_selector_test.go +++ b/internal/provider/resource_aci_host_path_selector_test.go @@ -21,18 +21,18 @@ func TestAccResourceInfraHPathS(t *testing.T) { { Config: testConfigInfraHPathSMinAllowExisting, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "owner_tag", ""), ), }, }, @@ -60,18 +60,18 @@ func TestAccResourceInfraHPathS(t *testing.T) { { Config: testConfigInfraHPathSMinAllowExisting, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "owner_tag", ""), ), }, }, @@ -99,10 +99,10 @@ func TestAccResourceInfraHPathS(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "annotation"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag_1"), ), }, // Update with minimum config and verify config is unchanged @@ -111,10 +111,10 @@ func TestAccResourceInfraHPathS(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag_1"), ), }, // Update with empty strings config or default value @@ -134,14 +134,6 @@ func TestAccResourceInfraHPathS(t *testing.T) { ResourceName: "aci_host_path_selector.test", ImportState: true, ImportStateVerify: true, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - ), }, // Update with children { @@ -155,12 +147,12 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "2"), ), }, @@ -176,12 +168,12 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "2"), ), }, @@ -195,10 +187,10 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "1"), ), }, @@ -220,12 +212,12 @@ func TestAccResourceInfraHPathS(t *testing.T) { } const testConfigInfraHPathSMinAllowExisting = ` -resource "aci_host_path_selector" "test" { +resource "aci_host_path_selector" "allow_test" { name = "host_path_selector" } -resource "aci_host_path_selector" "test_2" { +resource "aci_host_path_selector" "allow_test_2" { name = "host_path_selector" - depends_on = [aci_host_path_selector.test] + depends_on = [aci_host_path_selector.allow_test] } ` @@ -239,10 +231,10 @@ const testConfigInfraHPathSAll = ` resource "aci_host_path_selector" "test" { name = "host_path_selector" annotation = "annotation" - description = "description" - name_alias = "name_alias" - owner_key = "owner_key" - owner_tag = "owner_tag" + description = "description_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" } ` @@ -266,7 +258,7 @@ resource "aci_host_path_selector" "test" { }, { key = "key_1" - value = "value_2" + value = "test_value" }, ] tags = [ @@ -276,7 +268,7 @@ resource "aci_host_path_selector" "test" { }, { key = "key_1" - value = "value_2" + value = "test_value" }, ] } @@ -294,13 +286,13 @@ resource "aci_host_path_selector" "test" { annotations = [ { key = "key_1" - value = "value_2" + value = "test_value" }, ] tags = [ { key = "key_1" - value = "value_2" + value = "test_value" }, ] } From d0c9425708a266be7b9855b0b1d00e726100992d Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Wed, 31 Jul 2024 13:56:04 -0400 Subject: [PATCH 05/11] [minor_change] Add resource and data source for relation_to_host_path (infraRsHPathAtt). Provide attribute to add access base group to host path selector. --- docs/data-sources/host_path_selector.md | 8 + docs/data-sources/relation_to_host_path.md | 59 ++ docs/resources/host_path_selector.md | 33 + docs/resources/relation_to_host_path.md | 118 +++ .../aci_relation_to_host_path/data-source.tf | 5 + .../aci_relation_to_host_path/provider.tf | 14 + .../resource-all-attributes.tf | 12 + .../aci_relation_to_host_path/provider.tf | 14 + .../resource-all-attributes.tf | 18 + .../aci_relation_to_host_path/resource.tf | 5 + gen/definitions/classes.yaml | 6 + gen/definitions/properties.yaml | 27 + gen/meta/infraRsHPathAtt.json | 881 ++++++++++++++++ gen/meta/infraRsPathToAccBaseGrp.json | 966 ++++++++++++++++++ gen/testvars/infraHPathS.yaml | 24 + gen/testvars/infraRsHPathAtt.yaml | 62 ++ .../data_source_aci_host_path_selector.go | 32 + .../data_source_aci_relation_to_host_path.go | 149 +++ ...a_source_aci_relation_to_host_path_test.go | 49 + internal/provider/provider.go | 2 + .../resource_aci_host_path_selector.go | 250 ++++- .../resource_aci_host_path_selector_test.go | 58 +- .../resource_aci_relation_to_host_path.go | 643 ++++++++++++ ...resource_aci_relation_to_host_path_test.go | 290 ++++++ 24 files changed, 3707 insertions(+), 18 deletions(-) create mode 100644 docs/data-sources/relation_to_host_path.md create mode 100644 docs/resources/relation_to_host_path.md create mode 100644 examples/data-sources/aci_relation_to_host_path/data-source.tf create mode 100644 examples/data-sources/aci_relation_to_host_path/provider.tf create mode 100644 examples/resources/aci_relation_to_host_path/provider.tf create mode 100644 examples/resources/aci_relation_to_host_path/resource-all-attributes.tf create mode 100644 examples/resources/aci_relation_to_host_path/resource.tf create mode 100644 gen/meta/infraRsHPathAtt.json create mode 100644 gen/meta/infraRsPathToAccBaseGrp.json create mode 100644 gen/testvars/infraRsHPathAtt.yaml create mode 100644 internal/provider/data_source_aci_relation_to_host_path.go create mode 100644 internal/provider/data_source_aci_relation_to_host_path_test.go create mode 100644 internal/provider/resource_aci_relation_to_host_path.go create mode 100644 internal/provider/resource_aci_relation_to_host_path_test.go diff --git a/docs/data-sources/host_path_selector.md b/docs/data-sources/host_path_selector.md index f8bdd1216..14244cd96 100644 --- a/docs/data-sources/host_path_selector.md +++ b/docs/data-sources/host_path_selector.md @@ -57,6 +57,14 @@ data "aci_host_path_selector" "example" { * `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. +* `relation_to_host_paths` - (list) A list of Relation To Host Paths (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)). + * `annotation` (annotation) - (string) The annotation of the Relation To Host Path object. + * `target_dn` (tDn) - (string) The distinguished name of the target. + +* `relation_to_access_base_group` - (list) A list of Relation To Access Base Group (ACI object [infraRsPathToAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsPathToAccBaseGrp/overview)) pointing to (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)). + * `annotation` (annotation) - (string) The annotation of the Relation To Access Base Group object. + * `target_dn` (tDn) - (string) The distinguished name of the target. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/relation_to_host_path.md b/docs/data-sources/relation_to_host_path.md new file mode 100644 index 000000000..ce0c311f6 --- /dev/null +++ b/docs/data-sources/relation_to_host_path.md @@ -0,0 +1,59 @@ +--- +# 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: "Generic" +layout: "aci" +page_title: "ACI: aci_relation_to_host_path" +sidebar_current: "docs-aci-data-source-aci_relation_to_host_path" +description: |- + Data source for Relation To Host Path +--- + +# aci_relation_to_host_path # + +Data source for Relation To Host Path + +## API Information ## + +* Class: [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview) + +* Supported in ACI versions: 1.1(1j) and later. + +* Distinguished Name Format: `uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}]` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## + +```hcl + +data "aci_relation_to_host_path" "example_host_path_selector" { + parent_dn = aci_host_path_selector.example.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_host_path_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/host_path_selector) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) +* `target_dn` (tDn) - (string) The distinguished name of the target. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation To Host Path object. +* `annotation` (annotation) - (string) The annotation of the Relation To Host Path 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. diff --git a/docs/resources/host_path_selector.md b/docs/resources/host_path_selector.md index 4c3550a5e..f9c7680b8 100644 --- a/docs/resources/host_path_selector.md +++ b/docs/resources/host_path_selector.md @@ -52,6 +52,18 @@ resource "aci_host_path_selector" "full_example" { name_alias = "name_alias_1" owner_key = "owner_key_1" owner_tag = "owner_tag_1" + relation_to_host_paths = [ + { + annotation = "annotation_1" + target_dn = "target_dn_0" + } + ] + relation_to_access_base_group = [ + { + annotation = "annotation_1" + target_dn = "target_dn_1" + } + ] annotations = [ { key = "key_0" @@ -94,6 +106,27 @@ All examples for the Host Path Selector resource can be found in the [examples]( * `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. +* `relation_to_host_paths` - (list) A list of Relation To Host Paths (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)) which can be configured using the [aci_](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/) resource. + + #### Required #### + + * `target_dn` (tDn) - (string) The distinguished name of the target. + + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation To Host Path object. + - Default: `orchestrator:terraform` + +* `relation_to_access_base_group` - (list) A list of Relation To Access Base Group (ACI object [infraRsPathToAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsPathToAccBaseGrp/overview)) pointing to (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)) which can be configured using the [aci_](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/) resource. + - Max Items: 1 + + + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation To Access Base Group object. + - Default: `orchestrator:terraform` + * `target_dn` (tDn) - (string) The distinguished name of the target. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. #### Required #### diff --git a/docs/resources/relation_to_host_path.md b/docs/resources/relation_to_host_path.md new file mode 100644 index 000000000..cde19e044 --- /dev/null +++ b/docs/resources/relation_to_host_path.md @@ -0,0 +1,118 @@ +--- +# 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: "Generic" +layout: "aci" +page_title: "ACI: aci_relation_to_host_path" +sidebar_current: "docs-aci-resource-aci_relation_to_host_path" +description: |- + Manages ACI Relation To Host Path +--- + +# aci_relation_to_host_path # + +Manages ACI Relation To Host Path + + + +## API Information ## + +* Class: [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview) + +* Supported in ACI versions: 1.1(1j) and later. + +* Distinguished Name Format: `uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}]` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## + +The configuration snippet below creates a Relation To Host Path with only required attributes. + +```hcl + +resource "aci_relation_to_host_path" "example_host_path_selector" { + parent_dn = aci_host_path_selector.example.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" +} + +``` +The configuration snippet below shows all possible attributes of the Relation To Host Path. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_relation_to_host_path" "full_example_host_path_selector" { + parent_dn = aci_host_path_selector.example.id + annotation = "annotation" + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Relation To Host Path resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_relation_to_host_path) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_host_path_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/host_path_selector) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) +* `target_dn` (tDn) - (string) The distinguished name of the target. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation To Host Path object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Relation To Host Path object. + - Default: `orchestrator:terraform` + +* `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 Relation To Host Path 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_relation_to_host_path.example_host_path_selector uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}] +``` + +Starting in Terraform version 1.5, an existing Relation To Host Path can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}]" + to = aci_relation_to_host_path.example_host_path_selector +} +``` diff --git a/examples/data-sources/aci_relation_to_host_path/data-source.tf b/examples/data-sources/aci_relation_to_host_path/data-source.tf new file mode 100644 index 000000000..7fa16175b --- /dev/null +++ b/examples/data-sources/aci_relation_to_host_path/data-source.tf @@ -0,0 +1,5 @@ + +data "aci_relation_to_host_path" "example_host_path_selector" { + parent_dn = aci_host_path_selector.example.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" +} diff --git a/examples/data-sources/aci_relation_to_host_path/provider.tf b/examples/data-sources/aci_relation_to_host_path/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_relation_to_host_path/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_host_path_selector/resource-all-attributes.tf b/examples/resources/aci_host_path_selector/resource-all-attributes.tf index 885de1fcd..99ce7956c 100644 --- a/examples/resources/aci_host_path_selector/resource-all-attributes.tf +++ b/examples/resources/aci_host_path_selector/resource-all-attributes.tf @@ -6,6 +6,18 @@ resource "aci_host_path_selector" "full_example" { name_alias = "name_alias_1" owner_key = "owner_key_1" owner_tag = "owner_tag_1" + relation_to_host_paths = [ + { + annotation = "annotation_1" + target_dn = "target_dn_0" + } + ] + relation_to_access_base_group = [ + { + annotation = "annotation_1" + target_dn = "target_dn_1" + } + ] annotations = [ { key = "key_0" diff --git a/examples/resources/aci_relation_to_host_path/provider.tf b/examples/resources/aci_relation_to_host_path/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_relation_to_host_path/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_relation_to_host_path/resource-all-attributes.tf b/examples/resources/aci_relation_to_host_path/resource-all-attributes.tf new file mode 100644 index 000000000..940071be3 --- /dev/null +++ b/examples/resources/aci_relation_to_host_path/resource-all-attributes.tf @@ -0,0 +1,18 @@ + +resource "aci_relation_to_host_path" "full_example_host_path_selector" { + parent_dn = aci_host_path_selector.example.id + annotation = "annotation" + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_relation_to_host_path/resource.tf b/examples/resources/aci_relation_to_host_path/resource.tf new file mode 100644 index 000000000..b8ce3c49c --- /dev/null +++ b/examples/resources/aci_relation_to_host_path/resource.tf @@ -0,0 +1,5 @@ + +resource "aci_relation_to_host_path" "example_host_path_selector" { + parent_dn = aci_host_path_selector.example.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index efaa4900e..57cc4e085 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -567,3 +567,9 @@ physDomP: infraHPathS: resource_name: "host_path_selector" + +infraRsHPathAtt: + resource_name: "relation_to_host_path" + +infraRsPathToAccBaseGrp: + resource_name: "relation_to_access_base_group" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 6f00fea19..965ef9d9c 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -919,3 +919,30 @@ infraHPathS: - class_name: "infraInfra" parent_dependency: "" parent_dn: "uni/infra" + +infraRsHPathAtt: + parents: + - class_name: "infraHPathS" + target_classes: + - "fabricPathEp" + targets: + - class_name: "fabricPathEp" + target_dn: "topology/pod-1/paths-101/pathep-[eth1/1]" + relation_resource_name: "host_path" + static: true + - class_name: "fabricPathEp" + target_dn: "topology/pod-1/paths-101/pathep-[eth1/2]" + relation_resource_name: "host_path" + static: true + +infraRsPathToAccBaseGrp: + parents: + - class_name: "infraHPathS" + target_classes: + - "infraAccPortGrp" + targets: + - class_name: "infraAccPortGrp" + target_dn: "uni/infra/funcprof/accportgrp-interface_policy_group" + relation_resource_name: "access_base_group" + static: true + diff --git a/gen/meta/infraRsHPathAtt.json b/gen/meta/infraRsHPathAtt.json new file mode 100644 index 000000000..677f64484 --- /dev/null +++ b/gen/meta/infraRsHPathAtt.json @@ -0,0 +1,881 @@ +{ + "infra:RsHPathAtt": { + "contains": { + "aaa:RbacAnnotation": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "rbacDom-": "aaa:RbacAnnotation", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "tDn" + ], + "rnFormat": "rsHPathAtt-[{tDn}]", + "containedBy": { + "infra:HPathS": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "1-to-m", + "fromMo": "infra:HPathS", + "fromRelMo": "infra:RsHPathAtt", + "toMo": "fabric:PathEp", + "toRelMo": "fabric:RtHPathAtt", + "enforceable": false, + "resolvable": false + }, + "dnFormats": [ + "uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}]" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "faults": { + + }, + "events": { + "E4212296": "creation||infra:RsHPathAtt", + "E4212297": "modification||infra:RsHPathAtt", + "E4212298": "deletion||infra:RsHPathAtt" + }, + "stats": { + + }, + "versions": "1.1(1j)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": false, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": false, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "regular", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + "apic" + ], + "classId": "6106", + "className": "RsHPathAtt", + "classPkg": "infra", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "Host Path", + "comment": [ + "" + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38185", + "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": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40324", + "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 + }, + "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": "1.1(1j)-", + "comment": [ + "The class ID of the target object. This property is managed internally and should not be modified by the user." + ], + "isConfigurable": false, + "propGlobalId": "18160", + "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": "493", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "493", "localName": "fabricPathEp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "} + ], + "default": "fabricPathEp", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "1.1(1j)-", + "comment": [ + "The distinguished name of the target." + ], + "isConfigurable": true, + "propGlobalId": "18159", + "propLocalId": "77", + "label": "Target-dn", + "baseType": "reference:BinRef", + "modelType": "reln:Dn", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "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/meta/infraRsPathToAccBaseGrp.json b/gen/meta/infraRsPathToAccBaseGrp.json new file mode 100644 index 000000000..2f34c6335 --- /dev/null +++ b/gen/meta/infraRsPathToAccBaseGrp.json @@ -0,0 +1,966 @@ +{ + "infra:RsPathToAccBaseGrp": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Inst": "", + "health:Inst": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fault-": "fault:Inst", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + + ], + "rnFormat": "rspathToAccBaseGrp", + "containedBy": { + "infra:HPathS": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "n-to-1", + "fromMo": "infra:HPathS", + "fromRelMo": "infra:RsPathToAccBaseGrp", + "toMo": "infra:AccBaseGrp", + "toRelMo": "infra:RtPathToAccBaseGrp", + "enforceable": true, + "resolvable": true + }, + "dnFormats": [ + "uni/infra/hpaths-{name}/rspathToAccBaseGrp" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "faults": { + "F1631": "fltInfraRsPathToAccBaseGrpResolveFail" + }, + "events": { + "E4212347": "creation||infra:RsPathToAccBaseGrp", + "E4212348": "modification||infra:RsPathToAccBaseGrp", + "E4212349": "deletion||infra:RsPathToAccBaseGrp" + }, + "stats": { + + }, + "versions": "1.1(1j)-", + "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": "6108", + "className": "RsPathToAccBaseGrp", + "classPkg": "infra", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "Access Base Group", + "comment": [ + "" + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38186", + "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": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40325", + "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": "1.1(1j)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "18172", + "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": "1.1(1j)-", + "comment": [ + "The class ID of the target object. This property is managed internally and should not be modified by the user." + ], + "isConfigurable": false, + "propGlobalId": "18163", + "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": "4384", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4384", "localName": "infraAccBaseGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4406", "localName": "infraAccBndlGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "6102", "localName": "infraAccBndlPolGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4416", "localName": "infraAccBndlSubgrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4409", "localName": "infraAccPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "9141", "localName": "infraBrkoutPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "11873", "localName": "infraFcAccBndlGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "11874", "localName": "infraFcAccBndlPolGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "11872", "localName": "infraFcAccPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4386", "localName": "infraFexBndlGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "8243", "localName": "infraSpAccPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "} + ], + "default": "infraAccBaseGrp", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "1.1(1j)-", + "comment": [ + "The distinguished name of the target." + ], + "isConfigurable": true, + "propGlobalId": "18162", + "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/testvars/infraHPathS.yaml b/gen/testvars/infraHPathS.yaml index 33fbef238..ab5394471 100644 --- a/gen/testvars/infraHPathS.yaml +++ b/gen/testvars/infraHPathS.yaml @@ -26,6 +26,17 @@ all: owner_tag: "owner_tag_1" children: + relation_to_host_paths: + - annotation: "annotation_1" + target_dn: "target_dn_0" + + - annotation: "annotation_2" + target_dn: "target_dn_1" + + relation_to_access_base_group: + - annotation: "annotation_1" + target_dn: "target_dn_1" + deletable_child: true annotations: - key: "key_0" value: "value_1" @@ -41,3 +52,16 @@ children: value: "test_value" parents: +child_targets: + - class_name: "fabricPathEp" + target_dn: "topology/pod-1/paths-101/pathep-[eth1/1]" + relation_resource_name: "host_path" + static: true + - class_name: "fabricPathEp" + target_dn: "topology/pod-1/paths-101/pathep-[eth1/2]" + relation_resource_name: "host_path" + static: true + - class_name: "infraAccPortGrp" + target_dn: "uni/infra/funcprof/accportgrp-interface_policy_group" + relation_resource_name: "access_base_group" + static: true diff --git a/gen/testvars/infraRsHPathAtt.yaml b/gen/testvars/infraRsHPathAtt.yaml new file mode 100644 index 000000000..fcfa77cd1 --- /dev/null +++ b/gen/testvars/infraRsHPathAtt.yaml @@ -0,0 +1,62 @@ +# 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" + +datasource_non_existing: + target_dn: "non_existing_t_dn" + +datasource_required: + target_dn: "test_t_dn" + +resource_required: + target_dn: "test_t_dn" + +all: + annotation: "annotation" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + +parents: + - class_name: "infraHPathS" + parent_dependency: "" + parent_dn: "aci_host_path_selector.test.id" + class_in_parent: false + target_classes: + - "fabricPathEp" +targets: + - class_name: "fabricPathEp" + target_dn: "topology/pod-1/paths-101/pathep-[eth1/1]" + target_dn_ref: "aci_.test__0.id" + parent_dependency: "" + parent_dependency_dn_ref: "" + target_resource_name: "" + relation_resource_name: "host_path" + parent_dn_key: "parent_dn" + static: true + properties: + - class_name: "fabricPathEp" + target_dn: "topology/pod-1/paths-101/pathep-[eth1/2]" + target_dn_ref: "aci_.test__1.id" + parent_dependency: "" + parent_dependency_dn_ref: "" + target_resource_name: "" + relation_resource_name: "host_path" + parent_dn_key: "parent_dn" + static: true + properties: diff --git a/internal/provider/data_source_aci_host_path_selector.go b/internal/provider/data_source_aci_host_path_selector.go index 85862d7cb..4048ebcd0 100644 --- a/internal/provider/data_source_aci_host_path_selector.go +++ b/internal/provider/data_source_aci_host_path_selector.go @@ -73,6 +73,38 @@ func (d *InfraHPathSDataSource) Schema(ctx context.Context, req datasource.Schem Computed: true, MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, }, + "relation_to_host_paths": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Host Path object.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name of the target.`, + }, + }, + }, + }, + "relation_to_access_base_group": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Access Base Group object.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name of the target.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, diff --git a/internal/provider/data_source_aci_relation_to_host_path.go b/internal/provider/data_source_aci_relation_to_host_path.go new file mode 100644 index 000000000..85cdae5c3 --- /dev/null +++ b/internal/provider/data_source_aci_relation_to_host_path.go @@ -0,0 +1,149 @@ +// 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 = &InfraRsHPathAttDataSource{} + +func NewInfraRsHPathAttDataSource() datasource.DataSource { + return &InfraRsHPathAttDataSource{} +} + +// InfraRsHPathAttDataSource defines the data source implementation. +type InfraRsHPathAttDataSource struct { + client *client.Client +} + +func (d *InfraRsHPathAttDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_relation_to_host_path") + resp.TypeName = req.ProviderTypeName + "_relation_to_host_path" + tflog.Debug(ctx, "End metadata of datasource: aci_relation_to_host_path") +} + +func (d *InfraRsHPathAttDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_relation_to_host_path") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_to_host_path datasource for the 'infraRsHPathAtt' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Relation To Host Path object.", + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Host Path object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The distinguished name of the target.`, + }, + "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_relation_to_host_path") +} + +func (d *InfraRsHPathAttDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_relation_to_host_path") + // 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_relation_to_host_path") +} + +func (d *InfraRsHPathAttDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_relation_to_host_path") + var data *InfraRsHPathAttResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setInfraRsHPathAttId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraRsHPathAttAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_relation_to_host_path with id '%s'", data.Id.ValueString())) + + getAndSetInfraRsHPathAttAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_relation_to_host_path data source", + fmt.Sprintf("The aci_relation_to_host_path 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_relation_to_host_path with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_relation_to_host_path_test.go b/internal/provider/data_source_aci_relation_to_host_path_test.go new file mode 100644 index 000000000..86e698ac5 --- /dev/null +++ b/internal/provider/data_source_aci_relation_to_host_path_test.go @@ -0,0 +1,49 @@ +// 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 TestAccDataSourceInfraRsHPathAttWithInfraHPathS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraRsHPathAttDataSourceDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("data.aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), + ), + }, + { + Config: testConfigInfraRsHPathAttNotExistingInfraHPathS, + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_host_path data source"), + }, + }, + }) +} + +const testConfigInfraRsHPathAttDataSourceDependencyWithInfraHPathS = testConfigInfraRsHPathAttMinDependencyWithInfraHPathS + ` +data "aci_relation_to_host_path" "test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + depends_on = [aci_relation_to_host_path.test] +} +` + +const testConfigInfraRsHPathAttNotExistingInfraHPathS = testConfigInfraRsHPathAttMinDependencyWithInfraHPathS + ` +data "aci_relation_to_host_path" "test_non_existing" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]_not_existing" +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 400f7b6a7..2f86ae5e4 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -230,6 +230,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvSCrtrnResource, NewFvVmAttrResource, NewInfraHPathSResource, + NewInfraRsHPathAttResource, NewL3extConsLblResource, NewL3extProvLblResource, NewL3extRsOutToFBRGroupResource, @@ -281,6 +282,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvSCrtrnDataSource, NewFvVmAttrDataSource, NewInfraHPathSDataSource, + NewInfraRsHPathAttDataSource, NewL3extConsLblDataSource, NewL3extProvLblDataSource, NewL3extRsOutToFBRGroupDataSource, diff --git a/internal/provider/resource_aci_host_path_selector.go b/internal/provider/resource_aci_host_path_selector.go index 2decf6388..121b68970 100644 --- a/internal/provider/resource_aci_host_path_selector.go +++ b/internal/provider/resource_aci_host_path_selector.go @@ -13,6 +13,7 @@ import ( "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -22,6 +23,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -42,16 +44,18 @@ type InfraHPathSResource struct { // InfraHPathSResourceModel describes the resource data model. type InfraHPathSResourceModel struct { - Id types.String `tfsdk:"id"` - ParentDn types.String `tfsdk:"parent_dn"` - Annotation types.String `tfsdk:"annotation"` - Descr types.String `tfsdk:"description"` - Name types.String `tfsdk:"name"` - NameAlias types.String `tfsdk:"name_alias"` - OwnerKey types.String `tfsdk:"owner_key"` - OwnerTag types.String `tfsdk:"owner_tag"` - TagAnnotation types.Set `tfsdk:"annotations"` - TagTag types.Set `tfsdk:"tags"` + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + InfraRsHPathAtt types.Set `tfsdk:"relation_to_host_paths"` + InfraRsPathToAccBaseGrp types.Set `tfsdk:"relation_to_access_base_group"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` } func getEmptyInfraHPathSResourceModel() *InfraHPathSResourceModel { @@ -64,6 +68,18 @@ func getEmptyInfraHPathSResourceModel() *InfraHPathSResourceModel { NameAlias: basetypes.NewStringNull(), OwnerKey: basetypes.NewStringNull(), OwnerTag: basetypes.NewStringNull(), + InfraRsHPathAtt: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + }, + }), + InfraRsPathToAccBaseGrp: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + }, + }), TagAnnotation: types.SetNull(types.ObjectType{ AttrTypes: map[string]attr.Type{ "key": types.StringType, @@ -79,6 +95,32 @@ func getEmptyInfraHPathSResourceModel() *InfraHPathSResourceModel { } } +// InfraRsHPathAttInfraHPathSResourceModel describes the resource data model for the children without relation ships. +type InfraRsHPathAttInfraHPathSResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` +} + +func getEmptyInfraRsHPathAttInfraHPathSResourceModel() InfraRsHPathAttInfraHPathSResourceModel { + return InfraRsHPathAttInfraHPathSResourceModel{ + Annotation: basetypes.NewStringNull(), + TDn: basetypes.NewStringNull(), + } +} + +// InfraRsPathToAccBaseGrpInfraHPathSResourceModel describes the resource data model for the children without relation ships. +type InfraRsPathToAccBaseGrpInfraHPathSResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` +} + +func getEmptyInfraRsPathToAccBaseGrpInfraHPathSResourceModel() InfraRsPathToAccBaseGrpInfraHPathSResourceModel { + return InfraRsPathToAccBaseGrpInfraHPathSResourceModel{ + Annotation: basetypes.NewStringNull(), + TDn: basetypes.NewStringNull(), + } +} + // TagAnnotationInfraHPathSResourceModel describes the resource data model for the children without relation ships. type TagAnnotationInfraHPathSResourceModel struct { Key types.String `tfsdk:"key"` @@ -219,6 +261,64 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq }, MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, }, + "relation_to_host_paths": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Relation To Host Path object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name of the target.`, + }, + }, + }, + }, + "relation_to_access_base_group": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.Set{ + setvalidator.SizeAtMost(1), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Relation To Access Base Group object.`, + }, + "target_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name of the target.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, @@ -330,13 +430,19 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + var infraRsHPathAttPlan, infraRsHPathAttState []InfraRsHPathAttInfraHPathSResourceModel + data.InfraRsHPathAtt.ElementsAs(ctx, &infraRsHPathAttPlan, false) + stateData.InfraRsHPathAtt.ElementsAs(ctx, &infraRsHPathAttState, false) + var infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState []InfraRsPathToAccBaseGrpInfraHPathSResourceModel + data.InfraRsPathToAccBaseGrp.ElementsAs(ctx, &infraRsPathToAccBaseGrpPlan, false) + stateData.InfraRsPathToAccBaseGrp.ElementsAs(ctx, &infraRsPathToAccBaseGrpState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, true, data, infraRsHPathAttPlan, infraRsHPathAttState, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -395,13 +501,19 @@ func (r *InfraHPathSResource) Update(ctx context.Context, req resource.UpdateReq tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + var infraRsHPathAttPlan, infraRsHPathAttState []InfraRsHPathAttInfraHPathSResourceModel + data.InfraRsHPathAtt.ElementsAs(ctx, &infraRsHPathAttPlan, false) + stateData.InfraRsHPathAtt.ElementsAs(ctx, &infraRsHPathAttState, false) + var infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState []InfraRsPathToAccBaseGrpInfraHPathSResourceModel + data.InfraRsPathToAccBaseGrp.ElementsAs(ctx, &infraRsPathToAccBaseGrpPlan, false) + stateData.InfraRsPathToAccBaseGrp.ElementsAs(ctx, &infraRsPathToAccBaseGrpState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, false, data, infraRsHPathAttPlan, infraRsHPathAttState, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -455,7 +567,7 @@ func (r *InfraHPathSResource) ImportState(ctx context.Context, req resource.Impo } func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraHPathSResourceModel) { - requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "infraHPathS,tagAnnotation,tagTag"), "GET", nil) + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "infraHPathS,infraRsHPathAtt,infraRsPathToAccBaseGrp,tagAnnotation,tagTag"), "GET", nil) *data = *getEmptyInfraHPathSResourceModel() @@ -490,6 +602,8 @@ func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics data.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) } } + InfraRsHPathAttInfraHPathSList := make([]InfraRsHPathAttInfraHPathSResourceModel, 0) + InfraRsPathToAccBaseGrpInfraHPathSList := make([]InfraRsPathToAccBaseGrpInfraHPathSResourceModel, 0) TagAnnotationInfraHPathSList := make([]TagAnnotationInfraHPathSResourceModel, 0) TagTagInfraHPathSList := make([]TagTagInfraHPathSResourceModel, 0) _, ok := classReadInfo[0].(map[string]interface{})["children"] @@ -498,6 +612,30 @@ func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics for _, child := range children { for childClassName, childClassDetails := range child.(map[string]interface{}) { childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "infraRsHPathAtt" { + InfraRsHPathAttInfraHPathS := getEmptyInfraRsHPathAttInfraHPathSResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + InfraRsHPathAttInfraHPathS.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + InfraRsHPathAttInfraHPathS.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + InfraRsHPathAttInfraHPathSList = append(InfraRsHPathAttInfraHPathSList, InfraRsHPathAttInfraHPathS) + } + if childClassName == "infraRsPathToAccBaseGrp" { + InfraRsPathToAccBaseGrpInfraHPathS := getEmptyInfraRsPathToAccBaseGrpInfraHPathSResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + InfraRsPathToAccBaseGrpInfraHPathS.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + InfraRsPathToAccBaseGrpInfraHPathS.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + InfraRsPathToAccBaseGrpInfraHPathSList = append(InfraRsPathToAccBaseGrpInfraHPathSList, InfraRsPathToAccBaseGrpInfraHPathS) + } if childClassName == "tagAnnotation" { TagAnnotationInfraHPathS := getEmptyTagAnnotationInfraHPathSResourceModel() for childAttributeName, childAttributeValue := range childAttributes { @@ -525,6 +663,10 @@ func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics } } } + infraRsHPathAttSet, _ := types.SetValueFrom(ctx, data.InfraRsHPathAtt.ElementType(ctx), InfraRsHPathAttInfraHPathSList) + data.InfraRsHPathAtt = infraRsHPathAttSet + infraRsPathToAccBaseGrpSet, _ := types.SetValueFrom(ctx, data.InfraRsPathToAccBaseGrp.ElementType(ctx), InfraRsPathToAccBaseGrpInfraHPathSList) + data.InfraRsPathToAccBaseGrp = infraRsPathToAccBaseGrpSet tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationInfraHPathSList) data.TagAnnotation = tagAnnotationSet tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagInfraHPathSList) @@ -571,6 +713,74 @@ func setInfraHPathSId(ctx context.Context, data *InfraHPathSResourceModel) { data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } +func getInfraHPathSInfraRsHPathAttChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, infraRsHPathAttPlan, infraRsHPathAttState []InfraRsHPathAttInfraHPathSResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.InfraRsHPathAtt.IsUnknown() { + infraRsHPathAttIdentifiers := []InfraRsHPathAttIdentifier{} + for _, infraRsHPathAtt := range infraRsHPathAttPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !infraRsHPathAtt.Annotation.IsUnknown() && !infraRsHPathAtt.Annotation.IsNull() { + childMap["attributes"]["annotation"] = infraRsHPathAtt.Annotation.ValueString() + } else { + childMap["attributes"]["annotation"] = globalAnnotation + } + if !infraRsHPathAtt.TDn.IsUnknown() && !infraRsHPathAtt.TDn.IsNull() { + childMap["attributes"]["tDn"] = infraRsHPathAtt.TDn.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"infraRsHPathAtt": childMap}) + infraRsHPathAttIdentifier := InfraRsHPathAttIdentifier{} + infraRsHPathAttIdentifier.TDn = infraRsHPathAtt.TDn + infraRsHPathAttIdentifiers = append(infraRsHPathAttIdentifiers, infraRsHPathAttIdentifier) + } + for _, infraRsHPathAtt := range infraRsHPathAttState { + delete := true + for _, infraRsHPathAttIdentifier := range infraRsHPathAttIdentifiers { + if infraRsHPathAttIdentifier.TDn == infraRsHPathAtt.TDn { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["tDn"] = infraRsHPathAtt.TDn.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"infraRsHPathAtt": childMap}) + } + } + } else { + data.InfraRsHPathAtt = types.SetNull(data.InfraRsHPathAtt.ElementType(ctx)) + } + + return childPayloads +} +func getInfraHPathSInfraRsPathToAccBaseGrpChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState []InfraRsPathToAccBaseGrpInfraHPathSResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.InfraRsPathToAccBaseGrp.IsUnknown() { + for _, infraRsPathToAccBaseGrp := range infraRsPathToAccBaseGrpPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !infraRsPathToAccBaseGrp.Annotation.IsUnknown() && !infraRsPathToAccBaseGrp.Annotation.IsNull() { + childMap["attributes"]["annotation"] = infraRsPathToAccBaseGrp.Annotation.ValueString() + } else { + childMap["attributes"]["annotation"] = globalAnnotation + } + if !infraRsPathToAccBaseGrp.TDn.IsUnknown() && !infraRsPathToAccBaseGrp.TDn.IsNull() { + childMap["attributes"]["tDn"] = infraRsPathToAccBaseGrp.TDn.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"infraRsPathToAccBaseGrp": childMap}) + } + if len(infraRsPathToAccBaseGrpPlan) == 0 && len(infraRsPathToAccBaseGrpState) == 1 { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childPayloads = append(childPayloads, map[string]interface{}{"infraRsPathToAccBaseGrp": childMap}) + } + } else { + data.InfraRsPathToAccBaseGrp = types.SetNull(data.InfraRsPathToAccBaseGrp.ElementType(ctx)) + } + + return childPayloads +} func getInfraHPathSTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel) []map[string]interface{} { childPayloads := []map[string]interface{}{} @@ -650,7 +860,7 @@ func getInfraHPathSTagTagChildPayloads(ctx context.Context, diags *diag.Diagnost return childPayloads } -func getInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) *container.Container { +func getInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraHPathSResourceModel, infraRsHPathAttPlan, infraRsHPathAttState []InfraRsHPathAttInfraHPathSResourceModel, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState []InfraRsPathToAccBaseGrpInfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} @@ -659,6 +869,18 @@ func getInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostic } childPayloads := []map[string]interface{}{} + InfraRsHPathAttchildPayloads := getInfraHPathSInfraRsHPathAttChildPayloads(ctx, diags, data, infraRsHPathAttPlan, infraRsHPathAttState) + if InfraRsHPathAttchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, InfraRsHPathAttchildPayloads...) + + InfraRsPathToAccBaseGrpchildPayloads := getInfraHPathSInfraRsPathToAccBaseGrpChildPayloads(ctx, diags, data, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState) + if InfraRsPathToAccBaseGrpchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, InfraRsPathToAccBaseGrpchildPayloads...) + TagAnnotationchildPayloads := getInfraHPathSTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) if TagAnnotationchildPayloads == nil { return nil diff --git a/internal/provider/resource_aci_host_path_selector_test.go b/internal/provider/resource_aci_host_path_selector_test.go index 3563e8757..4eb7c142e 100644 --- a/internal/provider/resource_aci_host_path_selector_test.go +++ b/internal/provider/resource_aci_host_path_selector_test.go @@ -149,6 +149,14 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "target_dn_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "2"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), @@ -170,6 +178,14 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "target_dn_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "2"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), @@ -189,6 +205,10 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "1"), @@ -204,6 +224,8 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "0"), ), }, @@ -211,6 +233,9 @@ func TestAccResourceInfraHPathS(t *testing.T) { }) } +const testChildDependencyConfigInfraHPathS = ` +` + const testConfigInfraHPathSMinAllowExisting = ` resource "aci_host_path_selector" "allow_test" { name = "host_path_selector" @@ -248,7 +273,7 @@ resource "aci_host_path_selector" "test" { owner_tag = "" } ` -const testConfigInfraHPathSChildren = ` +const testConfigInfraHPathSChildren = testChildDependencyConfigInfraHPathS + ` resource "aci_host_path_selector" "test" { name = "host_path_selector" annotations = [ @@ -261,6 +286,22 @@ resource "aci_host_path_selector" "test" { value = "test_value" }, ] + relation_to_access_base_group = [ + { + annotation = "annotation_1" + target_dn = uni/infra/funcprof/accportgrp-interface_policy_group + }, + ] + relation_to_host_paths = [ + { + annotation = "annotation_1" + target_dn = topology/pod-1/paths-101/pathep-[eth1/1] + }, + { + annotation = "annotation_2" + target_dn = topology/pod-1/paths-101/pathep-[eth1/2] + }, + ] tags = [ { key = "key_0" @@ -274,13 +315,13 @@ resource "aci_host_path_selector" "test" { } ` -const testConfigInfraHPathSChildrenRemoveFromConfig = ` +const testConfigInfraHPathSChildrenRemoveFromConfig = testChildDependencyConfigInfraHPathS + ` resource "aci_host_path_selector" "test" { name = "host_path_selector" } ` -const testConfigInfraHPathSChildrenRemoveOne = ` +const testConfigInfraHPathSChildrenRemoveOne = testChildDependencyConfigInfraHPathS + ` resource "aci_host_path_selector" "test" { name = "host_path_selector" annotations = [ @@ -289,6 +330,13 @@ resource "aci_host_path_selector" "test" { value = "test_value" }, ] + relation_to_access_base_group = [] + relation_to_host_paths = [ + { + annotation = "annotation_2" + target_dn = "topology/pod-1/paths-101/pathep-[eth1/2]" + }, + ] tags = [ { key = "key_1" @@ -298,10 +346,12 @@ resource "aci_host_path_selector" "test" { } ` -const testConfigInfraHPathSChildrenRemoveAll = ` +const testConfigInfraHPathSChildrenRemoveAll = testChildDependencyConfigInfraHPathS + ` resource "aci_host_path_selector" "test" { name = "host_path_selector" annotations = [] + relation_to_access_base_group = [] + relation_to_host_paths = [] tags = [] } ` diff --git a/internal/provider/resource_aci_relation_to_host_path.go b/internal/provider/resource_aci_relation_to_host_path.go new file mode 100644 index 000000000..0319b9f71 --- /dev/null +++ b/internal/provider/resource_aci_relation_to_host_path.go @@ -0,0 +1,643 @@ +// 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" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/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 = &InfraRsHPathAttResource{} +var _ resource.ResourceWithImportState = &InfraRsHPathAttResource{} + +func NewInfraRsHPathAttResource() resource.Resource { + return &InfraRsHPathAttResource{} +} + +// InfraRsHPathAttResource defines the resource implementation. +type InfraRsHPathAttResource struct { + client *client.Client +} + +// InfraRsHPathAttResourceModel describes the resource data model. +type InfraRsHPathAttResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyInfraRsHPathAttResourceModel() *InfraRsHPathAttResourceModel { + return &InfraRsHPathAttResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + 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, + }, + }), + } +} + +// TagAnnotationInfraRsHPathAttResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraRsHPathAttResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraRsHPathAttResourceModel() TagAnnotationInfraRsHPathAttResourceModel { + return TagAnnotationInfraRsHPathAttResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +// TagTagInfraRsHPathAttResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraRsHPathAttResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraRsHPathAttResourceModel() TagTagInfraRsHPathAttResourceModel { + return TagTagInfraRsHPathAttResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +type InfraRsHPathAttIdentifier struct { + TDn types.String +} + +func (r *InfraRsHPathAttResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *InfraRsHPathAttResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { + setInfraRsHPathAttId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "infraRsHPathAtt", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *InfraRsHPathAttResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_relation_to_host_path") + resp.TypeName = req.ProviderTypeName + "_relation_to_host_path" + tflog.Debug(ctx, "End metadata of resource: aci_relation_to_host_path") +} + +func (r *InfraRsHPathAttResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_relation_to_host_path") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_to_host_path resource for the 'infraRsHPathAtt' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Relation To Host Path object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Relation To Host Path object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The distinguished name of the target.`, + }, + "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_relation_to_host_path") +} + +func (r *InfraRsHPathAttResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_relation_to_host_path") + // 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_relation_to_host_path") +} + +func (r *InfraRsHPathAttResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_relation_to_host_path") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraRsHPathAttResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setInfraRsHPathAttId(ctx, stateData) + } + getAndSetInfraRsHPathAttAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The infraRsHPathAtt object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *InfraRsHPathAttResourceModel + + // 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() { + setInfraRsHPathAttId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_host_path with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraRsHPathAttResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraRsHPathAttResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraRsHPathAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetInfraRsHPathAttAttributes(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_relation_to_host_path with id '%s'", data.Id.ValueString())) +} + +func (r *InfraRsHPathAttResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_relation_to_host_path") + var data *InfraRsHPathAttResourceModel + + // 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_relation_to_host_path with id '%s'", data.Id.ValueString())) + + getAndSetInfraRsHPathAttAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraRsHPathAttResourceModel + 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_relation_to_host_path with id '%s'", data.Id.ValueString())) +} + +func (r *InfraRsHPathAttResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_relation_to_host_path") + var data *InfraRsHPathAttResourceModel + var stateData *InfraRsHPathAttResourceModel + + // 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_relation_to_host_path with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraRsHPathAttResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraRsHPathAttResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraRsHPathAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetInfraRsHPathAttAttributes(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_relation_to_host_path with id '%s'", data.Id.ValueString())) +} + +func (r *InfraRsHPathAttResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_relation_to_host_path") + var data *InfraRsHPathAttResourceModel + + // 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_relation_to_host_path with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraRsHPathAtt", 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_relation_to_host_path with id '%s'", data.Id.ValueString())) +} + +func (r *InfraRsHPathAttResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_relation_to_host_path") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraRsHPathAttResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_relation_to_host_path with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_relation_to_host_path") +} + +func getAndSetInfraRsHPathAttAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraRsHPathAttResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "infraRsHPathAtt,tagAnnotation,tagTag"), "GET", nil) + + *data = *getEmptyInfraRsHPathAttResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraRsHPathAtt").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraRsHPathAtt").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + data.Id = basetypes.NewStringValue(attributeValue.(string)) + setInfraRsHPathAttParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "tDn" { + data.TDn = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationInfraRsHPathAttList := make([]TagAnnotationInfraRsHPathAttResourceModel, 0) + TagTagInfraRsHPathAttList := make([]TagTagInfraRsHPathAttResourceModel, 0) + _, ok := classReadInfo[0].(map[string]interface{})["children"] + if ok { + children := classReadInfo[0].(map[string]interface{})["children"].([]interface{}) + for _, child := range children { + for childClassName, childClassDetails := range child.(map[string]interface{}) { + childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "tagAnnotation" { + TagAnnotationInfraRsHPathAtt := getEmptyTagAnnotationInfraRsHPathAttResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraRsHPathAtt.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraRsHPathAtt.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationInfraRsHPathAttList = append(TagAnnotationInfraRsHPathAttList, TagAnnotationInfraRsHPathAtt) + } + if childClassName == "tagTag" { + TagTagInfraRsHPathAtt := getEmptyTagTagInfraRsHPathAttResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraRsHPathAtt.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraRsHPathAtt.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagInfraRsHPathAttList = append(TagTagInfraRsHPathAttList, TagTagInfraRsHPathAtt) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationInfraRsHPathAttList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagInfraRsHPathAttList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraRsHPathAtt'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getInfraRsHPathAttRn(ctx context.Context, data *InfraRsHPathAttResourceModel) string { + rn := "rsHPathAtt-[{tDn}]" + for _, identifier := range []string{"tDn"} { + fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) + fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() + rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) + } + return rn +} + +func setInfraRsHPathAttParentDn(ctx context.Context, dn string, data *InfraRsHPathAttResourceModel) { + bracketIndex := 0 + rnIndex := 0 + for i := len(dn) - 1; i >= 0; i-- { + if string(dn[i]) == "]" { + bracketIndex = bracketIndex + 1 + } else if string(dn[i]) == "[" { + bracketIndex = bracketIndex - 1 + } else if string(dn[i]) == "/" && bracketIndex == 0 { + rnIndex = i + break + } + } + data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) +} + +func setInfraRsHPathAttId(ctx context.Context, data *InfraRsHPathAttResourceModel) { + rn := getInfraRsHPathAttRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraRsHPathAttTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraRsHPathAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraRsHPathAttResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotation := range tagAnnotationPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagAnnotation.Key.IsUnknown() && !tagAnnotation.Key.IsNull() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() && !tagAnnotation.Value.IsNull() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func getInfraRsHPathAttTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraRsHPathAttResourceModel, tagTagPlan, tagTagState []TagTagInfraRsHPathAttResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTag := range tagTagPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagTag.Key.IsUnknown() && !tagTag.Key.IsNull() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() && !tagTag.Value.IsNull() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraRsHPathAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraRsHPathAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraRsHPathAttResourceModel, tagTagPlan, tagTagState []TagTagInfraRsHPathAttResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + + if createType && !globalAllowExistingOnCreate { + payloadMap["attributes"].(map[string]string)["status"] = "created" + } + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getInfraRsHPathAttTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraRsHPathAttTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.TDn.IsNull() && !data.TDn.IsUnknown() { + payloadMap["attributes"].(map[string]string)["tDn"] = data.TDn.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"infraRsHPathAtt": 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_relation_to_host_path_test.go b/internal/provider/resource_aci_relation_to_host_path_test.go new file mode 100644 index 000000000..cc2291ad6 --- /dev/null +++ b/internal/provider/resource_aci_relation_to_host_path_test.go @@ -0,0 +1,290 @@ +// 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 TestAccResourceInfraRsHPathAttWithInfraHPathS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test_2", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test_2", "annotation", "orchestrator:terraform"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test_2", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test_2", "annotation", "orchestrator:terraform"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraRsHPathAttAllDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "annotation"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraRsHPathAttResetDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), + ), + }, + // Import testing + { + ResourceName: "aci_relation_to_host_path.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), + ), + }, + // Update with children + { + Config: testConfigInfraRsHPathAttChildrenDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.value", "test_value"), + ), + }, + // Import testing with children + { + ResourceName: "aci_relation_to_host_path.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.value", "test_value"), + ), + }, + // Update with children removed from config + { + Config: testConfigInfraRsHPathAttChildrenRemoveFromConfigDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraRsHPathAttChildrenRemoveOneDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigInfraRsHPathAttChildrenRemoveAllDependencyWithInfraHPathS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testDependencyConfigInfraRsHPathAtt = ` +` + +const testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` +resource "aci_relation_to_host_path" "allow_test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" +} +resource "aci_relation_to_host_path" "allow_test_2" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + depends_on = [aci_relation_to_host_path.allow_test] +} +` + +const testConfigInfraRsHPathAttMinDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` +resource "aci_relation_to_host_path" "test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" +} +` + +const testConfigInfraRsHPathAttAllDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` +resource "aci_relation_to_host_path" "test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + annotation = "annotation" +} +` + +const testConfigInfraRsHPathAttResetDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` +resource "aci_relation_to_host_path" "test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + annotation = "orchestrator:terraform" +} +` +const testConfigInfraRsHPathAttChildrenDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` +resource "aci_relation_to_host_path" "test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/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" + }, + ] +} +` + +const testConfigInfraRsHPathAttChildrenRemoveFromConfigDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` +resource "aci_relation_to_host_path" "test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" +} +` + +const testConfigInfraRsHPathAttChildrenRemoveOneDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` +resource "aci_relation_to_host_path" "test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraRsHPathAttChildrenRemoveAllDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` +resource "aci_relation_to_host_path" "test" { + parent_dn = aci_host_path_selector.test.id + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + annotations = [] + tags = [] +} +` From 0f9e005a64bdce59d80f3df51a7644a5ed4eec03 Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Fri, 2 Aug 2024 11:32:02 -0400 Subject: [PATCH 06/11] [ignore] Fixed Documentation for target_dn not being displayed correctly. --- docs/resources/host_path_selector.md | 4 ++-- .../aci_host_path_selector/resource-all-attributes.tf | 4 ++-- gen/templates/resource_example_all_attributes.tf.tmpl | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/resources/host_path_selector.md b/docs/resources/host_path_selector.md index f9c7680b8..53b4ecdda 100644 --- a/docs/resources/host_path_selector.md +++ b/docs/resources/host_path_selector.md @@ -55,13 +55,13 @@ resource "aci_host_path_selector" "full_example" { relation_to_host_paths = [ { annotation = "annotation_1" - target_dn = "target_dn_0" + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } ] relation_to_access_base_group = [ { annotation = "annotation_1" - target_dn = "target_dn_1" + target_dn = "uni/infra/funcprof/accportgrp-access_interface_policy_group" } ] annotations = [ diff --git a/examples/resources/aci_host_path_selector/resource-all-attributes.tf b/examples/resources/aci_host_path_selector/resource-all-attributes.tf index 99ce7956c..056e1429b 100644 --- a/examples/resources/aci_host_path_selector/resource-all-attributes.tf +++ b/examples/resources/aci_host_path_selector/resource-all-attributes.tf @@ -9,13 +9,13 @@ resource "aci_host_path_selector" "full_example" { relation_to_host_paths = [ { annotation = "annotation_1" - target_dn = "target_dn_0" + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } ] relation_to_access_base_group = [ { annotation = "annotation_1" - target_dn = "target_dn_1" + target_dn = "uni/infra/funcprof/accportgrp-access_interface_policy_group" } ] annotations = [ diff --git a/gen/templates/resource_example_all_attributes.tf.tmpl b/gen/templates/resource_example_all_attributes.tf.tmpl index 5509510dc..e10606082 100644 --- a/gen/templates/resource_example_all_attributes.tf.tmpl +++ b/gen/templates/resource_example_all_attributes.tf.tmpl @@ -52,6 +52,8 @@ resource "aci_{{$.ResourceName}}" "full_example" { {{$ChildResourceName}} = [ { {{- range .Properties}}{{- if not .ReadOnly }}{{- if ne .NamedPropertyClass ""}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name + {{- else if eq .SnakeCaseName "t_dn" }}{{$attributeVale := getTestTargetDn $.TestVars.child_targets $ChildResourceName "target_dn_0" true nil 0 | replace "test_0" "example_2" }} + target_dn = {{if containsString $attributeVale "."}}{{$attributeVale}}{{else}}"{{$attributeVale}}"{{end}} {{- else if .IgnoreInTest}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{.IgnoreInTestExampleValue}}" {{- else}} From bcf11673f67814cfa88ab6de07c62a2f037c4d55 Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Mon, 5 Aug 2024 15:08:06 -0400 Subject: [PATCH 07/11] [ignore] Fix resource_test.go template for default_parent/no_parent for t_dn children. --- docs/resources/host_path_selector.md | 2 +- .../resource-all-attributes.tf | 2 +- gen/templates/resource_test.go.tmpl | 35 +++++++++++++------ .../resource_aci_host_path_selector_test.go | 22 ++++++------ ...resource_aci_relation_to_host_path_test.go | 16 --------- 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/docs/resources/host_path_selector.md b/docs/resources/host_path_selector.md index 53b4ecdda..0aa8134e2 100644 --- a/docs/resources/host_path_selector.md +++ b/docs/resources/host_path_selector.md @@ -61,7 +61,7 @@ resource "aci_host_path_selector" "full_example" { relation_to_access_base_group = [ { annotation = "annotation_1" - target_dn = "uni/infra/funcprof/accportgrp-access_interface_policy_group" + target_dn = "uni/infra/funcprof/accportgrp-interface_policy_group" } ] annotations = [ diff --git a/examples/resources/aci_host_path_selector/resource-all-attributes.tf b/examples/resources/aci_host_path_selector/resource-all-attributes.tf index 056e1429b..827882f46 100644 --- a/examples/resources/aci_host_path_selector/resource-all-attributes.tf +++ b/examples/resources/aci_host_path_selector/resource-all-attributes.tf @@ -15,7 +15,7 @@ resource "aci_host_path_selector" "full_example" { relation_to_access_base_group = [ { annotation = "annotation_1" - target_dn = "uni/infra/funcprof/accportgrp-access_interface_policy_group" + target_dn = "uni/infra/funcprof/accportgrp-interface_policy_group" } ] annotations = [ diff --git a/gen/templates/resource_test.go.tmpl b/gen/templates/resource_test.go.tmpl index d659bb7b6..0e0a93f6f 100644 --- a/gen/templates/resource_test.go.tmpl +++ b/gen/templates/resource_test.go.tmpl @@ -650,12 +650,14 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) { {{- range $key, $value := $.children}} {{- range $child_index, $child := $value}} {{- range $child_key, $child_value := $child}} - {{- if ne $child_key "deletable_child"}} + {{- 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}}"), + {{- else if ne $child_key "deletable_child"}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{$child_value}}"), {{- end}} {{- end}} {{- end}} - resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.#", "2"), + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.#", "{{len $value}}"), {{- end}} ), }, @@ -688,16 +690,14 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) { {{- range $key, $value := $.children}} {{- range $child_index, $child := $value}} {{- range $child_key, $child_value := $child}} - {{- if ne $child_key "deletable_child"}} + {{- 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}}"), + {{- else if ne $child_key "deletable_child"}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{$child_value}}"), {{- end}} {{- end}} {{- end}} - {{- if eq (len $value) 1}} - resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.#", "1"), - {{- else}} - resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.#", "2"), - {{- end}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.#", "{{len $value}}"), {{- end}} ), }, @@ -733,7 +733,9 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) { resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.#", "0"), {{- else}} {{- range $child_key, $child_value := $child}} - {{- if ne $child_key "deletable_child"}} + {{- if eq $child_key "target_dn"}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil 1}}"), + {{- else if ne $child_key "deletable_child"}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}", "{{$child_value}}"), {{- end}} {{- end}} @@ -742,7 +744,11 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) { {{- else}} {{- $child := index $value 1 }} {{- range $child_key, $child_value := $child}} + {{- if eq $child_key "target_dn"}} + resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil 1}}"), + {{- else}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}", "{{$child_value}}"), + {{- end}} {{- end}} resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.#", "1"), {{- end}} @@ -1109,8 +1115,8 @@ resource "aci_{{$.resourceName}}" "test" { {{- range $child := $value}} { {{- range $child_key, $child_value := $child}} - {{- if eq $child_key "target_dn"}} - {{$child_key}} = {{getTestTargetDn $.child_targets $key $child_value true nil $index}} + {{- if eq $child_key "target_dn"}}{{$attributeValue := getTestTargetDn $.child_targets $key $child_value true nil $index}} + {{$child_key}} = {{if containsString $attributeValue "."}}{{$attributeValue}}{{else}}"{{$attributeValue}}"{{end}} {{- else if ne $child_key "deletable_child"}} {{$child_key}} = "{{$child_value}}" {{- end}} @@ -1176,7 +1182,14 @@ resource "aci_{{$.resourceName}}" "test" { {{- end }} {{- end}} {{- range $key, $value := $.children}} + {{- if eq (len $value) 1}} + {{- $child := index $value 0}} + {{- if $child.deletable_child}} + {{$key}} = [] + {{- end}} + {{- else}} {{$key}} = [] + {{- end}} {{- end}} } ` diff --git a/internal/provider/resource_aci_host_path_selector_test.go b/internal/provider/resource_aci_host_path_selector_test.go index 4eb7c142e..80548ef99 100644 --- a/internal/provider/resource_aci_host_path_selector_test.go +++ b/internal/provider/resource_aci_host_path_selector_test.go @@ -150,12 +150,12 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.target_dn", "target_dn_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.target_dn", "uni/infra/funcprof/accportgrp-interface_policy_group"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "target_dn_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.annotation", "annotation_2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.target_dn", "topology/pod-1/paths-101/pathep-[eth1/2]"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "2"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), @@ -179,12 +179,12 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.target_dn", "uni/infra/funcprof/accportgrp-interface_policy_group"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "target_dn_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.annotation", "annotation_2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.target_dn", "topology/pod-1/paths-101/pathep-[eth1/2]"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "2"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), @@ -207,7 +207,7 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "0"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "target_dn_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/2]"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_1"), resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "test_value"), @@ -289,17 +289,17 @@ resource "aci_host_path_selector" "test" { relation_to_access_base_group = [ { annotation = "annotation_1" - target_dn = uni/infra/funcprof/accportgrp-interface_policy_group + target_dn = "uni/infra/funcprof/accportgrp-interface_policy_group" }, ] relation_to_host_paths = [ { annotation = "annotation_1" - target_dn = topology/pod-1/paths-101/pathep-[eth1/1] + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" }, { annotation = "annotation_2" - target_dn = topology/pod-1/paths-101/pathep-[eth1/2] + target_dn = "topology/pod-1/paths-101/pathep-[eth1/2]" }, ] tags = [ diff --git a/internal/provider/resource_aci_relation_to_host_path_test.go b/internal/provider/resource_aci_relation_to_host_path_test.go index cc2291ad6..aaae01dd3 100644 --- a/internal/provider/resource_aci_relation_to_host_path_test.go +++ b/internal/provider/resource_aci_relation_to_host_path_test.go @@ -107,10 +107,6 @@ func TestAccResourceInfraRsHPathAttWithInfraHPathS(t *testing.T) { ResourceName: "aci_relation_to_host_path.test", ImportState: true, ImportStateVerify: true, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), - ), }, // Update with children { @@ -134,18 +130,6 @@ func TestAccResourceInfraRsHPathAttWithInfraHPathS(t *testing.T) { ResourceName: "aci_relation_to_host_path.test", ImportState: true, ImportStateVerify: true, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.value", "test_value"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.value", "test_value"), - ), }, // Update with children removed from config { From c542accd7a8d8c3d5c59534e54412371e3f9a238 Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Mon, 5 Aug 2024 15:15:03 -0400 Subject: [PATCH 08/11] [ignore] Rename host_path_selector resource and datasource to access_interface_override. Limit the max host path to 1 for access_interface_override. --- ...lector.md => access_interface_override.md} | 32 +- docs/data-sources/relation_to_host_path.md | 6 +- ...lector.md => access_interface_override.md} | 53 +-- docs/resources/relation_to_host_path.md | 14 +- .../data-source.tf | 4 + .../provider.tf | 0 .../aci_host_path_selector/data-source.tf | 4 - .../aci_relation_to_host_path/data-source.tf | 4 +- .../provider.tf | 0 .../resource-all-attributes.tf | 6 +- .../aci_access_interface_override/resource.tf | 4 + .../aci_host_path_selector/resource.tf | 4 - .../resource-all-attributes.tf | 4 +- .../aci_relation_to_host_path/resource.tf | 4 +- gen/definitions/classes.yaml | 9 +- gen/definitions/properties.yaml | 8 +- gen/testvars/infraHPathS.yaml | 15 +- gen/testvars/infraRsHPathAtt.yaml | 12 +- ...a_source_aci_access_interface_override.go} | 40 +- ...rce_aci_access_interface_override_test.go} | 18 +- ...a_source_aci_relation_to_host_path_test.go | 4 +- ...resource_aci_access_interface_override.go} | 65 ++-- ...urce_aci_access_interface_override_test.go | 342 +++++++++++++++++ .../resource_aci_host_path_selector_test.go | 357 ------------------ ...resource_aci_relation_to_host_path_test.go | 18 +- 25 files changed, 502 insertions(+), 525 deletions(-) rename docs/data-sources/{host_path_selector.md => access_interface_override.md} (66%) rename docs/resources/{host_path_selector.md => access_interface_override.md} (63%) create mode 100644 examples/data-sources/aci_access_interface_override/data-source.tf rename examples/data-sources/{aci_host_path_selector => aci_access_interface_override}/provider.tf (100%) delete mode 100644 examples/data-sources/aci_host_path_selector/data-source.tf rename examples/resources/{aci_host_path_selector => aci_access_interface_override}/provider.tf (100%) rename examples/resources/{aci_host_path_selector => aci_access_interface_override}/resource-all-attributes.tf (74%) create mode 100644 examples/resources/aci_access_interface_override/resource.tf delete mode 100644 examples/resources/aci_host_path_selector/resource.tf rename internal/provider/{data_source_aci_host_path_selector.go => data_source_aci_access_interface_override.go} (77%) rename internal/provider/{data_source_aci_host_path_selector_test.go => data_source_aci_access_interface_override_test.go} (56%) rename internal/provider/{resource_aci_host_path_selector.go => resource_aci_access_interface_override.go} (92%) create mode 100644 internal/provider/resource_aci_access_interface_override_test.go delete mode 100644 internal/provider/resource_aci_host_path_selector_test.go diff --git a/docs/data-sources/host_path_selector.md b/docs/data-sources/access_interface_override.md similarity index 66% rename from docs/data-sources/host_path_selector.md rename to docs/data-sources/access_interface_override.md index 14244cd96..45470d1ec 100644 --- a/docs/data-sources/host_path_selector.md +++ b/docs/data-sources/access_interface_override.md @@ -2,17 +2,17 @@ # 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: "Generic" +subcategory: "Access Policies" layout: "aci" -page_title: "ACI: aci_host_path_selector" -sidebar_current: "docs-aci-data-source-aci_host_path_selector" +page_title: "ACI: aci_access_interface_override" +sidebar_current: "docs-aci-data-source-aci_access_interface_override" description: |- - Data source for Host Path Selector + Data source for Access Interface Override --- -# aci_host_path_selector # +# aci_access_interface_override # -Data source for Host Path Selector +Data source for Access Interface Override ## API Information ## @@ -24,13 +24,15 @@ Data source for Host Path Selector ## GUI Information ## -* Location: `Generic` +* Locations: + - `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides` + - `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides` ## Example Usage ## ```hcl -data "aci_host_path_selector" "example" { +data "aci_access_interface_override" "example" { name = "host_path_selector" } @@ -46,14 +48,14 @@ data "aci_host_path_selector" "example" { - Default: `uni/infra` -* `name` (name) - (string) The name of the Host Path Selector object. +* `name` (name) - (string) The name of the Access Interface Override object. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the Host Path Selector object. -* `annotation` (annotation) - (string) The annotation of the Host Path Selector object. -* `description` (descr) - (string) The description of the Host Path Selector object. -* `name_alias` (nameAlias) - (string) The name alias of the Host Path Selector object. +* `id` - (string) The distinguished name (DN) of the Access Interface Override object. +* `annotation` (annotation) - (string) The annotation of the Access Interface Override object. +* `description` (descr) - (string) The description of the Access Interface Override object. +* `name_alias` (nameAlias) - (string) The name alias of the Access Interface Override 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. @@ -61,8 +63,8 @@ data "aci_host_path_selector" "example" { * `annotation` (annotation) - (string) The annotation of the Relation To Host Path object. * `target_dn` (tDn) - (string) The distinguished name of the target. -* `relation_to_access_base_group` - (list) A list of Relation To Access Base Group (ACI object [infraRsPathToAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsPathToAccBaseGrp/overview)) pointing to (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)). - * `annotation` (annotation) - (string) The annotation of the Relation To Access Base Group object. +* `relation_to_access_interface_policy_group` - (list) A list of Relation To Access Interface Policy Group (ACI object [infraRsPathToAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsPathToAccBaseGrp/overview)) pointing to (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)). + * `annotation` (annotation) - (string) The annotation of the Relation To Access Interface Policy Group object. * `target_dn` (tDn) - (string) The distinguished name of the target. * `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. diff --git a/docs/data-sources/relation_to_host_path.md b/docs/data-sources/relation_to_host_path.md index ce0c311f6..4011ca55b 100644 --- a/docs/data-sources/relation_to_host_path.md +++ b/docs/data-sources/relation_to_host_path.md @@ -30,8 +30,8 @@ Data source for Relation To Host Path ```hcl -data "aci_relation_to_host_path" "example_host_path_selector" { - parent_dn = aci_host_path_selector.example.id +data "aci_relation_to_host_path" "example_access_interface_override" { + parent_dn = aci_access_interface_override.example.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } @@ -42,7 +42,7 @@ data "aci_relation_to_host_path" "example_host_path_selector" { ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - - [aci_host_path_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/host_path_selector) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) + - [aci_access_interface_override](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_interface_override) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) * `target_dn` (tDn) - (string) The distinguished name of the target. ### Read-Only ### diff --git a/docs/resources/host_path_selector.md b/docs/resources/access_interface_override.md similarity index 63% rename from docs/resources/host_path_selector.md rename to docs/resources/access_interface_override.md index 0aa8134e2..dea3c42a2 100644 --- a/docs/resources/host_path_selector.md +++ b/docs/resources/access_interface_override.md @@ -2,17 +2,17 @@ # 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: "Generic" +subcategory: "Access Policies" layout: "aci" -page_title: "ACI: aci_host_path_selector" -sidebar_current: "docs-aci-resource-aci_host_path_selector" +page_title: "ACI: aci_access_interface_override" +sidebar_current: "docs-aci-resource-aci_access_interface_override" description: |- - Manages ACI Host Path Selector + Manages ACI Access Interface Override --- -# aci_host_path_selector # +# aci_access_interface_override # -Manages ACI Host Path Selector +Manages ACI Access Interface Override @@ -26,26 +26,28 @@ Manages ACI Host Path Selector ## GUI Information ## -* Location: `Generic` +* Locations: + - `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides` + - `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides` ## Example Usage ## -The configuration snippet below creates a Host Path Selector with only required attributes. +The configuration snippet below creates a Access Interface Override with only required attributes. ```hcl -resource "aci_host_path_selector" "example" { +resource "aci_access_interface_override" "example" { name = "host_path_selector" } ``` -The configuration snippet below shows all possible attributes of the Host Path Selector. +The configuration snippet below shows all possible attributes of the Access Interface Override. !> This example might not be valid configuration and is only used to show all possible attributes. ```hcl -resource "aci_host_path_selector" "full_example" { +resource "aci_access_interface_override" "full_example" { annotation = "annotation" description = "description_1" name = "host_path_selector" @@ -58,10 +60,10 @@ resource "aci_host_path_selector" "full_example" { target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } ] - relation_to_access_base_group = [ + relation_to_access_interface_policy_group = [ { annotation = "annotation_1" - target_dn = "uni/infra/funcprof/accportgrp-interface_policy_group" + target_dn = "uni/infra/funcprof/accportgrp-access_interface_policy_group" } ] annotations = [ @@ -80,17 +82,17 @@ resource "aci_host_path_selector" "full_example" { ``` -All examples for the Host Path Selector resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_host_path_selector) folder. +All examples for the Access Interface Override resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_access_interface_override) folder. ## Schema ## ### Required ### -* `name` (name) - (string) The name of the Host Path Selector object. +* `name` (name) - (string) The name of the Access Interface Override object. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the Host Path Selector object. +* `id` - (string) The distinguished name (DN) of the Access Interface Override object. ### Optional ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: @@ -99,14 +101,15 @@ All examples for the Host Path Selector resource can be found in the [examples]( - Default: `uni/infra` -* `annotation` (annotation) - (string) The annotation of the Host Path Selector object. +* `annotation` (annotation) - (string) The annotation of the Access Interface Override object. - Default: `orchestrator:terraform` -* `description` (descr) - (string) The description of the Host Path Selector object. -* `name_alias` (nameAlias) - (string) The name alias of the Host Path Selector object. +* `description` (descr) - (string) The description of the Access Interface Override object. +* `name_alias` (nameAlias) - (string) The name alias of the Access Interface Override 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. * `relation_to_host_paths` - (list) A list of Relation To Host Paths (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)) which can be configured using the [aci_](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/) resource. + - Max Items: 1 #### Required #### @@ -117,13 +120,13 @@ All examples for the Host Path Selector resource can be found in the [examples]( * `annotation` (annotation) - (string) The annotation of the Relation To Host Path object. - Default: `orchestrator:terraform` -* `relation_to_access_base_group` - (list) A list of Relation To Access Base Group (ACI object [infraRsPathToAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsPathToAccBaseGrp/overview)) pointing to (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)) which can be configured using the [aci_](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/) resource. +* `relation_to_access_interface_policy_group` - (list) A list of Relation To Access Interface Policy Group (ACI object [infraRsPathToAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsPathToAccBaseGrp/overview)) pointing to (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)) which can be configured using the [aci_](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/) resource. - Max Items: 1 #### Optional #### - * `annotation` (annotation) - (string) The annotation of the Relation To Access Base Group object. + * `annotation` (annotation) - (string) The annotation of the Relation To Access Interface Policy Group object. - Default: `orchestrator:terraform` * `target_dn` (tDn) - (string) The distinguished name of the target. @@ -143,18 +146,18 @@ All examples for the Host Path Selector resource can be found in the [examples]( ## Importing -An existing Host Path Selector can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: +An existing Access Interface Override 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_host_path_selector.example uni/infra/hpaths-{name} +terraform import aci_access_interface_override.example uni/infra/hpaths-{name} ``` -Starting in Terraform version 1.5, an existing Host Path Selector can be imported +Starting in Terraform version 1.5, an existing Access Interface Override can be imported using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: ``` import { id = "uni/infra/hpaths-{name}" - to = aci_host_path_selector.example + to = aci_access_interface_override.example } ``` diff --git a/docs/resources/relation_to_host_path.md b/docs/resources/relation_to_host_path.md index cde19e044..e8eed4472 100644 --- a/docs/resources/relation_to_host_path.md +++ b/docs/resources/relation_to_host_path.md @@ -34,8 +34,8 @@ The configuration snippet below creates a Relation To Host Path with only requir ```hcl -resource "aci_relation_to_host_path" "example_host_path_selector" { - parent_dn = aci_host_path_selector.example.id +resource "aci_relation_to_host_path" "example_access_interface_override" { + parent_dn = aci_access_interface_override.example.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } @@ -46,8 +46,8 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl -resource "aci_relation_to_host_path" "full_example_host_path_selector" { - parent_dn = aci_host_path_selector.example.id +resource "aci_relation_to_host_path" "full_example_access_interface_override" { + parent_dn = aci_access_interface_override.example.id annotation = "annotation" target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" annotations = [ @@ -73,7 +73,7 @@ All examples for the Relation To Host Path resource can be found in the [example ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - - [aci_host_path_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/host_path_selector) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) + - [aci_access_interface_override](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_interface_override) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) * `target_dn` (tDn) - (string) The distinguished name of the target. ### Read-Only ### @@ -104,7 +104,7 @@ All examples for the Relation To Host Path resource can be found in the [example An existing Relation To Host Path 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_relation_to_host_path.example_host_path_selector uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}] +terraform import aci_relation_to_host_path.example_access_interface_override uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}] ``` Starting in Terraform version 1.5, an existing Relation To Host Path can be imported @@ -113,6 +113,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}]" - to = aci_relation_to_host_path.example_host_path_selector + to = aci_relation_to_host_path.example_access_interface_override } ``` diff --git a/examples/data-sources/aci_access_interface_override/data-source.tf b/examples/data-sources/aci_access_interface_override/data-source.tf new file mode 100644 index 000000000..931b79ad9 --- /dev/null +++ b/examples/data-sources/aci_access_interface_override/data-source.tf @@ -0,0 +1,4 @@ + +data "aci_access_interface_override" "example" { + name = "host_path_selector" +} diff --git a/examples/data-sources/aci_host_path_selector/provider.tf b/examples/data-sources/aci_access_interface_override/provider.tf similarity index 100% rename from examples/data-sources/aci_host_path_selector/provider.tf rename to examples/data-sources/aci_access_interface_override/provider.tf diff --git a/examples/data-sources/aci_host_path_selector/data-source.tf b/examples/data-sources/aci_host_path_selector/data-source.tf deleted file mode 100644 index 19a11528f..000000000 --- a/examples/data-sources/aci_host_path_selector/data-source.tf +++ /dev/null @@ -1,4 +0,0 @@ - -data "aci_host_path_selector" "example" { - name = "host_path_selector" -} diff --git a/examples/data-sources/aci_relation_to_host_path/data-source.tf b/examples/data-sources/aci_relation_to_host_path/data-source.tf index 7fa16175b..c9bfb8fe7 100644 --- a/examples/data-sources/aci_relation_to_host_path/data-source.tf +++ b/examples/data-sources/aci_relation_to_host_path/data-source.tf @@ -1,5 +1,5 @@ -data "aci_relation_to_host_path" "example_host_path_selector" { - parent_dn = aci_host_path_selector.example.id +data "aci_relation_to_host_path" "example_access_interface_override" { + parent_dn = aci_access_interface_override.example.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } diff --git a/examples/resources/aci_host_path_selector/provider.tf b/examples/resources/aci_access_interface_override/provider.tf similarity index 100% rename from examples/resources/aci_host_path_selector/provider.tf rename to examples/resources/aci_access_interface_override/provider.tf diff --git a/examples/resources/aci_host_path_selector/resource-all-attributes.tf b/examples/resources/aci_access_interface_override/resource-all-attributes.tf similarity index 74% rename from examples/resources/aci_host_path_selector/resource-all-attributes.tf rename to examples/resources/aci_access_interface_override/resource-all-attributes.tf index 827882f46..08c7d691a 100644 --- a/examples/resources/aci_host_path_selector/resource-all-attributes.tf +++ b/examples/resources/aci_access_interface_override/resource-all-attributes.tf @@ -1,5 +1,5 @@ -resource "aci_host_path_selector" "full_example" { +resource "aci_access_interface_override" "full_example" { annotation = "annotation" description = "description_1" name = "host_path_selector" @@ -12,10 +12,10 @@ resource "aci_host_path_selector" "full_example" { target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } ] - relation_to_access_base_group = [ + relation_to_access_interface_policy_group = [ { annotation = "annotation_1" - target_dn = "uni/infra/funcprof/accportgrp-interface_policy_group" + target_dn = "uni/infra/funcprof/accportgrp-access_interface_policy_group" } ] annotations = [ diff --git a/examples/resources/aci_access_interface_override/resource.tf b/examples/resources/aci_access_interface_override/resource.tf new file mode 100644 index 000000000..7c342178b --- /dev/null +++ b/examples/resources/aci_access_interface_override/resource.tf @@ -0,0 +1,4 @@ + +resource "aci_access_interface_override" "example" { + name = "host_path_selector" +} diff --git a/examples/resources/aci_host_path_selector/resource.tf b/examples/resources/aci_host_path_selector/resource.tf deleted file mode 100644 index f32f9050d..000000000 --- a/examples/resources/aci_host_path_selector/resource.tf +++ /dev/null @@ -1,4 +0,0 @@ - -resource "aci_host_path_selector" "example" { - name = "host_path_selector" -} diff --git a/examples/resources/aci_relation_to_host_path/resource-all-attributes.tf b/examples/resources/aci_relation_to_host_path/resource-all-attributes.tf index 940071be3..5278593cd 100644 --- a/examples/resources/aci_relation_to_host_path/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_host_path/resource-all-attributes.tf @@ -1,6 +1,6 @@ -resource "aci_relation_to_host_path" "full_example_host_path_selector" { - parent_dn = aci_host_path_selector.example.id +resource "aci_relation_to_host_path" "full_example_access_interface_override" { + parent_dn = aci_access_interface_override.example.id annotation = "annotation" target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" annotations = [ diff --git a/examples/resources/aci_relation_to_host_path/resource.tf b/examples/resources/aci_relation_to_host_path/resource.tf index b8ce3c49c..3b5816c37 100644 --- a/examples/resources/aci_relation_to_host_path/resource.tf +++ b/examples/resources/aci_relation_to_host_path/resource.tf @@ -1,5 +1,5 @@ -resource "aci_relation_to_host_path" "example_host_path_selector" { - parent_dn = aci_host_path_selector.example.id +resource "aci_relation_to_host_path" "example_access_interface_override" { + parent_dn = aci_access_interface_override.example.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index 57cc4e085..eff27dcb2 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -566,10 +566,15 @@ physDomP: resource_name: "physical_domain" infraHPathS: - resource_name: "host_path_selector" + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides" + - "Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides" + sub_category: "Access Policies" + resource_name: "access_interface_override" infraRsHPathAtt: resource_name: "relation_to_host_path" + max_one_class_allowed: true infraRsPathToAccBaseGrp: - resource_name: "relation_to_access_base_group" + resource_name: "relation_to_access_interface_policy_group" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 965ef9d9c..35852857b 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -930,10 +930,6 @@ infraRsHPathAtt: target_dn: "topology/pod-1/paths-101/pathep-[eth1/1]" relation_resource_name: "host_path" static: true - - class_name: "fabricPathEp" - target_dn: "topology/pod-1/paths-101/pathep-[eth1/2]" - relation_resource_name: "host_path" - static: true infraRsPathToAccBaseGrp: parents: @@ -942,7 +938,7 @@ infraRsPathToAccBaseGrp: - "infraAccPortGrp" targets: - class_name: "infraAccPortGrp" - target_dn: "uni/infra/funcprof/accportgrp-interface_policy_group" - relation_resource_name: "access_base_group" + target_dn: "uni/infra/funcprof/accportgrp-access_interface_policy_group" + relation_resource_name: "access_interface_policy_group" static: true diff --git a/gen/testvars/infraHPathS.yaml b/gen/testvars/infraHPathS.yaml index ab5394471..f6695b83c 100644 --- a/gen/testvars/infraHPathS.yaml +++ b/gen/testvars/infraHPathS.yaml @@ -29,11 +29,8 @@ children: relation_to_host_paths: - annotation: "annotation_1" target_dn: "target_dn_0" - - - annotation: "annotation_2" - target_dn: "target_dn_1" - - relation_to_access_base_group: + deletable_child: true + relation_to_access_interface_policy_group: - annotation: "annotation_1" target_dn: "target_dn_1" deletable_child: true @@ -57,11 +54,7 @@ child_targets: target_dn: "topology/pod-1/paths-101/pathep-[eth1/1]" relation_resource_name: "host_path" static: true - - class_name: "fabricPathEp" - target_dn: "topology/pod-1/paths-101/pathep-[eth1/2]" - relation_resource_name: "host_path" - static: true - class_name: "infraAccPortGrp" - target_dn: "uni/infra/funcprof/accportgrp-interface_policy_group" - relation_resource_name: "access_base_group" + target_dn: "uni/infra/funcprof/accportgrp-access_interface_policy_group" + relation_resource_name: "access_interface_policy_group" static: true diff --git a/gen/testvars/infraRsHPathAtt.yaml b/gen/testvars/infraRsHPathAtt.yaml index fcfa77cd1..31d17b445 100644 --- a/gen/testvars/infraRsHPathAtt.yaml +++ b/gen/testvars/infraRsHPathAtt.yaml @@ -35,7 +35,7 @@ children: parents: - class_name: "infraHPathS" parent_dependency: "" - parent_dn: "aci_host_path_selector.test.id" + parent_dn: "aci_access_interface_override.test.id" class_in_parent: false target_classes: - "fabricPathEp" @@ -50,13 +50,3 @@ targets: parent_dn_key: "parent_dn" static: true properties: - - class_name: "fabricPathEp" - target_dn: "topology/pod-1/paths-101/pathep-[eth1/2]" - target_dn_ref: "aci_.test__1.id" - parent_dependency: "" - parent_dependency_dn_ref: "" - target_resource_name: "" - relation_resource_name: "host_path" - parent_dn_key: "parent_dn" - static: true - properties: diff --git a/internal/provider/data_source_aci_host_path_selector.go b/internal/provider/data_source_aci_access_interface_override.go similarity index 77% rename from internal/provider/data_source_aci_host_path_selector.go rename to internal/provider/data_source_aci_access_interface_override.go index 4048ebcd0..7ffc28cb4 100644 --- a/internal/provider/data_source_aci_host_path_selector.go +++ b/internal/provider/data_source_aci_access_interface_override.go @@ -29,21 +29,21 @@ type InfraHPathSDataSource struct { } func (d *InfraHPathSDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - tflog.Debug(ctx, "Start metadata of datasource: aci_host_path_selector") - resp.TypeName = req.ProviderTypeName + "_host_path_selector" - tflog.Debug(ctx, "End metadata of datasource: aci_host_path_selector") + tflog.Debug(ctx, "Start metadata of datasource: aci_access_interface_override") + resp.TypeName = req.ProviderTypeName + "_access_interface_override" + tflog.Debug(ctx, "End metadata of datasource: aci_access_interface_override") } func (d *InfraHPathSDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - tflog.Debug(ctx, "Start schema of datasource: aci_host_path_selector") + tflog.Debug(ctx, "Start schema of datasource: aci_access_interface_override") resp.Schema = schema.Schema{ // This description is used by the documentation generator and the language server. - MarkdownDescription: "The host_path_selector datasource for the 'infraHPathS' class", + MarkdownDescription: "The access_interface_override datasource for the 'infraHPathS' class", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the Host Path Selector object.", + MarkdownDescription: "The distinguished name (DN) of the Access Interface Override object.", }, "parent_dn": schema.StringAttribute{ Optional: true, @@ -51,19 +51,19 @@ func (d *InfraHPathSDataSource) Schema(ctx context.Context, req datasource.Schem }, "annotation": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The annotation of the Host Path Selector object.`, + MarkdownDescription: `The annotation of the Access Interface Override object.`, }, "description": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The description of the Host Path Selector object.`, + MarkdownDescription: `The description of the Access Interface Override object.`, }, "name": schema.StringAttribute{ Required: true, - MarkdownDescription: `The name of the Host Path Selector object.`, + MarkdownDescription: `The name of the Access Interface Override object.`, }, "name_alias": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The name alias of the Host Path Selector object.`, + MarkdownDescription: `The name alias of the Access Interface Override object.`, }, "owner_key": schema.StringAttribute{ Computed: true, @@ -89,14 +89,14 @@ func (d *InfraHPathSDataSource) Schema(ctx context.Context, req datasource.Schem }, }, }, - "relation_to_access_base_group": schema.SetNestedAttribute{ + "relation_to_access_interface_policy_group": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "annotation": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The annotation of the Relation To Access Base Group object.`, + MarkdownDescription: `The annotation of the Relation To Access Interface Policy Group object.`, }, "target_dn": schema.StringAttribute{ Computed: true, @@ -139,11 +139,11 @@ func (d *InfraHPathSDataSource) Schema(ctx context.Context, req datasource.Schem }, }, } - tflog.Debug(ctx, "End schema of datasource: aci_host_path_selector") + tflog.Debug(ctx, "End schema of datasource: aci_access_interface_override") } func (d *InfraHPathSDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - tflog.Debug(ctx, "Start configure of datasource: aci_host_path_selector") + tflog.Debug(ctx, "Start configure of datasource: aci_access_interface_override") // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -161,11 +161,11 @@ func (d *InfraHPathSDataSource) Configure(ctx context.Context, req datasource.Co } d.client = client - tflog.Debug(ctx, "End configure of datasource: aci_host_path_selector") + tflog.Debug(ctx, "End configure of datasource: aci_access_interface_override") } func (d *InfraHPathSDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - tflog.Debug(ctx, "Start read of datasource: aci_host_path_selector") + tflog.Debug(ctx, "Start read of datasource: aci_access_interface_override") var data *InfraHPathSResourceModel // Read Terraform configuration data into the model @@ -184,19 +184,19 @@ func (d *InfraHPathSDataSource) Read(ctx context.Context, req datasource.ReadReq // Create a copy of the Id for when not found during getAndSetInfraHPathSAttributes cachedId := data.Id.ValueString() - tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_access_interface_override with id '%s'", data.Id.ValueString())) getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, d.client, data) if data.Id.IsNull() { resp.Diagnostics.AddError( - "Failed to read aci_host_path_selector data source", - fmt.Sprintf("The aci_host_path_selector data source with id '%s' has not been found", cachedId), + "Failed to read aci_access_interface_override data source", + fmt.Sprintf("The aci_access_interface_override 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_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_access_interface_override with id '%s'", data.Id.ValueString())) } diff --git a/internal/provider/data_source_aci_host_path_selector_test.go b/internal/provider/data_source_aci_access_interface_override_test.go similarity index 56% rename from internal/provider/data_source_aci_host_path_selector_test.go rename to internal/provider/data_source_aci_access_interface_override_test.go index c641bdd36..47f5c6922 100644 --- a/internal/provider/data_source_aci_host_path_selector_test.go +++ b/internal/provider/data_source_aci_access_interface_override_test.go @@ -20,30 +20,30 @@ func TestAccDataSourceInfraHPathS(t *testing.T) { { Config: testConfigInfraHPathSDataSource, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "annotation", "annotation"), - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "description", "description_1"), - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "name_alias", "name_alias_1"), - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_key", "owner_key_1"), - resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("data.aci_access_interface_override.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("data.aci_access_interface_override.test", "description", "description_1"), + resource.TestCheckResourceAttr("data.aci_access_interface_override.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("data.aci_access_interface_override.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("data.aci_access_interface_override.test", "owner_tag", "owner_tag_1"), ), }, { Config: testConfigInfraHPathSNotExisting, - ExpectError: regexp.MustCompile("Failed to read aci_host_path_selector data source"), + ExpectError: regexp.MustCompile("Failed to read aci_access_interface_override data source"), }, }, }) } const testConfigInfraHPathSDataSource = testConfigInfraHPathSAll + ` -data "aci_host_path_selector" "test" { +data "aci_access_interface_override" "test" { name = "host_path_selector" - depends_on = [aci_host_path_selector.test] + depends_on = [aci_access_interface_override.test] } ` const testConfigInfraHPathSNotExisting = testConfigInfraHPathSAll + ` -data "aci_host_path_selector" "test" { +data "aci_access_interface_override" "test" { name = "host_path_selector_non_existing" } ` diff --git a/internal/provider/data_source_aci_relation_to_host_path_test.go b/internal/provider/data_source_aci_relation_to_host_path_test.go index 86e698ac5..f04471a87 100644 --- a/internal/provider/data_source_aci_relation_to_host_path_test.go +++ b/internal/provider/data_source_aci_relation_to_host_path_test.go @@ -35,7 +35,7 @@ func TestAccDataSourceInfraRsHPathAttWithInfraHPathS(t *testing.T) { const testConfigInfraRsHPathAttDataSourceDependencyWithInfraHPathS = testConfigInfraRsHPathAttMinDependencyWithInfraHPathS + ` data "aci_relation_to_host_path" "test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" depends_on = [aci_relation_to_host_path.test] } @@ -43,7 +43,7 @@ data "aci_relation_to_host_path" "test" { const testConfigInfraRsHPathAttNotExistingInfraHPathS = testConfigInfraRsHPathAttMinDependencyWithInfraHPathS + ` data "aci_relation_to_host_path" "test_non_existing" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]_not_existing" } ` diff --git a/internal/provider/resource_aci_host_path_selector.go b/internal/provider/resource_aci_access_interface_override.go similarity index 92% rename from internal/provider/resource_aci_host_path_selector.go rename to internal/provider/resource_aci_access_interface_override.go index 121b68970..165e40e19 100644 --- a/internal/provider/resource_aci_host_path_selector.go +++ b/internal/provider/resource_aci_access_interface_override.go @@ -53,7 +53,7 @@ type InfraHPathSResourceModel struct { OwnerKey types.String `tfsdk:"owner_key"` OwnerTag types.String `tfsdk:"owner_tag"` InfraRsHPathAtt types.Set `tfsdk:"relation_to_host_paths"` - InfraRsPathToAccBaseGrp types.Set `tfsdk:"relation_to_access_base_group"` + InfraRsPathToAccBaseGrp types.Set `tfsdk:"relation_to_access_interface_policy_group"` TagAnnotation types.Set `tfsdk:"annotations"` TagTag types.Set `tfsdk:"tags"` } @@ -177,21 +177,21 @@ func (r *InfraHPathSResource) ModifyPlan(ctx context.Context, req resource.Modif } func (r *InfraHPathSResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - tflog.Debug(ctx, "Start metadata of resource: aci_host_path_selector") - resp.TypeName = req.ProviderTypeName + "_host_path_selector" - tflog.Debug(ctx, "End metadata of resource: aci_host_path_selector") + tflog.Debug(ctx, "Start metadata of resource: aci_access_interface_override") + resp.TypeName = req.ProviderTypeName + "_access_interface_override" + tflog.Debug(ctx, "End metadata of resource: aci_access_interface_override") } func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - tflog.Debug(ctx, "Start schema of resource: aci_host_path_selector") + tflog.Debug(ctx, "Start schema of resource: aci_access_interface_override") resp.Schema = schema.Schema{ // This description is used by the documentation generator and the language server. - MarkdownDescription: "The host_path_selector resource for the 'infraHPathS' class", + MarkdownDescription: "The access_interface_override resource for the 'infraHPathS' class", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the Host Path Selector object.", + MarkdownDescription: "The distinguished name (DN) of the Access Interface Override object.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -214,7 +214,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, Default: stringdefault.StaticString(globalAnnotation), - MarkdownDescription: `The annotation of the Host Path Selector object.`, + MarkdownDescription: `The annotation of the Access Interface Override object.`, }, "description": schema.StringAttribute{ Optional: true, @@ -223,7 +223,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The description of the Host Path Selector object.`, + MarkdownDescription: `The description of the Access Interface Override object.`, }, "name": schema.StringAttribute{ Required: true, @@ -232,7 +232,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), stringplanmodifier.RequiresReplace(), }, - MarkdownDescription: `The name of the Host Path Selector object.`, + MarkdownDescription: `The name of the Access Interface Override object.`, }, "name_alias": schema.StringAttribute{ Optional: true, @@ -241,7 +241,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The name alias of the Host Path Selector object.`, + MarkdownDescription: `The name alias of the Access Interface Override object.`, }, "owner_key": schema.StringAttribute{ Optional: true, @@ -268,6 +268,9 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), }, + Validators: []validator.Set{ + setvalidator.SizeAtMost(1), + }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "annotation": schema.StringAttribute{ @@ -288,7 +291,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq }, }, }, - "relation_to_access_base_group": schema.SetNestedAttribute{ + "relation_to_access_interface_policy_group": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, Computed: true, @@ -306,7 +309,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, - MarkdownDescription: `The annotation of the Relation To Access Base Group object.`, + MarkdownDescription: `The annotation of the Relation To Access Interface Policy Group object.`, }, "target_dn": schema.StringAttribute{ Optional: true, @@ -373,11 +376,11 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq }, }, } - tflog.Debug(ctx, "End schema of resource: aci_host_path_selector") + tflog.Debug(ctx, "End schema of resource: aci_access_interface_override") } func (r *InfraHPathSResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - tflog.Debug(ctx, "Start configure of resource: aci_host_path_selector") + tflog.Debug(ctx, "Start configure of resource: aci_access_interface_override") // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -395,11 +398,11 @@ func (r *InfraHPathSResource) Configure(ctx context.Context, req resource.Config } r.client = client - tflog.Debug(ctx, "End configure of resource: aci_host_path_selector") + tflog.Debug(ctx, "End configure of resource: aci_access_interface_override") } func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - tflog.Debug(ctx, "Start create of resource: aci_host_path_selector") + tflog.Debug(ctx, "Start create of resource: aci_access_interface_override") // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *InfraHPathSResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) @@ -428,7 +431,7 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq setInfraHPathSId(ctx, data) } - tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) var infraRsHPathAttPlan, infraRsHPathAttState []InfraRsHPathAttInfraHPathSResourceModel data.InfraRsHPathAtt.ElementsAs(ctx, &infraRsHPathAttPlan, false) @@ -457,11 +460,11 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq // Save data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) } func (r *InfraHPathSResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - tflog.Debug(ctx, "Start read of resource: aci_host_path_selector") + tflog.Debug(ctx, "Start read of resource: aci_access_interface_override") var data *InfraHPathSResourceModel // Read Terraform prior state data into the model @@ -471,7 +474,7 @@ func (r *InfraHPathSResource) Read(ctx context.Context, req resource.ReadRequest return } - tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, r.client, data) @@ -483,11 +486,11 @@ func (r *InfraHPathSResource) Read(ctx context.Context, req resource.ReadRequest resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } - tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) } func (r *InfraHPathSResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - tflog.Debug(ctx, "Start update of resource: aci_host_path_selector") + tflog.Debug(ctx, "Start update of resource: aci_access_interface_override") var data *InfraHPathSResourceModel var stateData *InfraHPathSResourceModel @@ -499,7 +502,7 @@ func (r *InfraHPathSResource) Update(ctx context.Context, req resource.UpdateReq return } - tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) var infraRsHPathAttPlan, infraRsHPathAttState []InfraRsHPathAttInfraHPathSResourceModel data.InfraRsHPathAtt.ElementsAs(ctx, &infraRsHPathAttPlan, false) @@ -529,11 +532,11 @@ func (r *InfraHPathSResource) Update(ctx context.Context, req resource.UpdateReq // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) } func (r *InfraHPathSResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - tflog.Debug(ctx, "Start delete of resource: aci_host_path_selector") + tflog.Debug(ctx, "Start delete of resource: aci_access_interface_override") var data *InfraHPathSResourceModel // Read Terraform prior state data into the model @@ -543,7 +546,7 @@ func (r *InfraHPathSResource) Delete(ctx context.Context, req resource.DeleteReq return } - tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraHPathS", data.Id.ValueString()) if resp.Diagnostics.HasError() { return @@ -552,18 +555,18 @@ func (r *InfraHPathSResource) Delete(ctx context.Context, req resource.DeleteReq if resp.Diagnostics.HasError() { return } - tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) } func (r *InfraHPathSResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - tflog.Debug(ctx, "Start import state of resource: aci_host_path_selector") + tflog.Debug(ctx, "Start import state of resource: aci_access_interface_override") resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) var stateData *InfraHPathSResourceModel resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) - tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_host_path_selector with id '%s'", stateData.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_access_interface_override with id '%s'", stateData.Id.ValueString())) - tflog.Debug(ctx, "End import of state resource: aci_host_path_selector") + tflog.Debug(ctx, "End import of state resource: aci_access_interface_override") } func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraHPathSResourceModel) { diff --git a/internal/provider/resource_aci_access_interface_override_test.go b/internal/provider/resource_aci_access_interface_override_test.go new file mode 100644 index 000000000..27dd976b3 --- /dev/null +++ b/internal/provider/resource_aci_access_interface_override_test.go @@ -0,0 +1,342 @@ +// 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 TestAccResourceInfraHPathS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPathSMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPathSMinAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPathSMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPathSMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraHPathSAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraHPathSMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraHPathSReset, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_access_interface_override.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraHPathSChildren, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.0.target_dn", "uni/infra/funcprof/accportgrp-access_interface_policy_group"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.#", "1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.#", "1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.#", "2"), + ), + }, + // Update with children removed from config + { + Config: testConfigInfraHPathSChildrenRemoveFromConfig, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.0.target_dn", "uni/infra/funcprof/accportgrp-access_interface_policy_group"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.#", "1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.#", "1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraHPathSChildrenRemoveOne, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.#", "0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.#", "0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigInfraHPathSChildrenRemoveAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.#", "0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.#", "0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testChildDependencyConfigInfraHPathS = ` +` + +const testConfigInfraHPathSMinAllowExisting = ` +resource "aci_access_interface_override" "allow_test" { + name = "host_path_selector" +} +resource "aci_access_interface_override" "allow_test_2" { + name = "host_path_selector" + depends_on = [aci_access_interface_override.allow_test] +} +` + +const testConfigInfraHPathSMin = ` +resource "aci_access_interface_override" "test" { + name = "host_path_selector" +} +` + +const testConfigInfraHPathSAll = ` +resource "aci_access_interface_override" "test" { + name = "host_path_selector" + annotation = "annotation" + description = "description_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" +} +` + +const testConfigInfraHPathSReset = ` +resource "aci_access_interface_override" "test" { + name = "host_path_selector" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraHPathSChildren = testChildDependencyConfigInfraHPathS + ` +resource "aci_access_interface_override" "test" { + name = "host_path_selector" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_access_interface_policy_group = [ + { + annotation = "annotation_1" + target_dn = "uni/infra/funcprof/accportgrp-access_interface_policy_group" + }, + ] + relation_to_host_paths = [ + { + annotation = "annotation_1" + target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraHPathSChildrenRemoveFromConfig = testChildDependencyConfigInfraHPathS + ` +resource "aci_access_interface_override" "test" { + name = "host_path_selector" +} +` + +const testConfigInfraHPathSChildrenRemoveOne = testChildDependencyConfigInfraHPathS + ` +resource "aci_access_interface_override" "test" { + name = "host_path_selector" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_access_interface_policy_group = [] + relation_to_host_paths = [] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraHPathSChildrenRemoveAll = testChildDependencyConfigInfraHPathS + ` +resource "aci_access_interface_override" "test" { + name = "host_path_selector" + annotations = [] + relation_to_access_interface_policy_group = [] + relation_to_host_paths = [] + tags = [] +} +` diff --git a/internal/provider/resource_aci_host_path_selector_test.go b/internal/provider/resource_aci_host_path_selector_test.go deleted file mode 100644 index 80548ef99..000000000 --- a/internal/provider/resource_aci_host_path_selector_test.go +++ /dev/null @@ -1,357 +0,0 @@ -// 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 TestAccResourceInfraHPathS(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigInfraHPathSMinAllowExisting, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "owner_tag", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "owner_tag", ""), - ), - }, - }, - }) - - setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigInfraHPathSMinAllowExisting, - ExpectError: regexp.MustCompile("Object Already Exists"), - }, - }, - }) - - setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigInfraHPathSMinAllowExisting, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test", "owner_tag", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.allow_test_2", "owner_tag", ""), - ), - }, - }, - }) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigInfraHPathSMin, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - ), - }, - // Update with all config and verify default APIC values - { - Config: testConfigInfraHPathSAll, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "annotation"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag_1"), - ), - }, - // Update with minimum config and verify config is unchanged - { - Config: testConfigInfraHPathSMin, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag_1"), - ), - }, - // Update with empty strings config or default value - { - Config: testConfigInfraHPathSReset, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - ), - }, - // Import testing - { - ResourceName: "aci_host_path_selector.test", - ImportState: true, - ImportStateVerify: true, - }, - // Update with children - { - Config: testConfigInfraHPathSChildren, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "test_value"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.target_dn", "uni/infra/funcprof/accportgrp-interface_policy_group"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.annotation", "annotation_2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.target_dn", "topology/pod-1/paths-101/pathep-[eth1/2]"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "test_value"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "2"), - ), - }, - // Update with children removed from config - { - Config: testConfigInfraHPathSChildrenRemoveFromConfig, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "test_value"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.0.target_dn", "uni/infra/funcprof/accportgrp-interface_policy_group"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.annotation", "annotation_2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.1.target_dn", "topology/pod-1/paths-101/pathep-[eth1/2]"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "test_value"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "2"), - ), - }, - // Update with children first child removed - { - Config: testConfigInfraHPathSChildrenRemoveOne, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "test_value"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "0"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.annotation", "annotation_2"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/2]"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_1"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "test_value"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "1"), - ), - }, - // Update with all children removed - { - Config: testConfigInfraHPathSChildrenRemoveAll, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "0"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_access_base_group.#", "0"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "relation_to_host_paths.#", "0"), - resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "0"), - ), - }, - }, - }) -} - -const testChildDependencyConfigInfraHPathS = ` -` - -const testConfigInfraHPathSMinAllowExisting = ` -resource "aci_host_path_selector" "allow_test" { - name = "host_path_selector" -} -resource "aci_host_path_selector" "allow_test_2" { - name = "host_path_selector" - depends_on = [aci_host_path_selector.allow_test] -} -` - -const testConfigInfraHPathSMin = ` -resource "aci_host_path_selector" "test" { - name = "host_path_selector" -} -` - -const testConfigInfraHPathSAll = ` -resource "aci_host_path_selector" "test" { - name = "host_path_selector" - annotation = "annotation" - description = "description_1" - name_alias = "name_alias_1" - owner_key = "owner_key_1" - owner_tag = "owner_tag_1" -} -` - -const testConfigInfraHPathSReset = ` -resource "aci_host_path_selector" "test" { - name = "host_path_selector" - annotation = "orchestrator:terraform" - description = "" - name_alias = "" - owner_key = "" - owner_tag = "" -} -` -const testConfigInfraHPathSChildren = testChildDependencyConfigInfraHPathS + ` -resource "aci_host_path_selector" "test" { - name = "host_path_selector" - annotations = [ - { - key = "key_0" - value = "value_1" - }, - { - key = "key_1" - value = "test_value" - }, - ] - relation_to_access_base_group = [ - { - annotation = "annotation_1" - target_dn = "uni/infra/funcprof/accportgrp-interface_policy_group" - }, - ] - relation_to_host_paths = [ - { - annotation = "annotation_1" - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - }, - { - annotation = "annotation_2" - target_dn = "topology/pod-1/paths-101/pathep-[eth1/2]" - }, - ] - tags = [ - { - key = "key_0" - value = "value_1" - }, - { - key = "key_1" - value = "test_value" - }, - ] -} -` - -const testConfigInfraHPathSChildrenRemoveFromConfig = testChildDependencyConfigInfraHPathS + ` -resource "aci_host_path_selector" "test" { - name = "host_path_selector" -} -` - -const testConfigInfraHPathSChildrenRemoveOne = testChildDependencyConfigInfraHPathS + ` -resource "aci_host_path_selector" "test" { - name = "host_path_selector" - annotations = [ - { - key = "key_1" - value = "test_value" - }, - ] - relation_to_access_base_group = [] - relation_to_host_paths = [ - { - annotation = "annotation_2" - target_dn = "topology/pod-1/paths-101/pathep-[eth1/2]" - }, - ] - tags = [ - { - key = "key_1" - value = "test_value" - }, - ] -} -` - -const testConfigInfraHPathSChildrenRemoveAll = testChildDependencyConfigInfraHPathS + ` -resource "aci_host_path_selector" "test" { - name = "host_path_selector" - annotations = [] - relation_to_access_base_group = [] - relation_to_host_paths = [] - tags = [] -} -` diff --git a/internal/provider/resource_aci_relation_to_host_path_test.go b/internal/provider/resource_aci_relation_to_host_path_test.go index aaae01dd3..341544129 100644 --- a/internal/provider/resource_aci_relation_to_host_path_test.go +++ b/internal/provider/resource_aci_relation_to_host_path_test.go @@ -179,11 +179,11 @@ const testDependencyConfigInfraRsHPathAtt = ` const testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` resource "aci_relation_to_host_path" "allow_test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } resource "aci_relation_to_host_path" "allow_test_2" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" depends_on = [aci_relation_to_host_path.allow_test] } @@ -191,14 +191,14 @@ resource "aci_relation_to_host_path" "allow_test_2" { const testConfigInfraRsHPathAttMinDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` resource "aci_relation_to_host_path" "test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } ` const testConfigInfraRsHPathAttAllDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` resource "aci_relation_to_host_path" "test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" annotation = "annotation" } @@ -206,14 +206,14 @@ resource "aci_relation_to_host_path" "test" { const testConfigInfraRsHPathAttResetDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` resource "aci_relation_to_host_path" "test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" annotation = "orchestrator:terraform" } ` const testConfigInfraRsHPathAttChildrenDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` resource "aci_relation_to_host_path" "test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" annotations = [ { @@ -240,14 +240,14 @@ resource "aci_relation_to_host_path" "test" { const testConfigInfraRsHPathAttChildrenRemoveFromConfigDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` resource "aci_relation_to_host_path" "test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" } ` const testConfigInfraRsHPathAttChildrenRemoveOneDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` resource "aci_relation_to_host_path" "test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" annotations = [ { @@ -266,7 +266,7 @@ resource "aci_relation_to_host_path" "test" { const testConfigInfraRsHPathAttChildrenRemoveAllDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` resource "aci_relation_to_host_path" "test" { - parent_dn = aci_host_path_selector.test.id + parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" annotations = [] tags = [] From 96bb856a76f4800acbb5a89105c70c3e97c0e4d2 Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Tue, 6 Aug 2024 10:25:26 -0400 Subject: [PATCH 09/11] [ignore] Add removed EPGs related config in definitions. Regenerate all files after Rebase. --- .../data-sources/access_interface_override.md | 4 +- .../relation_to_consumed_contract.md | 5 +++ docs/data-sources/relation_to_host_path.md | 10 +++-- .../relation_to_imported_contract.md | 5 +++ .../relation_to_intra_epg_contract.md | 5 +++ .../relation_to_provided_contract.md | 5 +++ docs/resources/access_interface_override.md | 4 +- .../relation_to_consumed_contract.md | 28 +++++++++++++- docs/resources/relation_to_contract_master.md | 4 +- docs/resources/relation_to_host_path.md | 6 ++- .../relation_to_imported_contract.md | 28 +++++++++++++- .../relation_to_intra_epg_contract.md | 27 +++++++++++++- .../relation_to_provided_contract.md | 29 ++++++++++++++- .../data-source.tf | 5 +++ .../data-source.tf | 5 +++ .../data-source.tf | 5 +++ .../data-source.tf | 5 +++ .../resource-all-attributes.tf | 19 ++++++++++ .../resource.tf | 5 +++ .../resource-all-attributes.tf | 19 ++++++++++ .../resource.tf | 5 +++ .../resource-all-attributes.tf | 18 +++++++++ .../resource.tf | 5 +++ .../resource-all-attributes.tf | 20 ++++++++++ .../resource.tf | 5 +++ gen/definitions/classes.yaml | 16 +++++++- gen/definitions/properties.yaml | 26 +++++++++++++ gen/testvars/fvRsCons.yaml | 4 ++ gen/testvars/fvRsConsIf.yaml | 4 ++ gen/testvars/fvRsIntraEpg.yaml | 4 ++ gen/testvars/fvRsProv.yaml | 4 ++ gen/testvars/fvRsSecInherited.yaml | 6 +++ ...urce_aci_access_interface_override_test.go | 2 +- ..._aci_relation_to_consumed_contract_test.go | 36 ++++++++++++++++++ ...ce_aci_relation_to_contract_master_test.go | 21 +++++++++++ ...a_source_aci_relation_to_host_path_test.go | 2 +- ..._aci_relation_to_imported_contract_test.go | 36 ++++++++++++++++++ ...aci_relation_to_intra_epg_contract_test.go | 35 ++++++++++++++++++ ..._aci_relation_to_provided_contract_test.go | 37 +++++++++++++++++++ 39 files changed, 486 insertions(+), 23 deletions(-) diff --git a/docs/data-sources/access_interface_override.md b/docs/data-sources/access_interface_override.md index 45470d1ec..c18a68bb2 100644 --- a/docs/data-sources/access_interface_override.md +++ b/docs/data-sources/access_interface_override.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_access_interface_override" sidebar_current: "docs-aci-data-source-aci_access_interface_override" description: |- - Data source for Access Interface Override + Data source for ACI Access Interface Override --- # aci_access_interface_override # -Data source for Access Interface Override +Data source for ACI Access Interface Override ## API Information ## diff --git a/docs/data-sources/relation_to_consumed_contract.md b/docs/data-sources/relation_to_consumed_contract.md index 5a654e16c..dbcbc54d0 100644 --- a/docs/data-sources/relation_to_consumed_contract.md +++ b/docs/data-sources/relation_to_consumed_contract.md @@ -39,6 +39,11 @@ Data source for ACI Relation To Consumed Contract ```hcl +data "aci_relation_to_consumed_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + data "aci_relation_to_consumed_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/docs/data-sources/relation_to_host_path.md b/docs/data-sources/relation_to_host_path.md index 4011ca55b..29bd29c03 100644 --- a/docs/data-sources/relation_to_host_path.md +++ b/docs/data-sources/relation_to_host_path.md @@ -2,17 +2,17 @@ # 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: "Generic" +subcategory: "Access Policies" layout: "aci" page_title: "ACI: aci_relation_to_host_path" sidebar_current: "docs-aci-data-source-aci_relation_to_host_path" description: |- - Data source for Relation To Host Path + Data source for ACI Relation To Host Path --- # aci_relation_to_host_path # -Data source for Relation To Host Path +Data source for ACI Relation To Host Path ## API Information ## @@ -24,7 +24,9 @@ Data source for Relation To Host Path ## GUI Information ## -* Location: `Generic` +* Locations: + - `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides` + - `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides` ## Example Usage ## diff --git a/docs/data-sources/relation_to_imported_contract.md b/docs/data-sources/relation_to_imported_contract.md index 78ea561a5..b625ba581 100644 --- a/docs/data-sources/relation_to_imported_contract.md +++ b/docs/data-sources/relation_to_imported_contract.md @@ -39,6 +39,11 @@ Data source for ACI Relation To Imported Contract ```hcl +data "aci_relation_to_imported_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + imported_contract_name = aci_imported_contract.example.name +} + data "aci_relation_to_imported_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id imported_contract_name = aci_imported_contract.example.name diff --git a/docs/data-sources/relation_to_intra_epg_contract.md b/docs/data-sources/relation_to_intra_epg_contract.md index 5fa95b6da..7d25e4511 100644 --- a/docs/data-sources/relation_to_intra_epg_contract.md +++ b/docs/data-sources/relation_to_intra_epg_contract.md @@ -37,6 +37,11 @@ Data source for ACI Relation To Intra EPG Contract ```hcl +data "aci_relation_to_intra_epg_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + data "aci_relation_to_intra_epg_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/docs/data-sources/relation_to_provided_contract.md b/docs/data-sources/relation_to_provided_contract.md index c008e5a55..9e385f3dc 100644 --- a/docs/data-sources/relation_to_provided_contract.md +++ b/docs/data-sources/relation_to_provided_contract.md @@ -39,6 +39,11 @@ Data source for ACI Relation To Provided Contract ```hcl +data "aci_relation_to_provided_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + data "aci_relation_to_provided_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/docs/resources/access_interface_override.md b/docs/resources/access_interface_override.md index dea3c42a2..9f124b902 100644 --- a/docs/resources/access_interface_override.md +++ b/docs/resources/access_interface_override.md @@ -108,7 +108,7 @@ All examples for the Access Interface Override resource can be found in the [exa * `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. -* `relation_to_host_paths` - (list) A list of Relation To Host Paths (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)) which can be configured using the [aci_](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/) resource. +* `relation_to_host_paths` - (list) A list of Relation To Host Paths (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)). - Max Items: 1 #### Required #### @@ -120,7 +120,7 @@ All examples for the Access Interface Override resource can be found in the [exa * `annotation` (annotation) - (string) The annotation of the Relation To Host Path object. - Default: `orchestrator:terraform` -* `relation_to_access_interface_policy_group` - (list) A list of Relation To Access Interface Policy Group (ACI object [infraRsPathToAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsPathToAccBaseGrp/overview)) pointing to (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)) which can be configured using the [aci_](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/) resource. +* `relation_to_access_interface_policy_group` - (list) A list of Relation To Access Interface Policy Group (ACI object [infraRsPathToAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsPathToAccBaseGrp/overview)) pointing to (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)). - Max Items: 1 diff --git a/docs/resources/relation_to_consumed_contract.md b/docs/resources/relation_to_consumed_contract.md index a647a7f6c..cf07494bf 100644 --- a/docs/resources/relation_to_consumed_contract.md +++ b/docs/resources/relation_to_consumed_contract.md @@ -43,6 +43,11 @@ The configuration snippet below creates a Relation To Consumed Contract with onl ```hcl +resource "aci_relation_to_consumed_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + resource "aci_relation_to_consumed_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name @@ -55,6 +60,25 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl +resource "aci_relation_to_consumed_contract" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + priority = "level1" + contract_name = aci_contract.example.name + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + resource "aci_relation_to_consumed_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" @@ -138,7 +162,7 @@ All examples for the Relation To Consumed Contract resource can be found in the An existing Relation To Consumed Contract 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_relation_to_consumed_contract.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rscons-{tnVzBrCPName} +terraform import aci_relation_to_consumed_contract.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rscons-{tnVzBrCPName} ``` Starting in Terraform version 1.5, an existing Relation To Consumed Contract can be imported @@ -147,6 +171,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rscons-{tnVzBrCPName}" - to = aci_relation_to_consumed_contract.example_endpoint_security_group + to = aci_relation_to_consumed_contract.example_application_epg } ``` diff --git a/docs/resources/relation_to_contract_master.md b/docs/resources/relation_to_contract_master.md index f07784c60..61c02cf34 100644 --- a/docs/resources/relation_to_contract_master.md +++ b/docs/resources/relation_to_contract_master.md @@ -157,7 +157,7 @@ All examples for the Relation To Contract Master resource can be found in the [e An existing Relation To Contract Master 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_relation_to_contract_master.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rssecInherited-[{tDn}] +terraform import aci_relation_to_contract_master.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rssecInherited-[{tDn}] ``` Starting in Terraform version 1.5, an existing Relation To Contract Master can be imported @@ -166,6 +166,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rssecInherited-[{tDn}]" - to = aci_relation_to_contract_master.example_endpoint_security_group + to = aci_relation_to_contract_master.example_application_epg } ``` diff --git a/docs/resources/relation_to_host_path.md b/docs/resources/relation_to_host_path.md index e8eed4472..87014d364 100644 --- a/docs/resources/relation_to_host_path.md +++ b/docs/resources/relation_to_host_path.md @@ -2,7 +2,7 @@ # 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: "Generic" +subcategory: "Access Policies" layout: "aci" page_title: "ACI: aci_relation_to_host_path" sidebar_current: "docs-aci-resource-aci_relation_to_host_path" @@ -26,7 +26,9 @@ Manages ACI Relation To Host Path ## GUI Information ## -* Location: `Generic` +* Locations: + - `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides` + - `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides` ## Example Usage ## diff --git a/docs/resources/relation_to_imported_contract.md b/docs/resources/relation_to_imported_contract.md index e81d249aa..5003b7b3b 100644 --- a/docs/resources/relation_to_imported_contract.md +++ b/docs/resources/relation_to_imported_contract.md @@ -43,6 +43,11 @@ The configuration snippet below creates a Relation To Imported Contract with onl ```hcl +resource "aci_relation_to_imported_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + imported_contract_name = aci_imported_contract.example.name +} + resource "aci_relation_to_imported_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id imported_contract_name = aci_imported_contract.example.name @@ -55,6 +60,25 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl +resource "aci_relation_to_imported_contract" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + priority = "level1" + imported_contract_name = aci_imported_contract.example.name + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + resource "aci_relation_to_imported_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" @@ -138,7 +162,7 @@ All examples for the Relation To Imported Contract resource can be found in the An existing Relation To Imported Contract 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_relation_to_imported_contract.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rsconsIf-{tnVzCPIfName} +terraform import aci_relation_to_imported_contract.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rsconsIf-{tnVzCPIfName} ``` Starting in Terraform version 1.5, an existing Relation To Imported Contract can be imported @@ -147,6 +171,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rsconsIf-{tnVzCPIfName}" - to = aci_relation_to_imported_contract.example_endpoint_security_group + to = aci_relation_to_imported_contract.example_application_epg } ``` diff --git a/docs/resources/relation_to_intra_epg_contract.md b/docs/resources/relation_to_intra_epg_contract.md index 8fe70ab71..bd2cef540 100644 --- a/docs/resources/relation_to_intra_epg_contract.md +++ b/docs/resources/relation_to_intra_epg_contract.md @@ -41,6 +41,11 @@ The configuration snippet below creates a Relation To Intra EPG Contract with on ```hcl +resource "aci_relation_to_intra_epg_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + resource "aci_relation_to_intra_epg_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name @@ -53,6 +58,24 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl +resource "aci_relation_to_intra_epg_contract" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + contract_name = aci_contract.example.name + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + resource "aci_relation_to_intra_epg_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" @@ -132,7 +155,7 @@ All examples for the Relation To Intra EPG Contract resource can be found in the An existing Relation To Intra EPG Contract 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_relation_to_intra_epg_contract.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rsintraEpg-{tnVzBrCPName} +terraform import aci_relation_to_intra_epg_contract.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rsintraEpg-{tnVzBrCPName} ``` Starting in Terraform version 1.5, an existing Relation To Intra EPG Contract can be imported @@ -141,6 +164,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rsintraEpg-{tnVzBrCPName}" - to = aci_relation_to_intra_epg_contract.example_endpoint_security_group + to = aci_relation_to_intra_epg_contract.example_application_epg } ``` diff --git a/docs/resources/relation_to_provided_contract.md b/docs/resources/relation_to_provided_contract.md index a1d07f041..de5b27199 100644 --- a/docs/resources/relation_to_provided_contract.md +++ b/docs/resources/relation_to_provided_contract.md @@ -43,6 +43,11 @@ The configuration snippet below creates a Relation To Provided Contract with onl ```hcl +resource "aci_relation_to_provided_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + resource "aci_relation_to_provided_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name @@ -55,6 +60,26 @@ The configuration snippet below shows all possible attributes of the Relation To ```hcl +resource "aci_relation_to_provided_contract" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + match_criteria = "All" + priority = "level1" + contract_name = aci_contract.example.name + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + resource "aci_relation_to_provided_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" @@ -142,7 +167,7 @@ All examples for the Relation To Provided Contract resource can be found in the An existing Relation To Provided Contract 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_relation_to_provided_contract.example_endpoint_security_group uni/tn-{name}/ap-{name}/epg-{name}/rsprov-{tnVzBrCPName} +terraform import aci_relation_to_provided_contract.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/rsprov-{tnVzBrCPName} ``` Starting in Terraform version 1.5, an existing Relation To Provided Contract can be imported @@ -151,6 +176,6 @@ using [import blocks](https://developer.hashicorp.com/terraform/language/import) ``` import { id = "uni/tn-{name}/ap-{name}/epg-{name}/rsprov-{tnVzBrCPName}" - to = aci_relation_to_provided_contract.example_endpoint_security_group + to = aci_relation_to_provided_contract.example_application_epg } ``` diff --git a/examples/data-sources/aci_relation_to_consumed_contract/data-source.tf b/examples/data-sources/aci_relation_to_consumed_contract/data-source.tf index 17035cdc8..fa20f256d 100644 --- a/examples/data-sources/aci_relation_to_consumed_contract/data-source.tf +++ b/examples/data-sources/aci_relation_to_consumed_contract/data-source.tf @@ -1,4 +1,9 @@ +data "aci_relation_to_consumed_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + data "aci_relation_to_consumed_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/data-sources/aci_relation_to_imported_contract/data-source.tf b/examples/data-sources/aci_relation_to_imported_contract/data-source.tf index e14328780..79a46318b 100644 --- a/examples/data-sources/aci_relation_to_imported_contract/data-source.tf +++ b/examples/data-sources/aci_relation_to_imported_contract/data-source.tf @@ -1,4 +1,9 @@ +data "aci_relation_to_imported_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + imported_contract_name = aci_imported_contract.example.name +} + data "aci_relation_to_imported_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id imported_contract_name = aci_imported_contract.example.name diff --git a/examples/data-sources/aci_relation_to_intra_epg_contract/data-source.tf b/examples/data-sources/aci_relation_to_intra_epg_contract/data-source.tf index f376bcdb7..5f68b8bb6 100644 --- a/examples/data-sources/aci_relation_to_intra_epg_contract/data-source.tf +++ b/examples/data-sources/aci_relation_to_intra_epg_contract/data-source.tf @@ -1,4 +1,9 @@ +data "aci_relation_to_intra_epg_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + data "aci_relation_to_intra_epg_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/data-sources/aci_relation_to_provided_contract/data-source.tf b/examples/data-sources/aci_relation_to_provided_contract/data-source.tf index 10285f243..3d1435998 100644 --- a/examples/data-sources/aci_relation_to_provided_contract/data-source.tf +++ b/examples/data-sources/aci_relation_to_provided_contract/data-source.tf @@ -1,4 +1,9 @@ +data "aci_relation_to_provided_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + data "aci_relation_to_provided_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/resources/aci_relation_to_consumed_contract/resource-all-attributes.tf b/examples/resources/aci_relation_to_consumed_contract/resource-all-attributes.tf index 417565166..31e99c329 100644 --- a/examples/resources/aci_relation_to_consumed_contract/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_consumed_contract/resource-all-attributes.tf @@ -1,4 +1,23 @@ +resource "aci_relation_to_consumed_contract" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + priority = "level1" + contract_name = aci_contract.example.name + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + resource "aci_relation_to_consumed_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" diff --git a/examples/resources/aci_relation_to_consumed_contract/resource.tf b/examples/resources/aci_relation_to_consumed_contract/resource.tf index 5f12d8de7..8bc891d2f 100644 --- a/examples/resources/aci_relation_to_consumed_contract/resource.tf +++ b/examples/resources/aci_relation_to_consumed_contract/resource.tf @@ -1,4 +1,9 @@ +resource "aci_relation_to_consumed_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + resource "aci_relation_to_consumed_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/resources/aci_relation_to_imported_contract/resource-all-attributes.tf b/examples/resources/aci_relation_to_imported_contract/resource-all-attributes.tf index b0940f894..e18cafd6c 100644 --- a/examples/resources/aci_relation_to_imported_contract/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_imported_contract/resource-all-attributes.tf @@ -1,4 +1,23 @@ +resource "aci_relation_to_imported_contract" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + priority = "level1" + imported_contract_name = aci_imported_contract.example.name + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + resource "aci_relation_to_imported_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" diff --git a/examples/resources/aci_relation_to_imported_contract/resource.tf b/examples/resources/aci_relation_to_imported_contract/resource.tf index 018bd948f..c8ff249c4 100644 --- a/examples/resources/aci_relation_to_imported_contract/resource.tf +++ b/examples/resources/aci_relation_to_imported_contract/resource.tf @@ -1,4 +1,9 @@ +resource "aci_relation_to_imported_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + imported_contract_name = aci_imported_contract.example.name +} + resource "aci_relation_to_imported_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id imported_contract_name = aci_imported_contract.example.name diff --git a/examples/resources/aci_relation_to_intra_epg_contract/resource-all-attributes.tf b/examples/resources/aci_relation_to_intra_epg_contract/resource-all-attributes.tf index f9e32ba29..bc6161c18 100644 --- a/examples/resources/aci_relation_to_intra_epg_contract/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_intra_epg_contract/resource-all-attributes.tf @@ -1,4 +1,22 @@ +resource "aci_relation_to_intra_epg_contract" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + contract_name = aci_contract.example.name + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + resource "aci_relation_to_intra_epg_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" diff --git a/examples/resources/aci_relation_to_intra_epg_contract/resource.tf b/examples/resources/aci_relation_to_intra_epg_contract/resource.tf index e9f7a1e1c..cef4e5b71 100644 --- a/examples/resources/aci_relation_to_intra_epg_contract/resource.tf +++ b/examples/resources/aci_relation_to_intra_epg_contract/resource.tf @@ -1,4 +1,9 @@ +resource "aci_relation_to_intra_epg_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + resource "aci_relation_to_intra_epg_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/examples/resources/aci_relation_to_provided_contract/resource-all-attributes.tf b/examples/resources/aci_relation_to_provided_contract/resource-all-attributes.tf index 1a7273859..bed3f2f79 100644 --- a/examples/resources/aci_relation_to_provided_contract/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_provided_contract/resource-all-attributes.tf @@ -1,4 +1,24 @@ +resource "aci_relation_to_provided_contract" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + match_criteria = "All" + priority = "level1" + contract_name = aci_contract.example.name + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + resource "aci_relation_to_provided_contract" "full_example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id annotation = "annotation" diff --git a/examples/resources/aci_relation_to_provided_contract/resource.tf b/examples/resources/aci_relation_to_provided_contract/resource.tf index e23fb09ae..d4fba1dba 100644 --- a/examples/resources/aci_relation_to_provided_contract/resource.tf +++ b/examples/resources/aci_relation_to_provided_contract/resource.tf @@ -1,4 +1,9 @@ +resource "aci_relation_to_provided_contract" "example_application_epg" { + parent_dn = aci_application_epg.example.id + contract_name = aci_contract.example.name +} + resource "aci_relation_to_provided_contract" "example_endpoint_security_group" { parent_dn = aci_endpoint_security_group.example.id contract_name = aci_contract.example.name diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index eff27dcb2..495a5ee47 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -406,6 +406,7 @@ fvRsScope: fvRsCons: resource_name: "relation_to_consumed_contract" example_classes: + - "fvAEPg" - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rscons-{tnVzBrCPName}" @@ -423,6 +424,7 @@ fvRsCons: fvRsProv: resource_name: "relation_to_provided_contract" example_classes: + - "fvAEPg" - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rsprov-{tnVzBrCPName}" @@ -440,6 +442,7 @@ fvRsProv: fvRsConsIf: resource_name: "relation_to_imported_contract" example_classes: + - "fvAEPg" - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rsconsIf-{tnVzCPIfName}" @@ -472,7 +475,8 @@ fvRsProtBy: fvRsIntraEpg: resource_name: "relation_to_intra_epg_contract" example_classes: - - "fvESg" + - "fvAEPg" + - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rsintraEpg-{tnVzBrCPName}" - "uni/tn-{name}/ap-{name}/esg-{name}/rsintraEpg-{tnVzBrCPName}" @@ -487,8 +491,10 @@ fvRsIntraEpg: fvRsSecInherited: resource_name: "relation_to_contract_master" example_classes: + - "fvAEPg" - "fvESg" relationship_classes: + - "fvAEPg" - "fvESg" dn_formats: - "uni/tn-{name}/ap-{name}/epg-{name}/rssecInherited-[{tDn}]" @@ -573,8 +579,16 @@ infraHPathS: resource_name: "access_interface_override" infraRsHPathAtt: + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides" + - "Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides" + sub_category: "Access Policies" resource_name: "relation_to_host_path" max_one_class_allowed: true infraRsPathToAccBaseGrp: + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides" + - "Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides" + sub_category: "Access Policies" resource_name: "relation_to_access_interface_policy_group" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 35852857b..e0b4ba1c6 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -405,6 +405,8 @@ fvRsCons: parents: - class_name: "fvESg" parent_dependency: "fvAp" + - class_name: "fvAEPg" + parent_dependency: "fvAp" fvRsProv: ignores: @@ -412,11 +414,15 @@ fvRsProv: parents: - class_name: "fvESg" parent_dependency: "fvAp" + - class_name: "fvAEPg" + parent_dependency: "fvAp" fvRsConsIf: parents: - class_name: "fvESg" parent_dependency: "fvAp" + - class_name: "fvAEPg" + parent_dependency: "fvAp" fvRsProtBy: parents: @@ -433,9 +439,15 @@ fvRsIntraEpg: parents: - class_name: "fvESg" parent_dependency: "fvAp" + - class_name: "fvAEPg" + parent_dependency: "fvAp" fvRsSecInherited: parents: + - class_name: "fvAEPg" + parent_dependency: "fvAp" + target_classes: + - "fvAEPg" - class_name: "fvESg" parent_dependency: "fvAp" target_classes: @@ -455,6 +467,20 @@ fvRsSecInherited: relation_resource_name: "contract_master" properties: name: "esg_1" + - class_name: "fvAEPg" + parent_dependency: "fvAp" + overwrite_parent_dn_key: "application_profile_dn" + target_dn: "uni/tn-test_tenant/ap-test_ap/epg-epg_2" + relation_resource_name: "contract_master" + properties: + name: "epg_2" + - class_name: "fvAEPg" + parent_dependency: "fvAp" + overwrite_parent_dn_key: "application_profile_dn" + target_dn: "uni/tn-test_tenant/ap-test_ap/epg-epg_3" + relation_resource_name: "contract_master" + properties: + name: "epg_3" fvCrtrn: overwrites: diff --git a/gen/testvars/fvRsCons.yaml b/gen/testvars/fvRsCons.yaml index 889ac3560..a96cb3cb9 100644 --- a/gen/testvars/fvRsCons.yaml +++ b/gen/testvars/fvRsCons.yaml @@ -35,6 +35,10 @@ children: value: "test_value" parents: + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dn: "aci_application_epg.test.id" + class_in_parent: false - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/fvRsConsIf.yaml b/gen/testvars/fvRsConsIf.yaml index 6f6604474..ea9e6798d 100644 --- a/gen/testvars/fvRsConsIf.yaml +++ b/gen/testvars/fvRsConsIf.yaml @@ -35,6 +35,10 @@ children: value: "test_value" parents: + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dn: "aci_application_epg.test.id" + class_in_parent: false - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/fvRsIntraEpg.yaml b/gen/testvars/fvRsIntraEpg.yaml index 092839858..50e6d6792 100644 --- a/gen/testvars/fvRsIntraEpg.yaml +++ b/gen/testvars/fvRsIntraEpg.yaml @@ -33,6 +33,10 @@ children: value: "test_value" parents: + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dn: "aci_application_epg.test.id" + class_in_parent: false - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/fvRsProv.yaml b/gen/testvars/fvRsProv.yaml index 7cc0eeb9d..ca0aaba9c 100644 --- a/gen/testvars/fvRsProv.yaml +++ b/gen/testvars/fvRsProv.yaml @@ -37,6 +37,10 @@ children: value: "test_value" parents: + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dn: "aci_application_epg.test.id" + class_in_parent: false - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/gen/testvars/fvRsSecInherited.yaml b/gen/testvars/fvRsSecInherited.yaml index 1bb8350d7..1da67d6d7 100644 --- a/gen/testvars/fvRsSecInherited.yaml +++ b/gen/testvars/fvRsSecInherited.yaml @@ -33,6 +33,12 @@ children: value: "test_value" parents: + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dn: "aci_application_epg.test.id" + class_in_parent: false + target_classes: + - "fvAEPg" - class_name: "fvESg" parent_dependency: "fvAp" parent_dn: "aci_endpoint_security_group.test.id" diff --git a/internal/provider/data_source_aci_access_interface_override_test.go b/internal/provider/data_source_aci_access_interface_override_test.go index 47f5c6922..111cf3ea2 100644 --- a/internal/provider/data_source_aci_access_interface_override_test.go +++ b/internal/provider/data_source_aci_access_interface_override_test.go @@ -43,7 +43,7 @@ data "aci_access_interface_override" "test" { ` const testConfigInfraHPathSNotExisting = testConfigInfraHPathSAll + ` -data "aci_access_interface_override" "test" { +data "aci_access_interface_override" "test_non_existing" { name = "host_path_selector_non_existing" } ` diff --git a/internal/provider/data_source_aci_relation_to_consumed_contract_test.go b/internal/provider/data_source_aci_relation_to_consumed_contract_test.go index cddef022a..15cab183f 100644 --- a/internal/provider/data_source_aci_relation_to_consumed_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_consumed_contract_test.go @@ -11,6 +11,28 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) +func TestAccDataSourceFvRsConsWithFvAEPg(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvRsConsDataSourceDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_to_consumed_contract.test", "contract_name", "test_tn_vz_br_cp_name"), + resource.TestCheckResourceAttr("data.aci_relation_to_consumed_contract.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_relation_to_consumed_contract.test", "priority", "unspecified"), + ), + }, + { + Config: testConfigFvRsConsNotExistingFvAEPg, + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_consumed_contract data source"), + }, + }, + }) +} func TestAccDataSourceFvRsConsWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -34,6 +56,20 @@ func TestAccDataSourceFvRsConsWithFvESg(t *testing.T) { }) } +const testConfigFvRsConsDataSourceDependencyWithFvAEPg = testConfigFvRsConsMinDependencyWithFvAEPg + ` +data "aci_relation_to_consumed_contract" "test" { + parent_dn = aci_application_epg.test.id + contract_name = "test_tn_vz_br_cp_name" + depends_on = [aci_relation_to_consumed_contract.test] +} +` + +const testConfigFvRsConsNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +data "aci_relation_to_consumed_contract" "test_non_existing" { + parent_dn = aci_application_epg.test.id + contract_name = "non_existing_tn_vz_br_cp_name" +} +` const testConfigFvRsConsDataSourceDependencyWithFvESg = testConfigFvRsConsMinDependencyWithFvESg + ` data "aci_relation_to_consumed_contract" "test" { parent_dn = aci_endpoint_security_group.test.id diff --git a/internal/provider/data_source_aci_relation_to_contract_master_test.go b/internal/provider/data_source_aci_relation_to_contract_master_test.go index 951416b4b..af13936d4 100644 --- a/internal/provider/data_source_aci_relation_to_contract_master_test.go +++ b/internal/provider/data_source_aci_relation_to_contract_master_test.go @@ -11,6 +11,27 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) +func TestAccDataSourceFvRsSecInheritedWithFvAEPg(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvRsSecInheritedDataSourceDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_to_contract_master.test", "target_dn", "uni/tn-test_tenant/ap-test_ap/epg-epg_2"), + resource.TestCheckResourceAttr("data.aci_relation_to_contract_master.test", "annotation", "orchestrator:terraform"), + ), + }, + { + Config: testConfigFvRsSecInheritedNotExistingFvAEPg, + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_contract_master data source"), + }, + }, + }) +} func TestAccDataSourceFvRsSecInheritedWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ diff --git a/internal/provider/data_source_aci_relation_to_host_path_test.go b/internal/provider/data_source_aci_relation_to_host_path_test.go index f04471a87..c30cc1005 100644 --- a/internal/provider/data_source_aci_relation_to_host_path_test.go +++ b/internal/provider/data_source_aci_relation_to_host_path_test.go @@ -41,7 +41,7 @@ data "aci_relation_to_host_path" "test" { } ` -const testConfigInfraRsHPathAttNotExistingInfraHPathS = testConfigInfraRsHPathAttMinDependencyWithInfraHPathS + ` +const testConfigInfraRsHPathAttNotExistingInfraHPathS = testConfigInfraHPathSMin + ` data "aci_relation_to_host_path" "test_non_existing" { parent_dn = aci_access_interface_override.test.id target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]_not_existing" diff --git a/internal/provider/data_source_aci_relation_to_imported_contract_test.go b/internal/provider/data_source_aci_relation_to_imported_contract_test.go index ef04cabac..a63066e2c 100644 --- a/internal/provider/data_source_aci_relation_to_imported_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_imported_contract_test.go @@ -11,6 +11,28 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) +func TestAccDataSourceFvRsConsIfWithFvAEPg(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvRsConsIfDataSourceDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_to_imported_contract.test", "imported_contract_name", "test_tn_vz_cp_if_name"), + resource.TestCheckResourceAttr("data.aci_relation_to_imported_contract.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_relation_to_imported_contract.test", "priority", "unspecified"), + ), + }, + { + Config: testConfigFvRsConsIfNotExistingFvAEPg, + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_imported_contract data source"), + }, + }, + }) +} func TestAccDataSourceFvRsConsIfWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -34,6 +56,20 @@ func TestAccDataSourceFvRsConsIfWithFvESg(t *testing.T) { }) } +const testConfigFvRsConsIfDataSourceDependencyWithFvAEPg = testConfigFvRsConsIfMinDependencyWithFvAEPg + ` +data "aci_relation_to_imported_contract" "test" { + parent_dn = aci_application_epg.test.id + imported_contract_name = "test_tn_vz_cp_if_name" + depends_on = [aci_relation_to_imported_contract.test] +} +` + +const testConfigFvRsConsIfNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +data "aci_relation_to_imported_contract" "test_non_existing" { + parent_dn = aci_application_epg.test.id + imported_contract_name = "non_existing_tn_vz_cp_if_name" +} +` const testConfigFvRsConsIfDataSourceDependencyWithFvESg = testConfigFvRsConsIfMinDependencyWithFvESg + ` data "aci_relation_to_imported_contract" "test" { parent_dn = aci_endpoint_security_group.test.id diff --git a/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go b/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go index 72304f9a7..617798ccd 100644 --- a/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go @@ -11,6 +11,27 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) +func TestAccDataSourceFvRsIntraEpgWithFvAEPg(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvRsIntraEpgDataSourceDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_to_intra_epg_contract.test", "contract_name", "test_tn_vz_br_cp_name"), + resource.TestCheckResourceAttr("data.aci_relation_to_intra_epg_contract.test", "annotation", "orchestrator:terraform"), + ), + }, + { + Config: testConfigFvRsIntraEpgNotExistingFvAEPg, + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_intra_epg_contract data source"), + }, + }, + }) +} func TestAccDataSourceFvRsIntraEpgWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -33,6 +54,20 @@ func TestAccDataSourceFvRsIntraEpgWithFvESg(t *testing.T) { }) } +const testConfigFvRsIntraEpgDataSourceDependencyWithFvAEPg = testConfigFvRsIntraEpgMinDependencyWithFvAEPg + ` +data "aci_relation_to_intra_epg_contract" "test" { + parent_dn = aci_application_epg.test.id + contract_name = "test_tn_vz_br_cp_name" + depends_on = [aci_relation_to_intra_epg_contract.test] +} +` + +const testConfigFvRsIntraEpgNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +data "aci_relation_to_intra_epg_contract" "test_non_existing" { + parent_dn = aci_application_epg.test.id + contract_name = "non_existing_tn_vz_br_cp_name" +} +` const testConfigFvRsIntraEpgDataSourceDependencyWithFvESg = testConfigFvRsIntraEpgMinDependencyWithFvESg + ` data "aci_relation_to_intra_epg_contract" "test" { parent_dn = aci_endpoint_security_group.test.id diff --git a/internal/provider/data_source_aci_relation_to_provided_contract_test.go b/internal/provider/data_source_aci_relation_to_provided_contract_test.go index 696c358f5..0331bab61 100644 --- a/internal/provider/data_source_aci_relation_to_provided_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_provided_contract_test.go @@ -11,6 +11,29 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) +func TestAccDataSourceFvRsProvWithFvAEPg(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvRsProvDataSourceDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_to_provided_contract.test", "contract_name", "test_tn_vz_br_cp_name"), + resource.TestCheckResourceAttr("data.aci_relation_to_provided_contract.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_relation_to_provided_contract.test", "match_criteria", "AtleastOne"), + resource.TestCheckResourceAttr("data.aci_relation_to_provided_contract.test", "priority", "unspecified"), + ), + }, + { + Config: testConfigFvRsProvNotExistingFvAEPg, + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_provided_contract data source"), + }, + }, + }) +} func TestAccDataSourceFvRsProvWithFvESg(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -35,6 +58,20 @@ func TestAccDataSourceFvRsProvWithFvESg(t *testing.T) { }) } +const testConfigFvRsProvDataSourceDependencyWithFvAEPg = testConfigFvRsProvMinDependencyWithFvAEPg + ` +data "aci_relation_to_provided_contract" "test" { + parent_dn = aci_application_epg.test.id + contract_name = "test_tn_vz_br_cp_name" + depends_on = [aci_relation_to_provided_contract.test] +} +` + +const testConfigFvRsProvNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +data "aci_relation_to_provided_contract" "test_non_existing" { + parent_dn = aci_application_epg.test.id + contract_name = "non_existing_tn_vz_br_cp_name" +} +` const testConfigFvRsProvDataSourceDependencyWithFvESg = testConfigFvRsProvMinDependencyWithFvESg + ` data "aci_relation_to_provided_contract" "test" { parent_dn = aci_endpoint_security_group.test.id From 91f4e043b2d2a36abfb8365ea8ef3932ec45d4c0 Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Thu, 15 Aug 2024 07:55:52 -0400 Subject: [PATCH 10/11] [ignore] Add conditions to not render resources and datasources for Rs classes set to one max class allowed. --- docs/data-sources/relation_to_host_path.md | 61 -- docs/resources/relation_to_host_path.md | 120 ---- .../aci_relation_to_host_path/data-source.tf | 5 - .../aci_relation_to_host_path/provider.tf | 14 - .../aci_relation_to_host_path/provider.tf | 14 - .../resource-all-attributes.tf | 18 - .../aci_relation_to_host_path/resource.tf | 5 - gen/generator.go | 4 +- gen/templates/provider.go.tmpl | 4 +- gen/templates/resource.go.tmpl | 13 +- gen/testvars/infraRsHPathAtt.yaml | 52 -- .../data_source_aci_relation_to_host_path.go | 149 ---- ...a_source_aci_relation_to_host_path_test.go | 49 -- internal/provider/provider.go | 2 - .../resource_aci_access_interface_override.go | 23 +- .../resource_aci_relation_to_host_path.go | 643 ------------------ ...resource_aci_relation_to_host_path_test.go | 274 -------- 17 files changed, 20 insertions(+), 1430 deletions(-) delete mode 100644 docs/data-sources/relation_to_host_path.md delete mode 100644 docs/resources/relation_to_host_path.md delete mode 100644 examples/data-sources/aci_relation_to_host_path/data-source.tf delete mode 100644 examples/data-sources/aci_relation_to_host_path/provider.tf delete mode 100644 examples/resources/aci_relation_to_host_path/provider.tf delete mode 100644 examples/resources/aci_relation_to_host_path/resource-all-attributes.tf delete mode 100644 examples/resources/aci_relation_to_host_path/resource.tf delete mode 100644 gen/testvars/infraRsHPathAtt.yaml delete mode 100644 internal/provider/data_source_aci_relation_to_host_path.go delete mode 100644 internal/provider/data_source_aci_relation_to_host_path_test.go delete mode 100644 internal/provider/resource_aci_relation_to_host_path.go delete mode 100644 internal/provider/resource_aci_relation_to_host_path_test.go diff --git a/docs/data-sources/relation_to_host_path.md b/docs/data-sources/relation_to_host_path.md deleted file mode 100644 index 29bd29c03..000000000 --- a/docs/data-sources/relation_to_host_path.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -# 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_relation_to_host_path" -sidebar_current: "docs-aci-data-source-aci_relation_to_host_path" -description: |- - Data source for ACI Relation To Host Path ---- - -# aci_relation_to_host_path # - -Data source for ACI Relation To Host Path - -## API Information ## - -* Class: [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview) - -* Supported in ACI versions: 1.1(1j) and later. - -* Distinguished Name Format: `uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}]` - -## GUI Information ## - -* Locations: - - `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides` - - `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides` - -## Example Usage ## - -```hcl - -data "aci_relation_to_host_path" "example_access_interface_override" { - parent_dn = aci_access_interface_override.example.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" -} - -``` - -## Schema ## - -### Required ### - -* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - - [aci_access_interface_override](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_interface_override) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) -* `target_dn` (tDn) - (string) The distinguished name of the target. - -### Read-Only ### - -* `id` - (string) The distinguished name (DN) of the Relation To Host Path object. -* `annotation` (annotation) - (string) The annotation of the Relation To Host Path 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. diff --git a/docs/resources/relation_to_host_path.md b/docs/resources/relation_to_host_path.md deleted file mode 100644 index 87014d364..000000000 --- a/docs/resources/relation_to_host_path.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -# 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_relation_to_host_path" -sidebar_current: "docs-aci-resource-aci_relation_to_host_path" -description: |- - Manages ACI Relation To Host Path ---- - -# aci_relation_to_host_path # - -Manages ACI Relation To Host Path - - - -## API Information ## - -* Class: [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview) - -* Supported in ACI versions: 1.1(1j) and later. - -* Distinguished Name Format: `uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}]` - -## GUI Information ## - -* Locations: - - `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Overrides` - - `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides` - -## Example Usage ## - -The configuration snippet below creates a Relation To Host Path with only required attributes. - -```hcl - -resource "aci_relation_to_host_path" "example_access_interface_override" { - parent_dn = aci_access_interface_override.example.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" -} - -``` -The configuration snippet below shows all possible attributes of the Relation To Host Path. - -!> This example might not be valid configuration and is only used to show all possible attributes. - -```hcl - -resource "aci_relation_to_host_path" "full_example_access_interface_override" { - parent_dn = aci_access_interface_override.example.id - annotation = "annotation" - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} - -``` - -All examples for the Relation To Host Path resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_relation_to_host_path) folder. - -## Schema ## - -### Required ### - -* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - - [aci_access_interface_override](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_interface_override) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) -* `target_dn` (tDn) - (string) The distinguished name of the target. - -### Read-Only ### - -* `id` - (string) The distinguished name (DN) of the Relation To Host Path object. - -### Optional ### - -* `annotation` (annotation) - (string) The annotation of the Relation To Host Path object. - - Default: `orchestrator:terraform` - -* `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 Relation To Host Path 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_relation_to_host_path.example_access_interface_override uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}] -``` - -Starting in Terraform version 1.5, an existing Relation To Host Path can be imported -using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: - -``` -import { - id = "uni/infra/hpaths-{name}/rsHPathAtt-[{tDn}]" - to = aci_relation_to_host_path.example_access_interface_override -} -``` diff --git a/examples/data-sources/aci_relation_to_host_path/data-source.tf b/examples/data-sources/aci_relation_to_host_path/data-source.tf deleted file mode 100644 index c9bfb8fe7..000000000 --- a/examples/data-sources/aci_relation_to_host_path/data-source.tf +++ /dev/null @@ -1,5 +0,0 @@ - -data "aci_relation_to_host_path" "example_access_interface_override" { - parent_dn = aci_access_interface_override.example.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" -} diff --git a/examples/data-sources/aci_relation_to_host_path/provider.tf b/examples/data-sources/aci_relation_to_host_path/provider.tf deleted file mode 100644 index 975fca093..000000000 --- a/examples/data-sources/aci_relation_to_host_path/provider.tf +++ /dev/null @@ -1,14 +0,0 @@ -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_relation_to_host_path/provider.tf b/examples/resources/aci_relation_to_host_path/provider.tf deleted file mode 100644 index 975fca093..000000000 --- a/examples/resources/aci_relation_to_host_path/provider.tf +++ /dev/null @@ -1,14 +0,0 @@ -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_relation_to_host_path/resource-all-attributes.tf b/examples/resources/aci_relation_to_host_path/resource-all-attributes.tf deleted file mode 100644 index 5278593cd..000000000 --- a/examples/resources/aci_relation_to_host_path/resource-all-attributes.tf +++ /dev/null @@ -1,18 +0,0 @@ - -resource "aci_relation_to_host_path" "full_example_access_interface_override" { - parent_dn = aci_access_interface_override.example.id - annotation = "annotation" - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - annotations = [ - { - key = "key_0" - value = "value_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] -} diff --git a/examples/resources/aci_relation_to_host_path/resource.tf b/examples/resources/aci_relation_to_host_path/resource.tf deleted file mode 100644 index 3b5816c37..000000000 --- a/examples/resources/aci_relation_to_host_path/resource.tf +++ /dev/null @@ -1,5 +0,0 @@ - -resource "aci_relation_to_host_path" "example_access_interface_override" { - parent_dn = aci_access_interface_override.example.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" -} diff --git a/gen/generator.go b/gen/generator.go index 453b7393e..37cdb42d3 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -712,7 +712,9 @@ func main() { for _, model := range classModels { // Only render resources and datasources when the class has a unique identifier or is marked as include in the classes definitions YAML file - if len(model.IdentifiedBy) > 0 || model.Include { + // And only render when the class is also not a Rs object and is not set to max one class allowed + // TODO might need to extend this last condition in the future + if (len(model.IdentifiedBy) > 0 || model.Include) && !(strings.HasPrefix(model.RnFormat, "rs") && model.MaxOneClassAllowed) { // All classmodels have been read, thus now the model, child and relational resources names can be set // When done before additional files would need to be opened and read which would slow down the generation process diff --git a/gen/templates/provider.go.tmpl b/gen/templates/provider.go.tmpl index 8ba238cbb..4d4b0ee7d 100644 --- a/gen/templates/provider.go.tmpl +++ b/gen/templates/provider.go.tmpl @@ -204,7 +204,7 @@ func (p *AciProvider) Configure(ctx context.Context, req provider.ConfigureReque func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ {{- range . }} - {{- if or .IdentifiedBy .Include}} + {{- if and (or .IdentifiedBy .Include) (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))}} New{{.ResourceClassName}}Resource, {{- end }} {{- end }} @@ -215,7 +215,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ {{- range . }} - {{- if or .IdentifiedBy .Include}} + {{- if and (or .IdentifiedBy .Include) (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))}} New{{.ResourceClassName}}DataSource, {{- end }} {{- end }} diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index de0bf34e1..961d5983a 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -1464,7 +1464,7 @@ func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context childPayloads := []map[string]interface{}{} if !data.{{ .ResourceClassName }}.IsUnknown() { - {{- if .IdentifiedBy}} + {{- if and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))}} {{ .PkgName }}Identifiers := []{{ .ResourceClassName }}Identifier{} {{- end}} for _, {{ .PkgName }} := range {{ .PkgName }}Plan { @@ -1485,7 +1485,7 @@ func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context } {{- end}} {{- end}} childPayloads = append(childPayloads, map[string]interface{}{"{{ .PkgName }}": childMap}) - {{- if .IdentifiedBy}} + {{- if and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))}} {{ .PkgName }}Identifier := {{ .ResourceClassName }}Identifier{} {{- range .Properties}} {{- if .IsNaming}} @@ -1495,7 +1495,7 @@ func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context {{ .PkgName }}Identifiers = append({{ .PkgName }}Identifiers, {{ .PkgName }}Identifier) {{- end}} } - {{- if .IdentifiedBy}} + {{- if and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))}} for _, {{ .PkgName }} := range {{ .PkgName }}State { delete := true for _, {{ .PkgName }}Identifier := range {{ .PkgName }}Identifiers { {{$i := 1}}{{$length := len .IdentifiedBy}} @@ -1525,6 +1525,13 @@ func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context {{- if .AllowDelete}} childMap := map[string]map[string]interface{}{"attributes": {}} childMap["attributes"]["status"] = "deleted" + {{- if .IdentifiedBy}} + {{- range .Properties}} + {{- if .IsNaming }} + childMap["attributes"]["{{.PropertyName}}"] = {{ .PkgName }}State[0].{{- if eq .Name "Id"}}{{.ResourceClassName}}{{ .Name }}{{- else}}{{.Name}}{{- end}}.ValueString() + {{- end}} + {{- end}} + {{- end}} childPayloads = append(childPayloads, map[string]interface{}{"{{ .PkgName }}": childMap}) {{- else}} diags.AddError( diff --git a/gen/testvars/infraRsHPathAtt.yaml b/gen/testvars/infraRsHPathAtt.yaml deleted file mode 100644 index 31d17b445..000000000 --- a/gen/testvars/infraRsHPathAtt.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# 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" - -datasource_non_existing: - target_dn: "non_existing_t_dn" - -datasource_required: - target_dn: "test_t_dn" - -resource_required: - target_dn: "test_t_dn" - -all: - annotation: "annotation" - -children: - annotations: - - key: "key_0" - value: "value_1" - - - key: "key_1" - value: "test_value" - - tags: - - key: "key_0" - value: "value_1" - - - key: "key_1" - value: "test_value" - -parents: - - class_name: "infraHPathS" - parent_dependency: "" - parent_dn: "aci_access_interface_override.test.id" - class_in_parent: false - target_classes: - - "fabricPathEp" -targets: - - class_name: "fabricPathEp" - target_dn: "topology/pod-1/paths-101/pathep-[eth1/1]" - target_dn_ref: "aci_.test__0.id" - parent_dependency: "" - parent_dependency_dn_ref: "" - target_resource_name: "" - relation_resource_name: "host_path" - parent_dn_key: "parent_dn" - static: true - properties: diff --git a/internal/provider/data_source_aci_relation_to_host_path.go b/internal/provider/data_source_aci_relation_to_host_path.go deleted file mode 100644 index 85cdae5c3..000000000 --- a/internal/provider/data_source_aci_relation_to_host_path.go +++ /dev/null @@ -1,149 +0,0 @@ -// 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 = &InfraRsHPathAttDataSource{} - -func NewInfraRsHPathAttDataSource() datasource.DataSource { - return &InfraRsHPathAttDataSource{} -} - -// InfraRsHPathAttDataSource defines the data source implementation. -type InfraRsHPathAttDataSource struct { - client *client.Client -} - -func (d *InfraRsHPathAttDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - tflog.Debug(ctx, "Start metadata of datasource: aci_relation_to_host_path") - resp.TypeName = req.ProviderTypeName + "_relation_to_host_path" - tflog.Debug(ctx, "End metadata of datasource: aci_relation_to_host_path") -} - -func (d *InfraRsHPathAttDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - tflog.Debug(ctx, "Start schema of datasource: aci_relation_to_host_path") - resp.Schema = schema.Schema{ - // This description is used by the documentation generator and the language server. - MarkdownDescription: "The relation_to_host_path datasource for the 'infraRsHPathAtt' class", - - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - MarkdownDescription: "The distinguished name (DN) of the Relation To Host Path object.", - }, - "parent_dn": schema.StringAttribute{ - Required: true, - MarkdownDescription: "The distinguished name (DN) of the parent object.", - }, - "annotation": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `The annotation of the Relation To Host Path object.`, - }, - "target_dn": schema.StringAttribute{ - Required: true, - MarkdownDescription: `The distinguished name of the target.`, - }, - "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_relation_to_host_path") -} - -func (d *InfraRsHPathAttDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - tflog.Debug(ctx, "Start configure of datasource: aci_relation_to_host_path") - // 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_relation_to_host_path") -} - -func (d *InfraRsHPathAttDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - tflog.Debug(ctx, "Start read of datasource: aci_relation_to_host_path") - var data *InfraRsHPathAttResourceModel - - // Read Terraform configuration data into the model - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - setInfraRsHPathAttId(ctx, data) - - // Create a copy of the Id for when not found during getAndSetInfraRsHPathAttAttributes - cachedId := data.Id.ValueString() - - tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_relation_to_host_path with id '%s'", data.Id.ValueString())) - - getAndSetInfraRsHPathAttAttributes(ctx, &resp.Diagnostics, d.client, data) - - if data.Id.IsNull() { - resp.Diagnostics.AddError( - "Failed to read aci_relation_to_host_path data source", - fmt.Sprintf("The aci_relation_to_host_path 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_relation_to_host_path with id '%s'", data.Id.ValueString())) -} diff --git a/internal/provider/data_source_aci_relation_to_host_path_test.go b/internal/provider/data_source_aci_relation_to_host_path_test.go deleted file mode 100644 index c30cc1005..000000000 --- a/internal/provider/data_source_aci_relation_to_host_path_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// 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 TestAccDataSourceInfraRsHPathAttWithInfraHPathS(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testConfigInfraRsHPathAttDataSourceDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("data.aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), - ), - }, - { - Config: testConfigInfraRsHPathAttNotExistingInfraHPathS, - ExpectError: regexp.MustCompile("Failed to read aci_relation_to_host_path data source"), - }, - }, - }) -} - -const testConfigInfraRsHPathAttDataSourceDependencyWithInfraHPathS = testConfigInfraRsHPathAttMinDependencyWithInfraHPathS + ` -data "aci_relation_to_host_path" "test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - depends_on = [aci_relation_to_host_path.test] -} -` - -const testConfigInfraRsHPathAttNotExistingInfraHPathS = testConfigInfraHPathSMin + ` -data "aci_relation_to_host_path" "test_non_existing" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]_not_existing" -} -` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 2f86ae5e4..400f7b6a7 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -230,7 +230,6 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvSCrtrnResource, NewFvVmAttrResource, NewInfraHPathSResource, - NewInfraRsHPathAttResource, NewL3extConsLblResource, NewL3extProvLblResource, NewL3extRsOutToFBRGroupResource, @@ -282,7 +281,6 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvSCrtrnDataSource, NewFvVmAttrDataSource, NewInfraHPathSDataSource, - NewInfraRsHPathAttDataSource, NewL3extConsLblDataSource, NewL3extProvLblDataSource, NewL3extRsOutToFBRGroupDataSource, diff --git a/internal/provider/resource_aci_access_interface_override.go b/internal/provider/resource_aci_access_interface_override.go index 165e40e19..ab6d5c99d 100644 --- a/internal/provider/resource_aci_access_interface_override.go +++ b/internal/provider/resource_aci_access_interface_override.go @@ -720,7 +720,6 @@ func getInfraHPathSInfraRsHPathAttChildPayloads(ctx context.Context, diags *diag childPayloads := []map[string]interface{}{} if !data.InfraRsHPathAtt.IsUnknown() { - infraRsHPathAttIdentifiers := []InfraRsHPathAttIdentifier{} for _, infraRsHPathAtt := range infraRsHPathAttPlan { childMap := map[string]map[string]interface{}{"attributes": {}} if !infraRsHPathAtt.Annotation.IsUnknown() && !infraRsHPathAtt.Annotation.IsNull() { @@ -732,24 +731,12 @@ func getInfraHPathSInfraRsHPathAttChildPayloads(ctx context.Context, diags *diag childMap["attributes"]["tDn"] = infraRsHPathAtt.TDn.ValueString() } childPayloads = append(childPayloads, map[string]interface{}{"infraRsHPathAtt": childMap}) - infraRsHPathAttIdentifier := InfraRsHPathAttIdentifier{} - infraRsHPathAttIdentifier.TDn = infraRsHPathAtt.TDn - infraRsHPathAttIdentifiers = append(infraRsHPathAttIdentifiers, infraRsHPathAttIdentifier) } - for _, infraRsHPathAtt := range infraRsHPathAttState { - delete := true - for _, infraRsHPathAttIdentifier := range infraRsHPathAttIdentifiers { - if infraRsHPathAttIdentifier.TDn == infraRsHPathAtt.TDn { - delete = false - break - } - } - if delete { - childMap := map[string]map[string]interface{}{"attributes": {}} - childMap["attributes"]["status"] = "deleted" - childMap["attributes"]["tDn"] = infraRsHPathAtt.TDn.ValueString() - childPayloads = append(childPayloads, map[string]interface{}{"infraRsHPathAtt": childMap}) - } + if len(infraRsHPathAttPlan) == 0 && len(infraRsHPathAttState) == 1 { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["tDn"] = infraRsHPathAttState[0].TDn.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"infraRsHPathAtt": childMap}) } } else { data.InfraRsHPathAtt = types.SetNull(data.InfraRsHPathAtt.ElementType(ctx)) diff --git a/internal/provider/resource_aci_relation_to_host_path.go b/internal/provider/resource_aci_relation_to_host_path.go deleted file mode 100644 index 0319b9f71..000000000 --- a/internal/provider/resource_aci_relation_to_host_path.go +++ /dev/null @@ -1,643 +0,0 @@ -// 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" - "reflect" - "strings" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/container" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/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 = &InfraRsHPathAttResource{} -var _ resource.ResourceWithImportState = &InfraRsHPathAttResource{} - -func NewInfraRsHPathAttResource() resource.Resource { - return &InfraRsHPathAttResource{} -} - -// InfraRsHPathAttResource defines the resource implementation. -type InfraRsHPathAttResource struct { - client *client.Client -} - -// InfraRsHPathAttResourceModel describes the resource data model. -type InfraRsHPathAttResourceModel struct { - Id types.String `tfsdk:"id"` - ParentDn types.String `tfsdk:"parent_dn"` - Annotation types.String `tfsdk:"annotation"` - TDn types.String `tfsdk:"target_dn"` - TagAnnotation types.Set `tfsdk:"annotations"` - TagTag types.Set `tfsdk:"tags"` -} - -func getEmptyInfraRsHPathAttResourceModel() *InfraRsHPathAttResourceModel { - return &InfraRsHPathAttResourceModel{ - Id: basetypes.NewStringNull(), - ParentDn: basetypes.NewStringNull(), - 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, - }, - }), - } -} - -// TagAnnotationInfraRsHPathAttResourceModel describes the resource data model for the children without relation ships. -type TagAnnotationInfraRsHPathAttResourceModel struct { - Key types.String `tfsdk:"key"` - Value types.String `tfsdk:"value"` -} - -func getEmptyTagAnnotationInfraRsHPathAttResourceModel() TagAnnotationInfraRsHPathAttResourceModel { - return TagAnnotationInfraRsHPathAttResourceModel{ - Key: basetypes.NewStringNull(), - Value: basetypes.NewStringNull(), - } -} - -// TagTagInfraRsHPathAttResourceModel describes the resource data model for the children without relation ships. -type TagTagInfraRsHPathAttResourceModel struct { - Key types.String `tfsdk:"key"` - Value types.String `tfsdk:"value"` -} - -func getEmptyTagTagInfraRsHPathAttResourceModel() TagTagInfraRsHPathAttResourceModel { - return TagTagInfraRsHPathAttResourceModel{ - Key: basetypes.NewStringNull(), - Value: basetypes.NewStringNull(), - } -} - -type InfraRsHPathAttIdentifier struct { - TDn types.String -} - -func (r *InfraRsHPathAttResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { - if !req.Plan.Raw.IsNull() { - var planData, stateData *InfraRsHPathAttResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) - resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) - - if resp.Diagnostics.HasError() { - return - } - - if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { - setInfraRsHPathAttId(ctx, planData) - } - - if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { - CheckDn(ctx, &resp.Diagnostics, r.client, "infraRsHPathAtt", planData.Id.ValueString()) - if resp.Diagnostics.HasError() { - return - } - } - - resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) - } -} - -func (r *InfraRsHPathAttResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - tflog.Debug(ctx, "Start metadata of resource: aci_relation_to_host_path") - resp.TypeName = req.ProviderTypeName + "_relation_to_host_path" - tflog.Debug(ctx, "End metadata of resource: aci_relation_to_host_path") -} - -func (r *InfraRsHPathAttResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - tflog.Debug(ctx, "Start schema of resource: aci_relation_to_host_path") - resp.Schema = schema.Schema{ - // This description is used by the documentation generator and the language server. - MarkdownDescription: "The relation_to_host_path resource for the 'infraRsHPathAtt' class", - - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - MarkdownDescription: "The distinguished name (DN) of the Relation To Host Path object.", - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "parent_dn": schema.StringAttribute{ - Required: true, - MarkdownDescription: "The distinguished name (DN) of the parent object.", - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - stringplanmodifier.RequiresReplace(), - }, - }, - "annotation": schema.StringAttribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), - }, - Default: stringdefault.StaticString(globalAnnotation), - MarkdownDescription: `The annotation of the Relation To Host Path object.`, - }, - "target_dn": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), - stringplanmodifier.RequiresReplace(), - }, - MarkdownDescription: `The distinguished name of the target.`, - }, - "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_relation_to_host_path") -} - -func (r *InfraRsHPathAttResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - tflog.Debug(ctx, "Start configure of resource: aci_relation_to_host_path") - // 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_relation_to_host_path") -} - -func (r *InfraRsHPathAttResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - tflog.Debug(ctx, "Start create of resource: aci_relation_to_host_path") - // On create retrieve information on current state prior to making any changes in order to determine child delete operations - var stateData *InfraRsHPathAttResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setInfraRsHPathAttId(ctx, stateData) - } - getAndSetInfraRsHPathAttAttributes(ctx, &resp.Diagnostics, r.client, stateData) - if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { - resp.Diagnostics.AddError( - "Object Already Exists", - fmt.Sprintf("The infraRsHPathAtt object with DN '%s' already exists.", stateData.Id.ValueString()), - ) - return - } - - var data *InfraRsHPathAttResourceModel - - // 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() { - setInfraRsHPathAttId(ctx, data) - } - - tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_host_path with id '%s'", data.Id.ValueString())) - - var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraRsHPathAttResourceModel - data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) - stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) - var tagTagPlan, tagTagState []TagTagInfraRsHPathAttResourceModel - data.TagTag.ElementsAs(ctx, &tagTagPlan, false) - stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getInfraRsHPathAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) - - if resp.Diagnostics.HasError() { - return - } - - DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) - if resp.Diagnostics.HasError() { - return - } - - getAndSetInfraRsHPathAttAttributes(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_relation_to_host_path with id '%s'", data.Id.ValueString())) -} - -func (r *InfraRsHPathAttResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - tflog.Debug(ctx, "Start read of resource: aci_relation_to_host_path") - var data *InfraRsHPathAttResourceModel - - // 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_relation_to_host_path with id '%s'", data.Id.ValueString())) - - getAndSetInfraRsHPathAttAttributes(ctx, &resp.Diagnostics, r.client, data) - - // Save updated data into Terraform state - if data.Id.IsNull() { - var emptyData *InfraRsHPathAttResourceModel - 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_relation_to_host_path with id '%s'", data.Id.ValueString())) -} - -func (r *InfraRsHPathAttResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - tflog.Debug(ctx, "Start update of resource: aci_relation_to_host_path") - var data *InfraRsHPathAttResourceModel - var stateData *InfraRsHPathAttResourceModel - - // 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_relation_to_host_path with id '%s'", data.Id.ValueString())) - - var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraRsHPathAttResourceModel - data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) - stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) - var tagTagPlan, tagTagState []TagTagInfraRsHPathAttResourceModel - data.TagTag.ElementsAs(ctx, &tagTagPlan, false) - stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getInfraRsHPathAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) - - if resp.Diagnostics.HasError() { - return - } - - DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) - - if resp.Diagnostics.HasError() { - return - } - - getAndSetInfraRsHPathAttAttributes(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_relation_to_host_path with id '%s'", data.Id.ValueString())) -} - -func (r *InfraRsHPathAttResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - tflog.Debug(ctx, "Start delete of resource: aci_relation_to_host_path") - var data *InfraRsHPathAttResourceModel - - // 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_relation_to_host_path with id '%s'", data.Id.ValueString())) - jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraRsHPathAtt", 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_relation_to_host_path with id '%s'", data.Id.ValueString())) -} - -func (r *InfraRsHPathAttResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - tflog.Debug(ctx, "Start import state of resource: aci_relation_to_host_path") - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) - - var stateData *InfraRsHPathAttResourceModel - resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) - tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_relation_to_host_path with id '%s'", stateData.Id.ValueString())) - - tflog.Debug(ctx, "End import of state resource: aci_relation_to_host_path") -} - -func getAndSetInfraRsHPathAttAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraRsHPathAttResourceModel) { - requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "infraRsHPathAtt,tagAnnotation,tagTag"), "GET", nil) - - *data = *getEmptyInfraRsHPathAttResourceModel() - - if diags.HasError() { - return - } - if requestData.Search("imdata").Search("infraRsHPathAtt").Data() != nil { - classReadInfo := requestData.Search("imdata").Search("infraRsHPathAtt").Data().([]interface{}) - if len(classReadInfo) == 1 { - attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) - for attributeName, attributeValue := range attributes { - if attributeName == "dn" { - data.Id = basetypes.NewStringValue(attributeValue.(string)) - setInfraRsHPathAttParentDn(ctx, attributeValue.(string), data) - } - if attributeName == "annotation" { - data.Annotation = basetypes.NewStringValue(attributeValue.(string)) - } - if attributeName == "tDn" { - data.TDn = basetypes.NewStringValue(attributeValue.(string)) - } - } - TagAnnotationInfraRsHPathAttList := make([]TagAnnotationInfraRsHPathAttResourceModel, 0) - TagTagInfraRsHPathAttList := make([]TagTagInfraRsHPathAttResourceModel, 0) - _, ok := classReadInfo[0].(map[string]interface{})["children"] - if ok { - children := classReadInfo[0].(map[string]interface{})["children"].([]interface{}) - for _, child := range children { - for childClassName, childClassDetails := range child.(map[string]interface{}) { - childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) - if childClassName == "tagAnnotation" { - TagAnnotationInfraRsHPathAtt := getEmptyTagAnnotationInfraRsHPathAttResourceModel() - for childAttributeName, childAttributeValue := range childAttributes { - if childAttributeName == "key" { - TagAnnotationInfraRsHPathAtt.Key = basetypes.NewStringValue(childAttributeValue.(string)) - } - if childAttributeName == "value" { - TagAnnotationInfraRsHPathAtt.Value = basetypes.NewStringValue(childAttributeValue.(string)) - } - } - TagAnnotationInfraRsHPathAttList = append(TagAnnotationInfraRsHPathAttList, TagAnnotationInfraRsHPathAtt) - } - if childClassName == "tagTag" { - TagTagInfraRsHPathAtt := getEmptyTagTagInfraRsHPathAttResourceModel() - for childAttributeName, childAttributeValue := range childAttributes { - if childAttributeName == "key" { - TagTagInfraRsHPathAtt.Key = basetypes.NewStringValue(childAttributeValue.(string)) - } - if childAttributeName == "value" { - TagTagInfraRsHPathAtt.Value = basetypes.NewStringValue(childAttributeValue.(string)) - } - } - TagTagInfraRsHPathAttList = append(TagTagInfraRsHPathAttList, TagTagInfraRsHPathAtt) - } - } - } - } - tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationInfraRsHPathAttList) - data.TagAnnotation = tagAnnotationSet - tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagInfraRsHPathAttList) - data.TagTag = tagTagSet - } else { - diags.AddError( - "too many results in response", - fmt.Sprintf("%v matches returned for class 'infraRsHPathAtt'. Please report this issue to the provider developers.", len(classReadInfo)), - ) - } - } else { - data.Id = basetypes.NewStringNull() - } -} - -func getInfraRsHPathAttRn(ctx context.Context, data *InfraRsHPathAttResourceModel) string { - rn := "rsHPathAtt-[{tDn}]" - for _, identifier := range []string{"tDn"} { - fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) - fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() - rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) - } - return rn -} - -func setInfraRsHPathAttParentDn(ctx context.Context, dn string, data *InfraRsHPathAttResourceModel) { - bracketIndex := 0 - rnIndex := 0 - for i := len(dn) - 1; i >= 0; i-- { - if string(dn[i]) == "]" { - bracketIndex = bracketIndex + 1 - } else if string(dn[i]) == "[" { - bracketIndex = bracketIndex - 1 - } else if string(dn[i]) == "/" && bracketIndex == 0 { - rnIndex = i - break - } - } - data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) -} - -func setInfraRsHPathAttId(ctx context.Context, data *InfraRsHPathAttResourceModel) { - rn := getInfraRsHPathAttRn(ctx, data) - data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) -} - -func getInfraRsHPathAttTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraRsHPathAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraRsHPathAttResourceModel) []map[string]interface{} { - - childPayloads := []map[string]interface{}{} - if !data.TagAnnotation.IsUnknown() { - tagAnnotationIdentifiers := []TagAnnotationIdentifier{} - for _, tagAnnotation := range tagAnnotationPlan { - childMap := map[string]map[string]interface{}{"attributes": {}} - if !tagAnnotation.Key.IsUnknown() && !tagAnnotation.Key.IsNull() { - childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() - } - if !tagAnnotation.Value.IsUnknown() && !tagAnnotation.Value.IsNull() { - childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() - } - childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) - tagAnnotationIdentifier := TagAnnotationIdentifier{} - tagAnnotationIdentifier.Key = tagAnnotation.Key - tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) - } - for _, tagAnnotation := range tagAnnotationState { - delete := true - for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { - if tagAnnotationIdentifier.Key == tagAnnotation.Key { - delete = false - break - } - } - if delete { - childMap := map[string]map[string]interface{}{"attributes": {}} - childMap["attributes"]["status"] = "deleted" - childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() - childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) - } - } - } else { - data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) - } - - return childPayloads -} -func getInfraRsHPathAttTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraRsHPathAttResourceModel, tagTagPlan, tagTagState []TagTagInfraRsHPathAttResourceModel) []map[string]interface{} { - - childPayloads := []map[string]interface{}{} - if !data.TagTag.IsUnknown() { - tagTagIdentifiers := []TagTagIdentifier{} - for _, tagTag := range tagTagPlan { - childMap := map[string]map[string]interface{}{"attributes": {}} - if !tagTag.Key.IsUnknown() && !tagTag.Key.IsNull() { - childMap["attributes"]["key"] = tagTag.Key.ValueString() - } - if !tagTag.Value.IsUnknown() && !tagTag.Value.IsNull() { - childMap["attributes"]["value"] = tagTag.Value.ValueString() - } - childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) - tagTagIdentifier := TagTagIdentifier{} - tagTagIdentifier.Key = tagTag.Key - tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) - } - for _, tagTag := range tagTagState { - delete := true - for _, tagTagIdentifier := range tagTagIdentifiers { - if tagTagIdentifier.Key == tagTag.Key { - delete = false - break - } - } - if delete { - childMap := map[string]map[string]interface{}{"attributes": {}} - childMap["attributes"]["status"] = "deleted" - childMap["attributes"]["key"] = tagTag.Key.ValueString() - childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) - } - } - } else { - data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) - } - - return childPayloads -} - -func getInfraRsHPathAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraRsHPathAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraRsHPathAttResourceModel, tagTagPlan, tagTagState []TagTagInfraRsHPathAttResourceModel) *container.Container { - payloadMap := map[string]interface{}{} - payloadMap["attributes"] = map[string]string{} - - if createType && !globalAllowExistingOnCreate { - payloadMap["attributes"].(map[string]string)["status"] = "created" - } - childPayloads := []map[string]interface{}{} - - TagAnnotationchildPayloads := getInfraRsHPathAttTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) - if TagAnnotationchildPayloads == nil { - return nil - } - childPayloads = append(childPayloads, TagAnnotationchildPayloads...) - - TagTagchildPayloads := getInfraRsHPathAttTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) - if TagTagchildPayloads == nil { - return nil - } - childPayloads = append(childPayloads, TagTagchildPayloads...) - - payloadMap["children"] = childPayloads - if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { - payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() - } - if !data.TDn.IsNull() && !data.TDn.IsUnknown() { - payloadMap["attributes"].(map[string]string)["tDn"] = data.TDn.ValueString() - } - - payload, err := json.Marshal(map[string]interface{}{"infraRsHPathAtt": 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_relation_to_host_path_test.go b/internal/provider/resource_aci_relation_to_host_path_test.go deleted file mode 100644 index 341544129..000000000 --- a/internal/provider/resource_aci_relation_to_host_path_test.go +++ /dev/null @@ -1,274 +0,0 @@ -// 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 TestAccResourceInfraRsHPathAttWithInfraHPathS(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test_2", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test_2", "annotation", "orchestrator:terraform"), - ), - }, - }, - }) - - setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting, - ExpectError: regexp.MustCompile("Object Already Exists"), - }, - }, - }) - - setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test_2", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.allow_test_2", "annotation", "orchestrator:terraform"), - ), - }, - }, - }) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), - ), - }, - // Update with all config and verify default APIC values - { - Config: testConfigInfraRsHPathAttAllDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "annotation"), - ), - }, - // Update with minimum config and verify config is unchanged - { - Config: testConfigInfraRsHPathAttMinDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - ), - }, - // Update with empty strings config or default value - { - Config: testConfigInfraRsHPathAttResetDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), - ), - }, - // Import testing - { - ResourceName: "aci_relation_to_host_path.test", - ImportState: true, - ImportStateVerify: true, - }, - // Update with children - { - Config: testConfigInfraRsHPathAttChildrenDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.value", "test_value"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.value", "test_value"), - ), - }, - // Import testing with children - { - ResourceName: "aci_relation_to_host_path.test", - ImportState: true, - ImportStateVerify: true, - }, - // Update with children removed from config - { - Config: testConfigInfraRsHPathAttChildrenRemoveFromConfigDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.1.value", "test_value"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.#", "2"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.1.value", "test_value"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.#", "2"), - ), - }, - // Update with children first child removed - { - Config: testConfigInfraRsHPathAttChildrenRemoveOneDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.0.value", "test_value"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.#", "1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.0.value", "test_value"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.#", "1"), - ), - }, - // Update with all children removed - { - Config: testConfigInfraRsHPathAttChildrenRemoveAllDependencyWithInfraHPathS, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "annotations.#", "0"), - resource.TestCheckResourceAttr("aci_relation_to_host_path.test", "tags.#", "0"), - ), - }, - }, - }) -} - -const testDependencyConfigInfraRsHPathAtt = ` -` - -const testConfigInfraRsHPathAttMinDependencyWithInfraHPathSAllowExisting = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` -resource "aci_relation_to_host_path" "allow_test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" -} -resource "aci_relation_to_host_path" "allow_test_2" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - depends_on = [aci_relation_to_host_path.allow_test] -} -` - -const testConfigInfraRsHPathAttMinDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` -resource "aci_relation_to_host_path" "test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" -} -` - -const testConfigInfraRsHPathAttAllDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` -resource "aci_relation_to_host_path" "test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - annotation = "annotation" -} -` - -const testConfigInfraRsHPathAttResetDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` -resource "aci_relation_to_host_path" "test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - annotation = "orchestrator:terraform" -} -` -const testConfigInfraRsHPathAttChildrenDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` -resource "aci_relation_to_host_path" "test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/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" - }, - ] -} -` - -const testConfigInfraRsHPathAttChildrenRemoveFromConfigDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` -resource "aci_relation_to_host_path" "test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" -} -` - -const testConfigInfraRsHPathAttChildrenRemoveOneDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` -resource "aci_relation_to_host_path" "test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - annotations = [ - { - key = "key_1" - value = "test_value" - }, - ] - tags = [ - { - key = "key_1" - value = "test_value" - }, - ] -} -` - -const testConfigInfraRsHPathAttChildrenRemoveAllDependencyWithInfraHPathS = testDependencyConfigInfraRsHPathAtt + testConfigInfraHPathSMin + ` -resource "aci_relation_to_host_path" "test" { - parent_dn = aci_access_interface_override.test.id - target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" - annotations = [] - tags = [] -} -` From 2648c5d899c04790babf9a8d1c849cf1201cf952 Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Fri, 16 Aug 2024 09:35:56 -0400 Subject: [PATCH 11/11] [ignore] Fix resourceName set to singular when max class allowed set to one. Modify Logic for generating Rs class set to one max class allowed. --- .../data-sources/access_interface_override.md | 2 +- docs/resources/access_interface_override.md | 4 ++-- .../resource-all-attributes.tf | 2 +- gen/generator.go | 8 +++---- gen/templates/provider.go.tmpl | 4 ++-- gen/testvars/infraHPathS.yaml | 2 +- ...ta_source_aci_access_interface_override.go | 2 +- .../resource_aci_access_interface_override.go | 4 ++-- ...urce_aci_access_interface_override_test.go | 22 +++++++++---------- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/data-sources/access_interface_override.md b/docs/data-sources/access_interface_override.md index c18a68bb2..98a5963ab 100644 --- a/docs/data-sources/access_interface_override.md +++ b/docs/data-sources/access_interface_override.md @@ -59,7 +59,7 @@ data "aci_access_interface_override" "example" { * `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. -* `relation_to_host_paths` - (list) A list of Relation To Host Paths (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)). +* `relation_to_host_path` - (list) A list of Relation To Host Path (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)). * `annotation` (annotation) - (string) The annotation of the Relation To Host Path object. * `target_dn` (tDn) - (string) The distinguished name of the target. diff --git a/docs/resources/access_interface_override.md b/docs/resources/access_interface_override.md index 9f124b902..6c84d70b7 100644 --- a/docs/resources/access_interface_override.md +++ b/docs/resources/access_interface_override.md @@ -54,7 +54,7 @@ resource "aci_access_interface_override" "full_example" { name_alias = "name_alias_1" owner_key = "owner_key_1" owner_tag = "owner_tag_1" - relation_to_host_paths = [ + relation_to_host_path = [ { annotation = "annotation_1" target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" @@ -108,7 +108,7 @@ All examples for the Access Interface Override resource can be found in the [exa * `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. -* `relation_to_host_paths` - (list) A list of Relation To Host Paths (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)). +* `relation_to_host_path` - (list) A list of Relation To Host Path (ACI object [infraRsHPathAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsHPathAtt/overview)) pointing to (ACI Object [fabricPathEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fabricPathEp/overview)). - Max Items: 1 #### Required #### diff --git a/examples/resources/aci_access_interface_override/resource-all-attributes.tf b/examples/resources/aci_access_interface_override/resource-all-attributes.tf index 08c7d691a..142c2d6de 100644 --- a/examples/resources/aci_access_interface_override/resource-all-attributes.tf +++ b/examples/resources/aci_access_interface_override/resource-all-attributes.tf @@ -6,7 +6,7 @@ resource "aci_access_interface_override" "full_example" { name_alias = "name_alias_1" owner_key = "owner_key_1" owner_tag = "owner_tag_1" - relation_to_host_paths = [ + relation_to_host_path = [ { annotation = "annotation_1" target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" diff --git a/gen/generator.go b/gen/generator.go index 37cdb42d3..22f389cab 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -712,9 +712,9 @@ func main() { for _, model := range classModels { // Only render resources and datasources when the class has a unique identifier or is marked as include in the classes definitions YAML file - // And only render when the class is also not a Rs object and is not set to max one class allowed - // TODO might need to extend this last condition in the future - if (len(model.IdentifiedBy) > 0 || model.Include) && !(strings.HasPrefix(model.RnFormat, "rs") && model.MaxOneClassAllowed) { + // And if the class has a unique identifier, only render when the class is also not a Rs object and is not set to max one class allowed + // TODO might need to modify this last condition in the future + if (len(model.IdentifiedBy) > 0 && !(strings.HasPrefix(model.RnFormat, "rs") && model.MaxOneClassAllowed)) || model.Include { // All classmodels have been read, thus now the model, child and relational resources names can be set // When done before additional files would need to be opened and read which would slow down the generation process @@ -726,7 +726,7 @@ func main() { childMap := make(map[string]Model, 0) for childName, childModel := range model.Children { childModel.ChildResourceName = GetResourceName(childModel.PkgName, definitions) - if len(childModel.IdentifiedBy) > 0 { + if len(childModel.IdentifiedBy) > 0 && !(strings.HasPrefix(childModel.RnFormat, "rs") && childModel.MaxOneClassAllowed) { // TODO add logic to determine the naming for plural child resources childModel.ResourceNameDocReference = childModel.ChildResourceName childModel.ResourceName = fmt.Sprintf("%ss", childModel.ChildResourceName) diff --git a/gen/templates/provider.go.tmpl b/gen/templates/provider.go.tmpl index 4d4b0ee7d..d6c2440bc 100644 --- a/gen/templates/provider.go.tmpl +++ b/gen/templates/provider.go.tmpl @@ -204,7 +204,7 @@ func (p *AciProvider) Configure(ctx context.Context, req provider.ConfigureReque func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ {{- range . }} - {{- if and (or .IdentifiedBy .Include) (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))}} + {{- if or (and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))) .Include}} New{{.ResourceClassName}}Resource, {{- end }} {{- end }} @@ -215,7 +215,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ {{- range . }} - {{- if and (or .IdentifiedBy .Include) (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))}} + {{- if or (and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))) .Include}} New{{.ResourceClassName}}DataSource, {{- end }} {{- end }} diff --git a/gen/testvars/infraHPathS.yaml b/gen/testvars/infraHPathS.yaml index f6695b83c..762f04161 100644 --- a/gen/testvars/infraHPathS.yaml +++ b/gen/testvars/infraHPathS.yaml @@ -26,7 +26,7 @@ all: owner_tag: "owner_tag_1" children: - relation_to_host_paths: + relation_to_host_path: - annotation: "annotation_1" target_dn: "target_dn_0" deletable_child: true diff --git a/internal/provider/data_source_aci_access_interface_override.go b/internal/provider/data_source_aci_access_interface_override.go index 7ffc28cb4..7169293f2 100644 --- a/internal/provider/data_source_aci_access_interface_override.go +++ b/internal/provider/data_source_aci_access_interface_override.go @@ -73,7 +73,7 @@ func (d *InfraHPathSDataSource) Schema(ctx context.Context, req datasource.Schem Computed: true, MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, }, - "relation_to_host_paths": schema.SetNestedAttribute{ + "relation_to_host_path": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, NestedObject: schema.NestedAttributeObject{ diff --git a/internal/provider/resource_aci_access_interface_override.go b/internal/provider/resource_aci_access_interface_override.go index ab6d5c99d..e0034b32d 100644 --- a/internal/provider/resource_aci_access_interface_override.go +++ b/internal/provider/resource_aci_access_interface_override.go @@ -52,7 +52,7 @@ type InfraHPathSResourceModel struct { NameAlias types.String `tfsdk:"name_alias"` OwnerKey types.String `tfsdk:"owner_key"` OwnerTag types.String `tfsdk:"owner_tag"` - InfraRsHPathAtt types.Set `tfsdk:"relation_to_host_paths"` + InfraRsHPathAtt types.Set `tfsdk:"relation_to_host_path"` InfraRsPathToAccBaseGrp types.Set `tfsdk:"relation_to_access_interface_policy_group"` TagAnnotation types.Set `tfsdk:"annotations"` TagTag types.Set `tfsdk:"tags"` @@ -261,7 +261,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq }, MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, }, - "relation_to_host_paths": schema.SetNestedAttribute{ + "relation_to_host_path": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, Computed: true, diff --git a/internal/provider/resource_aci_access_interface_override_test.go b/internal/provider/resource_aci_access_interface_override_test.go index 27dd976b3..013c13939 100644 --- a/internal/provider/resource_aci_access_interface_override_test.go +++ b/internal/provider/resource_aci_access_interface_override_test.go @@ -152,9 +152,9 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.0.annotation", "annotation_1"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.0.target_dn", "uni/infra/funcprof/accportgrp-access_interface_policy_group"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.#", "1"), - resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.#", "1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_path.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_path.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_path.#", "1"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.1.key", "key_1"), @@ -179,9 +179,9 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.0.annotation", "annotation_1"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.0.target_dn", "uni/infra/funcprof/accportgrp-access_interface_policy_group"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.#", "1"), - resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.0.annotation", "annotation_1"), - resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), - resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.#", "1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_path.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_path.0.target_dn", "topology/pod-1/paths-101/pathep-[eth1/1]"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_path.#", "1"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.1.key", "key_1"), @@ -202,7 +202,7 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.0.value", "test_value"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.#", "1"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.#", "0"), - resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.#", "0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_path.#", "0"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.key", "key_1"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.0.value", "test_value"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.#", "1"), @@ -219,7 +219,7 @@ func TestAccResourceInfraHPathS(t *testing.T) { resource.TestCheckResourceAttr("aci_access_interface_override.test", "owner_tag", ""), resource.TestCheckResourceAttr("aci_access_interface_override.test", "annotations.#", "0"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_access_interface_policy_group.#", "0"), - resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_paths.#", "0"), + resource.TestCheckResourceAttr("aci_access_interface_override.test", "relation_to_host_path.#", "0"), resource.TestCheckResourceAttr("aci_access_interface_override.test", "tags.#", "0"), ), }, @@ -286,7 +286,7 @@ resource "aci_access_interface_override" "test" { target_dn = "uni/infra/funcprof/accportgrp-access_interface_policy_group" }, ] - relation_to_host_paths = [ + relation_to_host_path = [ { annotation = "annotation_1" target_dn = "topology/pod-1/paths-101/pathep-[eth1/1]" @@ -321,7 +321,7 @@ resource "aci_access_interface_override" "test" { }, ] relation_to_access_interface_policy_group = [] - relation_to_host_paths = [] + relation_to_host_path = [] tags = [ { key = "key_1" @@ -336,7 +336,7 @@ resource "aci_access_interface_override" "test" { name = "host_path_selector" annotations = [] relation_to_access_interface_policy_group = [] - relation_to_host_paths = [] + relation_to_host_path = [] tags = [] } `