diff --git a/aci/data_source_aci_fvbd.go b/aci/data_source_aci_fvbd.go index c2a46855e..e31b06ec2 100644 --- a/aci/data_source_aci_fvbd.go +++ b/aci/data_source_aci_fvbd.go @@ -123,6 +123,12 @@ func dataSourceAciBridgeDomain() *schema.Resource { Computed: true, }, + "seg": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "unicast_route": &schema.Schema{ Type: schema.TypeString, Optional: true, diff --git a/aci/resource_aci_fvbd.go b/aci/resource_aci_fvbd.go index 13cc58093..2f8b8972e 100644 --- a/aci/resource_aci_fvbd.go +++ b/aci/resource_aci_fvbd.go @@ -179,6 +179,11 @@ func resourceAciBridgeDomain() *schema.Resource { }, false), }, + "seg": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "unicast_route": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -351,6 +356,7 @@ func setBridgeDomainAttributes(fvBD *models.BridgeDomain, d *schema.ResourceData d.Set("multi_dst_pkt_act", fvBDMap["multiDstPktAct"]) d.Set("name_alias", fvBDMap["nameAlias"]) d.Set("bridge_domain_type", fvBDMap["type"]) + d.Set("seg", fvBDMap["seg"]) d.Set("unicast_route", fvBDMap["unicastRoute"]) d.Set("unk_mac_ucast_act", fvBDMap["unkMacUcastAct"]) d.Set("unk_mcast_act", fvBDMap["unkMcastAct"]) diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index be846d4f5..e4a089383 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -73,7 +73,7 @@ data "aci_annotation" "example_application_epg" { - [aci_epg_useg_ad_group_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_ad_group_attribute) ([fvIdGroupAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvIdGroupAttr/overview)) - [aci_epg_useg_ip_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_ip_attribute) ([fvIpAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvIpAttr/overview)) - [aci_epg_useg_mac_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_mac_attribute) ([fvMacAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvMacAttr/overview)) - - [aci_relation_to_consumed_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_contract) ([fvRsCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRsCons/overview)) + - [aci_remote_site_id_mappings](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/remote_site_id_mappings) ([fvRemoteId](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRemoteId/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/data-sources/application_epg.md b/docs/data-sources/application_epg.md index cdb55c6ce..fd1dff0fb 100644 --- a/docs/data-sources/application_epg.md +++ b/docs/data-sources/application_epg.md @@ -174,6 +174,15 @@ data "aci_application_epg" "example_application_profile" { * `annotation` (annotation) - (string) The annotation of the Relation To Trust Control Policy object. * `trust_control_policy_name` (tnFhsTrustCtrlPolName) - (string) Name. +* `associated_site` - (list) A list of Associated Site (ACI object [fvSiteAssociated](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvSiteAssociated/overview)). This attribute is supported in ACI versions: 3.0(1k) and later. + * `annotation` (annotation) - (string) The annotation of the Associated Site object. + * `description` (descr) - (string) The description of the Associated Site object. + * `name` (name) - (string) The name of the Associated Site object. + * `name_alias` (nameAlias) - (string) The name alias of the Associated Site 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. + * `site_id` (siteId) - (string) A number between 0 and 1000 to identify the primary site being associated. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/associated_site.md b/docs/data-sources/associated_site.md new file mode 100644 index 000000000..85bc19451 --- /dev/null +++ b/docs/data-sources/associated_site.md @@ -0,0 +1,78 @@ +--- +# 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: "Multi-Site" +layout: "aci" +page_title: "ACI: aci_associated_site" +sidebar_current: "docs-aci-data-source-aci_associated_site" +description: |- + Data source for ACI Associated Site +--- + +# aci_associated_site # + +Data source for ACI Associated Site + +## API Information ## + +* Class: [fvSiteAssociated](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvSiteAssociated/overview) + +* Supported in ACI versions: 3.0(1k) and later. + +* Distinguished Name Formats: + - `uni/tn-{name}/BD-{name}/stAsc` + - `uni/tn-{name}/ap-{name}/epg-{name}/stAsc` + - `uni/tn-{name}/ctx-{name}/stAsc` + - `uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc` + - `uni/tn-{name}/out-{name}/instP-{name}/stAsc` + +## GUI Information ## + +* Location: `Not shown in UI` + +## Example Usage ## + +```hcl + +data "aci_associated_site" "example_application_epg" { + parent_dn = aci_application_epg.example.id +} + +data "aci_associated_site" "example_bridge_domain" { + parent_dn = aci_bridge_domain.example.id +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) ([fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) + - [aci_bridge_domain](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/bridge_domain) ([fvBD](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvBD/overview)) + - [aci_vrf](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf) ([fvCtx](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvCtx/overview)) + - [aci_external_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_network_instance_profile) ([l3extInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extInstP/overview)) + - The distinguished name (DN) of classes below can be used but currently there is no available resource for it: + - [vnsEpgDefXlate](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vnsEpgDefXlate/overview) + + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Associated Site object. +* `annotation` (annotation) - (string) The annotation of the Associated Site object. +* `description` (descr) - (string) The description of the Associated Site object. +* `name` (name) - (string) The name of the Associated Site object. +* `name_alias` (nameAlias) - (string) The name alias of the Associated Site 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. +* `site_id` (siteId) - (string) A number between 0 and 1000 to identify the primary site being associated. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/remote_site_id_mappings.md b/docs/data-sources/remote_site_id_mappings.md new file mode 100644 index 000000000..25f935ae0 --- /dev/null +++ b/docs/data-sources/remote_site_id_mappings.md @@ -0,0 +1,72 @@ +--- +# 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: "Multi-Site" +layout: "aci" +page_title: "ACI: aci_remote_site_id_mappings" +sidebar_current: "docs-aci-data-source-aci_remote_site_id_mappings" +description: |- + Data source for ACI Remote Site Id Mappings +--- + +# aci_remote_site_id_mappings # + +Data source for ACI Remote Site Id Mappings + +## API Information ## + +* Class: [fvRemoteId](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRemoteId/overview) + +* Supported in ACI versions: 3.0(1k) and later. + +* Distinguished Name Formats: + - `uni/tn-{name}/BD-{name}/stAsc/site-{siteId}` + - `uni/tn-{name}/ap-{name}/epg-{name}/stAsc/site-{siteId}` + - `uni/tn-{name}/ap-{name}/esg-{name}/stAsc/site-{siteId}` + - `uni/tn-{name}/ctx-{name}/stAsc/site-{siteId}` + - `uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc/site-{siteId}` + - `uni/tn-{name}/out-{name}/instP-{name}/stAsc/site-{siteId}` + +## GUI Information ## + +* Location: `Not shown in UI` + +## Example Usage ## + +```hcl + +data "aci_remote_site_id_mappings" "example_associated_site" { + parent_dn = aci_associated_site.example.id + site_id = "100" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_associated_site](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/associated_site) ([fvSiteAssociated](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvSiteAssociated/overview)) +* `site_id` (siteId) - (string) A number between 0 and 1000 to identify the remote site being associated with the primary site. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Remote Site Id Mappings object. +* `annotation` (annotation) - (string) The annotation of the Remote Site Id Mappings object. +* `description` (descr) - (string) The description of the Remote Site Id Mappings object. +* `name` (name) - (string) The name of the Remote Site Id Mappings object. +* `name_alias` (nameAlias) - (string) The name alias of the Remote Site Id Mappings 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. +* `remote_vrf_pc_tag` (remoteCtxPcTag) - (string) Remote context's *pcTag*, mapping required for default route case. +* `remote_pc_tag` (remotePcTag) - (string) Remote Class ID. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/tag.md b/docs/data-sources/tag.md index 270bbed8a..dffacbe32 100644 --- a/docs/data-sources/tag.md +++ b/docs/data-sources/tag.md @@ -73,7 +73,7 @@ data "aci_tag" "example_application_epg" { - [aci_epg_useg_ad_group_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_ad_group_attribute) ([fvIdGroupAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvIdGroupAttr/overview)) - [aci_epg_useg_ip_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_ip_attribute) ([fvIpAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvIpAttr/overview)) - [aci_epg_useg_mac_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_mac_attribute) ([fvMacAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvMacAttr/overview)) - - [aci_relation_to_consumed_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_contract) ([fvRsCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRsCons/overview)) + - [aci_remote_site_id_mappings](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/remote_site_id_mappings) ([fvRemoteId](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRemoteId/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/resources/annotation.md b/docs/resources/annotation.md index f4d7cd03f..2f4f18d22 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -82,7 +82,7 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_epg_useg_ad_group_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_ad_group_attribute) ([fvIdGroupAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvIdGroupAttr/overview)) - [aci_epg_useg_ip_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_ip_attribute) ([fvIpAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvIpAttr/overview)) - [aci_epg_useg_mac_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_mac_attribute) ([fvMacAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvMacAttr/overview)) - - [aci_relation_to_consumed_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_contract) ([fvRsCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRsCons/overview)) + - [aci_remote_site_id_mappings](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/remote_site_id_mappings) ([fvRemoteId](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRemoteId/overview)) * `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/application_epg.md b/docs/resources/application_epg.md index 9ff877767..544f397ad 100644 --- a/docs/resources/application_epg.md +++ b/docs/resources/application_epg.md @@ -205,6 +205,17 @@ resource "aci_application_epg" "full_example_application_profile" { trust_control_policy_name = aci_trust_control_policy.example.name } ] + associated_site = [ + { + annotation = "annotation_1" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" + } + ] annotations = [ { key = "key_0" @@ -544,6 +555,23 @@ All examples for the Application EPG resource can be found in the [examples](htt - Default: `orchestrator:terraform` * `trust_control_policy_name` (tnFhsTrustCtrlPolName) - (string) Name. +* `associated_site` - (list) A list of Associated Site (ACI object [fvSiteAssociated](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvSiteAssociated/overview)). Associated Site can also be configured using a separate [aci_](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/) resource. This attribute is supported in ACI versions: 3.0(1k) and later. + - Max Items: 1 + + #### Required #### + + * `site_id` (siteId) - (string) A number between 0 and 1000 to identify the primary site being associated. + + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Associated Site object. + - Default: `orchestrator:terraform` + * `description` (descr) - (string) The description of the Associated Site object. + * `name` (name) - (string) The name of the Associated Site object. + * `name_alias` (nameAlias) - (string) The name alias of the Associated Site object. + * `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. + * `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. #### Required #### diff --git a/docs/resources/associated_site.md b/docs/resources/associated_site.md new file mode 100644 index 000000000..5a0d809d3 --- /dev/null +++ b/docs/resources/associated_site.md @@ -0,0 +1,172 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "Multi-Site" +layout: "aci" +page_title: "ACI: aci_associated_site" +sidebar_current: "docs-aci-resource-aci_associated_site" +description: |- + Manages ACI Associated Site +--- + +# aci_associated_site # + +Manages ACI Associated Site + + -> This resource should only be used to accomplish multi-site orchestration. Manually assigning a value to attribute `site_id` may lead to unexpected behaviour. + + +## API Information ## + +* Class: [fvSiteAssociated](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvSiteAssociated/overview) + +* Supported in ACI versions: 3.0(1k) and later. + +* Distinguished Name Formats: + - `uni/tn-{name}/BD-{name}/stAsc` + - `uni/tn-{name}/ap-{name}/epg-{name}/stAsc` + - `uni/tn-{name}/ctx-{name}/stAsc` + - `uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc` + - `uni/tn-{name}/out-{name}/instP-{name}/stAsc` + +## GUI Information ## + +* Location: `Not shown in UI` + +## Example Usage ## + +The configuration snippet below creates a Associated Site with only required attributes. + +```hcl + +resource "aci_associated_site" "example_application_epg" { + parent_dn = aci_application_epg.example.id + site_id = "0" +} + +resource "aci_associated_site" "example_bridge_domain" { + parent_dn = aci_bridge_domain.example.id + site_id = "0" +} + +``` +The configuration snippet below shows all possible attributes of the Associated Site. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_associated_site" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +resource "aci_associated_site" "full_example_bridge_domain" { + parent_dn = aci_bridge_domain.example.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Associated Site resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_associated_site) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) ([fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) + - [aci_bridge_domain](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/bridge_domain) ([fvBD](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvBD/overview)) + - [aci_vrf](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf) ([fvCtx](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvCtx/overview)) + - [aci_external_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_network_instance_profile) ([l3extInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extInstP/overview)) + - The distinguished name (DN) of classes below can be used but currently there is no available resource for it: + - [vnsEpgDefXlate](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vnsEpgDefXlate/overview) + +* `site_id` (siteId) - (string) A number between 0 and 1000 to identify the primary site being associated. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Associated Site object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Associated Site object. + - Default: `orchestrator:terraform` +* `description` (descr) - (string) The description of the Associated Site object. +* `name` (name) - (string) The name of the Associated Site object. +* `name_alias` (nameAlias) - (string) The name alias of the Associated Site object. +* `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. +* `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +## Importing + +An existing Associated Site can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: + +``` +terraform import aci_associated_site.example_application_epg uni/tn-{name}/ap-{name}/epg-{name}/stAsc +``` + +Starting in Terraform version 1.5, an existing Associated Site can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/tn-{name}/ap-{name}/epg-{name}/stAsc" + to = aci_associated_site.example_application_epg +} +``` + +## Child Resources + + - [aci_remote_site_id_mappings](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/remote_site_id_mappings) \ No newline at end of file diff --git a/docs/resources/remote_site_id_mappings.md b/docs/resources/remote_site_id_mappings.md new file mode 100644 index 000000000..14c699f57 --- /dev/null +++ b/docs/resources/remote_site_id_mappings.md @@ -0,0 +1,140 @@ +--- +# 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: "Multi-Site" +layout: "aci" +page_title: "ACI: aci_remote_site_id_mappings" +sidebar_current: "docs-aci-resource-aci_remote_site_id_mappings" +description: |- + Manages ACI Remote Site Id Mappings +--- + +# aci_remote_site_id_mappings # + +Manages ACI Remote Site Id Mappings + + -> This resource should only be used to accomplish multi-site orchestration. Assigning values to attribute `remote_vrf_pc_tag` should only be done for object under VRF. + + +## API Information ## + +* Class: [fvRemoteId](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRemoteId/overview) + +* Supported in ACI versions: 3.0(1k) and later. + +* Distinguished Name Formats: + - `uni/tn-{name}/BD-{name}/stAsc/site-{siteId}` + - `uni/tn-{name}/ap-{name}/epg-{name}/stAsc/site-{siteId}` + - `uni/tn-{name}/ap-{name}/esg-{name}/stAsc/site-{siteId}` + - `uni/tn-{name}/ctx-{name}/stAsc/site-{siteId}` + - `uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc/site-{siteId}` + - `uni/tn-{name}/out-{name}/instP-{name}/stAsc/site-{siteId}` + +## GUI Information ## + +* Location: `Not shown in UI` + +## Example Usage ## + +The configuration snippet below creates a Remote Site Id Mappings with only required attributes. + +```hcl + +resource "aci_remote_site_id_mappings" "example_associated_site" { + parent_dn = aci_associated_site.example.id + remote_pc_tag = "16386" + site_id = "100" +} + +``` +The configuration snippet below shows all possible attributes of the Remote Site Id Mappings. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_remote_site_id_mappings" "full_example_associated_site" { + parent_dn = aci_associated_site.example.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + remote_vrf_pc_tag = "any" + remote_pc_tag = "16386" + site_id = "100" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Remote Site Id Mappings resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_remote_site_id_mappings) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_associated_site](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/associated_site) ([fvSiteAssociated](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvSiteAssociated/overview)) +* `remote_pc_tag` (remotePcTag) - (string) Remote Class ID. +* `site_id` (siteId) - (string) A number between 0 and 1000 to identify the remote site being associated with the primary site. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Remote Site Id Mappings object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Remote Site Id Mappings object. + - Default: `orchestrator:terraform` +* `description` (descr) - (string) The description of the Remote Site Id Mappings object. +* `name` (name) - (string) The name of the Remote Site Id Mappings object. +* `name_alias` (nameAlias) - (string) The name alias of the Remote Site Id Mappings 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. +* `remote_vrf_pc_tag` (remoteCtxPcTag) - (string) Remote context's *pcTag*, mapping required for default route case. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +## Importing + +An existing Remote Site Id Mappings can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: + +``` +terraform import aci_remote_site_id_mappings.example_associated_site uni/tn-{name}/ctx-{name}/stAsc/site-{siteId} +``` + +Starting in Terraform version 1.5, an existing Remote Site Id Mappings can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/tn-{name}/ctx-{name}/stAsc/site-{siteId}" + to = aci_remote_site_id_mappings.example_associated_site +} +``` diff --git a/docs/resources/tag.md b/docs/resources/tag.md index b441f4d80..8469492b8 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -82,7 +82,7 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_epg_useg_ad_group_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_ad_group_attribute) ([fvIdGroupAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvIdGroupAttr/overview)) - [aci_epg_useg_ip_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_ip_attribute) ([fvIpAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvIpAttr/overview)) - [aci_epg_useg_mac_attribute](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/epg_useg_mac_attribute) ([fvMacAttr](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvMacAttr/overview)) - - [aci_relation_to_consumed_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_contract) ([fvRsCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRsCons/overview)) + - [aci_remote_site_id_mappings](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/remote_site_id_mappings) ([fvRemoteId](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvRemoteId/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/examples/data-sources/aci_associated_site/data-source.tf b/examples/data-sources/aci_associated_site/data-source.tf new file mode 100644 index 000000000..617b496ee --- /dev/null +++ b/examples/data-sources/aci_associated_site/data-source.tf @@ -0,0 +1,8 @@ + +data "aci_associated_site" "example_application_epg" { + parent_dn = aci_application_epg.example.id +} + +data "aci_associated_site" "example_bridge_domain" { + parent_dn = aci_bridge_domain.example.id +} diff --git a/examples/data-sources/aci_associated_site/provider.tf b/examples/data-sources/aci_associated_site/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_associated_site/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/data-sources/aci_remote_site_id_mappings/data-source.tf b/examples/data-sources/aci_remote_site_id_mappings/data-source.tf new file mode 100644 index 000000000..82cb8b869 --- /dev/null +++ b/examples/data-sources/aci_remote_site_id_mappings/data-source.tf @@ -0,0 +1,5 @@ + +data "aci_remote_site_id_mappings" "example_associated_site" { + parent_dn = aci_associated_site.example.id + site_id = "100" +} diff --git a/examples/data-sources/aci_remote_site_id_mappings/provider.tf b/examples/data-sources/aci_remote_site_id_mappings/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_remote_site_id_mappings/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_application_epg/resource-all-attributes.tf b/examples/resources/aci_application_epg/resource-all-attributes.tf index d160106e0..3c8646ead 100644 --- a/examples/resources/aci_application_epg/resource-all-attributes.tf +++ b/examples/resources/aci_application_epg/resource-all-attributes.tf @@ -158,6 +158,17 @@ resource "aci_application_epg" "full_example_application_profile" { trust_control_policy_name = aci_trust_control_policy.example.name } ] + associated_site = [ + { + annotation = "annotation_1" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" + } + ] annotations = [ { key = "key_0" diff --git a/examples/resources/aci_associated_site/provider.tf b/examples/resources/aci_associated_site/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_associated_site/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_associated_site/resource-all-attributes.tf b/examples/resources/aci_associated_site/resource-all-attributes.tf new file mode 100644 index 000000000..809318652 --- /dev/null +++ b/examples/resources/aci_associated_site/resource-all-attributes.tf @@ -0,0 +1,46 @@ + +resource "aci_associated_site" "full_example_application_epg" { + parent_dn = aci_application_epg.example.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +resource "aci_associated_site" "full_example_bridge_domain" { + parent_dn = aci_bridge_domain.example.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_associated_site/resource.tf b/examples/resources/aci_associated_site/resource.tf new file mode 100644 index 000000000..0324cf41a --- /dev/null +++ b/examples/resources/aci_associated_site/resource.tf @@ -0,0 +1,10 @@ + +resource "aci_associated_site" "example_application_epg" { + parent_dn = aci_application_epg.example.id + site_id = "0" +} + +resource "aci_associated_site" "example_bridge_domain" { + parent_dn = aci_bridge_domain.example.id + site_id = "0" +} diff --git a/examples/resources/aci_remote_site_id_mappings/provider.tf b/examples/resources/aci_remote_site_id_mappings/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_remote_site_id_mappings/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_remote_site_id_mappings/resource-all-attributes.tf b/examples/resources/aci_remote_site_id_mappings/resource-all-attributes.tf new file mode 100644 index 000000000..fa2cfe280 --- /dev/null +++ b/examples/resources/aci_remote_site_id_mappings/resource-all-attributes.tf @@ -0,0 +1,25 @@ + +resource "aci_remote_site_id_mappings" "full_example_associated_site" { + parent_dn = aci_associated_site.example.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + remote_vrf_pc_tag = "any" + remote_pc_tag = "16386" + site_id = "100" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_remote_site_id_mappings/resource.tf b/examples/resources/aci_remote_site_id_mappings/resource.tf new file mode 100644 index 000000000..2be49fb03 --- /dev/null +++ b/examples/resources/aci_remote_site_id_mappings/resource.tf @@ -0,0 +1,6 @@ + +resource "aci_remote_site_id_mappings" "example_associated_site" { + parent_dn = aci_associated_site.example.id + remote_pc_tag = "16386" + site_id = "100" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index 80dd6204b..c323e052d 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -311,6 +311,44 @@ fvFBRoute: resource_notes: - "This resource should not be used in combination with the `vrf_fallback_routes` nested attribute of the `aci_vrf_fallback_route_group` resource. Doing so will result in unexpected behaviour." +fvBD: + resource_name: "bridge_domain" + +l3extInstP: + resource_name: "external_network_instance_profile" + +fvSiteAssociated: + include: true + resource_name: "associated_site" + ui_locations: + - "Not shown in UI" + sub_category: "Multi-Site" + resource_notes: + - "This resource should only be used to accomplish multi-site orchestration. Manually assigning a value to attribute `site_id` may lead to unexpected behaviour." + dn_formats: + - "uni/tn-{name}/ap-{name}/epg-{name}/stAsc" + - "uni/tn-{name}/ctx-{name}/stAsc" + - "uni/tn-{name}/BD-{name}/stAsc" + - "uni/tn-{name}/out-{name}/instP-{name}/stAsc" + - "uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc" + example_classes: + - "fvAEPg" + - "fvBD" + +fvRemoteId: + ui_locations: + - "Not shown in UI" + sub_category: "Multi-Site" + resource_notes: + - "This resource should only be used to accomplish multi-site orchestration. Assigning values to attribute `remote_vrf_pc_tag` should only be done for object under VRF." + dn_formats: + - "uni/tn-{name}/ctx-{name}/stAsc/site-{siteId}" + - "uni/tn-{name}/ap-{name}/epg-{name}/stAsc/site-{siteId}" + - "uni/tn-{name}/BD-{name}/stAsc/site-{siteId}" + - "uni/tn-{name}/out-{name}/instP-{name}/stAsc/site-{siteId}" + - "uni/tn-{name}/ap-{name}/esg-{name}/stAsc/site-{siteId}" + - "uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc/site-{siteId}" + l3extRsOutToFBRGroup: resource_name: "relation_to_vrf_fallback_route_group" ui_locations: diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 96adaf24e..cdad93a78 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -235,6 +235,66 @@ fvFBRoute: parent_dependency: "fvCtx" parent_dn: "aci_vrf_fallback_route_group.test.id" +fvSiteAssociated: + overwrites: + siteId: "site_id" + documentation: + siteId: "A number between 0 and 1000 to identify the primary site being associated" + default_values: + site_id: "100" + resource_required: + - "site_id" + test_values: + all: + site_id: "0" + default: + site_id: "0" + resource_required: + site_id: "0" + datasource_required: + - "site_id" + parents: + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dn: "aci_application_epg.test.id" + - class_name: "fvBD" + parent_dependency: "fvTenant" + parent_dn: "aci_bridge_domain.test.id" + +fvRemoteId: + overwrites: + siteId: "site_id" + remote_ctx_pc_tag: "remote_vrf_pc_tag" + documentation: + siteId: "A number between 0 and 1000 to identify the remote site being associated with the primary site" + default_values: + siteId: "100" + remote_ctx_pc_tag: "any" + remote_pc_tag: "16386" + resource_required: + - "remotePcTag" + test_values: + all: + site_id: "100" + remote_vrf_pc_tag: "any" + remote_pc_tag: "16386" + default: + site_id: "100" + remote_vrf_pc_tag: "any" + remote_pc_tag: "16386" + resource_required: + site_id: "100" + remote_vrf_pc_tag: "any" + remote_pc_tag: "16386" + datasource_non_existing: + site_id: "102" + datasource_required: + site_id: "100" + parents: + - class_name: "fvSiteAssociated" + parent_dependency: "fvBD" + parent_dn: "aci_associated_site.test.id" + l3extRsOutToFBRGroup: documentation: tDn: "The distinguished name of the VRF Fallback Route Group object." diff --git a/gen/generator.go b/gen/generator.go index 453b7393e..d40f54696 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -1381,6 +1381,9 @@ func (m *Model) SetClassProperties(classDetails interface{}) { for _, details := range propertyValue.(map[string]interface{})["validValues"].([]interface{}) { validValue := details.(map[string]interface{})["localName"].(string) + if propertyName == "remoteCtxPcTag" || propertyName == "remotePcTag" { + validValue = "defaultValue" + } if validValue != "defaultValue" && !isInSlice(removedValidValuesList, validValue) { property.ValidValues = append(property.ValidValues, validValue) } @@ -1744,9 +1747,18 @@ func requiredProperty(propertyName, classPkgName string, definitions Definitions if classDetails, ok := definitions.Properties[precedence]; ok { for key, value := range classDetails.(map[interface{}]interface{}) { if key.(string) == "resource_required" { - for _, v := range value.([]interface{}) { - if v.(string) == propertyName { - return true + v1, ok1 := value.([]interface{}) + if !ok1 { + for k1, _ := range value.(map[interface{}]interface{}) { + if k1.(string) == propertyName { + return true + } + } + } else { + for _, v := range v1 { + if v.(string) == propertyName { + return true + } } } } diff --git a/gen/meta/fvRemoteId.json b/gen/meta/fvRemoteId.json new file mode 100644 index 000000000..55a86aacf --- /dev/null +++ b/gen/meta/fvRemoteId.json @@ -0,0 +1,841 @@ +{ + "fv:RemoteId": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "fault:Inst": "", + "fv:ImportExtRoutes": "", + "health:Inst": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fault-": "fault:Inst", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "importextroutes": "fv:ImportExtRoutes", + "rbacDom-": "aaa:RbacAnnotation", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "siteId" + ], + "rnFormat": "site-{siteId}", + "containedBy": { + "fv:SiteAssociated": "" + }, + "superClasses": [ + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc/site-{siteId}", + "uni/tn-{name}/ctx-{name}/stAsc/site-{siteId}", + "uni/tn-{name}/ap-{name}/epg-{name}/stAsc/site-{siteId}", + "uni/tn-{name}/BD-{name}/stAsc/site-{siteId}", + "uni/tn-{name}/out-{name}/instP-{name}/stAsc/site-{siteId}" + ], + "writeAccess": [ + "admin", + "tenant-security" + ], + "readAccess": [ + "admin", + "tenant-security" + ], + "faults": { + + }, + "events": { + "E4214949": "creation||fv:RemoteId", + "E4214950": "modification||fv:RemoteId", + "E4214951": "deletion||fv:RemoteId" + }, + "stats": { + + }, + "versions": "3.0(1k)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": true, + "hasStats": false, + "isStat": false, + "isFaultable": true, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + + ], + "classId": "9506", + "className": "RemoteId", + "classPkg": "fv", + "featureTag": "", + "moCategory": "Regular", + "label": "Remote Site ID Mappings", + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38587", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(1e)-", + "comment": [ + "Specifies a description of the policy definition." + ], + "isConfigurable": true, + "propGlobalId": "5579", + "propLocalId": "28", + "label": "Description", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Described:descr", + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40726", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "versions": "3.0(1k)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "28416", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "4991", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "ownerKey": { + "versions": "1.0(1e)-", + "comment": [ + "The key for enabling clients to own their data for entity correlation." + ], + "isConfigurable": true, + "propGlobalId": "15230", + "propLocalId": "4100", + "label": "ownerKey", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "ownerTag": { + "versions": "1.0(1e)-", + "comment": [ + "A tag for enabling clients to add their own data. For example, to indicate who created this object." + ], + "isConfigurable": true, + "propGlobalId": "15231", + "propLocalId": "4101", + "label": "ownerTag", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "remoteCtxPcTag": { + "versions": "3.0(1k)-", + "comment": [ + "Remote context's *pcTag*, mapping required for default route case" + ], + "isConfigurable": true, + "propGlobalId": "34444", + "propLocalId": "8155", + "label": "remoteCtxPcTag", + "baseType": "scalar:Uint32", + "modelType": "vz:GPCTag", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "0", "localName": "any", + "platformFlavors": [ + + ], + "label": "any "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "remotePcTag": { + "versions": "3.0(1k)-", + "comment": [ + "Remote Class ID" + ], + "isConfigurable": true, + "propGlobalId": "28392", + "propLocalId": "6713", + "label": "remotePcTag", + "baseType": "scalar:Uint32", + "modelType": "vz:GPCTag", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "0", "localName": "any", + "platformFlavors": [ + + ], + "label": "any "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "siteId": { + "versions": "3.0(1k)-", + "comment": [ + "Remote Site ID" + ], + "isConfigurable": true, + "propGlobalId": "28391", + "propLocalId": "6712", + "label": "siteId", + "baseType": "scalar:Uint16", + "modelType": "fabric:SiteId", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1000 } + ], + "validValues": [ + { "value": "0", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 0, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} \ No newline at end of file diff --git a/gen/meta/fvSiteAssociated.json b/gen/meta/fvSiteAssociated.json new file mode 100644 index 000000000..96e5b1199 --- /dev/null +++ b/gen/meta/fvSiteAssociated.json @@ -0,0 +1,778 @@ +{ + "fv:SiteAssociated": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "fv:ExportExtRoutes": "", + "fv:PeerContextDn": "", + "fv:RemoteId": "", + "health:Inst": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "exportextroutes": "fv:ExportExtRoutes", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "peerctx-": "fv:PeerContextDn", + "rbacDom-": "aaa:RbacAnnotation", + "site-": "fv:RemoteId", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + + ], + "rnFormat": "stAsc", + "containedBy": { + "fv:AEPg": "", + "fv:BD": "", + "fv:Ctx": "", + "l3ext:InstP": "", + "vns:EpgDefXlate": "" + }, + "superClasses": [ + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc", + "uni/tn-{name}/ctx-{name}/stAsc", + "uni/tn-{name}/ap-{name}/epg-{name}/stAsc", + "uni/tn-{name}/BD-{name}/stAsc", + "uni/tn-{name}/out-{name}/instP-{name}/stAsc" + ], + "writeAccess": [ + "admin", + "tenant-security" + ], + "readAccess": [ + "admin", + "tenant-security" + ], + "faults": { + + }, + "events": { + "E4214958": "creation||fv:SiteAssociated", + "E4214959": "modification||fv:SiteAssociated", + "E4214960": "deletion||fv:SiteAssociated" + }, + "stats": { + + }, + "versions": "3.0(1k)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": true, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + + ], + "classId": "9505", + "className": "SiteAssociated", + "classPkg": "fv", + "featureTag": "", + "moCategory": "Regular", + "label": "Remote Site ID Container", + "comment": [ + "Used to store ID mappings" + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38586", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(1e)-", + "comment": [ + "Specifies a description of the policy definition." + ], + "isConfigurable": true, + "propGlobalId": "5579", + "propLocalId": "28", + "label": "Description", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Described:descr", + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40725", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "versions": "3.0(1k)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "28415", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "4991", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "ownerKey": { + "versions": "1.0(1e)-", + "comment": [ + "The key for enabling clients to own their data for entity correlation." + ], + "isConfigurable": true, + "propGlobalId": "15230", + "propLocalId": "4100", + "label": "ownerKey", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "ownerTag": { + "versions": "1.0(1e)-", + "comment": [ + "A tag for enabling clients to add their own data. For example, to indicate who created this object." + ], + "isConfigurable": true, + "propGlobalId": "15231", + "propLocalId": "4101", + "label": "ownerTag", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "siteId": { + "versions": "3.0(1k)-", + "comment": [ + "Local Site ID" + ], + "isConfigurable": true, + "propGlobalId": "28390", + "propLocalId": "6712", + "label": "siteId", + "baseType": "scalar:Uint16", + "modelType": "fabric:SiteId", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1000 } + ], + "validValues": [ + { "value": "0", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 0, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} \ No newline at end of file diff --git a/gen/templates/datasource_test.go.tmpl b/gen/templates/datasource_test.go.tmpl index 4aed774d4..a1583662b 100644 --- a/gen/templates/datasource_test.go.tmpl +++ b/gen/templates/datasource_test.go.tmpl @@ -104,8 +104,13 @@ data "aci_{{$.resourceName}}" "test{{- if eq $.resourceClassName $parentClassNam depends_on = [aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}] } ` +{{- if not $.datasource_required }} -const testConfig{{$.resourceClassName}}NotExisting{{capitalize .class_name}} = testConfig{{capitalize .class_name}}Min{{- if ne .parent_dependency ""}}DependencyWith{{capitalize .parent_dependency}}{{if and (ne .parent_dependency_name nil) (ne .parent_dependency_name "")}}{{capitalize .parent_dependency_name }}{{- end }}{{- end}} + ` +const testConfig{{$.resourceClassName}}NotExisting{{capitalize .class_name}} = testConfig{{capitalize .class_name}}Min + ` +{{- else}} + +const testConfig{{$.resourceClassName}}NotExisting{{capitalize .class_name}} = testConfig{{$.resourceClassName}}MinDependencyWith{{capitalize .class_name}} + ` +{{- end }} data "aci_{{$.resourceName}}" "test_non_existing" { parent_dn = {{.parent_dn}} {{- range $key, $value := $.datasource_non_existing}} @@ -115,6 +120,9 @@ data "aci_{{$.resourceName}}" "test_non_existing" { {{$key}} = "{{$value}}" {{- end }} {{- end}} + {{- if $.datasource_required }} + depends_on = [aci_{{$.resourceName}}.test] + {{- end }} } ` {{- end}} diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index de0bf34e1..ddf81e5fd 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -10,8 +10,8 @@ import ( "encoding/json" {{- if .IdentifiedBy}} "reflect" - {{- end}} "strings" + {{- end}} "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" diff --git a/gen/templates/testvars.yaml.tmpl b/gen/templates/testvars.yaml.tmpl index 998b7726b..de065e192 100644 --- a/gen/templates/testvars.yaml.tmpl +++ b/gen/templates/testvars.yaml.tmpl @@ -51,13 +51,6 @@ resource_required: {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: "{{overwritePropertyValue .PkgName $overwritePropertyName $testValue "resource_required" 0 $.Definitions}}" {{- end}} {{- end}} -{{- end }} -{{- if .HasReadOnlyProperties}} - -read_only: - {{- range .Properties}}{{- if .ReadOnly}} - - "{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}" - {{- end}}{{- end}} {{- end}} all: diff --git a/gen/testvars/fvAEPg.yaml b/gen/testvars/fvAEPg.yaml index 171936156..dac606ae7 100644 --- a/gen/testvars/fvAEPg.yaml +++ b/gen/testvars/fvAEPg.yaml @@ -26,9 +26,6 @@ datasource_required: resource_required: name: "test_name" -read_only: - - "pc_tag" - all: annotation: "annotation" description: "description_1" @@ -222,6 +219,15 @@ children: - annotation: "annotation_1" trust_control_policy_name: "trust_control_policy_name_1" deletable_child: true + associated_site: + - annotation: "annotation_1" + description: "description_1" + name: "name_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + site_id: "0" + deletable_child: true annotations: - key: "key_0" value: "value_1" diff --git a/gen/testvars/fvESg.yaml b/gen/testvars/fvESg.yaml index b810f0f49..ef0b59be1 100644 --- a/gen/testvars/fvESg.yaml +++ b/gen/testvars/fvESg.yaml @@ -21,9 +21,6 @@ datasource_required: resource_required: name: "test_name" -read_only: - - "pc_tag" - all: annotation: "annotation" description: "description_1" diff --git a/gen/testvars/fvRemoteId.yaml b/gen/testvars/fvRemoteId.yaml new file mode 100644 index 000000000..0295fa2be --- /dev/null +++ b/gen/testvars/fvRemoteId.yaml @@ -0,0 +1,56 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + description: "" + name: "" + name_alias: "" + owner_key: "" + owner_tag: "" + remote_vrf_pc_tag: "any" + remote_pc_tag: "16386" + site_id: "100" + +datasource_non_existing: + site_id: "102" + +datasource_required: + site_id: "100" + +resource_required: + remote_pc_tag: "16386" + site_id: "100" + +all: + annotation: "annotation" + description: "description_1" + name: "name_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + remote_vrf_pc_tag: "any" + remote_pc_tag: "16386" + site_id: "100" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + +parents: + - class_name: "fvSiteAssociated" + parent_dependency: "fvBD" + parent_dn: "aci_associated_site.test.id" + class_in_parent: false diff --git a/gen/testvars/fvSiteAssociated.yaml b/gen/testvars/fvSiteAssociated.yaml new file mode 100644 index 000000000..893823b1e --- /dev/null +++ b/gen/testvars/fvSiteAssociated.yaml @@ -0,0 +1,47 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + description: "" + name: "" + name_alias: "" + owner_key: "" + owner_tag: "" + site_id: "0" + + +all: + annotation: "annotation" + description: "description_1" + name: "name_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + site_id: "0" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + +parents: + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dn: "aci_application_epg.test.id" + class_in_parent: false + - class_name: "fvBD" + parent_dependency: "fvTenant" + parent_dn: "aci_bridge_domain.test.id" + class_in_parent: false diff --git a/go.sum b/go.sum index 75ef66717..8d076cba0 100644 --- a/go.sum +++ b/go.sum @@ -232,4 +232,4 @@ gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= \ No newline at end of file diff --git a/internal/provider/data_source_aci_annotation_test.go b/internal/provider/data_source_aci_annotation_test.go index 77efa0a62..a7c9df9d7 100644 --- a/internal/provider/data_source_aci_annotation_test.go +++ b/internal/provider/data_source_aci_annotation_test.go @@ -62,10 +62,11 @@ data "aci_annotation" "test" { } ` -const testConfigTagAnnotationNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigTagAnnotationNotExistingFvTenant = testConfigTagAnnotationMinDependencyWithFvTenant + ` data "aci_annotation" "test_non_existing" { parent_dn = aci_tenant.test.id key = "non_existing_key" + depends_on = [aci_annotation.test] } ` const testConfigTagAnnotationDataSourceDependencyWithFvAEPg = testConfigTagAnnotationMinDependencyWithFvAEPg + ` @@ -76,9 +77,10 @@ data "aci_annotation" "test" { } ` -const testConfigTagAnnotationNotExistingFvAEPg = testConfigFvAEPgMin + ` +const testConfigTagAnnotationNotExistingFvAEPg = testConfigTagAnnotationMinDependencyWithFvAEPg + ` data "aci_annotation" "test_non_existing" { parent_dn = aci_application_epg.test.id key = "non_existing_key" + depends_on = [aci_annotation.test] } ` diff --git a/internal/provider/data_source_aci_application_epg.go b/internal/provider/data_source_aci_application_epg.go index de99aa916..d9d85c965 100644 --- a/internal/provider/data_source_aci_application_epg.go +++ b/internal/provider/data_source_aci_application_epg.go @@ -666,6 +666,42 @@ func (d *FvAEPgDataSource) Schema(ctx context.Context, req datasource.SchemaRequ }, }, }, + "associated_site": schema.SetNestedAttribute{ + MarkdownDescription: `Used to store ID mappings`, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Associated Site object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Associated Site object.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the Associated Site object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Associated Site 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.`, + }, + "site_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `A number between 0 and 1000 to identify the primary site being associated.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, diff --git a/internal/provider/data_source_aci_application_epg_test.go b/internal/provider/data_source_aci_application_epg_test.go index bfb52978f..439b16b9e 100644 --- a/internal/provider/data_source_aci_application_epg_test.go +++ b/internal/provider/data_source_aci_application_epg_test.go @@ -35,7 +35,6 @@ func TestAccDataSourceFvAEPgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("data.aci_application_epg.test", "preferred_group_member", "exclude"), resource.TestCheckResourceAttr("data.aci_application_epg.test", "priority", "unspecified"), resource.TestCheckResourceAttr("data.aci_application_epg.test", "useg_epg", "no"), - resource.TestCheckResourceAttrSet("data.aci_application_epg.test", "pc_tag"), ), }, { @@ -54,9 +53,10 @@ data "aci_application_epg" "test" { } ` -const testConfigFvAEPgNotExistingFvAp = testConfigFvApMinDependencyWithFvTenant + ` +const testConfigFvAEPgNotExistingFvAp = testConfigFvAEPgMinDependencyWithFvAp + ` data "aci_application_epg" "test_non_existing" { parent_dn = aci_application_profile.test.id name = "non_existing_name" + depends_on = [aci_application_epg.test] } ` diff --git a/internal/provider/data_source_aci_associated_site.go b/internal/provider/data_source_aci_associated_site.go new file mode 100644 index 000000000..dea9e08e0 --- /dev/null +++ b/internal/provider/data_source_aci_associated_site.go @@ -0,0 +1,169 @@ +// 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 = &FvSiteAssociatedDataSource{} + +func NewFvSiteAssociatedDataSource() datasource.DataSource { + return &FvSiteAssociatedDataSource{} +} + +// FvSiteAssociatedDataSource defines the data source implementation. +type FvSiteAssociatedDataSource struct { + client *client.Client +} + +func (d *FvSiteAssociatedDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_associated_site") + resp.TypeName = req.ProviderTypeName + "_associated_site" + tflog.Debug(ctx, "End metadata of datasource: aci_associated_site") +} + +func (d *FvSiteAssociatedDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_associated_site") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The associated_site datasource for the 'fvSiteAssociated' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Associated Site 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 Associated Site object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Associated Site object.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the Associated Site object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Associated Site 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.`, + }, + "site_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `A number between 0 and 1000 to identify the primary site being associated.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_associated_site") +} + +func (d *FvSiteAssociatedDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_associated_site") + // 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_associated_site") +} + +func (d *FvSiteAssociatedDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_associated_site") + var data *FvSiteAssociatedResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setFvSiteAssociatedId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetFvSiteAssociatedAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_associated_site with id '%s'", data.Id.ValueString())) + + getAndSetFvSiteAssociatedAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_associated_site data source", + fmt.Sprintf("The aci_associated_site 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_associated_site with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_associated_site_test.go b/internal/provider/data_source_aci_associated_site_test.go new file mode 100644 index 000000000..84db46c8d --- /dev/null +++ b/internal/provider/data_source_aci_associated_site_test.go @@ -0,0 +1,90 @@ +// 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 TestAccDataSourceFvSiteAssociatedWithFvAEPg(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvSiteAssociatedDataSourceDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_associated_site.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "name", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "owner_key", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "owner_tag", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "site_id", "0"), + ), + }, + { + Config: testConfigFvSiteAssociatedNotExistingFvAEPg, + ExpectError: regexp.MustCompile("Failed to read aci_associated_site data source"), + }, + }, + }) +} +func TestAccDataSourceFvSiteAssociatedWithFvBD(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvSiteAssociatedDataSourceDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_associated_site.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "name", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "owner_key", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "owner_tag", ""), + resource.TestCheckResourceAttr("data.aci_associated_site.test", "site_id", "0"), + ), + }, + { + Config: testConfigFvSiteAssociatedNotExistingFvBD, + ExpectError: regexp.MustCompile("Failed to read aci_associated_site data source"), + }, + }, + }) +} + +const testConfigFvSiteAssociatedDataSourceDependencyWithFvAEPg = testConfigFvSiteAssociatedMinDependencyWithFvAEPg + ` +data "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + depends_on = [aci_associated_site.test] +} +` + +const testConfigFvSiteAssociatedNotExistingFvAEPg = testConfigFvAEPgMin + ` +data "aci_associated_site" "test_non_existing" { + parent_dn = aci_application_epg.test.id +} +` +const testConfigFvSiteAssociatedDataSourceDependencyWithFvBD = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +data "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id + depends_on = [aci_associated_site.test] +} +` + +const testConfigFvSiteAssociatedNotExistingFvBD = testConfigFvBDMin + ` +data "aci_associated_site" "test_non_existing" { + parent_dn = aci_bridge_domain.test.id +} +` diff --git a/internal/provider/data_source_aci_custom_qos_policy_test.go b/internal/provider/data_source_aci_custom_qos_policy_test.go index 011d2ea7c..7ee2ce119 100644 --- a/internal/provider/data_source_aci_custom_qos_policy_test.go +++ b/internal/provider/data_source_aci_custom_qos_policy_test.go @@ -45,9 +45,10 @@ data "aci_custom_qos_policy" "test" { } ` -const testConfigQosCustomPolNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigQosCustomPolNotExistingFvTenant = testConfigQosCustomPolMinDependencyWithFvTenant + ` data "aci_custom_qos_policy" "test_non_existing" { parent_dn = aci_tenant.test.id name = "non_existing_name" + depends_on = [aci_custom_qos_policy.test] } ` diff --git a/internal/provider/data_source_aci_data_plane_policing_policy_test.go b/internal/provider/data_source_aci_data_plane_policing_policy_test.go index aa23d88f6..423a3d3d8 100644 --- a/internal/provider/data_source_aci_data_plane_policing_policy_test.go +++ b/internal/provider/data_source_aci_data_plane_policing_policy_test.go @@ -66,9 +66,10 @@ data "aci_data_plane_policing_policy" "test" { } ` -const testConfigQosDppPolNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigQosDppPolNotExistingFvTenant = testConfigQosDppPolMinDependencyWithFvTenant + ` data "aci_data_plane_policing_policy" "test_non_existing" { parent_dn = aci_tenant.test.id name = "non_existing_name" + depends_on = [aci_data_plane_policing_policy.test] } ` diff --git a/internal/provider/data_source_aci_endpoint_security_group_test.go b/internal/provider/data_source_aci_endpoint_security_group_test.go index 63d74de7a..34939f37d 100644 --- a/internal/provider/data_source_aci_endpoint_security_group_test.go +++ b/internal/provider/data_source_aci_endpoint_security_group_test.go @@ -30,7 +30,6 @@ func TestAccDataSourceFvESgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("data.aci_endpoint_security_group.test", "match_criteria", "AtleastOne"), resource.TestCheckResourceAttr("data.aci_endpoint_security_group.test", "name_alias", ""), resource.TestCheckResourceAttr("data.aci_endpoint_security_group.test", "preferred_group_member", "exclude"), - resource.TestCheckResourceAttrSet("data.aci_endpoint_security_group.test", "pc_tag"), ), }, { @@ -49,9 +48,10 @@ data "aci_endpoint_security_group" "test" { } ` -const testConfigFvESgNotExistingFvAp = testConfigFvApMinDependencyWithFvTenant + ` +const testConfigFvESgNotExistingFvAp = testConfigFvESgMinDependencyWithFvAp + ` data "aci_endpoint_security_group" "test_non_existing" { parent_dn = aci_application_profile.test.id name = "non_existing_name" + depends_on = [aci_endpoint_security_group.test] } ` diff --git a/internal/provider/data_source_aci_endpoint_tag_ip_test.go b/internal/provider/data_source_aci_endpoint_tag_ip_test.go index 66a4eff33..1e4c5ca23 100644 --- a/internal/provider/data_source_aci_endpoint_tag_ip_test.go +++ b/internal/provider/data_source_aci_endpoint_tag_ip_test.go @@ -46,10 +46,11 @@ data "aci_endpoint_tag_ip" "test" { } ` -const testConfigFvEpIpTagNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigFvEpIpTagNotExistingFvTenant = testConfigFvEpIpTagMinDependencyWithFvTenant + ` data "aci_endpoint_tag_ip" "test_non_existing" { parent_dn = aci_tenant.test.id ip = "10.0.1.2" vrf_name = "non_existing_ctx_name" + depends_on = [aci_endpoint_tag_ip.test] } ` diff --git a/internal/provider/data_source_aci_endpoint_tag_mac_test.go b/internal/provider/data_source_aci_endpoint_tag_mac_test.go index 9390118cd..34e6a3264 100644 --- a/internal/provider/data_source_aci_endpoint_tag_mac_test.go +++ b/internal/provider/data_source_aci_endpoint_tag_mac_test.go @@ -46,10 +46,11 @@ data "aci_endpoint_tag_mac" "test" { } ` -const testConfigFvEpMacTagNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigFvEpMacTagNotExistingFvTenant = testConfigFvEpMacTagMinDependencyWithFvTenant + ` data "aci_endpoint_tag_mac" "test_non_existing" { parent_dn = aci_tenant.test.id bd_name = "non_existing_bd_name" mac = "00:00:00:00:00:01" + depends_on = [aci_endpoint_tag_mac.test] } ` diff --git a/internal/provider/data_source_aci_epg_useg_ad_group_attribute_test.go b/internal/provider/data_source_aci_epg_useg_ad_group_attribute_test.go index 9684f1b32..f3c808fca 100644 --- a/internal/provider/data_source_aci_epg_useg_ad_group_attribute_test.go +++ b/internal/provider/data_source_aci_epg_useg_ad_group_attribute_test.go @@ -46,9 +46,10 @@ data "aci_epg_useg_ad_group_attribute" "test" { } ` -const testConfigFvIdGroupAttrNotExistingFvCrtrn = testConfigFvCrtrnMinDependencyWithFvAEPg + ` +const testConfigFvIdGroupAttrNotExistingFvCrtrn = testConfigFvIdGroupAttrMinDependencyWithFvCrtrn + ` data "aci_epg_useg_ad_group_attribute" "test_non_existing" { parent_dn = aci_epg_useg_block_statement.test.id selector = "adepg/authsvr-common-sg1-ISE_1/grpcont/dom-cisco.com/grp-Eng_non_existing" + depends_on = [aci_epg_useg_ad_group_attribute.test] } ` diff --git a/internal/provider/data_source_aci_epg_useg_dns_attribute_test.go b/internal/provider/data_source_aci_epg_useg_dns_attribute_test.go index 0e44bd12c..c4121eb20 100644 --- a/internal/provider/data_source_aci_epg_useg_dns_attribute_test.go +++ b/internal/provider/data_source_aci_epg_useg_dns_attribute_test.go @@ -46,9 +46,10 @@ data "aci_epg_useg_dns_attribute" "test" { } ` -const testConfigFvDnsAttrNotExistingFvCrtrn = testConfigFvCrtrnMinDependencyWithFvAEPg + ` +const testConfigFvDnsAttrNotExistingFvCrtrn = testConfigFvDnsAttrMinDependencyWithFvCrtrn + ` data "aci_epg_useg_dns_attribute" "test_non_existing" { parent_dn = aci_epg_useg_block_statement.test.id name = "dns_attribute_non_existing" + depends_on = [aci_epg_useg_dns_attribute.test] } ` diff --git a/internal/provider/data_source_aci_epg_useg_ip_attribute_test.go b/internal/provider/data_source_aci_epg_useg_ip_attribute_test.go index dbb43d0c8..457444cae 100644 --- a/internal/provider/data_source_aci_epg_useg_ip_attribute_test.go +++ b/internal/provider/data_source_aci_epg_useg_ip_attribute_test.go @@ -47,9 +47,10 @@ data "aci_epg_useg_ip_attribute" "test" { } ` -const testConfigFvIpAttrNotExistingFvCrtrn = testConfigFvCrtrnMinDependencyWithFvAEPg + ` +const testConfigFvIpAttrNotExistingFvCrtrn = testConfigFvIpAttrMinDependencyWithFvCrtrn + ` data "aci_epg_useg_ip_attribute" "test_non_existing" { parent_dn = aci_epg_useg_block_statement.test.id name = "131_non_existing" + depends_on = [aci_epg_useg_ip_attribute.test] } ` diff --git a/internal/provider/data_source_aci_epg_useg_mac_attribute_test.go b/internal/provider/data_source_aci_epg_useg_mac_attribute_test.go index a93801104..1c6453f7d 100644 --- a/internal/provider/data_source_aci_epg_useg_mac_attribute_test.go +++ b/internal/provider/data_source_aci_epg_useg_mac_attribute_test.go @@ -46,9 +46,10 @@ data "aci_epg_useg_mac_attribute" "test" { } ` -const testConfigFvMacAttrNotExistingFvCrtrn = testConfigFvCrtrnMinDependencyWithFvAEPg + ` +const testConfigFvMacAttrNotExistingFvCrtrn = testConfigFvMacAttrMinDependencyWithFvCrtrn + ` data "aci_epg_useg_mac_attribute" "test_non_existing" { parent_dn = aci_epg_useg_block_statement.test.id name = "mac_attr_non_existing" + depends_on = [aci_epg_useg_mac_attribute.test] } ` diff --git a/internal/provider/data_source_aci_epg_useg_sub_block_statement_test.go b/internal/provider/data_source_aci_epg_useg_sub_block_statement_test.go index dfb59e62f..b5a404350 100644 --- a/internal/provider/data_source_aci_epg_useg_sub_block_statement_test.go +++ b/internal/provider/data_source_aci_epg_useg_sub_block_statement_test.go @@ -72,10 +72,11 @@ data "aci_epg_useg_sub_block_statement" "test" { } ` -const testConfigFvSCrtrnNotExistingFvCrtrn = testConfigFvCrtrnMinDependencyWithFvAEPg + ` +const testConfigFvSCrtrnNotExistingFvCrtrn = testConfigFvSCrtrnMinDependencyWithFvCrtrn + ` data "aci_epg_useg_sub_block_statement" "test_non_existing" { parent_dn = aci_epg_useg_block_statement.test.id name = "sub_criterion_non_existing" + depends_on = [aci_epg_useg_sub_block_statement.test] } ` const testConfigFvSCrtrnDataSourceDependencyWithFvSCrtrn = testConfigFvSCrtrnMinDependencyWithFvSCrtrn + ` @@ -86,9 +87,10 @@ data "aci_epg_useg_sub_block_statement" "test_1" { } ` -const testConfigFvSCrtrnNotExistingFvSCrtrn = testConfigFvSCrtrnMinDependencyWithFvCrtrn + ` +const testConfigFvSCrtrnNotExistingFvSCrtrn = testConfigFvSCrtrnMinDependencyWithFvSCrtrn + ` data "aci_epg_useg_sub_block_statement" "test_non_existing" { parent_dn = aci_epg_useg_sub_block_statement.test.id name = "sub_criterion_non_existing" + depends_on = [aci_epg_useg_sub_block_statement.test] } ` diff --git a/internal/provider/data_source_aci_epg_useg_vm_attribute_test.go b/internal/provider/data_source_aci_epg_useg_vm_attribute_test.go index 5713d5023..9202cb9d1 100644 --- a/internal/provider/data_source_aci_epg_useg_vm_attribute_test.go +++ b/internal/provider/data_source_aci_epg_useg_vm_attribute_test.go @@ -80,10 +80,11 @@ data "aci_epg_useg_vm_attribute" "test" { } ` -const testConfigFvVmAttrNotExistingFvCrtrn = testConfigFvCrtrnMinDependencyWithFvAEPg + ` +const testConfigFvVmAttrNotExistingFvCrtrn = testConfigFvVmAttrMinDependencyWithFvCrtrn + ` data "aci_epg_useg_vm_attribute" "test_non_existing" { parent_dn = aci_epg_useg_block_statement.test.id name = "vm_attribute_non_existing" + depends_on = [aci_epg_useg_vm_attribute.test] } ` const testConfigFvVmAttrDataSourceDependencyWithFvSCrtrn = testConfigFvVmAttrMinDependencyWithFvSCrtrn + ` @@ -94,9 +95,10 @@ data "aci_epg_useg_vm_attribute" "test" { } ` -const testConfigFvVmAttrNotExistingFvSCrtrn = testConfigFvSCrtrnMinDependencyWithFvCrtrn + ` +const testConfigFvVmAttrNotExistingFvSCrtrn = testConfigFvVmAttrMinDependencyWithFvSCrtrn + ` data "aci_epg_useg_vm_attribute" "test_non_existing" { parent_dn = aci_epg_useg_sub_block_statement.test.id name = "vm_attribute_non_existing" + depends_on = [aci_epg_useg_vm_attribute.test] } ` diff --git a/internal/provider/data_source_aci_external_management_network_subnet_test.go b/internal/provider/data_source_aci_external_management_network_subnet_test.go index cdfbaf8ae..841afdc32 100644 --- a/internal/provider/data_source_aci_external_management_network_subnet_test.go +++ b/internal/provider/data_source_aci_external_management_network_subnet_test.go @@ -44,9 +44,10 @@ data "aci_external_management_network_subnet" "test" { } ` -const testConfigMgmtSubnetNotExistingMgmtInstP = testConfigMgmtInstPMin + ` +const testConfigMgmtSubnetNotExistingMgmtInstP = testConfigMgmtSubnetMinDependencyWithMgmtInstP + ` data "aci_external_management_network_subnet" "test_non_existing" { parent_dn = aci_external_management_network_instance_profile.test.id ip = "2.2.2.0/24" + depends_on = [aci_external_management_network_subnet.test] } ` diff --git a/internal/provider/data_source_aci_l3out_consumer_label_test.go b/internal/provider/data_source_aci_l3out_consumer_label_test.go index 5811e8648..b77e57c10 100644 --- a/internal/provider/data_source_aci_l3out_consumer_label_test.go +++ b/internal/provider/data_source_aci_l3out_consumer_label_test.go @@ -47,9 +47,10 @@ data "aci_l3out_consumer_label" "test" { } ` -const testConfigL3extConsLblNotExistingL3extOut = testConfigL3extOutMin + ` +const testConfigL3extConsLblNotExistingL3extOut = testConfigL3extConsLblMinDependencyWithL3extOut + ` data "aci_l3out_consumer_label" "test_non_existing" { parent_dn = aci_l3_outside.test.id name = "non_existing_name" + depends_on = [aci_l3out_consumer_label.test] } ` diff --git a/internal/provider/data_source_aci_l3out_node_sid_profile_test.go b/internal/provider/data_source_aci_l3out_node_sid_profile_test.go index 29634bab1..76a85fd54 100644 --- a/internal/provider/data_source_aci_l3out_node_sid_profile_test.go +++ b/internal/provider/data_source_aci_l3out_node_sid_profile_test.go @@ -45,9 +45,10 @@ data "aci_l3out_node_sid_profile" "test" { } ` -const testConfigMplsNodeSidPNotExistingL3extLoopBackIfP = testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt + ` +const testConfigMplsNodeSidPNotExistingL3extLoopBackIfP = testConfigMplsNodeSidPMinDependencyWithL3extLoopBackIfP + ` data "aci_l3out_node_sid_profile" "test_non_existing" { parent_dn = aci_l3out_loopback_interface_profile.test.id segment_id = "2" + depends_on = [aci_l3out_node_sid_profile.test] } ` diff --git a/internal/provider/data_source_aci_l3out_provider_label_test.go b/internal/provider/data_source_aci_l3out_provider_label_test.go index a37b73b5e..fa00bca3e 100644 --- a/internal/provider/data_source_aci_l3out_provider_label_test.go +++ b/internal/provider/data_source_aci_l3out_provider_label_test.go @@ -46,9 +46,10 @@ data "aci_l3out_provider_label" "test" { } ` -const testConfigL3extProvLblNotExistingL3extOut = testConfigL3extOutMinDependencyWithFvTenantInfra + ` +const testConfigL3extProvLblNotExistingL3extOut = testConfigL3extProvLblMinDependencyWithL3extOut + ` data "aci_l3out_provider_label" "test_non_existing" { parent_dn = aci_l3_outside.test.id name = "prov_label_non_existing" + depends_on = [aci_l3out_provider_label.test] } ` diff --git a/internal/provider/data_source_aci_l3out_redistribute_policy_test.go b/internal/provider/data_source_aci_l3out_redistribute_policy_test.go index 48ba80197..5bcc81642 100644 --- a/internal/provider/data_source_aci_l3out_redistribute_policy_test.go +++ b/internal/provider/data_source_aci_l3out_redistribute_policy_test.go @@ -44,10 +44,11 @@ data "aci_l3out_redistribute_policy" "test" { } ` -const testConfigL3extRsRedistributePolNotExistingL3extOut = testConfigL3extOutMinDependencyWithFvTenant + ` +const testConfigL3extRsRedistributePolNotExistingL3extOut = testConfigL3extRsRedistributePolMinDependencyWithL3extOut + ` data "aci_l3out_redistribute_policy" "test_non_existing" { parent_dn = aci_l3_outside.test.id route_control_profile_name = "non_existing_tn_rtctrl_profile_name" source = "static" + depends_on = [aci_l3out_redistribute_policy.test] } ` diff --git a/internal/provider/data_source_aci_netflow_monitor_policy_test.go b/internal/provider/data_source_aci_netflow_monitor_policy_test.go index 5cfc3948a..7af9046b2 100644 --- a/internal/provider/data_source_aci_netflow_monitor_policy_test.go +++ b/internal/provider/data_source_aci_netflow_monitor_policy_test.go @@ -45,9 +45,10 @@ data "aci_netflow_monitor_policy" "test" { } ` -const testConfigNetflowMonitorPolNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigNetflowMonitorPolNotExistingFvTenant = testConfigNetflowMonitorPolMinDependencyWithFvTenant + ` data "aci_netflow_monitor_policy" "test_non_existing" { parent_dn = aci_tenant.test.id name = "netfow_monitor_non_existing" + depends_on = [aci_netflow_monitor_policy.test] } ` diff --git a/internal/provider/data_source_aci_netflow_record_policy_test.go b/internal/provider/data_source_aci_netflow_record_policy_test.go index ecfaf204f..3744ffb83 100644 --- a/internal/provider/data_source_aci_netflow_record_policy_test.go +++ b/internal/provider/data_source_aci_netflow_record_policy_test.go @@ -48,9 +48,10 @@ data "aci_netflow_record_policy" "test" { } ` -const testConfigNetflowRecordPolNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigNetflowRecordPolNotExistingFvTenant = testConfigNetflowRecordPolMinDependencyWithFvTenant + ` data "aci_netflow_record_policy" "test_non_existing" { parent_dn = aci_tenant.test.id name = "netfow_record_non_existing" + depends_on = [aci_netflow_record_policy.test] } ` diff --git a/internal/provider/data_source_aci_pim_route_map_entry_test.go b/internal/provider/data_source_aci_pim_route_map_entry_test.go index 777403a1e..601ec2d8b 100644 --- a/internal/provider/data_source_aci_pim_route_map_entry_test.go +++ b/internal/provider/data_source_aci_pim_route_map_entry_test.go @@ -48,9 +48,10 @@ data "aci_pim_route_map_entry" "test" { } ` -const testConfigPimRouteMapEntryNotExistingPimRouteMapPol = testConfigPimRouteMapPolMinDependencyWithFvTenant + ` +const testConfigPimRouteMapEntryNotExistingPimRouteMapPol = testConfigPimRouteMapEntryMinDependencyWithPimRouteMapPol + ` data "aci_pim_route_map_entry" "test_non_existing" { parent_dn = aci_pim_route_map_policy.test.id order = "2" + depends_on = [aci_pim_route_map_entry.test] } ` diff --git a/internal/provider/data_source_aci_pim_route_map_policy_test.go b/internal/provider/data_source_aci_pim_route_map_policy_test.go index 0220f8f03..69b8daa95 100644 --- a/internal/provider/data_source_aci_pim_route_map_policy_test.go +++ b/internal/provider/data_source_aci_pim_route_map_policy_test.go @@ -45,9 +45,10 @@ data "aci_pim_route_map_policy" "test" { } ` -const testConfigPimRouteMapPolNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigPimRouteMapPolNotExistingFvTenant = testConfigPimRouteMapPolMinDependencyWithFvTenant + ` data "aci_pim_route_map_policy" "test_non_existing" { parent_dn = aci_tenant.test.id name = "non_existing_name" + depends_on = [aci_pim_route_map_policy.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_consumed_contract_test.go b/internal/provider/data_source_aci_relation_to_consumed_contract_test.go index 15cab183f..927107e86 100644 --- a/internal/provider/data_source_aci_relation_to_consumed_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_consumed_contract_test.go @@ -64,10 +64,11 @@ data "aci_relation_to_consumed_contract" "test" { } ` -const testConfigFvRsConsNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsConsNotExistingFvAEPg = testConfigFvRsConsMinDependencyWithFvAEPg + ` data "aci_relation_to_consumed_contract" "test_non_existing" { parent_dn = aci_application_epg.test.id contract_name = "non_existing_tn_vz_br_cp_name" + depends_on = [aci_relation_to_consumed_contract.test] } ` const testConfigFvRsConsDataSourceDependencyWithFvESg = testConfigFvRsConsMinDependencyWithFvESg + ` @@ -78,9 +79,10 @@ data "aci_relation_to_consumed_contract" "test" { } ` -const testConfigFvRsConsNotExistingFvESg = testConfigFvESgMinDependencyWithFvAp + ` +const testConfigFvRsConsNotExistingFvESg = testConfigFvRsConsMinDependencyWithFvESg + ` data "aci_relation_to_consumed_contract" "test_non_existing" { parent_dn = aci_endpoint_security_group.test.id contract_name = "non_existing_tn_vz_br_cp_name" + depends_on = [aci_relation_to_consumed_contract.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract_test.go b/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract_test.go index e3bc93845..c935ea7d2 100644 --- a/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract_test.go @@ -42,9 +42,10 @@ data "aci_relation_to_consumed_out_of_band_contract" "test" { } ` -const testConfigMgmtRsOoBConsNotExistingMgmtInstP = testConfigMgmtInstPMin + ` +const testConfigMgmtRsOoBConsNotExistingMgmtInstP = testConfigMgmtRsOoBConsMinDependencyWithMgmtInstP + ` data "aci_relation_to_consumed_out_of_band_contract" "test_non_existing" { parent_dn = aci_external_management_network_instance_profile.test.id out_of_band_contract_name = "non_existing_tn_vz_oob_br_cp_name" + depends_on = [aci_relation_to_consumed_out_of_band_contract.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_contract_master_test.go b/internal/provider/data_source_aci_relation_to_contract_master_test.go index af13936d4..021aa5e64 100644 --- a/internal/provider/data_source_aci_relation_to_contract_master_test.go +++ b/internal/provider/data_source_aci_relation_to_contract_master_test.go @@ -62,10 +62,11 @@ data "aci_relation_to_contract_master" "test" { } ` -const testConfigFvRsSecInheritedNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsSecInheritedNotExistingFvAEPg = testConfigFvRsSecInheritedMinDependencyWithFvAEPg + ` data "aci_relation_to_contract_master" "test_non_existing" { parent_dn = aci_application_epg.test.id target_dn = "uni/tn-test_tenant/ap-test_ap/epg-epg_2_not_existing" + depends_on = [aci_relation_to_contract_master.test] } ` const testConfigFvRsSecInheritedDataSourceDependencyWithFvESg = testConfigFvRsSecInheritedMinDependencyWithFvESg + ` @@ -76,9 +77,10 @@ data "aci_relation_to_contract_master" "test" { } ` -const testConfigFvRsSecInheritedNotExistingFvESg = testConfigFvESgMinDependencyWithFvAp + ` +const testConfigFvRsSecInheritedNotExistingFvESg = testConfigFvRsSecInheritedMinDependencyWithFvESg + ` data "aci_relation_to_contract_master" "test_non_existing" { parent_dn = aci_endpoint_security_group.test.id target_dn = "uni/tn-test_tenant/ap-test_ap/esg-esg_0_not_existing" + depends_on = [aci_relation_to_contract_master.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_domain_test.go b/internal/provider/data_source_aci_relation_to_domain_test.go index e79de2bdc..7cfe03d32 100644 --- a/internal/provider/data_source_aci_relation_to_domain_test.go +++ b/internal/provider/data_source_aci_relation_to_domain_test.go @@ -62,9 +62,10 @@ data "aci_relation_to_domain" "test" { } ` -const testConfigFvRsDomAttNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsDomAttNotExistingFvAEPg = testConfigFvRsDomAttMinDependencyWithFvAEPg + ` data "aci_relation_to_domain" "test_non_existing" { parent_dn = aci_application_epg.test.id target_dn = "uni/vmmp-VMware/dom-domain_1_not_existing" + depends_on = [aci_relation_to_domain.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_fibre_channel_path_test.go b/internal/provider/data_source_aci_relation_to_fibre_channel_path_test.go index 46eb676b0..07a492337 100644 --- a/internal/provider/data_source_aci_relation_to_fibre_channel_path_test.go +++ b/internal/provider/data_source_aci_relation_to_fibre_channel_path_test.go @@ -44,9 +44,10 @@ data "aci_relation_to_fibre_channel_path" "test" { } ` -const testConfigFvRsFcPathAttNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsFcPathAttNotExistingFvAEPg = testConfigFvRsFcPathAttMinDependencyWithFvAEPg + ` data "aci_relation_to_fibre_channel_path" "test_non_existing" { parent_dn = aci_application_epg.test.id target_dn = "topology/pod-2/paths-201/pathep-[eth1/1]" + depends_on = [aci_relation_to_fibre_channel_path.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_imported_contract_test.go b/internal/provider/data_source_aci_relation_to_imported_contract_test.go index a63066e2c..ea6c898c8 100644 --- a/internal/provider/data_source_aci_relation_to_imported_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_imported_contract_test.go @@ -64,10 +64,11 @@ data "aci_relation_to_imported_contract" "test" { } ` -const testConfigFvRsConsIfNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsConsIfNotExistingFvAEPg = testConfigFvRsConsIfMinDependencyWithFvAEPg + ` data "aci_relation_to_imported_contract" "test_non_existing" { parent_dn = aci_application_epg.test.id imported_contract_name = "non_existing_tn_vz_cp_if_name" + depends_on = [aci_relation_to_imported_contract.test] } ` const testConfigFvRsConsIfDataSourceDependencyWithFvESg = testConfigFvRsConsIfMinDependencyWithFvESg + ` @@ -78,9 +79,10 @@ data "aci_relation_to_imported_contract" "test" { } ` -const testConfigFvRsConsIfNotExistingFvESg = testConfigFvESgMinDependencyWithFvAp + ` +const testConfigFvRsConsIfNotExistingFvESg = testConfigFvRsConsIfMinDependencyWithFvESg + ` data "aci_relation_to_imported_contract" "test_non_existing" { parent_dn = aci_endpoint_security_group.test.id imported_contract_name = "non_existing_tn_vz_cp_if_name" + depends_on = [aci_relation_to_imported_contract.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go b/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go index 617798ccd..ac7d382cb 100644 --- a/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_intra_epg_contract_test.go @@ -62,10 +62,11 @@ data "aci_relation_to_intra_epg_contract" "test" { } ` -const testConfigFvRsIntraEpgNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsIntraEpgNotExistingFvAEPg = testConfigFvRsIntraEpgMinDependencyWithFvAEPg + ` data "aci_relation_to_intra_epg_contract" "test_non_existing" { parent_dn = aci_application_epg.test.id contract_name = "non_existing_tn_vz_br_cp_name" + depends_on = [aci_relation_to_intra_epg_contract.test] } ` const testConfigFvRsIntraEpgDataSourceDependencyWithFvESg = testConfigFvRsIntraEpgMinDependencyWithFvESg + ` @@ -76,9 +77,10 @@ data "aci_relation_to_intra_epg_contract" "test" { } ` -const testConfigFvRsIntraEpgNotExistingFvESg = testConfigFvESgMinDependencyWithFvAp + ` +const testConfigFvRsIntraEpgNotExistingFvESg = testConfigFvRsIntraEpgMinDependencyWithFvESg + ` data "aci_relation_to_intra_epg_contract" "test_non_existing" { parent_dn = aci_endpoint_security_group.test.id contract_name = "non_existing_tn_vz_br_cp_name" + depends_on = [aci_relation_to_intra_epg_contract.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_netflow_exporter_test.go b/internal/provider/data_source_aci_relation_to_netflow_exporter_test.go index cbb1f515b..c5ef90c08 100644 --- a/internal/provider/data_source_aci_relation_to_netflow_exporter_test.go +++ b/internal/provider/data_source_aci_relation_to_netflow_exporter_test.go @@ -41,9 +41,10 @@ data "aci_relation_to_netflow_exporter" "test" { } ` -const testConfigNetflowRsMonitorToExporterNotExistingNetflowMonitorPol = testConfigNetflowMonitorPolMinDependencyWithFvTenant + ` +const testConfigNetflowRsMonitorToExporterNotExistingNetflowMonitorPol = testConfigNetflowRsMonitorToExporterMinDependencyWithNetflowMonitorPol + ` data "aci_relation_to_netflow_exporter" "test_non_existing" { parent_dn = aci_netflow_monitor_policy.test.id netflow_exporter_policy_name = "non_existing_tn_netflow_exporter_pol_name" + depends_on = [aci_relation_to_netflow_exporter.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_provided_contract_test.go b/internal/provider/data_source_aci_relation_to_provided_contract_test.go index 0331bab61..8a8cd867d 100644 --- a/internal/provider/data_source_aci_relation_to_provided_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_provided_contract_test.go @@ -66,10 +66,11 @@ data "aci_relation_to_provided_contract" "test" { } ` -const testConfigFvRsProvNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsProvNotExistingFvAEPg = testConfigFvRsProvMinDependencyWithFvAEPg + ` data "aci_relation_to_provided_contract" "test_non_existing" { parent_dn = aci_application_epg.test.id contract_name = "non_existing_tn_vz_br_cp_name" + depends_on = [aci_relation_to_provided_contract.test] } ` const testConfigFvRsProvDataSourceDependencyWithFvESg = testConfigFvRsProvMinDependencyWithFvESg + ` @@ -80,9 +81,10 @@ data "aci_relation_to_provided_contract" "test" { } ` -const testConfigFvRsProvNotExistingFvESg = testConfigFvESgMinDependencyWithFvAp + ` +const testConfigFvRsProvNotExistingFvESg = testConfigFvRsProvMinDependencyWithFvESg + ` data "aci_relation_to_provided_contract" "test_non_existing" { parent_dn = aci_endpoint_security_group.test.id contract_name = "non_existing_tn_vz_br_cp_name" + depends_on = [aci_relation_to_provided_contract.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_static_leaf_test.go b/internal/provider/data_source_aci_relation_to_static_leaf_test.go index 22160c77f..df2e83894 100644 --- a/internal/provider/data_source_aci_relation_to_static_leaf_test.go +++ b/internal/provider/data_source_aci_relation_to_static_leaf_test.go @@ -45,9 +45,10 @@ data "aci_relation_to_static_leaf" "test" { } ` -const testConfigFvRsNodeAttNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsNodeAttNotExistingFvAEPg = testConfigFvRsNodeAttMinDependencyWithFvAEPg + ` data "aci_relation_to_static_leaf" "test_non_existing" { parent_dn = aci_application_epg.test.id target_dn = "topology/pod-2/paths-201/pathep-[eth1/1]" + depends_on = [aci_relation_to_static_leaf.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_static_path_test.go b/internal/provider/data_source_aci_relation_to_static_path_test.go index 7409c6b96..cd9ee2928 100644 --- a/internal/provider/data_source_aci_relation_to_static_path_test.go +++ b/internal/provider/data_source_aci_relation_to_static_path_test.go @@ -46,9 +46,10 @@ data "aci_relation_to_static_path" "test" { } ` -const testConfigFvRsPathAttNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsPathAttNotExistingFvAEPg = testConfigFvRsPathAttMinDependencyWithFvAEPg + ` data "aci_relation_to_static_path" "test_non_existing" { parent_dn = aci_application_epg.test.id target_dn = "topology/pod-2/paths-201/pathep-[eth1/1]" + depends_on = [aci_relation_to_static_path.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_taboo_contract_test.go b/internal/provider/data_source_aci_relation_to_taboo_contract_test.go index 50c3eba9d..2f9b43963 100644 --- a/internal/provider/data_source_aci_relation_to_taboo_contract_test.go +++ b/internal/provider/data_source_aci_relation_to_taboo_contract_test.go @@ -41,9 +41,10 @@ data "aci_relation_to_taboo_contract" "test" { } ` -const testConfigFvRsProtByNotExistingFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +const testConfigFvRsProtByNotExistingFvAEPg = testConfigFvRsProtByMinDependencyWithFvAEPg + ` data "aci_relation_to_taboo_contract" "test_non_existing" { parent_dn = aci_application_epg.test.id taboo_contract_name = "non_existing_tn_vz_taboo_name" + depends_on = [aci_relation_to_taboo_contract.test] } ` diff --git a/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group_test.go b/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group_test.go index 4eda76267..4784c0a3b 100644 --- a/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group_test.go +++ b/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group_test.go @@ -41,9 +41,10 @@ data "aci_relation_to_vrf_fallback_route_group" "test" { } ` -const testConfigL3extRsOutToFBRGroupNotExistingL3extOut = testConfigL3extOutMinDependencyWithFvTenant + ` +const testConfigL3extRsOutToFBRGroupNotExistingL3extOut = testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut + ` data "aci_relation_to_vrf_fallback_route_group" "test_non_existing" { parent_dn = aci_l3_outside.test.id target_dn = "uni/tn-test_tenant/ctx-test_vrf/fbrg-vrf_fallback_route_group_0_not_existing" + depends_on = [aci_relation_to_vrf_fallback_route_group.test] } ` diff --git a/internal/provider/data_source_aci_remote_site_id_mappings.go b/internal/provider/data_source_aci_remote_site_id_mappings.go new file mode 100644 index 000000000..b6d0b3ef8 --- /dev/null +++ b/internal/provider/data_source_aci_remote_site_id_mappings.go @@ -0,0 +1,177 @@ +// 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 = &FvRemoteIdDataSource{} + +func NewFvRemoteIdDataSource() datasource.DataSource { + return &FvRemoteIdDataSource{} +} + +// FvRemoteIdDataSource defines the data source implementation. +type FvRemoteIdDataSource struct { + client *client.Client +} + +func (d *FvRemoteIdDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_remote_site_id_mappings") + resp.TypeName = req.ProviderTypeName + "_remote_site_id_mappings" + tflog.Debug(ctx, "End metadata of datasource: aci_remote_site_id_mappings") +} + +func (d *FvRemoteIdDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_remote_site_id_mappings") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The remote_site_id_mappings datasource for the 'fvRemoteId' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Remote Site Id Mappings 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 Remote Site Id Mappings object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Remote Site Id Mappings object.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the Remote Site Id Mappings object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Remote Site Id Mappings 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.`, + }, + "remote_vrf_pc_tag": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Remote context's *pcTag*, mapping required for default route case.`, + }, + "remote_pc_tag": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Remote Class ID.`, + }, + "site_id": schema.StringAttribute{ + Required: true, + MarkdownDescription: `A number between 0 and 1000 to identify the remote site being associated with the primary site.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_remote_site_id_mappings") +} + +func (d *FvRemoteIdDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_remote_site_id_mappings") + // 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_remote_site_id_mappings") +} + +func (d *FvRemoteIdDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_remote_site_id_mappings") + var data *FvRemoteIdResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setFvRemoteIdId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetFvRemoteIdAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_remote_site_id_mappings with id '%s'", data.Id.ValueString())) + + getAndSetFvRemoteIdAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_remote_site_id_mappings data source", + fmt.Sprintf("The aci_remote_site_id_mappings 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_remote_site_id_mappings with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_remote_site_id_mappings_test.go b/internal/provider/data_source_aci_remote_site_id_mappings_test.go new file mode 100644 index 000000000..40b1115e9 --- /dev/null +++ b/internal/provider/data_source_aci_remote_site_id_mappings_test.go @@ -0,0 +1,58 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceFvRemoteIdWithFvSiteAssociated(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvRemoteIdDataSourceDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "site_id", "100"), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "name", ""), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "owner_key", ""), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "owner_tag", ""), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "any"), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "site_id", "100"), + ), + }, + { + Config: testConfigFvRemoteIdNotExistingFvSiteAssociated, + ExpectError: regexp.MustCompile("Failed to read aci_remote_site_id_mappings data source"), + }, + }, + }) +} + +const testConfigFvRemoteIdDataSourceDependencyWithFvSiteAssociated = testConfigFvRemoteIdMinDependencyWithFvSiteAssociated + ` +data "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + site_id = "100" + depends_on = [aci_remote_site_id_mappings.test] +} +` + +const testConfigFvRemoteIdNotExistingFvSiteAssociated = testConfigFvRemoteIdMinDependencyWithFvSiteAssociated + ` +data "aci_remote_site_id_mappings" "test_non_existing" { + parent_dn = aci_associated_site.test.id + site_id = "102" + depends_on = [aci_remote_site_id_mappings.test] +} +` diff --git a/internal/provider/data_source_aci_tag_test.go b/internal/provider/data_source_aci_tag_test.go index dcdbafeef..db0b0865f 100644 --- a/internal/provider/data_source_aci_tag_test.go +++ b/internal/provider/data_source_aci_tag_test.go @@ -62,10 +62,11 @@ data "aci_tag" "test" { } ` -const testConfigTagTagNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigTagTagNotExistingFvTenant = testConfigTagTagMinDependencyWithFvTenant + ` data "aci_tag" "test_non_existing" { parent_dn = aci_tenant.test.id key = "non_existing_key" + depends_on = [aci_tag.test] } ` const testConfigTagTagDataSourceDependencyWithFvAEPg = testConfigTagTagMinDependencyWithFvAEPg + ` @@ -76,9 +77,10 @@ data "aci_tag" "test" { } ` -const testConfigTagTagNotExistingFvAEPg = testConfigFvAEPgMin + ` +const testConfigTagTagNotExistingFvAEPg = testConfigTagTagMinDependencyWithFvAEPg + ` data "aci_tag" "test_non_existing" { parent_dn = aci_application_epg.test.id key = "non_existing_key" + depends_on = [aci_tag.test] } ` diff --git a/internal/provider/data_source_aci_trust_control_policy_test.go b/internal/provider/data_source_aci_trust_control_policy_test.go index bfda656ab..fc272cd41 100644 --- a/internal/provider/data_source_aci_trust_control_policy_test.go +++ b/internal/provider/data_source_aci_trust_control_policy_test.go @@ -51,9 +51,10 @@ data "aci_trust_control_policy" "test" { } ` -const testConfigFhsTrustCtrlPolNotExistingFvTenant = testConfigFvTenantMin + ` +const testConfigFhsTrustCtrlPolNotExistingFvTenant = testConfigFhsTrustCtrlPolMinDependencyWithFvTenant + ` data "aci_trust_control_policy" "test_non_existing" { parent_dn = aci_tenant.test.id name = "non_existing_name" + depends_on = [aci_trust_control_policy.test] } ` diff --git a/internal/provider/data_source_aci_vrf_fallback_route_group_member_test.go b/internal/provider/data_source_aci_vrf_fallback_route_group_member_test.go index 54f9fb60f..a2dfe2eb0 100644 --- a/internal/provider/data_source_aci_vrf_fallback_route_group_member_test.go +++ b/internal/provider/data_source_aci_vrf_fallback_route_group_member_test.go @@ -44,9 +44,10 @@ data "aci_vrf_fallback_route_group_member" "test" { } ` -const testConfigFvFBRMemberNotExistingFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +const testConfigFvFBRMemberNotExistingFvFBRGroup = testConfigFvFBRMemberMinDependencyWithFvFBRGroup + ` data "aci_vrf_fallback_route_group_member" "test_non_existing" { parent_dn = aci_vrf_fallback_route_group.test.id fallback_member = "2.2.2.4" + depends_on = [aci_vrf_fallback_route_group_member.test] } ` diff --git a/internal/provider/data_source_aci_vrf_fallback_route_group_test.go b/internal/provider/data_source_aci_vrf_fallback_route_group_test.go index c01f15411..c4c12ffe6 100644 --- a/internal/provider/data_source_aci_vrf_fallback_route_group_test.go +++ b/internal/provider/data_source_aci_vrf_fallback_route_group_test.go @@ -43,9 +43,10 @@ data "aci_vrf_fallback_route_group" "test" { } ` -const testConfigFvFBRGroupNotExistingFvCtx = testConfigFvCtxMinDependencyWithFvTenant + ` +const testConfigFvFBRGroupNotExistingFvCtx = testConfigFvFBRGroupMinDependencyWithFvCtx + ` data "aci_vrf_fallback_route_group" "test_non_existing" { parent_dn = aci_vrf.test.id name = "fallback_route_group_non_existing" + depends_on = [aci_vrf_fallback_route_group.test] } ` diff --git a/internal/provider/data_source_aci_vrf_fallback_route_test.go b/internal/provider/data_source_aci_vrf_fallback_route_test.go index 7e7a89729..50e58ac8f 100644 --- a/internal/provider/data_source_aci_vrf_fallback_route_test.go +++ b/internal/provider/data_source_aci_vrf_fallback_route_test.go @@ -44,9 +44,10 @@ data "aci_vrf_fallback_route" "test" { } ` -const testConfigFvFBRouteNotExistingFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +const testConfigFvFBRouteNotExistingFvFBRGroup = testConfigFvFBRouteMinDependencyWithFvFBRGroup + ` data "aci_vrf_fallback_route" "test_non_existing" { parent_dn = aci_vrf_fallback_route_group.test.id prefix_address = "2.2.2.4/24" + depends_on = [aci_vrf_fallback_route.test] } ` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 88b87432f..ab16bf05d 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -217,6 +217,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvIdGroupAttrResource, NewFvIpAttrResource, NewFvMacAttrResource, + NewFvRemoteIdResource, NewFvRsConsResource, NewFvRsConsIfResource, NewFvRsDomAttResource, @@ -228,6 +229,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvRsProvResource, NewFvRsSecInheritedResource, NewFvSCrtrnResource, + NewFvSiteAssociatedResource, NewFvVmAttrResource, NewL3extConsLblResource, NewL3extProvLblResource, @@ -266,6 +268,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvIdGroupAttrDataSource, NewFvIpAttrDataSource, NewFvMacAttrDataSource, + NewFvRemoteIdDataSource, NewFvRsConsDataSource, NewFvRsConsIfDataSource, NewFvRsDomAttDataSource, @@ -277,6 +280,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvRsProvDataSource, NewFvRsSecInheritedDataSource, NewFvSCrtrnDataSource, + NewFvSiteAssociatedDataSource, NewFvVmAttrDataSource, NewL3extConsLblDataSource, NewL3extProvLblDataSource, diff --git a/internal/provider/resource_aci_application_epg.go b/internal/provider/resource_aci_application_epg.go index 39be5de51..9e691f98a 100644 --- a/internal/provider/resource_aci_application_epg.go +++ b/internal/provider/resource_aci_application_epg.go @@ -78,6 +78,7 @@ type FvAEPgResourceModel struct { FvRsProv types.Set `tfsdk:"relation_to_provided_contracts"` FvRsSecInherited types.Set `tfsdk:"relation_to_contract_masters"` FvRsTrustCtrl types.Set `tfsdk:"relation_to_trust_control_policy"` + FvSiteAssociated types.Set `tfsdk:"associated_site"` TagAnnotation types.Set `tfsdk:"annotations"` TagTag types.Set `tfsdk:"tags"` DeprecatedExceptionTag types.String `tfsdk:"exception_tag"` @@ -269,6 +270,17 @@ func getEmptyFvAEPgResourceModel() *FvAEPgResourceModel { "trust_control_policy_name": types.StringType, }, }), + FvSiteAssociated: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "description": types.StringType, + "name": types.StringType, + "name_alias": types.StringType, + "owner_key": types.StringType, + "owner_tag": types.StringType, + "site_id": types.StringType, + }, + }), TagAnnotation: types.SetNull(types.ObjectType{ AttrTypes: map[string]attr.Type{ "key": types.StringType, @@ -611,6 +623,29 @@ func getEmptyFvRsTrustCtrlFvAEPgResourceModel() FvRsTrustCtrlFvAEPgResourceModel } } +// FvSiteAssociatedFvAEPgResourceModel describes the resource data model for the children without relation ships. +type FvSiteAssociatedFvAEPgResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + SiteId types.String `tfsdk:"site_id"` +} + +func getEmptyFvSiteAssociatedFvAEPgResourceModel() FvSiteAssociatedFvAEPgResourceModel { + return FvSiteAssociatedFvAEPgResourceModel{ + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + SiteId: basetypes.NewStringNull(), + } +} + // TagAnnotationFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1259,6 +1294,20 @@ func (r *FvAEPgResource) UpgradeState(ctx context.Context) map[int64]resource.St FvRsTrustCtrlSet, _ := types.SetValueFrom(ctx, FvRsTrustCtrlType, FvRsTrustCtrlList) upgradedStateData.FvRsTrustCtrl = FvRsTrustCtrlSet + upgradedStateData.FvSiteAssociated = types.SetNull( + types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": basetypes.StringType{}, + "description": basetypes.StringType{}, + "name": basetypes.StringType{}, + "name_alias": basetypes.StringType{}, + "owner_key": basetypes.StringType{}, + "owner_tag": basetypes.StringType{}, + "site_id": basetypes.StringType{}, + }, + }, + ) + upgradedStateData.TagAnnotation = types.SetNull( types.ObjectType{ AttrTypes: map[string]attr.Type{ @@ -3772,6 +3821,86 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, }, }, }, + "associated_site": schema.SetNestedAttribute{ + MarkdownDescription: `Used to store ID mappings`, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.Set{ + setvalidator.SizeAtMost(1), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{}, + MarkdownDescription: `The annotation of the Associated Site object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{}, + MarkdownDescription: `The description of the Associated Site object.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{}, + MarkdownDescription: `The name of the Associated Site object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{}, + MarkdownDescription: `The name alias of the Associated Site object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{}, + 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(), + }, + Validators: []validator.String{}, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "site_id": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + MakeStringRequired(), + }, + MarkdownDescription: `A number between 0 and 1000 to identify the primary site being associated.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, @@ -4005,13 +4134,16 @@ func (r *FvAEPgResource) Create(ctx context.Context, req resource.CreateRequest, var fvRsTrustCtrlPlan, fvRsTrustCtrlState []FvRsTrustCtrlFvAEPgResourceModel data.FvRsTrustCtrl.ElementsAs(ctx, &fvRsTrustCtrlPlan, false) stateData.FvRsTrustCtrl.ElementsAs(ctx, &fvRsTrustCtrlState, false) + var fvSiteAssociatedPlan, fvSiteAssociatedState []FvSiteAssociatedFvAEPgResourceModel + data.FvSiteAssociated.ElementsAs(ctx, &fvSiteAssociatedPlan, false) + stateData.FvSiteAssociated.ElementsAs(ctx, &fvSiteAssociatedState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvAEPgResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagFvAEPgResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvAEPgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvCrtrnPlan, fvCrtrnState, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState, fvRsBdPlan, fvRsBdState, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsCustQosPolPlan, fvRsCustQosPolState, fvRsDomAttPlan, fvRsDomAttState, fvRsDppPolPlan, fvRsDppPolState, fvRsFcPathAttPlan, fvRsFcPathAttState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsNodeAttPlan, fvRsNodeAttState, fvRsPathAttPlan, fvRsPathAttState, fvRsProtByPlan, fvRsProtByState, fvRsProvPlan, fvRsProvState, fvRsSecInheritedPlan, fvRsSecInheritedState, fvRsTrustCtrlPlan, fvRsTrustCtrlState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getFvAEPgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvCrtrnPlan, fvCrtrnState, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState, fvRsBdPlan, fvRsBdState, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsCustQosPolPlan, fvRsCustQosPolState, fvRsDomAttPlan, fvRsDomAttState, fvRsDppPolPlan, fvRsDppPolState, fvRsFcPathAttPlan, fvRsFcPathAttState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsNodeAttPlan, fvRsNodeAttState, fvRsPathAttPlan, fvRsPathAttState, fvRsProtByPlan, fvRsProtByState, fvRsProvPlan, fvRsProvState, fvRsSecInheritedPlan, fvRsSecInheritedState, fvRsTrustCtrlPlan, fvRsTrustCtrlState, fvSiteAssociatedPlan, fvSiteAssociatedState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -4118,13 +4250,16 @@ func (r *FvAEPgResource) Update(ctx context.Context, req resource.UpdateRequest, var fvRsTrustCtrlPlan, fvRsTrustCtrlState []FvRsTrustCtrlFvAEPgResourceModel data.FvRsTrustCtrl.ElementsAs(ctx, &fvRsTrustCtrlPlan, false) stateData.FvRsTrustCtrl.ElementsAs(ctx, &fvRsTrustCtrlState, false) + var fvSiteAssociatedPlan, fvSiteAssociatedState []FvSiteAssociatedFvAEPgResourceModel + data.FvSiteAssociated.ElementsAs(ctx, &fvSiteAssociatedPlan, false) + stateData.FvSiteAssociated.ElementsAs(ctx, &fvSiteAssociatedState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvAEPgResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagFvAEPgResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvAEPgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvCrtrnPlan, fvCrtrnState, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState, fvRsBdPlan, fvRsBdState, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsCustQosPolPlan, fvRsCustQosPolState, fvRsDomAttPlan, fvRsDomAttState, fvRsDppPolPlan, fvRsDppPolState, fvRsFcPathAttPlan, fvRsFcPathAttState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsNodeAttPlan, fvRsNodeAttState, fvRsPathAttPlan, fvRsPathAttState, fvRsProtByPlan, fvRsProtByState, fvRsProvPlan, fvRsProvState, fvRsSecInheritedPlan, fvRsSecInheritedState, fvRsTrustCtrlPlan, fvRsTrustCtrlState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getFvAEPgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvCrtrnPlan, fvCrtrnState, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState, fvRsBdPlan, fvRsBdState, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsCustQosPolPlan, fvRsCustQosPolState, fvRsDomAttPlan, fvRsDomAttState, fvRsDppPolPlan, fvRsDppPolState, fvRsFcPathAttPlan, fvRsFcPathAttState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsNodeAttPlan, fvRsNodeAttState, fvRsPathAttPlan, fvRsPathAttState, fvRsProtByPlan, fvRsProtByState, fvRsProvPlan, fvRsProvState, fvRsSecInheritedPlan, fvRsSecInheritedState, fvRsTrustCtrlPlan, fvRsTrustCtrlState, fvSiteAssociatedPlan, fvSiteAssociatedState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -4178,7 +4313,7 @@ func (r *FvAEPgResource) ImportState(ctx context.Context, req resource.ImportSta } func getAndSetFvAEPgAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *FvAEPgResourceModel) { - requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "fvAEPg,fvCrtrn,fvRsAEPgMonPol,fvRsBd,fvRsCons,fvRsConsIf,fvRsCustQosPol,fvRsDomAtt,fvRsDppPol,fvRsFcPathAtt,fvRsIntraEpg,fvRsNodeAtt,fvRsPathAtt,fvRsProtBy,fvRsProv,fvRsSecInherited,fvRsTrustCtrl,tagAnnotation,tagTag"), "GET", nil) + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "fvAEPg,fvCrtrn,fvRsAEPgMonPol,fvRsBd,fvRsCons,fvRsConsIf,fvRsCustQosPol,fvRsDomAtt,fvRsDppPol,fvRsFcPathAtt,fvRsIntraEpg,fvRsNodeAtt,fvRsPathAtt,fvRsProtBy,fvRsProv,fvRsSecInherited,fvRsTrustCtrl,fvSiteAssociated,tagAnnotation,tagTag"), "GET", nil) *data = *getEmptyFvAEPgResourceModel() @@ -4258,6 +4393,7 @@ func getAndSetFvAEPgAttributes(ctx context.Context, diags *diag.Diagnostics, cli FvRsProvFvAEPgList := make([]FvRsProvFvAEPgResourceModel, 0) FvRsSecInheritedFvAEPgList := make([]FvRsSecInheritedFvAEPgResourceModel, 0) FvRsTrustCtrlFvAEPgList := make([]FvRsTrustCtrlFvAEPgResourceModel, 0) + FvSiteAssociatedFvAEPgList := make([]FvSiteAssociatedFvAEPgResourceModel, 0) TagAnnotationFvAEPgList := make([]TagAnnotationFvAEPgResourceModel, 0) TagTagFvAEPgList := make([]TagTagFvAEPgResourceModel, 0) _, ok := classReadInfo[0].(map[string]interface{})["children"] @@ -4603,6 +4739,33 @@ func getAndSetFvAEPgAttributes(ctx context.Context, diags *diag.Diagnostics, cli } FvRsTrustCtrlFvAEPgList = append(FvRsTrustCtrlFvAEPgList, FvRsTrustCtrlFvAEPg) } + if childClassName == "fvSiteAssociated" { + FvSiteAssociatedFvAEPg := getEmptyFvSiteAssociatedFvAEPgResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + FvSiteAssociatedFvAEPg.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "descr" { + FvSiteAssociatedFvAEPg.Descr = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "name" { + FvSiteAssociatedFvAEPg.Name = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "nameAlias" { + FvSiteAssociatedFvAEPg.NameAlias = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "ownerKey" { + FvSiteAssociatedFvAEPg.OwnerKey = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "ownerTag" { + FvSiteAssociatedFvAEPg.OwnerTag = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "siteId" { + FvSiteAssociatedFvAEPg.SiteId = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + FvSiteAssociatedFvAEPgList = append(FvSiteAssociatedFvAEPgList, FvSiteAssociatedFvAEPg) + } if childClassName == "tagAnnotation" { TagAnnotationFvAEPg := getEmptyTagAnnotationFvAEPgResourceModel() for childAttributeName, childAttributeValue := range childAttributes { @@ -4662,6 +4825,8 @@ func getAndSetFvAEPgAttributes(ctx context.Context, diags *diag.Diagnostics, cli data.FvRsSecInherited = fvRsSecInheritedSet fvRsTrustCtrlSet, _ := types.SetValueFrom(ctx, data.FvRsTrustCtrl.ElementType(ctx), FvRsTrustCtrlFvAEPgList) data.FvRsTrustCtrl = fvRsTrustCtrlSet + fvSiteAssociatedSet, _ := types.SetValueFrom(ctx, data.FvSiteAssociated.ElementType(ctx), FvSiteAssociatedFvAEPgList) + data.FvSiteAssociated = fvSiteAssociatedSet tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationFvAEPgList) data.TagAnnotation = tagAnnotationSet tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagFvAEPgList) @@ -5426,6 +5591,48 @@ func getFvAEPgFvRsTrustCtrlChildPayloads(ctx context.Context, diags *diag.Diagno return childPayloads } +func getFvAEPgFvSiteAssociatedChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvAEPgResourceModel, fvSiteAssociatedPlan, fvSiteAssociatedState []FvSiteAssociatedFvAEPgResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.FvSiteAssociated.IsUnknown() { + for _, fvSiteAssociated := range fvSiteAssociatedPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !fvSiteAssociated.Annotation.IsUnknown() && !fvSiteAssociated.Annotation.IsNull() { + childMap["attributes"]["annotation"] = fvSiteAssociated.Annotation.ValueString() + } else { + childMap["attributes"]["annotation"] = globalAnnotation + } + if !fvSiteAssociated.Descr.IsUnknown() && !fvSiteAssociated.Descr.IsNull() { + childMap["attributes"]["descr"] = fvSiteAssociated.Descr.ValueString() + } + if !fvSiteAssociated.Name.IsUnknown() && !fvSiteAssociated.Name.IsNull() { + childMap["attributes"]["name"] = fvSiteAssociated.Name.ValueString() + } + if !fvSiteAssociated.NameAlias.IsUnknown() && !fvSiteAssociated.NameAlias.IsNull() { + childMap["attributes"]["nameAlias"] = fvSiteAssociated.NameAlias.ValueString() + } + if !fvSiteAssociated.OwnerKey.IsUnknown() && !fvSiteAssociated.OwnerKey.IsNull() { + childMap["attributes"]["ownerKey"] = fvSiteAssociated.OwnerKey.ValueString() + } + if !fvSiteAssociated.OwnerTag.IsUnknown() && !fvSiteAssociated.OwnerTag.IsNull() { + childMap["attributes"]["ownerTag"] = fvSiteAssociated.OwnerTag.ValueString() + } + if !fvSiteAssociated.SiteId.IsUnknown() && !fvSiteAssociated.SiteId.IsNull() { + childMap["attributes"]["siteId"] = fvSiteAssociated.SiteId.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"fvSiteAssociated": childMap}) + } + if len(fvSiteAssociatedPlan) == 0 && len(fvSiteAssociatedState) == 1 { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childPayloads = append(childPayloads, map[string]interface{}{"fvSiteAssociated": childMap}) + } + } else { + data.FvSiteAssociated = types.SetNull(data.FvSiteAssociated.ElementType(ctx)) + } + + return childPayloads +} func getFvAEPgTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvAEPgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvAEPgResourceModel) []map[string]interface{} { childPayloads := []map[string]interface{}{} @@ -5505,7 +5712,7 @@ func getFvAEPgTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, return childPayloads } -func getFvAEPgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvAEPgResourceModel, fvCrtrnPlan, fvCrtrnState []FvCrtrnFvAEPgResourceModel, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState []FvRsAEPgMonPolFvAEPgResourceModel, fvRsBdPlan, fvRsBdState []FvRsBdFvAEPgResourceModel, fvRsConsPlan, fvRsConsState []FvRsConsFvAEPgResourceModel, fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvAEPgResourceModel, fvRsCustQosPolPlan, fvRsCustQosPolState []FvRsCustQosPolFvAEPgResourceModel, fvRsDomAttPlan, fvRsDomAttState []FvRsDomAttFvAEPgResourceModel, fvRsDppPolPlan, fvRsDppPolState []FvRsDppPolFvAEPgResourceModel, fvRsFcPathAttPlan, fvRsFcPathAttState []FvRsFcPathAttFvAEPgResourceModel, fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvAEPgResourceModel, fvRsNodeAttPlan, fvRsNodeAttState []FvRsNodeAttFvAEPgResourceModel, fvRsPathAttPlan, fvRsPathAttState []FvRsPathAttFvAEPgResourceModel, fvRsProtByPlan, fvRsProtByState []FvRsProtByFvAEPgResourceModel, fvRsProvPlan, fvRsProvState []FvRsProvFvAEPgResourceModel, fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvAEPgResourceModel, fvRsTrustCtrlPlan, fvRsTrustCtrlState []FvRsTrustCtrlFvAEPgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvAEPgResourceModel, tagTagPlan, tagTagState []TagTagFvAEPgResourceModel) *container.Container { +func getFvAEPgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvAEPgResourceModel, fvCrtrnPlan, fvCrtrnState []FvCrtrnFvAEPgResourceModel, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState []FvRsAEPgMonPolFvAEPgResourceModel, fvRsBdPlan, fvRsBdState []FvRsBdFvAEPgResourceModel, fvRsConsPlan, fvRsConsState []FvRsConsFvAEPgResourceModel, fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvAEPgResourceModel, fvRsCustQosPolPlan, fvRsCustQosPolState []FvRsCustQosPolFvAEPgResourceModel, fvRsDomAttPlan, fvRsDomAttState []FvRsDomAttFvAEPgResourceModel, fvRsDppPolPlan, fvRsDppPolState []FvRsDppPolFvAEPgResourceModel, fvRsFcPathAttPlan, fvRsFcPathAttState []FvRsFcPathAttFvAEPgResourceModel, fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvAEPgResourceModel, fvRsNodeAttPlan, fvRsNodeAttState []FvRsNodeAttFvAEPgResourceModel, fvRsPathAttPlan, fvRsPathAttState []FvRsPathAttFvAEPgResourceModel, fvRsProtByPlan, fvRsProtByState []FvRsProtByFvAEPgResourceModel, fvRsProvPlan, fvRsProvState []FvRsProvFvAEPgResourceModel, fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvAEPgResourceModel, fvRsTrustCtrlPlan, fvRsTrustCtrlState []FvRsTrustCtrlFvAEPgResourceModel, fvSiteAssociatedPlan, fvSiteAssociatedState []FvSiteAssociatedFvAEPgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvAEPgResourceModel, tagTagPlan, tagTagState []TagTagFvAEPgResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} @@ -5610,6 +5817,12 @@ func getFvAEPgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, cr } childPayloads = append(childPayloads, FvRsTrustCtrlchildPayloads...) + FvSiteAssociatedchildPayloads := getFvAEPgFvSiteAssociatedChildPayloads(ctx, diags, data, fvSiteAssociatedPlan, fvSiteAssociatedState) + if FvSiteAssociatedchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, FvSiteAssociatedchildPayloads...) + TagAnnotationchildPayloads := getFvAEPgTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) if TagAnnotationchildPayloads == nil { return nil diff --git a/internal/provider/resource_aci_application_epg_test.go b/internal/provider/resource_aci_application_epg_test.go index 5c253f7ba..124d9fd98 100644 --- a/internal/provider/resource_aci_application_epg_test.go +++ b/internal/provider/resource_aci_application_epg_test.go @@ -50,7 +50,6 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_application_epg.allow_test_2", "priority", "unspecified"), resource.TestCheckResourceAttr("aci_application_epg.allow_test", "useg_epg", "no"), resource.TestCheckResourceAttr("aci_application_epg.allow_test_2", "useg_epg", "no"), - resource.TestCheckResourceAttrSet("aci_application_epg.allow_test", "pc_tag"), ), }, }, @@ -107,8 +106,6 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_application_epg.allow_test_2", "priority", "unspecified"), resource.TestCheckResourceAttr("aci_application_epg.allow_test", "useg_epg", "no"), resource.TestCheckResourceAttr("aci_application_epg.allow_test_2", "useg_epg", "no"), - resource.TestCheckResourceAttrSet("aci_application_epg.allow_test", "pc_tag"), - resource.TestCheckResourceAttrSet("aci_application_epg.allow_test_2", "pc_tag"), ), }, }, @@ -137,7 +134,6 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_application_epg.test", "preferred_group_member", "exclude"), resource.TestCheckResourceAttr("aci_application_epg.test", "priority", "unspecified"), resource.TestCheckResourceAttr("aci_application_epg.test", "useg_epg", "no"), - resource.TestCheckResourceAttrSet("aci_application_epg.test", "pc_tag"), ), }, // Update with all config and verify default APIC values @@ -159,7 +155,6 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_application_epg.test", "preferred_group_member", "exclude"), resource.TestCheckResourceAttr("aci_application_epg.test", "priority", "level1"), resource.TestCheckResourceAttr("aci_application_epg.test", "useg_epg", "no"), - resource.TestCheckResourceAttrSet("aci_application_epg.test", "pc_tag"), ), }, // Update with minimum config and verify config is unchanged @@ -168,7 +163,6 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_application_epg.test", "name", "test_name"), - resource.TestCheckResourceAttrSet("aci_application_epg.test", "pc_tag"), ), }, // Update with empty strings config or default value @@ -190,7 +184,6 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_application_epg.test", "preferred_group_member", "exclude"), resource.TestCheckResourceAttr("aci_application_epg.test", "priority", "unspecified"), resource.TestCheckResourceAttr("aci_application_epg.test", "useg_epg", "no"), - resource.TestCheckResourceAttrSet("aci_application_epg.test", "pc_tag"), ), }, // Import testing @@ -218,11 +211,17 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_application_epg.test", "preferred_group_member", "exclude"), resource.TestCheckResourceAttr("aci_application_epg.test", "priority", "unspecified"), resource.TestCheckResourceAttr("aci_application_epg.test", "useg_epg", "no"), - resource.TestCheckResourceAttrSet("aci_application_epg.test", "pc_tag"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.0.key", "key_0"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.site_id", "0"), resource.TestCheckResourceAttr("aci_application_epg.test", "epg_useg_block_statement.0.annotation", "annotation_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "epg_useg_block_statement.0.description", "description_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "epg_useg_block_statement.0.match", "all"), @@ -373,12 +372,19 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { Config: testConfigFvAEPgChildrenRemoveFromConfigDependencyWithFvAp, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("aci_application_epg.test", "pc_tag"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.0.key", "key_0"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.0.site_id", "0"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.#", "1"), resource.TestCheckResourceAttr("aci_application_epg.test", "epg_useg_block_statement.0.annotation", "annotation_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "epg_useg_block_statement.0.description", "description_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "epg_useg_block_statement.0.match", "all"), @@ -540,10 +546,10 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { Config: testConfigFvAEPgChildrenRemoveOneDependencyWithFvAp, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("aci_application_epg.test", "pc_tag"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.0.key", "key_1"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.0.value", "test_value"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.#", "0"), resource.TestCheckResourceAttr("aci_application_epg.test", "epg_useg_block_statement.#", "0"), resource.TestCheckResourceAttr("aci_application_epg.test", "relation_to_application_epg_monitoring_policy.#", "0"), resource.TestCheckResourceAttr("aci_application_epg.test", "relation_to_bridge_domain.0.annotation", "annotation_1"), @@ -631,8 +637,8 @@ func TestAccResourceFvAEPgWithFvAp(t *testing.T) { Config: testConfigFvAEPgChildrenRemoveAllDependencyWithFvAp, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("aci_application_epg.test", "pc_tag"), resource.TestCheckResourceAttr("aci_application_epg.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_application_epg.test", "associated_site.#", "0"), resource.TestCheckResourceAttr("aci_application_epg.test", "epg_useg_block_statement.#", "0"), resource.TestCheckResourceAttr("aci_application_epg.test", "relation_to_application_epg_monitoring_policy.#", "0"), resource.TestCheckResourceAttr("aci_application_epg.test", "relation_to_bridge_domain.0.annotation", "annotation_1"), @@ -743,6 +749,17 @@ resource "aci_application_epg" "test" { value = "test_value" }, ] + associated_site = [ + { + annotation = "annotation_1" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" + }, + ] epg_useg_block_statement = [ { annotation = "annotation_1" @@ -990,6 +1007,7 @@ resource "aci_application_epg" "test" { value = "test_value" }, ] + associated_site = [] epg_useg_block_statement = [] relation_to_application_epg_monitoring_policy = [] relation_to_consumed_contracts = [ @@ -1105,6 +1123,7 @@ resource "aci_application_epg" "test" { parent_dn = aci_application_profile.test.id name = "test_name" annotations = [] + associated_site = [] epg_useg_block_statement = [] relation_to_application_epg_monitoring_policy = [] relation_to_consumed_contracts = [] diff --git a/internal/provider/resource_aci_associated_site.go b/internal/provider/resource_aci_associated_site.go new file mode 100644 index 000000000..1e7820bf9 --- /dev/null +++ b/internal/provider/resource_aci_associated_site.go @@ -0,0 +1,715 @@ +// 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" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &FvSiteAssociatedResource{} +var _ resource.ResourceWithImportState = &FvSiteAssociatedResource{} + +func NewFvSiteAssociatedResource() resource.Resource { + return &FvSiteAssociatedResource{} +} + +// FvSiteAssociatedResource defines the resource implementation. +type FvSiteAssociatedResource struct { + client *client.Client +} + +// FvSiteAssociatedResourceModel describes the resource data model. +type FvSiteAssociatedResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + SiteId types.String `tfsdk:"site_id"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyFvSiteAssociatedResourceModel() *FvSiteAssociatedResourceModel { + return &FvSiteAssociatedResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + SiteId: basetypes.NewStringNull(), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +// TagAnnotationFvSiteAssociatedResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationFvSiteAssociatedResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationFvSiteAssociatedResourceModel() TagAnnotationFvSiteAssociatedResourceModel { + return TagAnnotationFvSiteAssociatedResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +// TagTagFvSiteAssociatedResourceModel describes the resource data model for the children without relation ships. +type TagTagFvSiteAssociatedResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagFvSiteAssociatedResourceModel() TagTagFvSiteAssociatedResourceModel { + return TagTagFvSiteAssociatedResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +func (r *FvSiteAssociatedResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *FvSiteAssociatedResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() { + setFvSiteAssociatedId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "fvSiteAssociated", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *FvSiteAssociatedResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_associated_site") + resp.TypeName = req.ProviderTypeName + "_associated_site" + tflog.Debug(ctx, "End metadata of resource: aci_associated_site") +} + +func (r *FvSiteAssociatedResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_associated_site") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The associated_site resource for the 'fvSiteAssociated' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Associated Site object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Associated Site object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Associated Site object.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name of the Associated Site object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Associated Site object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, + }, + "owner_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "site_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `A number between 0 and 1000 to identify the primary site being associated.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_associated_site") +} + +func (r *FvSiteAssociatedResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_associated_site") + // 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_associated_site") +} + +func (r *FvSiteAssociatedResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_associated_site") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *FvSiteAssociatedResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setFvSiteAssociatedId(ctx, stateData) + } + getAndSetFvSiteAssociatedAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The fvSiteAssociated object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *FvSiteAssociatedResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if data.Id.IsUnknown() || data.Id.IsNull() { + setFvSiteAssociatedId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_associated_site with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvSiteAssociatedResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagFvSiteAssociatedResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getFvSiteAssociatedCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetFvSiteAssociatedAttributes(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_associated_site with id '%s'", data.Id.ValueString())) +} + +func (r *FvSiteAssociatedResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_associated_site") + var data *FvSiteAssociatedResourceModel + + // 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_associated_site with id '%s'", data.Id.ValueString())) + + getAndSetFvSiteAssociatedAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *FvSiteAssociatedResourceModel + 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_associated_site with id '%s'", data.Id.ValueString())) +} + +func (r *FvSiteAssociatedResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_associated_site") + var data *FvSiteAssociatedResourceModel + var stateData *FvSiteAssociatedResourceModel + + // 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_associated_site with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvSiteAssociatedResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagFvSiteAssociatedResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getFvSiteAssociatedCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetFvSiteAssociatedAttributes(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_associated_site with id '%s'", data.Id.ValueString())) +} + +func (r *FvSiteAssociatedResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_associated_site") + var data *FvSiteAssociatedResourceModel + + // 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_associated_site with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "fvSiteAssociated", data.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_associated_site with id '%s'", data.Id.ValueString())) +} + +func (r *FvSiteAssociatedResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_associated_site") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *FvSiteAssociatedResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_associated_site with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_associated_site") +} + +func getAndSetFvSiteAssociatedAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *FvSiteAssociatedResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "fvSiteAssociated,tagAnnotation,tagTag"), "GET", nil) + + *data = *getEmptyFvSiteAssociatedResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("fvSiteAssociated").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("fvSiteAssociated").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)) + setFvSiteAssociatedParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + data.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + data.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + data.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + data.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + data.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "siteId" { + data.SiteId = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationFvSiteAssociatedList := make([]TagAnnotationFvSiteAssociatedResourceModel, 0) + TagTagFvSiteAssociatedList := make([]TagTagFvSiteAssociatedResourceModel, 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" { + TagAnnotationFvSiteAssociated := getEmptyTagAnnotationFvSiteAssociatedResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationFvSiteAssociated.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationFvSiteAssociated.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationFvSiteAssociatedList = append(TagAnnotationFvSiteAssociatedList, TagAnnotationFvSiteAssociated) + } + if childClassName == "tagTag" { + TagTagFvSiteAssociated := getEmptyTagTagFvSiteAssociatedResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagFvSiteAssociated.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagFvSiteAssociated.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagFvSiteAssociatedList = append(TagTagFvSiteAssociatedList, TagTagFvSiteAssociated) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationFvSiteAssociatedList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagFvSiteAssociatedList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'fvSiteAssociated'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getFvSiteAssociatedRn(ctx context.Context, data *FvSiteAssociatedResourceModel) string { + return "stAsc" +} + +func setFvSiteAssociatedParentDn(ctx context.Context, dn string, data *FvSiteAssociatedResourceModel) { + 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 setFvSiteAssociatedId(ctx context.Context, data *FvSiteAssociatedResourceModel) { + rn := getFvSiteAssociatedRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getFvSiteAssociatedTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvSiteAssociatedResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvSiteAssociatedResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotation := range tagAnnotationPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagAnnotation.Key.IsUnknown() && !tagAnnotation.Key.IsNull() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() && !tagAnnotation.Value.IsNull() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func getFvSiteAssociatedTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvSiteAssociatedResourceModel, tagTagPlan, tagTagState []TagTagFvSiteAssociatedResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTag := range tagTagPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagTag.Key.IsUnknown() && !tagTag.Key.IsNull() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() && !tagTag.Value.IsNull() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getFvSiteAssociatedCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvSiteAssociatedResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvSiteAssociatedResourceModel, tagTagPlan, tagTagState []TagTagFvSiteAssociatedResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + + if createType && !globalAllowExistingOnCreate { + payloadMap["attributes"].(map[string]string)["status"] = "created" + } + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getFvSiteAssociatedTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getFvSiteAssociatedTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + if !data.OwnerKey.IsNull() && !data.OwnerKey.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerKey"] = data.OwnerKey.ValueString() + } + if !data.OwnerTag.IsNull() && !data.OwnerTag.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerTag"] = data.OwnerTag.ValueString() + } + if !data.SiteId.IsNull() && !data.SiteId.IsUnknown() { + payloadMap["attributes"].(map[string]string)["siteId"] = data.SiteId.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"fvSiteAssociated": payloadMap}) + if err != nil { + diags.AddError( + "Marshalling of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + jsonPayload, err := container.ParseJSON(payload) + + if err != nil { + diags.AddError( + "Construction of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + return jsonPayload +} diff --git a/internal/provider/resource_aci_associated_site_test.go b/internal/provider/resource_aci_associated_site_test.go new file mode 100644 index 000000000..53efe642a --- /dev/null +++ b/internal/provider/resource_aci_associated_site_test.go @@ -0,0 +1,611 @@ +// 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 TestAccResourceFvSiteAssociatedWithFvAEPg(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvAEPgAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "site_id", "0"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "site_id", "0"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvAEPgAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvAEPgAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "site_id", "0"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "site_id", "0"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "site_id", "0"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigFvSiteAssociatedAllDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_associated_site.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", "name_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "site_id", "0"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc(), + }, + // Update with empty strings config or default value + { + Config: testConfigFvSiteAssociatedResetDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "site_id", "0"), + ), + }, + // Import testing + { + ResourceName: "aci_associated_site.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigFvSiteAssociatedChildrenDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "site_id", "0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.1.value", "test_value"), + ), + }, + // Import testing with children + { + ResourceName: "aci_associated_site.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigFvSiteAssociatedChildrenRemoveFromConfigDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigFvSiteAssociatedChildrenRemoveOneDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigFvSiteAssociatedChildrenRemoveAllDependencyWithFvAEPg, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.#", "0"), + ), + }, + }, + }) +} +func TestAccResourceFvSiteAssociatedWithFvBD(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvBDAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "site_id", "0"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "site_id", "0"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvBDAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvBDAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.allow_test", "site_id", "0"), + resource.TestCheckResourceAttr("aci_associated_site.allow_test_2", "site_id", "0"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "site_id", "0"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigFvSiteAssociatedAllDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_associated_site.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", "name_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "site_id", "0"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigFvSiteAssociatedMinDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc(), + }, + // Update with empty strings config or default value + { + Config: testConfigFvSiteAssociatedResetDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "site_id", "0"), + ), + }, + // Import testing + { + ResourceName: "aci_associated_site.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigFvSiteAssociatedChildrenDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_associated_site.test", "description", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_associated_site.test", "site_id", "0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.1.value", "test_value"), + ), + }, + // Import testing with children + { + ResourceName: "aci_associated_site.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigFvSiteAssociatedChildrenRemoveFromConfigDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigFvSiteAssociatedChildrenRemoveOneDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigFvSiteAssociatedChildrenRemoveAllDependencyWithFvBD, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_associated_site.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_associated_site.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigFvSiteAssociatedMinDependencyWithFvAEPgAllowExisting = testConfigFvAEPgMinDependencyWithFvAp + ` +resource "aci_associated_site" "allow_test" { + parent_dn = aci_application_epg.test.id +} +resource "aci_associated_site" "allow_test_2" { + parent_dn = aci_application_epg.test.id + depends_on = [aci_associated_site.allow_test] +} +` + +const testConfigFvSiteAssociatedMinDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id +} +` + +const testConfigFvSiteAssociatedAllDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" +} +` + +const testConfigFvSiteAssociatedResetDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotation = "orchestrator:terraform" + description = "" + name = "" + name_alias = "" + owner_key = "" + owner_tag = "" + site_id = "0" +} +` +const testConfigFvSiteAssociatedChildrenDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigFvSiteAssociatedChildrenRemoveFromConfigDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id +} +` + +const testConfigFvSiteAssociatedChildrenRemoveOneDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigFvSiteAssociatedChildrenRemoveAllDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvAp + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotations = [] + tags = [] +} +` + +const testConfigFvSiteAssociatedMinDependencyWithFvBDAllowExisting = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "allow_test" { + parent_dn = aci_bridge_domain.test.id +} +resource "aci_associated_site" "allow_test_2" { + parent_dn = aci_bridge_domain.test.id + depends_on = [aci_associated_site.allow_test] +} +` + +const testConfigFvSiteAssociatedMinDependencyWithFvBD = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id +} +` + +const testConfigFvSiteAssociatedAllDependencyWithFvBD = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + site_id = "0" +} +` + +const testConfigFvSiteAssociatedResetDependencyWithFvBD = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id + annotation = "orchestrator:terraform" + description = "" + name = "" + name_alias = "" + owner_key = "" + owner_tag = "" + site_id = "0" +} +` +const testConfigFvSiteAssociatedChildrenDependencyWithFvBD = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigFvSiteAssociatedChildrenRemoveFromConfigDependencyWithFvBD = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id +} +` + +const testConfigFvSiteAssociatedChildrenRemoveOneDependencyWithFvBD = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigFvSiteAssociatedChildrenRemoveAllDependencyWithFvBD = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id + annotations = [] + tags = [] +} +` diff --git a/internal/provider/resource_aci_endpoint_security_group_test.go b/internal/provider/resource_aci_endpoint_security_group_test.go index c0b6818e8..9c54a24af 100644 --- a/internal/provider/resource_aci_endpoint_security_group_test.go +++ b/internal/provider/resource_aci_endpoint_security_group_test.go @@ -40,7 +40,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_endpoint_security_group.allow_test_2", "name_alias", ""), resource.TestCheckResourceAttr("aci_endpoint_security_group.allow_test", "preferred_group_member", "exclude"), resource.TestCheckResourceAttr("aci_endpoint_security_group.allow_test_2", "preferred_group_member", "exclude"), - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.allow_test", "pc_tag"), ), }, }, @@ -87,8 +86,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_endpoint_security_group.allow_test_2", "name_alias", ""), resource.TestCheckResourceAttr("aci_endpoint_security_group.allow_test", "preferred_group_member", "exclude"), resource.TestCheckResourceAttr("aci_endpoint_security_group.allow_test_2", "preferred_group_member", "exclude"), - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.allow_test", "pc_tag"), - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.allow_test_2", "pc_tag"), ), }, }, @@ -112,7 +109,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "match_criteria", "AtleastOne"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "name_alias", ""), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "preferred_group_member", "exclude"), - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.test", "pc_tag"), ), }, // Update with all config and verify default APIC values @@ -129,7 +125,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "match_criteria", "All"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "name_alias", "name_alias_1"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "preferred_group_member", "exclude"), - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.test", "pc_tag"), ), }, // Update with minimum config and verify config is unchanged @@ -138,7 +133,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "name", "test_name"), - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.test", "pc_tag"), ), }, // Update with empty strings config or default value @@ -155,7 +149,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "match_criteria", "AtleastOne"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "name_alias", ""), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "preferred_group_member", "exclude"), - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.test", "pc_tag"), ), }, // Import testing @@ -178,7 +171,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "match_criteria", "AtleastOne"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "name_alias", ""), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "preferred_group_member", "exclude"), - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.test", "pc_tag"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.0.key", "key_0"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.1.key", "key_1"), @@ -230,7 +222,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { Config: testConfigFvESgChildrenRemoveFromConfigDependencyWithFvAp, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.test", "pc_tag"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.0.key", "key_0"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.1.key", "key_1"), @@ -284,7 +275,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { Config: testConfigFvESgChildrenRemoveOneDependencyWithFvAp, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.test", "pc_tag"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.0.key", "key_1"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.0.value", "test_value"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.#", "1"), @@ -320,7 +310,6 @@ func TestAccResourceFvESgWithFvAp(t *testing.T) { Config: testConfigFvESgChildrenRemoveAllDependencyWithFvAp, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("aci_endpoint_security_group.test", "pc_tag"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "annotations.#", "0"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "relation_to_consumed_contracts.#", "0"), resource.TestCheckResourceAttr("aci_endpoint_security_group.test", "relation_to_contract_masters.#", "0"), diff --git a/internal/provider/resource_aci_remote_site_id_mappings.go b/internal/provider/resource_aci_remote_site_id_mappings.go new file mode 100644 index 000000000..4158e1d24 --- /dev/null +++ b/internal/provider/resource_aci_remote_site_id_mappings.go @@ -0,0 +1,761 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &FvRemoteIdResource{} +var _ resource.ResourceWithImportState = &FvRemoteIdResource{} + +func NewFvRemoteIdResource() resource.Resource { + return &FvRemoteIdResource{} +} + +// FvRemoteIdResource defines the resource implementation. +type FvRemoteIdResource struct { + client *client.Client +} + +// FvRemoteIdResourceModel describes the resource data model. +type FvRemoteIdResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + RemoteCtxPcTag types.String `tfsdk:"remote_vrf_pc_tag"` + RemotePcTag types.String `tfsdk:"remote_pc_tag"` + SiteId types.String `tfsdk:"site_id"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyFvRemoteIdResourceModel() *FvRemoteIdResourceModel { + return &FvRemoteIdResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + RemoteCtxPcTag: basetypes.NewStringNull(), + RemotePcTag: basetypes.NewStringNull(), + SiteId: basetypes.NewStringNull(), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +// TagAnnotationFvRemoteIdResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationFvRemoteIdResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationFvRemoteIdResourceModel() TagAnnotationFvRemoteIdResourceModel { + return TagAnnotationFvRemoteIdResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +// TagTagFvRemoteIdResourceModel describes the resource data model for the children without relation ships. +type TagTagFvRemoteIdResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagFvRemoteIdResourceModel() TagTagFvRemoteIdResourceModel { + return TagTagFvRemoteIdResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +type FvRemoteIdIdentifier struct { + SiteId types.String +} + +func (r *FvRemoteIdResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *FvRemoteIdResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.SiteId.IsUnknown() { + setFvRemoteIdId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "fvRemoteId", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *FvRemoteIdResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_remote_site_id_mappings") + resp.TypeName = req.ProviderTypeName + "_remote_site_id_mappings" + tflog.Debug(ctx, "End metadata of resource: aci_remote_site_id_mappings") +} + +func (r *FvRemoteIdResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_remote_site_id_mappings") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The remote_site_id_mappings resource for the 'fvRemoteId' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Remote Site Id Mappings object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Remote Site Id Mappings object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Remote Site Id Mappings object.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name of the Remote Site Id Mappings object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Remote Site Id Mappings object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, + }, + "owner_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "remote_vrf_pc_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `Remote context's *pcTag*, mapping required for default route case.`, + }, + "remote_pc_tag": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `Remote Class ID.`, + }, + "site_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `A number between 0 and 1000 to identify the remote site being associated with the primary site.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_remote_site_id_mappings") +} + +func (r *FvRemoteIdResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_remote_site_id_mappings") + // 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_remote_site_id_mappings") +} + +func (r *FvRemoteIdResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_remote_site_id_mappings") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *FvRemoteIdResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setFvRemoteIdId(ctx, stateData) + } + getAndSetFvRemoteIdAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The fvRemoteId object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *FvRemoteIdResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if data.Id.IsUnknown() || data.Id.IsNull() { + setFvRemoteIdId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_remote_site_id_mappings with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRemoteIdResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagFvRemoteIdResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getFvRemoteIdCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetFvRemoteIdAttributes(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_remote_site_id_mappings with id '%s'", data.Id.ValueString())) +} + +func (r *FvRemoteIdResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_remote_site_id_mappings") + var data *FvRemoteIdResourceModel + + // 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_remote_site_id_mappings with id '%s'", data.Id.ValueString())) + + getAndSetFvRemoteIdAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *FvRemoteIdResourceModel + 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_remote_site_id_mappings with id '%s'", data.Id.ValueString())) +} + +func (r *FvRemoteIdResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_remote_site_id_mappings") + var data *FvRemoteIdResourceModel + var stateData *FvRemoteIdResourceModel + + // 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_remote_site_id_mappings with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRemoteIdResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagFvRemoteIdResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getFvRemoteIdCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetFvRemoteIdAttributes(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_remote_site_id_mappings with id '%s'", data.Id.ValueString())) +} + +func (r *FvRemoteIdResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_remote_site_id_mappings") + var data *FvRemoteIdResourceModel + + // 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_remote_site_id_mappings with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "fvRemoteId", data.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_remote_site_id_mappings with id '%s'", data.Id.ValueString())) +} + +func (r *FvRemoteIdResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_remote_site_id_mappings") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *FvRemoteIdResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_remote_site_id_mappings with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_remote_site_id_mappings") +} + +func getAndSetFvRemoteIdAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *FvRemoteIdResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "fvRemoteId,tagAnnotation,tagTag"), "GET", nil) + + *data = *getEmptyFvRemoteIdResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("fvRemoteId").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("fvRemoteId").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)) + setFvRemoteIdParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + data.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + data.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + data.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + data.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + data.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "remoteCtxPcTag" { + data.RemoteCtxPcTag = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "remotePcTag" { + data.RemotePcTag = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "siteId" { + data.SiteId = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationFvRemoteIdList := make([]TagAnnotationFvRemoteIdResourceModel, 0) + TagTagFvRemoteIdList := make([]TagTagFvRemoteIdResourceModel, 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" { + TagAnnotationFvRemoteId := getEmptyTagAnnotationFvRemoteIdResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationFvRemoteId.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationFvRemoteId.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationFvRemoteIdList = append(TagAnnotationFvRemoteIdList, TagAnnotationFvRemoteId) + } + if childClassName == "tagTag" { + TagTagFvRemoteId := getEmptyTagTagFvRemoteIdResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagFvRemoteId.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagFvRemoteId.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagFvRemoteIdList = append(TagTagFvRemoteIdList, TagTagFvRemoteId) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationFvRemoteIdList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagFvRemoteIdList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'fvRemoteId'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getFvRemoteIdRn(ctx context.Context, data *FvRemoteIdResourceModel) string { + rn := "site-{siteId}" + for _, identifier := range []string{"siteId"} { + 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 setFvRemoteIdParentDn(ctx context.Context, dn string, data *FvRemoteIdResourceModel) { + 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 setFvRemoteIdId(ctx context.Context, data *FvRemoteIdResourceModel) { + rn := getFvRemoteIdRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getFvRemoteIdTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvRemoteIdResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRemoteIdResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotation := range tagAnnotationPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagAnnotation.Key.IsUnknown() && !tagAnnotation.Key.IsNull() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() && !tagAnnotation.Value.IsNull() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func getFvRemoteIdTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvRemoteIdResourceModel, tagTagPlan, tagTagState []TagTagFvRemoteIdResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTag := range tagTagPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagTag.Key.IsUnknown() && !tagTag.Key.IsNull() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() && !tagTag.Value.IsNull() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getFvRemoteIdCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRemoteIdResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRemoteIdResourceModel, tagTagPlan, tagTagState []TagTagFvRemoteIdResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + + if createType && !globalAllowExistingOnCreate { + payloadMap["attributes"].(map[string]string)["status"] = "created" + } + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getFvRemoteIdTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getFvRemoteIdTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + if !data.OwnerKey.IsNull() && !data.OwnerKey.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerKey"] = data.OwnerKey.ValueString() + } + if !data.OwnerTag.IsNull() && !data.OwnerTag.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerTag"] = data.OwnerTag.ValueString() + } + if !data.RemoteCtxPcTag.IsNull() && !data.RemoteCtxPcTag.IsUnknown() { + payloadMap["attributes"].(map[string]string)["remoteCtxPcTag"] = data.RemoteCtxPcTag.ValueString() + } + if !data.RemotePcTag.IsNull() && !data.RemotePcTag.IsUnknown() { + payloadMap["attributes"].(map[string]string)["remotePcTag"] = data.RemotePcTag.ValueString() + } + if !data.SiteId.IsNull() && !data.SiteId.IsUnknown() { + payloadMap["attributes"].(map[string]string)["siteId"] = data.SiteId.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"fvRemoteId": payloadMap}) + if err != nil { + diags.AddError( + "Marshalling of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + jsonPayload, err := container.ParseJSON(payload) + + if err != nil { + diags.AddError( + "Construction of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + return jsonPayload +} diff --git a/internal/provider/resource_aci_remote_site_id_mappings_test.go b/internal/provider/resource_aci_remote_site_id_mappings_test.go new file mode 100644 index 000000000..6aded739e --- /dev/null +++ b/internal/provider/resource_aci_remote_site_id_mappings_test.go @@ -0,0 +1,349 @@ +// 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 TestAccResourceFvRemoteIdWithFvSiteAssociated(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvRemoteIdMinDependencyWithFvSiteAssociatedAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "remote_vrf_pc_tag", "any"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "remote_vrf_pc_tag", "any"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "site_id", "100"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "site_id", "100"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvRemoteIdMinDependencyWithFvSiteAssociatedAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvRemoteIdMinDependencyWithFvSiteAssociatedAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "name", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "name", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "remote_vrf_pc_tag", "any"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "remote_vrf_pc_tag", "any"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test", "site_id", "100"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.allow_test_2", "site_id", "100"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvRemoteIdMinDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "description", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "any"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "100"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigFvRemoteIdAllDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name", "name_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_tag", "owner_tag_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "any"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "100"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigFvRemoteIdMinDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "100"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigFvRemoteIdResetDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "100"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "description", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "any"), + ), + }, + // Import testing + { + ResourceName: "aci_remote_site_id_mappings.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigFvRemoteIdChildrenDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_pc_tag", "16386"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "100"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "description", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "any"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.1.value", "test_value"), + ), + }, + // Import testing with children + { + ResourceName: "aci_remote_site_id_mappings.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigFvRemoteIdChildrenRemoveFromConfigDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigFvRemoteIdChildrenRemoveOneDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigFvRemoteIdChildrenRemoveAllDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigFvRemoteIdMinDependencyWithFvSiteAssociatedAllowExisting = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +resource "aci_remote_site_id_mappings" "allow_test" { + parent_dn = aci_associated_site.test.id + remote_pc_tag = "16386" + site_id = "100" +} +resource "aci_remote_site_id_mappings" "allow_test_2" { + parent_dn = aci_associated_site.test.id + remote_pc_tag = "16386" + site_id = "100" + depends_on = [aci_remote_site_id_mappings.allow_test] +} +` + +const testConfigFvRemoteIdMinDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + remote_pc_tag = "16386" + site_id = "100" +} +` + +const testConfigFvRemoteIdAllDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + annotation = "annotation" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + remote_pc_tag = "16386" + remote_vrf_pc_tag = "any" + site_id = "100" +} +` + +const testConfigFvRemoteIdResetDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + annotation = "orchestrator:terraform" + description = "" + name = "" + name_alias = "" + owner_key = "" + owner_tag = "" + remote_pc_tag = "16386" + remote_vrf_pc_tag = "any" + site_id = "100" +} +` +const testConfigFvRemoteIdChildrenDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + remote_pc_tag = "16386" + site_id = "100" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigFvRemoteIdChildrenRemoveFromConfigDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + remote_pc_tag = "16386" + site_id = "100" +} +` + +const testConfigFvRemoteIdChildrenRemoveOneDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + remote_pc_tag = "16386" + site_id = "100" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigFvRemoteIdChildrenRemoveAllDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + remote_pc_tag = "16386" + site_id = "100" + annotations = [] + tags = [] +} +` diff --git a/internal/provider/test_constants.go b/internal/provider/test_constants.go index 5383a2867..7b1513f80 100644 --- a/internal/provider/test_constants.go +++ b/internal/provider/test_constants.go @@ -95,3 +95,12 @@ resource "aci_l3out_loopback_interface_profile" "test" { addr = "1.2.3.5" } ` + +const testConfigFvBDMinDependencyWithFvTenant = testConfigFvTenantMin + ` +resource "aci_bridge_domain" "test" { + tenant_dn = aci_tenant.test.id + name = "test_bd" +} +` + +const testConfigFvBDMin = testConfigFvBDMinDependencyWithFvTenant