diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index eb9424eeb..85cb13f16 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -53,6 +53,7 @@ data "aci_annotation" "example_application_epg" { ### Required ### * `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_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)) @@ -61,8 +62,10 @@ data "aci_annotation" "example_application_epg" { - [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_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_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)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) + - [aci_relation_to_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_instance_profile) ([l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview)) - [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)) @@ -71,9 +74,6 @@ data "aci_annotation" "example_application_epg" { - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) - - Too many classes to display, see model documentation for all possible classes of [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview). * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/data-sources/l3out_consumer_label.md b/docs/data-sources/l3out_consumer_label.md index d9031ba6e..1bfc67df1 100644 --- a/docs/data-sources/l3out_consumer_label.md +++ b/docs/data-sources/l3out_consumer_label.md @@ -58,6 +58,10 @@ data "aci_l3out_consumer_label" "example_l3_outside" { * `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. * `tag` (tag) - (string) Specifies the color of a policy label. +* `relation_to_instance_profiles` - (list) A list of Relation To Instance Profiles (ACI object [l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview)) pointing to External Network Instance Profile (ACI Object [l3extInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extInstP/overview)). This attribute is supported in ACI versions: 5.0(1k) and later. + * `annotation` (annotation) - (string) The annotation of the Relation To Instance Profile object. + * `target_dn` (tDn) - (string) The distinguished name of the External Network Instance Profile object. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/relation_to_instance_profile.md b/docs/data-sources/relation_to_instance_profile.md new file mode 100644 index 000000000..1b488e180 --- /dev/null +++ b/docs/data-sources/relation_to_instance_profile.md @@ -0,0 +1,62 @@ +--- +# 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: "L3Out" +layout: "aci" +page_title: "ACI: aci_relation_to_instance_profile" +sidebar_current: "docs-aci-data-source-aci_relation_to_instance_profile" +description: |- + Data source for Relation To Instance Profile +--- + +# aci_relation_to_instance_profile # + +Data source for Relation To Instance Profile + +## API Information ## + +* Class: [l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview) + +* Supported in ACI versions: 5.0(1k) and later. + +* Distinguished Name Format: `uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]` + +## GUI Information ## + +* Location: `Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label` + +## Example Usage ## + +```hcl + +data "aci_relation_to_instance_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + target_dn = aci_external_network_instance_profile.test.id +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [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)) + - The distinquised name (DN) of classes below can be used but currently there is no available resource for it: + - [l3extConsLblDef](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLblDef/overview) + +* `target_dn` (tDn) - (string) The distinguished name of the External Network Instance Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation To Instance Profile object. +* `annotation` (annotation) - (string) The annotation of the Relation To Instance Profile object. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/tag.md b/docs/data-sources/tag.md index 17b078e92..adabe05d3 100644 --- a/docs/data-sources/tag.md +++ b/docs/data-sources/tag.md @@ -53,6 +53,7 @@ data "aci_tag" "example_application_epg" { ### Required ### * `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_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)) @@ -61,8 +62,10 @@ data "aci_tag" "example_application_epg" { - [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_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_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)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) + - [aci_relation_to_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_instance_profile) ([l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview)) - [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)) @@ -71,9 +74,6 @@ data "aci_tag" "example_application_epg" { - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) - - Too many classes to display, see model documentation for all possible classes of [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/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 9f4be718b..40d863998 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -62,6 +62,7 @@ All examples for the Annotation resource can be found in the [examples](https:// ### Required ### * `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_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)) @@ -70,8 +71,10 @@ All examples for the Annotation resource can be found in the [examples](https:// - [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_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_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)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) + - [aci_relation_to_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_instance_profile) ([l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview)) - [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)) @@ -80,9 +83,6 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) - - Too many classes to display, see model documentation for all possible classes of [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/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/l3out_consumer_label.md b/docs/resources/l3out_consumer_label.md index 1cb74b2f5..00c6e225b 100644 --- a/docs/resources/l3out_consumer_label.md +++ b/docs/resources/l3out_consumer_label.md @@ -58,6 +58,12 @@ resource "aci_l3out_consumer_label" "full_example_l3_outside" { owner_key = "owner_key" owner_tag = "owner_tag" tag = "lemon-chiffon" + relation_to_instance_profiles = [ + { + annotation = "annotation_1" + target_dn = aci_external_network_instance_profile.test.id + } + ] annotations = [ { key = "key_0" @@ -102,6 +108,17 @@ All examples for the L3out Consumer Label resource can be found in the [examples * `tag` (tag) - (string) Specifies the color of a policy label. - Valid Values: `alice-blue`, `antique-white`, `aqua`, `aquamarine`, `azure`, `beige`, `bisque`, `black`, `blanched-almond`, `blue`, `blue-violet`, `brown`, `burlywood`, `cadet-blue`, `chartreuse`, `chocolate`, `coral`, `cornflower-blue`, `cornsilk`, `crimson`, `cyan`, `dark-blue`, `dark-cyan`, `dark-goldenrod`, `dark-gray`, `dark-green`, `dark-khaki`, `dark-magenta`, `dark-olive-green`, `dark-orange`, `dark-orchid`, `dark-red`, `dark-salmon`, `dark-sea-green`, `dark-slate-blue`, `dark-slate-gray`, `dark-turquoise`, `dark-violet`, `deep-pink`, `deep-sky-blue`, `dim-gray`, `dodger-blue`, `fire-brick`, `floral-white`, `forest-green`, `fuchsia`, `gainsboro`, `ghost-white`, `gold`, `goldenrod`, `gray`, `green`, `green-yellow`, `honeydew`, `hot-pink`, `indian-red`, `indigo`, `ivory`, `khaki`, `lavender`, `lavender-blush`, `lawn-green`, `lemon-chiffon`, `light-blue`, `light-coral`, `light-cyan`, `light-goldenrod-yellow`, `light-gray`, `light-green`, `light-pink`, `light-salmon`, `light-sea-green`, `light-sky-blue`, `light-slate-gray`, `light-steel-blue`, `light-yellow`, `lime`, `lime-green`, `linen`, `magenta`, `maroon`, `medium-aquamarine`, `medium-blue`, `medium-orchid`, `medium-purple`, `medium-sea-green`, `medium-slate-blue`, `medium-spring-green`, `medium-turquoise`, `medium-violet-red`, `midnight-blue`, `mint-cream`, `misty-rose`, `moccasin`, `navajo-white`, `navy`, `old-lace`, `olive`, `olive-drab`, `orange`, `orange-red`, `orchid`, `pale-goldenrod`, `pale-green`, `pale-turquoise`, `pale-violet-red`, `papaya-whip`, `peachpuff`, `peru`, `pink`, `plum`, `powder-blue`, `purple`, `red`, `rosy-brown`, `royal-blue`, `saddle-brown`, `salmon`, `sandy-brown`, `sea-green`, `seashell`, `sienna`, `silver`, `sky-blue`, `slate-blue`, `slate-gray`, `snow`, `spring-green`, `steel-blue`, `tan`, `teal`, `thistle`, `tomato`, `turquoise`, `violet`, `wheat`, `white`, `white-smoke`, `yellow`, `yellow-green`. +* `relation_to_instance_profiles` - (list) A list of Relation To Instance Profiles (ACI object [l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview)) pointing to External Network Instance Profile (ACI Object [l3extInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extInstP/overview)) which can be configured using the [aci_external_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_network_instance_profile) resource. This attribute is supported in ACI versions: 5.0(1k) and later. + + #### Required #### + + * `target_dn` (tDn) - (string) The distinguished name of the External Network Instance Profile object. + + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation To Instance Profile object. + - Default: `orchestrator:terraform` + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. #### Required #### diff --git a/docs/resources/relation_to_instance_profile.md b/docs/resources/relation_to_instance_profile.md new file mode 100644 index 000000000..c4bde536d --- /dev/null +++ b/docs/resources/relation_to_instance_profile.md @@ -0,0 +1,122 @@ +--- +# 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: "L3Out" +layout: "aci" +page_title: "ACI: aci_relation_to_instance_profile" +sidebar_current: "docs-aci-resource-aci_relation_to_instance_profile" +description: |- + Manages ACI Relation To Instance Profile +--- + +# aci_relation_to_instance_profile # + +Manages ACI Relation To Instance Profile + + -> This resource should not be used in combination with the `l3out_consumer_label` nested attributes of other resources for the same object. Doing so will result in unexpected behaviour. + + +## API Information ## + +* Class: [l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview) + +* Supported in ACI versions: 5.0(1k) and later. + +* Distinguished Name Format: `uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]` + +## GUI Information ## + +* Location: `Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label` + +## Example Usage ## + +The configuration snippet below creates a Relation To Instance Profile with only required attributes. + +```hcl + +resource "aci_relation_to_instance_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + target_dn = aci_external_network_instance_profile.test.id +} + +``` +The configuration snippet below shows all possible attributes of the Relation To Instance Profile. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_relation_to_instance_profile" "full_example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + annotation = "annotation" + target_dn = aci_external_network_instance_profile.test.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Relation To Instance Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_relation_to_instance_profile) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [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)) + - The distinquised name (DN) of classes below can be used but currently there is no available resource for it: + - [l3extConsLblDef](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLblDef/overview) + +* `target_dn` (tDn) - (string) The distinguished name of the External Network Instance Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation To Instance Profile object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Relation To Instance Profile object. + - Default: `orchestrator:terraform` + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +## Importing + +An existing Relation To Instance Profile can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: + +``` +terraform import aci_relation_to_instance_profile.example_l3out_consumer_label uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}] +``` + +Starting in Terraform version 1.5, an existing Relation To Instance Profile can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]" + to = aci_relation_to_instance_profile.example_l3out_consumer_label +} +``` diff --git a/docs/resources/tag.md b/docs/resources/tag.md index 1cf431ae8..437d5c66e 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -62,6 +62,7 @@ All examples for the Tag resource can be found in the [examples](https://github. ### Required ### * `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_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)) @@ -70,8 +71,10 @@ All examples for the Tag resource can be found in the [examples](https://github. - [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_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_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)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) + - [aci_relation_to_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_instance_profile) ([l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview)) - [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)) @@ -80,9 +83,6 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) - - Too many classes to display, see model documentation for all possible classes of [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/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_relation_to_instance_profile/data-source.tf b/examples/data-sources/aci_relation_to_instance_profile/data-source.tf new file mode 100644 index 000000000..c30d5f722 --- /dev/null +++ b/examples/data-sources/aci_relation_to_instance_profile/data-source.tf @@ -0,0 +1,5 @@ + +data "aci_relation_to_instance_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + target_dn = aci_external_network_instance_profile.test.id +} diff --git a/examples/data-sources/aci_relation_to_instance_profile/provider.tf b/examples/data-sources/aci_relation_to_instance_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_relation_to_instance_profile/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_l3out_consumer_label/resource-all-attributes.tf b/examples/resources/aci_l3out_consumer_label/resource-all-attributes.tf index 09a5c84eb..a73185158 100644 --- a/examples/resources/aci_l3out_consumer_label/resource-all-attributes.tf +++ b/examples/resources/aci_l3out_consumer_label/resource-all-attributes.tf @@ -9,6 +9,12 @@ resource "aci_l3out_consumer_label" "full_example_l3_outside" { owner_key = "owner_key" owner_tag = "owner_tag" tag = "lemon-chiffon" + relation_to_instance_profiles = [ + { + annotation = "annotation_1" + target_dn = aci_external_network_instance_profile.test.id + } + ] annotations = [ { key = "key_0" diff --git a/examples/resources/aci_relation_to_instance_profile/provider.tf b/examples/resources/aci_relation_to_instance_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_relation_to_instance_profile/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_relation_to_instance_profile/resource-all-attributes.tf b/examples/resources/aci_relation_to_instance_profile/resource-all-attributes.tf new file mode 100644 index 000000000..cf4220808 --- /dev/null +++ b/examples/resources/aci_relation_to_instance_profile/resource-all-attributes.tf @@ -0,0 +1,18 @@ + +resource "aci_relation_to_instance_profile" "full_example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + annotation = "annotation" + target_dn = aci_external_network_instance_profile.test.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_relation_to_instance_profile/resource.tf b/examples/resources/aci_relation_to_instance_profile/resource.tf new file mode 100644 index 000000000..718509d59 --- /dev/null +++ b/examples/resources/aci_relation_to_instance_profile/resource.tf @@ -0,0 +1,5 @@ + +resource "aci_relation_to_instance_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + target_dn = aci_external_network_instance_profile.test.id +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index 462ca67ca..d4bc12299 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -70,6 +70,9 @@ mgmtRsOoBCons: l3extOut: resource_name: "l3_outside" +l3extInstP: + resource_name: "external_network_instance_profile" + l3extConsLbl: resource_name: "l3out_consumer_label" ui_locations: @@ -164,3 +167,15 @@ l3extProvLbl: ui_locations: - "Tenants (infra) -> Networking -> L3Outs -> Policy -> Main -> Provider Label" sub_category: "L3Out" + +l3extRsLblToInstP: + resource_name: "relation_to_instance_profile" + ui_locations: + - "Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label" + sub_category: "L3Out" + dn_formats: + - "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]" + example_classes: + - "l3extConsLbl" + resource_notes: + - "This resource should not be used in combination with the `l3out_consumer_label` nested attributes of other resources for the same object. Doing so will result in unexpected behaviour." diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index ec4edb1d2..b7c6e2435 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -233,3 +233,28 @@ l3extProvLbl: parent_dependency_name: "infra" parent_dn: "aci_l3_outside.test.id" class_in_parent: false + +l3extRsLblToInstP: + documentation: + tDn: "The distinguished name of the External Network Instance Profile object." + test_values: + resource_required: + target_dn: aci_external_network_instance_profile.test.id + datasource_required: + target_dn: aci_external_network_instance_profile.test.id + datasource_non_existing: + target_dn: aci_external_network_instance_profile.test.id + test_values_for_parent: + - target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP1" + - target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2" + parents: + - class_name: "l3extOut" + parent_dependency: "fvTenant" + parent_dn: "aci_l3_outside.test.id" + class_in_parent: false + targets: + - class_name: "l3extInstP" + parent_dependency: "l3extOut" + parent_dependency_dn: "aci_external_network_instance_profile.test.id" + parent_dn: "aci_l3_outside.test.id" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP" diff --git a/gen/generator.go b/gen/generator.go index 6f669327e..d853d1271 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -80,28 +80,29 @@ const pubhupDevnetBaseUrl = "https://pubhub.devnetcloud.com/media/model-doc-late // The map contains a key which is the name of the function used in the template and a value which is the function itself // The functions itself are defined in the current file var templateFuncs = template.FuncMap{ - "snakeCase": Underscore, - "validatorString": ValidatorString, - "containsString": ContainsString, - "listToString": ListToString, - "overwriteProperty": GetOverwriteAttributeName, - "overwritePropertyValue": GetOverwriteAttributeValue, - "createTestValue": func(val string) string { return fmt.Sprintf("test_%s", val) }, - "createNonExistingValue": func(val string) string { return fmt.Sprintf("non_existing_%s", val) }, - "getParentTestDependencies": GetParentTestDependencies, - "getTargetTestDependencies": GetTargetTestDependencies, - "fromInterfacesToString": FromInterfacesToString, - "containsNoneAttributeValue": ContainsNoneAttributeValue, - "definedInMap": DefinedInMap, - "add": func(val1, val2 int) int { return val1 + val2 }, - "lookupTestValue": LookupTestValue, - "lookupChildTestValue": LookupChildTestValue, - "createParentDnValue": CreateParentDnValue, - "getResourceName": GetResourceName, - "getResourceNameAsDescription": GetResourceNameAsDescription, - "capitalize": Capitalize, - "getTestConfigVariableName": GetTestConfigVariableName, - "getDevnetDocForClass": GetDevnetDocForClass, + "snakeCase": Underscore, + "validatorString": ValidatorString, + "containsString": ContainsString, + "listToString": ListToString, + "overwriteProperty": GetOverwriteAttributeName, + "overwritePropertyValue": GetOverwriteAttributeValue, + "createTestValue": func(val string) string { return fmt.Sprintf("test_%s", val) }, + "createNonExistingValue": func(val string) string { return fmt.Sprintf("non_existing_%s", val) }, + "getParentTestDependencies": GetParentTestDependencies, + "getTargetTestDependencies": GetTargetTestDependencies, + "fromInterfacesToString": FromInterfacesToString, + "containsNoneAttributeValue": ContainsNoneAttributeValue, + "definedInMap": DefinedInMap, + "add": func(val1, val2 int) int { return val1 + val2 }, + "lookupTestValue": LookupTestValue, + "lookupChildTestValue": LookupChildTestValue, + "lookupChildResourceRequiredTestValue": LookupChildResourceRequiredTestValue, + "createParentDnValue": CreateParentDnValue, + "getResourceName": GetResourceName, + "getResourceNameAsDescription": GetResourceNameAsDescription, + "capitalize": Capitalize, + "getTestConfigVariableName": GetTestConfigVariableName, + "getDevnetDocForClass": GetDevnetDocForClass, } // Global variables used for unique resource name setting based on label from meta data @@ -203,6 +204,28 @@ func LookupChildTestValue(classPkgName, childResourceName, propertyName string, return "test_value_for_child" } +// Retrieves resource_required attribute value from the properties.yaml file of the class. +// This is used to lookup the target dn resource reference value when the resource is not part of the internal provider +func LookupChildResourceRequiredTestValue(classPkgName, propertyName string, definitions Definitions) string { + if classDetails, ok := definitions.Properties[classPkgName]; ok { + for key, value := range classDetails.(map[interface{}]interface{}) { + if key.(string) == "test_values" { + for test_type, test_type_values := range value.(map[interface{}]interface{}) { + if test_type.(string) == "resource_required" { + for k, v := range test_type_values.(map[interface{}]interface{}) { + if k.(string) == propertyName { + return v.(string) + } + } + } + + } + } + } + } + return "" +} + func ContainsNoneAttributeValue(values []string) bool { if slices.Contains(values, "none") { return true @@ -1493,7 +1516,7 @@ func setDocumentationData(m *Model, definitions Definitions) { } } - if len(resourcesNotFound) != 0 { + if len(resourcesNotFound) != 0 && len(resourcesFound) < docsParentDnAmount { if len(resourcesNotFound) > docsParentDnAmount-len(resourcesFound) { // TODO catch default classes and add to documentation resourcesNotFound = resourcesNotFound[0:(docsParentDnAmount - len(resourcesFound))] diff --git a/gen/meta/l3extRsLblToInstP.json b/gen/meta/l3extRsLblToInstP.json new file mode 100644 index 000000000..bb9911753 --- /dev/null +++ b/gen/meta/l3extRsLblToInstP.json @@ -0,0 +1,913 @@ +{ + "l3ext:RsLblToInstP": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Inst": "", + "health:Inst": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fault-": "fault:Inst", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "tDn" + ], + "rnFormat": "rslblToInstP-[{tDn}]", + "containedBy": { + "l3ext:ConsLbl": "", + "l3ext:ConsLblDef": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "n-to-m", + "fromMo": "l3ext:AConsLbl", + "fromRelMo": "l3ext:RsLblToInstP", + "toMo": "l3ext:InstP", + "toRelMo": "l3ext:RtLblToInstP", + "enforceable": true, + "resolvable": true + }, + "dnFormats": [ + "uni/epp/rtd-[{epgPKey}]/conslbl-{name}/rslblToInstP-[{tDn}]", + "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]" + ], + "writeAccess": [ + "admin", + "tenant-ext-connectivity" + ], + "readAccess": [ + "admin", + "tenant-ext-connectivity" + ], + "faults": { + "F3783": "fltL3extRsLblToInstPResolveFail" + }, + "events": { + "E4217479": "creation||l3ext:RsLblToInstP", + "E4217480": "modification||l3ext:RsLblToInstP", + "E4217481": "deletion||l3ext:RsLblToInstP" + }, + "stats": { + + }, + "versions": "5.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": "regular", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + + ], + "classId": "16895", + "className": "RsLblToInstP", + "classPkg": "l3ext", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "External Network Instance Profile", + "properties": { + "annotation": { + "versions": "5.0(1k)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "57359", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "5.0(1k)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "57360", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "forceResolve": { + "versions": "1.0(1e)-", + "comment": [ + "Whether the relation should force pull the target." + ], + "isConfigurable": false, + "propGlobalId": "107", + "propLocalId": "83", + "label": "Force Resolve", + "baseType": "scalar:Bool", + "modelType": "scalar:Bool", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "true", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "false", "localName": "no", + "platformFlavors": [ + + ], + "label": "No "}, + { "value": "true", "localName": "yes", + "platformFlavors": [ + + ], + "label": "Yes "} + ], + "default": "yes", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "versions": "5.0(1k)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "57356", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rType": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the type of resolver." + ], + "isConfigurable": false, + "propGlobalId": "106", + "propLocalId": "82", + "label": "Resolver Type", + "baseType": "scalar:Enum8", + "modelType": "reln:ResolverType", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "mo", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "3", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "mo", + "platformFlavors": [ + + ], + "label": "MO "}, + { "value": "2", "localName": "service", + "platformFlavors": [ + + ], + "label": "Service "} + ], + "default": "mo", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "state": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the state of the relationship." + ], + "isConfigurable": false, + "propGlobalId": "103", + "propLocalId": "26", + "label": "State", + "baseType": "scalar:Enum8", + "modelType": "reln:State", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "5", "localName": "cardinality-violation", + "platformFlavors": [ + + ], + "comment": [ + "cardinality violation - When relations are created such that\n they violate the cardinality, state of the relation would be\n set to this." + ], + "label": "Cardinality Violation "}, + { "value": "unformed", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "formed", + "platformFlavors": [ + + ], + "comment": [ + "the relationship is formed with the target object" + ], + "label": "Formed "}, + { "value": "4", "localName": "invalid-target", + "platformFlavors": [ + + ], + "comment": [ + "invalid target DN" + ], + "label": "Invalid Target "}, + { "value": "2", "localName": "missing-target", + "platformFlavors": [ + + ], + "comment": [ + "target does not exist" + ], + "label": "Missing Target "}, + { "value": "0", "localName": "unformed", + "platformFlavors": [ + + ], + "comment": [ + "the relationship is not formed" + ], + "label": "Unformed "} + ], + "default": "unformed", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "stateQual": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the state qualifier of the relationship." + ], + "isConfigurable": false, + "propGlobalId": "104", + "propLocalId": "80", + "label": "State Qualifier", + "baseType": "scalar:Enum8", + "modelType": "reln:StateQual", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "default-target", + "platformFlavors": [ + + ], + "comment": [ + "target not specified, using default" + ], + "label": "Target Not Specified "}, + { "value": "none", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "mismatch-target", + "platformFlavors": [ + + ], + "comment": [ + "target not found, using default" + ], + "label": "Target Not Found "}, + { "value": "0", "localName": "none", + "platformFlavors": [ + + ], + "comment": [ + "no issue" + ], + "label": "None "} + ], + "default": "none", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tCl": { + "versions": "5.0(1k)-", + "comment": [ + "The class ID of the target object. This property is managed internally and should not be modified by the user." + ], + "isConfigurable": false, + "propGlobalId": "57346", + "propLocalId": "78", + "label": "Target Class", + "baseType": "scalar:Enum16", + "modelType": "reln:ClassId", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validValues": [ + { "value": "1775", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1775", "localName": "l3extInstP", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "} + ], + "default": "l3extInstP", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "5.0(1k)-", + "comment": [ + "The distinguished name of the target." + ], + "isConfigurable": true, + "propGlobalId": "57345", + "propLocalId": "77", + "label": "Target-dn", + "baseType": "reference:BinRef", + "modelType": "reln:Dn", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tType": { + "versions": "1.0(1e)-", + "comment": [ + "The type of target." + ], + "isConfigurable": false, + "propGlobalId": "105", + "propLocalId": "81", + "label": "Target Type", + "baseType": "scalar:Enum8", + "modelType": "reln:TargetType", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "all", + "platformFlavors": [ + + ], + "label": "All "}, + { "value": "mo", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "mo", + "platformFlavors": [ + + ], + "label": "MO "}, + { "value": "0", "localName": "name", + "platformFlavors": [ + + ], + "label": "Name "} + ], + "default": "mo", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/templates/resource_example_all_attributes.tf.tmpl b/gen/templates/resource_example_all_attributes.tf.tmpl index 861ed8d1a..65a3bf057 100644 --- a/gen/templates/resource_example_all_attributes.tf.tmpl +++ b/gen/templates/resource_example_all_attributes.tf.tmpl @@ -13,9 +13,15 @@ resource "aci_{{$.ResourceName}}" "full_example_{{getResourceName $key $.Definit {{- range $key, $value := $.Children}}{{$ChildResourceName := .ResourceName}} {{$ChildResourceName}} = [ { {{- range .Properties}}{{- if ne .NamedPropertyClass ""}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name + {{- overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name {{- else}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupChildTestValue .PkgName $ChildResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}"{{- end}}{{ end}} + {{- $overwritePropertyName := overwriteProperty .PkgName .SnakeCaseName $.Definitions}} + {{- if eq .SnakeCaseName "t_dn" }} + {{$overwritePropertyName}} = {{ lookupChildResourceRequiredTestValue .PkgName $overwritePropertyName $.Definitions }} + {{- else }} + {{$overwritePropertyName}} = "{{lookupChildTestValue .PkgName $ChildResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}" + {{- end }} + {{- end}}{{- end}} } ] {{- end}} diff --git a/gen/testvars/l3extConsLbl.yaml b/gen/testvars/l3extConsLbl.yaml index fabbd89ac..001d5dc9c 100644 --- a/gen/testvars/l3extConsLbl.yaml +++ b/gen/testvars/l3extConsLbl.yaml @@ -30,6 +30,13 @@ all: tag: "lemon-chiffon" children: + relation_to_instance_profiles: + - annotation: "annotation_1" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP1" + + - annotation: "annotation_2" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2" + annotations: - key: "key_0" value: "value_1" diff --git a/gen/testvars/l3extRsLblToInstP.yaml b/gen/testvars/l3extRsLblToInstP.yaml new file mode 100644 index 000000000..f151054ed --- /dev/null +++ b/gen/testvars/l3extRsLblToInstP.yaml @@ -0,0 +1,39 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + +datasource_non_existing: + target_dn: aci_external_network_instance_profile.test.id + +datasource_required: + target_dn: aci_external_network_instance_profile.test.id + +resource_required: + target_dn: aci_external_network_instance_profile.test.id + +all: + annotation: "annotation" + +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: "l3extConsLbl" + parent_dependency: "fvTenant" + parent_dn: "aci_l3out_consumer_label.test.id" + class_in_parent: false diff --git a/internal/provider/data_source_aci_l3out_consumer_label.go b/internal/provider/data_source_aci_l3out_consumer_label.go index 8781de9e8..1da4bf4d4 100644 --- a/internal/provider/data_source_aci_l3out_consumer_label.go +++ b/internal/provider/data_source_aci_l3out_consumer_label.go @@ -80,6 +80,22 @@ func (d *L3extConsLblDataSource) Schema(ctx context.Context, req datasource.Sche Computed: true, MarkdownDescription: `Specifies the color of a policy label.`, }, + "relation_to_instance_profiles": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Instance Profile object.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name of the External Network Instance Profile object.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, diff --git a/internal/provider/data_source_aci_relation_to_instance_profile.go b/internal/provider/data_source_aci_relation_to_instance_profile.go new file mode 100644 index 000000000..dd7b6c1b7 --- /dev/null +++ b/internal/provider/data_source_aci_relation_to_instance_profile.go @@ -0,0 +1,149 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &L3extRsLblToInstPDataSource{} + +func NewL3extRsLblToInstPDataSource() datasource.DataSource { + return &L3extRsLblToInstPDataSource{} +} + +// L3extRsLblToInstPDataSource defines the data source implementation. +type L3extRsLblToInstPDataSource struct { + client *client.Client +} + +func (d *L3extRsLblToInstPDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_relation_to_instance_profile") + resp.TypeName = req.ProviderTypeName + "_relation_to_instance_profile" + tflog.Debug(ctx, "End metadata of datasource: aci_relation_to_instance_profile") +} + +func (d *L3extRsLblToInstPDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_relation_to_instance_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_to_instance_profile datasource for the 'l3extRsLblToInstP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Relation To Instance Profile object.", + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Instance Profile object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The distinguished name of the External Network Instance Profile object.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_relation_to_instance_profile") +} + +func (d *L3extRsLblToInstPDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_relation_to_instance_profile") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + d.client = client + tflog.Debug(ctx, "End configure of datasource: aci_relation_to_instance_profile") +} + +func (d *L3extRsLblToInstPDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_relation_to_instance_profile") + var data *L3extRsLblToInstPResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setL3extRsLblToInstPId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetL3extRsLblToInstPAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) + + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_relation_to_instance_profile data source", + fmt.Sprintf("The aci_relation_to_instance_profile data source with id '%s' has not been found", cachedId), + ) + return + } + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_relation_to_instance_profile_test.go b/internal/provider/data_source_aci_relation_to_instance_profile_test.go new file mode 100644 index 000000000..e7bb7d4db --- /dev/null +++ b/internal/provider/data_source_aci_relation_to_instance_profile_test.go @@ -0,0 +1,50 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceL3extRsLblToInstPWithL3extConsLbl(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigL3extRsLblToInstPDataSourceDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_to_instance_profile.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP"), + resource.TestCheckResourceAttr("data.aci_relation_to_instance_profile.test", "annotation", "orchestrator:terraform"), + ), + }, + { + Config: testConfigL3extRsLblToInstPNotExistingL3extConsLbl, + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_instance_profile data source"), + }, + }, + }) +} + +const testConfigL3extRsLblToInstPDataSourceDependencyWithL3extConsLbl = testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl + ` +data "aci_relation_to_instance_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_external_network_instance_profile.test.id + depends_on = [aci_relation_to_instance_profile.test] +} +` + +const testConfigL3extRsLblToInstPNotExistingL3extConsLbl = testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl + ` +data "aci_relation_to_instance_profile" "test_non_existing" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP_not_existing" + depends_on = [aci_relation_to_instance_profile.test] +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 2f962970d..464808290 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -202,6 +202,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvFBRMemberResource, NewL3extConsLblResource, NewL3extProvLblResource, + NewL3extRsLblToInstPResource, NewL3extRsOutToFBRGroupResource, NewL3extRsRedistributePolResource, NewMgmtInstPResource, @@ -224,6 +225,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvFBRMemberDataSource, NewL3extConsLblDataSource, NewL3extProvLblDataSource, + NewL3extRsLblToInstPDataSource, NewL3extRsOutToFBRGroupDataSource, NewL3extRsRedistributePolDataSource, NewMgmtInstPDataSource, diff --git a/internal/provider/resource_aci_l3out_consumer_label.go b/internal/provider/resource_aci_l3out_consumer_label.go index b3c602508..aa554eddd 100644 --- a/internal/provider/resource_aci_l3out_consumer_label.go +++ b/internal/provider/resource_aci_l3out_consumer_label.go @@ -43,18 +43,25 @@ type L3extConsLblResource struct { // L3extConsLblResourceModel describes the resource data model. type L3extConsLblResourceModel 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"` - Owner types.String `tfsdk:"owner"` - OwnerKey types.String `tfsdk:"owner_key"` - OwnerTag types.String `tfsdk:"owner_tag"` - Tag types.String `tfsdk:"tag"` - TagAnnotation types.Set `tfsdk:"annotations"` - TagTag types.Set `tfsdk:"tags"` + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + Owner types.String `tfsdk:"owner"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + Tag types.String `tfsdk:"tag"` + L3extRsLblToInstP types.Set `tfsdk:"relation_to_instance_profiles"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +// L3extRsLblToInstPL3extConsLblResourceModel describes the resource data model for the children without relation ships. +type L3extRsLblToInstPL3extConsLblResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` } // TagAnnotationL3extConsLblResourceModel describes the resource data model for the children without relation ships. @@ -172,6 +179,33 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe }, MarkdownDescription: `Specifies the color of a policy label.`, }, + "relation_to_instance_profiles": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Relation To Instance Profile object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name of the External Network Instance Profile object.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, @@ -272,13 +306,16 @@ func (r *L3extConsLblResource) Create(ctx context.Context, req resource.CreateRe tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_consumer_label with id '%s'", data.Id.ValueString())) + var l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel + data.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPPlan, false) + stateData.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, data, l3extRsLblToInstPPlan, l3extRsLblToInstPState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -337,13 +374,16 @@ func (r *L3extConsLblResource) Update(ctx context.Context, req resource.UpdateRe tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_l3out_consumer_label with id '%s'", data.Id.ValueString())) + var l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel + data.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPPlan, false) + stateData.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, data, l3extRsLblToInstPPlan, l3extRsLblToInstPState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -397,7 +437,7 @@ func (r *L3extConsLblResource) ImportState(ctx context.Context, req resource.Imp } func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *L3extConsLblResourceModel) { - requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "l3extConsLbl,tagAnnotation,tagTag"), "GET", nil) + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "l3extConsLbl,l3extRsLblToInstP,tagAnnotation,tagTag"), "GET", nil) if diags.HasError() { return @@ -436,6 +476,7 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic data.Tag = basetypes.NewStringValue(attributeValue.(string)) } } + L3extRsLblToInstPL3extConsLblList := make([]L3extRsLblToInstPL3extConsLblResourceModel, 0) TagAnnotationL3extConsLblList := make([]TagAnnotationL3extConsLblResourceModel, 0) TagTagL3extConsLblList := make([]TagTagL3extConsLblResourceModel, 0) _, ok := classReadInfo[0].(map[string]interface{})["children"] @@ -444,6 +485,18 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic for _, child := range children { for childClassName, childClassDetails := range child.(map[string]interface{}) { childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "l3extRsLblToInstP" { + L3extRsLblToInstPL3extConsLbl := L3extRsLblToInstPL3extConsLblResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + L3extRsLblToInstPL3extConsLbl.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + L3extRsLblToInstPL3extConsLbl.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + L3extRsLblToInstPL3extConsLblList = append(L3extRsLblToInstPL3extConsLblList, L3extRsLblToInstPL3extConsLbl) + } if childClassName == "tagAnnotation" { TagAnnotationL3extConsLbl := TagAnnotationL3extConsLblResourceModel{} for childAttributeName, childAttributeValue := range childAttributes { @@ -471,6 +524,8 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic } } } + l3extRsLblToInstPSet, _ := types.SetValueFrom(ctx, data.L3extRsLblToInstP.ElementType(ctx), L3extRsLblToInstPL3extConsLblList) + data.L3extRsLblToInstP = l3extRsLblToInstPSet tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationL3extConsLblList) data.TagAnnotation = tagAnnotationSet tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagL3extConsLblList) @@ -517,6 +572,47 @@ func setL3extConsLblId(ctx context.Context, data *L3extConsLblResourceModel) { data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } +func getL3extConsLblL3extRsLblToInstPChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.L3extRsLblToInstP.IsUnknown() { + l3extRsLblToInstPIdentifiers := []L3extRsLblToInstPIdentifier{} + for _, l3extRsLblToInstP := range l3extRsLblToInstPPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !l3extRsLblToInstP.Annotation.IsUnknown() { + childMap["attributes"]["annotation"] = l3extRsLblToInstP.Annotation.ValueString() + } else { + childMap["attributes"]["annotation"] = globalAnnotation + } + if !l3extRsLblToInstP.TDn.IsUnknown() { + childMap["attributes"]["tDn"] = l3extRsLblToInstP.TDn.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"l3extRsLblToInstP": childMap}) + l3extRsLblToInstPIdentifier := L3extRsLblToInstPIdentifier{} + l3extRsLblToInstPIdentifier.TDn = l3extRsLblToInstP.TDn + l3extRsLblToInstPIdentifiers = append(l3extRsLblToInstPIdentifiers, l3extRsLblToInstPIdentifier) + } + for _, l3extRsLblToInstP := range l3extRsLblToInstPState { + delete := true + for _, l3extRsLblToInstPIdentifier := range l3extRsLblToInstPIdentifiers { + if l3extRsLblToInstPIdentifier.TDn == l3extRsLblToInstP.TDn { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["tDn"] = l3extRsLblToInstP.TDn.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"l3extRsLblToInstP": childMap}) + } + } + } else { + data.L3extRsLblToInstP = types.SetNull(data.L3extRsLblToInstP.ElementType(ctx)) + } + + return childPayloads +} func getL3extConsLblTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel) []map[string]interface{} { childPayloads := []map[string]interface{}{} @@ -596,11 +692,17 @@ func getL3extConsLblTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { +func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} + L3extRsLblToInstPchildPayloads := getL3extConsLblL3extRsLblToInstPChildPayloads(ctx, diags, data, l3extRsLblToInstPPlan, l3extRsLblToInstPState) + if L3extRsLblToInstPchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, L3extRsLblToInstPchildPayloads...) + TagAnnotationchildPayloads := getL3extConsLblTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) if TagAnnotationchildPayloads == nil { return nil diff --git a/internal/provider/resource_aci_l3out_consumer_label_test.go b/internal/provider/resource_aci_l3out_consumer_label_test.go index 01a8459da..e87791dfb 100644 --- a/internal/provider/resource_aci_l3out_consumer_label_test.go +++ b/internal/provider/resource_aci_l3out_consumer_label_test.go @@ -102,6 +102,10 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.0.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.1.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.1.key", "key_1"), @@ -126,6 +130,10 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.0.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.1.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.1.key", "key_1"), @@ -142,6 +150,11 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.value", "value_2"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.0.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.1.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.#", "2"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.0.key", "key_0"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.0.value", "value_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.1.key", "key_1"), @@ -157,6 +170,9 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.0.key", "key_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.0.value", "value_2"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.0.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.0.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.#", "1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.0.key", "key_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.0.value", "value_2"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.#", "1"), @@ -168,6 +184,7 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_instance_profiles.#", "0"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.#", "0"), ), }, @@ -223,6 +240,16 @@ resource "aci_l3out_consumer_label" "test" { value = "value_2" }, ] + relation_to_instance_profiles = [ + { + annotation = "annotation_1" + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP1" + }, + { + annotation = "annotation_2" + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2" + }, + ] tags = [ { key = "key_0" @@ -253,6 +280,12 @@ resource "aci_l3out_consumer_label" "test" { value = "value_2" }, ] + relation_to_instance_profiles = [ + { + annotation = "annotation_2" + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2" + }, + ] tags = [ { key = "key_1" @@ -267,6 +300,7 @@ resource "aci_l3out_consumer_label" "test" { parent_dn = aci_l3_outside.test.id name = "test_name" annotations = [] + relation_to_instance_profiles = [] tags = [] } ` diff --git a/internal/provider/resource_aci_relation_to_instance_profile.go b/internal/provider/resource_aci_relation_to_instance_profile.go new file mode 100644 index 000000000..d94069d94 --- /dev/null +++ b/internal/provider/resource_aci_relation_to_instance_profile.go @@ -0,0 +1,563 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &L3extRsLblToInstPResource{} +var _ resource.ResourceWithImportState = &L3extRsLblToInstPResource{} + +func NewL3extRsLblToInstPResource() resource.Resource { + return &L3extRsLblToInstPResource{} +} + +// L3extRsLblToInstPResource defines the resource implementation. +type L3extRsLblToInstPResource struct { + client *client.Client +} + +// L3extRsLblToInstPResourceModel describes the resource data model. +type L3extRsLblToInstPResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +// TagAnnotationL3extRsLblToInstPResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationL3extRsLblToInstPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +// TagTagL3extRsLblToInstPResourceModel describes the resource data model for the children without relation ships. +type TagTagL3extRsLblToInstPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +type L3extRsLblToInstPIdentifier struct { + TDn types.String +} + +func (r *L3extRsLblToInstPResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_relation_to_instance_profile") + resp.TypeName = req.ProviderTypeName + "_relation_to_instance_profile" + tflog.Debug(ctx, "End metadata of resource: aci_relation_to_instance_profile") +} + +func (r *L3extRsLblToInstPResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_relation_to_instance_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_to_instance_profile resource for the 'l3extRsLblToInstP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Relation To Instance Profile 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 Relation To Instance Profile object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The distinguished name of the External Network Instance Profile object.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_relation_to_instance_profile") +} + +func (r *L3extRsLblToInstPResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_relation_to_instance_profile") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client + tflog.Debug(ctx, "End configure of resource: aci_relation_to_instance_profile") +} + +func (r *L3extRsLblToInstPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_relation_to_instance_profile") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *L3extRsLblToInstPResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + setL3extRsLblToInstPId(ctx, stateData) + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *L3extRsLblToInstPResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setL3extRsLblToInstPId(ctx, data) + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToInstPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagL3extRsLblToInstPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getL3extRsLblToInstPCreateJsonPayload(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 + } + + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToInstPResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_relation_to_instance_profile") + var data *L3extRsLblToInstPResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) + + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *L3extRsLblToInstPResourceModel + resp.Diagnostics.Append(resp.State.Set(ctx, &emptyData)...) + } else { + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + } + + tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToInstPResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_relation_to_instance_profile") + var data *L3extRsLblToInstPResourceModel + var stateData *L3extRsLblToInstPResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToInstPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagL3extRsLblToInstPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getL3extRsLblToInstPCreateJsonPayload(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 + } + + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToInstPResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_relation_to_instance_profile") + var data *L3extRsLblToInstPResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "l3extRsLblToInstP", data.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_relation_to_instance_profile with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToInstPResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_relation_to_instance_profile") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *L3extRsLblToInstPResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_relation_to_instance_profile with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_relation_to_instance_profile") +} + +func getAndSetL3extRsLblToInstPAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *L3extRsLblToInstPResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "l3extRsLblToInstP,tagAnnotation,tagTag"), "GET", nil) + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("l3extRsLblToInstP").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("l3extRsLblToInstP").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)) + setL3extRsLblToInstPParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "tDn" { + data.TDn = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationL3extRsLblToInstPList := make([]TagAnnotationL3extRsLblToInstPResourceModel, 0) + TagTagL3extRsLblToInstPList := make([]TagTagL3extRsLblToInstPResourceModel, 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" { + TagAnnotationL3extRsLblToInstP := TagAnnotationL3extRsLblToInstPResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationL3extRsLblToInstP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationL3extRsLblToInstP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationL3extRsLblToInstPList = append(TagAnnotationL3extRsLblToInstPList, TagAnnotationL3extRsLblToInstP) + } + if childClassName == "tagTag" { + TagTagL3extRsLblToInstP := TagTagL3extRsLblToInstPResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagL3extRsLblToInstP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagL3extRsLblToInstP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagL3extRsLblToInstPList = append(TagTagL3extRsLblToInstPList, TagTagL3extRsLblToInstP) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationL3extRsLblToInstPList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagL3extRsLblToInstPList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'l3extRsLblToInstP'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getL3extRsLblToInstPRn(ctx context.Context, data *L3extRsLblToInstPResourceModel) string { + rn := "rslblToInstP-[{tDn}]" + for _, identifier := range []string{"tDn"} { + fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) + fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() + rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) + } + return rn +} + +func setL3extRsLblToInstPParentDn(ctx context.Context, dn string, data *L3extRsLblToInstPResourceModel) { + 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 setL3extRsLblToInstPId(ctx context.Context, data *L3extRsLblToInstPResourceModel) { + rn := getL3extRsLblToInstPRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getL3extRsLblToInstPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extRsLblToInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToInstPResourceModel) []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 getL3extRsLblToInstPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extRsLblToInstPResourceModel, tagTagPlan, tagTagState []TagTagL3extRsLblToInstPResourceModel) []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 getL3extRsLblToInstPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extRsLblToInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToInstPResourceModel, tagTagPlan, tagTagState []TagTagL3extRsLblToInstPResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getL3extRsLblToInstPTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getL3extRsLblToInstPTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.TDn.IsNull() && !data.TDn.IsUnknown() { + payloadMap["attributes"].(map[string]string)["tDn"] = data.TDn.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"l3extRsLblToInstP": payloadMap}) + if err != nil { + diags.AddError( + "Marshalling of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + jsonPayload, err := container.ParseJSON(payload) + + if err != nil { + diags.AddError( + "Construction of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + return jsonPayload +} diff --git a/internal/provider/resource_aci_relation_to_instance_profile_test.go b/internal/provider/resource_aci_relation_to_instance_profile_test.go new file mode 100644 index 000000000..20d6a69e5 --- /dev/null +++ b/internal/provider/resource_aci_relation_to_instance_profile_test.go @@ -0,0 +1,224 @@ +// 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 TestAccResourceL3extRsLblToInstPWithL3extConsLbl(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: testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotation", "orchestrator:terraform"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigL3extRsLblToInstPAllDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotation", "annotation"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigL3extRsLblToInstPResetDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotation", "orchestrator:terraform"), + ), + }, + // Import testing + { + ResourceName: "aci_relation_to_instance_profile.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotation", "orchestrator:terraform"), + ), + }, + // Update with children + { + Config: testConfigL3extRsLblToInstPChildrenDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.1.value", "value_2"), + ), + }, + // Import testing with children + { + ResourceName: "aci_relation_to_instance_profile.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.1.value", "value_2"), + ), + }, + // Update with children removed from config + { + Config: testConfigL3extRsLblToInstPChildrenRemoveFromConfigDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigL3extRsLblToInstPChildrenRemoveOneDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigL3extRsLblToInstPChildrenRemoveAllDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_relation_to_instance_profile.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_instance_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_external_network_instance_profile.test.id +} +` + +const testConfigL3extRsLblToInstPAllDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_instance_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_external_network_instance_profile.test.id + annotation = "annotation" +} +` + +const testConfigL3extRsLblToInstPResetDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_instance_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_external_network_instance_profile.test.id + annotation = "orchestrator:terraform" +} +` +const testConfigL3extRsLblToInstPChildrenDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_instance_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_external_network_instance_profile.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 testConfigL3extRsLblToInstPChildrenRemoveFromConfigDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_instance_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_external_network_instance_profile.test.id +} +` + +const testConfigL3extRsLblToInstPChildrenRemoveOneDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_instance_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_external_network_instance_profile.test.id + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigL3extRsLblToInstPChildrenRemoveAllDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_instance_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_external_network_instance_profile.test.id + annotations = [] + tags = [] +} +` diff --git a/internal/provider/test_constants.go b/internal/provider/test_constants.go index 426d357a4..1d7a7a19d 100644 --- a/internal/provider/test_constants.go +++ b/internal/provider/test_constants.go @@ -70,3 +70,14 @@ resource "aci_l3_outside" "test" { relation_l3ext_rs_ectx = aci_vrf.test.id } ` + +const testConfigL3extConsLblMinDependencyWithFvTenant = testConfigL3extOutMin + ` +resource "aci_external_network_instance_profile" "test" { + l3_outside_dn = aci_l3_outside.test.id + name = "testInstP" +} +resource "aci_l3out_consumer_label" "test" { + parent_dn = aci_l3_outside.test.id + name = "test_name" +} +`