From 83eb57cb7d199b4aff21d8784275448a2c3a1c16 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Tue, 23 Jan 2024 09:24:29 -0500 Subject: [PATCH] [minor_change] Addition of new generated resource and data source for pkiTP --- docs/data-sources/annotation.md | 2 + docs/data-sources/certificate_authority.md | 64 ++ docs/resources/annotation.md | 2 + docs/resources/certificate_authority.md | 120 +++ .../aci_certificate_authority/data-source.tf | 5 + .../aci_certificate_authority/provider.tf | 14 + .../aci_certificate_authority/provider.tf | 14 + .../resource-all-attributes.tf | 17 + .../aci_certificate_authority/resource.tf | 6 + gen/definitions/classes.yaml | 34 + gen/definitions/properties.yaml | 72 ++ gen/generator.go | 64 +- gen/meta/pkiEp.json | 709 ++++++++++++++ gen/meta/pkiTP.json | 868 ++++++++++++++++++ gen/templates/resource_example.tf.tmpl | 7 +- gen/templates/resource_test.go.tmpl | 70 +- gen/templates/testvars.yaml.tmpl | 22 +- gen/testvars/l3extConsLbl.yaml | 5 +- gen/testvars/l3extRsRedistributePol.yaml | 5 +- gen/testvars/mgmtInstP.yaml | 5 +- gen/testvars/mgmtRsOoBCons.yaml | 5 +- gen/testvars/mgmtSubnet.yaml | 5 +- gen/testvars/pimRouteMapEntry.yaml | 5 +- gen/testvars/pimRouteMapPol.yaml | 5 +- gen/testvars/pkiTP.yaml | 43 + gen/testvars/tagAnnotation.yaml | 14 +- gen/testvars/vzOOBBrCP.yaml | 5 +- .../data_source_aci_certificate_authority.go | 153 +++ ...a_source_aci_certificate_authority_test.go | 55 ++ internal/provider/provider.go | 2 + .../provider/resource_aci_annotation_test.go | 90 +- .../resource_aci_certificate_authority.go | 584 ++++++++++++ ...resource_aci_certificate_authority_test.go | 285 ++++++ ...external_management_network_subnet_test.go | 4 +- .../resource_aci_l3out_consumer_label_test.go | 4 +- ...urce_aci_l3out_redistribute_policy_test.go | 4 +- .../resource_aci_pim_route_map_entry_test.go | 4 +- .../resource_aci_pim_route_map_policy_test.go | 4 +- ...n_to_consumed_out_of_band_contract_test.go | 4 +- internal/provider/test_constants.go | 2 + 40 files changed, 3343 insertions(+), 39 deletions(-) create mode 100644 docs/data-sources/certificate_authority.md create mode 100644 docs/resources/certificate_authority.md create mode 100644 examples/data-sources/aci_certificate_authority/data-source.tf create mode 100644 examples/data-sources/aci_certificate_authority/provider.tf create mode 100644 examples/resources/aci_certificate_authority/provider.tf create mode 100644 examples/resources/aci_certificate_authority/resource-all-attributes.tf create mode 100644 examples/resources/aci_certificate_authority/resource.tf create mode 100644 gen/meta/pkiEp.json create mode 100644 gen/meta/pkiTP.json create mode 100644 gen/testvars/pkiTP.yaml create mode 100644 internal/provider/data_source_aci_certificate_authority.go create mode 100644 internal/provider/data_source_aci_certificate_authority_test.go create mode 100644 internal/provider/resource_aci_certificate_authority.go create mode 100644 internal/provider/resource_aci_certificate_authority_test.go diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index 16bf50ce8..b11520950 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -65,6 +65,8 @@ data "aci_annotation" "example_application_epg" { - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) + - [aci_public_key_management](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/public_key_management) ([pkiEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pkiEp/overview)) + - [aci_certificate_authority](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/certificate_authority) ([pkiTP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pkiTP/overview)) - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) diff --git a/docs/data-sources/certificate_authority.md b/docs/data-sources/certificate_authority.md new file mode 100644 index 000000000..7004b0080 --- /dev/null +++ b/docs/data-sources/certificate_authority.md @@ -0,0 +1,64 @@ +--- +# 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_certificate_authority" +sidebar_current: "docs-aci-data-source-aci_certificate_authority" +description: |- + Data source for Certificate Authority +--- + +# aci_certificate_authority # + +Data source for Certificate Authority + +## API Information ## + +* Class: [pkiTP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pkiTP/overview) + + +* Distinguished Name Formats: + - `uni/tn-{name}/certstore/tp-{name}` + - `uni/userext/pkiext/tp-{name}` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## + +```hcl + +data "aci_certificate_authority" "example_public_key_management" { + parent_dn = aci_public_key_management.example.id + name = "test_name" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_public_key_management](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/public_key_management) ([pkiEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pkiEp/overview)) + - The distinquised name (DN) of classes below can be used but currently there is no available resource for it: + - [cloudCertStore](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/cloudCertStore/overview) + +* `name` (name) - (string) The name of the Certificate Authority object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Certificate Authority object. +* `annotation` (annotation) - (string) The annotation of the Certificate Authority object. +* `cert_chain` (certChain) - (string) The PEM-encoded chain of trust from the trustpoint to a trusted root authority. +* `description` (descr) - (string) The description of the Certificate Authority object. +* `name_alias` (nameAlias) - (string) The name alias of the Certificate Authority 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 objects ([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/resources/annotation.md b/docs/resources/annotation.md index 8681160d1..a9e7b6cd0 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -74,6 +74,8 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) + - [aci_public_key_management](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/public_key_management) ([pkiEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pkiEp/overview)) + - [aci_certificate_authority](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/certificate_authority) ([pkiTP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pkiTP/overview)) - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) diff --git a/docs/resources/certificate_authority.md b/docs/resources/certificate_authority.md new file mode 100644 index 000000000..a3b580f26 --- /dev/null +++ b/docs/resources/certificate_authority.md @@ -0,0 +1,120 @@ +--- +# 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_certificate_authority" +sidebar_current: "docs-aci-resource-aci_certificate_authority" +description: |- + Manages ACI Certificate Authority +--- + +# aci_certificate_authority # + +Manages ACI Certificate Authority + + + +## API Information ## + +* Class: [pkiTP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pkiTP/overview) + + +* Distinguished Name Formats: + - `uni/tn-{name}/certstore/tp-{name}` + - `uni/userext/pkiext/tp-{name}` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## + +The configuration snippet below creates a Certificate Authority with only required attributes. + +```hcl + +resource "aci_certificate_authority" "example_public_key_management" { + parent_dn = "uni/userext/pkiext" + cert_chain = "< This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_certificate_authority" "full_example_public_key_management" { + parent_dn = aci_public_key_management.example.id + annotation = "annotation" + cert_chain = "< Policies -> Protocol -> Endpoint Tags -> Endpoint IP" sub_category: "Tenant Policies" +======= +commHttps: + include: true + +# pkiKeyRing: +# contained_by: +# - "polUni" +# rn_prepend: "userext/pkiext" +# dn_formats: +# #- "uni/tn-{name}/certstore/tp-{name}" +# - "uni/userext/pkiext/tp-{name}" + +# cloudCertStore: +# rn_format: "uni/tn-{name}" + +# pkiKeyRing: +# parent_dn: +# - "uni/userext/pkiext" + +pkiTP: + # contained_by: + # - "pkiEp" + parent_dn: + - "uni/userext/pkiext" + +# aaaUserEp: +# contained_by: +# - "polUni" +# rn_prepend: "uni" +# dn_formats: +# - "uni/userext" + +>>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 5d927a888..d4d80080b 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -138,3 +138,75 @@ tagAnnotation: test_values: default: value: "test_value" + parents: + - class_name: "commHttps" + parent_dependency: "commPol" + - class_name: "commPol" + parent_dependency: "" + +pkiTP: + parents: + - parent_dn: "uni/userext/pkiext" + - is_explicit_parent_dn: true + resource_required: + - "certChain" + test_values: + resource_required: + cert_chain: <>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) } // Set variables that are used during the rendering of the example and documentation templates @@ -1394,6 +1450,7 @@ func setDocumentationData(m *Model, definitions Definitions) { // TODO add overwrite to provide which documentation examples to be included docsExampleAmount := m.Configuration["docs_examples_amount"].(int) +<<<<<<< HEAD if len(m.ContainedBy) >= docsExampleAmount { overwriteExampleClasses := GetOverwriteExampleClasses(m.PkgName, definitions) if len(overwriteExampleClasses) > 0 { @@ -1404,6 +1461,11 @@ func setDocumentationData(m *Model, definitions Definitions) { for _, resourceDetails := range resourcesFound[0:docsExampleAmount] { m.DocumentationExamples = append(m.DocumentationExamples, resourceDetails[1]) } +======= + if len(m.ContainedBy) > docsExampleAmount { + for _, resourceDetails := range resourcesFound[0:docsExampleAmount] { + m.DocumentationExamples = append(m.DocumentationExamples, resourceDetails[1]) +>>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) } } else { for _, resourceDetails := range resourcesFound { diff --git a/gen/meta/pkiEp.json b/gen/meta/pkiEp.json new file mode 100644 index 000000000..91e43e819 --- /dev/null +++ b/gen/meta/pkiEp.json @@ -0,0 +1,709 @@ +{ + "pki:Ep": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "pki:CsyncPolicy": "", + "pki:CsyncSharedKey": "", + "pki:DebugPluginChallenge": "", + "pki:KeyRing": "", + "pki:RtResPkiEp": "", + "pki:SiteJwtPubKey": "", + "pki:TP": "", + "pki:TbkKey": "", + "pki:WebTokenData": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "csyncpolicy": "pki:CsyncPolicy", + "csyncsharedkey": "pki:CsyncSharedKey", + "dbgplgch": "pki:DebugPluginChallenge", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "keyring-": "pki:KeyRing", + "rbacDom-": "aaa:RbacAnnotation", + "rtfabricResPkiEp-": "pki:RtResPkiEp", + "sitejwtpubkey-": "pki:SiteJwtPubKey", + "tagKey-": "tag:Tag", + "tbkey-": "pki:TbkKey", + "tp-": "pki:TP", + "webtokendata": "pki:WebTokenData" + }, + "identifiedBy": [ + + ], + "rnFormat": "pkiext", + "containedBy": { + "aaa:UserEp": "" + }, + "superClasses": [ + "pki:Definition", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "pki:RtResPkiEp": "fabric:SecRelnHolder" + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/userext/pkiext" + ], + "writeAccess": [ + "aaa", + "admin" + ], + "readAccess": [ + "aaa", + "admin" + ], + "faults": { + + }, + "events": { + "E4212884": "creation||pki:Ep", + "E4212885": "modification||pki:Ep", + "E4212886": "deletion||pki:Ep" + }, + "stats": { + + }, + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": 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": "ambiguous", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "never", + "platformFlavors": [ + + ], + "classId": "1478", + "className": "Ep", + "classPkg": "pki", + "featureTag": "", + "moCategory": "Regular", + "label": "Public Key Management", + "comment": [ + "The PKI configuration, which includes key rings and certificate authority (CA) credentials. Components of the PKI are used to establish secure communications between two devices." + ], + "properties": { + "annotation": { + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37505", + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "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": "deleteAll "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "deleteNonPresent "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "ignore "} + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "39644", + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "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": "ResolvedOnBehalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "14133", + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "name": { + "comment": [ + "" + ], + "isConfigurable": true, + "propGlobalId": "1221", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": true, + "readWrite": false, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "ownerKey": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "ownerTag": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "status": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/meta/pkiTP.json b/gen/meta/pkiTP.json new file mode 100644 index 000000000..8f9bdb680 --- /dev/null +++ b/gen/meta/pkiTP.json @@ -0,0 +1,868 @@ +{ + "pki:TP": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "fault:Inst": "", + "health:Inst": "", + "pki:RtClientCertCA": "", + "pki:RtSvrCertChain": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fault-": "fault:Inst", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "rtadepgSvrCertChain-": "pki:RtSvrCertChain", + "rtcommClientCertCA-": "pki:RtClientCertCA", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "tp-{name}", + "containedBy": { + "cloud:CertStore": "", + "pki:Ep": "" + }, + "superClasses": [ + "pki:Item", + "pki:Definition", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "pki:RtClientCertCA": "comm:Https", + "pki:RtSvrCertChain": "adepg:ASvr" + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/tn-{name}/certstore/tp-{name}", + "uni/userext/pkiext/tp-{name}" + ], + "writeAccess": [ + "aaa", + "admin" + ], + "readAccess": [ + "aaa", + "admin" + ], + "faults": { + "F2930": "fltPkiTPTPExpired", + "F2929": "fltPkiTPTPExpiring" + }, + "events": { + "E4204971": "creation||pki:TP", + "E4204972": "deletion||pki:TP", + "E4204973": "modification||pki:TP", + "E4212896": "creation||pki:TP", + "E4212897": "modification||pki:TP", + "E4212898": "deletion||pki:TP" + }, + "stats": { + + }, + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": 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": "ambiguous", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + + ], + "classId": "1483", + "className": "TP", + "classPkg": "pki", + "featureTag": "", + "moCategory": "Regular", + "label": "Certificate Authority", + "comment": [ + "A trustpoint (certificate authority/CA), which issues and validates (signs) digital certificates. When participating in secure communications using the public key infrastructure (PKI), a participant can verify the identity of the other party through the CA that signed the other party's public key." + ], + "properties": { + "annotation": { + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37509", + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "certChain": { + "comment": [ + "The PEM-encoded chain of trust from the trustpoint to a trusted root authority." + ], + "isConfigurable": true, + "propGlobalId": "1207", + "propLocalId": "635", + "label": "Certificate Chain", + "baseType": "string:CharBuffer", + "modelType": "pki:Cert", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "certValidUntil": { + "comment": [ + "The certificate expiration date of the certificate posted by the user in the cert field." + ], + "isConfigurable": false, + "propGlobalId": "35520", + "propLocalId": "632", + "label": "Certificate Validity", + "baseType": "string:CharBuffer", + "modelType": "pki:CertValidity", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "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": "deleteAll "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "deleteNonPresent "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "ignore "} + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "expState": { + "isConfigurable": false, + "propGlobalId": "35521", + "propLocalId": "8280", + "label": "expState", + "baseType": "scalar:Enum8", + "modelType": "pki:ExpStatus", + "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": "active", + "platformFlavors": [ + + ], + "label": "Active "}, + { "value": "active", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "3", "localName": "expired", + "platformFlavors": [ + + ], + "label": "Expired "}, + { "value": "2", "localName": "expiring", + "platformFlavors": [ + + ], + "label": "Expiring "} + ], + "default": "active", + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "39648", + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "fp": { + "comment": [ + "This property is managed internally and should not be modified by the user." + ], + "isConfigurable": false, + "propGlobalId": "1208", + "propLocalId": "636", + "label": "fp", + "baseType": "string:CharBuffer", + "modelType": "pki:FP", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "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": "ResolvedOnBehalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "26561", + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "name": { + "comment": [ + "The name of the certificate authority (CA or trustpoint)." + ], + "isConfigurable": true, + "propGlobalId": "7018", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 1, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "numCerts": { + "comment": [ + "The number of certificates found in the certificate chain." + ], + "isConfigurable": false, + "propGlobalId": "1209", + "propLocalId": "637", + "label": "numCerts", + "baseType": "scalar:Uint32", + "modelType": "scalar:Uint32", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "0", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "0", + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "ownerKey": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "ownerTag": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "status": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "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": [ + + ], + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/templates/resource_example.tf.tmpl b/gen/templates/resource_example.tf.tmpl index 8cb4e3d4f..aaec75a62 100644 --- a/gen/templates/resource_example.tf.tmpl +++ b/gen/templates/resource_example.tf.tmpl @@ -1,8 +1,13 @@ {{- if .DocumentationExamples}}{{- range $key := .DocumentationExamples}} resource "aci_{{$.ResourceName}}" "example_{{getResourceName $key $.Definitions}}" { - {{- if $.HasParent}} + {{- if and $.HasParent (not $.ExplicitParentDns)}} parent_dn = {{createParentDnValue $key "example" $.Definitions}} {{- end}} + {{- if $.ExplicitParentDns}} + {{- range $.ExplicitParentDns}} + parent_dn = "{{.}}" + {{- end}} + {{- end}} {{- range $.Properties}}{{- if .IsRequired}}{{- if ne .NamedPropertyClass ""}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name {{- else}} diff --git a/gen/templates/resource_test.go.tmpl b/gen/templates/resource_test.go.tmpl index fccd71dab..f42e9b4f0 100644 --- a/gen/templates/resource_test.go.tmpl +++ b/gen/templates/resource_test.go.tmpl @@ -6,6 +6,15 @@ package provider import ( "testing" + {{- $found_time_cert := false -}} + {{- range $key, $value := $.default}} + {{- if contains $key "cert" }} + {{- $found_time_cert = true -}} + {{- end}} + {{- end}} + {{- if $found_time_cert }} + "time" + {{- end}} "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) @@ -15,7 +24,18 @@ import ( func TestAccResource{{$.resourceClassName}}With{{capitalize .class_name}}(t *testing.T) { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + {{- $found_cert := false -}} +{{- range $key, $value := $.default}} + {{- if contains $key "cert" }} + {{- $found_cert = true -}} + {{- end}} +{{- end}} +PreCheck: func() { + testAccPreCheck(t) + {{- if $found_cert }} + time.Sleep(10 * time.Second) + {{- end }} +}, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create with minimum config and verify default APIC values @@ -29,7 +49,11 @@ func TestAccResource{{$.resourceClassName}}With{{capitalize .class_name}}(t *tes {{- end}} {{- end}} {{- range $key, $value := $.default}} + {{- if contains $value "<>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) {{- end}} {{- end}} +{{- if not .Include}} datasource_non_existing: {{- range .Properties}}{{$testValue := createNonExistingValue .SnakeCaseName}}{{$overwritePropertyName := overwriteProperty .PkgName .SnakeCaseName $.Definitions}} {{- if or .IsNaming }} @@ -31,6 +38,7 @@ resource_required: {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: "{{overwritePropertyValue .PkgName $overwritePropertyName $testValue "resource_required" $.Definitions}}" {{- end}} {{- end}} +{{- end}} all: {{- range .Properties}}{{$overwritePropertyName := overwriteProperty .PkgName .SnakeCaseName $.Definitions}} @@ -53,7 +61,7 @@ children: {{ end}} - {{ range .Properties}}{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: {{$length := len .ValidValues}}{{if ge $length 2}}"{{ index .ValidValues 1 }}"{{else if not .IsNaming}}"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}_2"{{- else}}"{{$name}}_2"{{- end}} {{ end}}{{- end}}{{- end}} -{{- if .ContainedBy}} +{{- if and .ContainedBy (not .ExplicitParentDns) }} parents: {{- $index := 0}}{{- range $key := .DocumentationExamples}}{{$parentDependency := getParentTestDependencies $.PkgName $index $.Definitions}} - class_name: "{{ $key }}" @@ -62,3 +70,15 @@ parents: class_in_parent: {{$parentDependency.class_in_parent}}{{$index = add $index 1}} {{- end}} {{- end}} +{{- if .ExplicitParentDns}} +parents: +{{- $index := 0}}{{- range $key := .DocumentationExamples}}{{$parentDependency := getParentTestDependencies $.PkgName $index $.Definitions}} + - class_name: "{{ $key }}" + parent_dependency: "{{$parentDependency.parent_dependency}}" + class_in_parent: {{$parentDependency.class_in_parent}}{{$index = add $index 1}} + {{- end}} +{{- range .ExplicitParentDns}} + parent_dn: "{{.}}" + is_explicit_parent_dn: true + {{- end}} + {{- end}} \ No newline at end of file diff --git a/gen/testvars/l3extConsLbl.yaml b/gen/testvars/l3extConsLbl.yaml index 07d8ef97f..0d57cf25b 100644 --- a/gen/testvars/l3extConsLbl.yaml +++ b/gen/testvars/l3extConsLbl.yaml @@ -10,7 +10,6 @@ default: owner_key: "" owner_tag: "" tag: "yellow-green" - datasource_non_existing: name: "non_existing_name" @@ -18,7 +17,7 @@ datasource_required: name: "test_name" resource_required: - name: "test_name" + name: "test_name" all: annotation: "annotation" @@ -41,4 +40,4 @@ parents: - class_name: "l3extOut" parent_dependency: "" parent_dn: "aci_l3_outside.test.id" - class_in_parent: false + class_in_parent: false \ No newline at end of file diff --git a/gen/testvars/l3extRsRedistributePol.yaml b/gen/testvars/l3extRsRedistributePol.yaml index 11268732f..cac8ec2a4 100644 --- a/gen/testvars/l3extRsRedistributePol.yaml +++ b/gen/testvars/l3extRsRedistributePol.yaml @@ -5,7 +5,6 @@ default: annotation: "orchestrator:terraform" source: "direct" - datasource_non_existing: source: "static" route_control_profile_name: "non_existing_tn_rtctrl_profile_name" @@ -16,7 +15,7 @@ datasource_required: resource_required: source: "direct" - route_control_profile_name: "test_tn_rtctrl_profile_name" + route_control_profile_name: "test_tn_rtctrl_profile_name" all: annotation: "annotation" @@ -34,4 +33,4 @@ parents: - class_name: "l3extOut" parent_dependency: "fvTenant" parent_dn: "aci_l3_outside.test.id" - class_in_parent: true + class_in_parent: true \ No newline at end of file diff --git a/gen/testvars/mgmtInstP.yaml b/gen/testvars/mgmtInstP.yaml index 4e0884f3f..416458d3b 100644 --- a/gen/testvars/mgmtInstP.yaml +++ b/gen/testvars/mgmtInstP.yaml @@ -7,7 +7,6 @@ default: description: "" name_alias: "" priority: "unspecified" - datasource_non_existing: name: "non_existing_name" @@ -15,7 +14,7 @@ datasource_required: name: "test_name" resource_required: - name: "test_name" + name: "test_name" all: annotation: "annotation" @@ -39,4 +38,4 @@ children: - key: "annotations_2" value: "value_2" - + \ No newline at end of file diff --git a/gen/testvars/mgmtRsOoBCons.yaml b/gen/testvars/mgmtRsOoBCons.yaml index 65c5abd4c..dca91b968 100644 --- a/gen/testvars/mgmtRsOoBCons.yaml +++ b/gen/testvars/mgmtRsOoBCons.yaml @@ -5,7 +5,6 @@ default: annotation: "orchestrator:terraform" priority: "unspecified" - datasource_non_existing: out_of_band_contract_name: "non_existing_tn_vz_oob_br_cp_name" @@ -13,7 +12,7 @@ datasource_required: out_of_band_contract_name: "test_tn_vz_oob_br_cp_name" resource_required: - out_of_band_contract_name: "test_tn_vz_oob_br_cp_name" + out_of_band_contract_name: "test_tn_vz_oob_br_cp_name" all: annotation: "annotation" @@ -31,4 +30,4 @@ parents: - class_name: "mgmtInstP" parent_dependency: "" parent_dn: "aci_external_management_network_instance_profile.test.id" - class_in_parent: true + class_in_parent: true \ No newline at end of file diff --git a/gen/testvars/mgmtSubnet.yaml b/gen/testvars/mgmtSubnet.yaml index 3331a9269..7847957af 100644 --- a/gen/testvars/mgmtSubnet.yaml +++ b/gen/testvars/mgmtSubnet.yaml @@ -7,7 +7,6 @@ default: description: "" name: "" name_alias: "" - datasource_non_existing: ip: "2.2.2.0/24" @@ -15,7 +14,7 @@ datasource_required: ip: "1.1.1.0/24" resource_required: - ip: "1.1.1.0/24" + ip: "1.1.1.0/24" all: annotation: "annotation" @@ -35,4 +34,4 @@ parents: - class_name: "mgmtInstP" parent_dependency: "" parent_dn: "aci_external_management_network_instance_profile.test.id" - class_in_parent: false + class_in_parent: false \ No newline at end of file diff --git a/gen/testvars/pimRouteMapEntry.yaml b/gen/testvars/pimRouteMapEntry.yaml index 1fad1b565..8f26b067c 100644 --- a/gen/testvars/pimRouteMapEntry.yaml +++ b/gen/testvars/pimRouteMapEntry.yaml @@ -11,7 +11,6 @@ default: name_alias: "" rendezvous_point_ip: "0.0.0.0" source_ip: "0.0.0.0" - datasource_non_existing: order: "2" @@ -19,7 +18,7 @@ datasource_required: order: "1" resource_required: - order: "1" + order: "1" all: action: "deny" @@ -43,4 +42,4 @@ parents: - class_name: "pimRouteMapPol" parent_dependency: "fvTenant" parent_dn: "aci_pim_route_map_policy.test.id" - class_in_parent: false + class_in_parent: false \ No newline at end of file diff --git a/gen/testvars/pimRouteMapPol.yaml b/gen/testvars/pimRouteMapPol.yaml index 1ded4b16a..6cd7caa86 100644 --- a/gen/testvars/pimRouteMapPol.yaml +++ b/gen/testvars/pimRouteMapPol.yaml @@ -8,7 +8,6 @@ default: name_alias: "" owner_key: "" owner_tag: "" - datasource_non_existing: name: "non_existing_name" @@ -16,7 +15,7 @@ datasource_required: name: "test_name" resource_required: - name: "test_name" + name: "test_name" all: annotation: "annotation" @@ -37,4 +36,4 @@ parents: - class_name: "fvTenant" parent_dependency: "" parent_dn: "aci_tenant.test.id" - class_in_parent: false + class_in_parent: false \ No newline at end of file diff --git a/gen/testvars/pkiTP.yaml b/gen/testvars/pkiTP.yaml new file mode 100644 index 000000000..8e09668a6 --- /dev/null +++ b/gen/testvars/pkiTP.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" + cert_chain: "<>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) diff --git a/gen/testvars/vzOOBBrCP.yaml b/gen/testvars/vzOOBBrCP.yaml index 94c05cc58..f5265f7c9 100644 --- a/gen/testvars/vzOOBBrCP.yaml +++ b/gen/testvars/vzOOBBrCP.yaml @@ -12,7 +12,6 @@ default: priority: "unspecified" scope: "context" target_dscp: "unspecified" - datasource_non_existing: name: "non_existing_name" @@ -20,7 +19,7 @@ datasource_required: name: "test_name" resource_required: - name: "test_name" + name: "test_name" all: annotation: "annotation" @@ -40,4 +39,4 @@ children: - key: "annotations_2" value: "value_2" - + \ No newline at end of file diff --git a/internal/provider/data_source_aci_certificate_authority.go b/internal/provider/data_source_aci_certificate_authority.go new file mode 100644 index 000000000..0e3c2220e --- /dev/null +++ b/internal/provider/data_source_aci_certificate_authority.go @@ -0,0 +1,153 @@ +// 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 = &PkiTPDataSource{} + +func NewPkiTPDataSource() datasource.DataSource { + return &PkiTPDataSource{} +} + +// PkiTPDataSource defines the data source implementation. +type PkiTPDataSource struct { + client *client.Client +} + +func (d *PkiTPDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_certificate_authority") + resp.TypeName = req.ProviderTypeName + "_certificate_authority" + tflog.Debug(ctx, "End metadata of datasource: aci_certificate_authority") +} + +func (d *PkiTPDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_certificate_authority") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The certificate_authority datasource for the 'pkiTP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Certificate Authority 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 Certificate Authority object.`, + }, + "cert_chain": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The PEM-encoded chain of trust from the trustpoint to a trusted root authority.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Certificate Authority object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Certificate Authority object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Certificate Authority 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.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_certificate_authority") +} + +func (d *PkiTPDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_certificate_authority") + // 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_certificate_authority") +} + +func (d *PkiTPDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_certificate_authority") + var data *PkiTPResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setPkiTPId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetPkiTPAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_certificate_authority with id '%s'", data.Id.ValueString())) + + getAndSetPkiTPAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_certificate_authority data source", + fmt.Sprintf("The aci_certificate_authority 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_certificate_authority with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_certificate_authority_test.go b/internal/provider/data_source_aci_certificate_authority_test.go new file mode 100644 index 000000000..dded60343 --- /dev/null +++ b/internal/provider/data_source_aci_certificate_authority_test.go @@ -0,0 +1,55 @@ +// 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 TestAccDataSourcePkiTPWithPkiEp(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigPkiTPDataSourceDependencyWithPkiEp, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_certificate_authority.test", "name", "test_name"), + resource.TestCheckResourceAttr("data.aci_certificate_authority.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_certificate_authority.test", "cert_chain", "<>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) func TestAccResourceTagAnnotationWithFvTenant(t *testing.T) { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create with minimum config and verify default APIC values @@ -67,6 +129,7 @@ func TestAccResourceTagAnnotationWithFvTenant(t *testing.T) { } func TestAccResourceTagAnnotationWithFvAEPg(t *testing.T) { +<<<<<<< HEAD resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, @@ -120,6 +183,31 @@ func TestAccResourceTagAnnotationWithFvAEPg(t *testing.T) { }, }) } +======= +const testConfigTagAnnotationMinDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithCommPol + ` +resource "aci_annotation" "test" { + parent_dn = aci_application_epg.test.id + key = "test_key" + value = "test_value" +} +` + +const testConfigTagAnnotationAllDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithCommPol + ` +resource "aci_annotation" "test" { + parent_dn = aci_application_epg.test.id + key = "test_key" + value = "value" +} +` + +const testConfigTagAnnotationResetDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithCommPol + ` +resource "aci_annotation" "test" { + parent_dn = aci_application_epg.test.id + key = "test_key" + value = "test_value" +} +` +>>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) const testConfigTagAnnotationMinDependencyWithFvTenant = testConfigFvTenantMin + ` resource "aci_annotation" "test" { diff --git a/internal/provider/resource_aci_certificate_authority.go b/internal/provider/resource_aci_certificate_authority.go new file mode 100644 index 000000000..2d4824c7e --- /dev/null +++ b/internal/provider/resource_aci_certificate_authority.go @@ -0,0 +1,584 @@ +// 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 = &PkiTPResource{} +var _ resource.ResourceWithImportState = &PkiTPResource{} + +func NewPkiTPResource() resource.Resource { + return &PkiTPResource{} +} + +// PkiTPResource defines the resource implementation. +type PkiTPResource struct { + client *client.Client +} + +// PkiTPResourceModel describes the resource data model. +type PkiTPResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + CertChain types.String `tfsdk:"cert_chain"` + 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"` +} + +// TagAnnotationPkiTPResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationPkiTPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +type PkiTPIdentifier struct { + Name types.String +} + +func (r *PkiTPResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_certificate_authority") + resp.TypeName = req.ProviderTypeName + "_certificate_authority" + tflog.Debug(ctx, "End metadata of resource: aci_certificate_authority") +} + +func (r *PkiTPResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_certificate_authority") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The certificate_authority resource for the 'pkiTP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Certificate Authority 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(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Certificate Authority object.`, + }, + "cert_chain": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The PEM-encoded chain of trust from the trustpoint to a trusted root authority.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the Certificate Authority object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Certificate Authority object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the Certificate Authority 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.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_certificate_authority") +} + +func (r *PkiTPResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_certificate_authority") + // 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_certificate_authority") +} + +func (r *PkiTPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_certificate_authority") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *PkiTPResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + setPkiTPId(ctx, stateData) + getAndSetPkiTPAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *PkiTPResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setPkiTPId(ctx, data) + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_certificate_authority with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationPkiTPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + jsonPayload := getPkiTPCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState) + + if resp.Diagnostics.HasError() { + return + } + + doPkiTPRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetPkiTPAttributes(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_certificate_authority with id '%s'", data.Id.ValueString())) +} + +func (r *PkiTPResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_certificate_authority") + var data *PkiTPResourceModel + + // 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_certificate_authority with id '%s'", data.Id.ValueString())) + + getAndSetPkiTPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *PkiTPResourceModel + 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_certificate_authority with id '%s'", data.Id.ValueString())) +} + +func (r *PkiTPResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_certificate_authority") + var data *PkiTPResourceModel + var stateData *PkiTPResourceModel + + // 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_certificate_authority with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationPkiTPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + jsonPayload := getPkiTPCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState) + + if resp.Diagnostics.HasError() { + return + } + + doPkiTPRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetPkiTPAttributes(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_certificate_authority with id '%s'", data.Id.ValueString())) +} + +func (r *PkiTPResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_certificate_authority") + var data *PkiTPResourceModel + + // 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_certificate_authority with id '%s'", data.Id.ValueString())) + jsonPayload := getPkiTPDeleteJsonPayload(ctx, &resp.Diagnostics, data) + if resp.Diagnostics.HasError() { + return + } + doPkiTPRequest(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_certificate_authority with id '%s'", data.Id.ValueString())) +} + +func (r *PkiTPResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_certificate_authority") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *PkiTPResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_certificate_authority with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_certificate_authority") +} + +func getAndSetPkiTPAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *PkiTPResourceModel) { + requestData := doPkiTPRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "pkiTP,tagAnnotation"), "GET", nil) + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("pkiTP").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("pkiTP").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)) + setPkiTPParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "certChain" { + data.CertChain = 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)) + } + } + TagAnnotationPkiTPList := make([]TagAnnotationPkiTPResourceModel, 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" { + TagAnnotationPkiTP := TagAnnotationPkiTPResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationPkiTP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationPkiTP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationPkiTPList = append(TagAnnotationPkiTPList, TagAnnotationPkiTP) + } + } + } + } + if len(TagAnnotationPkiTPList) > 0 { + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationPkiTPList) + data.TagAnnotation = tagAnnotationSet + } + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'pkiTP'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getPkiTPRn(ctx context.Context, data *PkiTPResourceModel) string { + rn := "tp-{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 setPkiTPParentDn(ctx context.Context, dn string, data *PkiTPResourceModel) { + 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 setPkiTPId(ctx context.Context, data *PkiTPResourceModel) { + rn := getPkiTPRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getPkiTPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *PkiTPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPkiTPResourceModel) []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 getPkiTPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *PkiTPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPkiTPResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getPkiTPTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.CertChain.IsNull() && !data.CertChain.IsUnknown() { + payloadMap["attributes"].(map[string]string)["certChain"] = data.CertChain.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{}{"pkiTP": 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 +} + +func getPkiTPDeleteJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *PkiTPResourceModel) *container.Container { + + jsonString := fmt.Sprintf(`{"pkiTP":{"attributes":{"dn": "%s","status": "deleted"}}}`, data.Id.ValueString()) + jsonPayload, err := container.ParseJSON([]byte(jsonString)) + 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 +} + +func doPkiTPRequest(ctx context.Context, diags *diag.Diagnostics, client *client.Client, path, method string, payload *container.Container) *container.Container { + + restRequest, err := client.MakeRestRequest(method, path, payload, true) + if err != nil { + diags.AddError( + "Creation of rest request failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + cont, restResponse, err := client.Do(restRequest) + + if restResponse != nil && restResponse.StatusCode != 200 { + diags.AddError( + fmt.Sprintf("The %s rest request failed", strings.ToLower(method)), + fmt.Sprintf("Response: %s, err: %s. Please report this issue to the provider developers.", cont.Data().(map[string]interface{})["imdata"], err), + ) + return nil + } else if err != nil { + diags.AddError( + fmt.Sprintf("The %s rest request failed", strings.ToLower(method)), + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + return cont +} diff --git a/internal/provider/resource_aci_certificate_authority_test.go b/internal/provider/resource_aci_certificate_authority_test.go new file mode 100644 index 000000000..4ac74d0d2 --- /dev/null +++ b/internal/provider/resource_aci_certificate_authority_test.go @@ -0,0 +1,285 @@ +// 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" + "time" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourcePkiTPWithPkiEp(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + time.Sleep(10 * time.Second) + }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigPkiTPMinDependencyWithPkiEp, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "-----BEGIN CERTIFICATE-----\nMIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV\nBAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX\nDTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p\nbjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG\n9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i\nv+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl\nXHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw\nAQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud\nIwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl\n3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l\nKU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00=\n-----END CERTIFICATE-----\n"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "description", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigPkiTPAllDependencyWithPkiEp, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "-----BEGIN CERTIFICATE-----\nMIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV\nBAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX\nDTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p\nbjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG\n9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i\nv+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl\nXHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw\nAQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud\nIwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl\n3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l\nKU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00=\n-----END CERTIFICATE-----\n"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "description", "description"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "owner_tag", "owner_tag"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigPkiTPMinDependencyWithPkiEp, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "-----BEGIN CERTIFICATE-----\nMIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV\nBAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX\nDTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p\nbjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG\n9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i\nv+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl\nXHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw\nAQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud\nIwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl\n3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l\nKU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00=\n-----END CERTIFICATE-----\n"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name", "test_name"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigPkiTPResetDependencyWithPkiEp, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "-----BEGIN CERTIFICATE-----\nMIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV\nBAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX\nDTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p\nbjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG\n9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i\nv+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl\nXHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw\nAQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud\nIwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl\n3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l\nKU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00=\n-----END CERTIFICATE-----\n"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "description", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_certificate_authority.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "-----BEGIN CERTIFICATE-----\nMIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV\nBAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX\nDTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p\nbjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG\n9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i\nv+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl\nXHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw\nAQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud\nIwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl\n3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l\nKU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00=\n-----END CERTIFICATE-----\n"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "description", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_certificate_authority.test", "owner_tag", ""), + ), + }, + // Update with children + { + Config: testConfigPkiTPChildrenDependencyWithPkiEp, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "<