diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index 8a28ab9f1..e5aa1b87c 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -61,6 +61,7 @@ data "aci_annotation" "example_application_epg" { - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) + - [aci_host_path_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/host_path_selector) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) @@ -73,7 +74,6 @@ data "aci_annotation" "example_application_epg" { - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/data-sources/host_path_selector.md b/docs/data-sources/host_path_selector.md new file mode 100644 index 000000000..f8bdd1216 --- /dev/null +++ b/docs/data-sources/host_path_selector.md @@ -0,0 +1,66 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "Generic" +layout: "aci" +page_title: "ACI: aci_host_path_selector" +sidebar_current: "docs-aci-data-source-aci_host_path_selector" +description: |- + Data source for Host Path Selector +--- + +# aci_host_path_selector # + +Data source for Host Path Selector + +## API Information ## + +* Class: [infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview) + +* Supported in ACI versions: 1.1(1j) and later. + +* Distinguished Name Format: `uni/infra/hpaths-{name}` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## + +```hcl + +data "aci_host_path_selector" "example" { + name = "host_path_selector" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - The distinguished name (DN) of classes below can be used but currently there is no available resource for it: + - [infraInfra](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraInfra/overview) + + - Default: `uni/infra` + +* `name` (name) - (string) The name of the Host Path Selector object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Host Path Selector object. +* `annotation` (annotation) - (string) The annotation of the Host Path Selector object. +* `description` (descr) - (string) The description of the Host Path Selector object. +* `name_alias` (nameAlias) - (string) The name alias of the Host Path Selector object. +* `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. +* `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/tag.md b/docs/data-sources/tag.md index 55e36e99e..1bcae3334 100644 --- a/docs/data-sources/tag.md +++ b/docs/data-sources/tag.md @@ -61,6 +61,7 @@ data "aci_tag" "example_application_epg" { - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) + - [aci_host_path_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/host_path_selector) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) @@ -73,7 +74,6 @@ data "aci_tag" "example_application_epg" { - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/resources/annotation.md b/docs/resources/annotation.md index 85e946ee4..b4b03468b 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -70,6 +70,7 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) + - [aci_host_path_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/host_path_selector) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) @@ -82,7 +83,6 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/resources/host_path_selector.md b/docs/resources/host_path_selector.md new file mode 100644 index 000000000..a60cf5192 --- /dev/null +++ b/docs/resources/host_path_selector.md @@ -0,0 +1,127 @@ +--- +# 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: "Generic" +layout: "aci" +page_title: "ACI: aci_host_path_selector" +sidebar_current: "docs-aci-resource-aci_host_path_selector" +description: |- + Manages ACI Host Path Selector +--- + +# aci_host_path_selector # + +Manages ACI Host Path Selector + + + +## API Information ## + +* Class: [infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview) + +* Supported in ACI versions: 1.1(1j) and later. + +* Distinguished Name Format: `uni/infra/hpaths-{name}` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## + +The configuration snippet below creates a Host Path Selector with only required attributes. + +```hcl + +resource "aci_host_path_selector" "example" { + name = "host_path_selector" +} + +``` +The configuration snippet below shows all possible attributes of the Host Path Selector. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_host_path_selector" "full_example" { + annotation = "annotation" + description = "description" + name = "host_path_selector" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the Host Path Selector resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_host_path_selector) folder. + +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the Host Path Selector object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Host Path Selector object. + +### Optional ### +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - The distinguished name (DN) of classes below can be used but currently there is no available resource for it: + - [infraInfra](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraInfra/overview) + + - Default: `uni/infra` + +* `annotation` (annotation) - (string) The annotation of the Host Path Selector object. + - Default: `orchestrator:terraform` +* `description` (descr) - (string) The description of the Host Path Selector object. +* `name_alias` (nameAlias) - (string) The name alias of the Host Path Selector object. +* `owner_key` (ownerKey) - (string) The key for enabling clients to own their data for entity correlation. +* `owner_tag` (ownerTag) - (string) A tag for enabling clients to add their own data. For example, to indicate who created this object. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +## Importing + +An existing Host Path Selector 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_host_path_selector.example uni/infra/hpaths-{name} +``` + +Starting in Terraform version 1.5, an existing Host Path Selector can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/infra/hpaths-{name}" + to = aci_host_path_selector.example +} +``` diff --git a/docs/resources/tag.md b/docs/resources/tag.md index d879337bc..1144c4f3e 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -70,6 +70,7 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) + - [aci_host_path_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/host_path_selector) ([infraHPathS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPathS/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) @@ -82,7 +83,6 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/examples/data-sources/aci_host_path_selector/data-source.tf b/examples/data-sources/aci_host_path_selector/data-source.tf new file mode 100644 index 000000000..19a11528f --- /dev/null +++ b/examples/data-sources/aci_host_path_selector/data-source.tf @@ -0,0 +1,4 @@ + +data "aci_host_path_selector" "example" { + name = "host_path_selector" +} diff --git a/examples/data-sources/aci_host_path_selector/provider.tf b/examples/data-sources/aci_host_path_selector/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_host_path_selector/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_host_path_selector/provider.tf b/examples/resources/aci_host_path_selector/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_host_path_selector/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_host_path_selector/resource-all-attributes.tf b/examples/resources/aci_host_path_selector/resource-all-attributes.tf new file mode 100644 index 000000000..0f6159d53 --- /dev/null +++ b/examples/resources/aci_host_path_selector/resource-all-attributes.tf @@ -0,0 +1,21 @@ + +resource "aci_host_path_selector" "full_example" { + annotation = "annotation" + description = "description" + name = "host_path_selector" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_host_path_selector/resource.tf b/examples/resources/aci_host_path_selector/resource.tf new file mode 100644 index 000000000..f32f9050d --- /dev/null +++ b/examples/resources/aci_host_path_selector/resource.tf @@ -0,0 +1,4 @@ + +resource "aci_host_path_selector" "example" { + name = "host_path_selector" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index a28175ee5..54da69e84 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -218,3 +218,6 @@ mplsNodeSidP: - "uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/lbp-[{addr}]/nodesidp-{sidoffset}" contained_by: - "l3extLoopBackIfP" + +infraHPathS: + resource_name: "host_path_selector" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 7f582469f..932e14619 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -327,3 +327,20 @@ netflowRecordPol: - class_name: "fvTenant" parent_dependency: "" parent_dn: "aci_tenant.test.id" + +infraHPathS: + default_values: + parent_dn: "uni/infra" + test_values: + default: + name: "host_path_selector_default" + resource_required: + name: "host_path_selector" + datasource_required: + name: "host_path_selector" + datasource_non_existing: + name: "host_path_selector_non_existing" + parents: + - class_name: "infraInfra" + parent_dependency: "" + parent_dn: "uni/infra" diff --git a/gen/meta/infraHPathS.json b/gen/meta/infraHPathS.json new file mode 100644 index 000000000..f54679035 --- /dev/null +++ b/gen/meta/infraHPathS.json @@ -0,0 +1,786 @@ +{ + "infra:HPathS": { + "contains": { + "aaa:RbacAnnotation": "", + "fabric:RtToFabricPathS": "", + "fabric:RtToInfraPathS": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "infra:RsHPathAtt": "", + "infra:RsPathToAccBaseGrp": "", + "infra:SelectorIssues": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "rsHPathAtt-": "infra:RsHPathAtt", + "rspathToAccBaseGrp": "infra:RsPathToAccBaseGrp", + "rtinfraToInfraPathS-": "fabric:RtToInfraPathS", + "rttoFabricPathS-": "fabric:RtToFabricPathS", + "selectorissues": "infra:SelectorIssues", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "hpaths-{name}", + "containedBy": { + "infra:Infra": "" + }, + "superClasses": [ + "infra:APathS", + "fabric:APathS", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "fabric:RtToFabricPathS": "fabric:NodeCfg", + "fabric:RtToInfraPathS": "infra:NodeCfg" + }, + "relationTo": { + "infra:RsHPathAtt": "fabric:PathEp", + "infra:RsPathToAccBaseGrp": "infra:AccBaseGrp" + }, + "dnFormats": [ + "uni/infra/hpaths-{name}" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "custom-port-privilege" + ], + "faults": { + + }, + "events": { + "E4212236": "creation||infra:HPathS", + "E4212237": "modification||infra:HPathS", + "E4212238": "deletion||infra:HPathS" + }, + "stats": { + + }, + "versions": "1.1(1j)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": true, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + "apic" + ], + "classId": "6105", + "className": "HPathS", + "classPkg": "infra", + "featureTag": "", + "moCategory": "Regular", + "label": "Host Path Selector", + "comment": [ + "" + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38184", + "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 + }, + "creator": { + "versions": "5.2(8d)-5.2(8e),6.0(2h)-", + "isConfigurable": false, + "propGlobalId": "69215", + "propLocalId": "14578", + "label": "MO creator origin", + "baseType": "scalar:Enum8", + "modelType": "fabric:CreatorType", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "1", "localName": "SYSTEM", + "platformFlavors": [ + + ], + "label": "system maintained "}, + { "value": "0", "localName": "USER", + "platformFlavors": [ + + ], + "label": "created by the user "}, + { "value": "USER", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "USER", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(1e)-", + "comment": [ + "Specifies a description of the policy definition." + ], + "isConfigurable": true, + "propGlobalId": "5579", + "propLocalId": "28", + "label": "Description", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Described:descr", + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40323", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "versions": "1.1(1j)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "18171", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.1(1j)-", + "comment": [ + "The name of the object." + ], + "isConfigurable": true, + "propGlobalId": "18138", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 1, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "ownerKey": { + "versions": "1.0(1e)-", + "comment": [ + "The key for enabling clients to own their data for entity correlation." + ], + "isConfigurable": true, + "propGlobalId": "15230", + "propLocalId": "4100", + "label": "ownerKey", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "ownerTag": { + "versions": "1.0(1e)-", + "comment": [ + "A tag for enabling clients to add their own data. For example, to indicate who created this object." + ], + "isConfigurable": true, + "propGlobalId": "15231", + "propLocalId": "4101", + "label": "ownerTag", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/testvars/infraHPathS.yaml b/gen/testvars/infraHPathS.yaml new file mode 100644 index 000000000..d440bed6a --- /dev/null +++ b/gen/testvars/infraHPathS.yaml @@ -0,0 +1,43 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + description: "" + name_alias: "" + owner_key: "" + owner_tag: "" + +datasource_non_existing: + name: "host_path_selector_non_existing" + +datasource_required: + name: "host_path_selector" + +resource_required: + name: "host_path_selector" + +all: + annotation: "annotation" + description: "description" + name_alias: "name_alias" + owner_key: "owner_key" + owner_tag: "owner_tag" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + +parents: diff --git a/internal/provider/data_source_aci_host_path_selector.go b/internal/provider/data_source_aci_host_path_selector.go new file mode 100644 index 000000000..85862d7cb --- /dev/null +++ b/internal/provider/data_source_aci_host_path_selector.go @@ -0,0 +1,170 @@ +// 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-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &InfraHPathSDataSource{} + +func NewInfraHPathSDataSource() datasource.DataSource { + return &InfraHPathSDataSource{} +} + +// InfraHPathSDataSource defines the data source implementation. +type InfraHPathSDataSource struct { + client *client.Client +} + +func (d *InfraHPathSDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_host_path_selector") + resp.TypeName = req.ProviderTypeName + "_host_path_selector" + tflog.Debug(ctx, "End metadata of datasource: aci_host_path_selector") +} + +func (d *InfraHPathSDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_host_path_selector") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The host_path_selector datasource for the 'infraHPathS' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Host Path Selector object.", + }, + "parent_dn": schema.StringAttribute{ + Optional: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Host Path Selector object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Host Path Selector object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Host Path Selector object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Host Path Selector object.`, + }, + "owner_key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, + }, + "owner_tag": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "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_host_path_selector") +} + +func (d *InfraHPathSDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_host_path_selector") + // 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_host_path_selector") +} + +func (d *InfraHPathSDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_host_path_selector") + var data *InfraHPathSResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + if data.ParentDn.IsNull() || data.ParentDn.IsUnknown() { + data.ParentDn = basetypes.NewStringValue("uni/infra") + } + + setInfraHPathSId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraHPathSAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_host_path_selector with id '%s'", data.Id.ValueString())) + + getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_host_path_selector data source", + fmt.Sprintf("The aci_host_path_selector 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_host_path_selector with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_host_path_selector_test.go b/internal/provider/data_source_aci_host_path_selector_test.go new file mode 100644 index 000000000..58a62edf9 --- /dev/null +++ b/internal/provider/data_source_aci_host_path_selector_test.go @@ -0,0 +1,50 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceInfraHPathS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraHPathSDataSource, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "description", "description"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("data.aci_host_path_selector.test", "owner_tag", "owner_tag"), + ), + }, + { + Config: testConfigInfraHPathSNotExisting, + ExpectError: regexp.MustCompile("Failed to read aci_host_path_selector data source"), + }, + }, + }) +} + +const testConfigInfraHPathSDataSource = testConfigInfraHPathSAll + ` +data "aci_host_path_selector" "test" { + name = "host_path_selector" + depends_on = [aci_host_path_selector.test] +} +` + +const testConfigInfraHPathSNotExisting = testConfigInfraHPathSAll + ` +data "aci_host_path_selector" "test" { + name = "host_path_selector_non_existing" + depends_on = [aci_host_path_selector.test] +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 431a6fb26..6cb6b187b 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -200,6 +200,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvEpMacTagResource, NewFvFBRGroupResource, NewFvFBRMemberResource, + NewInfraHPathSResource, NewL3extConsLblResource, NewL3extProvLblResource, NewL3extRsOutToFBRGroupResource, @@ -226,6 +227,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvEpMacTagDataSource, NewFvFBRGroupDataSource, NewFvFBRMemberDataSource, + NewInfraHPathSDataSource, NewL3extConsLblDataSource, NewL3extProvLblDataSource, NewL3extRsOutToFBRGroupDataSource, diff --git a/internal/provider/resource_aci_host_path_selector.go b/internal/provider/resource_aci_host_path_selector.go new file mode 100644 index 000000000..9a7aaca11 --- /dev/null +++ b/internal/provider/resource_aci_host_path_selector.go @@ -0,0 +1,625 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &InfraHPathSResource{} +var _ resource.ResourceWithImportState = &InfraHPathSResource{} + +func NewInfraHPathSResource() resource.Resource { + return &InfraHPathSResource{} +} + +// InfraHPathSResource defines the resource implementation. +type InfraHPathSResource struct { + client *client.Client +} + +// InfraHPathSResourceModel describes the resource data model. +type InfraHPathSResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + OwnerKey types.String `tfsdk:"owner_key"` + OwnerTag types.String `tfsdk:"owner_tag"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +// TagAnnotationInfraHPathSResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraHPathSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +// TagTagInfraHPathSResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraHPathSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +type InfraHPathSIdentifier struct { + Name types.String +} + +func (r *InfraHPathSResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_host_path_selector") + resp.TypeName = req.ProviderTypeName + "_host_path_selector" + tflog.Debug(ctx, "End metadata of resource: aci_host_path_selector") +} + +func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_host_path_selector") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The host_path_selector resource for the 'infraHPathS' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Host Path Selector object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + Default: stringdefault.StaticString("uni/infra"), + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Host Path Selector object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the Host Path Selector object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Host Path Selector object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the Host Path Selector object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`, + }, + "owner_tag": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "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_host_path_selector") +} + +func (r *InfraHPathSResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_host_path_selector") + // 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_host_path_selector") +} + +func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_host_path_selector") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraHPathSResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + setInfraHPathSId(ctx, stateData) + getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *InfraHPathSResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setInfraHPathSId(ctx, data) + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_host_path_selector with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetInfraHPathSAttributes(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_host_path_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPathSResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_host_path_selector") + var data *InfraHPathSResourceModel + + // 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_host_path_selector with id '%s'", data.Id.ValueString())) + + getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraHPathSResourceModel + 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_host_path_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPathSResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_host_path_selector") + var data *InfraHPathSResourceModel + var stateData *InfraHPathSResourceModel + + // 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_host_path_selector with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetInfraHPathSAttributes(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_host_path_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPathSResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_host_path_selector") + var data *InfraHPathSResourceModel + + // 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_host_path_selector with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraHPathS", 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_host_path_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPathSResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_host_path_selector") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraHPathSResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_host_path_selector with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_host_path_selector") +} + +func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraHPathSResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "infraHPathS,tagAnnotation,tagTag"), "GET", nil) + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraHPathS").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraHPathS").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)) + setInfraHPathSParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + data.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + data.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + data.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + data.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + data.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationInfraHPathSList := make([]TagAnnotationInfraHPathSResourceModel, 0) + TagTagInfraHPathSList := make([]TagTagInfraHPathSResourceModel, 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" { + TagAnnotationInfraHPathS := TagAnnotationInfraHPathSResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraHPathS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraHPathS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationInfraHPathSList = append(TagAnnotationInfraHPathSList, TagAnnotationInfraHPathS) + } + if childClassName == "tagTag" { + TagTagInfraHPathS := TagTagInfraHPathSResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraHPathS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraHPathS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagInfraHPathSList = append(TagTagInfraHPathSList, TagTagInfraHPathS) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationInfraHPathSList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagInfraHPathSList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraHPathS'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getInfraHPathSRn(ctx context.Context, data *InfraHPathSResourceModel) string { + rn := "hpaths-{name}" + for _, identifier := range []string{"name"} { + 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 setInfraHPathSParentDn(ctx context.Context, dn string, data *InfraHPathSResourceModel) { + 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 setInfraHPathSId(ctx context.Context, data *InfraHPathSResourceModel) { + rn := getInfraHPathSRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraHPathSTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotation := range tagAnnotationPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagAnnotation.Key.IsUnknown() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func getInfraHPathSTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTag := range tagTagPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagTag.Key.IsUnknown() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *InfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getInfraHPathSTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraHPathSTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + if !data.OwnerKey.IsNull() && !data.OwnerKey.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerKey"] = data.OwnerKey.ValueString() + } + if !data.OwnerTag.IsNull() && !data.OwnerTag.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerTag"] = data.OwnerTag.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"infraHPathS": 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_host_path_selector_test.go b/internal/provider/resource_aci_host_path_selector_test.go new file mode 100644 index 000000000..4978541cb --- /dev/null +++ b/internal/provider/resource_aci_host_path_selector_test.go @@ -0,0 +1,240 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourceInfraHPathS(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: testConfigInfraHPathSMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraHPathSAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraHPathSMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", "description"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", "name_alias"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", "owner_key"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", "owner_tag"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraHPathSReset, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_host_path_selector.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name", "host_path_selector"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + ), + }, + // Update with children + { + Config: testConfigInfraHPathSChildren, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "2"), + ), + }, + // Update with children removed from config + { + Config: testConfigInfraHPathSChildrenRemoveFromConfig, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraHPathSChildrenRemoveOne, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigInfraHPathSChildrenRemoveAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_host_path_selector.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigInfraHPathSMin = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" +} +` + +const testConfigInfraHPathSAll = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotation = "annotation" + description = "description" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" +} +` + +const testConfigInfraHPathSReset = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraHPathSChildren = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigInfraHPathSChildrenRemoveFromConfig = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" +} +` + +const testConfigInfraHPathSChildrenRemoveOne = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigInfraHPathSChildrenRemoveAll = ` +resource "aci_host_path_selector" "test" { + name = "host_path_selector" + annotations = [] + tags = [] +} +`