diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index 8a28ab9f1..a0a80d555 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -55,13 +55,17 @@ data "aci_annotation" "example_application_epg" { * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - Too many parent DNs to display, see model documentation for all possible parents of [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview). - [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_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/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)) + - [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)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/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)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) @@ -70,10 +74,6 @@ data "aci_annotation" "example_application_epg" { - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/data-sources/associated_site.md b/docs/data-sources/associated_site.md new file mode 100644 index 000000000..780aa576d --- /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 Associated Site +--- + +# aci_associated_site # + +Data source for 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 distinquised 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..04db972f8 --- /dev/null +++ b/docs/data-sources/remote_site_id_mappings.md @@ -0,0 +1,66 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "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 Remote Site Id Mappings +--- + +# aci_remote_site_id_mappings # + +Data source for 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 Format: `uni/tn-{name}/ctx-{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 = "0" +} + +``` + +## 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 55e36e99e..21373c6eb 100644 --- a/docs/data-sources/tag.md +++ b/docs/data-sources/tag.md @@ -55,13 +55,17 @@ data "aci_tag" "example_application_epg" { * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - Too many parent DNs to display, see model documentation for all possible parents of [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview). - [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_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/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)) + - [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)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/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)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) @@ -70,10 +74,6 @@ data "aci_tag" "example_application_epg" { - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/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 85e946ee4..02b4ee51f 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -64,13 +64,17 @@ All examples for the Annotation resource can be found in the [examples](https:// * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - Too many parent DNs to display, see model documentation for all possible parents of [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview). - [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_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/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)) + - [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)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/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)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) @@ -79,10 +83,6 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/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/associated_site.md b/docs/resources/associated_site.md new file mode 100644 index 000000000..05373a126 --- /dev/null +++ b/docs/resources/associated_site.md @@ -0,0 +1,171 @@ +--- +# 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 + + + +## 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" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + 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" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + 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 distinquised 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}/ctx-{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}/ctx-{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..3344d4bc0 --- /dev/null +++ b/docs/resources/remote_site_id_mappings.md @@ -0,0 +1,134 @@ +--- +# 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 + + + +## 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 Format: `uni/tn-{name}/ctx-{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 + site_id = "0" +} + +``` +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" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + remote_vrf_pc_tag = "0" + remote_pc_tag = "0" + site_id = "0" + 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)) +* `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. + - Valid Values: `any`. +* `remote_pc_tag` (remotePcTag) - (string) Remote Class ID. + - Valid Values: `any`. + +* `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 d879337bc..f1e047c65 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -64,13 +64,17 @@ All examples for the Tag resource can be found in the [examples](https://github. * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - Too many parent DNs to display, see model documentation for all possible parents of [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview). - [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_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/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)) + - [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)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/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)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) @@ -79,10 +83,6 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/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..6edb084d5 --- /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 = "0" +} 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_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..65e585a87 --- /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" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + 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" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + 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..34cbd23eb --- /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" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + remote_vrf_pc_tag = "0" + remote_pc_tag = "0" + site_id = "0" + 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..8aecb5ea3 --- /dev/null +++ b/examples/resources/aci_remote_site_id_mappings/resource.tf @@ -0,0 +1,5 @@ + +resource "aci_remote_site_id_mappings" "example_associated_site" { + parent_dn = aci_associated_site.example.id + site_id = "0" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index a28175ee5..733aa5f22 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -162,6 +162,32 @@ fvFBRMember: resource_notes: - "This resource should not be used in combination with the `vrf_fallback_route_group` nested attributes of other resources for the same object. 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" + dn_formats: + - "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" + - "uni/tn-{name}/mscGraphXlateCont/epgDefXlate-[{epgDefDn}]/stAsc" + +fvRemoteId: + ui_locations: + - "Not shown in UI" + sub_category: "Multi-Site" + dn_formats: + - "uni/tn-{name}/ctx-{name}/stAsc/site-{siteId}" + l3extRsOutToFBRGroup: resource_name: "relation_to_fallback_route_group" ui_locations: diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 16d746eb3..a03dea311 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -192,6 +192,56 @@ fvFBRMember: parent_dn: "aci_vrf_fallback_route_group.test.id" class_in_parent: false +fvSiteAssociated: + overwrites: + siteId: "site_id" + documentation: + siteId: "A number between 0 and 1000 to identify the primary site being associated" + test_values: + all: + site_id: "0" + default: + site_id: "0" + resource_required: + site_id: "0" + resource_required: + siteId: "0" + default_values: + siteId: "0" + parents: + - class_name: "fvCtx" + parent_dependency: "fvTenant" + parent_dn: "aci_vrf.test.id" + - class_name: "fvAEPg" + parent_dependency: "fvAp" + parent_dn: "aci_application_epg.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" + test_values: + all: + site_id: "0" + remote_vrf_pc_tag: "0" + remote_pc_tag: "0" + default: + site_id: "0" + remote_vrf_pc_tag: "0" + remote_pc_tag: "0" + resource_required: + site_id: "0" + resource_required: + siteId: "0" + default_values: + siteId: "0" + parents: + - class_name: "fvSiteAssociated" + parent_dependency: "fvCtx" + 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 ba1228518..011dfe404 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -908,8 +908,6 @@ func (m *Model) SetClassInclude() { for key, value := range classDetails.(map[interface{}]interface{}) { if key.(string) == "include" { m.Include = value.(bool) - } else { - m.Include = false } } } @@ -1223,14 +1221,38 @@ Precendence order is: 2. global level from properties.yaml */ func requiredProperty(propertyName, classPkgName string, definitions Definitions) bool { + // precedenceList := []string{classPkgName, "global"} + // for _, precedence := range precedenceList { + // 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 + // } + // } + // } + // } + // } + // } + // return false precedenceList := []string{classPkgName, "global"} for _, precedence := range precedenceList { 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/testvars.yaml.tmpl b/gen/templates/testvars.yaml.tmpl index fc638fd13..5baf2c188 100644 --- a/gen/templates/testvars.yaml.tmpl +++ b/gen/templates/testvars.yaml.tmpl @@ -10,7 +10,7 @@ default: {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: "{{overwritePropertyValue .PkgName $overwritePropertyName "" "default" 0 $.Definitions}}" {{- end}} {{- end}} - +{{ if .HasNaming }} datasource_non_existing: {{- range .Properties}}{{$testValue := createNonExistingValue .SnakeCaseName}}{{$overwritePropertyName := overwriteProperty .PkgName .SnakeCaseName $.Definitions}} {{- if eq .SnakeCaseName "t_dn" }} @@ -37,6 +37,7 @@ resource_required: {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: "{{overwritePropertyValue .PkgName $overwritePropertyName $testValue "resource_required" 0 $.Definitions}}" {{- end}} {{- end}} +{{- end}} all: {{- range .Properties}}{{$overwritePropertyName := overwriteProperty .PkgName .SnakeCaseName $.Definitions}} diff --git a/gen/testvars/fvRemoteId.yaml b/gen/testvars/fvRemoteId.yaml new file mode 100644 index 000000000..182c8be79 --- /dev/null +++ b/gen/testvars/fvRemoteId.yaml @@ -0,0 +1,55 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + description: "" + name: "" + name_alias: "" + owner_key: "" + owner_tag: "" + remote_vrf_pc_tag: "0" + remote_pc_tag: "0" + site_id: "0" + +datasource_non_existing: + site_id: "non_existing_site_id" + +datasource_required: + site_id: "test_site_id" + +resource_required: + site_id: "0" + +all: + annotation: "annotation" + description: "description" + name: "name" + name_alias: "name_alias" + owner_key: "owner_key" + owner_tag: "owner_tag" + remote_vrf_pc_tag: "0" + remote_pc_tag: "0" + site_id: "0" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + +parents: + - class_name: "fvSiteAssociated" + parent_dependency: "fvCtx" + 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..8d2239336 --- /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" + name: "name" + name_alias: "name_alias" + owner_key: "owner_key" + owner_tag: "owner_tag" + site_id: "0" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + +parents: + - class_name: "fvAEPg" + parent_dependency: "fvTenant" + 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/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..16032627b --- /dev/null +++ b/internal/provider/data_source_aci_associated_site_test.go @@ -0,0 +1,92 @@ +// 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 = testConfigFvSiteAssociatedMinDependencyWithFvAEPg + ` +data "aci_associated_site" "test_non_existing" { + parent_dn = aci_application_epg.test.id + depends_on = [aci_associated_site.test] +} +` +const testConfigFvSiteAssociatedDataSourceDependencyWithFvBD = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +data "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id + depends_on = [aci_associated_site.test] +} +` + +const testConfigFvSiteAssociatedNotExistingFvBD = testConfigFvSiteAssociatedMinDependencyWithFvBD + ` +data "aci_associated_site" "test_non_existing" { + parent_dn = aci_bridge_domain.test.id + depends_on = [aci_associated_site.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..07bfa8e6c --- /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", "test_site_id"), + 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", "0"), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "0"), + resource.TestCheckResourceAttr("data.aci_remote_site_id_mappings.test", "site_id", "0"), + ), + }, + { + 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 = "test_site_id" + 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 = "non_existing_site_id" + depends_on = [aci_remote_site_id_mappings.test] +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index ddca36000..21aa4f6f3 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" + // temporary unused until muxing is removed // "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -200,6 +201,8 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvEpMacTagResource, NewFvFBRGroupResource, NewFvFBRMemberResource, + NewFvRemoteIdResource, + NewFvSiteAssociatedResource, NewL3extConsLblResource, NewL3extProvLblResource, NewL3extRsOutToFBRGroupResource, @@ -225,6 +228,8 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvEpMacTagDataSource, NewFvFBRGroupDataSource, NewFvFBRMemberDataSource, + NewFvRemoteIdDataSource, + NewFvSiteAssociatedDataSource, NewL3extConsLblDataSource, NewL3extProvLblDataSource, NewL3extRsOutToFBRGroupDataSource, diff --git a/internal/provider/resource_aci_associated_site.go b/internal/provider/resource_aci_associated_site.go new file mode 100644 index 000000000..0953f2ebe --- /dev/null +++ b/internal/provider/resource_aci_associated_site.go @@ -0,0 +1,625 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &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"` +} + +// 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"` +} + +// 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 (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(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Associated Site object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the Associated Site object.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name of the Associated Site object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the Associated Site object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, + }, + "owner_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "site_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + 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)...) + setFvSiteAssociatedId(ctx, stateData) + getAndSetFvSiteAssociatedAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *FvSiteAssociatedResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + 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, 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, 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) + + 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 := TagAnnotationFvSiteAssociatedResourceModel{} + 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 := TagTagFvSiteAssociatedResourceModel{} + 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() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func 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() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getFvSiteAssociatedCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvSiteAssociatedResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvSiteAssociatedResourceModel, tagTagPlan, tagTagState []TagTagFvSiteAssociatedResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + 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..407e98d45 --- /dev/null +++ b/internal/provider/resource_aci_associated_site_test.go @@ -0,0 +1,502 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func 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: 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"), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", "name"), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", "owner_tag"), + 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, + 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 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", "value_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", "value_2"), + ), + }, + // Import testing with children + { + ResourceName: "aci_associated_site.test", + ImportState: true, + ImportStateVerify: true, + 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", "value_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", "value_2"), + ), + }, + // 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", "value_2"), + 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", "value_2"), + 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", "value_2"), + 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", "value_2"), + 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: 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"), + resource.TestCheckResourceAttr("aci_associated_site.test", "name", "name"), + resource.TestCheckResourceAttr("aci_associated_site.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("aci_associated_site.test", "owner_tag", "owner_tag"), + 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, + 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 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", "value_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", "value_2"), + ), + }, + // Import testing with children + { + ResourceName: "aci_associated_site.test", + ImportState: true, + ImportStateVerify: true, + 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", "value_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", "value_2"), + ), + }, + // 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", "value_2"), + 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", "value_2"), + 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", "value_2"), + 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", "value_2"), + 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 testConfigFvSiteAssociatedMinDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id +} +` + +const testConfigFvSiteAssociatedAllDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotation = "annotation" + description = "description" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + site_id = "0" +} +` + +const testConfigFvSiteAssociatedResetDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvTenant + ` +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 = testConfigFvAEPgMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigFvSiteAssociatedChildrenRemoveFromConfigDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id +} +` + +const testConfigFvSiteAssociatedChildrenRemoveOneDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigFvSiteAssociatedChildrenRemoveAllDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_application_epg.test.id + annotations = [] + tags = [] +} +` + +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" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + 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 = "value_2" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +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 = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigFvSiteAssociatedChildrenRemoveAllDependencyWithFvBD = testConfigFvBDMinDependencyWithFvTenant + ` +resource "aci_associated_site" "test" { + parent_dn = aci_bridge_domain.test.id + annotations = [] + tags = [] +} +` 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..e7057a093 --- /dev/null +++ b/internal/provider/resource_aci_remote_site_id_mappings.go @@ -0,0 +1,676 @@ +// 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-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &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"` +} + +// 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"` +} + +// 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"` +} + +type FvRemoteIdIdentifier struct { + SiteId types.String +} + +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(), + }, + 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(), + }, + MarkdownDescription: `The description of the Remote Site Id Mappings object.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name of the Remote Site Id Mappings object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the Remote Site Id Mappings object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, + }, + "owner_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "remote_vrf_pc_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("any"), + }, + MarkdownDescription: `Remote context's *pcTag*, mapping required for default route case.`, + }, + "remote_pc_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("any"), + }, + MarkdownDescription: `Remote Class ID.`, + }, + "site_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + 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)...) + setFvRemoteIdId(ctx, stateData) + getAndSetFvRemoteIdAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *FvRemoteIdResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + 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, 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, 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) + + 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 := TagAnnotationFvRemoteIdResourceModel{} + 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 := TagTagFvRemoteIdResourceModel{} + 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() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func 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() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getFvRemoteIdCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvRemoteIdResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRemoteIdResourceModel, tagTagPlan, tagTagState []TagTagFvRemoteIdResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + 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..ed9a2040a --- /dev/null +++ b/internal/provider/resource_aci_remote_site_id_mappings_test.go @@ -0,0 +1,280 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func 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: 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", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "0"), + ), + }, + // 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"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name", "name"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "owner_tag", "owner_tag"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_pc_tag", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "0"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigFvRemoteIdMinDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "0"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigFvRemoteIdResetDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "0"), + 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", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "0"), + ), + }, + // Import testing + { + ResourceName: "aci_remote_site_id_mappings.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "0"), + 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", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "0"), + ), + }, + // Update with children + { + Config: testConfigFvRemoteIdChildrenDependencyWithFvSiteAssociated, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "0"), + 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", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "0"), + 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", "value_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", "value_2"), + ), + }, + // Import testing with children + { + ResourceName: "aci_remote_site_id_mappings.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "site_id", "0"), + 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", "0"), + resource.TestCheckResourceAttr("aci_remote_site_id_mappings.test", "remote_vrf_pc_tag", "0"), + 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", "value_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", "value_2"), + ), + }, + // 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", "value_2"), + 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", "value_2"), + 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", "value_2"), + 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", "value_2"), + 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 testConfigFvRemoteIdMinDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvCtx + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + site_id = "0" +} +` + +const testConfigFvRemoteIdAllDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvCtx + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + annotation = "annotation" + description = "description" + name = "name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + remote_pc_tag = "0" + remote_vrf_pc_tag = "0" + site_id = "0" +} +` + +const testConfigFvRemoteIdResetDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvCtx + ` +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 = "0" + remote_vrf_pc_tag = "0" + site_id = "0" +} +` +const testConfigFvRemoteIdChildrenDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvCtx + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + site_id = "0" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigFvRemoteIdChildrenRemoveFromConfigDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvCtx + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + site_id = "0" +} +` + +const testConfigFvRemoteIdChildrenRemoveOneDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvCtx + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + site_id = "0" + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigFvRemoteIdChildrenRemoveAllDependencyWithFvSiteAssociated = testConfigFvSiteAssociatedMinDependencyWithFvCtx + ` +resource "aci_remote_site_id_mappings" "test" { + parent_dn = aci_associated_site.test.id + site_id = "0" + annotations = [] + tags = [] +} +` diff --git a/internal/provider/test_constants.go b/internal/provider/test_constants.go index e44ac5da0..f4ebc44bd 100644 --- a/internal/provider/test_constants.go +++ b/internal/provider/test_constants.go @@ -51,6 +51,7 @@ resource "aci_vrf" "test" { name = "test_vrf" } ` +const testConfigFvAEPgMinDependencyWithFvTenant = testConfigFvAEPgMin const testConfigFvTenantInfraMin = ` data "aci_tenant" "test" {