diff --git a/docs/data-sources/l3out_consumer_label.md b/docs/data-sources/l3out_consumer_label.md index 2278fdade..5c46d01e6 100644 --- a/docs/data-sources/l3out_consumer_label.md +++ b/docs/data-sources/l3out_consumer_label.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_l3out_consumer_label" sidebar_current: "docs-aci-data-source-aci_l3out_consumer_label" description: |- - Data source for ACI L3out Consumer Label + Data source for ACI L3Out Consumer Label --- # aci_l3out_consumer_label # -Data source for ACI L3out Consumer Label +Data source for ACI L3Out Consumer Label ## API Information ## @@ -45,19 +45,28 @@ data "aci_l3out_consumer_label" "example_l3_outside" { * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - [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)) -* `name` (name) - (string) The name of the L3out Consumer Label object. +* `name` (name) - (string) The name of the L3Out Consumer Label object. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the L3out Consumer Label object. -* `annotation` (annotation) - (string) The annotation of the L3out Consumer Label object. -* `description` (descr) - (string) The description of the L3out Consumer Label object. -* `name_alias` (nameAlias) - (string) The name alias of the L3out Consumer Label object. -* `owner` (owner) - (string) The owner of the L3out Consumer Label object. +* `id` - (string) The distinguished name (DN) of the L3Out Consumer Label object. +* `annotation` (annotation) - (string) The annotation of the L3Out Consumer Label object. +* `description` (descr) - (string) The description of the L3Out Consumer Label object. +* `name_alias` (nameAlias) - (string) The name alias of the L3Out Consumer Label object. +* `owner` (owner) - (string) The owner of the L3Out Consumer Label object. * `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. * `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. * `tag` (tag) - (string) Specifies the color of a policy label. +* `relation_to_external_epgs` - (list) A list of Relation From L3Out Consumer Label To External EPGs (ACI object [l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview)) pointing to External EPG (ACI Object [l3extInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extInstP/overview)). This attribute is supported in ACI versions: 5.0(1k) and later. + * `annotation` (annotation) - (string) The annotation of the Relation From L3Out Consumer Label To External EPG object. + * `target_dn` (tDn) - (string) The distinguished name (DN) of the External EPG object. + +* `relation_to_route_control_profiles` - (list) A list of Relation From L3Out Consumer Label 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 From L3Out Consumer Label To Route Control Profile object. + * `direction` (direction) - (string) The connector direction. + * `target_dn` (tDn) - (string) The distinguished name (DN) 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/l3out_node_sid_profile.md b/docs/data-sources/l3out_node_sid_profile.md index cda1d03a0..d70e24e06 100644 --- a/docs/data-sources/l3out_node_sid_profile.md +++ b/docs/data-sources/l3out_node_sid_profile.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_l3out_node_sid_profile" sidebar_current: "docs-aci-data-source-aci_l3out_node_sid_profile" description: |- - Data source for ACI L3out Node SR-MPLS Segment ID Profile + Data source for ACI L3Out Node SR-MPLS Segment ID Profile --- # aci_l3out_node_sid_profile # -Data source for ACI L3out Node SR-MPLS Segment ID Profile +Data source for ACI L3Out Node SR-MPLS Segment ID Profile ## API Information ## @@ -43,16 +43,16 @@ data "aci_l3out_node_sid_profile" "example_l3out_loopback_interface_profile" { * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) -* `segment_id` (sidoffset) - (string) The segment ID of the L3out Node SR-MPLS Segment ID Profile object. +* `segment_id` (sidoffset) - (string) The segment ID of the L3Out Node SR-MPLS Segment ID Profile object. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the L3out Node SR-MPLS Segment ID Profile object. -* `annotation` (annotation) - (string) The annotation of the L3out Node SR-MPLS Segment ID Profile object. -* `description` (descr) - (string) The description of the L3out Node SR-MPLS Segment ID Profile object. -* `loopback_address` (loopbackAddr) - (string) The loopback address of the L3out Node SR-MPLS Segment ID Profile object. -* `name` (name) - (string) The name of the L3out Node SR-MPLS Segment ID Profile object. -* `name_alias` (nameAlias) - (string) The name alias of the L3out Node SR-MPLS Segment ID Profile object. +* `id` - (string) The distinguished name (DN) of the L3Out Node SR-MPLS Segment ID Profile object. +* `annotation` (annotation) - (string) The annotation of the L3Out Node SR-MPLS Segment ID Profile object. +* `description` (descr) - (string) The description of the L3Out Node SR-MPLS Segment ID Profile object. +* `loopback_address` (loopbackAddr) - (string) The loopback address of the L3Out Node SR-MPLS Segment ID Profile object. +* `name` (name) - (string) The name of the L3Out Node SR-MPLS Segment ID Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the L3Out Node SR-MPLS Segment ID 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. diff --git a/docs/data-sources/l3out_provider_label.md b/docs/data-sources/l3out_provider_label.md index ba0e6f47b..83edbf76b 100644 --- a/docs/data-sources/l3out_provider_label.md +++ b/docs/data-sources/l3out_provider_label.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_l3out_provider_label" sidebar_current: "docs-aci-data-source-aci_l3out_provider_label" description: |- - Data source for ACI L3out Provider Label + Data source for ACI L3Out Provider Label --- # aci_l3out_provider_label # -Data source for ACI L3out Provider Label +Data source for ACI L3Out Provider Label ## API Information ## @@ -43,14 +43,14 @@ data "aci_l3out_provider_label" "example_l3_outside" { * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - [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)) -* `name` (name) - (string) The name of the L3out Provider Label object. +* `name` (name) - (string) The name of the L3Out Provider Label object. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the L3out Provider Label object. -* `annotation` (annotation) - (string) The annotation of the L3out Provider Label object. -* `description` (descr) - (string) The description of the L3out Provider Label object. -* `name_alias` (nameAlias) - (string) The name alias of the L3out Provider Label object. +* `id` - (string) The distinguished name (DN) of the L3Out Provider Label object. +* `annotation` (annotation) - (string) The annotation of the L3Out Provider Label object. +* `description` (descr) - (string) The description of the L3Out Provider Label object. +* `name_alias` (nameAlias) - (string) The name alias of the L3Out Provider Label object. * `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. * `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. * `tag` (tag) - (string) Specifies the color of a policy label. diff --git a/docs/data-sources/l3out_redistribute_policy.md b/docs/data-sources/l3out_redistribute_policy.md index 805b0d1de..c0bfda726 100644 --- a/docs/data-sources/l3out_redistribute_policy.md +++ b/docs/data-sources/l3out_redistribute_policy.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_l3out_redistribute_policy" sidebar_current: "docs-aci-data-source-aci_l3out_redistribute_policy" description: |- - Data source for ACI L3out Redistribute Policy + Data source for ACI L3Out Redistribute Policy --- # aci_l3out_redistribute_policy # -Data source for ACI L3out Redistribute Policy +Data source for ACI L3Out Redistribute Policy ## API Information ## @@ -44,14 +44,14 @@ data "aci_l3out_redistribute_policy" "example_l3_outside" { * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - [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)) -* `source` (src) - (string) The source of the L3out Redistribute Policy object. +* `source` (src) - (string) The source of the L3Out Redistribute Policy object. - Valid Values: `attached-host`, `direct`, `static`. * `route_control_profile_name` (tnRtctrlProfileName) - (string) The name of the Route Control Profile object. This attribute can be referenced from a [resource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) with `aci_route_control_profile.example.name` or from a [datasource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/data-sources/route_control_profile) with `data.aci_route_control_profile.example.name`. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the L3out Redistribute Policy object. -* `annotation` (annotation) - (string) The annotation of the L3out Redistribute Policy object. +* `id` - (string) The distinguished name (DN) of the L3Out Redistribute Policy object. +* `annotation` (annotation) - (string) The annotation of the L3Out Redistribute Policy 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. diff --git a/docs/data-sources/relation_from_l3out_consumer_label_to_external_epg.md b/docs/data-sources/relation_from_l3out_consumer_label_to_external_epg.md new file mode 100644 index 000000000..d0e4917ea --- /dev/null +++ b/docs/data-sources/relation_from_l3out_consumer_label_to_external_epg.md @@ -0,0 +1,62 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "L3Out" +layout: "aci" +page_title: "ACI: aci_relation_from_l3out_consumer_label_to_external_epg" +sidebar_current: "docs-aci-data-source-aci_relation_from_l3out_consumer_label_to_external_epg" +description: |- + Data source for ACI Relation From L3Out Consumer Label To External EPG +--- + +# aci_relation_from_l3out_consumer_label_to_external_epg # + +Data source for ACI Relation From L3Out Consumer Label To External EPG + +## API Information ## + +* Class: [l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview) + +* Supported in ACI versions: 5.0(1k) and later. + +* Distinguished Name Format: `uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]` + +## GUI Information ## + +* Location: `Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label` + +## Example Usage ## + +```hcl + +data "aci_relation_from_l3out_consumer_label_to_external_epg" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + target_dn = "uni/tn-example_tenant/out-example_l3_outside/instP-inst_profile_2" +} + +``` + +## 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 distinguished name (DN) of classes below can be used but currently there is no available resource for it: + - [l3extConsLblDef](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLblDef/overview) + +* `target_dn` (tDn) - (string) The distinguished name (DN) of the External EPG object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation From L3Out Consumer Label To External EPG object. +* `annotation` (annotation) - (string) The annotation of the Relation From L3Out Consumer Label To External EPG 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/relation_from_l3out_consumer_label_to_route_control_profile.md b/docs/data-sources/relation_from_l3out_consumer_label_to_route_control_profile.md new file mode 100644 index 000000000..7e296788c --- /dev/null +++ b/docs/data-sources/relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile" +sidebar_current: "docs-aci-data-source-aci_relation_from_l3out_consumer_label_to_route_control_profile" +description: |- + Data source for ACI Relation From L3Out Consumer Label To Route Control Profile +--- + +# aci_relation_from_l3out_consumer_label_to_route_control_profile # + +Data source for ACI Relation From L3Out Consumer Label 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_from_l3out_consumer_label_to_route_control_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + direction = "import" + target_dn = "uni/tn-example_tenant/prof-rt_ctrl_profile_2" +} + +``` + +## 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 distinguished 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 (DN) of the Route Control Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation From L3Out Consumer Label To Route Control Profile object. +* `annotation` (annotation) - (string) The annotation of the Relation From L3Out Consumer Label 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/resources/l3out_consumer_label.md b/docs/resources/l3out_consumer_label.md index a639e083a..168bcbe48 100644 --- a/docs/resources/l3out_consumer_label.md +++ b/docs/resources/l3out_consumer_label.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_l3out_consumer_label" sidebar_current: "docs-aci-resource-aci_l3out_consumer_label" description: |- - Manages ACI L3out Consumer Label + Manages ACI L3Out Consumer Label --- # aci_l3out_consumer_label # -Manages ACI L3out Consumer Label +Manages ACI L3Out Consumer Label @@ -32,7 +32,7 @@ Manages ACI L3out Consumer Label ## Example Usage ## -The configuration snippet below creates a L3out Consumer Label with only required attributes. +The configuration snippet below creates a L3Out Consumer Label with only required attributes. ```hcl @@ -42,7 +42,7 @@ resource "aci_l3out_consumer_label" "example_l3_outside" { } ``` -The configuration snippet below shows all possible attributes of the L3out Consumer Label. +The configuration snippet below shows all possible attributes of the L3Out Consumer Label. !> This example might not be valid configuration and is only used to show all possible attributes. @@ -58,6 +58,19 @@ resource "aci_l3out_consumer_label" "full_example_l3_outside" { owner_key = "owner_key_1" owner_tag = "owner_tag_1" tag = "lemon-chiffon" + relation_to_external_epgs = [ + { + annotation = "annotation_1" + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + } + ] + relation_to_route_control_profiles = [ + { + annotation = "annotation_1" + direction = "export" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + } + ] annotations = [ { key = "key_0" @@ -74,7 +87,7 @@ resource "aci_l3out_consumer_label" "full_example_l3_outside" { ``` -All examples for the L3out Consumer Label resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_consumer_label) folder. +All examples for the L3Out Consumer Label resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_consumer_label) folder. ## Schema ## @@ -82,19 +95,19 @@ All examples for the L3out Consumer Label resource can be found in the [examples * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - [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)) -* `name` (name) - (string) The name of the L3out Consumer Label object. +* `name` (name) - (string) The name of the L3Out Consumer Label object. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the L3out Consumer Label object. +* `id` - (string) The distinguished name (DN) of the L3Out Consumer Label object. ### Optional ### -* `annotation` (annotation) - (string) The annotation of the L3out Consumer Label object. +* `annotation` (annotation) - (string) The annotation of the L3Out Consumer Label object. - Default: `orchestrator:terraform` -* `description` (descr) - (string) The description of the L3out Consumer Label object. -* `name_alias` (nameAlias) - (string) The name alias of the L3out Consumer Label object. -* `owner` (owner) - (string) The owner of the L3out Consumer Label object. +* `description` (descr) - (string) The description of the L3Out Consumer Label object. +* `name_alias` (nameAlias) - (string) The name alias of the L3Out Consumer Label object. +* `owner` (owner) - (string) The owner of the L3Out Consumer Label object. - Default: `infra` - Valid Values: `infra`, `tenant`. * `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. @@ -102,6 +115,29 @@ All examples for the L3out Consumer Label resource can be found in the [examples * `tag` (tag) - (string) Specifies the color of a policy label. - Valid Values: `alice-blue`, `antique-white`, `aqua`, `aquamarine`, `azure`, `beige`, `bisque`, `black`, `blanched-almond`, `blue`, `blue-violet`, `brown`, `burlywood`, `cadet-blue`, `chartreuse`, `chocolate`, `coral`, `cornflower-blue`, `cornsilk`, `crimson`, `cyan`, `dark-blue`, `dark-cyan`, `dark-goldenrod`, `dark-gray`, `dark-green`, `dark-khaki`, `dark-magenta`, `dark-olive-green`, `dark-orange`, `dark-orchid`, `dark-red`, `dark-salmon`, `dark-sea-green`, `dark-slate-blue`, `dark-slate-gray`, `dark-turquoise`, `dark-violet`, `deep-pink`, `deep-sky-blue`, `dim-gray`, `dodger-blue`, `fire-brick`, `floral-white`, `forest-green`, `fuchsia`, `gainsboro`, `ghost-white`, `gold`, `goldenrod`, `gray`, `green`, `green-yellow`, `honeydew`, `hot-pink`, `indian-red`, `indigo`, `ivory`, `khaki`, `lavender`, `lavender-blush`, `lawn-green`, `lemon-chiffon`, `light-blue`, `light-coral`, `light-cyan`, `light-goldenrod-yellow`, `light-gray`, `light-green`, `light-pink`, `light-salmon`, `light-sea-green`, `light-sky-blue`, `light-slate-gray`, `light-steel-blue`, `light-yellow`, `lime`, `lime-green`, `linen`, `magenta`, `maroon`, `medium-aquamarine`, `medium-blue`, `medium-orchid`, `medium-purple`, `medium-sea-green`, `medium-slate-blue`, `medium-spring-green`, `medium-turquoise`, `medium-violet-red`, `midnight-blue`, `mint-cream`, `misty-rose`, `moccasin`, `navajo-white`, `navy`, `old-lace`, `olive`, `olive-drab`, `orange`, `orange-red`, `orchid`, `pale-goldenrod`, `pale-green`, `pale-turquoise`, `pale-violet-red`, `papaya-whip`, `peachpuff`, `peru`, `pink`, `plum`, `powder-blue`, `purple`, `red`, `rosy-brown`, `royal-blue`, `saddle-brown`, `salmon`, `sandy-brown`, `sea-green`, `seashell`, `sienna`, `silver`, `sky-blue`, `slate-blue`, `slate-gray`, `snow`, `spring-green`, `steel-blue`, `tan`, `teal`, `thistle`, `tomato`, `turquoise`, `violet`, `wheat`, `white`, `white-smoke`, `yellow`, `yellow-green`. +* `relation_to_external_epgs` - (list) A list of Relation From L3Out Consumer Label To External EPGs (ACI object [l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview)) pointing to External EPG (ACI Object [l3extInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extInstP/overview)) which can be configured using the [aci_external_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_network_instance_profile) resource. This attribute is supported in ACI versions: 5.0(1k) and later. + + #### Required #### + + * `target_dn` (tDn) - (string) The distinguished name (DN) of the External EPG object. + + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation From L3Out Consumer Label To External EPG object. + - Default: `orchestrator:terraform` + +* `relation_to_route_control_profiles` - (list) A list of Relation From L3Out Consumer Label 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 (DN) of the Route Control Profile object. + + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation From L3Out Consumer Label 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 #### @@ -118,13 +154,13 @@ All examples for the L3out Consumer Label resource can be found in the [examples ## Importing -An existing L3out Consumer Label can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: +An existing L3Out Consumer Label 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_l3out_consumer_label.example_l3_outside uni/tn-{name}/out-{name}/conslbl-{name} ``` -Starting in Terraform version 1.5, an existing L3out Consumer Label can be imported +Starting in Terraform version 1.5, an existing L3Out Consumer Label can be imported using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: ``` diff --git a/docs/resources/l3out_node_sid_profile.md b/docs/resources/l3out_node_sid_profile.md index 79adbbe27..b31d485c1 100644 --- a/docs/resources/l3out_node_sid_profile.md +++ b/docs/resources/l3out_node_sid_profile.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_l3out_node_sid_profile" sidebar_current: "docs-aci-resource-aci_l3out_node_sid_profile" description: |- - Manages ACI L3out Node SR-MPLS Segment ID Profile + Manages ACI L3Out Node SR-MPLS Segment ID Profile --- # aci_l3out_node_sid_profile # -Manages ACI L3out Node SR-MPLS Segment ID Profile +Manages ACI L3Out Node SR-MPLS Segment ID Profile @@ -30,7 +30,7 @@ Manages ACI L3out Node SR-MPLS Segment ID Profile ## Example Usage ## -The configuration snippet below creates a L3out Node SR-MPLS Segment ID Profile with only required attributes. +The configuration snippet below creates a L3Out Node SR-MPLS Segment ID Profile with only required attributes. ```hcl @@ -40,7 +40,7 @@ resource "aci_l3out_node_sid_profile" "example_l3out_loopback_interface_profile" } ``` -The configuration snippet below shows all possible attributes of the L3out Node SR-MPLS Segment ID Profile. +The configuration snippet below shows all possible attributes of the L3Out Node SR-MPLS Segment ID Profile. !> This example might not be valid configuration and is only used to show all possible attributes. @@ -70,7 +70,7 @@ resource "aci_l3out_node_sid_profile" "full_example_l3out_loopback_interface_pro ``` -All examples for the L3out Node SR-MPLS Segment ID Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_node_sid_profile) folder. +All examples for the L3Out Node SR-MPLS Segment ID Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_node_sid_profile) folder. ## Schema ## @@ -78,20 +78,20 @@ All examples for the L3out Node SR-MPLS Segment ID Profile resource can be found * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) -* `segment_id` (sidoffset) - (string) The segment ID of the L3out Node SR-MPLS Segment ID Profile object. +* `segment_id` (sidoffset) - (string) The segment ID of the L3Out Node SR-MPLS Segment ID Profile object. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the L3out Node SR-MPLS Segment ID Profile object. +* `id` - (string) The distinguished name (DN) of the L3Out Node SR-MPLS Segment ID Profile object. ### Optional ### -* `annotation` (annotation) - (string) The annotation of the L3out Node SR-MPLS Segment ID Profile object. +* `annotation` (annotation) - (string) The annotation of the L3Out Node SR-MPLS Segment ID Profile object. - Default: `orchestrator:terraform` -* `description` (descr) - (string) The description of the L3out Node SR-MPLS Segment ID Profile object. -* `loopback_address` (loopbackAddr) - (string) The loopback address of the L3out Node SR-MPLS Segment ID Profile object. -* `name` (name) - (string) The name of the L3out Node SR-MPLS Segment ID Profile object. -* `name_alias` (nameAlias) - (string) The name alias of the L3out Node SR-MPLS Segment ID Profile object. +* `description` (descr) - (string) The description of the L3Out Node SR-MPLS Segment ID Profile object. +* `loopback_address` (loopbackAddr) - (string) The loopback address of the L3Out Node SR-MPLS Segment ID Profile object. +* `name` (name) - (string) The name of the L3Out Node SR-MPLS Segment ID Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the L3Out Node SR-MPLS Segment ID 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)). 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. @@ -109,13 +109,13 @@ All examples for the L3out Node SR-MPLS Segment ID Profile resource can be found ## Importing -An existing L3out Node SR-MPLS Segment ID Profile can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: +An existing L3Out Node SR-MPLS Segment ID 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_l3out_node_sid_profile.example_l3out_loopback_interface_profile uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/lbp-[{addr}]/nodesidp-{sidoffset} ``` -Starting in Terraform version 1.5, an existing L3out Node SR-MPLS Segment ID Profile can be imported +Starting in Terraform version 1.5, an existing L3Out Node SR-MPLS Segment ID Profile can be imported using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: ``` diff --git a/docs/resources/l3out_provider_label.md b/docs/resources/l3out_provider_label.md index 0764d94f3..f38ba077f 100644 --- a/docs/resources/l3out_provider_label.md +++ b/docs/resources/l3out_provider_label.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_l3out_provider_label" sidebar_current: "docs-aci-resource-aci_l3out_provider_label" description: |- - Manages ACI L3out Provider Label + Manages ACI L3Out Provider Label --- # aci_l3out_provider_label # -Manages ACI L3out Provider Label +Manages ACI L3Out Provider Label @@ -30,7 +30,7 @@ Manages ACI L3out Provider Label ## Example Usage ## -The configuration snippet below creates a L3out Provider Label with only required attributes. +The configuration snippet below creates a L3Out Provider Label with only required attributes. ```hcl @@ -40,7 +40,7 @@ resource "aci_l3out_provider_label" "example_l3_outside" { } ``` -The configuration snippet below shows all possible attributes of the L3out Provider Label. +The configuration snippet below shows all possible attributes of the L3Out Provider Label. !> This example might not be valid configuration and is only used to show all possible attributes. @@ -71,7 +71,7 @@ resource "aci_l3out_provider_label" "full_example_l3_outside" { ``` -All examples for the L3out Provider Label resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_provider_label) folder. +All examples for the L3Out Provider Label resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_provider_label) folder. ## Schema ## @@ -79,18 +79,18 @@ All examples for the L3out Provider Label resource can be found in the [examples * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - [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)) -* `name` (name) - (string) The name of the L3out Provider Label object. +* `name` (name) - (string) The name of the L3Out Provider Label object. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the L3out Provider Label object. +* `id` - (string) The distinguished name (DN) of the L3Out Provider Label object. ### Optional ### -* `annotation` (annotation) - (string) The annotation of the L3out Provider Label object. +* `annotation` (annotation) - (string) The annotation of the L3Out Provider Label object. - Default: `orchestrator:terraform` -* `description` (descr) - (string) The description of the L3out Provider Label object. -* `name_alias` (nameAlias) - (string) The name alias of the L3out Provider Label object. +* `description` (descr) - (string) The description of the L3Out Provider Label object. +* `name_alias` (nameAlias) - (string) The name alias of the L3Out Provider Label object. * `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. * `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. * `tag` (tag) - (string) Specifies the color of a policy label. @@ -112,13 +112,13 @@ All examples for the L3out Provider Label resource can be found in the [examples ## Importing -An existing L3out Provider Label can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: +An existing L3Out Provider Label 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_l3out_provider_label.example_l3_outside uni/tn-{name}/out-{name}/provlbl-{name} ``` -Starting in Terraform version 1.5, an existing L3out Provider Label can be imported +Starting in Terraform version 1.5, an existing L3Out Provider Label can be imported using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: ``` diff --git a/docs/resources/l3out_redistribute_policy.md b/docs/resources/l3out_redistribute_policy.md index 270843a8b..a9e636ac4 100644 --- a/docs/resources/l3out_redistribute_policy.md +++ b/docs/resources/l3out_redistribute_policy.md @@ -7,12 +7,12 @@ layout: "aci" page_title: "ACI: aci_l3out_redistribute_policy" sidebar_current: "docs-aci-resource-aci_l3out_redistribute_policy" description: |- - Manages ACI L3out Redistribute Policy + Manages ACI L3Out Redistribute Policy --- # aci_l3out_redistribute_policy # -Manages ACI L3out Redistribute Policy +Manages ACI L3Out Redistribute Policy @@ -30,7 +30,7 @@ Manages ACI L3out Redistribute Policy ## Example Usage ## -The configuration snippet below creates a L3out Redistribute Policy with only required attributes. +The configuration snippet below creates a L3Out Redistribute Policy with only required attributes. ```hcl @@ -41,7 +41,7 @@ resource "aci_l3out_redistribute_policy" "example_l3_outside" { } ``` -The configuration snippet below shows all possible attributes of the L3out Redistribute Policy. +The configuration snippet below shows all possible attributes of the L3Out Redistribute Policy. !> This example might not be valid configuration and is only used to show all possible attributes. @@ -68,7 +68,7 @@ resource "aci_l3out_redistribute_policy" "full_example_l3_outside" { ``` -All examples for the L3out Redistribute Policy resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_redistribute_policy) folder. +All examples for the L3Out Redistribute Policy resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_redistribute_policy) folder. ## Schema ## @@ -76,17 +76,17 @@ All examples for the L3out Redistribute Policy resource can be found in the [exa * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: - [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)) -* `source` (src) - (string) The source of the L3out Redistribute Policy object. +* `source` (src) - (string) The source of the L3Out Redistribute Policy object. - Valid Values: `attached-host`, `direct`, `static`. * `route_control_profile_name` (tnRtctrlProfileName) - (string) The name of the Route Control Profile object. This attribute can be referenced from a [resource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) with `aci_route_control_profile.example.name` or from a [datasource](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/data-sources/route_control_profile) with `data.aci_route_control_profile.example.name`. ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the L3out Redistribute Policy object. +* `id` - (string) The distinguished name (DN) of the L3Out Redistribute Policy object. ### Optional ### -* `annotation` (annotation) - (string) The annotation of the L3out Redistribute Policy object. +* `annotation` (annotation) - (string) The annotation of the L3Out Redistribute Policy 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. @@ -105,13 +105,13 @@ All examples for the L3out Redistribute Policy resource can be found in the [exa ## Importing -An existing L3out Redistribute Policy can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: +An existing L3Out Redistribute Policy 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_l3out_redistribute_policy.example_l3_outside uni/tn-{name}/out-{name}/rsredistributePol-[{tnRtctrlProfileName}]-{src} ``` -Starting in Terraform version 1.5, an existing L3out Redistribute Policy can be imported +Starting in Terraform version 1.5, an existing L3Out Redistribute Policy can be imported using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: ``` diff --git a/docs/resources/relation_from_l3out_consumer_label_to_external_epg.md b/docs/resources/relation_from_l3out_consumer_label_to_external_epg.md new file mode 100644 index 000000000..68255e094 --- /dev/null +++ b/docs/resources/relation_from_l3out_consumer_label_to_external_epg.md @@ -0,0 +1,122 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "L3Out" +layout: "aci" +page_title: "ACI: aci_relation_from_l3out_consumer_label_to_external_epg" +sidebar_current: "docs-aci-resource-aci_relation_from_l3out_consumer_label_to_external_epg" +description: |- + Manages ACI Relation From L3Out Consumer Label To External EPG +--- + +# aci_relation_from_l3out_consumer_label_to_external_epg # + +Manages ACI Relation From L3Out Consumer Label To External EPG + + -> This resource should not be used in combination with the `l3out_consumer_label` nested attributes of other resources for the same object. Doing so will result in unexpected behaviour. + + +## API Information ## + +* Class: [l3extRsLblToInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsLblToInstP/overview) + +* Supported in ACI versions: 5.0(1k) and later. + +* Distinguished Name Format: `uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]` + +## GUI Information ## + +* Location: `Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label` + +## Example Usage ## + +The configuration snippet below creates a Relation From L3Out Consumer Label To External EPG with only required attributes. + +```hcl + +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + target_dn = "uni/tn-example_tenant/out-example_l3_outside/instP-inst_profile_2" +} + +``` +The configuration snippet below shows all possible attributes of the Relation From L3Out Consumer Label To External EPG. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "full_example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + annotation = "annotation" + target_dn = "uni/tn-example_tenant/out-example_l3_outside/instP-inst_profile_2" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Relation From L3Out Consumer Label To External EPG resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg) 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 distinguished name (DN) of classes below can be used but currently there is no available resource for it: + - [l3extConsLblDef](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLblDef/overview) + +* `target_dn` (tDn) - (string) The distinguished name (DN) of the External EPG object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation From L3Out Consumer Label To External EPG object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Relation From L3Out Consumer Label To External EPG 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 From L3Out Consumer Label To External EPG 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_from_l3out_consumer_label_to_external_epg.example_l3out_consumer_label uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}] +``` + +Starting in Terraform version 1.5, an existing Relation From L3Out Consumer Label To External EPG can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]" + to = aci_relation_from_l3out_consumer_label_to_external_epg.example_l3out_consumer_label +} +``` diff --git a/docs/resources/relation_from_l3out_consumer_label_to_route_control_profile.md b/docs/resources/relation_from_l3out_consumer_label_to_route_control_profile.md new file mode 100644 index 000000000..54910faa9 --- /dev/null +++ b/docs/resources/relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile" +sidebar_current: "docs-aci-resource-aci_relation_from_l3out_consumer_label_to_route_control_profile" +description: |- + Manages ACI Relation From L3Out Consumer Label To Route Control Profile +--- + +# aci_relation_from_l3out_consumer_label_to_route_control_profile # + +Manages ACI Relation From L3Out Consumer Label 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 From L3Out Consumer Label To Route Control Profile with only required attributes. + +```hcl + +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + direction = "import" + target_dn = "uni/tn-example_tenant/prof-rt_ctrl_profile_2" +} + +``` +The configuration snippet below shows all possible attributes of the Relation From L3Out Consumer Label To Route Control Profile. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "full_example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + annotation = "annotation" + direction = "import" + target_dn = "uni/tn-example_tenant/prof-rt_ctrl_profile_2" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Relation From L3Out Consumer Label To Route Control Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_relation_from_l3out_consumer_label_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 distinguished 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 (DN) of the Route Control Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Relation From L3Out Consumer Label To Route Control Profile object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Relation From L3Out Consumer Label 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 From L3Out Consumer Label 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_from_l3out_consumer_label_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 From L3Out Consumer Label 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_from_l3out_consumer_label_to_route_control_profile.example_l3out_consumer_label +} +``` diff --git a/examples/data-sources/aci_relation_from_l3out_consumer_label_to_external_epg/data-source.tf b/examples/data-sources/aci_relation_from_l3out_consumer_label_to_external_epg/data-source.tf new file mode 100644 index 000000000..bc82dfd56 --- /dev/null +++ b/examples/data-sources/aci_relation_from_l3out_consumer_label_to_external_epg/data-source.tf @@ -0,0 +1,5 @@ + +data "aci_relation_from_l3out_consumer_label_to_external_epg" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + target_dn = "uni/tn-example_tenant/out-example_l3_outside/instP-inst_profile_2" +} diff --git a/examples/data-sources/aci_relation_from_l3out_consumer_label_to_external_epg/provider.tf b/examples/data-sources/aci_relation_from_l3out_consumer_label_to_external_epg/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_relation_from_l3out_consumer_label_to_external_epg/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/data-sources/aci_relation_from_l3out_consumer_label_to_route_control_profile/data-source.tf b/examples/data-sources/aci_relation_from_l3out_consumer_label_to_route_control_profile/data-source.tf new file mode 100644 index 000000000..5844fb1f3 --- /dev/null +++ b/examples/data-sources/aci_relation_from_l3out_consumer_label_to_route_control_profile/data-source.tf @@ -0,0 +1,6 @@ + +data "aci_relation_from_l3out_consumer_label_to_route_control_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + direction = "import" + target_dn = "uni/tn-example_tenant/prof-rt_ctrl_profile_2" +} diff --git a/examples/data-sources/aci_relation_from_l3out_consumer_label_to_route_control_profile/provider.tf b/examples/data-sources/aci_relation_from_l3out_consumer_label_to_route_control_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_relation_from_l3out_consumer_label_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 2f429d7b9..b77165538 100644 --- a/examples/resources/aci_l3out_consumer_label/resource-all-attributes.tf +++ b/examples/resources/aci_l3out_consumer_label/resource-all-attributes.tf @@ -9,6 +9,19 @@ resource "aci_l3out_consumer_label" "full_example_l3_outside" { owner_key = "owner_key_1" owner_tag = "owner_tag_1" tag = "lemon-chiffon" + relation_to_external_epgs = [ + { + annotation = "annotation_1" + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + } + ] + relation_to_route_control_profiles = [ + { + annotation = "annotation_1" + direction = "export" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + } + ] annotations = [ { key = "key_0" diff --git a/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg/provider.tf b/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg/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_from_l3out_consumer_label_to_external_epg/resource-all-attributes.tf b/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg/resource-all-attributes.tf new file mode 100644 index 000000000..dbc4780d1 --- /dev/null +++ b/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg/resource-all-attributes.tf @@ -0,0 +1,18 @@ + +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "full_example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + annotation = "annotation" + target_dn = "uni/tn-example_tenant/out-example_l3_outside/instP-inst_profile_2" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg/resource.tf b/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg/resource.tf new file mode 100644 index 000000000..0410dae13 --- /dev/null +++ b/examples/resources/aci_relation_from_l3out_consumer_label_to_external_epg/resource.tf @@ -0,0 +1,5 @@ + +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + target_dn = "uni/tn-example_tenant/out-example_l3_outside/instP-inst_profile_2" +} diff --git a/examples/resources/aci_relation_from_l3out_consumer_label_to_route_control_profile/provider.tf b/examples/resources/aci_relation_from_l3out_consumer_label_to_route_control_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile/resource-all-attributes.tf b/examples/resources/aci_relation_from_l3out_consumer_label_to_route_control_profile/resource-all-attributes.tf new file mode 100644 index 000000000..8c133694a --- /dev/null +++ b/examples/resources/aci_relation_from_l3out_consumer_label_to_route_control_profile/resource-all-attributes.tf @@ -0,0 +1,19 @@ + +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "full_example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + annotation = "annotation" + direction = "import" + target_dn = "uni/tn-example_tenant/prof-rt_ctrl_profile_2" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_relation_from_l3out_consumer_label_to_route_control_profile/resource.tf b/examples/resources/aci_relation_from_l3out_consumer_label_to_route_control_profile/resource.tf new file mode 100644 index 000000000..6cee78495 --- /dev/null +++ b/examples/resources/aci_relation_from_l3out_consumer_label_to_route_control_profile/resource.tf @@ -0,0 +1,6 @@ + +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "example_l3out_consumer_label" { + parent_dn = aci_l3out_consumer_label.example.id + direction = "import" + target_dn = "uni/tn-example_tenant/prof-rt_ctrl_profile_2" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index a2f4d5821..5a4b48ec7 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -59,7 +59,7 @@ fvAEPg: fvRsNodeAtt: relation_fv_rs_node_att: relation_to_static_leafs node_dn: relation_to_static_leafs.target_dn - encap: relation_to_static_leafs.encapsulation + encap: relation_to_static_leafs.encapsulation description: relation_to_static_leafs.description deployment_immediacy: relation_to_static_leafs.deployment_immediacy mode: relation_to_static_leafs.mode @@ -153,6 +153,7 @@ mgmtInB: resource_name: "node_mgmt_epg" rtctrlProfile: + resource_name: "route_control_profile" ui_locations: - "Tenants -> Networking -> L3Outs -> Route map for import and export Route Control" - "Tenants -> Policies -> Protocol -> Route Maps for Route Control" @@ -594,3 +595,23 @@ infraRsPathToAccBaseGrp: - "Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Overrides" sub_category: "Access Policies" resource_name: "relation_to_access_interface_policy_group" + +l3extRsLblToInstP: + resource_name: "relation_from_l3out_consumer_label_to_external_epg" + ui_locations: + - "Tenants -> Networking -> L3Outs -> Policy -> Main -> Consumer Label" + sub_category: "L3Out" + dn_formats: + - "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]" + 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_from_l3out_consumer_label_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}" + 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 e0b4ba1c6..159e3c113 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -47,9 +47,16 @@ global: Ip: "IP" Ad: "AD" Esg: "ESG" + "External Network Instance Profile": "External EPG" + L3out: L3Out ignores: - "userdom" +resource_name_overwrite: + relation_from_l3out_consumer_label_to_external_epg: "external_network_instance_profile" + relation_to_external_epgs: "external_network_instance_profile" + relation_from_l3out_consumer_label_to_route_control_profile: "route_control_profile" + l3extRsRedistributePol: overwrites: src: "source" @@ -956,7 +963,7 @@ infraRsHPathAtt: target_dn: "topology/pod-1/paths-101/pathep-[eth1/1]" relation_resource_name: "host_path" static: true - + infraRsPathToAccBaseGrp: parents: - class_name: "infraHPathS" @@ -968,3 +975,62 @@ infraRsPathToAccBaseGrp: relation_resource_name: "access_interface_policy_group" static: true +l3extRsLblToInstP: + overwrites: + relation_from_l3out_consumer_label_to_external_epgs: "relation_to_external_epgs" + documentation: + tDn: "The distinguished name (DN) of the External EPG object." + test_values: + test_values_for_parent: + - target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + - target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_2" + parents: + - class_name: "l3extConsLbl" + parent_dependency: "l3extOut" + parent_dn: "aci_l3out_consumer_label.test.id" + target_classes: + - "l3extInstP" + targets: + - class_name: "l3extInstP" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + relation_resource_name: "external_network_instance_profile" + parent_dependency: "l3extOut" + target_dn_overwrite_docs: "aci_external_network_instance_profile.example.id" + properties: + name: "inst_profile_1" + static: true + +l3extRsLblToProfile: + overwrites: + relation_from_l3out_consumer_label_to_route_control_profiles: "relation_to_route_control_profiles" + documentation: + tDn: "The distinguished name (DN) of the Route Control Profile object." + test_values: + default: + direction: "import" + all: + direction: "export" + resource_required: + direction: "import" + datasource_required: + direction: "import" + datasource_non_existing: + direction: "import" + test_values_for_parent: + - target_dn: "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + - target_dn: "uni/tn-test_tenant/prof-rt_ctrl_profile_2" + parents: + - class_name: "l3extConsLbl" + parent_dependency: "l3extOut" + parent_dn: "aci_l3out_consumer_label.test.id" + target_classes: + - "rtctrlProfile" + targets: + - class_name: "rtctrlProfile" + target_dn: "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + relation_resource_name: "route_control_profile" + parent_dependency: "fvTenant" + target_dn_overwrite_docs: "aci_route_control_profile.example.id" + properties: + name: "rt_ctrl_profile_1" + static: true diff --git a/gen/generator.go b/gen/generator.go index bf88ce807..d499510b0 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -323,7 +323,19 @@ func LookupTestValue(classPkgName, propertyName string, testVars map[string]inte } if propertyName == "target_dn" { - targetResourceName := strings.TrimPrefix(GetResourceName(classPkgName, definitions), "relation_to_") + targetResourceName := "" + resourceName := GetResourceName(classPkgName, definitions) + if strings.HasPrefix(resourceName, "relation_from_") { + definitions := getDefinitions().Properties["resource_name_overwrite"].(map[interface{}]interface{}) + if definitions[resourceName] == nil { + targetResourceName = definitions[strings.TrimSuffix(resourceName, "s")].(string) + } else { + targetResourceName = definitions[resourceName].(string) + } + } else { + targetResourceName = strings.TrimPrefix(GetResourceName(classPkgName, definitions), "relation_to_") + } + targets, ok := testVars["targets"].([]interface{}) if ok { for _, target := range targets { @@ -340,7 +352,6 @@ func LookupTestValue(classPkgName, propertyName string, testVars map[string]inte // Retrieves a value for a attribute of a aci class when defined in the testVars YAML file of the class // Returns "test_value_for_child" if no value is defined in the testVars YAML file func LookupChildTestValue(classPkgName, childResourceName, propertyName string, testVars map[string]interface{}, testValueIndex int, definitions Definitions) interface{} { - propertyName = GetOverwriteAttributeName(classPkgName, propertyName, definitions) overwritePropertyValue := GetOverwriteAttributeValue(classPkgName, propertyName, "", "test_values_for_parent", testValueIndex, definitions) @@ -2032,10 +2043,23 @@ func getTestDependency(className string, targetMap map[interface{}]interface{}, return testDependency } -func GetTestTargetDn(targets []interface{}, resourceName, targetDnValue string, reference bool, targetClasses interface{}, index int) string { +func GetTargetResourceName(resourceName string) string { + definitions := getDefinitions().Properties["resource_name_overwrite"].(map[interface{}]interface{}) + if definitions[resourceName] != nil { + return definitions[resourceName].(string) + } else if definitions[resourceName] == nil { + if definitions[strings.TrimSuffix(resourceName, "s")] != nil { + return definitions[strings.TrimSuffix(resourceName, "s")].(string) + } else { + return strings.TrimPrefix(resourceName, "relation_to_") + } + } + return resourceName +} +func GetTestTargetDn(targets []interface{}, resourceName, targetDnValue string, reference bool, targetClasses interface{}, index int) string { var filteredTargets []interface{} - targetResourceName := strings.TrimPrefix(resourceName, "relation_to_") + targetResourceName := GetTargetResourceName(resourceName) if targetClasses != nil { // CHANGE logic here when allowing for multiple target classes in single resource diff --git a/gen/meta/l3extRsLblToInstP.json b/gen/meta/l3extRsLblToInstP.json new file mode 100644 index 000000000..bb9911753 --- /dev/null +++ b/gen/meta/l3extRsLblToInstP.json @@ -0,0 +1,913 @@ +{ + "l3ext:RsLblToInstP": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Inst": "", + "health:Inst": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fault-": "fault:Inst", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "tDn" + ], + "rnFormat": "rslblToInstP-[{tDn}]", + "containedBy": { + "l3ext:ConsLbl": "", + "l3ext:ConsLblDef": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "n-to-m", + "fromMo": "l3ext:AConsLbl", + "fromRelMo": "l3ext:RsLblToInstP", + "toMo": "l3ext:InstP", + "toRelMo": "l3ext:RtLblToInstP", + "enforceable": true, + "resolvable": true + }, + "dnFormats": [ + "uni/epp/rtd-[{epgPKey}]/conslbl-{name}/rslblToInstP-[{tDn}]", + "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToInstP-[{tDn}]" + ], + "writeAccess": [ + "admin", + "tenant-ext-connectivity" + ], + "readAccess": [ + "admin", + "tenant-ext-connectivity" + ], + "faults": { + "F3783": "fltL3extRsLblToInstPResolveFail" + }, + "events": { + "E4217479": "creation||l3ext:RsLblToInstP", + "E4217480": "modification||l3ext:RsLblToInstP", + "E4217481": "deletion||l3ext:RsLblToInstP" + }, + "stats": { + + }, + "versions": "5.0(1k)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": true, + "hasStats": false, + "isStat": false, + "isFaultable": true, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "regular", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + + ], + "classId": "16895", + "className": "RsLblToInstP", + "classPkg": "l3ext", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "External Network Instance Profile", + "properties": { + "annotation": { + "versions": "5.0(1k)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "57359", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "5.0(1k)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "57360", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "forceResolve": { + "versions": "1.0(1e)-", + "comment": [ + "Whether the relation should force pull the target." + ], + "isConfigurable": false, + "propGlobalId": "107", + "propLocalId": "83", + "label": "Force Resolve", + "baseType": "scalar:Bool", + "modelType": "scalar:Bool", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "true", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "false", "localName": "no", + "platformFlavors": [ + + ], + "label": "No "}, + { "value": "true", "localName": "yes", + "platformFlavors": [ + + ], + "label": "Yes "} + ], + "default": "yes", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "versions": "5.0(1k)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "57356", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rType": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the type of resolver." + ], + "isConfigurable": false, + "propGlobalId": "106", + "propLocalId": "82", + "label": "Resolver Type", + "baseType": "scalar:Enum8", + "modelType": "reln:ResolverType", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "mo", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "3", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "mo", + "platformFlavors": [ + + ], + "label": "MO "}, + { "value": "2", "localName": "service", + "platformFlavors": [ + + ], + "label": "Service "} + ], + "default": "mo", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "state": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the state of the relationship." + ], + "isConfigurable": false, + "propGlobalId": "103", + "propLocalId": "26", + "label": "State", + "baseType": "scalar:Enum8", + "modelType": "reln:State", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "5", "localName": "cardinality-violation", + "platformFlavors": [ + + ], + "comment": [ + "cardinality violation - When relations are created such that\n they violate the cardinality, state of the relation would be\n set to this." + ], + "label": "Cardinality Violation "}, + { "value": "unformed", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "formed", + "platformFlavors": [ + + ], + "comment": [ + "the relationship is formed with the target object" + ], + "label": "Formed "}, + { "value": "4", "localName": "invalid-target", + "platformFlavors": [ + + ], + "comment": [ + "invalid target DN" + ], + "label": "Invalid Target "}, + { "value": "2", "localName": "missing-target", + "platformFlavors": [ + + ], + "comment": [ + "target does not exist" + ], + "label": "Missing Target "}, + { "value": "0", "localName": "unformed", + "platformFlavors": [ + + ], + "comment": [ + "the relationship is not formed" + ], + "label": "Unformed "} + ], + "default": "unformed", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "stateQual": { + "versions": "1.0(1e)-", + "comment": [ + "Represents the state qualifier of the relationship." + ], + "isConfigurable": false, + "propGlobalId": "104", + "propLocalId": "80", + "label": "State Qualifier", + "baseType": "scalar:Enum8", + "modelType": "reln:StateQual", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "default-target", + "platformFlavors": [ + + ], + "comment": [ + "target not specified, using default" + ], + "label": "Target Not Specified "}, + { "value": "none", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "mismatch-target", + "platformFlavors": [ + + ], + "comment": [ + "target not found, using default" + ], + "label": "Target Not Found "}, + { "value": "0", "localName": "none", + "platformFlavors": [ + + ], + "comment": [ + "no issue" + ], + "label": "None "} + ], + "default": "none", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tCl": { + "versions": "5.0(1k)-", + "comment": [ + "The class ID of the target object. This property is managed internally and should not be modified by the user." + ], + "isConfigurable": false, + "propGlobalId": "57346", + "propLocalId": "78", + "label": "Target Class", + "baseType": "scalar:Enum16", + "modelType": "reln:ClassId", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validValues": [ + { "value": "1775", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1775", "localName": "l3extInstP", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "} + ], + "default": "l3extInstP", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "5.0(1k)-", + "comment": [ + "The distinguished name of the target." + ], + "isConfigurable": true, + "propGlobalId": "57345", + "propLocalId": "77", + "label": "Target-dn", + "baseType": "reference:BinRef", + "modelType": "reln:Dn", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tType": { + "versions": "1.0(1e)-", + "comment": [ + "The type of target." + ], + "isConfigurable": false, + "propGlobalId": "105", + "propLocalId": "81", + "label": "Target Type", + "baseType": "scalar:Enum8", + "modelType": "reln:TargetType", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "all", + "platformFlavors": [ + + ], + "label": "All "}, + { "value": "mo", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "mo", + "platformFlavors": [ + + ], + "label": "MO "}, + { "value": "0", "localName": "name", + "platformFlavors": [ + + ], + "label": "Name "} + ], + "default": "mo", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/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/templates/datasource.go.tmpl b/gen/templates/datasource.go.tmpl index d81952e21..0d6f7377b 100644 --- a/gen/templates/datasource.go.tmpl +++ b/gen/templates/datasource.go.tmpl @@ -105,7 +105,7 @@ func (d *{{.ResourceClassName}}DataSource) Schema(ctx context.Context, req datas },{{- end}} {{- end}} {{- range .Children}} - "{{.ResourceName}}": schema.SetNestedAttribute{ + "{{overwriteProperty .PkgName .ResourceName $.Definitions}}": schema.SetNestedAttribute{ MarkdownDescription: `{{.Comment}}`, Computed: true, NestedObject: schema.NestedAttributeObject{ diff --git a/gen/templates/datasource.md.tmpl b/gen/templates/datasource.md.tmpl index 291fdda1a..1482afbce 100644 --- a/gen/templates/datasource.md.tmpl +++ b/gen/templates/datasource.md.tmpl @@ -80,9 +80,9 @@ Data source for ACI {{.ResourceNameAsDescription}} {{- end}} {{ range .Children }}{{$childVersion := .Versions}}{{$RelationshipClasses := .RelationshipClasses}}{{$length := len .RelationshipClasses}} {{- if ge $length 1}} -* `{{- .ResourceName}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}} (ACI object {{getDevnetDocForClass .PkgName}}) pointing to {{range $index, $value := .RelationshipResourceNames}}{{- if or (eq $length 1) (eq $.PkgName (index $RelationshipClasses $index))}}{{getResourceNameAsDescription $value $.Definitions}} (ACI Object {{getDevnetDocForClass (index $RelationshipClasses $index)}}){{end}}{{end}}.{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} +* `{{- overwriteProperty .PkgName .ResourceName $.Definitions}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}} (ACI object {{getDevnetDocForClass .PkgName}}) pointing to {{range $index, $value := .RelationshipResourceNames}}{{- if or (eq $length 1) (eq $.PkgName (index $RelationshipClasses $index))}}{{getResourceNameAsDescription $value $.Definitions}} (ACI Object {{getDevnetDocForClass (index $RelationshipClasses $index)}}){{end}}{{end}}.{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} {{- else}} -* `{{- .ResourceName}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}} (ACI object {{getDevnetDocForClass .PkgName}}).{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} +* `{{- overwriteProperty .PkgName .ResourceName $.Definitions}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}} (ACI object {{getDevnetDocForClass .PkgName}}).{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} {{- end}} {{- range .Properties}} diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index 7a7c62704..1735e2323 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -73,7 +73,7 @@ type {{.ResourceClassName}}ResourceModel struct { {{- end}} {{- end}} {{- range .Children}} - {{ .ResourceClassName }} types.Set `tfsdk:"{{- .ResourceName}}"` + {{ .ResourceClassName }} types.Set `tfsdk:"{{overwriteProperty .PkgName .ResourceName $.Definitions}}"` {{- end}} {{- if .LegacyAttributes}} {{- range .LegacyAttributes}}{{- if ne .ReplacedBy.AttributeName "" }} @@ -965,7 +965,7 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc {{- end}} {{- end}} {{- range .Children}} - "{{- .ResourceName}}": schema.SetNestedAttribute{ + "{{overwriteProperty .PkgName .ResourceName $.Definitions}}": schema.SetNestedAttribute{ MarkdownDescription: `{{.Comment}}`, Optional: true, Computed: true, diff --git a/gen/templates/resource.md.tmpl b/gen/templates/resource.md.tmpl index 4ead61c6d..df407aaa7 100644 --- a/gen/templates/resource.md.tmpl +++ b/gen/templates/resource.md.tmpl @@ -122,20 +122,20 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the {{- if ge $length 1}} {{- if .MultiRelationshipClass}} {{$RelationshipResourceNames := .RelationshipResourceNames}} -* `{{- .ResourceName}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}}. This relation{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}} and{{- end}} can point to multiple ACI objects: +* `{{- overwriteProperty .PkgName .ResourceName $.Definitions}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}}. This relation{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}} and{{- end}} can point to multiple ACI objects: {{- range $index, $value := .RelationshipClasses}} {{- if le $index (len $RelationshipResourceNames)}} - {{getDevnetDocForClass $value}}{{- if ne (index $RelationshipResourceNames $index) ""}} which can be configured using the [aci_{{(index $RelationshipResourceNames $index)}}](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/{{(index $RelationshipResourceNames $index)}}) resource.{{- else}}. Currently there is no resource is available to configure this ACI object.{{- end}} {{- end}} {{- end}} {{- else}} -* `{{- .ResourceName}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}} (ACI object {{getDevnetDocForClass .PkgName}}) pointing to {{range $index, $value := .RelationshipResourceNames}}{{- if or (eq $length 1) (eq $.PkgName (index $RelationshipClasses $index))}}{{getResourceNameAsDescription $value $.Definitions}} (ACI Object {{getDevnetDocForClass (index $RelationshipClasses $index)}}){{- if ne $value ""}} which can be configured using the [aci_{{($value)}}](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/{{($value)}}) resource{{end}}{{end}}{{end}}.{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} +* `{{- overwriteProperty .PkgName .ResourceName $.Definitions}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}} (ACI object {{getDevnetDocForClass .PkgName}}) pointing to {{range $index, $value := .RelationshipResourceNames}}{{- if or (eq $length 1) (eq $.PkgName (index $RelationshipClasses $index))}}{{getResourceNameAsDescription $value $.Definitions}} (ACI Object {{getDevnetDocForClass (index $RelationshipClasses $index)}}){{- if ne $value ""}} which can be configured using the [aci_{{($value)}}](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/{{($value)}}) resource{{end}}{{end}}{{end}}.{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} {{- if or (not .IdentifiedBy) .MaxOneClassAllowed}} - Max Items: 1 {{- end}} {{- end}} {{- else}} -* `{{- .ResourceName}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}} (ACI object {{getDevnetDocForClass .PkgName}}). {{getResourceNameAsDescription .ResourceName $.Definitions}} can also be configured using a separate [aci_{{.ResourceNameDocReference}}](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/{{.ResourceNameDocReference}}) resource.{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} +* `{{- overwriteProperty .PkgName .ResourceName $.Definitions}}` - (list) A list of {{getResourceNameAsDescription .ResourceName $.Definitions}} (ACI object {{getDevnetDocForClass .PkgName}}). {{getResourceNameAsDescription .ResourceName $.Definitions}} can also be configured using a separate [aci_{{.ResourceNameDocReference}}](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/{{.ResourceNameDocReference}}) resource.{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}} {{- if or (not .IdentifiedBy) .MaxOneClassAllowed}} - Max Items: 1 {{- end}} diff --git a/gen/templates/resource_example_all_attributes.tf.tmpl b/gen/templates/resource_example_all_attributes.tf.tmpl index e10606082..6e288b34d 100644 --- a/gen/templates/resource_example_all_attributes.tf.tmpl +++ b/gen/templates/resource_example_all_attributes.tf.tmpl @@ -19,7 +19,7 @@ resource "aci_{{$.ResourceName}}" "full_example_{{getResourceName $key $.Definit {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions}}" {{- end}}{{- end}}{{- end}} - {{- range $key, $value := $.Children}}{{$ChildResourceName := .ResourceName}} + {{- range $key, $value := $.Children}}{{$ChildResourceName := overwriteProperty .PkgName .ResourceName $.Definitions}} {{$ChildResourceName}} = [ { {{- range .Properties}}{{- if not .ReadOnly }}{{- if ne .NamedPropertyClass ""}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name @@ -48,7 +48,7 @@ resource "aci_{{$.ResourceName}}" "full_example" { {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions}}" {{- end}}{{- end}}{{- end}} - {{- range $key, $value := $.Children}}{{$ChildResourceName := .ResourceName}} + {{- range $key, $value := $.Children}}{{$ChildResourceName := overwriteProperty .PkgName .ResourceName $.Definitions}} {{$ChildResourceName}} = [ { {{- range .Properties}}{{- if not .ReadOnly }}{{- if ne .NamedPropertyClass ""}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name diff --git a/gen/templates/testvars.yaml.tmpl b/gen/templates/testvars.yaml.tmpl index 998b7726b..e6caa7417 100644 --- a/gen/templates/testvars.yaml.tmpl +++ b/gen/templates/testvars.yaml.tmpl @@ -95,7 +95,7 @@ all: {{ if .Children}} children: {{- range $key, $value := .Children}}{{$name := .ResourceName}}{{$child_deletable := .AllowDelete}} - {{.ResourceName}}: + {{overwriteProperty .PkgName .ResourceName $.Definitions}}: {{- if or (not .IdentifiedBy) .MaxOneClassAllowed}} - {{ range .Properties}}{{$overwritePropertyName := overwriteProperty .PkgName .SnakeCaseName $.Definitions}}{{- if and (not .IgnoreInTest) (not .ReadOnly)}}{{$overwritePropertyName}}: {{$length := len .ValidValues}}{{if ne $length 0}}"{{ index .ValidValues 0 }}"{{else if not .IsNaming}}"{{overwritePropertyValue .PkgName $overwritePropertyName $overwritePropertyName "all" 0 $.Definitions }}"{{- else}}"{{lookupChildTestValue .PkgName $.ResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}"{{- end}} {{ end}}{{ end}} diff --git a/gen/testvars/l3extConsLbl.yaml b/gen/testvars/l3extConsLbl.yaml index 6eaec39e4..f8c4abcc9 100644 --- a/gen/testvars/l3extConsLbl.yaml +++ b/gen/testvars/l3extConsLbl.yaml @@ -30,6 +30,22 @@ all: tag: "lemon-chiffon" children: + relation_to_external_epgs: + - annotation: "annotation_1" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + + - annotation: "annotation_2" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_2" + + relation_to_route_control_profiles: + - annotation: "annotation_1" + direction: "export" + target_dn: "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + + - annotation: "annotation_2" + direction: "import" + target_dn: "uni/tn-test_tenant/prof-rt_ctrl_profile_2" + annotations: - key: "key_0" value: "value_1" @@ -49,3 +65,12 @@ parents: parent_dependency: "" parent_dn: "aci_l3_outside.test.id" class_in_parent: false +child_targets: + - class_name: "l3extInstP" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + relation_resource_name: "external_network_instance_profile" + static: true + - class_name: "rtctrlProfile" + target_dn: "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + relation_resource_name: "route_control_profile" + static: true diff --git a/gen/testvars/l3extRsLblToInstP.yaml b/gen/testvars/l3extRsLblToInstP.yaml new file mode 100644 index 000000000..16c13a87d --- /dev/null +++ b/gen/testvars/l3extRsLblToInstP.yaml @@ -0,0 +1,53 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + +datasource_non_existing: + target_dn: "non_existing_t_dn" + +datasource_required: + target_dn: "test_t_dn" + +resource_required: + target_dn: "test_t_dn" + +all: + annotation: "annotation" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + +parents: + - class_name: "l3extConsLbl" + parent_dependency: "l3extOut" + parent_dn: "aci_l3out_consumer_label.test.id" + class_in_parent: false + target_classes: + - "l3extInstP" +targets: + - class_name: "l3extInstP" + target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + target_dn_ref: "aci_external_network_instance_profile.test_external_network_instance_profile_0.id" + parent_dependency: "l3extOut" + parent_dependency_dn_ref: "aci_l3_outside.test.id" + target_resource_name: "external_network_instance_profile" + relation_resource_name: "external_network_instance_profile" + parent_dn_key: "parent_dn" + static: true + properties: + name: "inst_profile_1" diff --git a/gen/testvars/l3extRsLblToProfile.yaml b/gen/testvars/l3extRsLblToProfile.yaml new file mode 100644 index 000000000..ad26c5705 --- /dev/null +++ b/gen/testvars/l3extRsLblToProfile.yaml @@ -0,0 +1,58 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + direction: "import" + +datasource_non_existing: + direction: "import" + target_dn: "non_existing_t_dn" + +datasource_required: + direction: "import" + target_dn: "test_t_dn" + +resource_required: + direction: "import" + target_dn: "test_t_dn" + +all: + annotation: "annotation" + direction: "export" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "test_value" + +parents: + - class_name: "l3extConsLbl" + parent_dependency: "l3extOut" + parent_dn: "aci_l3out_consumer_label.test.id" + class_in_parent: false + target_classes: + - "rtctrlProfile" +targets: + - class_name: "rtctrlProfile" + target_dn: "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + target_dn_ref: "aci_route_control_profile.test_route_control_profile_0.id" + parent_dependency: "fvTenant" + parent_dependency_dn_ref: "aci_tenant.test.id" + target_resource_name: "route_control_profile" + relation_resource_name: "route_control_profile" + parent_dn_key: "parent_dn" + static: true + properties: + name: "rt_ctrl_profile_1" diff --git a/internal/provider/data_source_aci_l3out_consumer_label.go b/internal/provider/data_source_aci_l3out_consumer_label.go index 8781de9e8..257d73a6c 100644 --- a/internal/provider/data_source_aci_l3out_consumer_label.go +++ b/internal/provider/data_source_aci_l3out_consumer_label.go @@ -42,7 +42,7 @@ func (d *L3extConsLblDataSource) Schema(ctx context.Context, req datasource.Sche Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the L3out Consumer Label object.", + MarkdownDescription: "The distinguished name (DN) of the L3Out Consumer Label object.", }, "parent_dn": schema.StringAttribute{ Required: true, @@ -50,23 +50,23 @@ func (d *L3extConsLblDataSource) Schema(ctx context.Context, req datasource.Sche }, "annotation": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The annotation of the L3out Consumer Label object.`, + MarkdownDescription: `The annotation of the L3Out Consumer Label object.`, }, "description": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The description of the L3out Consumer Label object.`, + MarkdownDescription: `The description of the L3Out Consumer Label object.`, }, "name": schema.StringAttribute{ Required: true, - MarkdownDescription: `The name of the L3out Consumer Label object.`, + MarkdownDescription: `The name of the L3Out Consumer Label object.`, }, "name_alias": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The name alias of the L3out Consumer Label object.`, + MarkdownDescription: `The name alias of the L3Out Consumer Label object.`, }, "owner": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The owner of the L3out Consumer Label object.`, + MarkdownDescription: `The owner of the L3Out Consumer Label object.`, }, "owner_key": schema.StringAttribute{ Computed: true, @@ -80,6 +80,42 @@ func (d *L3extConsLblDataSource) Schema(ctx context.Context, req datasource.Sche Computed: true, MarkdownDescription: `Specifies the color of a policy label.`, }, + "relation_to_external_epgs": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation From L3Out Consumer Label To External EPG object.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name (DN) of the External EPG object.`, + }, + }, + }, + }, + "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 From L3Out Consumer Label To Route Control Profile object.`, + }, + "direction": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The connector direction.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name (DN) of the Route Control Profile object.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, diff --git a/internal/provider/data_source_aci_l3out_node_sid_profile.go b/internal/provider/data_source_aci_l3out_node_sid_profile.go index 0452ddff9..c2290e5cb 100644 --- a/internal/provider/data_source_aci_l3out_node_sid_profile.go +++ b/internal/provider/data_source_aci_l3out_node_sid_profile.go @@ -42,7 +42,7 @@ func (d *MplsNodeSidPDataSource) Schema(ctx context.Context, req datasource.Sche Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the L3out Node SR-MPLS Segment ID Profile object.", + MarkdownDescription: "The distinguished name (DN) of the L3Out Node SR-MPLS Segment ID Profile object.", }, "parent_dn": schema.StringAttribute{ Required: true, @@ -50,27 +50,27 @@ func (d *MplsNodeSidPDataSource) Schema(ctx context.Context, req datasource.Sche }, "annotation": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The annotation of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The annotation of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "description": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The description of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The description of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "loopback_address": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The loopback address of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The loopback address of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "name": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The name of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The name of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "name_alias": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The name alias of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The name alias of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "segment_id": schema.StringAttribute{ Required: true, - MarkdownDescription: `The segment ID of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The segment ID of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, diff --git a/internal/provider/data_source_aci_l3out_provider_label.go b/internal/provider/data_source_aci_l3out_provider_label.go index 24d96f1ef..0e239a052 100644 --- a/internal/provider/data_source_aci_l3out_provider_label.go +++ b/internal/provider/data_source_aci_l3out_provider_label.go @@ -42,7 +42,7 @@ func (d *L3extProvLblDataSource) Schema(ctx context.Context, req datasource.Sche Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the L3out Provider Label object.", + MarkdownDescription: "The distinguished name (DN) of the L3Out Provider Label object.", }, "parent_dn": schema.StringAttribute{ Required: true, @@ -50,19 +50,19 @@ func (d *L3extProvLblDataSource) Schema(ctx context.Context, req datasource.Sche }, "annotation": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The annotation of the L3out Provider Label object.`, + MarkdownDescription: `The annotation of the L3Out Provider Label object.`, }, "description": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The description of the L3out Provider Label object.`, + MarkdownDescription: `The description of the L3Out Provider Label object.`, }, "name": schema.StringAttribute{ Required: true, - MarkdownDescription: `The name of the L3out Provider Label object.`, + MarkdownDescription: `The name of the L3Out Provider Label object.`, }, "name_alias": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The name alias of the L3out Provider Label object.`, + MarkdownDescription: `The name alias of the L3Out Provider Label object.`, }, "owner_key": schema.StringAttribute{ Computed: true, diff --git a/internal/provider/data_source_aci_l3out_redistribute_policy.go b/internal/provider/data_source_aci_l3out_redistribute_policy.go index 63f2003f1..3479fa91f 100644 --- a/internal/provider/data_source_aci_l3out_redistribute_policy.go +++ b/internal/provider/data_source_aci_l3out_redistribute_policy.go @@ -42,7 +42,7 @@ func (d *L3extRsRedistributePolDataSource) Schema(ctx context.Context, req datas Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the L3out Redistribute Policy object.", + MarkdownDescription: "The distinguished name (DN) of the L3Out Redistribute Policy object.", }, "parent_dn": schema.StringAttribute{ Required: true, @@ -50,11 +50,11 @@ func (d *L3extRsRedistributePolDataSource) Schema(ctx context.Context, req datas }, "annotation": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The annotation of the L3out Redistribute Policy object.`, + MarkdownDescription: `The annotation of the L3Out Redistribute Policy object.`, }, "source": schema.StringAttribute{ Required: true, - MarkdownDescription: `The source of the L3out Redistribute Policy object.`, + MarkdownDescription: `The source of the L3Out Redistribute Policy object.`, }, "route_control_profile_name": schema.StringAttribute{ Required: true, diff --git a/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_external_epg.go b/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_external_epg.go new file mode 100644 index 000000000..fe1c84f81 --- /dev/null +++ b/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_external_epg.go @@ -0,0 +1,149 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &L3extRsLblToInstPDataSource{} + +func NewL3extRsLblToInstPDataSource() datasource.DataSource { + return &L3extRsLblToInstPDataSource{} +} + +// L3extRsLblToInstPDataSource defines the data source implementation. +type L3extRsLblToInstPDataSource struct { + client *client.Client +} + +func (d *L3extRsLblToInstPDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_relation_from_l3out_consumer_label_to_external_epg") + resp.TypeName = req.ProviderTypeName + "_relation_from_l3out_consumer_label_to_external_epg" + tflog.Debug(ctx, "End metadata of datasource: aci_relation_from_l3out_consumer_label_to_external_epg") +} + +func (d *L3extRsLblToInstPDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_relation_from_l3out_consumer_label_to_external_epg") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_from_l3out_consumer_label_to_external_epg datasource for the 'l3extRsLblToInstP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Relation From L3Out Consumer Label To External EPG 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 From L3Out Consumer Label To External EPG object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The distinguished name (DN) of the External EPG 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_from_l3out_consumer_label_to_external_epg") +} + +func (d *L3extRsLblToInstPDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_relation_from_l3out_consumer_label_to_external_epg") + // 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_from_l3out_consumer_label_to_external_epg") +} + +func (d *L3extRsLblToInstPDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_relation_from_l3out_consumer_label_to_external_epg") + var data *L3extRsLblToInstPResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setL3extRsLblToInstPId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetL3extRsLblToInstPAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) + + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_relation_from_l3out_consumer_label_to_external_epg data source", + fmt.Sprintf("The aci_relation_from_l3out_consumer_label_to_external_epg 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_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_external_epg_test.go b/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_external_epg_test.go new file mode 100644 index 000000000..7032b3c90 --- /dev/null +++ b/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_external_epg_test.go @@ -0,0 +1,49 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceL3extRsLblToInstPWithL3extConsLbl(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigL3extRsLblToInstPDataSourceDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_relation_from_l3out_consumer_label_to_external_epg.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("data.aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotation", "orchestrator:terraform"), + ), + }, + { + Config: testConfigL3extRsLblToInstPNotExistingL3extConsLbl, + ExpectError: regexp.MustCompile("Failed to read aci_relation_from_l3out_consumer_label_to_external_epg data source"), + }, + }, + }) +} + +const testConfigL3extRsLblToInstPDataSourceDependencyWithL3extConsLbl = testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl + ` +data "aci_relation_from_l3out_consumer_label_to_external_epg" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + depends_on = [aci_relation_from_l3out_consumer_label_to_external_epg.test] +} +` + +const testConfigL3extRsLblToInstPNotExistingL3extConsLbl = testConfigL3extConsLblMinDependencyWithL3extOut + ` +data "aci_relation_from_l3out_consumer_label_to_external_epg" "test_non_existing" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1_not_existing" +} +` diff --git a/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_route_control_profile.go b/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_route_control_profile.go new file mode 100644 index 000000000..e60f09e1d --- /dev/null +++ b/internal/provider/data_source_aci_relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile") + resp.TypeName = req.ProviderTypeName + "_relation_from_l3out_consumer_label_to_route_control_profile" + tflog.Debug(ctx, "End metadata of datasource: aci_relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_from_l3out_consumer_label_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 From L3Out Consumer Label 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 From L3Out Consumer Label To Route Control Profile object.`, + }, + "direction": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The connector direction.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The distinguished name (DN) 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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile data source", + fmt.Sprintf("The aci_relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_route_control_profile_test.go b/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_route_control_profile_test.go new file mode 100644 index 000000000..617c240e9 --- /dev/null +++ b/internal/provider/data_source_aci_relation_from_l3out_consumer_label_to_route_control_profile_test.go @@ -0,0 +1,53 @@ +// 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_from_l3out_consumer_label_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("data.aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("data.aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "direction", "import"), + ), + }, + { + Config: testConfigL3extRsLblToProfileNotExistingL3extConsLbl, + ExpectError: regexp.MustCompile("Failed to read aci_relation_from_l3out_consumer_label_to_route_control_profile data source"), + }, + }, + }) +} + +const testConfigL3extRsLblToProfileDataSourceDependencyWithL3extConsLbl = testConfigL3extRsLblToProfileMinDependencyWithL3extConsLbl + ` +data "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + depends_on = [aci_relation_from_l3out_consumer_label_to_route_control_profile.test] +} +` + +const testConfigL3extRsLblToProfileNotExistingL3extConsLbl = testConfigL3extConsLblMinDependencyWithL3extOut + ` +data "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test_non_existing" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1_not_existing" +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 400f7b6a7..a285f5847 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -232,6 +232,8 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewInfraHPathSResource, NewL3extConsLblResource, NewL3extProvLblResource, + NewL3extRsLblToInstPResource, + NewL3extRsLblToProfileResource, NewL3extRsOutToFBRGroupResource, NewL3extRsRedistributePolResource, NewMgmtInstPResource, @@ -283,6 +285,8 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewInfraHPathSDataSource, 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 f77f157bd..7ee428243 100644 --- a/internal/provider/resource_aci_l3out_consumer_label.go +++ b/internal/provider/resource_aci_l3out_consumer_label.go @@ -44,18 +44,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"` - 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_external_epgs"` + L3extRsLblToProfile types.Set `tfsdk:"relation_to_route_control_profiles"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` } func getEmptyL3extConsLblResourceModel() *L3extConsLblResourceModel { @@ -70,6 +72,19 @@ func getEmptyL3extConsLblResourceModel() *L3extConsLblResourceModel { OwnerKey: basetypes.NewStringNull(), OwnerTag: basetypes.NewStringNull(), Tag: basetypes.NewStringNull(), + L3extRsLblToInstP: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + }, + }), + L3extRsLblToProfile: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "annotation": types.StringType, + "direction": types.StringType, + "target_dn": types.StringType, + }, + }), TagAnnotation: types.SetNull(types.ObjectType{ AttrTypes: map[string]attr.Type{ "key": types.StringType, @@ -85,6 +100,34 @@ func getEmptyL3extConsLblResourceModel() *L3extConsLblResourceModel { } } +// L3extRsLblToInstPL3extConsLblResourceModel describes the resource data model for the children without relation ships. +type L3extRsLblToInstPL3extConsLblResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` +} + +func getEmptyL3extRsLblToInstPL3extConsLblResourceModel() L3extRsLblToInstPL3extConsLblResourceModel { + return L3extRsLblToInstPL3extConsLblResourceModel{ + Annotation: basetypes.NewStringNull(), + TDn: basetypes.NewStringNull(), + } +} + +// 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"` +} + +func getEmptyL3extRsLblToProfileL3extConsLblResourceModel() L3extRsLblToProfileL3extConsLblResourceModel { + return L3extRsLblToProfileL3extConsLblResourceModel{ + Annotation: basetypes.NewStringNull(), + Direction: basetypes.NewStringNull(), + TDn: basetypes.NewStringNull(), + } +} + // TagAnnotationL3extConsLblResourceModel describes the resource data model for the children without relation ships. type TagAnnotationL3extConsLblResourceModel struct { Key types.String `tfsdk:"key"` @@ -155,7 +198,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the L3out Consumer Label object.", + MarkdownDescription: "The distinguished name (DN) of the L3Out Consumer Label object.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -176,7 +219,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, Default: stringdefault.StaticString(globalAnnotation), - MarkdownDescription: `The annotation of the L3out Consumer Label object.`, + MarkdownDescription: `The annotation of the L3Out Consumer Label object.`, }, "description": schema.StringAttribute{ Optional: true, @@ -185,7 +228,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The description of the L3out Consumer Label object.`, + MarkdownDescription: `The description of the L3Out Consumer Label object.`, }, "name": schema.StringAttribute{ Required: true, @@ -194,7 +237,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), stringplanmodifier.RequiresReplace(), }, - MarkdownDescription: `The name of the L3out Consumer Label object.`, + MarkdownDescription: `The name of the L3Out Consumer Label object.`, }, "name_alias": schema.StringAttribute{ Optional: true, @@ -203,7 +246,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The name alias of the L3out Consumer Label object.`, + MarkdownDescription: `The name alias of the L3Out Consumer Label object.`, }, "owner": schema.StringAttribute{ Optional: true, @@ -215,7 +258,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Validators: []validator.String{ stringvalidator.OneOf("infra", "tenant"), }, - MarkdownDescription: `The owner of the L3out Consumer Label object.`, + MarkdownDescription: `The owner of the L3Out Consumer Label object.`, }, "owner_key": schema.StringAttribute{ Optional: true, @@ -247,6 +290,71 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe }, MarkdownDescription: `Specifies the color of a policy label.`, }, + "relation_to_external_epgs": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Relation From L3Out Consumer Label To External EPG object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name (DN) of the External EPG object.`, + }, + }, + }, + }, + "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 From L3Out Consumer Label To Route Control Profile object.`, + }, + "direction": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("export", "import"), + MakeStringRequired(), + }, + MarkdownDescription: `The connector direction.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name (DN) of the Route Control Profile object.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, @@ -358,13 +466,19 @@ func (r *L3extConsLblResource) Create(ctx context.Context, req resource.CreateRe tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_consumer_label with id '%s'", data.Id.ValueString())) + var l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel + data.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPPlan, false) + stateData.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPState, false) + var 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, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, true, data, l3extRsLblToInstPPlan, l3extRsLblToInstPState, l3extRsLblToProfilePlan, l3extRsLblToProfileState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -423,13 +537,19 @@ func (r *L3extConsLblResource) Update(ctx context.Context, req resource.UpdateRe tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_l3out_consumer_label with id '%s'", data.Id.ValueString())) + var l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel + data.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPPlan, false) + stateData.L3extRsLblToInstP.ElementsAs(ctx, &l3extRsLblToInstPState, false) + var 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, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, false, data, l3extRsLblToInstPPlan, l3extRsLblToInstPState, l3extRsLblToProfilePlan, l3extRsLblToProfileState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -483,7 +603,7 @@ func (r *L3extConsLblResource) ImportState(ctx context.Context, req resource.Imp } func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *L3extConsLblResourceModel) { - requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "l3extConsLbl,tagAnnotation,tagTag"), "GET", nil) + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "l3extConsLbl,l3extRsLblToInstP,l3extRsLblToProfile,tagAnnotation,tagTag"), "GET", nil) *data = *getEmptyL3extConsLblResourceModel() @@ -524,6 +644,8 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic data.Tag = basetypes.NewStringValue(attributeValue.(string)) } } + L3extRsLblToInstPL3extConsLblList := make([]L3extRsLblToInstPL3extConsLblResourceModel, 0) + L3extRsLblToProfileL3extConsLblList := make([]L3extRsLblToProfileL3extConsLblResourceModel, 0) TagAnnotationL3extConsLblList := make([]TagAnnotationL3extConsLblResourceModel, 0) TagTagL3extConsLblList := make([]TagTagL3extConsLblResourceModel, 0) _, ok := classReadInfo[0].(map[string]interface{})["children"] @@ -532,6 +654,33 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic for _, child := range children { for childClassName, childClassDetails := range child.(map[string]interface{}) { childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "l3extRsLblToInstP" { + L3extRsLblToInstPL3extConsLbl := getEmptyL3extRsLblToInstPL3extConsLblResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + L3extRsLblToInstPL3extConsLbl.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + L3extRsLblToInstPL3extConsLbl.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + L3extRsLblToInstPL3extConsLblList = append(L3extRsLblToInstPL3extConsLblList, L3extRsLblToInstPL3extConsLbl) + } + if childClassName == "l3extRsLblToProfile" { + L3extRsLblToProfileL3extConsLbl := getEmptyL3extRsLblToProfileL3extConsLblResourceModel() + 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 := getEmptyTagAnnotationL3extConsLblResourceModel() for childAttributeName, childAttributeValue := range childAttributes { @@ -559,6 +708,10 @@ 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) @@ -605,6 +758,94 @@ func setL3extConsLblId(ctx context.Context, data *L3extConsLblResourceModel) { data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } +func getL3extConsLblL3extRsLblToInstPChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, l3extRsLblToInstPPlan, l3extRsLblToInstPState []L3extRsLblToInstPL3extConsLblResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.L3extRsLblToInstP.IsUnknown() { + l3extRsLblToInstPIdentifiers := []L3extRsLblToInstPIdentifier{} + for _, l3extRsLblToInstP := range l3extRsLblToInstPPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !l3extRsLblToInstP.Annotation.IsUnknown() && !l3extRsLblToInstP.Annotation.IsNull() { + childMap["attributes"]["annotation"] = l3extRsLblToInstP.Annotation.ValueString() + } else { + childMap["attributes"]["annotation"] = globalAnnotation + } + if !l3extRsLblToInstP.TDn.IsUnknown() && !l3extRsLblToInstP.TDn.IsNull() { + childMap["attributes"]["tDn"] = l3extRsLblToInstP.TDn.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"l3extRsLblToInstP": childMap}) + l3extRsLblToInstPIdentifier := L3extRsLblToInstPIdentifier{} + l3extRsLblToInstPIdentifier.TDn = l3extRsLblToInstP.TDn + l3extRsLblToInstPIdentifiers = append(l3extRsLblToInstPIdentifiers, l3extRsLblToInstPIdentifier) + } + for _, l3extRsLblToInstP := range l3extRsLblToInstPState { + delete := true + for _, l3extRsLblToInstPIdentifier := range l3extRsLblToInstPIdentifiers { + if l3extRsLblToInstPIdentifier.TDn == l3extRsLblToInstP.TDn { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["tDn"] = l3extRsLblToInstP.TDn.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"l3extRsLblToInstP": childMap}) + } + } + } else { + data.L3extRsLblToInstP = types.SetNull(data.L3extRsLblToInstP.ElementType(ctx)) + } + + return childPayloads +} +func 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() && !l3extRsLblToProfile.Annotation.IsNull() { + childMap["attributes"]["annotation"] = l3extRsLblToProfile.Annotation.ValueString() + } else { + childMap["attributes"]["annotation"] = globalAnnotation + } + if !l3extRsLblToProfile.Direction.IsUnknown() && !l3extRsLblToProfile.Direction.IsNull() { + childMap["attributes"]["direction"] = l3extRsLblToProfile.Direction.ValueString() + } + if !l3extRsLblToProfile.TDn.IsUnknown() && !l3extRsLblToProfile.TDn.IsNull() { + 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{}{} @@ -684,7 +925,7 @@ func getL3extConsLblTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { +func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, 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{} @@ -693,6 +934,18 @@ func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnosti } childPayloads := []map[string]interface{}{} + L3extRsLblToInstPchildPayloads := getL3extConsLblL3extRsLblToInstPChildPayloads(ctx, diags, data, l3extRsLblToInstPPlan, l3extRsLblToInstPState) + if L3extRsLblToInstPchildPayloads == nil { + return nil + } + 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 f40a550bb..f158f0e83 100644 --- a/internal/provider/resource_aci_l3out_consumer_label_test.go +++ b/internal/provider/resource_aci_l3out_consumer_label_test.go @@ -167,6 +167,16 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.0.value", "value_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.0.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.1.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_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-rt_ctrl_profile_1"), + 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-rt_ctrl_profile_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"), @@ -194,6 +204,18 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.key", "key_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.1.value", "test_value"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.0.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.1.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.1.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.#", "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-rt_ctrl_profile_1"), + 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-rt_ctrl_profile_2"), + 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"), @@ -209,6 +231,13 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.0.key", "key_1"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.0.value", "test_value"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.0.annotation", "annotation_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.0.target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_2"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.#", "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-rt_ctrl_profile_2"), + 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", "test_value"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.#", "1"), @@ -220,6 +249,8 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_external_epgs.#", "0"), + resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "relation_to_route_control_profiles.#", "0"), resource.TestCheckResourceAttr("aci_l3out_consumer_label.test", "tags.#", "0"), ), }, @@ -227,6 +258,9 @@ func TestAccResourceL3extConsLblWithL3extOut(t *testing.T) { }) } +const testChildDependencyConfigL3extConsLbl = ` +` + const testConfigL3extConsLblMinDependencyWithL3extOutAllowExisting = testConfigL3extOutMin + ` resource "aci_l3out_consumer_label" "allow_test" { parent_dn = aci_l3_outside.test.id @@ -273,7 +307,7 @@ resource "aci_l3out_consumer_label" "test" { tag = "yellow-green" } ` -const testConfigL3extConsLblChildrenDependencyWithL3extOut = testConfigL3extOutMin + ` +const testConfigL3extConsLblChildrenDependencyWithL3extOut = testChildDependencyConfigL3extConsLbl + testConfigL3extOutMin + ` resource "aci_l3out_consumer_label" "test" { parent_dn = aci_l3_outside.test.id name = "test_name" @@ -287,6 +321,28 @@ resource "aci_l3out_consumer_label" "test" { value = "test_value" }, ] + relation_to_external_epgs = [ + { + annotation = "annotation_1" + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + }, + { + annotation = "annotation_2" + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_2" + }, + ] + relation_to_route_control_profiles = [ + { + annotation = "annotation_1" + direction = "export" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + }, + { + annotation = "annotation_2" + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_2" + }, + ] tags = [ { key = "key_0" @@ -300,14 +356,14 @@ resource "aci_l3out_consumer_label" "test" { } ` -const testConfigL3extConsLblChildrenRemoveFromConfigDependencyWithL3extOut = testConfigL3extOutMin + ` +const testConfigL3extConsLblChildrenRemoveFromConfigDependencyWithL3extOut = testChildDependencyConfigL3extConsLbl + testConfigL3extOutMin + ` resource "aci_l3out_consumer_label" "test" { parent_dn = aci_l3_outside.test.id name = "test_name" } ` -const testConfigL3extConsLblChildrenRemoveOneDependencyWithL3extOut = testConfigL3extOutMin + ` +const testConfigL3extConsLblChildrenRemoveOneDependencyWithL3extOut = testChildDependencyConfigL3extConsLbl + testConfigL3extOutMin + ` resource "aci_l3out_consumer_label" "test" { parent_dn = aci_l3_outside.test.id name = "test_name" @@ -317,6 +373,19 @@ resource "aci_l3out_consumer_label" "test" { value = "test_value" }, ] + relation_to_external_epgs = [ + { + annotation = "annotation_2" + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_2" + }, + ] + relation_to_route_control_profiles = [ + { + annotation = "annotation_2" + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_2" + }, + ] tags = [ { key = "key_1" @@ -326,11 +395,13 @@ resource "aci_l3out_consumer_label" "test" { } ` -const testConfigL3extConsLblChildrenRemoveAllDependencyWithL3extOut = testConfigL3extOutMin + ` +const testConfigL3extConsLblChildrenRemoveAllDependencyWithL3extOut = testChildDependencyConfigL3extConsLbl + testConfigL3extOutMin + ` resource "aci_l3out_consumer_label" "test" { parent_dn = aci_l3_outside.test.id name = "test_name" annotations = [] + relation_to_external_epgs = [] + relation_to_route_control_profiles = [] tags = [] } ` diff --git a/internal/provider/resource_aci_l3out_node_sid_profile.go b/internal/provider/resource_aci_l3out_node_sid_profile.go index 2baeb0223..6daa01ff4 100644 --- a/internal/provider/resource_aci_l3out_node_sid_profile.go +++ b/internal/provider/resource_aci_l3out_node_sid_profile.go @@ -149,7 +149,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the L3out Node SR-MPLS Segment ID Profile object.", + MarkdownDescription: "The distinguished name (DN) of the L3Out Node SR-MPLS Segment ID Profile object.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -170,7 +170,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, Default: stringdefault.StaticString(globalAnnotation), - MarkdownDescription: `The annotation of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The annotation of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "description": schema.StringAttribute{ Optional: true, @@ -179,7 +179,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The description of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The description of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "loopback_address": schema.StringAttribute{ Optional: true, @@ -188,7 +188,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The loopback address of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The loopback address of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "name": schema.StringAttribute{ Optional: true, @@ -197,7 +197,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The name of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The name of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "name_alias": schema.StringAttribute{ Optional: true, @@ -206,7 +206,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The name alias of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The name alias of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "segment_id": schema.StringAttribute{ Required: true, @@ -215,7 +215,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), stringplanmodifier.RequiresReplace(), }, - MarkdownDescription: `The segment ID of the L3out Node SR-MPLS Segment ID Profile object.`, + MarkdownDescription: `The segment ID of the L3Out Node SR-MPLS Segment ID Profile object.`, }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, diff --git a/internal/provider/resource_aci_l3out_provider_label.go b/internal/provider/resource_aci_l3out_provider_label.go index 2f5106fd5..f1cdbf498 100644 --- a/internal/provider/resource_aci_l3out_provider_label.go +++ b/internal/provider/resource_aci_l3out_provider_label.go @@ -153,7 +153,7 @@ func (r *L3extProvLblResource) Schema(ctx context.Context, req resource.SchemaRe Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the L3out Provider Label object.", + MarkdownDescription: "The distinguished name (DN) of the L3Out Provider Label object.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -174,7 +174,7 @@ func (r *L3extProvLblResource) Schema(ctx context.Context, req resource.SchemaRe SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, Default: stringdefault.StaticString(globalAnnotation), - MarkdownDescription: `The annotation of the L3out Provider Label object.`, + MarkdownDescription: `The annotation of the L3Out Provider Label object.`, }, "description": schema.StringAttribute{ Optional: true, @@ -183,7 +183,7 @@ func (r *L3extProvLblResource) Schema(ctx context.Context, req resource.SchemaRe stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The description of the L3out Provider Label object.`, + MarkdownDescription: `The description of the L3Out Provider Label object.`, }, "name": schema.StringAttribute{ Required: true, @@ -192,7 +192,7 @@ func (r *L3extProvLblResource) Schema(ctx context.Context, req resource.SchemaRe SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), stringplanmodifier.RequiresReplace(), }, - MarkdownDescription: `The name of the L3out Provider Label object.`, + MarkdownDescription: `The name of the L3Out Provider Label object.`, }, "name_alias": schema.StringAttribute{ Optional: true, @@ -201,7 +201,7 @@ func (r *L3extProvLblResource) Schema(ctx context.Context, req resource.SchemaRe stringplanmodifier.UseStateForUnknown(), SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, - MarkdownDescription: `The name alias of the L3out Provider Label object.`, + MarkdownDescription: `The name alias of the L3Out Provider Label object.`, }, "owner_key": schema.StringAttribute{ Optional: true, diff --git a/internal/provider/resource_aci_l3out_redistribute_policy.go b/internal/provider/resource_aci_l3out_redistribute_policy.go index 0154d7350..b550e76e1 100644 --- a/internal/provider/resource_aci_l3out_redistribute_policy.go +++ b/internal/provider/resource_aci_l3out_redistribute_policy.go @@ -146,7 +146,7 @@ func (r *L3extRsRedistributePolResource) Schema(ctx context.Context, req resourc Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the L3out Redistribute Policy object.", + MarkdownDescription: "The distinguished name (DN) of the L3Out Redistribute Policy object.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -167,7 +167,7 @@ func (r *L3extRsRedistributePolResource) Schema(ctx context.Context, req resourc SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), }, Default: stringdefault.StaticString(globalAnnotation), - MarkdownDescription: `The annotation of the L3out Redistribute Policy object.`, + MarkdownDescription: `The annotation of the L3Out Redistribute Policy object.`, }, "source": schema.StringAttribute{ Required: true, @@ -179,7 +179,7 @@ func (r *L3extRsRedistributePolResource) Schema(ctx context.Context, req resourc Validators: []validator.String{ stringvalidator.OneOf("attached-host", "direct", "static"), }, - MarkdownDescription: `The source of the L3out Redistribute Policy object.`, + MarkdownDescription: `The source of the L3Out Redistribute Policy object.`, }, "route_control_profile_name": schema.StringAttribute{ Required: true, diff --git a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go new file mode 100644 index 000000000..62686c809 --- /dev/null +++ b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go @@ -0,0 +1,643 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &L3extRsLblToInstPResource{} +var _ resource.ResourceWithImportState = &L3extRsLblToInstPResource{} + +func NewL3extRsLblToInstPResource() resource.Resource { + return &L3extRsLblToInstPResource{} +} + +// L3extRsLblToInstPResource defines the resource implementation. +type L3extRsLblToInstPResource struct { + client *client.Client +} + +// L3extRsLblToInstPResourceModel describes the resource data model. +type L3extRsLblToInstPResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyL3extRsLblToInstPResourceModel() *L3extRsLblToInstPResourceModel { + return &L3extRsLblToInstPResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + TDn: basetypes.NewStringNull(), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +// TagAnnotationL3extRsLblToInstPResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationL3extRsLblToInstPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationL3extRsLblToInstPResourceModel() TagAnnotationL3extRsLblToInstPResourceModel { + return TagAnnotationL3extRsLblToInstPResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +// TagTagL3extRsLblToInstPResourceModel describes the resource data model for the children without relation ships. +type TagTagL3extRsLblToInstPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagL3extRsLblToInstPResourceModel() TagTagL3extRsLblToInstPResourceModel { + return TagTagL3extRsLblToInstPResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +type L3extRsLblToInstPIdentifier struct { + TDn types.String +} + +func (r *L3extRsLblToInstPResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *L3extRsLblToInstPResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { + setL3extRsLblToInstPId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "l3extRsLblToInstP", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *L3extRsLblToInstPResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_relation_from_l3out_consumer_label_to_external_epg") + resp.TypeName = req.ProviderTypeName + "_relation_from_l3out_consumer_label_to_external_epg" + tflog.Debug(ctx, "End metadata of resource: aci_relation_from_l3out_consumer_label_to_external_epg") +} + +func (r *L3extRsLblToInstPResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_relation_from_l3out_consumer_label_to_external_epg") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_from_l3out_consumer_label_to_external_epg resource for the 'l3extRsLblToInstP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Relation From L3Out Consumer Label To External EPG object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Relation From L3Out Consumer Label To External EPG object.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The distinguished name (DN) of the External EPG 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_from_l3out_consumer_label_to_external_epg") +} + +func (r *L3extRsLblToInstPResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_relation_from_l3out_consumer_label_to_external_epg") + // 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_from_l3out_consumer_label_to_external_epg") +} + +func (r *L3extRsLblToInstPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_relation_from_l3out_consumer_label_to_external_epg") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *L3extRsLblToInstPResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setL3extRsLblToInstPId(ctx, stateData) + } + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The l3extRsLblToInstP object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *L3extRsLblToInstPResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if data.Id.IsUnknown() || data.Id.IsNull() { + setL3extRsLblToInstPId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToInstPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagL3extRsLblToInstPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getL3extRsLblToInstPCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToInstPResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_relation_from_l3out_consumer_label_to_external_epg") + var data *L3extRsLblToInstPResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) + + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *L3extRsLblToInstPResourceModel + resp.Diagnostics.Append(resp.State.Set(ctx, &emptyData)...) + } else { + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + } + + tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToInstPResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_relation_from_l3out_consumer_label_to_external_epg") + var data *L3extRsLblToInstPResourceModel + var stateData *L3extRsLblToInstPResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToInstPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagL3extRsLblToInstPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getL3extRsLblToInstPCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetL3extRsLblToInstPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToInstPResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_relation_from_l3out_consumer_label_to_external_epg") + var data *L3extRsLblToInstPResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "l3extRsLblToInstP", data.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", data.Id.ValueString())) +} + +func (r *L3extRsLblToInstPResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_relation_from_l3out_consumer_label_to_external_epg") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *L3extRsLblToInstPResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_relation_from_l3out_consumer_label_to_external_epg with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_relation_from_l3out_consumer_label_to_external_epg") +} + +func getAndSetL3extRsLblToInstPAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *L3extRsLblToInstPResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "l3extRsLblToInstP,tagAnnotation,tagTag"), "GET", nil) + + *data = *getEmptyL3extRsLblToInstPResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("l3extRsLblToInstP").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("l3extRsLblToInstP").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + data.Id = basetypes.NewStringValue(attributeValue.(string)) + setL3extRsLblToInstPParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "tDn" { + data.TDn = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationL3extRsLblToInstPList := make([]TagAnnotationL3extRsLblToInstPResourceModel, 0) + TagTagL3extRsLblToInstPList := make([]TagTagL3extRsLblToInstPResourceModel, 0) + _, ok := classReadInfo[0].(map[string]interface{})["children"] + if ok { + children := classReadInfo[0].(map[string]interface{})["children"].([]interface{}) + for _, child := range children { + for childClassName, childClassDetails := range child.(map[string]interface{}) { + childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "tagAnnotation" { + TagAnnotationL3extRsLblToInstP := getEmptyTagAnnotationL3extRsLblToInstPResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationL3extRsLblToInstP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationL3extRsLblToInstP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationL3extRsLblToInstPList = append(TagAnnotationL3extRsLblToInstPList, TagAnnotationL3extRsLblToInstP) + } + if childClassName == "tagTag" { + TagTagL3extRsLblToInstP := getEmptyTagTagL3extRsLblToInstPResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagL3extRsLblToInstP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagL3extRsLblToInstP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagL3extRsLblToInstPList = append(TagTagL3extRsLblToInstPList, TagTagL3extRsLblToInstP) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationL3extRsLblToInstPList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagL3extRsLblToInstPList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'l3extRsLblToInstP'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getL3extRsLblToInstPRn(ctx context.Context, data *L3extRsLblToInstPResourceModel) string { + rn := "rslblToInstP-[{tDn}]" + for _, identifier := range []string{"tDn"} { + fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) + fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() + rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) + } + return rn +} + +func setL3extRsLblToInstPParentDn(ctx context.Context, dn string, data *L3extRsLblToInstPResourceModel) { + bracketIndex := 0 + rnIndex := 0 + for i := len(dn) - 1; i >= 0; i-- { + if string(dn[i]) == "]" { + bracketIndex = bracketIndex + 1 + } else if string(dn[i]) == "[" { + bracketIndex = bracketIndex - 1 + } else if string(dn[i]) == "/" && bracketIndex == 0 { + rnIndex = i + break + } + } + data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) +} + +func setL3extRsLblToInstPId(ctx context.Context, data *L3extRsLblToInstPResourceModel) { + rn := getL3extRsLblToInstPRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getL3extRsLblToInstPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extRsLblToInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToInstPResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotation := range tagAnnotationPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagAnnotation.Key.IsUnknown() && !tagAnnotation.Key.IsNull() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() && !tagAnnotation.Value.IsNull() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func getL3extRsLblToInstPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *L3extRsLblToInstPResourceModel, tagTagPlan, tagTagState []TagTagL3extRsLblToInstPResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTag := range tagTagPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagTag.Key.IsUnknown() && !tagTag.Key.IsNull() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() && !tagTag.Value.IsNull() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getL3extRsLblToInstPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extRsLblToInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToInstPResourceModel, tagTagPlan, tagTagState []TagTagL3extRsLblToInstPResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + + if createType && !globalAllowExistingOnCreate { + payloadMap["attributes"].(map[string]string)["status"] = "created" + } + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getL3extRsLblToInstPTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getL3extRsLblToInstPTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.TDn.IsNull() && !data.TDn.IsUnknown() { + payloadMap["attributes"].(map[string]string)["tDn"] = data.TDn.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"l3extRsLblToInstP": payloadMap}) + if err != nil { + diags.AddError( + "Marshalling of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + jsonPayload, err := container.ParseJSON(payload) + + if err != nil { + diags.AddError( + "Construction of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + return jsonPayload +} diff --git a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg_test.go b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg_test.go new file mode 100644 index 000000000..679b80c82 --- /dev/null +++ b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg_test.go @@ -0,0 +1,279 @@ +// 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 TestAccResourceL3extRsLblToInstPWithL3extConsLbl(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigL3extRsLblToInstPMinDependencyWithL3extConsLblAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.allow_test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.allow_test_2", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.allow_test_2", "annotation", "orchestrator:terraform"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigL3extRsLblToInstPMinDependencyWithL3extConsLblAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigL3extRsLblToInstPMinDependencyWithL3extConsLblAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.allow_test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.allow_test_2", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.allow_test_2", "annotation", "orchestrator:terraform"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotation", "orchestrator:terraform"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigL3extRsLblToInstPAllDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotation", "annotation"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigL3extRsLblToInstPResetDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotation", "orchestrator:terraform"), + ), + }, + // Import testing + { + ResourceName: "aci_relation_from_l3out_consumer_label_to_external_epg.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigL3extRsLblToInstPChildrenDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "target_dn", "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.1.value", "test_value"), + ), + }, + // Refresh State before import testing to ensure that the state is up to date + { + RefreshState: true, + ExpectNonEmptyPlan: false, + }, + // Import testing with children + { + ResourceName: "aci_relation_from_l3out_consumer_label_to_external_epg.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigL3extRsLblToInstPChildrenRemoveFromConfigDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigL3extRsLblToInstPChildrenRemoveOneDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigL3extRsLblToInstPChildrenRemoveAllDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_external_epg.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testDependencyConfigL3extRsLblToInstP = ` +` + +const testConfigL3extRsLblToInstPMinDependencyWithL3extConsLblAllowExisting = testDependencyConfigL3extRsLblToInstP + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "allow_test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" +} +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "allow_test_2" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + depends_on = [aci_relation_from_l3out_consumer_label_to_external_epg.allow_test] +} +` + +const testConfigL3extRsLblToInstPMinDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToInstP + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" +} +` + +const testConfigL3extRsLblToInstPAllDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToInstP + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + annotation = "annotation" +} +` + +const testConfigL3extRsLblToInstPResetDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToInstP + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + annotation = "orchestrator:terraform" +} +` +const testConfigL3extRsLblToInstPChildrenDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToInstP + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigL3extRsLblToInstPChildrenRemoveFromConfigDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToInstP + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" +} +` + +const testConfigL3extRsLblToInstPChildrenRemoveOneDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToInstP + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigL3extRsLblToInstPChildrenRemoveAllDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToInstP + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_external_epg" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/out-test_l3_outside/instP-inst_profile_1" + annotations = [] + tags = [] +} +` diff --git a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go new file mode 100644 index 000000000..2df0022a3 --- /dev/null +++ b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go @@ -0,0 +1,666 @@ +// 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/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/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"` +} + +func getEmptyL3extRsLblToProfileResourceModel() *L3extRsLblToProfileResourceModel { + return &L3extRsLblToProfileResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Direction: basetypes.NewStringNull(), + TDn: basetypes.NewStringNull(), + TagAnnotation: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: types.SetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } +} + +// 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"` +} + +func getEmptyTagAnnotationL3extRsLblToProfileResourceModel() TagAnnotationL3extRsLblToProfileResourceModel { + return TagAnnotationL3extRsLblToProfileResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +// 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"` +} + +func getEmptyTagTagL3extRsLblToProfileResourceModel() TagTagL3extRsLblToProfileResourceModel { + return TagTagL3extRsLblToProfileResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +type L3extRsLblToProfileIdentifier struct { + Direction types.String + TDn types.String +} + +func (r *L3extRsLblToProfileResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *L3extRsLblToProfileResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Direction.IsUnknown() && !planData.TDn.IsUnknown() { + setL3extRsLblToProfileId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "l3extRsLblToProfile", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *L3extRsLblToProfileResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_relation_from_l3out_consumer_label_to_route_control_profile") + resp.TypeName = req.ProviderTypeName + "_relation_from_l3out_consumer_label_to_route_control_profile" + tflog.Debug(ctx, "End metadata of resource: aci_relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The relation_from_l3out_consumer_label_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 From L3Out Consumer Label 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Relation From L3Out Consumer Label To Route Control Profile object.`, + }, + "direction": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("export", "import"), + }, + MarkdownDescription: `The connector direction.`, + }, + "target_dn": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The distinguished name (DN) 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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setL3extRsLblToProfileId(ctx, stateData) + } + getAndSetL3extRsLblToProfileAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The l3extRsLblToProfile object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *L3extRsLblToProfileResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if data.Id.IsUnknown() || data.Id.IsNull() { + setL3extRsLblToProfileId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_from_l3out_consumer_label_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, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + 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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + 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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_relation_from_l3out_consumer_label_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) + + *data = *getEmptyL3extRsLblToProfileResourceModel() + + 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 := getEmptyTagAnnotationL3extRsLblToProfileResourceModel() + 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 := getEmptyTagTagL3extRsLblToProfileResourceModel() + 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() && !tagAnnotation.Key.IsNull() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() && !tagAnnotation.Value.IsNull() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func 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() && !tagTag.Key.IsNull() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() && !tagTag.Value.IsNull() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getL3extRsLblToProfileCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extRsLblToProfileResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsLblToProfileResourceModel, tagTagPlan, tagTagState []TagTagL3extRsLblToProfileResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + + if createType && !globalAllowExistingOnCreate { + payloadMap["attributes"].(map[string]string)["status"] = "created" + } + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := 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_from_l3out_consumer_label_to_route_control_profile_test.go b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile_test.go new file mode 100644 index 000000000..cb74a8482 --- /dev/null +++ b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile_test.go @@ -0,0 +1,297 @@ +// 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 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: testConfigL3extRsLblToProfileMinDependencyWithL3extConsLblAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test_2", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test_2", "direction", "import"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigL3extRsLblToProfileMinDependencyWithL3extConsLblAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigL3extRsLblToProfileMinDependencyWithL3extConsLblAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test_2", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test_2", "direction", "import"), + ), + }, + }, + }) + + 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_from_l3out_consumer_label_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_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_from_l3out_consumer_label_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigL3extRsLblToProfileResetDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + ), + }, + // Import testing + { + ResourceName: "aci_relation_from_l3out_consumer_label_to_route_control_profile.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigL3extRsLblToProfileChildrenDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "direction", "import"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "target_dn", "uni/tn-test_tenant/prof-rt_ctrl_profile_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.1.value", "test_value"), + ), + }, + // Refresh State before import testing to ensure that the state is up to date + { + RefreshState: true, + ExpectNonEmptyPlan: false, + }, + // Import testing with children + { + ResourceName: "aci_relation_from_l3out_consumer_label_to_route_control_profile.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigL3extRsLblToProfileChildrenRemoveFromConfigDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigL3extRsLblToProfileChildrenRemoveOneDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigL3extRsLblToProfileChildrenRemoveAllDependencyWithL3extConsLbl, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_relation_from_l3out_consumer_label_to_route_control_profile.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testDependencyConfigL3extRsLblToProfile = ` +` + +const testConfigL3extRsLblToProfileMinDependencyWithL3extConsLblAllowExisting = testDependencyConfigL3extRsLblToProfile + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "allow_test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" +} +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "allow_test_2" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + depends_on = [aci_relation_from_l3out_consumer_label_to_route_control_profile.allow_test] +} +` + +const testConfigL3extRsLblToProfileMinDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToProfile + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" +} +` + +const testConfigL3extRsLblToProfileAllDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToProfile + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + annotation = "annotation" + direction = "export" +} +` + +const testConfigL3extRsLblToProfileResetDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToProfile + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + annotation = "orchestrator:terraform" + direction = "import" +} +` +const testConfigL3extRsLblToProfileChildrenDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToProfile + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigL3extRsLblToProfileChildrenRemoveFromConfigDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToProfile + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" +} +` + +const testConfigL3extRsLblToProfileChildrenRemoveOneDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToProfile + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigL3extRsLblToProfileChildrenRemoveAllDependencyWithL3extConsLbl = testDependencyConfigL3extRsLblToProfile + testConfigL3extConsLblMinDependencyWithL3extOut + ` +resource "aci_relation_from_l3out_consumer_label_to_route_control_profile" "test" { + parent_dn = aci_l3out_consumer_label.test.id + direction = "import" + target_dn = "uni/tn-test_tenant/prof-rt_ctrl_profile_1" + annotations = [] + tags = [] +} +`