From a5b060b1fdf5d728ec590746a3e603ce113a4567 Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Thu, 25 Apr 2024 08:35:46 +0530 Subject: [PATCH] [ignore] added relation to route control profile --- docs/data-sources/annotation.md | 2 +- docs/data-sources/l3out_consumer_label.md | 5 + .../relation_to_route_control_profile.md | 65 ++ docs/data-sources/tag.md | 2 +- docs/resources/annotation.md | 2 +- docs/resources/l3out_consumer_label.md | 19 + .../relation_to_route_control_profile.md | 126 +++ docs/resources/tag.md | 2 +- .../data-source.tf | 6 + .../provider.tf | 14 + .../resource-all-attributes.tf | 7 + .../provider.tf | 14 + .../resource-all-attributes.tf | 19 + .../resource.tf | 6 + gen/definitions/classes.yaml | 12 + gen/definitions/properties.yaml | 38 +- gen/meta/l3extRsLblToProfile.json | 970 ++++++++++++++++++ gen/testvars/l3extConsLbl.yaml | 9 + gen/testvars/l3extRsLblToProfile.yaml | 44 + .../data_source_aci_l3out_consumer_label.go | 20 + ...e_aci_relation_to_route_control_profile.go | 153 +++ ..._relation_to_route_control_profile_test.go | 54 + internal/provider/provider.go | 2 + .../resource_aci_l3out_consumer_label.go | 156 ++- .../resource_aci_l3out_consumer_label_test.go | 44 + ...e_aci_relation_to_route_control_profile.go | 584 +++++++++++ ..._relation_to_route_control_profile_test.go | 238 +++++ internal/provider/test_constants.go | 4 + 28 files changed, 2593 insertions(+), 24 deletions(-) create mode 100644 docs/data-sources/relation_to_route_control_profile.md create mode 100644 docs/resources/relation_to_route_control_profile.md create mode 100644 examples/data-sources/aci_relation_to_route_control_profile/data-source.tf create mode 100644 examples/data-sources/aci_relation_to_route_control_profile/provider.tf create mode 100644 examples/resources/aci_relation_to_route_control_profile/provider.tf create mode 100644 examples/resources/aci_relation_to_route_control_profile/resource-all-attributes.tf create mode 100644 examples/resources/aci_relation_to_route_control_profile/resource.tf create mode 100644 gen/meta/l3extRsLblToProfile.json create mode 100644 gen/testvars/l3extRsLblToProfile.yaml create mode 100644 internal/provider/data_source_aci_relation_to_route_control_profile.go create mode 100644 internal/provider/data_source_aci_relation_to_route_control_profile_test.go create mode 100644 internal/provider/resource_aci_relation_to_route_control_profile.go create mode 100644 internal/provider/resource_aci_relation_to_route_control_profile_test.go diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index 85cb13f16..4167a3b1f 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -66,6 +66,7 @@ data "aci_annotation" "example_application_epg" { - [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_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_route_control_profile) ([l3extRsLblToProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToProfile/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)) @@ -73,7 +74,6 @@ data "aci_annotation" "example_application_epg" { - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - - [aci_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)) * `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 1bfc67df1..e27d521de 100644 --- a/docs/data-sources/l3out_consumer_label.md +++ b/docs/data-sources/l3out_consumer_label.md @@ -62,6 +62,11 @@ data "aci_l3out_consumer_label" "example_l3_outside" { * `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. +* `relation_to_route_control_profiles` - (list) A list of Relation To Route Control Profiles (ACI object [l3extRsLblToProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToProfile/overview)) pointing to Route Control Profile (ACI Object [rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)). This attribute is supported in ACI versions: 5.0(1k) and later. + * `annotation` (annotation) - (string) The annotation of the Relation To Route Control Profile object. + * `direction` (direction) - (string) The connector direction. + * `target_dn` (tDn) - (string) The distinguished name of the Route Control 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_route_control_profile.md b/docs/data-sources/relation_to_route_control_profile.md new file mode 100644 index 000000000..ef6618610 --- /dev/null +++ b/docs/data-sources/relation_to_route_control_profile.md @@ -0,0 +1,65 @@ +--- +# 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_route_control_profile" +sidebar_current: "docs-aci-data-source-aci_relation_to_route_control_profile" +description: |- + Data source for Relation To Route Control Profile +--- + +# aci_relation_to_route_control_profile # + +Data source for Relation To Route Control Profile + +## API Information ## + +* Class: [l3extRsLblToProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToProfile/overview) + +* Supported in ACI versions: 5.0(1k) and later. + +* Distinguished Name Format: `uni/tn-{name}/out-{name}/conslbl-{name}/rslblToProfile-[{tDn}]-{direction}` + +## GUI Information ## + +* Location: `Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label` + +## Example Usage ## + +```hcl + +data "aci_relation_to_route_control_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + direction = "import" + target_dn = aci_route_control_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) + +* `direction` (direction) - (string) The connector direction. + - Valid Values: `export`, `import`. +* `target_dn` (tDn) - (string) The distinguished name of the Route Control Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation To Route Control Profile object. +* `annotation` (annotation) - (string) The annotation of the Relation To Route Control 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 adabe05d3..7ad931c07 100644 --- a/docs/data-sources/tag.md +++ b/docs/data-sources/tag.md @@ -66,6 +66,7 @@ data "aci_tag" "example_application_epg" { - [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_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_route_control_profile) ([l3extRsLblToProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToProfile/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)) @@ -73,7 +74,6 @@ data "aci_tag" "example_application_epg" { - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - - [aci_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)) * `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 40d863998..97565a61c 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -75,6 +75,7 @@ All examples for the Annotation resource can be found in the [examples](https:// - [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_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_route_control_profile) ([l3extRsLblToProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToProfile/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)) @@ -82,7 +83,6 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - - [aci_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)) * `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 00c6e225b..8cbfc7ea7 100644 --- a/docs/resources/l3out_consumer_label.md +++ b/docs/resources/l3out_consumer_label.md @@ -64,6 +64,13 @@ resource "aci_l3out_consumer_label" "full_example_l3_outside" { target_dn = aci_external_network_instance_profile.test.id } ] + relation_to_route_control_profiles = [ + { + annotation = "annotation_1" + direction = "export" + target_dn = aci_route_control_profile.test.id + } + ] annotations = [ { key = "key_0" @@ -119,6 +126,18 @@ All examples for the L3out Consumer Label resource can be found in the [examples * `annotation` (annotation) - (string) The annotation of the Relation To Instance Profile object. - Default: `orchestrator:terraform` +* `relation_to_route_control_profiles` - (list) A list of Relation To Route Control Profiles (ACI object [l3extRsLblToProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToProfile/overview)) pointing to Route Control Profile (ACI Object [rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) which can be configured using the [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) resource. This attribute is supported in ACI versions: 5.0(1k) and later. + + #### Required #### + + * `direction` (direction) - (string) The connector direction. + * `target_dn` (tDn) - (string) The distinguished name of the Route Control Profile object. + + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation To Route Control 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_route_control_profile.md b/docs/resources/relation_to_route_control_profile.md new file mode 100644 index 000000000..fcf945936 --- /dev/null +++ b/docs/resources/relation_to_route_control_profile.md @@ -0,0 +1,126 @@ +--- +# 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_route_control_profile" +sidebar_current: "docs-aci-resource-aci_relation_to_route_control_profile" +description: |- + Manages ACI Relation To Route Control Profile +--- + +# aci_relation_to_route_control_profile # + +Manages ACI Relation To Route Control 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: [l3extRsLblToProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToProfile/overview) + +* Supported in ACI versions: 5.0(1k) and later. + +* Distinguished Name Format: `uni/tn-{name}/out-{name}/conslbl-{name}/rslblToProfile-[{tDn}]-{direction}` + +## GUI Information ## + +* Location: `Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label` + +## Example Usage ## + +The configuration snippet below creates a Relation To Route Control Profile with only required attributes. + +```hcl + +resource "aci_relation_to_route_control_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + direction = "import" + target_dn = aci_route_control_profile.test.id +} + +``` +The configuration snippet below shows all possible attributes of the Relation To Route Control Profile. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_relation_to_route_control_profile" "full_example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + annotation = "annotation" + direction = "import" + target_dn = aci_route_control_profile.test.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Relation To Route Control Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_relation_to_route_control_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) + +* `direction` (direction) - (string) The connector direction. + - Valid Values: `export`, `import`. +* `target_dn` (tDn) - (string) The distinguished name of the Route Control Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation To Route Control Profile object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Relation To Route Control 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 Route Control 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_route_control_profile.example_l3out_consumer_label uni/tn-{name}/out-{name}/conslbl-{name}/rslblToProfile-[{tDn}]-{direction} +``` + +Starting in Terraform version 1.5, an existing Relation To Route Control 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}/rslblToProfile-[{tDn}]-{direction}" + to = aci_relation_to_route_control_profile.example_l3out_consumer_label +} +``` diff --git a/docs/resources/tag.md b/docs/resources/tag.md index 437d5c66e..fc6c09a96 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -75,6 +75,7 @@ All examples for the Tag resource can be found in the [examples](https://github. - [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_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_route_control_profile) ([l3extRsLblToProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToProfile/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)) @@ -82,7 +83,6 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - - [aci_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)) * `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_route_control_profile/data-source.tf b/examples/data-sources/aci_relation_to_route_control_profile/data-source.tf new file mode 100644 index 000000000..a57b1ffc3 --- /dev/null +++ b/examples/data-sources/aci_relation_to_route_control_profile/data-source.tf @@ -0,0 +1,6 @@ + +data "aci_relation_to_route_control_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + direction = "import" + target_dn = aci_route_control_profile.test.id +} diff --git a/examples/data-sources/aci_relation_to_route_control_profile/provider.tf b/examples/data-sources/aci_relation_to_route_control_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_relation_to_route_control_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 a73185158..203ff1e4d 100644 --- a/examples/resources/aci_l3out_consumer_label/resource-all-attributes.tf +++ b/examples/resources/aci_l3out_consumer_label/resource-all-attributes.tf @@ -15,6 +15,13 @@ resource "aci_l3out_consumer_label" "full_example_l3_outside" { target_dn = aci_external_network_instance_profile.test.id } ] + relation_to_route_control_profiles = [ + { + annotation = "annotation_1" + direction = "export" + target_dn = aci_route_control_profile.test.id + } + ] annotations = [ { key = "key_0" diff --git a/examples/resources/aci_relation_to_route_control_profile/provider.tf b/examples/resources/aci_relation_to_route_control_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_relation_to_route_control_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_route_control_profile/resource-all-attributes.tf b/examples/resources/aci_relation_to_route_control_profile/resource-all-attributes.tf new file mode 100644 index 000000000..0b0af714f --- /dev/null +++ b/examples/resources/aci_relation_to_route_control_profile/resource-all-attributes.tf @@ -0,0 +1,19 @@ + +resource "aci_relation_to_route_control_profile" "full_example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + annotation = "annotation" + direction = "import" + target_dn = aci_route_control_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_route_control_profile/resource.tf b/examples/resources/aci_relation_to_route_control_profile/resource.tf new file mode 100644 index 000000000..0c355f5f6 --- /dev/null +++ b/examples/resources/aci_relation_to_route_control_profile/resource.tf @@ -0,0 +1,6 @@ + +resource "aci_relation_to_route_control_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + direction = "import" + target_dn = aci_route_control_profile.test.id +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index d4bc12299..2e567a11f 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -179,3 +179,15 @@ l3extRsLblToInstP: - "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." + +l3extRsLblToProfile: + resource_name: "relation_to_route_control_profile" + ui_locations: + - "Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label" + sub_category: "L3Out" + dn_formats: + - "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToProfile-[{tDn}]-{direction}" + 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 b7c6e2435..e867e5165 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -245,8 +245,8 @@ l3extRsLblToInstP: 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" + - target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP1" # Used for the parent resource test + - target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2" # Used for the parent resource test parents: - class_name: "l3extOut" parent_dependency: "fvTenant" @@ -257,4 +257,36 @@ l3extRsLblToInstP: 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" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP" # Used for the current resource test + +l3extRsLblToProfile: + documentation: + tDn: "The distinguished name of the Route Control Profile object." + test_values: + default: + direction: "import" + all: + direction: "export" + resource_required: + target_dn: aci_route_control_profile.test.id + direction: "import" + datasource_required: + target_dn: aci_route_control_profile.test.id + direction: "export" + datasource_non_existing: + target_dn: aci_route_control_profile.test.id + direction: "export" + test_values_for_parent: + - target_dn: "uni/tn-test_tenant/prof-test_rctp1" + - target_dn: "uni/tn-test_tenant/prof-test_rctp2" + parents: + - class_name: "l3extOut" + parent_dependency: "fvTenant" + parent_dn: "aci_l3_outside.test.id" + class_in_parent: false + targets: + - class_name: "rtctrlProfile" + parent_dependency: "l3extOut" + parent_dependency_dn: "aci_route_control_profile.test.id" + parent_dn: "aci_l3_outside.test.id" + target_dn: "uni/tn-test_tenant/prof-test_rctp" diff --git a/gen/meta/l3extRsLblToProfile.json b/gen/meta/l3extRsLblToProfile.json new file mode 100644 index 000000000..e8000342e --- /dev/null +++ b/gen/meta/l3extRsLblToProfile.json @@ -0,0 +1,970 @@ +{ + "l3ext:RsLblToProfile": { + "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", + "direction" + ], + "rnFormat": "rslblToProfile-[{tDn}]-{direction}", + "containedBy": { + "l3ext:ConsLbl": "", + "l3ext:ConsLblDef": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "n-to-m", + "fromMo": "l3ext:AConsLbl", + "fromRelMo": "l3ext:RsLblToProfile", + "toMo": "rtctrl:Profile", + "toRelMo": "rtctrl:RtLblToProfile", + "enforceable": true, + "resolvable": true + }, + "dnFormats": [ + "uni/epp/rtd-[{epgPKey}]/conslbl-{name}/rslblToProfile-[{tDn}]-{direction}", + "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToProfile-[{tDn}]-{direction}" + ], + "writeAccess": [ + "admin", + "tenant-ext-connectivity" + ], + "readAccess": [ + "admin", + "tenant-ext-connectivity" + ], + "faults": { + "F3784": "fltL3extRsLblToProfileResolveFail" + }, + "events": { + "E4217482": "creation||l3ext:RsLblToProfile", + "E4217483": "modification||l3ext:RsLblToProfile", + "E4217484": "deletion||l3ext:RsLblToProfile" + }, + "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": "16893", + "className": "RsLblToProfile", + "classPkg": "l3ext", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "Route Control Profile", + "comment": [ + "Consumer Lable Relation to Routing Policy" + ], + "properties": { + "annotation": { + "versions": "5.0(1k)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "57357", + "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 + }, + "direction": { + "versions": "5.0(1k)-", + "comment": [ + "The connector direction." + ], + "isConfigurable": true, + "propGlobalId": "57349", + "propLocalId": "94", + "label": "direction", + "baseType": "scalar:Enum8", + "modelType": "rtctrl:Direction", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "import", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "export", + "platformFlavors": [ + + ], + "comment": [ + "In To Out" + ], + "label": "Route Export Policy "}, + { "value": "2", "localName": "import", + "platformFlavors": [ + + ], + "comment": [ + "Out to In" + ], + "label": "Route Import Policy "} + ], + "default": "import", + "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": "57358", + "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": "57355", + "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": "57351", + "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": "602", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "602", "localName": "rtctrlProfile", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "} + ], + "default": "rtctrlProfile", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "5.0(1k)-", + "comment": [ + "The distinguished name of the target." + ], + "isConfigurable": true, + "propGlobalId": "57350", + "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/testvars/l3extConsLbl.yaml b/gen/testvars/l3extConsLbl.yaml index 001d5dc9c..a3e31deab 100644 --- a/gen/testvars/l3extConsLbl.yaml +++ b/gen/testvars/l3extConsLbl.yaml @@ -37,6 +37,15 @@ children: - annotation: "annotation_2" target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2" + relation_to_route_control_profiles: + - annotation: "annotation_1" + direction: "export" + target_dn: "uni/tn-test_tenant/prof-test_rctp1" + + - annotation: "annotation_2" + direction: "import" + target_dn: "uni/tn-test_tenant/prof-test_rctp2" + annotations: - key: "key_0" value: "value_1" diff --git a/gen/testvars/l3extRsLblToProfile.yaml b/gen/testvars/l3extRsLblToProfile.yaml new file mode 100644 index 000000000..b393cdbaf --- /dev/null +++ b/gen/testvars/l3extRsLblToProfile.yaml @@ -0,0 +1,44 @@ +# 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" + direction: "import" + +datasource_non_existing: + direction: "export" + target_dn: aci_route_control_profile.test.id + +datasource_required: + direction: "export" + target_dn: aci_route_control_profile.test.id + +resource_required: + direction: "import" + target_dn: aci_route_control_profile.test.id + +all: + annotation: "annotation" + direction: "export" + +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 1da4bf4d4..5567e7f1b 100644 --- a/internal/provider/data_source_aci_l3out_consumer_label.go +++ b/internal/provider/data_source_aci_l3out_consumer_label.go @@ -96,6 +96,26 @@ func (d *L3extConsLblDataSource) Schema(ctx context.Context, req datasource.Sche }, }, }, + "relation_to_route_control_profiles": schema.SetNestedAttribute{ + MarkdownDescription: `Consumer Lable Relation to Routing Policy`, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Route Control Profile object.`, + }, + "direction": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The connector direction.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name of the Route Control Profile object.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, diff --git a/internal/provider/data_source_aci_relation_to_route_control_profile.go b/internal/provider/data_source_aci_relation_to_route_control_profile.go new file mode 100644 index 000000000..728549d7e --- /dev/null +++ b/internal/provider/data_source_aci_relation_to_route_control_profile.go @@ -0,0 +1,153 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &L3extRsLblToProfileDataSource{} + +func NewL3extRsLblToProfileDataSource() datasource.DataSource { + return &L3extRsLblToProfileDataSource{} +} + +// L3extRsLblToProfileDataSource defines the data source implementation. +type L3extRsLblToProfileDataSource struct { + client *client.Client +} + +func (d *L3extRsLblToProfileDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_relation_to_route_control_profile") + resp.TypeName = req.ProviderTypeName + "_relation_to_route_control_profile" + tflog.Debug(ctx, "End metadata of datasource: aci_relation_to_route_control_profile") +} + +func (d *L3extRsLblToProfileDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_relation_to_route_control_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_to_route_control_profile datasource for the 'l3extRsLblToProfile' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Relation To Route Control 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 Route Control Profile object.`, + }, + "direction": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The connector direction.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The distinguished name of the Route Control 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_route_control_profile") +} + +func (d *L3extRsLblToProfileDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_relation_to_route_control_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_route_control_profile") +} + +func (d *L3extRsLblToProfileDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_relation_to_route_control_profile") + var data *L3extRsLblToProfileResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setL3extRsLblToProfileId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetL3extRsLblToProfileAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_relation_to_route_control_profile with id '%s'", data.Id.ValueString())) + + getAndSetL3extRsLblToProfileAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_relation_to_route_control_profile data source", + fmt.Sprintf("The aci_relation_to_route_control_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_route_control_profile with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_relation_to_route_control_profile_test.go b/internal/provider/data_source_aci_relation_to_route_control_profile_test.go new file mode 100644 index 000000000..e9a1d76a9 --- /dev/null +++ b/internal/provider/data_source_aci_relation_to_route_control_profile_test.go @@ -0,0 +1,54 @@ +// 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 TestAccDataSourceL3extRsLblToProfileWithL3extConsLbl(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigL3extRsLblToProfileDataSourceDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_to_route_control_profile.test", "direction", "export"), + resource.TestCheckResourceAttr("data.aci_relation_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-test_rctp"), + resource.TestCheckResourceAttr("data.aci_relation_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_relation_to_route_control_profile.test", "direction", "import"), + ), + }, + { + Config: testConfigL3extRsLblToProfileNotExistingL3extConsLbl, + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_route_control_profile data source"), + }, + }, + }) +} + +const testConfigL3extRsLblToProfileDataSourceDependencyWithL3extConsLbl = testConfigL3extRsLblToProfileMinDependencyWithL3extConsLbl + ` +data "aci_relation_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "export" + target_dn = aci_route_control_profile.test.id + depends_on = [aci_relation_to_route_control_profile.test] +} +` + +const testConfigL3extRsLblToProfileNotExistingL3extConsLbl = testConfigL3extRsLblToProfileMinDependencyWithL3extConsLbl + ` +data "aci_relation_to_route_control_profile" "test_non_existing" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "export" + target_dn = "uni/tn-test_tenant/prof-test_rctp_not_existing" + depends_on = [aci_relation_to_route_control_profile.test] +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 464808290..1af9ad082 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -203,6 +203,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewL3extConsLblResource, NewL3extProvLblResource, NewL3extRsLblToInstPResource, + NewL3extRsLblToProfileResource, NewL3extRsOutToFBRGroupResource, NewL3extRsRedistributePolResource, NewMgmtInstPResource, @@ -226,6 +227,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewL3extConsLblDataSource, NewL3extProvLblDataSource, NewL3extRsLblToInstPDataSource, + NewL3extRsLblToProfileDataSource, NewL3extRsOutToFBRGroupDataSource, NewL3extRsRedistributePolDataSource, NewMgmtInstPDataSource, diff --git a/internal/provider/resource_aci_l3out_consumer_label.go b/internal/provider/resource_aci_l3out_consumer_label.go index aa554eddd..a918ca770 100644 --- a/internal/provider/resource_aci_l3out_consumer_label.go +++ b/internal/provider/resource_aci_l3out_consumer_label.go @@ -43,19 +43,20 @@ 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"` - L3extRsLblToInstP types.Set `tfsdk:"relation_to_instance_profiles"` - 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"` + L3extRsLblToProfile types.Set `tfsdk:"relation_to_route_control_profiles"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` } // L3extRsLblToInstPL3extConsLblResourceModel describes the resource data model for the children without relation ships. @@ -64,6 +65,13 @@ type L3extRsLblToInstPL3extConsLblResourceModel struct { TDn types.String `tfsdk:"target_dn"` } +// L3extRsLblToProfileL3extConsLblResourceModel describes the resource data model for the children without relation ships. +type L3extRsLblToProfileL3extConsLblResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + Direction types.String `tfsdk:"direction"` + TDn types.String `tfsdk:"target_dn"` +} + // TagAnnotationL3extConsLblResourceModel describes the resource data model for the children without relation ships. type TagAnnotationL3extConsLblResourceModel struct { Key types.String `tfsdk:"key"` @@ -206,6 +214,43 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe }, }, }, + "relation_to_route_control_profiles": schema.SetNestedAttribute{ + MarkdownDescription: `Consumer Lable Relation to Routing Policy`, + 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 Route Control Profile object.`, + }, + "direction": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("export", "import"), + }, + MarkdownDescription: `The connector direction.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name of the Route Control Profile object.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, @@ -309,13 +354,16 @@ func (r *L3extConsLblResource) Create(ctx context.Context, req resource.CreateRe var l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel data.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPPlan, false) stateData.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPState, false) + var l3extRsLblToProfilePlan, l3extRsLblToProfileState []L3extRsLblToProfileL3extConsLblResourceModel + data.L3extRsLblToProfile.ElementsAs(ctx, &l3extRsLblToProfilePlan, false) + stateData.L3extRsLblToProfile.ElementsAs(ctx, &l3extRsLblToProfileState, 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, l3extRsLblToInstPPlan, l3extRsLblToInstPState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, data, l3extRsLblToInstPPlan, l3extRsLblToInstPState, l3extRsLblToProfilePlan, l3extRsLblToProfileState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -377,13 +425,16 @@ func (r *L3extConsLblResource) Update(ctx context.Context, req resource.UpdateRe var l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel data.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPPlan, false) stateData.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPState, false) + var l3extRsLblToProfilePlan, l3extRsLblToProfileState []L3extRsLblToProfileL3extConsLblResourceModel + data.L3extRsLblToProfile.ElementsAs(ctx, &l3extRsLblToProfilePlan, false) + stateData.L3extRsLblToProfile.ElementsAs(ctx, &l3extRsLblToProfileState, 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, l3extRsLblToInstPPlan, l3extRsLblToInstPState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, data, l3extRsLblToInstPPlan, l3extRsLblToInstPState, l3extRsLblToProfilePlan, l3extRsLblToProfileState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -437,7 +488,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,l3extRsLblToInstP,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,l3extRsLblToProfile,tagAnnotation,tagTag"), "GET", nil) if diags.HasError() { return @@ -477,6 +528,7 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic } } L3extRsLblToInstPL3extConsLblList := make([]L3extRsLblToInstPL3extConsLblResourceModel, 0) + L3extRsLblToProfileL3extConsLblList := make([]L3extRsLblToProfileL3extConsLblResourceModel, 0) TagAnnotationL3extConsLblList := make([]TagAnnotationL3extConsLblResourceModel, 0) TagTagL3extConsLblList := make([]TagTagL3extConsLblResourceModel, 0) _, ok := classReadInfo[0].(map[string]interface{})["children"] @@ -497,6 +549,21 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic } L3extRsLblToInstPL3extConsLblList = append(L3extRsLblToInstPL3extConsLblList, L3extRsLblToInstPL3extConsLbl) } + if childClassName == "l3extRsLblToProfile" { + L3extRsLblToProfileL3extConsLbl := L3extRsLblToProfileL3extConsLblResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + L3extRsLblToProfileL3extConsLbl.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "direction" { + L3extRsLblToProfileL3extConsLbl.Direction = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + L3extRsLblToProfileL3extConsLbl.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + L3extRsLblToProfileL3extConsLblList = append(L3extRsLblToProfileL3extConsLblList, L3extRsLblToProfileL3extConsLbl) + } if childClassName == "tagAnnotation" { TagAnnotationL3extConsLbl := TagAnnotationL3extConsLblResourceModel{} for childAttributeName, childAttributeValue := range childAttributes { @@ -526,6 +593,8 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic } l3extRsLblToInstPSet, _ := types.SetValueFrom(ctx, data.L3extRsLblToInstP.ElementType(ctx), L3extRsLblToInstPL3extConsLblList) data.L3extRsLblToInstP = l3extRsLblToInstPSet + l3extRsLblToProfileSet, _ := types.SetValueFrom(ctx, data.L3extRsLblToProfile.ElementType(ctx), L3extRsLblToProfileL3extConsLblList) + data.L3extRsLblToProfile = l3extRsLblToProfileSet tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationL3extConsLblList) data.TagAnnotation = tagAnnotationSet tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagL3extConsLblList) @@ -613,6 +682,53 @@ func getL3extConsLblL3extRsLblToInstPChildPayloads(ctx context.Context, diags *d return childPayloads } +func getL3extConsLblL3extRsLblToProfileChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, l3extRsLblToProfilePlan, l3extRsLblToProfileState []L3extRsLblToProfileL3extConsLblResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.L3extRsLblToProfile.IsUnknown() { + l3extRsLblToProfileIdentifiers := []L3extRsLblToProfileIdentifier{} + for _, l3extRsLblToProfile := range l3extRsLblToProfilePlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !l3extRsLblToProfile.Annotation.IsUnknown() { + childMap["attributes"]["annotation"] = l3extRsLblToProfile.Annotation.ValueString() + } else { + childMap["attributes"]["annotation"] = globalAnnotation + } + if !l3extRsLblToProfile.Direction.IsUnknown() { + childMap["attributes"]["direction"] = l3extRsLblToProfile.Direction.ValueString() + } + if !l3extRsLblToProfile.TDn.IsUnknown() { + childMap["attributes"]["tDn"] = l3extRsLblToProfile.TDn.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"l3extRsLblToProfile": childMap}) + l3extRsLblToProfileIdentifier := L3extRsLblToProfileIdentifier{} + l3extRsLblToProfileIdentifier.Direction = l3extRsLblToProfile.Direction + l3extRsLblToProfileIdentifier.TDn = l3extRsLblToProfile.TDn + l3extRsLblToProfileIdentifiers = append(l3extRsLblToProfileIdentifiers, l3extRsLblToProfileIdentifier) + } + for _, l3extRsLblToProfile := range l3extRsLblToProfileState { + delete := true + for _, l3extRsLblToProfileIdentifier := range l3extRsLblToProfileIdentifiers { + if l3extRsLblToProfileIdentifier.Direction == l3extRsLblToProfile.Direction && + l3extRsLblToProfileIdentifier.TDn == l3extRsLblToProfile.TDn { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["direction"] = l3extRsLblToProfile.Direction.ValueString() + childMap["attributes"]["tDn"] = l3extRsLblToProfile.TDn.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"l3extRsLblToProfile": childMap}) + } + } + } else { + data.L3extRsLblToProfile = types.SetNull(data.L3extRsLblToProfile.ElementType(ctx)) + } + + return childPayloads +} func getL3extConsLblTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel) []map[string]interface{} { childPayloads := []map[string]interface{}{} @@ -692,7 +808,7 @@ func getL3extConsLblTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { +func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel, l3extRsLblToProfilePlan, l3extRsLblToProfileState []L3extRsLblToProfileL3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} @@ -703,6 +819,12 @@ func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnosti } childPayloads = append(childPayloads, L3extRsLblToInstPchildPayloads...) + L3extRsLblToProfilechildPayloads := getL3extConsLblL3extRsLblToProfileChildPayloads(ctx, diags, data, l3extRsLblToProfilePlan, l3extRsLblToProfileState) + if L3extRsLblToProfilechildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, L3extRsLblToProfilechildPayloads...) + 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 e87791dfb..adb26086a 100644 --- a/internal/provider/resource_aci_l3out_consumer_label_test.go +++ b/internal/provider/resource_aci_l3out_consumer_label_test.go @@ -106,6 +106,12 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { 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_route_control_profiles.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.0.direction", "export"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.0.target_dn", "uni/tn-test_tenant/prof-test_rctp1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.direction", "import"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.target_dn", "uni/tn-test_tenant/prof-test_rctp2"), 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"), @@ -134,6 +140,12 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { 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_route_control_profiles.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.0.direction", "export"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.0.target_dn", "uni/tn-test_tenant/prof-test_rctp1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.direction", "import"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.target_dn", "uni/tn-test_tenant/prof-test_rctp2"), 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"), @@ -155,6 +167,13 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { 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", "relation_to_route_control_profiles.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.0.direction", "export"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.0.target_dn", "uni/tn-test_tenant/prof-test_rctp1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.direction", "import"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.1.target_dn", "uni/tn-test_tenant/prof-test_rctp2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_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"), @@ -173,6 +192,10 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { 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", "relation_to_route_control_profiles.0.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.0.direction", "import"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.0.target_dn", "uni/tn-test_tenant/prof-test_rctp2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_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"), @@ -185,6 +208,7 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { 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", "relation_to_route_control_profiles.#", "0"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.#", "0"), ), }, @@ -250,6 +274,18 @@ resource "aci_l3out_consumer_label" "test" { target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2" }, ] + relation_to_route_control_profiles = [ + { + annotation = "annotation_1" + direction = "export" + target_dn = "uni/tn-test_tenant/prof-test_rctp1" + }, + { + annotation = "annotation_2" + direction = "import" + target_dn = "uni/tn-test_tenant/prof-test_rctp2" + }, + ] tags = [ { key = "key_0" @@ -286,6 +322,13 @@ resource "aci_l3out_consumer_label" "test" { target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP2" }, ] + relation_to_route_control_profiles = [ + { + annotation = "annotation_2" + direction = "import" + target_dn = "uni/tn-test_tenant/prof-test_rctp2" + }, + ] tags = [ { key = "key_1" @@ -301,6 +344,7 @@ resource "aci_l3out_consumer_label" "test" { name = "test_name" annotations = [] relation_to_instance_profiles = [] + relation_to_route_control_profiles = [] tags = [] } ` diff --git a/internal/provider/resource_aci_relation_to_route_control_profile.go b/internal/provider/resource_aci_relation_to_route_control_profile.go new file mode 100644 index 000000000..090bcefcc --- /dev/null +++ b/internal/provider/resource_aci_relation_to_route_control_profile.go @@ -0,0 +1,584 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &L3extRsLblToProfileResource{} +var _ resource.ResourceWithImportState = &L3extRsLblToProfileResource{} + +func NewL3extRsLblToProfileResource() resource.Resource { + return &L3extRsLblToProfileResource{} +} + +// L3extRsLblToProfileResource defines the resource implementation. +type L3extRsLblToProfileResource struct { + client *client.Client +} + +// L3extRsLblToProfileResourceModel describes the resource data model. +type L3extRsLblToProfileResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Direction types.String `tfsdk:"direction"` + TDn types.String `tfsdk:"target_dn"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +// TagAnnotationL3extRsLblToProfileResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationL3extRsLblToProfileResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +// TagTagL3extRsLblToProfileResourceModel describes the resource data model for the children without relation ships. +type TagTagL3extRsLblToProfileResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +type L3extRsLblToProfileIdentifier struct { + Direction types.String + TDn types.String +} + +func (r *L3extRsLblToProfileResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_relation_to_route_control_profile") + resp.TypeName = req.ProviderTypeName + "_relation_to_route_control_profile" + tflog.Debug(ctx, "End metadata of resource: aci_relation_to_route_control_profile") +} + +func (r *L3extRsLblToProfileResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_relation_to_route_control_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_to_route_control_profile resource for the 'l3extRsLblToProfile' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Relation To Route Control 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 Route Control Profile object.`, + }, + "direction": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("export", "import"), + }, + MarkdownDescription: `The connector direction.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The distinguished name of the Route Control 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_route_control_profile") +} + +func (r *L3extRsLblToProfileResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_relation_to_route_control_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_route_control_profile") +} + +func (r *L3extRsLblToProfileResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_relation_to_route_control_profile") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *L3extRsLblToProfileResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + setL3extRsLblToProfileId(ctx, stateData) + getAndSetL3extRsLblToProfileAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *L3extRsLblToProfileResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setL3extRsLblToProfileId(ctx, data) + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_route_control_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToProfileResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagL3extRsLblToProfileResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getL3extRsLblToProfileCreateJsonPayload(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 + } + + getAndSetL3extRsLblToProfileAttributes(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_route_control_profile with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToProfileResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_relation_to_route_control_profile") + var data *L3extRsLblToProfileResourceModel + + // 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_route_control_profile with id '%s'", data.Id.ValueString())) + + getAndSetL3extRsLblToProfileAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *L3extRsLblToProfileResourceModel + 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_route_control_profile with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToProfileResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_relation_to_route_control_profile") + var data *L3extRsLblToProfileResourceModel + var stateData *L3extRsLblToProfileResourceModel + + // 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_route_control_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToProfileResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagL3extRsLblToProfileResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getL3extRsLblToProfileCreateJsonPayload(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 + } + + getAndSetL3extRsLblToProfileAttributes(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_route_control_profile with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToProfileResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_relation_to_route_control_profile") + var data *L3extRsLblToProfileResourceModel + + // 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_route_control_profile with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "l3extRsLblToProfile", 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_route_control_profile with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToProfileResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_relation_to_route_control_profile") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *L3extRsLblToProfileResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_relation_to_route_control_profile with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_relation_to_route_control_profile") +} + +func getAndSetL3extRsLblToProfileAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *L3extRsLblToProfileResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "l3extRsLblToProfile,tagAnnotation,tagTag"), "GET", nil) + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("l3extRsLblToProfile").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("l3extRsLblToProfile").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)) + setL3extRsLblToProfileParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "direction" { + data.Direction = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "tDn" { + data.TDn = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationL3extRsLblToProfileList := make([]TagAnnotationL3extRsLblToProfileResourceModel, 0) + TagTagL3extRsLblToProfileList := make([]TagTagL3extRsLblToProfileResourceModel, 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" { + TagAnnotationL3extRsLblToProfile := TagAnnotationL3extRsLblToProfileResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationL3extRsLblToProfile.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationL3extRsLblToProfile.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationL3extRsLblToProfileList = append(TagAnnotationL3extRsLblToProfileList, TagAnnotationL3extRsLblToProfile) + } + if childClassName == "tagTag" { + TagTagL3extRsLblToProfile := TagTagL3extRsLblToProfileResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagL3extRsLblToProfile.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagL3extRsLblToProfile.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagL3extRsLblToProfileList = append(TagTagL3extRsLblToProfileList, TagTagL3extRsLblToProfile) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationL3extRsLblToProfileList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagL3extRsLblToProfileList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'l3extRsLblToProfile'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getL3extRsLblToProfileRn(ctx context.Context, data *L3extRsLblToProfileResourceModel) string { + rn := "rslblToProfile-[{tDn}]-{direction}" + for _, identifier := range []string{"tDn", "direction"} { + 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 setL3extRsLblToProfileParentDn(ctx context.Context, dn string, data *L3extRsLblToProfileResourceModel) { + 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 setL3extRsLblToProfileId(ctx context.Context, data *L3extRsLblToProfileResourceModel) { + rn := getL3extRsLblToProfileRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getL3extRsLblToProfileTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extRsLblToProfileResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToProfileResourceModel) []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 getL3extRsLblToProfileTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extRsLblToProfileResourceModel, tagTagPlan, tagTagState []TagTagL3extRsLblToProfileResourceModel) []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 getL3extRsLblToProfileCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extRsLblToProfileResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToProfileResourceModel, tagTagPlan, tagTagState []TagTagL3extRsLblToProfileResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getL3extRsLblToProfileTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getL3extRsLblToProfileTagTagChildPayloads(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.Direction.IsNull() && !data.Direction.IsUnknown() { + payloadMap["attributes"].(map[string]string)["direction"] = data.Direction.ValueString() + } + if !data.TDn.IsNull() && !data.TDn.IsUnknown() { + payloadMap["attributes"].(map[string]string)["tDn"] = data.TDn.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"l3extRsLblToProfile": 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_route_control_profile_test.go b/internal/provider/resource_aci_relation_to_route_control_profile_test.go new file mode 100644 index 000000000..567178750 --- /dev/null +++ b/internal/provider/resource_aci_relation_to_route_control_profile_test.go @@ -0,0 +1,238 @@ +// 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 TestAccResourceL3extRsLblToProfileWithL3extConsLbl(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: testConfigL3extRsLblToProfileMinDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-test_rctp"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "direction", "import"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigL3extRsLblToProfileAllDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-test_rctp"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "direction", "export"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigL3extRsLblToProfileMinDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-test_rctp"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigL3extRsLblToProfileResetDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-test_rctp"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + ), + }, + // Import testing + { + ResourceName: "aci_relation_to_route_control_profile.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-test_rctp"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + ), + }, + // Update with children + { + Config: testConfigL3extRsLblToProfileChildrenDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-test_rctp"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.1.value", "value_2"), + ), + }, + // Import testing with children + { + ResourceName: "aci_relation_to_route_control_profile.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-test_rctp"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.1.value", "value_2"), + ), + }, + // Update with children removed from config + { + Config: testConfigL3extRsLblToProfileChildrenRemoveFromConfigDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigL3extRsLblToProfileChildrenRemoveOneDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigL3extRsLblToProfileChildrenRemoveAllDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_relation_to_route_control_profile.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigL3extRsLblToProfileMinDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = aci_route_control_profile.test.id +} +` + +const testConfigL3extRsLblToProfileAllDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_route_control_profile.test.id + annotation = "annotation" + direction = "export" +} +` + +const testConfigL3extRsLblToProfileResetDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = aci_route_control_profile.test.id + annotation = "orchestrator:terraform" + direction = "import" +} +` +const testConfigL3extRsLblToProfileChildrenDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = aci_route_control_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 testConfigL3extRsLblToProfileChildrenRemoveFromConfigDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = aci_route_control_profile.test.id +} +` + +const testConfigL3extRsLblToProfileChildrenRemoveOneDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = aci_route_control_profile.test.id + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigL3extRsLblToProfileChildrenRemoveAllDependencyWithL3extConsLbl = testConfigL3extConsLblMinDependencyWithFvTenant + ` +resource "aci_relation_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = aci_route_control_profile.test.id + annotations = [] + tags = [] +} +` diff --git a/internal/provider/test_constants.go b/internal/provider/test_constants.go index 1d7a7a19d..0933f6c7e 100644 --- a/internal/provider/test_constants.go +++ b/internal/provider/test_constants.go @@ -72,6 +72,10 @@ resource "aci_l3_outside" "test" { ` const testConfigL3extConsLblMinDependencyWithFvTenant = testConfigL3extOutMin + ` +resource "aci_route_control_profile" "test" { + parent_dn = aci_tenant.test.id + name = "test_rctp" +} resource "aci_external_network_instance_profile" "test" { l3_outside_dn = aci_l3_outside.test.id name = "testInstP"