From 5ad5ce6e996e06f777fda8a2fa1082e02d4c1821 Mon Sep 17 00:00:00 2001 From: akinross Date: Mon, 10 Nov 2025 14:12:22 +0100 Subject: [PATCH 1/5] [ignore] Remove legacy files for access_port_block, access_port_selector, fex_profile. leaf_interface_profile, spine_interface_profile and spine_access_port_selector --- aci/data_source_aci_infraaccportp.go | 54 --- aci/data_source_aci_infrafexp.go | 54 --- aci/data_source_aci_infrahports.go | 84 ---- aci/data_source_aci_infraportblk.go | 98 ----- aci/data_source_aci_infrashports.go | 75 ---- aci/data_source_aci_infraspaccportp.go | 56 --- aci/provider.go | 12 - aci/resource_aci_infraaccportp.go | 199 --------- aci/resource_aci_infraaccportp_test.go | 141 ------- aci/resource_aci_infrafexp.go | 196 --------- aci/resource_aci_infrafexp_test.go | 140 ------- aci/resource_aci_infrahports.go | 319 --------------- aci/resource_aci_infrahports_test.go | 155 ------- aci/resource_aci_infraportblk.go | 380 ------------------ aci/resource_aci_infraportblk_test.go | 163 -------- aci/resource_aci_infrashports.go | 305 -------------- aci/resource_aci_infrashports_test.go | 140 ------- aci/resource_aci_infraspaccportp.go | 193 --------- aci/resource_aci_infraspaccportp_test.go | 141 ------- .../docs/d/access_port_block.html.markdown | 50 --- .../docs/d/access_port_selector.html.markdown | 35 -- legacy-docs/docs/d/fex_profile.html.markdown | 33 -- .../d/leaf_interface_profile.html.markdown | 30 -- .../spine_access_port_selector.html.markdown | 45 --- .../d/spine_interface_profile.html.markdown | 35 -- .../docs/r/access_port_block.html.markdown | 66 --- .../docs/r/access_port_selector.html.markdown | 50 --- legacy-docs/docs/r/fex_profile.html.markdown | 46 --- .../r/leaf_interface_profile.html.markdown | 44 -- .../spine_access_port_selector.html.markdown | 57 --- .../r/spine_interface_profile.html.markdown | 48 --- 31 files changed, 3444 deletions(-) delete mode 100644 aci/data_source_aci_infraaccportp.go delete mode 100644 aci/data_source_aci_infrafexp.go delete mode 100644 aci/data_source_aci_infrahports.go delete mode 100644 aci/data_source_aci_infraportblk.go delete mode 100644 aci/data_source_aci_infrashports.go delete mode 100644 aci/data_source_aci_infraspaccportp.go delete mode 100644 aci/resource_aci_infraaccportp.go delete mode 100644 aci/resource_aci_infraaccportp_test.go delete mode 100644 aci/resource_aci_infrafexp.go delete mode 100644 aci/resource_aci_infrafexp_test.go delete mode 100644 aci/resource_aci_infrahports.go delete mode 100644 aci/resource_aci_infrahports_test.go delete mode 100644 aci/resource_aci_infraportblk.go delete mode 100644 aci/resource_aci_infraportblk_test.go delete mode 100644 aci/resource_aci_infrashports.go delete mode 100644 aci/resource_aci_infrashports_test.go delete mode 100644 aci/resource_aci_infraspaccportp.go delete mode 100644 aci/resource_aci_infraspaccportp_test.go delete mode 100644 legacy-docs/docs/d/access_port_block.html.markdown delete mode 100644 legacy-docs/docs/d/access_port_selector.html.markdown delete mode 100644 legacy-docs/docs/d/fex_profile.html.markdown delete mode 100644 legacy-docs/docs/d/leaf_interface_profile.html.markdown delete mode 100644 legacy-docs/docs/d/spine_access_port_selector.html.markdown delete mode 100644 legacy-docs/docs/d/spine_interface_profile.html.markdown delete mode 100644 legacy-docs/docs/r/access_port_block.html.markdown delete mode 100644 legacy-docs/docs/r/access_port_selector.html.markdown delete mode 100644 legacy-docs/docs/r/fex_profile.html.markdown delete mode 100644 legacy-docs/docs/r/leaf_interface_profile.html.markdown delete mode 100644 legacy-docs/docs/r/spine_access_port_selector.html.markdown delete mode 100644 legacy-docs/docs/r/spine_interface_profile.html.markdown diff --git a/aci/data_source_aci_infraaccportp.go b/aci/data_source_aci_infraaccportp.go deleted file mode 100644 index b5f604f18..000000000 --- a/aci/data_source_aci_infraaccportp.go +++ /dev/null @@ -1,54 +0,0 @@ -package aci - -import ( - "context" - "fmt" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceAciLeafInterfaceProfile() *schema.Resource { - return &schema.Resource{ - - ReadContext: dataSourceAciLeafInterfaceProfileRead, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - }), - } -} - -func dataSourceAciLeafInterfaceProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - aciClient := m.(*client.Client) - - name := d.Get("name").(string) - - rn := fmt.Sprintf("infra/accportprof-%s", name) - - dn := fmt.Sprintf("uni/%s", rn) - - infraAccPortP, err := getRemoteLeafInterfaceProfile(aciClient, dn) - - if err != nil { - return diag.FromErr(err) - } - _, err = setLeafInterfaceProfileAttributes(infraAccPortP, d) - if err != nil { - return diag.FromErr(err) - } - return nil -} diff --git a/aci/data_source_aci_infrafexp.go b/aci/data_source_aci_infrafexp.go deleted file mode 100644 index 55dd4bea7..000000000 --- a/aci/data_source_aci_infrafexp.go +++ /dev/null @@ -1,54 +0,0 @@ -package aci - -import ( - "context" - "fmt" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceAciFEXProfile() *schema.Resource { - return &schema.Resource{ - - ReadContext: dataSourceAciFEXProfileRead, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - }), - } -} - -func dataSourceAciFEXProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - aciClient := m.(*client.Client) - - name := d.Get("name").(string) - - rn := fmt.Sprintf("infra/fexprof-%s", name) - - dn := fmt.Sprintf("uni/%s", rn) - - infraFexP, err := getRemoteFEXProfile(aciClient, dn) - - if err != nil { - return diag.FromErr(err) - } - _, err = setFEXProfileAttributes(infraFexP, d) - if err != nil { - return diag.FromErr(err) - } - return nil -} diff --git a/aci/data_source_aci_infrahports.go b/aci/data_source_aci_infrahports.go deleted file mode 100644 index aa5d8c5a7..000000000 --- a/aci/data_source_aci_infrahports.go +++ /dev/null @@ -1,84 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceAciAccessPortSelector() *schema.Resource { - return &schema.Resource{ - - ReadContext: dataSourceAciAccessPortSelectorRead, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - "leaf_interface_profile_dn": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "access_port_selector_type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "relation_infra_rs_acc_base_grp": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, - }), - } -} - -func dataSourceAciAccessPortSelectorRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - aciClient := m.(*client.Client) - - name := d.Get("name").(string) - - access_port_selector_type := d.Get("access_port_selector_type").(string) - - rn := fmt.Sprintf("hports-%s-typ-%s", name, access_port_selector_type) - LeafInterfaceProfileDn := d.Get("leaf_interface_profile_dn").(string) - - dn := fmt.Sprintf("%s/%s", LeafInterfaceProfileDn, rn) - log.Printf("[DEBUG] %s: Data Source - Beginning Read", dn) - - infraHPortS, err := getRemoteAccessPortSelector(aciClient, dn) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(dn) - - _, err = setAccessPortSelectorAttributes(infraHPortS, d) - if err != nil { - return diag.FromErr(err) - } - - // infraRsAccBaseGrp - Beginning Read - log.Printf("[DEBUG] %s: infraRsAccBaseGrp - Beginning Read with parent DN", dn) - _, err = getAndSetReadRelationinfraRsAccBaseGrpFromAccessPortSelector(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsAccBaseGrp - Read finished successfully", d.Get("relation_infra_rs_acc_base_grp")) - } - // infraRsAccBaseGrp - Read finished successfully - - log.Printf("[DEBUG] %s: Data Source - Read finished successfully", dn) - return nil -} diff --git a/aci/data_source_aci_infraportblk.go b/aci/data_source_aci_infraportblk.go deleted file mode 100644 index 454422d51..000000000 --- a/aci/data_source_aci_infraportblk.go +++ /dev/null @@ -1,98 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceAciAccessPortBlock() *schema.Resource { - return &schema.Resource{ - - ReadContext: dataSourceAciAccessPortBlockRead, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - "access_port_selector_dn": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "from_card": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "from_port": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "to_card": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "to_port": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "relation_infra_rs_acc_bndl_subgrp": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, - }), - } -} - -func dataSourceAciAccessPortBlockRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - aciClient := m.(*client.Client) - - name := d.Get("name").(string) - - rn := fmt.Sprintf("portblk-%s", name) - AccessPortSelectorDn := d.Get("access_port_selector_dn").(string) - - dn := fmt.Sprintf("%s/%s", AccessPortSelectorDn, rn) - - infraPortBlk, err := getRemoteAccessPortBlock(aciClient, dn) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(dn) - - _, err = setAccessPortBlockAttributes(infraPortBlk, d) - if err != nil { - return diag.FromErr(err) - } - - log.Printf("[DEBUG] %s: infraRsAccBndlSubgrp - Beginning Read with parent DN", dn) - _, err = getAndSetReadRelationinfraRsAccBndlSubgrp(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsAccBndlSubgrp - Read finished successfully", d.Get("relation_infra_rs_acc_bndl_subgrp")) - } - - return nil -} diff --git a/aci/data_source_aci_infrashports.go b/aci/data_source_aci_infrashports.go deleted file mode 100644 index a35dc4d31..000000000 --- a/aci/data_source_aci_infrashports.go +++ /dev/null @@ -1,75 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceAciSpineAccessPortSelector() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceAciSpineAccessPortSelectorRead, - SchemaVersion: 1, - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - "spine_interface_profile_dn": { - Type: schema.TypeString, - Required: true, - }, - - "name": { - Type: schema.TypeString, - Required: true, - }, - - "spine_access_port_selector_type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - "relation_infra_rs_sp_acc_grp": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, - }), - } -} - -func dataSourceAciSpineAccessPortSelectorRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - aciClient := m.(*client.Client) - - name := d.Get("name").(string) - - spine_access_port_selector_type := d.Get("spine_access_port_selector_type").(string) - - rn := fmt.Sprintf("shports-%s-typ-%s", name, spine_access_port_selector_type) - SpineInterfaceProfileDn := d.Get("spine_interface_profile_dn").(string) - - dn := fmt.Sprintf("%s/%s", SpineInterfaceProfileDn, rn) - log.Printf("[DEBUG] %s: Data Source - Beginning Read", dn) - - infraSHPortS, err := getRemoteSpineAccessPortSelector(aciClient, dn) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(dn) - - _, err = setSpineAccessPortSelectorAttributes(infraSHPortS, d) - if err != nil { - return diag.FromErr(err) - } - - // infraRsSpAccGrp - Beginning Read - log.Printf("[DEBUG] %s: infraRsSpAccGrp - Beginning Read with parent DN", dn) - _, err = getAndSetReadRelationinfraRsSpAccGrp(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsSpAccGrp - Read finished successfully", d.Get("relation_infra_rs_sp_acc_grp")) - } - // infraRsSpAccGrp - Read finished successfully - - log.Printf("[DEBUG] %s: Data Source - Read finished successfully", dn) - return nil -} diff --git a/aci/data_source_aci_infraspaccportp.go b/aci/data_source_aci_infraspaccportp.go deleted file mode 100644 index 4f360828b..000000000 --- a/aci/data_source_aci_infraspaccportp.go +++ /dev/null @@ -1,56 +0,0 @@ -package aci - -import ( - "context" - "fmt" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceAciSpineInterfaceProfile() *schema.Resource { - return &schema.Resource{ - - ReadContext: dataSourceAciSpineInterfaceProfileRead, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - }), - } -} - -func dataSourceAciSpineInterfaceProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - aciClient := m.(*client.Client) - - name := d.Get("name").(string) - - rn := fmt.Sprintf("infra/spaccportprof-%s", name) - - dn := fmt.Sprintf("uni/%s", rn) - - infraSpAccPortP, err := getRemoteSpineInterfaceProfile(aciClient, dn) - - if err != nil { - return diag.FromErr(err) - } - _, err = setSpineInterfaceProfileAttributes(infraSpAccPortP, d) - - if err != nil { - return diag.FromErr(err) - } - - return nil -} diff --git a/aci/provider.go b/aci/provider.go index 2e78cfa4f..4a336db65 100644 --- a/aci/provider.go +++ b/aci/provider.go @@ -92,7 +92,6 @@ func Provider() *schema.Provider { "aci_rest": resourceAciRest(), "aci_external_network_instance_profile": resourceAciExternalNetworkInstanceProfile(), "aci_l3_outside": resourceAciL3Outside(), - "aci_leaf_interface_profile": resourceAciLeafInterfaceProfile(), "aci_bfd_multihop_interface_profile": resourceAciBfdMultihopInterfaceProfile(), "aci_bfd_multihop_interface_policy": resourceAciBfdMultihopInterfacePolicy(), "aci_bfd_multihop_node_policy": resourceAciBFDMultihopNodePolicy(), @@ -104,8 +103,6 @@ func Provider() *schema.Provider { "aci_lldp_interface_policy": resourceAciLLDPInterfacePolicy(), "aci_miscabling_protocol_interface_policy": resourceAciMiscablingProtocolInterfacePolicy(), "aci_ospf_interface_policy": resourceAciOSPFInterfacePolicy(), - "aci_access_port_selector": resourceAciAccessPortSelector(), - "aci_access_port_block": resourceAciAccessPortBlock(), "aci_lacp_policy": resourceAciLACPPolicy(), "aci_lacp_member_policy": resourceAciLACPMemberPolicy(), "aci_port_security_policy": resourceAciPortSecurityPolicy(), @@ -178,14 +175,12 @@ func Provider() *schema.Provider { "aci_epgs_using_function": resourceAciEPGsUsingFunction(), "aci_service_redirect_policy": resourceAciServiceRedirectPolicy(), "aci_destination_of_redirected_traffic": resourceAciDestinationofredirectedtraffic(), - "aci_fex_profile": resourceAciFEXProfile(), "aci_fex_bundle_group": resourceAciFexBundleGroup(), "aci_access_group": resourceAciAccessGroup(), "aci_spine_profile": resourceAciSpineProfile(), "aci_spine_switch_association": resourceAciSwitchSpineAssociation(), "aci_spine_interface_profile_selector": resourceAciInterfaceProfile(), "aci_spine_port_selector": resourceAciInterfaceProfileDeprecated(), - "aci_spine_interface_profile": resourceAciSpineInterfaceProfile(), "aci_spine_port_policy_group": resourceAciSpineAccessPortPolicyGroup(), "aci_fabric_if_pol": resourceAciLinkLevelPolicy(), "aci_spanning_tree_interface_policy": resourceAciSpanningTreeInterfacePolicy(), @@ -290,7 +285,6 @@ func Provider() *schema.Provider { "aci_match_community_terms": resourceAciMatchCommunityTerm(), "aci_match_regex_community_terms": resourceAciMatchRuleBasedonCommunityRegularExpression(), "aci_match_route_destination_rule": resourceAciMatchRouteDestinationRule(), - "aci_spine_access_port_selector": resourceAciSpineAccessPortSelector(), "aci_aaa_domain_relationship": resourceAciDomainRelationship(), "aci_aaep_to_domain": resourceAciInfraRsDomP(), "aci_action_rule_additional_communities": resourceAciRtctrlSetAddComm(), @@ -329,7 +323,6 @@ func Provider() *schema.Provider { "aci_vrf_to_bgp_address_family_context": dataSourceAciBGPAddressFamilyContextPolicyRelationship(), "aci_external_network_instance_profile": dataSourceAciExternalNetworkInstanceProfile(), "aci_l3_outside": dataSourceAciL3Outside(), - "aci_leaf_interface_profile": dataSourceAciLeafInterfaceProfile(), "aci_bfd_multihop_interface_profile": dataSourceAciBfdMultihopInterfaceProfile(), "aci_bfd_multihop_interface_policy": dataSourceAciBfdMultihopInterfacePolicy(), "aci_bfd_multihop_node_policy": dataSourceAciBFDMultihopNodePolicy(), @@ -341,8 +334,6 @@ func Provider() *schema.Provider { "aci_lldp_interface_policy": dataSourceAciLLDPInterfacePolicy(), "aci_miscabling_protocol_interface_policy": dataSourceAciMiscablingProtocolInterfacePolicy(), "aci_ospf_interface_policy": dataSourceAciOSPFInterfacePolicy(), - "aci_access_port_selector": dataSourceAciAccessPortSelector(), - "aci_access_port_block": dataSourceAciAccessPortBlock(), "aci_lacp_policy": dataSourceAciLACPPolicy(), "aci_lacp_member_policy": dataSourceAciLACPMemberPolicy(), "aci_port_security_policy": dataSourceAciPortSecurityPolicy(), @@ -419,14 +410,12 @@ func Provider() *schema.Provider { "aci_epgs_using_function": dataSourceAciEPGsUsingFunction(), "aci_service_redirect_policy": dataSourceAciServiceRedirectPolicy(), "aci_destination_of_redirected_traffic": dataSourceAciDestinationofredirectedtraffic(), - "aci_fex_profile": dataSourceAciFEXProfile(), "aci_fex_bundle_group": dataSourceAciFexBundleGroup(), "aci_access_group": dataSourceAciAccessGroup(), "aci_spine_profile": dataSourceAciSpineProfile(), "aci_spine_switch_association": dataSourceAciSwitchSpineAssociation(), "aci_spine_interface_profile_selector": dataSourceAciInterfaceProfile(), "aci_spine_port_selector": dataSourceAciInterfaceProfileDeprecated(), - "aci_spine_interface_profile": dataSourceAciSpineInterfaceProfile(), "aci_spine_port_policy_group": dataSourceAciSpineAccessPortPolicyGroup(), "aci_fabric_path_ep": dataSourceAciFabricPathEndpoint(), "aci_fabric_if_pol": dataSourceAciLinkLevelPolicy(), @@ -537,7 +526,6 @@ func Provider() *schema.Provider { "aci_match_community_terms": dataSourceAciMatchCommunityTerm(), "aci_match_regex_community_terms": dataSourceAciMatchRuleBasedonCommunityRegularExpression(), "aci_match_route_destination_rule": dataSourceAciMatchRouteDestinationRule(), - "aci_spine_access_port_selector": dataSourceAciSpineAccessPortSelector(), "aci_aaa_domain_relationship": dataSourceAciDomainRelationship(), "aci_aaep_to_domain": dataSourceAciInfraRsDomP(), "aci_action_rule_additional_communities": dataSourceAciRtctrlSetAddComm(), diff --git a/aci/resource_aci_infraaccportp.go b/aci/resource_aci_infraaccportp.go deleted file mode 100644 index fcd0d3555..000000000 --- a/aci/resource_aci_infraaccportp.go +++ /dev/null @@ -1,199 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceAciLeafInterfaceProfile() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceAciLeafInterfaceProfileCreate, - UpdateContext: resourceAciLeafInterfaceProfileUpdate, - ReadContext: resourceAciLeafInterfaceProfileRead, - DeleteContext: resourceAciLeafInterfaceProfileDelete, - - Importer: &schema.ResourceImporter{ - State: resourceAciLeafInterfaceProfileImport, - }, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - }), - } -} -func getRemoteLeafInterfaceProfile(client *client.Client, dn string) (*models.LeafInterfaceProfile, error) { - infraAccPortPCont, err := client.Get(dn) - if err != nil { - return nil, err - } - - infraAccPortP := models.LeafInterfaceProfileFromContainer(infraAccPortPCont) - - if infraAccPortP.DistinguishedName == "" { - return nil, fmt.Errorf("Leaf Interface Profile %s not found", dn) - } - - return infraAccPortP, nil -} - -func setLeafInterfaceProfileAttributes(infraAccPortP *models.LeafInterfaceProfile, d *schema.ResourceData) (*schema.ResourceData, error) { - d.SetId(infraAccPortP.DistinguishedName) - d.Set("description", infraAccPortP.Description) - infraAccPortPMap, err := infraAccPortP.ToMap() - if err != nil { - return d, err - } - - d.Set("name", infraAccPortPMap["name"]) - d.Set("annotation", infraAccPortPMap["annotation"]) - d.Set("name_alias", infraAccPortPMap["nameAlias"]) - return d, nil -} - -func resourceAciLeafInterfaceProfileImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - log.Printf("[DEBUG] %s: Beginning Import", d.Id()) - aciClient := m.(*client.Client) - - dn := d.Id() - - infraAccPortP, err := getRemoteLeafInterfaceProfile(aciClient, dn) - - if err != nil { - return nil, err - } - schemaFilled, err := setLeafInterfaceProfileAttributes(infraAccPortP, d) - if err != nil { - return nil, err - } - - log.Printf("[DEBUG] %s: Import finished successfully", d.Id()) - - return []*schema.ResourceData{schemaFilled}, nil -} - -func resourceAciLeafInterfaceProfileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] LeafInterfaceProfile: Beginning Creation") - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - name := d.Get("name").(string) - - infraAccPortPAttr := models.LeafInterfaceProfileAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraAccPortPAttr.Annotation = Annotation.(string) - } else { - infraAccPortPAttr.Annotation = "{}" - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraAccPortPAttr.NameAlias = NameAlias.(string) - } - infraAccPortP := models.NewLeafInterfaceProfile(fmt.Sprintf("infra/accportprof-%s", name), "uni", desc, infraAccPortPAttr) - - err := aciClient.Save(infraAccPortP) - if err != nil { - return diag.FromErr(err) - } - d.Partial(true) - - d.Partial(false) - - d.SetId(infraAccPortP.DistinguishedName) - log.Printf("[DEBUG] %s: Creation finished successfully", d.Id()) - - return resourceAciLeafInterfaceProfileRead(ctx, d, m) -} - -func resourceAciLeafInterfaceProfileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] LeafInterfaceProfile: Beginning Update") - - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - name := d.Get("name").(string) - - infraAccPortPAttr := models.LeafInterfaceProfileAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraAccPortPAttr.Annotation = Annotation.(string) - } else { - infraAccPortPAttr.Annotation = "{}" - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraAccPortPAttr.NameAlias = NameAlias.(string) - } - infraAccPortP := models.NewLeafInterfaceProfile(fmt.Sprintf("infra/accportprof-%s", name), "uni", desc, infraAccPortPAttr) - - infraAccPortP.Status = "modified" - - err := aciClient.Save(infraAccPortP) - - if err != nil { - return diag.FromErr(err) - } - d.Partial(true) - - d.Partial(false) - - d.SetId(infraAccPortP.DistinguishedName) - log.Printf("[DEBUG] %s: Update finished successfully", d.Id()) - - return resourceAciLeafInterfaceProfileRead(ctx, d, m) - -} - -func resourceAciLeafInterfaceProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Read", d.Id()) - - aciClient := m.(*client.Client) - - dn := d.Id() - infraAccPortP, err := getRemoteLeafInterfaceProfile(aciClient, dn) - - if err != nil { - return errorForObjectNotFound(err, dn, d) - } - - _, err = setLeafInterfaceProfileAttributes(infraAccPortP, d) - if err != nil { - d.SetId("") - return nil - } - - log.Printf("[DEBUG] %s: Read finished successfully", d.Id()) - - return nil -} - -func resourceAciLeafInterfaceProfileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Destroy", d.Id()) - - aciClient := m.(*client.Client) - dn := d.Id() - err := aciClient.DeleteByDn(dn, "infraAccPortP") - if err != nil { - return diag.FromErr(err) - } - - log.Printf("[DEBUG] %s: Destroy finished successfully", d.Id()) - - d.SetId("") - return diag.FromErr(err) -} diff --git a/aci/resource_aci_infraaccportp_test.go b/aci/resource_aci_infraaccportp_test.go deleted file mode 100644 index 8863c6e5c..000000000 --- a/aci/resource_aci_infraaccportp_test.go +++ /dev/null @@ -1,141 +0,0 @@ -package aci - -import ( - "fmt" - "testing" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccAciLeafInterfaceProfile_Basic(t *testing.T) { - var leaf_interface_profile models.LeafInterfaceProfile - description := "leaf_interface_profile created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciLeafInterfaceProfileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciLeafInterfaceProfileConfig_basic(description, "alias_leaf"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciLeafInterfaceProfileExists("aci_leaf_interface_profile.fooleaf_interface_profile", &leaf_interface_profile), - testAccCheckAciLeafInterfaceProfileAttributes(description, "alias_leaf", &leaf_interface_profile), - ), - }, - }, - }) -} - -func TestAccAciLeafInterfaceProfile_update(t *testing.T) { - var leaf_interface_profile models.LeafInterfaceProfile - description := "leaf_interface_profile created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciLeafInterfaceProfileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciLeafInterfaceProfileConfig_basic(description, "alias_leaf"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciLeafInterfaceProfileExists("aci_leaf_interface_profile.fooleaf_interface_profile", &leaf_interface_profile), - testAccCheckAciLeafInterfaceProfileAttributes(description, "alias_leaf", &leaf_interface_profile), - ), - }, - { - Config: testAccCheckAciLeafInterfaceProfileConfig_basic(description, "alias_update"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciLeafInterfaceProfileExists("aci_leaf_interface_profile.fooleaf_interface_profile", &leaf_interface_profile), - testAccCheckAciLeafInterfaceProfileAttributes(description, "alias_update", &leaf_interface_profile), - ), - }, - }, - }) -} - -func testAccCheckAciLeafInterfaceProfileConfig_basic(description, name_alias string) string { - return fmt.Sprintf(` - - resource "aci_leaf_interface_profile" "fooleaf_interface_profile" { - description = "%s" - name = "demo_leaf_profile" - annotation = "tag_leaf" - name_alias = "%s" - } - `, description, name_alias) -} - -func testAccCheckAciLeafInterfaceProfileExists(name string, leaf_interface_profile *models.LeafInterfaceProfile) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - - if !ok { - return fmt.Errorf("Leaf Interface Profile %s not found", name) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No Leaf Interface Profile dn was set") - } - - client := testAccProvider.Meta().(*client.Client) - - cont, err := client.Get(rs.Primary.ID) - if err != nil { - return err - } - - leaf_interface_profileFound := models.LeafInterfaceProfileFromContainer(cont) - if leaf_interface_profileFound.DistinguishedName != rs.Primary.ID { - return fmt.Errorf("Leaf Interface Profile %s not found", rs.Primary.ID) - } - *leaf_interface_profile = *leaf_interface_profileFound - return nil - } -} - -func testAccCheckAciLeafInterfaceProfileDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*client.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type == "aci_leaf_interface_profile" { - cont, err := client.Get(rs.Primary.ID) - leaf_interface_profile := models.LeafInterfaceProfileFromContainer(cont) - if err == nil { - return fmt.Errorf("Leaf Interface Profile %s Still exists", leaf_interface_profile.DistinguishedName) - } - - } else { - continue - } - } - - return nil -} - -func testAccCheckAciLeafInterfaceProfileAttributes(description, name_alias string, leaf_interface_profile *models.LeafInterfaceProfile) resource.TestCheckFunc { - return func(s *terraform.State) error { - - if description != leaf_interface_profile.Description { - return fmt.Errorf("Bad leaf_interface_profile Description %s", leaf_interface_profile.Description) - } - - if "demo_leaf_profile" != leaf_interface_profile.Name { - return fmt.Errorf("Bad leaf_interface_profile name %s", leaf_interface_profile.Name) - } - - if "tag_leaf" != leaf_interface_profile.Annotation { - return fmt.Errorf("Bad leaf_interface_profile annotation %s", leaf_interface_profile.Annotation) - } - - if name_alias != leaf_interface_profile.NameAlias { - return fmt.Errorf("Bad leaf_interface_profile name_alias %s", leaf_interface_profile.NameAlias) - } - - return nil - } -} diff --git a/aci/resource_aci_infrafexp.go b/aci/resource_aci_infrafexp.go deleted file mode 100644 index 3fc7b46f3..000000000 --- a/aci/resource_aci_infrafexp.go +++ /dev/null @@ -1,196 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceAciFEXProfile() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceAciFEXProfileCreate, - UpdateContext: resourceAciFEXProfileUpdate, - ReadContext: resourceAciFEXProfileRead, - DeleteContext: resourceAciFEXProfileDelete, - - Importer: &schema.ResourceImporter{ - State: resourceAciFEXProfileImport, - }, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - }), - } -} - -func getRemoteFEXProfile(client *client.Client, dn string) (*models.FEXProfile, error) { - infraFexPCont, err := client.Get(dn) - if err != nil { - return nil, err - } - - infraFexP := models.FEXProfileFromContainer(infraFexPCont) - - if infraFexP.DistinguishedName == "" { - return nil, fmt.Errorf("FEX Profile %s not found", dn) - } - - return infraFexP, nil -} - -func setFEXProfileAttributes(infraFexP *models.FEXProfile, d *schema.ResourceData) (*schema.ResourceData, error) { - d.SetId(infraFexP.DistinguishedName) - d.Set("description", infraFexP.Description) - infraFexPMap, err := infraFexP.ToMap() - if err != nil { - return d, err - } - - d.Set("name", infraFexPMap["name"]) - - d.Set("annotation", infraFexPMap["annotation"]) - d.Set("name_alias", infraFexPMap["nameAlias"]) - return d, nil -} - -func resourceAciFEXProfileImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - log.Printf("[DEBUG] %s: Beginning Import", d.Id()) - aciClient := m.(*client.Client) - - dn := d.Id() - - infraFexP, err := getRemoteFEXProfile(aciClient, dn) - - if err != nil { - return nil, err - } - schemaFilled, err := setFEXProfileAttributes(infraFexP, d) - if err != nil { - return nil, err - } - - log.Printf("[DEBUG] %s: Import finished successfully", d.Id()) - - return []*schema.ResourceData{schemaFilled}, nil -} - -func resourceAciFEXProfileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] FEXProfile: Beginning Creation") - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - name := d.Get("name").(string) - - infraFexPAttr := models.FEXProfileAttributes{} - - if Annotation, ok := d.GetOk("annotation"); ok { - infraFexPAttr.Annotation = Annotation.(string) - } else { - infraFexPAttr.Annotation = "{}" - } - - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraFexPAttr.NameAlias = NameAlias.(string) - } - infraFexP := models.NewFEXProfile(fmt.Sprintf("infra/fexprof-%s", name), "uni", desc, infraFexPAttr) - - err := aciClient.Save(infraFexP) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(infraFexP.DistinguishedName) - log.Printf("[DEBUG] %s: Creation finished successfully", d.Id()) - - return resourceAciFEXProfileRead(ctx, d, m) -} - -func resourceAciFEXProfileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] FEXProfile: Beginning Update") - - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - name := d.Get("name").(string) - - infraFexPAttr := models.FEXProfileAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraFexPAttr.Annotation = Annotation.(string) - } else { - infraFexPAttr.Annotation = "{}" - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraFexPAttr.NameAlias = NameAlias.(string) - } - infraFexP := models.NewFEXProfile(fmt.Sprintf("infra/fexprof-%s", name), "uni", desc, infraFexPAttr) - - infraFexP.Status = "modified" - - err := aciClient.Save(infraFexP) - - if err != nil { - return diag.FromErr(err) - } - - d.SetId(infraFexP.DistinguishedName) - log.Printf("[DEBUG] %s: Update finished successfully", d.Id()) - - return resourceAciFEXProfileRead(ctx, d, m) - -} - -func resourceAciFEXProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Read", d.Id()) - - aciClient := m.(*client.Client) - - dn := d.Id() - infraFexP, err := getRemoteFEXProfile(aciClient, dn) - - if err != nil { - return errorForObjectNotFound(err, dn, d) - } - _, err = setFEXProfileAttributes(infraFexP, d) - if err != nil { - d.SetId("") - return nil - } - - log.Printf("[DEBUG] %s: Read finished successfully", d.Id()) - - return nil -} - -func resourceAciFEXProfileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Destroy", d.Id()) - - aciClient := m.(*client.Client) - dn := d.Id() - err := aciClient.DeleteByDn(dn, "infraFexP") - if err != nil { - return diag.FromErr(err) - } - - log.Printf("[DEBUG] %s: Destroy finished successfully", d.Id()) - - d.SetId("") - return diag.FromErr(err) -} diff --git a/aci/resource_aci_infrafexp_test.go b/aci/resource_aci_infrafexp_test.go deleted file mode 100644 index f096cc813..000000000 --- a/aci/resource_aci_infrafexp_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package aci - -import ( - "fmt" - "testing" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccAciFEXProfile_Basic(t *testing.T) { - var fex_profile models.FEXProfile - description := "fex_profile created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciFEXProfileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciFEXProfileConfig_basic(description), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciFEXProfileExists("aci_fex_profile.example", &fex_profile), - testAccCheckAciFEXProfileAttributes(description, &fex_profile), - ), - }, - }, - }) -} - -func TestAccAciFEXProfile_update(t *testing.T) { - var fex_profile models.FEXProfile - description := "fex_profile created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciFEXProfileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciFEXProfileConfig_basic(description), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciFEXProfileExists("aci_fex_profile.example", &fex_profile), - testAccCheckAciFEXProfileAttributes(description, &fex_profile), - ), - }, - { - Config: testAccCheckAciFEXProfileConfig_basic(description), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciFEXProfileExists("aci_fex_profile.example", &fex_profile), - testAccCheckAciFEXProfileAttributes(description, &fex_profile), - ), - }, - }, - }) -} - -func testAccCheckAciFEXProfileConfig_basic(description string) string { - return fmt.Sprintf(` - resource "aci_fex_profile" "example" { - description = "%s" - name = "check" - annotation = "check" - name_alias = "check" - } - `, description) -} - -func testAccCheckAciFEXProfileExists(name string, fex_profile *models.FEXProfile) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - - if !ok { - return fmt.Errorf("FEX Profile %s not found", name) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No FEX Profile dn was set") - } - - client := testAccProvider.Meta().(*client.Client) - - cont, err := client.Get(rs.Primary.ID) - if err != nil { - return err - } - - fex_profileFound := models.FEXProfileFromContainer(cont) - if fex_profileFound.DistinguishedName != rs.Primary.ID { - return fmt.Errorf("FEX Profile %s not found", rs.Primary.ID) - } - *fex_profile = *fex_profileFound - return nil - } -} - -func testAccCheckAciFEXProfileDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*client.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type == "aci_fex_profile" { - cont, err := client.Get(rs.Primary.ID) - fex_profile := models.FEXProfileFromContainer(cont) - if err == nil { - return fmt.Errorf("FEX Profile %s Still exists", fex_profile.DistinguishedName) - } - - } else { - continue - } - } - - return nil -} - -func testAccCheckAciFEXProfileAttributes(description string, fex_profile *models.FEXProfile) resource.TestCheckFunc { - return func(s *terraform.State) error { - - if description != fex_profile.Description { - return fmt.Errorf("Bad fex_profile Description %s", fex_profile.Description) - } - - if "check" != fex_profile.Name { - return fmt.Errorf("Bad fex_profile name %s", fex_profile.Name) - } - - if "check" != fex_profile.Annotation { - return fmt.Errorf("Bad fex_profile annotation %s", fex_profile.Annotation) - } - - if "check" != fex_profile.NameAlias { - return fmt.Errorf("Bad fex_profile name_alias %s", fex_profile.NameAlias) - } - - return nil - } -} diff --git a/aci/resource_aci_infrahports.go b/aci/resource_aci_infrahports.go deleted file mode 100644 index 29d6686c2..000000000 --- a/aci/resource_aci_infrahports.go +++ /dev/null @@ -1,319 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" -) - -func resourceAciAccessPortSelector() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceAciAccessPortSelectorCreate, - UpdateContext: resourceAciAccessPortSelectorUpdate, - ReadContext: resourceAciAccessPortSelectorRead, - DeleteContext: resourceAciAccessPortSelectorDelete, - - Importer: &schema.ResourceImporter{ - State: resourceAciAccessPortSelectorImport, - }, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - "leaf_interface_profile_dn": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "access_port_selector_type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - "ALL", - "range", - }, false), - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "relation_infra_rs_acc_base_grp": &schema.Schema{ - Type: schema.TypeString, - - Optional: true, - }, - }), - } -} - -func getRemoteAccessPortSelector(client *client.Client, dn string) (*models.AccessPortSelector, error) { - infraHPortSCont, err := client.Get(dn) - if err != nil { - return nil, err - } - - infraHPortS := models.AccessPortSelectorFromContainer(infraHPortSCont) - - if infraHPortS.DistinguishedName == "" { - return nil, fmt.Errorf("Access Port Selector %s not found", dn) - } - - return infraHPortS, nil -} - -func setAccessPortSelectorAttributes(infraHPortS *models.AccessPortSelector, d *schema.ResourceData) (*schema.ResourceData, error) { - dn := d.Id() - d.SetId(infraHPortS.DistinguishedName) - d.Set("description", infraHPortS.Description) - - if dn != infraHPortS.DistinguishedName { - d.Set("leaf_interface_profile_dn", "") - } - infraHPortSMap, err := infraHPortS.ToMap() - if err != nil { - return d, err - } - - d.Set("leaf_interface_profile_dn", GetParentDn(dn, fmt.Sprintf("/hports-%s-typ-%s", infraHPortSMap["name"], infraHPortSMap["type"]))) - d.Set("name", infraHPortSMap["name"]) - d.Set("name_alias", infraHPortSMap["nameAlias"]) - d.Set("annotation", infraHPortSMap["annotation"]) - d.Set("access_port_selector_type", infraHPortSMap["type"]) - - return d, nil -} - -func getAndSetReadRelationinfraRsAccBaseGrpFromAccessPortSelector(client *client.Client, dn string, d *schema.ResourceData) (*schema.ResourceData, error) { - infraRsAccBaseGrpData, err := client.ReadRelationinfraRsAccBaseGrpFromAccessPortSelector(dn) - if err != nil { - log.Printf("[DEBUG] Error while reading relation infraRsAccBaseGrp %v", err) - d.Set("relation_infra_rs_acc_base_grp", nil) - return d, err - } else { - d.Set("relation_infra_rs_acc_base_grp", infraRsAccBaseGrpData.(string)) - } - return d, nil -} - -func resourceAciAccessPortSelectorImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - log.Printf("[DEBUG] %s: Beginning Import", d.Id()) - aciClient := m.(*client.Client) - - dn := d.Id() - - infraHPortS, err := getRemoteAccessPortSelector(aciClient, dn) - if err != nil { - return nil, err - } - - infraHPortSMap, err := infraHPortS.ToMap() - if err != nil { - return nil, err - } - - name := infraHPortSMap["name"] - ptype := infraHPortSMap["type"] - pDN := GetParentDn(dn, fmt.Sprintf("/hports-%s-typ-%s", name, ptype)) - d.Set("leaf_interface_profile_dn", pDN) - schemaFilled, err := setAccessPortSelectorAttributes(infraHPortS, d) - if err != nil { - return nil, err - } - - // infraRsAccBaseGrp - Beginning Import - log.Printf("[DEBUG] %s: infraRsAccBaseGrp - Beginning Import with parent DN", dn) - _, err = getAndSetReadRelationinfraRsAccBaseGrpFromAccessPortSelector(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsAccBaseGrp - Import finished successfully", d.Get("relation_infra_rs_acc_base_grp")) - } - // infraRsAccBaseGrp - Import finished successfully - - log.Printf("[DEBUG] %s: Import finished successfully", d.Id()) - - return []*schema.ResourceData{schemaFilled}, nil -} - -func resourceAciAccessPortSelectorCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] AccessPortSelector: Beginning Creation") - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - name := d.Get("name").(string) - access_port_selector_type := d.Get("access_port_selector_type").(string) - LeafInterfaceProfileDn := d.Get("leaf_interface_profile_dn").(string) - - infraHPortSAttr := models.AccessPortSelectorAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraHPortSAttr.Annotation = Annotation.(string) - } else { - infraHPortSAttr.Annotation = "{}" - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraHPortSAttr.NameAlias = NameAlias.(string) - } - if AccessPortSelector_type, ok := d.GetOk("access_port_selector_type"); ok { - infraHPortSAttr.AccessPortSelector_type = AccessPortSelector_type.(string) - } - infraHPortS := models.NewAccessPortSelector(fmt.Sprintf("hports-%s-typ-%s", name, access_port_selector_type), LeafInterfaceProfileDn, desc, infraHPortSAttr) - - err := aciClient.Save(infraHPortS) - if err != nil { - return diag.FromErr(err) - } - - checkDns := make([]string, 0, 1) - - if relationToinfraRsAccBaseGrp, ok := d.GetOk("relation_infra_rs_acc_base_grp"); ok { - relationParam := relationToinfraRsAccBaseGrp.(string) - checkDns = append(checkDns, relationParam) - } - - d.Partial(true) - err = checkTDn(aciClient, checkDns) - if err != nil { - return diag.FromErr(err) - } - d.Partial(false) - - if relationToinfraRsAccBaseGrp, ok := d.GetOk("relation_infra_rs_acc_base_grp"); ok { - relationParam := relationToinfraRsAccBaseGrp.(string) - err = aciClient.CreateRelationinfraRsAccBaseGrpFromAccessPortSelector(infraHPortS.DistinguishedName, relationParam) - if err != nil { - return diag.FromErr(err) - } - } - - d.SetId(infraHPortS.DistinguishedName) - log.Printf("[DEBUG] %s: Creation finished successfully", d.Id()) - - return resourceAciAccessPortSelectorRead(ctx, d, m) -} - -func resourceAciAccessPortSelectorUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] AccessPortSelector: Beginning Update") - - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - name := d.Get("name").(string) - - access_port_selector_type := d.Get("access_port_selector_type").(string) - - LeafInterfaceProfileDn := d.Get("leaf_interface_profile_dn").(string) - - infraHPortSAttr := models.AccessPortSelectorAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraHPortSAttr.Annotation = Annotation.(string) - } else { - infraHPortSAttr.Annotation = "{}" - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraHPortSAttr.NameAlias = NameAlias.(string) - } - if AccessPortSelector_type, ok := d.GetOk("access_port_selector_type"); ok { - infraHPortSAttr.AccessPortSelector_type = AccessPortSelector_type.(string) - } - infraHPortS := models.NewAccessPortSelector(fmt.Sprintf("hports-%s-typ-%s", name, access_port_selector_type), LeafInterfaceProfileDn, desc, infraHPortSAttr) - - infraHPortS.Status = "modified" - - err := aciClient.Save(infraHPortS) - - if err != nil { - return diag.FromErr(err) - } - - checkDns := make([]string, 0, 1) - - if d.HasChange("relation_infra_rs_acc_base_grp") { - _, newRelParam := d.GetChange("relation_infra_rs_acc_base_grp") - checkDns = append(checkDns, newRelParam.(string)) - } - - d.Partial(true) - err = checkTDn(aciClient, checkDns) - if err != nil { - return diag.FromErr(err) - } - d.Partial(false) - - if d.HasChange("relation_infra_rs_acc_base_grp") { - _, newRelParam := d.GetChange("relation_infra_rs_acc_base_grp") - err = aciClient.DeleteRelationinfraRsAccBaseGrpFromAccessPortSelector(infraHPortS.DistinguishedName) - if err != nil { - return diag.FromErr(err) - } - err = aciClient.CreateRelationinfraRsAccBaseGrpFromAccessPortSelector(infraHPortS.DistinguishedName, newRelParam.(string)) - if err != nil { - return diag.FromErr(err) - } - } - - d.SetId(infraHPortS.DistinguishedName) - log.Printf("[DEBUG] %s: Update finished successfully", d.Id()) - - return resourceAciAccessPortSelectorRead(ctx, d, m) - -} - -func resourceAciAccessPortSelectorRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Read", d.Id()) - - aciClient := m.(*client.Client) - - dn := d.Id() - infraHPortS, err := getRemoteAccessPortSelector(aciClient, dn) - - if err != nil { - return errorForObjectNotFound(err, dn, d) - } - _, err = setAccessPortSelectorAttributes(infraHPortS, d) - if err != nil { - d.SetId("") - return nil - } - - // infraRsAccBaseGrp - Beginning Read - log.Printf("[DEBUG] %s: infraRsAccBaseGrp - Beginning Read with parent DN", dn) - _, err = getAndSetReadRelationinfraRsAccBaseGrpFromAccessPortSelector(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsAccBaseGrp - Read finished successfully", d.Get("relation_infra_rs_acc_base_grp")) - } - // infraRsAccBaseGrp - Read finished successfully - - log.Printf("[DEBUG] %s: Read finished successfully", d.Id()) - - return nil -} - -func resourceAciAccessPortSelectorDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Destroy", d.Id()) - - aciClient := m.(*client.Client) - dn := d.Id() - err := aciClient.DeleteByDn(dn, "infraHPortS") - if err != nil { - return diag.FromErr(err) - } - - log.Printf("[DEBUG] %s: Destroy finished successfully", d.Id()) - d.SetId("") - - return diag.FromErr(err) -} diff --git a/aci/resource_aci_infrahports_test.go b/aci/resource_aci_infrahports_test.go deleted file mode 100644 index 04f5c710e..000000000 --- a/aci/resource_aci_infrahports_test.go +++ /dev/null @@ -1,155 +0,0 @@ -package aci - -import ( - "fmt" - "testing" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccAciAccessPortSelector_Basic(t *testing.T) { - var access_port_selector models.AccessPortSelector - description := "access_port_selector created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciAccessPortSelectorDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciAccessPortSelectorConfig_basic(description, "ALL"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciAccessPortSelectorExists("aci_access_port_selector.fooaccess_port_selector", &access_port_selector), - testAccCheckAciAccessPortSelectorAttributes(description, "ALL", &access_port_selector), - ), - }, - { - ResourceName: "aci_access_port_selector", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccAciAccessPortSelector_update(t *testing.T) { - var access_port_selector models.AccessPortSelector - description := "access_port_selector created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciAccessPortSelectorDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciAccessPortSelectorConfig_basic(description, "ALL"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciAccessPortSelectorExists("aci_access_port_selector.fooaccess_port_selector", &access_port_selector), - testAccCheckAciAccessPortSelectorAttributes(description, "ALL", &access_port_selector), - ), - }, - { - Config: testAccCheckAciAccessPortSelectorConfig_basic(description, "range"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciAccessPortSelectorExists("aci_access_port_selector.fooaccess_port_selector", &access_port_selector), - testAccCheckAciAccessPortSelectorAttributes(description, "range", &access_port_selector), - ), - }, - }, - }) -} - -func testAccCheckAciAccessPortSelectorConfig_basic(description, access_port_selector_type string) string { - return fmt.Sprintf(` - - resource "aci_leaf_interface_profile" "example" { - name = "demo_leaf_profile" - } - resource "aci_access_port_selector" "fooaccess_port_selector" { - leaf_interface_profile_dn = aci_leaf_interface_profile.example.id - description = "%s" - name = "demo_port_selector" - access_port_selector_type = "%s" - annotation = "tag_port_selector" - name_alias = "alias_port_selector" - } - `, description, access_port_selector_type) -} - -func testAccCheckAciAccessPortSelectorExists(name string, access_port_selector *models.AccessPortSelector) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - - if !ok { - return fmt.Errorf("Access Port Selector %s not found", name) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No Access Port Selector dn was set") - } - - client := testAccProvider.Meta().(*client.Client) - - cont, err := client.Get(rs.Primary.ID) - if err != nil { - return err - } - - access_port_selectorFound := models.AccessPortSelectorFromContainer(cont) - if access_port_selectorFound.DistinguishedName != rs.Primary.ID { - return fmt.Errorf("Access Port Selector %s not found", rs.Primary.ID) - } - *access_port_selector = *access_port_selectorFound - return nil - } -} - -func testAccCheckAciAccessPortSelectorDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*client.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type == "aci_access_port_selector" { - cont, err := client.Get(rs.Primary.ID) - access_port_selector := models.AccessPortSelectorFromContainer(cont) - if err == nil { - return fmt.Errorf("Access Port Selector %s Still exists", access_port_selector.DistinguishedName) - } - - } else { - continue - } - } - - return nil -} - -func testAccCheckAciAccessPortSelectorAttributes(description, access_port_selector_type string, access_port_selector *models.AccessPortSelector) resource.TestCheckFunc { - return func(s *terraform.State) error { - - if description != access_port_selector.Description { - return fmt.Errorf("Bad access_port_selector Description %s", access_port_selector.Description) - } - - if "demo_port_selector" != access_port_selector.Name { - return fmt.Errorf("Bad access_port_selector name %s", access_port_selector.Name) - } - - if access_port_selector_type != access_port_selector.AccessPortSelector_type { - return fmt.Errorf("Bad access_port_selector access_port_selector_type %s", access_port_selector.AccessPortSelector_type) - } - - if "tag_port_selector" != access_port_selector.Annotation { - return fmt.Errorf("Bad access_port_selector annotation %s", access_port_selector.Annotation) - } - - if "alias_port_selector" != access_port_selector.NameAlias { - return fmt.Errorf("Bad access_port_selector name_alias %s", access_port_selector.NameAlias) - } - - return nil - } -} diff --git a/aci/resource_aci_infraportblk.go b/aci/resource_aci_infraportblk.go deleted file mode 100644 index 0b845c0af..000000000 --- a/aci/resource_aci_infraportblk.go +++ /dev/null @@ -1,380 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - "strconv" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceAciAccessPortBlock() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceAciAccessPortBlockCreate, - UpdateContext: resourceAciAccessPortBlockUpdate, - ReadContext: resourceAciAccessPortBlockRead, - DeleteContext: resourceAciAccessPortBlockDelete, - - Importer: &schema.ResourceImporter{ - State: resourceAciAccessPortBlockImport, - }, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - "access_port_selector_dn": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "from_card": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "from_port": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "to_card": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "to_port": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "relation_infra_rs_acc_bndl_subgrp": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, - }), - } -} -func getRemoteAccessPortBlock(client *client.Client, dn string) (*models.AccessPortBlock, error) { - infraPortBlkCont, err := client.Get(dn) - if err != nil { - return nil, err - } - - infraPortBlk := models.AccessPortBlockFromContainer(infraPortBlkCont) - - if infraPortBlk.DistinguishedName == "" { - return nil, fmt.Errorf("Access Port Block %s not found", dn) - } - - return infraPortBlk, nil -} - -func setAccessPortBlockAttributes(infraPortBlk *models.AccessPortBlock, d *schema.ResourceData) (*schema.ResourceData, error) { - dn := d.Id() - d.SetId(infraPortBlk.DistinguishedName) - d.Set("description", infraPortBlk.Description) - - if dn != infraPortBlk.DistinguishedName { - d.Set("access_port_selector_dn", "") - } - infraPortBlkMap, err := infraPortBlk.ToMap() - if err != nil { - return d, err - } - - d.Set("access_port_selector_dn", GetParentDn(dn, fmt.Sprintf("/portblk-%s", infraPortBlkMap["name"]))) - d.Set("name", infraPortBlkMap["name"]) - - d.Set("annotation", infraPortBlkMap["annotation"]) - d.Set("from_card", infraPortBlkMap["fromCard"]) - d.Set("from_port", infraPortBlkMap["fromPort"]) - d.Set("name_alias", infraPortBlkMap["nameAlias"]) - d.Set("to_card", infraPortBlkMap["toCard"]) - d.Set("to_port", infraPortBlkMap["toPort"]) - return d, nil -} - -func getAndSetReadRelationinfraRsAccBndlSubgrp(client *client.Client, dn string, d *schema.ResourceData) (*schema.ResourceData, error) { - infraRsAccBndlSubgrp, err := client.ReadRelationinfraRsAccBndlSubgrpFromAccessPortBlock(dn) - if err != nil { - log.Printf("[DEBUG] Error while reading relation infraRsAccBndlSubgrp %v", err) - d.Set("relation_infra_rs_acc_bndl_subgrp", nil) - return d, err - } else { - d.Set("relation_infra_rs_acc_bndl_subgrp", infraRsAccBndlSubgrp.(string)) - } - return d, nil -} - -func resourceAciAccessPortBlockImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - log.Printf("[DEBUG] %s: Beginning Import", d.Id()) - aciClient := m.(*client.Client) - - dn := d.Id() - - infraPortBlk, err := getRemoteAccessPortBlock(aciClient, dn) - if err != nil { - return nil, err - } - - schemaFilled, err := setAccessPortBlockAttributes(infraPortBlk, d) - if err != nil { - return nil, err - } - - log.Printf("[DEBUG] %s: infraRsAccBndlSubgrp - Beginning Import with parent DN", dn) - _, err = getAndSetReadRelationinfraRsAccBndlSubgrp(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsAccBndlSubgrp - Import finished successfully", d.Get("relation_infra_rs_acc_bndl_subgrp")) - } - - log.Printf("[DEBUG] %s: Import finished successfully", d.Id()) - - return []*schema.ResourceData{schemaFilled}, nil -} - -func resourceAciAccessPortBlockCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] AccessPortBlock: Beginning Creation") - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - AccessPortSelectorDn := d.Get("access_port_selector_dn").(string) - - var name string - if _, ok := d.GetOk("name"); !ok { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, AccessPortSelectorDn, "infraPortBlk") - - cont, err := aciClient.GetViaURL(dnUrl) - if err != nil { - if models.G(cont, "totalCount") != "0" { - return diag.FromErr(err) - } - } - contList := models.ListFromContainer(cont, "infraPortBlk") - contListLen := len(contList) - - blkNames := make([]string, 0, 1) - for i := 0; i < contListLen; i++ { - tp := models.G(contList[i], "name") - blkNames = append(blkNames, tp) - } - - cnt := contListLen + 1 - for true { - flag := false - tpName := fmt.Sprintf("Block%s", strconv.Itoa(cnt)) - for _, val := range blkNames { - if val == tpName { - flag = true - cnt = cnt + 1 - break - } - } - if !flag { - name = tpName - break - } - } - } else { - name = d.Get("name").(string) - } - - infraPortBlkAttr := models.AccessPortBlockAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraPortBlkAttr.Annotation = Annotation.(string) - } else { - infraPortBlkAttr.Annotation = "{}" - } - if FromCard, ok := d.GetOk("from_card"); ok { - infraPortBlkAttr.FromCard = FromCard.(string) - } - if FromPort, ok := d.GetOk("from_port"); ok { - infraPortBlkAttr.FromPort = FromPort.(string) - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraPortBlkAttr.NameAlias = NameAlias.(string) - } - if ToCard, ok := d.GetOk("to_card"); ok { - infraPortBlkAttr.ToCard = ToCard.(string) - } - if ToPort, ok := d.GetOk("to_port"); ok { - infraPortBlkAttr.ToPort = ToPort.(string) - } - infraPortBlk := models.NewAccessPortBlock(fmt.Sprintf("portblk-%s", name), AccessPortSelectorDn, desc, infraPortBlkAttr) - - err := aciClient.Save(infraPortBlk) - if err != nil { - return diag.FromErr(err) - } - - checkDns := make([]string, 0, 1) - - if relationToinfraRsAccBndlSubgrp, ok := d.GetOk("relation_infra_rs_acc_bndl_subgrp"); ok { - relationParam := relationToinfraRsAccBndlSubgrp.(string) - checkDns = append(checkDns, relationParam) - } - - d.Partial(true) - err = checkTDn(aciClient, checkDns) - if err != nil { - return diag.FromErr(err) - } - d.Partial(false) - - if relationToinfraRsAccBndlSubgrp, ok := d.GetOk("relation_infra_rs_acc_bndl_subgrp"); ok { - relationParam := relationToinfraRsAccBndlSubgrp.(string) - err = aciClient.CreateRelationinfraRsAccBndlSubgrpFromAccessPortBlock(infraPortBlk.DistinguishedName, relationParam) - if err != nil { - return diag.FromErr(err) - } - - } - - d.SetId(infraPortBlk.DistinguishedName) - log.Printf("[DEBUG] %s: Creation finished successfully", d.Id()) - - return resourceAciAccessPortBlockRead(ctx, d, m) -} - -func resourceAciAccessPortBlockUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] AccessPortBlock: Beginning Update") - - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - name := d.Get("name").(string) - - AccessPortSelectorDn := d.Get("access_port_selector_dn").(string) - - infraPortBlkAttr := models.AccessPortBlockAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraPortBlkAttr.Annotation = Annotation.(string) - } else { - infraPortBlkAttr.Annotation = "{}" - } - if FromCard, ok := d.GetOk("from_card"); ok { - infraPortBlkAttr.FromCard = FromCard.(string) - } - if FromPort, ok := d.GetOk("from_port"); ok { - infraPortBlkAttr.FromPort = FromPort.(string) - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraPortBlkAttr.NameAlias = NameAlias.(string) - } - if ToCard, ok := d.GetOk("to_card"); ok { - infraPortBlkAttr.ToCard = ToCard.(string) - } - if ToPort, ok := d.GetOk("to_port"); ok { - infraPortBlkAttr.ToPort = ToPort.(string) - } - infraPortBlk := models.NewAccessPortBlock(fmt.Sprintf("portblk-%s", name), AccessPortSelectorDn, desc, infraPortBlkAttr) - - infraPortBlk.Status = "modified" - - err := aciClient.Save(infraPortBlk) - - if err != nil { - return diag.FromErr(err) - } - - checkDns := make([]string, 0, 1) - - if d.HasChange("relation_infra_rs_acc_bndl_subgrp") { - _, newRelParam := d.GetChange("relation_infra_rs_acc_bndl_subgrp") - checkDns = append(checkDns, newRelParam.(string)) - } - - d.Partial(true) - err = checkTDn(aciClient, checkDns) - if err != nil { - return diag.FromErr(err) - } - d.Partial(false) - - if d.HasChange("relation_infra_rs_acc_bndl_subgrp") { - _, newRelParam := d.GetChange("relation_infra_rs_acc_bndl_subgrp") - err = aciClient.DeleteRelationinfraRsAccBndlSubgrpFromAccessPortBlock(infraPortBlk.DistinguishedName) - if err != nil { - return diag.FromErr(err) - } - err = aciClient.CreateRelationinfraRsAccBndlSubgrpFromAccessPortBlock(infraPortBlk.DistinguishedName, newRelParam.(string)) - if err != nil { - return diag.FromErr(err) - } - - } - - d.SetId(infraPortBlk.DistinguishedName) - log.Printf("[DEBUG] %s: Update finished successfully", d.Id()) - - return resourceAciAccessPortBlockRead(ctx, d, m) - -} - -func resourceAciAccessPortBlockRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Read", d.Id()) - - aciClient := m.(*client.Client) - - dn := d.Id() - infraPortBlk, err := getRemoteAccessPortBlock(aciClient, dn) - - if err != nil { - return errorForObjectNotFound(err, dn, d) - } - _, err = setAccessPortBlockAttributes(infraPortBlk, d) - - if err != nil { - d.SetId("") - return nil - } - - log.Printf("[DEBUG] %s: infraRsAccBndlSubgrp - Beginning Read with parent DN", dn) - _, err = getAndSetReadRelationinfraRsAccBndlSubgrp(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsAccBndlSubgrp - Read finished successfully", d.Get("relation_infra_rs_acc_bndl_subgrp")) - } - - log.Printf("[DEBUG] %s: Read finished successfully", d.Id()) - - return nil -} - -func resourceAciAccessPortBlockDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Destroy", d.Id()) - - aciClient := m.(*client.Client) - dn := d.Id() - err := aciClient.DeleteByDn(dn, "infraPortBlk") - if err != nil { - return diag.FromErr(err) - } - - log.Printf("[DEBUG] %s: Destroy finished successfully", d.Id()) - - d.SetId("") - return diag.FromErr(err) -} diff --git a/aci/resource_aci_infraportblk_test.go b/aci/resource_aci_infraportblk_test.go deleted file mode 100644 index c05db8f1e..000000000 --- a/aci/resource_aci_infraportblk_test.go +++ /dev/null @@ -1,163 +0,0 @@ -package aci - -import ( - "fmt" - "testing" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccAciAccessPortBlock_Basic(t *testing.T) { - var access_port_block models.AccessPortBlock - description := "access_port_block created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciAccessPortBlockDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciAccessPortBlockConfig_basic(description, "1"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciAccessPortBlockExists("aci_access_port_block.fooaccess_port_block", &access_port_block), - testAccCheckAciAccessPortBlockAttributes(description, "1", &access_port_block), - ), - }, - }, - }) -} - -func TestAccAciAccessPortBlock_update(t *testing.T) { - var access_port_block models.AccessPortBlock - description := "access_port_block created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciAccessPortBlockDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciAccessPortBlockConfig_basic(description, "1"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciAccessPortBlockExists("aci_access_port_block.fooaccess_port_block", &access_port_block), - testAccCheckAciAccessPortBlockAttributes(description, "1", &access_port_block), - ), - }, - { - Config: testAccCheckAciAccessPortBlockConfig_basic(description, "2"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciAccessPortBlockExists("aci_access_port_block.fooaccess_port_block", &access_port_block), - testAccCheckAciAccessPortBlockAttributes(description, "2", &access_port_block), - ), - }, - }, - }) -} - -func testAccCheckAciAccessPortBlockConfig_basic(description, from_port string) string { - return fmt.Sprintf(` - - resource "aci_access_port_block" "fooaccess_port_block" { - //access_port_selector_dn = aci_access_port_selector.example.id - access_port_selector_dn = "uni/infra/accportprof-demo_leaf_profile/hports-demo_port_selector-typ-range" - description = "%s" - name = "demo_port_block" - annotation = "tag_port_block" - from_card = "1" - from_port = "%s" - name_alias = "alias_port_block" - to_card = "3" - to_port = "3" - } - `, description, from_port) -} - -func testAccCheckAciAccessPortBlockExists(name string, access_port_block *models.AccessPortBlock) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - - if !ok { - return fmt.Errorf("Access Port Block %s not found", name) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No Access Port Block dn was set") - } - - client := testAccProvider.Meta().(*client.Client) - - cont, err := client.Get(rs.Primary.ID) - if err != nil { - return err - } - - access_port_blockFound := models.AccessPortBlockFromContainer(cont) - if access_port_blockFound.DistinguishedName != rs.Primary.ID { - return fmt.Errorf("Access Port Block %s not found", rs.Primary.ID) - } - *access_port_block = *access_port_blockFound - return nil - } -} - -func testAccCheckAciAccessPortBlockDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*client.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type == "aci_access_port_block" { - cont, err := client.Get(rs.Primary.ID) - access_port_block := models.AccessPortBlockFromContainer(cont) - if err == nil { - return fmt.Errorf("Access Port Block %s Still exists", access_port_block.DistinguishedName) - } - - } else { - continue - } - } - - return nil -} - -func testAccCheckAciAccessPortBlockAttributes(description, from_port string, access_port_block *models.AccessPortBlock) resource.TestCheckFunc { - return func(s *terraform.State) error { - - if description != access_port_block.Description { - return fmt.Errorf("Bad access_port_block Description %s", access_port_block.Description) - } - - if "demo_port_block" != access_port_block.Name { - return fmt.Errorf("Bad access_port_block name %s", access_port_block.Name) - } - - if "tag_port_block" != access_port_block.Annotation { - return fmt.Errorf("Bad access_port_block annotation %s", access_port_block.Annotation) - } - - if "1" != access_port_block.FromCard { - return fmt.Errorf("Bad access_port_block from_card %s", access_port_block.FromCard) - } - - if from_port != access_port_block.FromPort { - return fmt.Errorf("Bad access_port_block from_port %s", access_port_block.FromPort) - } - - if "alias_port_block" != access_port_block.NameAlias { - return fmt.Errorf("Bad access_port_block name_alias %s", access_port_block.NameAlias) - } - - if "3" != access_port_block.ToCard { - return fmt.Errorf("Bad access_port_block to_card %s", access_port_block.ToCard) - } - - if "3" != access_port_block.ToPort { - return fmt.Errorf("Bad access_port_block to_port %s", access_port_block.ToPort) - } - - return nil - } -} diff --git a/aci/resource_aci_infrashports.go b/aci/resource_aci_infrashports.go deleted file mode 100644 index 629ffa0dd..000000000 --- a/aci/resource_aci_infrashports.go +++ /dev/null @@ -1,305 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" -) - -func resourceAciSpineAccessPortSelector() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceAciSpineAccessPortSelectorCreate, - UpdateContext: resourceAciSpineAccessPortSelectorUpdate, - ReadContext: resourceAciSpineAccessPortSelectorRead, - DeleteContext: resourceAciSpineAccessPortSelectorDelete, - - Importer: &schema.ResourceImporter{ - State: resourceAciSpineAccessPortSelectorImport, - }, - - SchemaVersion: 1, - Schema: AppendBaseAttrSchema(AppendNameAliasAttrSchema(map[string]*schema.Schema{ - "spine_interface_profile_dn": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "spine_access_port_selector_type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - "ALL", - "range", - }, false), - }, - - "relation_infra_rs_sp_acc_grp": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Create relation to infra:SpAccGrp", - }, - })), - } -} - -func getRemoteSpineAccessPortSelector(client *client.Client, dn string) (*models.SpineAccessPortSelector, error) { - infraSHPortSCont, err := client.Get(dn) - if err != nil { - return nil, err - } - - infraSHPortS := models.SpineAccessPortSelectorFromContainer(infraSHPortSCont) - - if infraSHPortS.DistinguishedName == "" { - return nil, fmt.Errorf("Spine Access Port Selector %s not found", dn) - } - - return infraSHPortS, nil -} - -func setSpineAccessPortSelectorAttributes(infraSHPortS *models.SpineAccessPortSelector, d *schema.ResourceData) (*schema.ResourceData, error) { - dn := d.Id() - d.SetId(infraSHPortS.DistinguishedName) - d.Set("description", infraSHPortS.Description) - - if dn != infraSHPortS.DistinguishedName { - d.Set("spine_interface_profile_dn", "") - } - infraSHPortSMap, err := infraSHPortS.ToMap() - if err != nil { - return d, err - } - - d.Set("spine_interface_profile_dn", GetParentDn(dn, fmt.Sprintf("/shports-%s-typ-%s", infraSHPortSMap["name"], infraSHPortSMap["type"]))) - d.Set("name", infraSHPortSMap["name"]) - d.Set("name_alias", infraSHPortSMap["nameAlias"]) - d.Set("annotation", infraSHPortSMap["annotation"]) - d.Set("spine_access_port_selector_type", infraSHPortSMap["type"]) - - return d, nil -} - -func getAndSetReadRelationinfraRsSpAccGrp(client *client.Client, dn string, d *schema.ResourceData) (*schema.ResourceData, error) { - infraRsSpAccGrpData, err := client.ReadRelationinfraRsSpAccGrp(dn) - if err != nil { - log.Printf("[DEBUG] Error while reading relation infraRsSpAccGrp %v", err) - d.Set("relation_infra_rs_sp_acc_grp", nil) - return d, err - } else { - d.Set("relation_infra_rs_sp_acc_grp", infraRsSpAccGrpData.(string)) - } - return d, nil -} - -func resourceAciSpineAccessPortSelectorImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - log.Printf("[DEBUG] %s: Beginning Import", d.Id()) - aciClient := m.(*client.Client) - - dn := d.Id() - - infraSHPortS, err := getRemoteSpineAccessPortSelector(aciClient, dn) - if err != nil { - return nil, err - } - - schemaFilled, err := setSpineAccessPortSelectorAttributes(infraSHPortS, d) - if err != nil { - return nil, err - } - - // infraRsSpAccGrp - Beginning Import - log.Printf("[DEBUG] %s: infraRsSpAccGrp - Beginning Import with parent DN", dn) - _, err = getAndSetReadRelationinfraRsSpAccGrp(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsSpAccGrp - Import finished successfully", d.Get("relation_infra_rs_sp_acc_grp")) - } - // infraRsSpAccGrp - Import finished successfully - - log.Printf("[DEBUG] %s: Import finished successfully", d.Id()) - - return []*schema.ResourceData{schemaFilled}, nil -} - -func resourceAciSpineAccessPortSelectorCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] SpineAccessPortSelector: Beginning Creation") - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - name := d.Get("name").(string) - spine_access_port_selector_type := d.Get("spine_access_port_selector_type").(string) - SpineInterfaceProfileDn := d.Get("spine_interface_profile_dn").(string) - - infraSHPortSAttr := models.SpineAccessPortSelectorAttributes{} - nameAlias := "" - if NameAlias, ok := d.GetOk("name_alias"); ok { - nameAlias = NameAlias.(string) - } - if Annotation, ok := d.GetOk("annotation"); ok { - infraSHPortSAttr.Annotation = Annotation.(string) - } else { - infraSHPortSAttr.Annotation = "{}" - } - - if Name, ok := d.GetOk("name"); ok { - infraSHPortSAttr.Name = Name.(string) - } - - if SpineAccessPortSelector_type, ok := d.GetOk("spine_access_port_selector_type"); ok { - infraSHPortSAttr.SpineAccessPortSelector_type = SpineAccessPortSelector_type.(string) - } - infraSHPortS := models.NewSpineAccessPortSelector(fmt.Sprintf(models.RninfraSHPortS, name, spine_access_port_selector_type), SpineInterfaceProfileDn, desc, nameAlias, infraSHPortSAttr) - - err := aciClient.Save(infraSHPortS) - if err != nil { - return diag.FromErr(err) - } - - checkDns := make([]string, 0, 1) - - if relationToinfraRsSpAccGrp, ok := d.GetOk("relation_infra_rs_sp_acc_grp"); ok { - relationParam := relationToinfraRsSpAccGrp.(string) - checkDns = append(checkDns, relationParam) - } - - d.Partial(true) - err = checkTDn(aciClient, checkDns) - if err != nil { - return diag.FromErr(err) - } - d.Partial(false) - - if relationToinfraRsSpAccGrp, ok := d.GetOk("relation_infra_rs_sp_acc_grp"); ok { - relationParam := relationToinfraRsSpAccGrp.(string) - err = aciClient.CreateRelationinfraRsSpAccGrp(infraSHPortS.DistinguishedName, infraSHPortSAttr.Annotation, relationParam) - if err != nil { - return diag.FromErr(err) - } - } - - d.SetId(infraSHPortS.DistinguishedName) - log.Printf("[DEBUG] %s: Creation finished successfully", d.Id()) - - return resourceAciSpineAccessPortSelectorRead(ctx, d, m) -} - -func resourceAciSpineAccessPortSelectorUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] SpineAccessPortSelector: Beginning Update") - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - name := d.Get("name").(string) - spine_access_port_selector_type := d.Get("spine_access_port_selector_type").(string) - SpineInterfaceProfileDn := d.Get("spine_interface_profile_dn").(string) - infraSHPortSAttr := models.SpineAccessPortSelectorAttributes{} - nameAlias := "" - if NameAlias, ok := d.GetOk("name_alias"); ok { - nameAlias = NameAlias.(string) - } - - if Annotation, ok := d.GetOk("annotation"); ok { - infraSHPortSAttr.Annotation = Annotation.(string) - } else { - infraSHPortSAttr.Annotation = "{}" - } - - if Name, ok := d.GetOk("name"); ok { - infraSHPortSAttr.Name = Name.(string) - } - - if SpineAccessPortSelector_type, ok := d.GetOk("spine_access_port_selector_type"); ok { - infraSHPortSAttr.SpineAccessPortSelector_type = SpineAccessPortSelector_type.(string) - } - infraSHPortS := models.NewSpineAccessPortSelector(fmt.Sprintf(models.RninfraSHPortS, name, spine_access_port_selector_type), SpineInterfaceProfileDn, desc, nameAlias, infraSHPortSAttr) - - infraSHPortS.Status = "modified" - err := aciClient.Save(infraSHPortS) - if err != nil { - return diag.FromErr(err) - } - - checkDns := make([]string, 0, 1) - - if d.HasChange("relation_infra_rs_sp_acc_grp") || d.HasChange("annotation") { - _, newRelParam := d.GetChange("relation_infra_rs_sp_acc_grp") - checkDns = append(checkDns, newRelParam.(string)) - } - - d.Partial(true) - err = checkTDn(aciClient, checkDns) - if err != nil { - return diag.FromErr(err) - } - d.Partial(false) - - if d.HasChange("relation_infra_rs_sp_acc_grp") || d.HasChange("annotation") { - _, newRelParam := d.GetChange("relation_infra_rs_sp_acc_grp") - err = aciClient.DeleteRelationinfraRsSpAccGrp(infraSHPortS.DistinguishedName) - if err != nil { - return diag.FromErr(err) - } - err = aciClient.CreateRelationinfraRsSpAccGrp(infraSHPortS.DistinguishedName, infraSHPortSAttr.Annotation, newRelParam.(string)) - if err != nil { - return diag.FromErr(err) - } - } - - d.SetId(infraSHPortS.DistinguishedName) - log.Printf("[DEBUG] %s: Update finished successfully", d.Id()) - - return resourceAciSpineAccessPortSelectorRead(ctx, d, m) -} - -func resourceAciSpineAccessPortSelectorRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Read", d.Id()) - aciClient := m.(*client.Client) - dn := d.Id() - infraSHPortS, err := getRemoteSpineAccessPortSelector(aciClient, dn) - if err != nil { - return errorForObjectNotFound(err, dn, d) - } - - _, err = setSpineAccessPortSelectorAttributes(infraSHPortS, d) - if err != nil { - d.SetId("") - return nil - } - - // infraRsSpAccGrp - Beginning Read - log.Printf("[DEBUG] %s: infraRsSpAccGrp - Beginning Read with parent DN", dn) - _, err = getAndSetReadRelationinfraRsSpAccGrp(aciClient, dn, d) - if err == nil { - log.Printf("[DEBUG] %s: infraRsSpAccGrp - Read finished successfully", d.Get("relation_infra_rs_sp_acc_grp")) - } - // infraRsSpAccGrp - Read finished successfully - - log.Printf("[DEBUG] %s: Read finished successfully", d.Id()) - return nil -} - -func resourceAciSpineAccessPortSelectorDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Destroy", d.Id()) - - aciClient := m.(*client.Client) - dn := d.Id() - err := aciClient.DeleteByDn(dn, "infraSHPortS") - if err != nil { - return diag.FromErr(err) - } - - log.Printf("[DEBUG] %s: Destroy finished successfully", d.Id()) - d.SetId("") - - return diag.FromErr(err) -} diff --git a/aci/resource_aci_infrashports_test.go b/aci/resource_aci_infrashports_test.go deleted file mode 100644 index 6ba64b8d4..000000000 --- a/aci/resource_aci_infrashports_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package aci - -import ( - "fmt" - "testing" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccAciSpineAccessPortSelector_Basic(t *testing.T) { - var spine_access_port_selector models.SpineAccessPortSelector - infra_sp_acc_port_p_name := acctest.RandString(5) - infra_sh_port_s_name := acctest.RandString(5) - description := "spine_access_port_selector created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciSpineAccessPortSelectorDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciSpineAccessPortSelectorConfig_basic(infra_sp_acc_port_p_name, infra_sh_port_s_name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciSpineAccessPortSelectorExists("aci_spine_access_port_selector.foospine_access_port_selector", &spine_access_port_selector), - testAccCheckAciSpineAccessPortSelectorAttributes(infra_sp_acc_port_p_name, infra_sh_port_s_name, description, &spine_access_port_selector), - ), - }, - }, - }) -} - -func TestAccAciSpineAccessPortSelector_Update(t *testing.T) { - var spine_access_port_selector models.SpineAccessPortSelector - infra_sp_acc_port_p_name := acctest.RandString(5) - infra_sh_port_s_name := acctest.RandString(5) - description := "spine_access_port_selector created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciSpineAccessPortSelectorDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciSpineAccessPortSelectorConfig_basic(infra_sp_acc_port_p_name, infra_sh_port_s_name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciSpineAccessPortSelectorExists("aci_spine_access_port_selector.foospine_access_port_selector", &spine_access_port_selector), - testAccCheckAciSpineAccessPortSelectorAttributes(infra_sp_acc_port_p_name, infra_sh_port_s_name, description, &spine_access_port_selector), - ), - }, - { - Config: testAccCheckAciSpineAccessPortSelectorConfig_basic(infra_sp_acc_port_p_name, infra_sh_port_s_name), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciSpineAccessPortSelectorExists("aci_spine_access_port_selector.foospine_access_port_selector", &spine_access_port_selector), - testAccCheckAciSpineAccessPortSelectorAttributes(infra_sp_acc_port_p_name, infra_sh_port_s_name, description, &spine_access_port_selector), - ), - }, - }, - }) -} - -func testAccCheckAciSpineAccessPortSelectorConfig_basic(infra_sp_acc_port_p_name, infra_sh_port_s_name string) string { - return fmt.Sprintf(` - - resource "aci_spine_interface_profile" "foospine_interface_profile" { - name = "%s" - description = "spine_interface_profile created while acceptance testing" - - } - - resource "aci_spine_access_port_selector" "foospine_access_port_selector" { - name = "%s" - description = "spine_access_port_selector created while acceptance testing" - spine_interface_profile_dn = aci_spine_interface_profile.foospine_interface_profile.id - } - - `, infra_sp_acc_port_p_name, infra_sh_port_s_name) -} - -func testAccCheckAciSpineAccessPortSelectorExists(name string, spine_access_port_selector *models.SpineAccessPortSelector) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - - if !ok { - return fmt.Errorf("Spine Access Port Selector %s not found", name) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No Spine Access Port Selector dn was set") - } - - client := testAccProvider.Meta().(*client.Client) - - cont, err := client.Get(rs.Primary.ID) - if err != nil { - return err - } - - spine_access_port_selectorFound := models.SpineAccessPortSelectorFromContainer(cont) - if spine_access_port_selectorFound.DistinguishedName != rs.Primary.ID { - return fmt.Errorf("Spine Access Port Selector %s not found", rs.Primary.ID) - } - *spine_access_port_selector = *spine_access_port_selectorFound - return nil - } -} - -func testAccCheckAciSpineAccessPortSelectorDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*client.Client) - for _, rs := range s.RootModule().Resources { - if rs.Type == "aci_spine_access_port_selector" { - cont, err := client.Get(rs.Primary.ID) - spine_access_port_selector := models.SpineAccessPortSelectorFromContainer(cont) - if err == nil { - return fmt.Errorf("Spine Access Port Selector %s Still exists", spine_access_port_selector.DistinguishedName) - } - } else { - continue - } - } - return nil -} - -func testAccCheckAciSpineAccessPortSelectorAttributes(infra_sp_acc_port_p_name, infra_sh_port_s_name, description string, spine_access_port_selector *models.SpineAccessPortSelector) resource.TestCheckFunc { - return func(s *terraform.State) error { - if infra_sh_port_s_name != GetMOName(spine_access_port_selector.DistinguishedName) { - return fmt.Errorf("Bad infrash_port_s %s", GetMOName(spine_access_port_selector.DistinguishedName)) - } - - if infra_sp_acc_port_p_name != GetMOName(GetParentDn(spine_access_port_selector.DistinguishedName)) { - return fmt.Errorf(" Bad infra_sp_acc_port_p %s", GetMOName(GetParentDn(spine_access_port_selector.DistinguishedName))) - } - if description != spine_access_port_selector.Description { - return fmt.Errorf("Bad spine_access_port_selector Description %s", spine_access_port_selector.Description) - } - return nil - } -} diff --git a/aci/resource_aci_infraspaccportp.go b/aci/resource_aci_infraspaccportp.go deleted file mode 100644 index 33cc21427..000000000 --- a/aci/resource_aci_infraspaccportp.go +++ /dev/null @@ -1,193 +0,0 @@ -package aci - -import ( - "context" - "fmt" - "log" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceAciSpineInterfaceProfile() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceAciSpineInterfaceProfileCreate, - UpdateContext: resourceAciSpineInterfaceProfileUpdate, - ReadContext: resourceAciSpineInterfaceProfileRead, - DeleteContext: resourceAciSpineInterfaceProfileDelete, - - Importer: &schema.ResourceImporter{ - State: resourceAciSpineInterfaceProfileImport, - }, - - SchemaVersion: 1, - - Schema: AppendBaseAttrSchema(map[string]*schema.Schema{ - - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - }), - } -} -func getRemoteSpineInterfaceProfile(client *client.Client, dn string) (*models.SpineInterfaceProfile, error) { - infraSpAccPortPCont, err := client.Get(dn) - if err != nil { - return nil, err - } - - infraSpAccPortP := models.SpineInterfaceProfileFromContainer(infraSpAccPortPCont) - - if infraSpAccPortP.DistinguishedName == "" { - return nil, fmt.Errorf("Spine Interface Profile %s not found", dn) - } - - return infraSpAccPortP, nil -} - -func setSpineInterfaceProfileAttributes(infraSpAccPortP *models.SpineInterfaceProfile, d *schema.ResourceData) (*schema.ResourceData, error) { - d.SetId(infraSpAccPortP.DistinguishedName) - d.Set("description", infraSpAccPortP.Description) - infraSpAccPortPMap, err := infraSpAccPortP.ToMap() - if err != nil { - return d, err - } - - d.Set("name", infraSpAccPortPMap["name"]) - d.Set("annotation", infraSpAccPortPMap["annotation"]) - d.Set("name_alias", infraSpAccPortPMap["nameAlias"]) - return d, nil -} - -func resourceAciSpineInterfaceProfileImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - log.Printf("[DEBUG] %s: Beginning Import", d.Id()) - aciClient := m.(*client.Client) - - dn := d.Id() - - infraSpAccPortP, err := getRemoteSpineInterfaceProfile(aciClient, dn) - - if err != nil { - return nil, err - } - schemaFilled, err := setSpineInterfaceProfileAttributes(infraSpAccPortP, d) - if err != nil { - return nil, err - } - - log.Printf("[DEBUG] %s: Import finished successfully", d.Id()) - - return []*schema.ResourceData{schemaFilled}, nil -} - -func resourceAciSpineInterfaceProfileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] SpineInterfaceProfile: Beginning Creation") - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - name := d.Get("name").(string) - - infraSpAccPortPAttr := models.SpineInterfaceProfileAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraSpAccPortPAttr.Annotation = Annotation.(string) - } else { - infraSpAccPortPAttr.Annotation = "{}" - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraSpAccPortPAttr.NameAlias = NameAlias.(string) - } - infraSpAccPortP := models.NewSpineInterfaceProfile(fmt.Sprintf("infra/spaccportprof-%s", name), "uni", desc, infraSpAccPortPAttr) - - err := aciClient.Save(infraSpAccPortP) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(infraSpAccPortP.DistinguishedName) - log.Printf("[DEBUG] %s: Creation finished successfully", d.Id()) - - return resourceAciSpineInterfaceProfileRead(ctx, d, m) -} - -func resourceAciSpineInterfaceProfileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] SpineInterfaceProfile: Beginning Update") - - aciClient := m.(*client.Client) - desc := d.Get("description").(string) - - name := d.Get("name").(string) - - infraSpAccPortPAttr := models.SpineInterfaceProfileAttributes{} - if Annotation, ok := d.GetOk("annotation"); ok { - infraSpAccPortPAttr.Annotation = Annotation.(string) - } else { - infraSpAccPortPAttr.Annotation = "{}" - } - if NameAlias, ok := d.GetOk("name_alias"); ok { - infraSpAccPortPAttr.NameAlias = NameAlias.(string) - } - infraSpAccPortP := models.NewSpineInterfaceProfile(fmt.Sprintf("infra/spaccportprof-%s", name), "uni", desc, infraSpAccPortPAttr) - - infraSpAccPortP.Status = "modified" - - err := aciClient.Save(infraSpAccPortP) - - if err != nil { - return diag.FromErr(err) - } - - d.SetId(infraSpAccPortP.DistinguishedName) - log.Printf("[DEBUG] %s: Update finished successfully", d.Id()) - - return resourceAciSpineInterfaceProfileRead(ctx, d, m) - -} - -func resourceAciSpineInterfaceProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Read", d.Id()) - - aciClient := m.(*client.Client) - - dn := d.Id() - infraSpAccPortP, err := getRemoteSpineInterfaceProfile(aciClient, dn) - - if err != nil { - return errorForObjectNotFound(err, dn, d) - } - - _, err = setSpineInterfaceProfileAttributes(infraSpAccPortP, d) - if err != nil { - d.SetId("") - return nil - } - - log.Printf("[DEBUG] %s: Read finished successfully", d.Id()) - - return nil -} - -func resourceAciSpineInterfaceProfileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Printf("[DEBUG] %s: Beginning Destroy", d.Id()) - - aciClient := m.(*client.Client) - dn := d.Id() - err := aciClient.DeleteByDn(dn, "infraSpAccPortP") - if err != nil { - return diag.FromErr(err) - } - - log.Printf("[DEBUG] %s: Destroy finished successfully", d.Id()) - - d.SetId("") - return diag.FromErr(err) -} diff --git a/aci/resource_aci_infraspaccportp_test.go b/aci/resource_aci_infraspaccportp_test.go deleted file mode 100644 index 2cc1a7b6f..000000000 --- a/aci/resource_aci_infraspaccportp_test.go +++ /dev/null @@ -1,141 +0,0 @@ -package aci - -import ( - "fmt" - "testing" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccAciSpineInterfaceProfile_Basic(t *testing.T) { - var spine_interface_profile models.SpineInterfaceProfile - description := "spine_interface_profile created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciSpineInterfaceProfileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciSpineInterfaceProfileConfig_basic(description), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciSpineInterfaceProfileExists("aci_spine_interface_profile.foospine_interface_profile", &spine_interface_profile), - testAccCheckAciSpineInterfaceProfileAttributes(description, &spine_interface_profile), - ), - }, - }, - }) -} - -func TestAccAciSpineInterfaceProfile_update(t *testing.T) { - var spine_interface_profile models.SpineInterfaceProfile - description := "spine_interface_profile created while acceptance testing" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAciSpineInterfaceProfileDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckAciSpineInterfaceProfileConfig_basic(description), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciSpineInterfaceProfileExists("aci_spine_interface_profile.foospine_interface_profile", &spine_interface_profile), - testAccCheckAciSpineInterfaceProfileAttributes(description, &spine_interface_profile), - ), - }, - { - Config: testAccCheckAciSpineInterfaceProfileConfig_basic(description), - Check: resource.ComposeTestCheckFunc( - testAccCheckAciSpineInterfaceProfileExists("aci_spine_interface_profile.foospine_interface_profile", &spine_interface_profile), - testAccCheckAciSpineInterfaceProfileAttributes(description, &spine_interface_profile), - ), - }, - }, - }) -} - -func testAccCheckAciSpineInterfaceProfileConfig_basic(description string) string { - return fmt.Sprintf(` - - resource "aci_spine_interface_profile" "foospine_interface_profile" { - description = "%s" - name = "example" - annotation = "example" - name_alias = "example" - } - `, description) -} - -func testAccCheckAciSpineInterfaceProfileExists(name string, spine_interface_profile *models.SpineInterfaceProfile) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - - if !ok { - return fmt.Errorf("Spine Interface Profile %s not found", name) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No Spine Interface Profile dn was set") - } - - client := testAccProvider.Meta().(*client.Client) - - cont, err := client.Get(rs.Primary.ID) - if err != nil { - return err - } - - spine_interface_profileFound := models.SpineInterfaceProfileFromContainer(cont) - if spine_interface_profileFound.DistinguishedName != rs.Primary.ID { - return fmt.Errorf("Spine Interface Profile %s not found", rs.Primary.ID) - } - *spine_interface_profile = *spine_interface_profileFound - return nil - } -} - -func testAccCheckAciSpineInterfaceProfileDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*client.Client) - - for _, rs := range s.RootModule().Resources { - - if rs.Type == "aci_spine_interface_profile" { - cont, err := client.Get(rs.Primary.ID) - spine_interface_profile := models.SpineInterfaceProfileFromContainer(cont) - if err == nil { - return fmt.Errorf("Spine Interface Profile %s Still exists", spine_interface_profile.DistinguishedName) - } - - } else { - continue - } - } - - return nil -} - -func testAccCheckAciSpineInterfaceProfileAttributes(description string, spine_interface_profile *models.SpineInterfaceProfile) resource.TestCheckFunc { - return func(s *terraform.State) error { - - if description != spine_interface_profile.Description { - return fmt.Errorf("Bad spine_interface_profile Description %s", spine_interface_profile.Description) - } - - if "example" != spine_interface_profile.Name { - return fmt.Errorf("Bad spine_interface_profile name %s", spine_interface_profile.Name) - } - - if "example" != spine_interface_profile.Annotation { - return fmt.Errorf("Bad spine_interface_profile annotation %s", spine_interface_profile.Annotation) - } - - if "example" != spine_interface_profile.NameAlias { - return fmt.Errorf("Bad spine_interface_profile name_alias %s", spine_interface_profile.NameAlias) - } - - return nil - } -} diff --git a/legacy-docs/docs/d/access_port_block.html.markdown b/legacy-docs/docs/d/access_port_block.html.markdown deleted file mode 100644 index ce43e317a..000000000 --- a/legacy-docs/docs/d/access_port_block.html.markdown +++ /dev/null @@ -1,50 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_access_port_block" -sidebar_current: "docs-aci-data-source-aci_access_port_block" -description: |- - Data source for ACI Access Port Block ---- - -# aci_access_port_block - -Data source for ACI Access Port Block - -## API Information ## - -* `Class` - infraPortBlk -* `Distinguished Name` - uni/infra/accportprof-{leaf_interface_profile_name}/hports-{leaf_interface_profile_dn}-typ-{type}/portblk-{name} - -## GUI Information ## - -* `Location` - Fabric -> Access Policies -> Interfaces -> Profiles -> Create Leaf Interface Profile -> Interface Selectors -> Port Blocks - -## Example Usage - -```hcl - -data "aci_access_port_block" "dev_port_blk" { - access_port_selector_dn = aci_access_port_selector.example.id - name = "foo_port_blk" -} - -``` - -## Argument Reference - -- `access_port_selector_dn` - (Required) Distinguished name of the parent Access Port Selector or Spine Access Port Selector object. -- `name` - (Required) Name of the Access Port Block object. - -## Attribute Reference - -- `id` - Attribute id set to the Dn of the Access Port Block. -- `description` - (Optional) Description of the Access Port Block object. -- `annotation` - (Optional) Annotation of the Access Port Block object. -- `from_card` - (Optional) The beginning (from-range) of the card range block for the leaf Access Port Block. -- `from_port` - (Optional) The beginning (from-range) of the port range block for the leaf Access Port Block. -- `name_alias` - (Optional) Name alias of the Access Port Block object. -- `to_card` - (Optional) The end (to-range) of the card range block for the leaf Access Port Block. -- `to_port` - (Optional) The end (to-range) of the port range block for the leaf Access Port Block. - -- `relation_infra_rs_acc_bndl_subgrp` - (Optional) Relation to class infraAccBndlSubgrp. Cardinality - N_TO_ONE. Type - String. diff --git a/legacy-docs/docs/d/access_port_selector.html.markdown b/legacy-docs/docs/d/access_port_selector.html.markdown deleted file mode 100644 index 7716b8312..000000000 --- a/legacy-docs/docs/d/access_port_selector.html.markdown +++ /dev/null @@ -1,35 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_access_port_selector" -sidebar_current: "docs-aci-data-source-aci_access_port_selector" -description: |- - Data source for ACI Access Port Selector ---- - -# aci_access_port_selector - -Data source for ACI Access Port Selector - -## Example Usage - -```hcl -data "aci_access_port_selector" "dev_acc_port_select" { - leaf_interface_profile_dn = aci_leaf_interface_profile.example.id - name = "foo_acc_port_select" - access_port_selector_type = "ALL" -} -``` - -## Argument Reference - -- `leaf_interface_profile_dn` - (Required) Distinguished name of parent Leaf Interface Profile object. -- `name` - (Required) Name of Object Access Port Selector. -- `access_port_selector_type` - (Required) The host port selector type. Allowed values are "ALL" and "range". Default is "ALL". - -## Attribute Reference - -- `id` - Attribute id set to the Dn of the Access Port Selector. -- `annotation` - (Optional) Annotation for object Access Port Selector. -- `description` - (Optional) Description for object Access Port Selector. -- `name_alias` - (Optional) Name alias for object Access Port Selector. diff --git a/legacy-docs/docs/d/fex_profile.html.markdown b/legacy-docs/docs/d/fex_profile.html.markdown deleted file mode 100644 index f0d62ae80..000000000 --- a/legacy-docs/docs/d/fex_profile.html.markdown +++ /dev/null @@ -1,33 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_fex_profile" -sidebar_current: "docs-aci-data-source-aci_fex_profile" -description: |- - Data source for ACI FEX Profile ---- - -# aci_fex_profile - -Data source for ACI FEX Profile - -## Example Usage - -```hcl - -data "aci_fex_profile" "example" { - name = "example" -} - -``` - -## Argument Reference - -- `name` - (Required) The fex profile name. - -## Attribute Reference - -- `id` - Attribute id set to the Dn of the FEX Profile. -- `annotation` - (Optional) Specifies the annotation of the policy definition. -- `name_alias` - (Optional) Specifies the description of the policy definition. -- `name_alias` - (Optional) Specifies the alias name of the policy definition. diff --git a/legacy-docs/docs/d/leaf_interface_profile.html.markdown b/legacy-docs/docs/d/leaf_interface_profile.html.markdown deleted file mode 100644 index d49ae88bd..000000000 --- a/legacy-docs/docs/d/leaf_interface_profile.html.markdown +++ /dev/null @@ -1,30 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_leaf_interface_profile" -sidebar_current: "docs-aci-data-source-aci_leaf_interface_profile" -description: |- - Data source for ACI Leaf Interface Profile ---- - -# aci_leaf_interface_profile # -Data source for ACI Leaf Interface Profile - -## Example Usage ## - -```hcl -data "aci_leaf_interface_profile" "dev_leaf_int_prof" { - name = "foo_leaf_int_prof" -} -``` -## Argument Reference ## -* `name` - (Required) Name of Object Leaf Interface Profile. - - - -## Attribute Reference - -* `id` - Attribute id set to the Dn of the Leaf Interface Profile. -* `description` - (Optional) Description for object Leaf Interface Profile. -* `annotation` - (Optional) Annotation for object Leaf Interface Profile. -* `name_alias` - (Optional) Name alias for object Leaf Interface Profile. diff --git a/legacy-docs/docs/d/spine_access_port_selector.html.markdown b/legacy-docs/docs/d/spine_access_port_selector.html.markdown deleted file mode 100644 index b5c1395c8..000000000 --- a/legacy-docs/docs/d/spine_access_port_selector.html.markdown +++ /dev/null @@ -1,45 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_spine_access_port_selector" -sidebar_current: "docs-aci-data-source-aci_spine_access_port_selector" -description: |- - Data source for ACI Spine Access Port Selector ---- - -# aci_spine_access_port_selector # - -Data source for ACI Spine Access Port Selector - - -## API Information ## - -* `Class` - infraSHPortS -* `Distinguished Named` - uni/infra/spaccportprof-{name}/shports-{name}-typ-{type} - -## GUI Information ## - -* `Location` - Fabric > Access Policies > Interfaces > Spine Interfaces > Profiles > {interface_profile}:{interface_selector} - - - -## Example Usage ## - -```hcl -data "aci_spine_access_port_selector" "example" { - spine_interface_profile_dn = aci_spine_interface_profile.example.id - name = "example" - spine_access_port_selector_type = "ALL" -} -``` - -## Argument Reference ## - -* `spine_interface_profile_dn` - (Required) Distinguished name of the parent Spine Interface Profile object. -* `name` - (Required) Name of the Spine Access Port Selector. -* `spine_access_port_selector_type` - (Required) The type of Spine Access Port Selector. Allowed values are "ALL" and "range". Default is "ALL". - -## Attribute Reference ## -* `id` - Attribute id set to the Dn of the Spine Access Port Selector. -* `annotation` - (Optional) Annotation of the Spine Access Port Selector. -* `name_alias` - (Optional) Name Alias of the Spine Access Port Selector. \ No newline at end of file diff --git a/legacy-docs/docs/d/spine_interface_profile.html.markdown b/legacy-docs/docs/d/spine_interface_profile.html.markdown deleted file mode 100644 index 8f812b397..000000000 --- a/legacy-docs/docs/d/spine_interface_profile.html.markdown +++ /dev/null @@ -1,35 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_spine_interface_profile" -sidebar_current: "docs-aci-data-source-aci_spine_interface_profile" -description: |- - Data source for ACI Spine Interface Profile ---- - -# aci_spine_interface_profile # -Data source for ACI Spine Interface Profile - -## Example Usage ## - -```hcl - -data "aci_spine_interface_profile" "example" { - name = "example" - description = "from terraform" -} - -``` - - -## Argument Reference ## -* `name` - (Required) Name of Object spine_interface_profile. - - - -## Attribute Reference - -* `id` - Attribute id set to the Dn of the Object Spine interface profile. -* `description` - (Optional) Description for Object Spine interface profile. -* `annotation` - (Optional) Annotation for Object Spine interface profile. -* `name_alias` - (Optional) Name alias for Object Spine interface profile. diff --git a/legacy-docs/docs/r/access_port_block.html.markdown b/legacy-docs/docs/r/access_port_block.html.markdown deleted file mode 100644 index 99749d225..000000000 --- a/legacy-docs/docs/r/access_port_block.html.markdown +++ /dev/null @@ -1,66 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_access_port_block" -sidebar_current: "docs-aci-resource-aci_access_port_block" -description: |- - Manages ACI Access Port Block ---- - -# aci_access_port_block - -Manages ACI Access Port Block - -## API Information ## - -* `Class` - infraPortBlk -* `Distinguished Name` - uni/infra/accportprof-{leaf_interface_profile_name}/hports-{leaf_interface_profile_dn}-typ-{type}/portblk-{name} - -## GUI Information ## - -* `Location` - Fabric -> Access Policies -> Interfaces -> Profiles -> Create Leaf Interface Profile -> Interface Selectors -> Port Blocks - -## Example Usage - -```hcl -resource "aci_access_port_block" "test_port_block" { - access_port_selector_dn = aci_access_port_selector.fooaccess_port_selector.id - name = "tf_test_block" - description = "From Terraform" - annotation = "tag_port_block" - from_card = "1" - from_port = "1" - name_alias = "alias_port_block" - to_card = "3" - to_port = "3" - relation_infra_rs_acc_bndl_subgrp = aci_leaf_access_bundle_policy_sub_group.test_access_bundle_policy_sub_group.id -} -``` - -## Argument Reference - -- `access_port_selector_dn` - (Required) Distinguished name of the parent Access Port Selector or Spine Access Port Selector object. -- `name` - (Optional) Name of the Access Port Block object. -- `annotation` - (Optional) Annotation of the Access Port Block object. -- `description` - (Optional) Description of the Access Port Block object. -- `from_card` - (Optional) The beginning (from-range) of the card range block for the leaf access port block. Allowed value range is 1-100. Default value is "1". -- `from_port` - (Optional) The beginning (from-range) of the port range block for the leaf access port block. Allowed value range is 1-127. Default value is "1". -- `name_alias` - (Optional) Name alias of the Access Port Block object. -- `to_card` - (Optional) The end (to-range) of the card range block for the leaf access port block. Allowed value range is 1-100. Default value is "1". -- `to_port` - (Optional) The end (to-range) of the port range block for the leaf access port block. Allowed value range is 1-127. Default value is "1". - -- `relation_infra_rs_acc_bndl_subgrp` - (Optional) Relation to class infraAccBndlSubgrp. Cardinality - N_TO_ONE. Type - String. - -## Attribute Reference - -The only attribute that this resource exports is the `id`, which is set to the -Dn of the Access Port Block. - -## Importing - -An existing Access Port Block can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html - -``` -terraform import aci_access_port_block.example -``` diff --git a/legacy-docs/docs/r/access_port_selector.html.markdown b/legacy-docs/docs/r/access_port_selector.html.markdown deleted file mode 100644 index 08d9ff109..000000000 --- a/legacy-docs/docs/r/access_port_selector.html.markdown +++ /dev/null @@ -1,50 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_access_port_selector" -sidebar_current: "docs-aci-resource-aci_access_port_selector" -description: |- - Manages ACI Access Port Selector ---- - -# aci_access_port_selector - -Manages ACI Access Port Selector - -## Example Usage - -```hcl -resource "aci_access_port_selector" "fooaccess_port_selector" { - leaf_interface_profile_dn = aci_leaf_interface_profile.example.id - description = "from terraform" - name = "demo_port_selector" - access_port_selector_type = "ALL" - annotation = "tag_port_selector" - name_alias = "alias_port_selector" -} -``` - -## Argument Reference - -- `leaf_interface_profile_dn` - (Required) Distinguished name of parent Leaf Interface Profile object. -- `name` - (Required) Name of Object Access Port Selector. -- `access_port_selector_type` - (Required) The host port selector type. Allowed values are "ALL" and "range". Default is "ALL". -- `annotation` - (Optional) Annotation for object Access Port Selector. -- `description` - (Optional) Description for object Access Port Selector. -- `name_alias` - (Optional) Name alias for object Access Port Selector. - -- `relation_infra_rs_acc_base_grp` - (Optional) Relation to class infraAccBaseGrp. Cardinality - N_TO_ONE. Type - String. - -## Attribute Reference - -The only attribute that this resource exports is the `id`, which is set to the -Dn of the Access Port Selector. - -## Importing - -An existing Access Port Selector can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html - -``` -terraform import aci_access_port_selector.example -``` diff --git a/legacy-docs/docs/r/fex_profile.html.markdown b/legacy-docs/docs/r/fex_profile.html.markdown deleted file mode 100644 index 70f18373c..000000000 --- a/legacy-docs/docs/r/fex_profile.html.markdown +++ /dev/null @@ -1,46 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_fex_profile" -sidebar_current: "docs-aci-resource-aci_fex_profile" -description: |- - Manages ACI FEX Profile ---- - -# aci_fex_profile - -Manages ACI FEX Profile - -## Example Usage - -```hcl - -resource "aci_fex_profile" "example" { - name = "fex_prof" - annotation = "example" - name_alias = "example" - description = "from terraform" -} - -``` - -## Argument Reference - -- `name` - (Required) The FEX profile name. -- `annotation` - (Optional) Specifies the annotation of the FEX profile name. -- `description` - (Optional) Specifies the description of the FEX profile name. -- `name_alias` - (Optional) Specifies the alias name of the FEX profile name. - -## Attribute Reference - -The only attribute that this resource exports is the `id`, which is set to the -Dn of the FEX Profile. - -## Importing - -An existing FEX Profile can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html - -``` -terraform import aci_fex_profile.example -``` diff --git a/legacy-docs/docs/r/leaf_interface_profile.html.markdown b/legacy-docs/docs/r/leaf_interface_profile.html.markdown deleted file mode 100644 index f7fc22d4a..000000000 --- a/legacy-docs/docs/r/leaf_interface_profile.html.markdown +++ /dev/null @@ -1,44 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_leaf_interface_profile" -sidebar_current: "docs-aci-resource-aci_leaf_interface_profile" -description: |- - Manages ACI Leaf Interface Profile ---- - -# aci_leaf_interface_profile # -Manages ACI Leaf Interface Profile - -## Example Usage ## - -```hcl -resource "aci_leaf_interface_profile" "fooleaf_interface_profile" { - description = "From Terraform" - name = "demo_leaf_profile" - annotation = "tag_leaf" - name_alias = "name_alias" -} -``` -## Argument Reference ## -* `name` - (Required) Name of Object leaf interface profile. -* `description` - (Optional) Description for object leaf interface profile. -* `annotation` - (Optional) Annotation for object leaf interface profile. -* `name_alias` - (Optional) Name alias for object leaf interface profile. - - - -## Attribute Reference - -The only attribute that this resource exports is the `id`, which is set to the -Dn of the Leaf Interface Profile. - -## Importing ## - -An existing Leaf Interface Profile can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html - - -``` -terraform import aci_leaf_interface_profile.example -``` diff --git a/legacy-docs/docs/r/spine_access_port_selector.html.markdown b/legacy-docs/docs/r/spine_access_port_selector.html.markdown deleted file mode 100644 index 7ac70ecd1..000000000 --- a/legacy-docs/docs/r/spine_access_port_selector.html.markdown +++ /dev/null @@ -1,57 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_spine_access_port_selector" -sidebar_current: "docs-aci-resource-aci_spine_access_port_selector" -description: |- - Manages ACI Spine Access Port Selector ---- - -# aci_spine_access_port_selector # - -Manages ACI Spine Access Port Selector - -## API Information ## - -* `Class` - infraSHPortS -* `Distinguished Named` - uni/infra/spaccportprof-{name}/shports-{name}-typ-{type} - -## GUI Information ## - -* `Location` - Fabric > Access Policies > Interfaces > Spine Interfaces > Profiles > {interface_profile}:{interface_selector} - - -## Example Usage ## - -```hcl -resource "aci_spine_access_port_selector" "example" { - spine_interface_profile_dn = aci_spine_interface_profile.example.id - name = "example" - spine_access_port_selector_type = "ALL" - annotation = "orchestrator:terraform" - name_alias = "alias example" - - relation_infra_rs_sp_acc_grp = aci_resource.example.id -} -``` - -## Argument Reference ## - -* `spine_interface_profile_dn` - (Required) Distinguished name of the parent Spine Interface Profile. -* `name` - (Required) Name of the Spine Access Port Selector. -* `spine_access_port_selector_type` - (Required) The type of Spine Access Port Selector. Allowed values are "ALL" and "range". Default is "ALL". The "range" can be specified with the resource "aci_access_port_block". -* `annotation` - (Optional) Annotation of the Spine Access Port Selector. -* `name_alias` - (Optional) Name Alias of the Spine Access Port Selector. - -* `relation_infra_rs_sp_acc_grp` - (Optional) Represents the relation to a Spine Access Group (class infraSpAccGrp). Type: String. - - -## Importing ## - -An existing Spine Access Port Selector can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html - - -``` -terraform import aci_spine_access_port_selector.example -``` diff --git a/legacy-docs/docs/r/spine_interface_profile.html.markdown b/legacy-docs/docs/r/spine_interface_profile.html.markdown deleted file mode 100644 index ced13b1ee..000000000 --- a/legacy-docs/docs/r/spine_interface_profile.html.markdown +++ /dev/null @@ -1,48 +0,0 @@ ---- -subcategory: "Access Policies" -layout: "aci" -page_title: "ACI: aci_spine_interface_profile" -sidebar_current: "docs-aci-resource-aci_spine_interface_profile" -description: |- - Manages ACI Spine Interface Profile ---- - -# aci_spine_interface_profile # -Manages ACI Spine Interface Profile - -## Example Usage ## - -```hcl - -resource "aci_spine_interface_profile" "example" { - name = "example" - description = "from terraform" - annotation = "example" - name_alias = "example" -} - -``` - - -## Argument Reference ## -* `name` - (Required) Name of Object Spine interface profile. -* `description` - (Optional) Description for Object Spine interface profile. -* `annotation` - (Optional) Annotation for Object Spine interface profile. -* `name_alias` - (Optional) Name alias for Object Spine interface profile. - - - -## Attribute Reference - -The only attribute that this resource exports is the `id`, which is set to the -Dn of the Spine Interface Profile. - -## Importing ## - -An existing Spine Interface Profile can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html - - -``` -terraform import aci_spine_interface_profile.example -``` \ No newline at end of file From 2016396670445ec8f67401d5ec0f074c078a2867 Mon Sep 17 00:00:00 2001 From: akinross Date: Tue, 11 Nov 2025 10:52:25 +0100 Subject: [PATCH 2/5] [minor_change] Migrate resources and datasource aci_access_port_block, aci_access_port_selector, aci_fex_profile. aci_leaf_interface_profile, aci_spine_interface_profile and aci_spine_access_port_selector to terrform plugin framework --- docs/data-sources/access_port_block.md | 73 +- docs/data-sources/access_port_selector.md | 78 +- docs/data-sources/fex_profile.md | 53 +- docs/data-sources/leaf_interface_profile.md | 54 +- .../spine_access_port_selector.md | 62 +- docs/data-sources/spine_interface_profile.md | 49 +- docs/resources/access_port_block.md | 213 ++- docs/resources/access_port_selector.md | 211 ++- docs/resources/fex_profile.md | 115 +- docs/resources/leaf_interface_profile.md | 117 +- docs/resources/spine_access_port_selector.md | 152 +- docs/resources/spine_interface_profile.md | 113 +- .../aci_access_port_block/data-source.tf | 10 + .../aci_access_port_block/provider.tf | 14 + .../aci_access_port_selector/data-source.tf | 12 + .../aci_access_port_selector/provider.tf | 14 + .../aci_fex_profile/data-source.tf | 4 + .../data-sources/aci_fex_profile/provider.tf | 14 + .../aci_leaf_interface_profile/data-source.tf | 4 + .../aci_leaf_interface_profile/provider.tf | 14 + .../data-source.tf | 6 + .../provider.tf | 14 + .../data-source.tf | 4 + .../aci_spine_interface_profile/provider.tf | 14 + .../aci_access_port_block/provider.tf | 14 + .../resource-all-attributes.tf | 80 + .../aci_access_port_block/resource.tf | 10 + .../aci_access_port_selector/provider.tf | 14 + .../resource-all-attributes.tf | 80 + .../aci_access_port_selector/resource.tf | 12 + .../resources/aci_fex_profile/provider.tf | 14 + .../resource-all-attributes.tf | 21 + .../resources/aci_fex_profile/resource.tf | 4 + .../aci_leaf_interface_profile/provider.tf | 14 + .../resource-all-attributes.tf | 21 + .../aci_leaf_interface_profile/resource.tf | 4 + .../provider.tf | 14 + .../resource-all-attributes.tf | 39 + .../resource.tf | 6 + .../aci_spine_interface_profile/provider.tf | 14 + .../resource-all-attributes.tf | 21 + .../aci_spine_interface_profile/resource.tf | 4 + gen/definitions/classes.yaml | 78 + gen/definitions/properties.yaml | 108 ++ gen/generator.go | 37 +- gen/meta/infraAccPortP.json | 826 ++++++++++ gen/meta/infraFexP.json | 848 ++++++++++ gen/meta/infraHPortS.json | 826 ++++++++++ gen/meta/infraPortBlk.json | 819 ++++++++++ gen/meta/infraRsAccBaseGrp.json | 1007 ++++++++++++ gen/meta/infraRsAccBndlSubgrp.json | 916 +++++++++++ gen/meta/infraRsSpAccGrp.json | 918 +++++++++++ gen/meta/infraSHPortS.json | 824 ++++++++++ gen/meta/infraSpAccPortP.json | 818 ++++++++++ gen/templates/resource.go.tmpl | 22 +- .../resource_example_all_attributes.tf.tmpl | 10 +- gen/templates/resource_test.go.tmpl | 12 + gen/templates/testvars.yaml.tmpl | 9 + gen/testvars/infraAccPortP.yaml | 46 + gen/testvars/infraFexP.yaml | 46 + gen/testvars/infraHPortS.yaml | 98 ++ gen/testvars/infraPortBlk.yaml | 82 + gen/testvars/infraSHPortS.yaml | 92 ++ gen/testvars/infraSpAccPortP.yaml | 46 + .../data_source_aci_access_port_block.go | 230 +++ .../data_source_aci_access_port_block_test.go | 96 ++ .../data_source_aci_access_port_selector.go | 239 +++ ...ta_source_aci_access_port_selector_test.go | 98 ++ .../provider/data_source_aci_fex_profile.go | 170 ++ .../data_source_aci_fex_profile_test.go | 49 + .../data_source_aci_leaf_interface_profile.go | 170 ++ ..._source_aci_leaf_interface_profile_test.go | 49 + ...a_source_aci_spine_access_port_selector.go | 235 +++ ...rce_aci_spine_access_port_selector_test.go | 56 + ...data_source_aci_spine_interface_profile.go | 170 ++ ...source_aci_spine_interface_profile_test.go | 49 + internal/provider/provider.go | 12 + .../resource_aci_access_port_block.go | 1347 ++++++++++++++++ .../resource_aci_access_port_block_test.go | 846 ++++++++++ .../resource_aci_access_port_selector.go | 1371 +++++++++++++++++ .../resource_aci_access_port_selector_test.go | 860 +++++++++++ internal/provider/resource_aci_fex_profile.go | 722 +++++++++ .../provider/resource_aci_fex_profile_test.go | 308 ++++ .../resource_aci_leaf_interface_profile.go | 722 +++++++++ ...esource_aci_leaf_interface_profile_test.go | 308 ++++ ...resource_aci_spine_access_port_selector.go | 1349 ++++++++++++++++ ...rce_aci_spine_access_port_selector_test.go | 436 ++++++ .../resource_aci_spine_interface_profile.go | 722 +++++++++ ...source_aci_spine_interface_profile_test.go | 308 ++++ 89 files changed, 20989 insertions(+), 221 deletions(-) create mode 100644 examples/data-sources/aci_access_port_block/data-source.tf create mode 100644 examples/data-sources/aci_access_port_block/provider.tf create mode 100644 examples/data-sources/aci_access_port_selector/data-source.tf create mode 100644 examples/data-sources/aci_access_port_selector/provider.tf create mode 100644 examples/data-sources/aci_fex_profile/data-source.tf create mode 100644 examples/data-sources/aci_fex_profile/provider.tf create mode 100644 examples/data-sources/aci_leaf_interface_profile/data-source.tf create mode 100644 examples/data-sources/aci_leaf_interface_profile/provider.tf create mode 100644 examples/data-sources/aci_spine_access_port_selector/data-source.tf create mode 100644 examples/data-sources/aci_spine_access_port_selector/provider.tf create mode 100644 examples/data-sources/aci_spine_interface_profile/data-source.tf create mode 100644 examples/data-sources/aci_spine_interface_profile/provider.tf create mode 100644 examples/resources/aci_access_port_block/provider.tf create mode 100644 examples/resources/aci_access_port_block/resource-all-attributes.tf create mode 100644 examples/resources/aci_access_port_block/resource.tf create mode 100644 examples/resources/aci_access_port_selector/provider.tf create mode 100644 examples/resources/aci_access_port_selector/resource-all-attributes.tf create mode 100644 examples/resources/aci_access_port_selector/resource.tf create mode 100644 examples/resources/aci_fex_profile/provider.tf create mode 100644 examples/resources/aci_fex_profile/resource-all-attributes.tf create mode 100644 examples/resources/aci_fex_profile/resource.tf create mode 100644 examples/resources/aci_leaf_interface_profile/provider.tf create mode 100644 examples/resources/aci_leaf_interface_profile/resource-all-attributes.tf create mode 100644 examples/resources/aci_leaf_interface_profile/resource.tf create mode 100644 examples/resources/aci_spine_access_port_selector/provider.tf create mode 100644 examples/resources/aci_spine_access_port_selector/resource-all-attributes.tf create mode 100644 examples/resources/aci_spine_access_port_selector/resource.tf create mode 100644 examples/resources/aci_spine_interface_profile/provider.tf create mode 100644 examples/resources/aci_spine_interface_profile/resource-all-attributes.tf create mode 100644 examples/resources/aci_spine_interface_profile/resource.tf create mode 100644 gen/meta/infraAccPortP.json create mode 100644 gen/meta/infraFexP.json create mode 100644 gen/meta/infraHPortS.json create mode 100644 gen/meta/infraPortBlk.json create mode 100644 gen/meta/infraRsAccBaseGrp.json create mode 100644 gen/meta/infraRsAccBndlSubgrp.json create mode 100644 gen/meta/infraRsSpAccGrp.json create mode 100644 gen/meta/infraSHPortS.json create mode 100644 gen/meta/infraSpAccPortP.json create mode 100644 gen/testvars/infraAccPortP.yaml create mode 100644 gen/testvars/infraFexP.yaml create mode 100644 gen/testvars/infraHPortS.yaml create mode 100644 gen/testvars/infraPortBlk.yaml create mode 100644 gen/testvars/infraSHPortS.yaml create mode 100644 gen/testvars/infraSpAccPortP.yaml create mode 100644 internal/provider/data_source_aci_access_port_block.go create mode 100644 internal/provider/data_source_aci_access_port_block_test.go create mode 100644 internal/provider/data_source_aci_access_port_selector.go create mode 100644 internal/provider/data_source_aci_access_port_selector_test.go create mode 100644 internal/provider/data_source_aci_fex_profile.go create mode 100644 internal/provider/data_source_aci_fex_profile_test.go create mode 100644 internal/provider/data_source_aci_leaf_interface_profile.go create mode 100644 internal/provider/data_source_aci_leaf_interface_profile_test.go create mode 100644 internal/provider/data_source_aci_spine_access_port_selector.go create mode 100644 internal/provider/data_source_aci_spine_access_port_selector_test.go create mode 100644 internal/provider/data_source_aci_spine_interface_profile.go create mode 100644 internal/provider/data_source_aci_spine_interface_profile_test.go create mode 100644 internal/provider/resource_aci_access_port_block.go create mode 100644 internal/provider/resource_aci_access_port_block_test.go create mode 100644 internal/provider/resource_aci_access_port_selector.go create mode 100644 internal/provider/resource_aci_access_port_selector_test.go create mode 100644 internal/provider/resource_aci_fex_profile.go create mode 100644 internal/provider/resource_aci_fex_profile_test.go create mode 100644 internal/provider/resource_aci_leaf_interface_profile.go create mode 100644 internal/provider/resource_aci_leaf_interface_profile_test.go create mode 100644 internal/provider/resource_aci_spine_access_port_selector.go create mode 100644 internal/provider/resource_aci_spine_access_port_selector_test.go create mode 100644 internal/provider/resource_aci_spine_interface_profile.go create mode 100644 internal/provider/resource_aci_spine_interface_profile_test.go diff --git a/docs/data-sources/access_port_block.md b/docs/data-sources/access_port_block.md index ce43e317a..e3fcc2441 100644 --- a/docs/data-sources/access_port_block.md +++ b/docs/data-sources/access_port_block.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_access_port_block" @@ -7,44 +10,72 @@ description: |- Data source for ACI Access Port Block --- -# aci_access_port_block +# aci_access_port_block # Data source for ACI Access Port Block ## API Information ## -* `Class` - infraPortBlk -* `Distinguished Name` - uni/infra/accportprof-{leaf_interface_profile_name}/hports-{leaf_interface_profile_dn}-typ-{type}/portblk-{name} +* Class: [infraPortBlk](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraPortBlk/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Formats: + - `uni/infra/accportprof-{name}/hports-{name}-typ-{type}/portblk-{name}` + - `uni/infra/fexprof-{name}/hports-{name}-typ-{type}/portblk-{name}` + - `uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}/portblk-{name}` ## GUI Information ## -* `Location` - Fabric -> Access Policies -> Interfaces -> Profiles -> Create Leaf Interface Profile -> Interface Selectors -> Port Blocks +* Location: `Fabric -> Access Policies -> Interfaces -> Leaf/Spine Interfaces -> Profiles -> Interface Selectors -> Port Blocks` -## Example Usage +## Example Usage ## ```hcl -data "aci_access_port_block" "dev_port_blk" { - access_port_selector_dn = aci_access_port_selector.example.id - name = "foo_port_blk" +data "aci_access_port_block" "example_access_port_selector" { + parent_dn = aci_access_port_selector.example.id + name = "test_name" +} + +data "aci_access_port_block" "example_spine_access_port_selector" { + parent_dn = aci_spine_access_port_selector.example.id + name = "test_name" } ``` -## Argument Reference +## Schema ## -- `access_port_selector_dn` - (Required) Distinguished name of the parent Access Port Selector or Spine Access Port Selector object. -- `name` - (Required) Name of the Access Port Block object. +### Required ### -## Attribute Reference +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_access_port_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_port_selector) ([infraHPortS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPortS/overview)) + - [aci_spine_access_port_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/spine_access_port_selector) ([infraSHPortS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSHPortS/overview)) +* `name` (name) - (string) The name of the Access Port Block object. -- `id` - Attribute id set to the Dn of the Access Port Block. -- `description` - (Optional) Description of the Access Port Block object. -- `annotation` - (Optional) Annotation of the Access Port Block object. -- `from_card` - (Optional) The beginning (from-range) of the card range block for the leaf Access Port Block. -- `from_port` - (Optional) The beginning (from-range) of the port range block for the leaf Access Port Block. -- `name_alias` - (Optional) Name alias of the Access Port Block object. -- `to_card` - (Optional) The end (to-range) of the card range block for the leaf Access Port Block. -- `to_port` - (Optional) The end (to-range) of the port range block for the leaf Access Port Block. +### Read-Only ### -- `relation_infra_rs_acc_bndl_subgrp` - (Optional) Relation to class infraAccBndlSubgrp. Cardinality - N_TO_ONE. Type - String. +* `id` - (string) The distinguished name (DN) of the Access Port Block object. +* `annotation` (annotation) - (string) The annotation of the Access Port Block object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `description` (descr) - (string) The description of the Access Port Block object. This attribute is supported in ACI versions: 1.0(4g) and later. +* `from_card` (fromCard) - (string) The start of the line card range for the Access Port Block object. +* `from_port` (fromPort) - (string) The start of the port range for the Access Port Block object. +* `name_alias` (nameAlias) - (string) The name alias of the Access Port Block object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `to_card` (toCard) - (string) The end of the line card range for the Access Port Block object. +* `to_port` (toPort) - (string) The end of the port range for the Access Port Block object. +* `relation_to_pc_vpc_override_policy` - (map) A map of Relation To Pc Vpc Override Policy (ACI object [infraRsAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBndlSubgrp/overview)) pointing to PC VPC Override Policy (ACI Object [infraAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBndlSubgrp/overview)). + * `annotation` (annotation) - (string) The annotation of the Relation To Pc Vpc Override Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. + * `target_dn` (tDn) - (string) The distinguished name (DN) of the target PC VPC Override Policy. + * `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. +* `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/access_port_selector.md b/docs/data-sources/access_port_selector.md index 7716b8312..cdc50209a 100644 --- a/docs/data-sources/access_port_selector.md +++ b/docs/data-sources/access_port_selector.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_access_port_selector" @@ -7,29 +10,74 @@ description: |- Data source for ACI Access Port Selector --- -# aci_access_port_selector +# aci_access_port_selector # Data source for ACI Access Port Selector -## Example Usage +## API Information ## + +* Class: [infraHPortS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPortS/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Formats: + - `uni/infra/accportprof-{name}/hports-{name}-typ-{type}` + - `uni/infra/fexprof-{name}/hports-{name}-typ-{type}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Interface Selectors` + +## Example Usage ## ```hcl -data "aci_access_port_selector" "dev_acc_port_select" { - leaf_interface_profile_dn = aci_leaf_interface_profile.example.id - name = "foo_acc_port_select" - access_port_selector_type = "ALL" + +data "aci_access_port_selector" "example_leaf_interface_profile" { + parent_dn = aci_leaf_interface_profile.example.id + name = "test_name" + port_selector_type = "range" +} + +data "aci_access_port_selector" "example_fex_profile" { + parent_dn = aci_fex_profile.example.id + name = "test_name" + port_selector_type = "range" } + ``` -## Argument Reference +## Schema ## + +### Required ### -- `leaf_interface_profile_dn` - (Required) Distinguished name of parent Leaf Interface Profile object. -- `name` - (Required) Name of Object Access Port Selector. -- `access_port_selector_type` - (Required) The host port selector type. Allowed values are "ALL" and "range". Default is "ALL". +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_leaf_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/leaf_interface_profile) ([infraAccPortP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccPortP/overview)) + - [aci_fex_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/fex_profile) ([infraFexP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraFexP/overview)) +* `name` (name) - (string) The name of the Access Port Selector object. +* `port_selector_type` (type) - (string) The port selector type of the Access Port Selector object. + - Valid Values: `ALL`, `range`. -## Attribute Reference +### Read-Only ### -- `id` - Attribute id set to the Dn of the Access Port Selector. -- `annotation` - (Optional) Annotation for object Access Port Selector. -- `description` - (Optional) Description for object Access Port Selector. -- `name_alias` - (Optional) Name alias for object Access Port Selector. +* `id` - (string) The distinguished name (DN) of the Access Port Selector object. +* `annotation` (annotation) - (string) The annotation of the Access Port Selector object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `description` (descr) - (string) The description of the Access Port Selector object. +* `name_alias` (nameAlias) - (string) The name alias of the Access Port Selector object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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. +* `relation_to_leaf_access_port_policy_group` - (map) A map of Relation To Leaf Access Port Policy Group (ACI object [infraRsAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBaseGrp/overview)) pointing to Access Interface Policy Group (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)). + * `annotation` (annotation) - (string) The annotation of the Relation To Leaf Access Port Policy Group object. This attribute is supported in ACI versions: 3.2(1l) and later. + * `fex_id` (fexId) - (string) The interface policy group FEX ID. + * `target_dn` (tDn) - (string) Select or create an interface policy group to associate to the Access Port selector. + * `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. +* `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/fex_profile.md b/docs/data-sources/fex_profile.md index f0d62ae80..84a7c368b 100644 --- a/docs/data-sources/fex_profile.md +++ b/docs/data-sources/fex_profile.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_fex_profile" @@ -7,27 +10,57 @@ description: |- Data source for ACI FEX Profile --- -# aci_fex_profile +# aci_fex_profile # Data source for ACI FEX Profile -## Example Usage +## API Information ## + +* Class: [infraFexP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraFexP/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Format: `uni/infra/fexprof-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Fex Interfaces` + +## Example Usage ## ```hcl data "aci_fex_profile" "example" { - name = "example" + name = "test_name" } ``` -## Argument Reference +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the FEX Profile 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) -- `name` - (Required) The fex profile name. + - Default: `uni/infra` -## Attribute Reference +### Read-Only ### -- `id` - Attribute id set to the Dn of the FEX Profile. -- `annotation` - (Optional) Specifies the annotation of the policy definition. -- `name_alias` - (Optional) Specifies the description of the policy definition. -- `name_alias` - (Optional) Specifies the alias name of the policy definition. +* `id` - (string) The distinguished name (DN) of the FEX Profile object. +* `annotation` (annotation) - (string) The annotation of the FEX Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `description` (descr) - (string) The description of the FEX Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the FEX Profile object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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/leaf_interface_profile.md b/docs/data-sources/leaf_interface_profile.md index d49ae88bd..8622c7c57 100644 --- a/docs/data-sources/leaf_interface_profile.md +++ b/docs/data-sources/leaf_interface_profile.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_leaf_interface_profile" @@ -8,23 +11,56 @@ description: |- --- # aci_leaf_interface_profile # + Data source for ACI Leaf Interface Profile +## API Information ## + +* Class: [infraAccPortP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccPortP/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Format: `uni/infra/accportprof-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Interfaces` + ## Example Usage ## ```hcl -data "aci_leaf_interface_profile" "dev_leaf_int_prof" { - name = "foo_leaf_int_prof" + +data "aci_leaf_interface_profile" "example" { + name = "test_name" } + ``` -## Argument Reference ## -* `name` - (Required) Name of Object Leaf Interface Profile. +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the Leaf Interface Profile 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` -## Attribute Reference +### Read-Only ### -* `id` - Attribute id set to the Dn of the Leaf Interface Profile. -* `description` - (Optional) Description for object Leaf Interface Profile. -* `annotation` - (Optional) Annotation for object Leaf Interface Profile. -* `name_alias` - (Optional) Name alias for object Leaf Interface Profile. +* `id` - (string) The distinguished name (DN) of the Leaf Interface Profile object. +* `annotation` (annotation) - (string) The annotation of the Leaf Interface Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `description` (descr) - (string) The description of the Leaf Interface Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the Leaf Interface Profile object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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/spine_access_port_selector.md b/docs/data-sources/spine_access_port_selector.md index b5c1395c8..11ff50231 100644 --- a/docs/data-sources/spine_access_port_selector.md +++ b/docs/data-sources/spine_access_port_selector.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_spine_access_port_selector" @@ -11,35 +14,60 @@ description: |- Data source for ACI Spine Access Port Selector - ## API Information ## -* `Class` - infraSHPortS -* `Distinguished Named` - uni/infra/spaccportprof-{name}/shports-{name}-typ-{type} +* Class: [infraSHPortS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSHPortS/overview) -## GUI Information ## +* Supported in ACI versions: 2.0(1m) and later. -* `Location` - Fabric > Access Policies > Interfaces > Spine Interfaces > Profiles > {interface_profile}:{interface_selector} +* Distinguished Name Format: `uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}` +## GUI Information ## +* Location: `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Profiles -> Interface Selectors` ## Example Usage ## ```hcl -data "aci_spine_access_port_selector" "example" { - spine_interface_profile_dn = aci_spine_interface_profile.example.id - name = "example" - spine_access_port_selector_type = "ALL" + +data "aci_spine_access_port_selector" "example_spine_interface_profile" { + parent_dn = aci_spine_interface_profile.example.id + name = "test_name" + port_selector_type = "ALL" } + ``` -## Argument Reference ## +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_spine_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/spine_interface_profile) ([infraSpAccPortP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSpAccPortP/overview)) +* `name` (name) - (string) The name of the Spine Access Port Selector object. +* `port_selector_type` (type) - (string) The port selector type of the Spine Access Port Selector object. + - Valid Values: `ALL`, `range`. -* `spine_interface_profile_dn` - (Required) Distinguished name of the parent Spine Interface Profile object. -* `name` - (Required) Name of the Spine Access Port Selector. -* `spine_access_port_selector_type` - (Required) The type of Spine Access Port Selector. Allowed values are "ALL" and "range". Default is "ALL". +### Read-Only ### -## Attribute Reference ## -* `id` - Attribute id set to the Dn of the Spine Access Port Selector. -* `annotation` - (Optional) Annotation of the Spine Access Port Selector. -* `name_alias` - (Optional) Name Alias of the Spine Access Port Selector. \ No newline at end of file +* `id` - (string) The distinguished name (DN) of the Spine Access Port Selector object. +* `annotation` (annotation) - (string) The annotation of the Spine Access Port Selector object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `description` (descr) - (string) The description of the Spine Access Port Selector object. +* `name_alias` (nameAlias) - (string) The name alias of the Spine Access Port Selector object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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. +* `relation_to_spine_port_policy_group` - (map) A map of Relation To Spine Port Policy Group (ACI object [infraRsSpAccGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsSpAccGrp/overview)) pointing to (ACI Object [infraSpAccGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSpAccGrp/overview)). + * `annotation` (annotation) - (string) The annotation of the Relation To Spine Port Policy Group object. This attribute is supported in ACI versions: 3.2(1l) and later. + * `target_dn` (tDn) - (string) The distinguished name of the target. + * `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. +* `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/spine_interface_profile.md b/docs/data-sources/spine_interface_profile.md index 8f812b397..ba300881c 100644 --- a/docs/data-sources/spine_interface_profile.md +++ b/docs/data-sources/spine_interface_profile.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_spine_interface_profile" @@ -8,28 +11,56 @@ description: |- --- # aci_spine_interface_profile # + Data source for ACI Spine Interface Profile +## API Information ## + +* Class: [infraSpAccPortP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSpAccPortP/overview) + +* Supported in ACI versions: 2.0(1m) and later. + +* Distinguished Name Format: `uni/infra/spaccportprof-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Profiles` + ## Example Usage ## ```hcl data "aci_spine_interface_profile" "example" { - name = "example" - description = "from terraform" + name = "test_name" } ``` +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the Spine Interface Profile object. -## Argument Reference ## -* `name` - (Required) Name of Object spine_interface_profile. +### 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` -## Attribute Reference +### Read-Only ### -* `id` - Attribute id set to the Dn of the Object Spine interface profile. -* `description` - (Optional) Description for Object Spine interface profile. -* `annotation` - (Optional) Annotation for Object Spine interface profile. -* `name_alias` - (Optional) Name alias for Object Spine interface profile. +* `id` - (string) The distinguished name (DN) of the Spine Interface Profile object. +* `annotation` (annotation) - (string) The annotation of the Spine Interface Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `description` (descr) - (string) The description of the Spine Interface Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the Spine Interface Profile object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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/resources/access_port_block.md b/docs/resources/access_port_block.md index 99749d225..26a8051db 100644 --- a/docs/resources/access_port_block.md +++ b/docs/resources/access_port_block.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_access_port_block" @@ -7,60 +10,204 @@ description: |- Manages ACI Access Port Block --- -# aci_access_port_block +# aci_access_port_block # Manages ACI Access Port Block + -> Port Blocks are only applied and visible in UI when the `port_selector_type` attribute on it's parent is set to `range`. + + !> This resource has been migrated to the terraform plugin protocol version 6, refer to the [migration guide](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/guides/migration) for more details and implications for already managed resources. + ## API Information ## -* `Class` - infraPortBlk -* `Distinguished Name` - uni/infra/accportprof-{leaf_interface_profile_name}/hports-{leaf_interface_profile_dn}-typ-{type}/portblk-{name} +* Class: [infraPortBlk](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraPortBlk/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Formats: + - `uni/infra/accportprof-{name}/hports-{name}-typ-{type}/portblk-{name}` + - `uni/infra/fexprof-{name}/hports-{name}-typ-{type}/portblk-{name}` + - `uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}/portblk-{name}` ## GUI Information ## -* `Location` - Fabric -> Access Policies -> Interfaces -> Profiles -> Create Leaf Interface Profile -> Interface Selectors -> Port Blocks +* Location: `Fabric -> Access Policies -> Interfaces -> Leaf/Spine Interfaces -> Profiles -> Interface Selectors -> Port Blocks` + +## Example Usage ## -## Example Usage +The configuration snippet below creates a Access Port Block with only required attributes. ```hcl -resource "aci_access_port_block" "test_port_block" { - access_port_selector_dn = aci_access_port_selector.fooaccess_port_selector.id - name = "tf_test_block" - description = "From Terraform" - annotation = "tag_port_block" - from_card = "1" - from_port = "1" - name_alias = "alias_port_block" - to_card = "3" - to_port = "3" - relation_infra_rs_acc_bndl_subgrp = aci_leaf_access_bundle_policy_sub_group.test_access_bundle_policy_sub_group.id + +resource "aci_access_port_block" "example_access_port_selector" { + parent_dn = aci_access_port_selector.example.id + name = "test_name" +} + +resource "aci_access_port_block" "example_spine_access_port_selector" { + parent_dn = aci_spine_access_port_selector.example.id + name = "test_name" } + ``` +The configuration snippet below shows all possible attributes of the Access Port Block. -## Argument Reference +!> This example might not be valid configuration and is only used to show all possible attributes. -- `access_port_selector_dn` - (Required) Distinguished name of the parent Access Port Selector or Spine Access Port Selector object. -- `name` - (Optional) Name of the Access Port Block object. -- `annotation` - (Optional) Annotation of the Access Port Block object. -- `description` - (Optional) Description of the Access Port Block object. -- `from_card` - (Optional) The beginning (from-range) of the card range block for the leaf access port block. Allowed value range is 1-100. Default value is "1". -- `from_port` - (Optional) The beginning (from-range) of the port range block for the leaf access port block. Allowed value range is 1-127. Default value is "1". -- `name_alias` - (Optional) Name alias of the Access Port Block object. -- `to_card` - (Optional) The end (to-range) of the card range block for the leaf access port block. Allowed value range is 1-100. Default value is "1". -- `to_port` - (Optional) The end (to-range) of the port range block for the leaf access port block. Allowed value range is 1-127. Default value is "1". +```hcl -- `relation_infra_rs_acc_bndl_subgrp` - (Optional) Relation to class infraAccBndlSubgrp. Cardinality - N_TO_ONE. Type - String. +resource "aci_access_port_block" "full_example_access_port_selector" { + parent_dn = aci_access_port_selector.example.id + annotation = "annotation" + description = "description_1" + from_card = "2" + from_port = "3" + name = "test_name" + name_alias = "name_alias_1" + to_card = "4" + to_port = "5" + relation_to_pc_vpc_override_policy = { + annotation = "annotation_1" + target_dn = aci_leaf_access_bundle_policy_sub_group.example.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} -## Attribute Reference +resource "aci_access_port_block" "full_example_spine_access_port_selector" { + parent_dn = aci_spine_access_port_selector.example.id + annotation = "annotation" + description = "description_1" + from_card = "2" + from_port = "3" + name = "test_name" + name_alias = "name_alias_1" + to_card = "4" + to_port = "5" + relation_to_pc_vpc_override_policy = { + annotation = "annotation_1" + target_dn = aci_leaf_access_bundle_policy_sub_group.example.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} -The only attribute that this resource exports is the `id`, which is set to the -Dn of the Access Port Block. +``` + +All examples for the Access Port Block resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_access_port_block) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_access_port_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_port_selector) ([infraHPortS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPortS/overview)) + - [aci_spine_access_port_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/spine_access_port_selector) ([infraSHPortS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSHPortS/overview)) +* `name` (name) - (string) The name of the Access Port Block object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Access Port Block object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Access Port Block object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` +* `description` (descr) - (string) The description of the Access Port Block object. This attribute is supported in ACI versions: 1.0(4g) and later. +* `from_card` (fromCard) - (string) The start of the line card range for the Access Port Block object. + - Default: `"1"` +* `from_port` (fromPort) - (string) The start of the port range for the Access Port Block object. + - Default: `"1"` +* `name_alias` (nameAlias) - (string) The name alias of the Access Port Block object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `to_card` (toCard) - (string) The end of the line card range for the Access Port Block object. + - Default: `"1"` +* `to_port` (toPort) - (string) The end of the port range for the Access Port Block object. + - Default: `"1"` +* `relation_to_pc_vpc_override_policy` - (map) A map of Relation To Pc Vpc Override Policy (ACI object [infraRsAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBndlSubgrp/overview)) pointing to PC VPC Override Policy (ACI Object [infraAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBndlSubgrp/overview)) which can be configured using the [aci_leaf_access_bundle_policy_sub_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/leaf_access_bundle_policy_sub_group) resource. + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation To Pc Vpc Override Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` + * `target_dn` (tDn) - (string) The distinguished name (DN) of the target PC VPC Override Policy. + * `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. +* `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 Access Port Block can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html +An existing Access Port Block 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_access_port_block.example +terraform import aci_access_port_block.example_access_port_selector uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}/portblk-{name} +``` + +Starting in Terraform version 1.5, an existing Access Port Block can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}/portblk-{name}" + to = aci_access_port_block.example_access_port_selector +} ``` diff --git a/docs/resources/access_port_selector.md b/docs/resources/access_port_selector.md index 08d9ff109..869b60fba 100644 --- a/docs/resources/access_port_selector.md +++ b/docs/resources/access_port_selector.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_access_port_selector" @@ -7,44 +10,206 @@ description: |- Manages ACI Access Port Selector --- -# aci_access_port_selector +# aci_access_port_selector # Manages ACI Access Port Selector -## Example Usage + + !> This resource has been migrated to the terraform plugin protocol version 6, refer to the [migration guide](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/guides/migration) for more details and implications for already managed resources. + +## API Information ## + +* Class: [infraHPortS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraHPortS/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Formats: + - `uni/infra/accportprof-{name}/hports-{name}-typ-{type}` + - `uni/infra/fexprof-{name}/hports-{name}-typ-{type}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Interface Selectors` + +## Example Usage ## + +The configuration snippet below creates a Access Port Selector with only required attributes. ```hcl -resource "aci_access_port_selector" "fooaccess_port_selector" { - leaf_interface_profile_dn = aci_leaf_interface_profile.example.id - description = "from terraform" - name = "demo_port_selector" - access_port_selector_type = "ALL" - annotation = "tag_port_selector" - name_alias = "alias_port_selector" + +resource "aci_access_port_selector" "example_leaf_interface_profile" { + parent_dn = aci_leaf_interface_profile.example.id + name = "test_name" + port_selector_type = "range" +} + +resource "aci_access_port_selector" "example_fex_profile" { + parent_dn = aci_fex_profile.example.id + name = "test_name" + port_selector_type = "range" } + ``` +The configuration snippet below shows all possible attributes of the Access Port Selector. -## Argument Reference +!> This example might not be valid configuration and is only used to show all possible attributes. -- `leaf_interface_profile_dn` - (Required) Distinguished name of parent Leaf Interface Profile object. -- `name` - (Required) Name of Object Access Port Selector. -- `access_port_selector_type` - (Required) The host port selector type. Allowed values are "ALL" and "range". Default is "ALL". -- `annotation` - (Optional) Annotation for object Access Port Selector. -- `description` - (Optional) Description for object Access Port Selector. -- `name_alias` - (Optional) Name alias for object Access Port Selector. +```hcl -- `relation_infra_rs_acc_base_grp` - (Optional) Relation to class infraAccBaseGrp. Cardinality - N_TO_ONE. Type - String. +resource "aci_access_port_selector" "full_example_leaf_interface_profile" { + parent_dn = aci_leaf_interface_profile.example.id + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + port_selector_type = "range" + relation_to_leaf_access_port_policy_group = { + annotation = "annotation_1" + fex_id = "102" + target_dn = aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} -## Attribute Reference +resource "aci_access_port_selector" "full_example_fex_profile" { + parent_dn = aci_fex_profile.example.id + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + port_selector_type = "range" + relation_to_leaf_access_port_policy_group = { + annotation = "annotation_1" + fex_id = "102" + target_dn = aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} -The only attribute that this resource exports is the `id`, which is set to the -Dn of the Access Port Selector. +``` + +All examples for the Access Port Selector resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_access_port_selector) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_leaf_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/leaf_interface_profile) ([infraAccPortP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccPortP/overview)) + - [aci_fex_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/fex_profile) ([infraFexP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraFexP/overview)) +* `name` (name) - (string) The name of the Access Port Selector object. +* `port_selector_type` (type) - (string) The port selector type of the Access Port Selector object. + - Valid Values: `"ALL"`, `"range"`. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Access Port Selector object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Access Port Selector object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` +* `description` (descr) - (string) The description of the Access Port Selector object. +* `name_alias` (nameAlias) - (string) The name alias of the Access Port Selector object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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. +* `relation_to_leaf_access_port_policy_group` - (map) A map of Relation To Leaf Access Port Policy Group (ACI object [infraRsAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBaseGrp/overview)) pointing to Access Interface Policy Group (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)) which can be configured using the [aci_access_interface_policy_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_interface_policy_group) resource. + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation To Leaf Access Port Policy Group object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` + * `fex_id` (fexId) - (string) The interface policy group FEX ID. + - Default: `"101"` + * `target_dn` (tDn) - (string) Select or create an interface policy group to associate to the Access Port selector. + * `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. +* `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 Access Port Selector can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html +An existing Access Port 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_access_port_selector.example +terraform import aci_access_port_selector.example_leaf_interface_profile uni/infra/fexprof-{name}/hports-{name}-typ-{type} +``` + +Starting in Terraform version 1.5, an existing Access Port Selector can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + ``` +import { + id = "uni/infra/fexprof-{name}/hports-{name}-typ-{type}" + to = aci_access_port_selector.example_leaf_interface_profile +} +``` + +## Child Resources + + - [aci_access_port_block](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_port_block) \ No newline at end of file diff --git a/docs/resources/fex_profile.md b/docs/resources/fex_profile.md index 70f18373c..bed97b700 100644 --- a/docs/resources/fex_profile.md +++ b/docs/resources/fex_profile.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_fex_profile" @@ -7,40 +10,118 @@ description: |- Manages ACI FEX Profile --- -# aci_fex_profile +# aci_fex_profile # Manages ACI FEX Profile -## Example Usage + + +## API Information ## + +* Class: [infraFexP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraFexP/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Format: `uni/infra/fexprof-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Fex Interfaces` + +## Example Usage ## + +The configuration snippet below creates a FEX Profile with only required attributes. ```hcl resource "aci_fex_profile" "example" { - name = "fex_prof" - annotation = "example" - name_alias = "example" - description = "from terraform" + name = "test_name" } ``` +The configuration snippet below shows all possible attributes of the FEX Profile. -## Argument Reference +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl -- `name` - (Required) The FEX profile name. -- `annotation` - (Optional) Specifies the annotation of the FEX profile name. -- `description` - (Optional) Specifies the description of the FEX profile name. -- `name_alias` - (Optional) Specifies the alias name of the FEX profile name. +resource "aci_fex_profile" "full_example" { + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` -## Attribute Reference +All examples for the FEX Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_fex_profile) folder. -The only attribute that this resource exports is the `id`, which is set to the -Dn of the FEX Profile. +## Schema ## + +### Required ### + +* `name` (name) - (string) The name of the FEX Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the FEX Profile 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 FEX Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` +* `description` (descr) - (string) The description of the FEX Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the FEX Profile object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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 FEX Profile can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html +An existing FEX 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_fex_profile.example +terraform import aci_fex_profile.example uni/infra/fexprof-{name} ``` + +Starting in Terraform version 1.5, an existing FEX Profile can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/infra/fexprof-{name}" + to = aci_fex_profile.example +} +``` + +## Child Resources + + - [aci_access_port_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_port_selector) \ No newline at end of file diff --git a/docs/resources/leaf_interface_profile.md b/docs/resources/leaf_interface_profile.md index f7fc22d4a..da76297b6 100644 --- a/docs/resources/leaf_interface_profile.md +++ b/docs/resources/leaf_interface_profile.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_leaf_interface_profile" @@ -8,37 +11,117 @@ description: |- --- # aci_leaf_interface_profile # + Manages ACI Leaf Interface Profile + + +## API Information ## + +* Class: [infraAccPortP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccPortP/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Format: `uni/infra/accportprof-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Interfaces` + ## Example Usage ## +The configuration snippet below creates a Leaf Interface Profile with only required attributes. + ```hcl -resource "aci_leaf_interface_profile" "fooleaf_interface_profile" { - description = "From Terraform" - name = "demo_leaf_profile" - annotation = "tag_leaf" - name_alias = "name_alias" + +resource "aci_leaf_interface_profile" "example" { + name = "test_name" } + ``` -## Argument Reference ## -* `name` - (Required) Name of Object leaf interface profile. -* `description` - (Optional) Description for object leaf interface profile. -* `annotation` - (Optional) Annotation for object leaf interface profile. -* `name_alias` - (Optional) Name alias for object leaf interface profile. +The configuration snippet below shows all possible attributes of the Leaf Interface Profile. +!> This example might not be valid configuration and is only used to show all possible attributes. +```hcl -## Attribute Reference +resource "aci_leaf_interface_profile" "full_example" { + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} -The only attribute that this resource exports is the `id`, which is set to the -Dn of the Leaf Interface Profile. +``` -## Importing ## +All examples for the Leaf Interface Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_leaf_interface_profile) folder. -An existing Leaf Interface Profile can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html +## Schema ## +### Required ### +* `name` (name) - (string) The name of the Leaf Interface Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Leaf Interface Profile 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 Leaf Interface Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` +* `description` (descr) - (string) The description of the Leaf Interface Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the Leaf Interface Profile object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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 Leaf Interface 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_leaf_interface_profile.example uni/infra/accportprof-{name} ``` -terraform import aci_leaf_interface_profile.example + +Starting in Terraform version 1.5, an existing Leaf Interface Profile can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + ``` +import { + id = "uni/infra/accportprof-{name}" + to = aci_leaf_interface_profile.example +} +``` + +## Child Resources + + - [aci_access_port_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_port_selector) \ No newline at end of file diff --git a/docs/resources/spine_access_port_selector.md b/docs/resources/spine_access_port_selector.md index 7ac70ecd1..881748b23 100644 --- a/docs/resources/spine_access_port_selector.md +++ b/docs/resources/spine_access_port_selector.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_spine_access_port_selector" @@ -11,47 +14,150 @@ description: |- Manages ACI Spine Access Port Selector + + !> This resource has been migrated to the terraform plugin protocol version 6, refer to the [migration guide](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/guides/migration) for more details and implications for already managed resources. + ## API Information ## -* `Class` - infraSHPortS -* `Distinguished Named` - uni/infra/spaccportprof-{name}/shports-{name}-typ-{type} +* Class: [infraSHPortS](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSHPortS/overview) -## GUI Information ## +* Supported in ACI versions: 2.0(1m) and later. + +* Distinguished Name Format: `uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}` -* `Location` - Fabric > Access Policies > Interfaces > Spine Interfaces > Profiles > {interface_profile}:{interface_selector} +## GUI Information ## +* Location: `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Profiles -> Interface Selectors` ## Example Usage ## +The configuration snippet below creates a Spine Access Port Selector with only required attributes. + ```hcl -resource "aci_spine_access_port_selector" "example" { - spine_interface_profile_dn = aci_spine_interface_profile.example.id - name = "example" - spine_access_port_selector_type = "ALL" - annotation = "orchestrator:terraform" - name_alias = "alias example" - - relation_infra_rs_sp_acc_grp = aci_resource.example.id + +resource "aci_spine_access_port_selector" "example_spine_interface_profile" { + parent_dn = aci_spine_interface_profile.example.id + name = "test_name" + port_selector_type = "ALL" } + ``` +The configuration snippet below shows all possible attributes of the Spine Access Port Selector. -## Argument Reference ## +!> This example might not be valid configuration and is only used to show all possible attributes. -* `spine_interface_profile_dn` - (Required) Distinguished name of the parent Spine Interface Profile. -* `name` - (Required) Name of the Spine Access Port Selector. -* `spine_access_port_selector_type` - (Required) The type of Spine Access Port Selector. Allowed values are "ALL" and "range". Default is "ALL". The "range" can be specified with the resource "aci_access_port_block". -* `annotation` - (Optional) Annotation of the Spine Access Port Selector. -* `name_alias` - (Optional) Name Alias of the Spine Access Port Selector. +```hcl -* `relation_infra_rs_sp_acc_grp` - (Optional) Represents the relation to a Spine Access Group (class infraSpAccGrp). Type: String. +resource "aci_spine_access_port_selector" "full_example_spine_interface_profile" { + parent_dn = aci_spine_interface_profile.example.id + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + port_selector_type = "ALL" + relation_to_spine_port_policy_group = { + annotation = "annotation_1" + target_dn = aci_spine_port_policy_group.test_spine_port_policy_group_0.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} +``` -## Importing ## +All examples for the Spine Access Port Selector resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_spine_access_port_selector) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_spine_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/spine_interface_profile) ([infraSpAccPortP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSpAccPortP/overview)) +* `name` (name) - (string) The name of the Spine Access Port Selector object. +* `port_selector_type` (type) - (string) The port selector type of the Spine Access Port Selector object. + - Valid Values: `"ALL"`, `"range"`. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the Spine Access Port Selector object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the Spine Access Port Selector object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` +* `description` (descr) - (string) The description of the Spine Access Port Selector object. +* `name_alias` (nameAlias) - (string) The name alias of the Spine Access Port Selector object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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. +* `relation_to_spine_port_policy_group` - (map) A map of Relation To Spine Port Policy Group (ACI object [infraRsSpAccGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsSpAccGrp/overview)) pointing to (ACI Object [infraSpAccGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSpAccGrp/overview)). + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the Relation To Spine Port Policy Group object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` + * `target_dn` (tDn) - (string) The distinguished name of the target. + * `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. +* `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 Spine Access Port Selector 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 Spine Access Port Selector can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html +``` +terraform import aci_spine_access_port_selector.example_spine_interface_profile uni/infra/spaccportprof-{name}/shports-{name}-typ-{type} +``` +Starting in Terraform version 1.5, an existing Spine Access Port Selector can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: ``` -terraform import aci_spine_access_port_selector.example +import { + id = "uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}" + to = aci_spine_access_port_selector.example_spine_interface_profile +} ``` + +## Child Resources + + - [aci_access_port_block](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/access_port_block) \ No newline at end of file diff --git a/docs/resources/spine_interface_profile.md b/docs/resources/spine_interface_profile.md index ced13b1ee..cb0e43c1e 100644 --- a/docs/resources/spine_interface_profile.md +++ b/docs/resources/spine_interface_profile.md @@ -1,4 +1,7 @@ --- +# 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: "Access Policies" layout: "aci" page_title: "ACI: aci_spine_interface_profile" @@ -8,41 +11,117 @@ description: |- --- # aci_spine_interface_profile # + Manages ACI Spine Interface Profile + + +## API Information ## + +* Class: [infraSpAccPortP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraSpAccPortP/overview) + +* Supported in ACI versions: 2.0(1m) and later. + +* Distinguished Name Format: `uni/infra/spaccportprof-{name}` + +## GUI Information ## + +* Location: `Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Profiles` + ## Example Usage ## +The configuration snippet below creates a Spine Interface Profile with only required attributes. + ```hcl resource "aci_spine_interface_profile" "example" { - name = "example" - description = "from terraform" - annotation = "example" - name_alias = "example" + name = "test_name" +} + +``` +The configuration snippet below shows all possible attributes of the Spine Interface Profile. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_spine_interface_profile" "full_example" { + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] } ``` +All examples for the Spine Interface Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_spine_interface_profile) folder. -## Argument Reference ## -* `name` - (Required) Name of Object Spine interface profile. -* `description` - (Optional) Description for Object Spine interface profile. -* `annotation` - (Optional) Annotation for Object Spine interface profile. -* `name_alias` - (Optional) Name alias for Object Spine interface profile. +## Schema ## +### Required ### +* `name` (name) - (string) The name of the Spine Interface Profile object. -## Attribute Reference +### Read-Only ### -The only attribute that this resource exports is the `id`, which is set to the -Dn of the Spine Interface Profile. +* `id` - (string) The distinguished name (DN) of the Spine Interface Profile object. -## Importing ## +### Optional ### -An existing Spine Interface Profile can be [imported][docs-import] into this resource via its Dn, via the following command: -[docs-import]: https://www.terraform.io/docs/import/index.html +* `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 Spine Interface Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. + - Default: `"orchestrator:terraform"` +* `description` (descr) - (string) The description of the Spine Interface Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the Spine Interface Profile object. This attribute is supported in ACI versions: 2.2(1k) and later. +* `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 Spine Interface 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_spine_interface_profile.example uni/infra/spaccportprof-{name} ``` -terraform import aci_spine_interface_profile.example -``` \ No newline at end of file + +Starting in Terraform version 1.5, an existing Spine Interface Profile can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/infra/spaccportprof-{name}" + to = aci_spine_interface_profile.example +} +``` + +## Child Resources + + - [aci_spine_access_port_selector](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/spine_access_port_selector) \ No newline at end of file diff --git a/examples/data-sources/aci_access_port_block/data-source.tf b/examples/data-sources/aci_access_port_block/data-source.tf new file mode 100644 index 000000000..3bf58e03a --- /dev/null +++ b/examples/data-sources/aci_access_port_block/data-source.tf @@ -0,0 +1,10 @@ + +data "aci_access_port_block" "example_access_port_selector" { + parent_dn = aci_access_port_selector.example.id + name = "test_name" +} + +data "aci_access_port_block" "example_spine_access_port_selector" { + parent_dn = aci_spine_access_port_selector.example.id + name = "test_name" +} diff --git a/examples/data-sources/aci_access_port_block/provider.tf b/examples/data-sources/aci_access_port_block/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_access_port_block/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_access_port_selector/data-source.tf b/examples/data-sources/aci_access_port_selector/data-source.tf new file mode 100644 index 000000000..846c68885 --- /dev/null +++ b/examples/data-sources/aci_access_port_selector/data-source.tf @@ -0,0 +1,12 @@ + +data "aci_access_port_selector" "example_leaf_interface_profile" { + parent_dn = aci_leaf_interface_profile.example.id + name = "test_name" + port_selector_type = "range" +} + +data "aci_access_port_selector" "example_fex_profile" { + parent_dn = aci_fex_profile.example.id + name = "test_name" + port_selector_type = "range" +} diff --git a/examples/data-sources/aci_access_port_selector/provider.tf b/examples/data-sources/aci_access_port_selector/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_access_port_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/data-sources/aci_fex_profile/data-source.tf b/examples/data-sources/aci_fex_profile/data-source.tf new file mode 100644 index 000000000..03c79969d --- /dev/null +++ b/examples/data-sources/aci_fex_profile/data-source.tf @@ -0,0 +1,4 @@ + +data "aci_fex_profile" "example" { + name = "test_name" +} diff --git a/examples/data-sources/aci_fex_profile/provider.tf b/examples/data-sources/aci_fex_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_fex_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/data-sources/aci_leaf_interface_profile/data-source.tf b/examples/data-sources/aci_leaf_interface_profile/data-source.tf new file mode 100644 index 000000000..bb117ffc9 --- /dev/null +++ b/examples/data-sources/aci_leaf_interface_profile/data-source.tf @@ -0,0 +1,4 @@ + +data "aci_leaf_interface_profile" "example" { + name = "test_name" +} diff --git a/examples/data-sources/aci_leaf_interface_profile/provider.tf b/examples/data-sources/aci_leaf_interface_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_leaf_interface_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/data-sources/aci_spine_access_port_selector/data-source.tf b/examples/data-sources/aci_spine_access_port_selector/data-source.tf new file mode 100644 index 000000000..0d98204ab --- /dev/null +++ b/examples/data-sources/aci_spine_access_port_selector/data-source.tf @@ -0,0 +1,6 @@ + +data "aci_spine_access_port_selector" "example_spine_interface_profile" { + parent_dn = aci_spine_interface_profile.example.id + name = "test_name" + port_selector_type = "ALL" +} diff --git a/examples/data-sources/aci_spine_access_port_selector/provider.tf b/examples/data-sources/aci_spine_access_port_selector/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_spine_access_port_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/data-sources/aci_spine_interface_profile/data-source.tf b/examples/data-sources/aci_spine_interface_profile/data-source.tf new file mode 100644 index 000000000..3b9c7c2c6 --- /dev/null +++ b/examples/data-sources/aci_spine_interface_profile/data-source.tf @@ -0,0 +1,4 @@ + +data "aci_spine_interface_profile" "example" { + name = "test_name" +} diff --git a/examples/data-sources/aci_spine_interface_profile/provider.tf b/examples/data-sources/aci_spine_interface_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_spine_interface_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_access_port_block/provider.tf b/examples/resources/aci_access_port_block/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_access_port_block/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_access_port_block/resource-all-attributes.tf b/examples/resources/aci_access_port_block/resource-all-attributes.tf new file mode 100644 index 000000000..4f00412df --- /dev/null +++ b/examples/resources/aci_access_port_block/resource-all-attributes.tf @@ -0,0 +1,80 @@ + +resource "aci_access_port_block" "full_example_access_port_selector" { + parent_dn = aci_access_port_selector.example.id + annotation = "annotation" + description = "description_1" + from_card = "2" + from_port = "3" + name = "test_name" + name_alias = "name_alias_1" + to_card = "4" + to_port = "5" + relation_to_pc_vpc_override_policy = { + annotation = "annotation_1" + target_dn = aci_leaf_access_bundle_policy_sub_group.example.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +resource "aci_access_port_block" "full_example_spine_access_port_selector" { + parent_dn = aci_spine_access_port_selector.example.id + annotation = "annotation" + description = "description_1" + from_card = "2" + from_port = "3" + name = "test_name" + name_alias = "name_alias_1" + to_card = "4" + to_port = "5" + relation_to_pc_vpc_override_policy = { + annotation = "annotation_1" + target_dn = aci_leaf_access_bundle_policy_sub_group.example.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_access_port_block/resource.tf b/examples/resources/aci_access_port_block/resource.tf new file mode 100644 index 000000000..9c70ddb71 --- /dev/null +++ b/examples/resources/aci_access_port_block/resource.tf @@ -0,0 +1,10 @@ + +resource "aci_access_port_block" "example_access_port_selector" { + parent_dn = aci_access_port_selector.example.id + name = "test_name" +} + +resource "aci_access_port_block" "example_spine_access_port_selector" { + parent_dn = aci_spine_access_port_selector.example.id + name = "test_name" +} diff --git a/examples/resources/aci_access_port_selector/provider.tf b/examples/resources/aci_access_port_selector/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_access_port_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_access_port_selector/resource-all-attributes.tf b/examples/resources/aci_access_port_selector/resource-all-attributes.tf new file mode 100644 index 000000000..49b3c4008 --- /dev/null +++ b/examples/resources/aci_access_port_selector/resource-all-attributes.tf @@ -0,0 +1,80 @@ + +resource "aci_access_port_selector" "full_example_leaf_interface_profile" { + parent_dn = aci_leaf_interface_profile.example.id + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + port_selector_type = "range" + relation_to_leaf_access_port_policy_group = { + annotation = "annotation_1" + fex_id = "102" + target_dn = aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +resource "aci_access_port_selector" "full_example_fex_profile" { + parent_dn = aci_fex_profile.example.id + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + port_selector_type = "range" + relation_to_leaf_access_port_policy_group = { + annotation = "annotation_1" + fex_id = "102" + target_dn = aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_access_port_selector/resource.tf b/examples/resources/aci_access_port_selector/resource.tf new file mode 100644 index 000000000..7cf04d6e3 --- /dev/null +++ b/examples/resources/aci_access_port_selector/resource.tf @@ -0,0 +1,12 @@ + +resource "aci_access_port_selector" "example_leaf_interface_profile" { + parent_dn = aci_leaf_interface_profile.example.id + name = "test_name" + port_selector_type = "range" +} + +resource "aci_access_port_selector" "example_fex_profile" { + parent_dn = aci_fex_profile.example.id + name = "test_name" + port_selector_type = "range" +} diff --git a/examples/resources/aci_fex_profile/provider.tf b/examples/resources/aci_fex_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_fex_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_fex_profile/resource-all-attributes.tf b/examples/resources/aci_fex_profile/resource-all-attributes.tf new file mode 100644 index 000000000..d53e28e84 --- /dev/null +++ b/examples/resources/aci_fex_profile/resource-all-attributes.tf @@ -0,0 +1,21 @@ + +resource "aci_fex_profile" "full_example" { + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_fex_profile/resource.tf b/examples/resources/aci_fex_profile/resource.tf new file mode 100644 index 000000000..15555f252 --- /dev/null +++ b/examples/resources/aci_fex_profile/resource.tf @@ -0,0 +1,4 @@ + +resource "aci_fex_profile" "example" { + name = "test_name" +} diff --git a/examples/resources/aci_leaf_interface_profile/provider.tf b/examples/resources/aci_leaf_interface_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_leaf_interface_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_leaf_interface_profile/resource-all-attributes.tf b/examples/resources/aci_leaf_interface_profile/resource-all-attributes.tf new file mode 100644 index 000000000..a9ed2f177 --- /dev/null +++ b/examples/resources/aci_leaf_interface_profile/resource-all-attributes.tf @@ -0,0 +1,21 @@ + +resource "aci_leaf_interface_profile" "full_example" { + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_leaf_interface_profile/resource.tf b/examples/resources/aci_leaf_interface_profile/resource.tf new file mode 100644 index 000000000..c811707db --- /dev/null +++ b/examples/resources/aci_leaf_interface_profile/resource.tf @@ -0,0 +1,4 @@ + +resource "aci_leaf_interface_profile" "example" { + name = "test_name" +} diff --git a/examples/resources/aci_spine_access_port_selector/provider.tf b/examples/resources/aci_spine_access_port_selector/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_spine_access_port_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_spine_access_port_selector/resource-all-attributes.tf b/examples/resources/aci_spine_access_port_selector/resource-all-attributes.tf new file mode 100644 index 000000000..c9b8ca968 --- /dev/null +++ b/examples/resources/aci_spine_access_port_selector/resource-all-attributes.tf @@ -0,0 +1,39 @@ + +resource "aci_spine_access_port_selector" "full_example_spine_interface_profile" { + parent_dn = aci_spine_interface_profile.example.id + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + port_selector_type = "ALL" + relation_to_spine_port_policy_group = { + annotation = "annotation_1" + target_dn = aci_spine_port_policy_group.test_spine_port_policy_group_0.id + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] + } + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_spine_access_port_selector/resource.tf b/examples/resources/aci_spine_access_port_selector/resource.tf new file mode 100644 index 000000000..7d63f0585 --- /dev/null +++ b/examples/resources/aci_spine_access_port_selector/resource.tf @@ -0,0 +1,6 @@ + +resource "aci_spine_access_port_selector" "example_spine_interface_profile" { + parent_dn = aci_spine_interface_profile.example.id + name = "test_name" + port_selector_type = "ALL" +} diff --git a/examples/resources/aci_spine_interface_profile/provider.tf b/examples/resources/aci_spine_interface_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_spine_interface_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_spine_interface_profile/resource-all-attributes.tf b/examples/resources/aci_spine_interface_profile/resource-all-attributes.tf new file mode 100644 index 000000000..4f36327ae --- /dev/null +++ b/examples/resources/aci_spine_interface_profile/resource-all-attributes.tf @@ -0,0 +1,21 @@ + +resource "aci_spine_interface_profile" "full_example" { + annotation = "annotation" + description = "description_1" + name = "test_name" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_spine_interface_profile/resource.tf b/examples/resources/aci_spine_interface_profile/resource.tf new file mode 100644 index 000000000..be4c179c9 --- /dev/null +++ b/examples/resources/aci_spine_interface_profile/resource.tf @@ -0,0 +1,4 @@ + +resource "aci_spine_interface_profile" "example" { + name = "test_name" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index df05dbfac..da35619d8 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -1137,3 +1137,81 @@ vnsLDevIf: sub_category: "L4-L7" ui_locations: - "Tenants -> Services -> L4-L7 -> Imported Devices" + +infraAccPortP: + resource_name: "leaf_interface_profile" + sub_category: "Access Policies" + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Interfaces" + migration_version: 1 + +infraSpAccPortP: + resource_name: "spine_interface_profile" + sub_category: "Access Policies" + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Profiles" + migration_version: 1 + +infraFexP: + resource_name: "fex_profile" + sub_category: "Access Policies" + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Fex Interfaces" + migration_version: 1 + +infraHPortS: + resource_name: "access_port_selector" + sub_category: "Access Policies" + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Interface Selectors" + migration_version: 1 + migration_blocks: + infraHPortS: + leaf_interface_profile_dn: parent_dn + access_port_selector_type: port_selector_type + infraRsAccBaseGrp: + relation_infra_rs_acc_base_grp: relation_to_leaf_access_port_policy_group.target_dn + +infraRsAccBaseGrp: + resource_name: "relation_to_leaf_access_port_policy_group" + +infraAccPortGrp: + resource_name: "leaf_access_port_policy_group" + +infraSHPortS: + resource_name: "spine_access_port_selector" + sub_category: "Access Policies" + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Profiles -> Interface Selectors" + migration_version: 1 + migration_blocks: + infraSHPortS: + spine_interface_profile_dn: parent_dn + spine_access_port_selector_type: port_selector_type + infraRsSpAccGrp: + relation_infra_rs_sp_acc_grp: relation_to_spine_port_policy_group.target_dn + +infraRsSpAccGrp: + resource_name: "relation_to_spine_port_policy_group" + +infraSpAccPortGrp: + resource_name: "spine_port_policy_group" + +infraPortBlk: + sub_category: "Access Policies" + ui_locations: + - "Fabric -> Access Policies -> Interfaces -> Leaf/Spine Interfaces -> Profiles -> Interface Selectors -> Port Blocks" + resource_notes: + - "Port Blocks are only applied and visible in UI when the `port_selector_type` attribute on it's parent is set to `range`." + migration_version: 1 + migration_blocks: + infraPortBlk: + access_port_selector_dn: parent_dn + infraRsAccBndlSubgrp: + relation_infra_rs_acc_bndl_subgrp: relation_to_pc_vpc_override_policy.target_dn + +infraRsAccBndlSubgrp: + resource_name: "relation_to_pc_vpc_override_policy" + +infraAccBndlSubgrp: + resource_name: "leaf_access_bundle_policy_sub_group" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 42a3e2059..93751eb85 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -87,6 +87,8 @@ global: Lacp Enhanced Lag Policy: "LACP Enhanced Lag Policy" Vmm: "VMM" Policys: "Policies" + Leaf Access Bundle Policy Sub Group: "PC VPC Override Policy" + Fex: "FEX" ignores: - "userdom" @@ -2743,3 +2745,109 @@ vnsLDevIf: datasource_required: logical_device: "uni/tn-test_tenant_imported_device/lDevVip-test_imported_device" custom_test_dependency_name: "ImportedVnsLDevVipWithFvTenant" + +infraAccPortP: + default_values: + parent_dn: "uni/infra" + +infraSpAccPortP: + default_values: + parent_dn: "uni/infra" + +infraFexP: + default_values: + parent_dn: "uni/infra" + +infraHPortS: + overwrites: + type: port_selector_type + documentation: + type: "The port selector type of the %s object." + test_values: + resource_required: + port_selector_type: "range" + datasource_required: + port_selector_type: "range" + datasource_non_existing: + port_selector_type: "range" + legacy: + port_selector_type: "range" + ignore_in_legacy: + - "port_selector_type" + +infraRsAccBaseGrp: + test_values: + all: + fex_id: "102" + targets: + - class_name: "infraAccPortGrp" + target_dn: "uni/infra/funcprof/accportgrp-leaf_access_port_policy_group_1" + relation_resource_name: "leaf_access_port_policy_group" + properties: + name: "leaf_access_port_policy_group_1" + +infraSHPortS: + overwrites: + type: port_selector_type + documentation: + type: "The port selector type of the %s object." + test_values: + resource_required: + port_selector_type: "ALL" + datasource_required: + port_selector_type: "ALL" + datasource_non_existing: + port_selector_type: "ALL" + legacy: + port_selector_type: "ALL" + ignore_in_legacy: + - "port_selector_type" + +infraRsSpAccGrp: + test_values: + all: + target_dn: "uni/infra/funcprof/spaccportgrp-spine_port_policy_group_1" + targets: + - class_name: "infraSpAccPortGrp" + target_dn: "uni/infra/funcprof/spaccportgrp-spine_port_policy_group_1" + relation_resource_name: "spine_port_policy_group" + properties: + name: "spine_port_policy_group_1" + +infraPortBlk: + documentation: + fromCard: "The start of the line card range for the %s object." + fromPort: "The start of the port range for the %s object." + toCard: " The end of the line card range for the %s object." + toPort: "The end of the port range for the %s object." + parents: + - class_name: "infraHPortS" + parent_dependency: "infraAccPortP" + parent_dn: "aci_access_port_selector.test.id" + - class_name: "infraZHPortS" + parent_dependency: "infraSpAccPortP" + parent_dn: "aaci_spine_access_port_selector.test.id" + test_values: + default: + from_card: "1" + from_port: "1" + to_card: "1" + to_port: "1" + all: + from_card: "2" + from_port: "3" + to_card: "4" + to_port: "5" + +infraRsAccBndlSubgrp: + documentation: + tDn: "The distinguished name (DN) of the target PC VPC Override Policy." + example_value_overwrite: + target_dn: "aci_leaf_access_bundle_policy_sub_group.example.id" + test_values: + all: + # Set to empty string to avoid validation error on APIC during tests, due to complicated test dependency structure + # Empty string still tests if the object is created and if the tDn value matches the input of "" + # Response Status Code: 400, Error Code: 182, Error Message: Validation failed PortBlk has a reln to AccBndlSubgrp not contained by AccBndlGrp its parent is associated to. + target_dn: "" + diff --git a/gen/generator.go b/gen/generator.go index 29f7fe7f6..57a5e5497 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -104,6 +104,7 @@ var templateFuncs = template.FuncMap{ "isInterfaceSlice": IsInterfaceSlice, "replace": Replace, "lookupTestValue": LookupTestValue, + "getTestValueOverwrite": GetTestValueOverwrite, "lookupChildTestValue": LookupChildTestValue, "createParentDnValue": CreateParentDnValue, "getResourceName": GetResourceName, @@ -152,6 +153,7 @@ var templateFuncs = template.FuncMap{ "getDeprecatedExplanation": GetDeprecatedExplanation, "getIgnoredExplanation": GetIgnoredExplanation, "getCustomTestDependency": GetCustomTestDependency, + "getIgnoreInLegacy": GetIgnoreInLegacy, } func GetDeprecatedExplanation(attributeName, replacedByAttributeName string) string { @@ -231,7 +233,7 @@ func GetTestValue(name string, model Model) string { childValue := GetOverwriteAttributeValue(child.PkgName, childKey, fmt.Sprintf("%s_1", childKey), "default", 0, model.Definitions).(string) properties = append(properties, getChildTarget(model, childKey, childValue, false)) } else if property.PropertyName == "tDn" { - return getChildTarget(model, child.PkgName, "target_dn_0", true) + return getChildTarget(model, child.PkgName, "", true) } } // If there are multiple properties that has suffix of Name, return the one that matches the child resource name @@ -764,6 +766,21 @@ func LookupTestValue(classPkgName, originalPropertyName string, testVars map[str return lookupValue } +func GetTestValueOverwrite(classPkgName, propertyName, propertyValue string, definitions Definitions) string { + if classDetails, ok := definitions.Properties[classPkgName]; ok { + for key, value := range classDetails.(map[interface{}]interface{}) { + if key.(string) == "example_value_overwrite" { + for k, v := range value.(map[interface{}]interface{}) { + if k.(string) == propertyName { + return v.(string) + } + } + } + } + } + return propertyValue +} + // 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{} { @@ -2706,6 +2723,24 @@ func GetOverwriteAttributeValue(classPkgName, propertyName, propertyValue, testT return propertyValue } +func GetIgnoreInLegacy(classPkgName string, definitions Definitions) []string { + result := []string{} + if classDetails, ok := definitions.Properties[classPkgName]; ok { + for key, value := range classDetails.(map[interface{}]interface{}) { + if key.(string) == "test_values" { + for test_type, test_type_values := range value.(map[interface{}]interface{}) { + if test_type.(string) == "ignore_in_legacy" { + for _, test_type_value := range test_type_values.([]interface{}) { + result = append(result, test_type_value.(string)) + } + } + } + } + } + } + return result +} + // Determine if possible parent classes in terraform configuration should be overwritten by contained_by from the classes.yaml file func GetOverwriteContainedBy(classDetails interface{}, classPkgName string, definitions Definitions) map[string]interface{} { containedBy := make(map[string]interface{}) diff --git a/gen/meta/infraAccPortP.json b/gen/meta/infraAccPortP.json new file mode 100644 index 000000000..3fdd5f1ab --- /dev/null +++ b/gen/meta/infraAccPortP.json @@ -0,0 +1,826 @@ +{ + "infra:AccPortP": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "infra:HPortS": "", + "infra:RtAccPortP": "", + "infra:RtInterfacePolProfile": "", + "infra:RtToInterfacePolProfile": "", + "infra:RtToInterfacePolProfileOpt": "", + "tag:AliasDelInst": "", + "tag:AliasInst": "", + "tag:Annotation": "", + "tag:ExtMngdInst": "", + "tag:Inst": "", + "tag:Tag": "" + }, + "rnMap": { + "alias": "tag:AliasInst", + "aliasdel-": "tag:AliasDelInst", + "annotationKey-": "tag:Annotation", + "extmngd": "tag:ExtMngdInst", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "hports-": "infra:HPortS", + "rbacDom-": "aaa:RbacAnnotation", + "rtaccPortP-": "infra:RtAccPortP", + "rtinterfacePolProfile-": "infra:RtInterfacePolProfile", + "rttoInterfacePolProfile-": "infra:RtToInterfacePolProfile", + "rttoInterfacePolProfileOpt-": "infra:RtToInterfacePolProfileOpt", + "tag-": "tag:Inst", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "accportprof-{name}", + "containedBy": { + "infra:Infra": "" + }, + "superClasses": [ + "infra:PortP", + "infra:Profile", + "fabric:AProfile", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "infra:RtAccPortP": "infra:NodeP", + "infra:RtInterfacePolProfile": "infra:NodeCfg", + "infra:RtToInterfacePolProfile": "infra:NodeCfg", + "infra:RtToInterfacePolProfileOpt": "infra:NodeCfg" + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/infra/accportprof-{name}" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "custom-port-privilege", + "ops" + ], + "faults": { + + }, + "events": { + "E4212197": "creation||infra:AccPortP", + "E4212198": "modification||infra:AccPortP", + "E4212199": "deletion||infra:AccPortP" + }, + "stats": { + + }, + "versions": "1.0(1e)-", + "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": "4367", + "className": "AccPortP", + "classPkg": "infra", + "featureTag": "", + "moCategory": "Regular", + "label": "Leaf Interface Profile", + "comment": [ + "The interface profile enables you to specify the interface you want to configure." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37888", + "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(4d)-", + "isConfigurable": false, + "propGlobalId": "65830", + "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": "User Created "}, + { "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": "40027", + "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.0(1e)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "14707", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "The interface profile name. This name can be up to 64 alphanumeric characters. Note that you cannot change this name after the object has been saved." + ], + "isConfigurable": true, + "propGlobalId": "6615", + "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": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nodeId": { + "versions": "5.2(4d)-", + "comment": [ + "The ID of the APIC, leaf, or spine." + ], + "isConfigurable": false, + "propGlobalId": "65831", + "propLocalId": "88", + "label": "Node Id", + "baseType": "scalar:Uint16", + "modelType": "fabric:PCNodeId", + "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 + }, + "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/meta/infraFexP.json b/gen/meta/infraFexP.json new file mode 100644 index 000000000..723175fef --- /dev/null +++ b/gen/meta/infraFexP.json @@ -0,0 +1,848 @@ +{ + "infra:FexP": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "infra:FexBndlGrp": "", + "infra:HPortS": "", + "infra:RtFexp": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "fexbundle-": "infra:FexBndlGrp", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "hports-": "infra:HPortS", + "rbacDom-": "aaa:RbacAnnotation", + "rtfexp-": "infra:RtFexp", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "fexprof-{name}", + "containedBy": { + "infra:Infra": "" + }, + "superClasses": [ + "infra:Profile", + "fabric:AProfile", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "infra:RtFexp": "infra:NodeCfg" + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/infra/fexprof-{name}" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "custom-port-privilege" + ], + "faults": { + + }, + "events": { + "E4212227": "creation||infra:FexP", + "E4212228": "modification||infra:FexP", + "E4212229": "deletion||infra:FexP" + }, + "stats": { + + }, + "versions": "1.0(1e)-", + "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": "4369", + "className": "FexP", + "classPkg": "infra", + "featureTag": "", + "moCategory": "Regular", + "label": "FEX Profile", + "comment": [ + "The FEX profile enables you to configure FEX interfaces." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37890", + "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(4d)-", + "isConfigurable": false, + "propGlobalId": "65830", + "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": "User Created "}, + { "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": "40029", + "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 + }, + "fexId": { + "versions": "5.2(4d)-", + "isConfigurable": false, + "propGlobalId": "65833", + "propLocalId": "4015", + "label": "Node Id", + "baseType": "scalar:UByte", + "modelType": "infra:PCFexId", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "0", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "Unspecified "} + ], + "default": "unspecified", + "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.0(1e)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "14709", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "The fex profile name" + ], + "isConfigurable": true, + "propGlobalId": "6639", + "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": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nodeId": { + "versions": "5.2(4d)-", + "comment": [ + "The ID of the APIC, leaf, or spine." + ], + "isConfigurable": false, + "propGlobalId": "65832", + "propLocalId": "88", + "label": "Node Id", + "baseType": "scalar:Uint16", + "modelType": "fabric:PCNodeId", + "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 + }, + "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/meta/infraHPortS.json b/gen/meta/infraHPortS.json new file mode 100644 index 000000000..1065be803 --- /dev/null +++ b/gen/meta/infraHPortS.json @@ -0,0 +1,826 @@ +{ + "infra:HPortS": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "infra:PortBlk": "", + "infra:RsAccBaseGrp": "", + "infra:SelectorIssues": "", + "infra:SubPortBlk": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "portblk-": "infra:PortBlk", + "rbacDom-": "aaa:RbacAnnotation", + "rsaccBaseGrp": "infra:RsAccBaseGrp", + "selectorissues": "infra:SelectorIssues", + "subportblk-": "infra:SubPortBlk", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name", + "type" + ], + "rnFormat": "hports-{name}-typ-{type}", + "containedBy": { + "infra:AccPortP": "", + "infra:FexP": "" + }, + "superClasses": [ + "infra:PortS", + "fabric:APortS", + "fabric:Selector", + "fabric:Def", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + + }, + "relationTo": { + "infra:RsAccBaseGrp": "infra:AccBaseGrp" + }, + "dnFormats": [ + "uni/infra/fexprof-{name}/hports-{name}-typ-{type}", + "uni/infra/accportprof-{name}/hports-{name}-typ-{type}" + ], + "writeAccess": [ + "access-equipment", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-equipment", + "admin", + "custom-port-privilege" + ], + "faults": { + + }, + "events": { + "E4214252": "creation||infra:HPortS", + "E4214253": "modification||infra:HPortS", + "E4214254": "deletion||infra:HPortS" + }, + "stats": { + + }, + "versions": "1.0(1e)-", + "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": "4314", + "className": "HPortS", + "classPkg": "infra", + "featureTag": "", + "moCategory": "Regular", + "label": "Access Port Selector", + "comment": [ + "The Host Port Selector is used for grouping ports between the node and the host (such as hypervisor)." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37876", + "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(4d)-", + "isConfigurable": false, + "propGlobalId": "65835", + "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": "User Created "}, + { "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": "40015", + "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.0(1e)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "14688", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "The host port selector name. This name can be up to 64 alphanumeric characters. Note that you cannot change this name after the object has been saved." + ], + "isConfigurable": true, + "propGlobalId": "6643", + "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 + }, + "type": { + "versions": "1.0(1e)-", + "comment": [ + "The host port selector type." + ], + "isConfigurable": true, + "propGlobalId": "6644", + "propLocalId": "33", + "label": "Selector Type", + "baseType": "scalar:Enum8", + "modelType": "fabric:Selector", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validValues": [ + { "value": "0", "localName": "ALL", + "platformFlavors": [ + + ], + "label": "ALL "}, + { "value": "1", "localName": "range", + "platformFlavors": [ + + ], + "label": "range "} + ], + "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/infraPortBlk.json b/gen/meta/infraPortBlk.json new file mode 100644 index 000000000..226cca0f3 --- /dev/null +++ b/gen/meta/infraPortBlk.json @@ -0,0 +1,819 @@ +{ + "infra:PortBlk": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "infra:RsAccBndlSubgrp": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "rsaccBndlSubgrp": "infra:RsAccBndlSubgrp", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "portblk-{name}", + "containedBy": { + "infra:HPortS": "", + "infra:SHPortS": "" + }, + "superClasses": [ + "fabric:APortBlk", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + + }, + "relationTo": { + "infra:RsAccBndlSubgrp": "infra:AccBndlSubgrp" + }, + "dnFormats": [ + "uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}/portblk-{name}", + "uni/infra/fexprof-{name}/hports-{name}-typ-{type}/portblk-{name}", + "uni/infra/accportprof-{name}/hports-{name}-typ-{type}/portblk-{name}" + ], + "writeAccess": [ + "access-equipment", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-equipment", + "admin", + "custom-port-privilege" + ], + "faults": { + + }, + "events": { + "E4214267": "creation||infra:PortBlk", + "E4214268": "modification||infra:PortBlk", + "E4214269": "deletion||infra:PortBlk" + }, + "stats": { + + }, + "versions": "1.0(1e)-", + "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": "4317", + "className": "PortBlk", + "classPkg": "infra", + "featureTag": "", + "moCategory": "Regular", + "label": "Access Port Block", + "comment": [ + "The port block enables you to specify a range of interfaces." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37878", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(4g)-", + "comment": [ + "The description of this configuration item." + ], + "isConfigurable": true, + "propGlobalId": "18092", + "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": "40017", + "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 + }, + "fromCard": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "875", + "propLocalId": "464", + "label": "From Module Id", + "baseType": "scalar:UByte", + "modelType": "fabric:CardId", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 1, "max": 100 } + ], + "validValues": [ + { "value": "1", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 1, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "fromPort": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "876", + "propLocalId": "465", + "label": "From Port Id", + "baseType": "scalar:UByte", + "modelType": "fabric:PortId", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 1, "max": 127 } + ], + "validValues": [ + { "value": "1", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 1, + "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.0(1e)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "14690", + "propLocalId": "228", + "label": "Monitoring Policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "The port block name" + ], + "isConfigurable": true, + "propGlobalId": "6660", + "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": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "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 + }, + "toCard": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "877", + "propLocalId": "466", + "label": "To Module Id", + "baseType": "scalar:UByte", + "modelType": "fabric:CardId", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 1, "max": 100 } + ], + "validValues": [ + { "value": "1", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 1, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "toPort": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "878", + "propLocalId": "467", + "label": "To Port Id", + "baseType": "scalar:UByte", + "modelType": "fabric:PortId", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 1, "max": 127 } + ], + "validValues": [ + { "value": "1", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 1, + "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/infraRsAccBaseGrp.json b/gen/meta/infraRsAccBaseGrp.json new file mode 100644 index 000000000..b5f29e270 --- /dev/null +++ b/gen/meta/infraRsAccBaseGrp.json @@ -0,0 +1,1007 @@ +{ + "infra:RsAccBaseGrp": { + "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": [ + + ], + "rnFormat": "rsaccBaseGrp", + "containedBy": { + "infra:HPortS": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "n-to-1", + "fromMo": "infra:HPortS", + "fromRelMo": "infra:RsAccBaseGrp", + "toMo": "infra:AccBaseGrp", + "toRelMo": "infra:RtAccBaseGrp", + "enforceable": true, + "resolvable": true + }, + "dnFormats": [ + "uni/infra/fexprof-{name}/hports-{name}-typ-{type}/rsaccBaseGrp", + "uni/infra/accportprof-{name}/hports-{name}-typ-{type}/rsaccBaseGrp" + ], + "writeAccess": [ + "access-equipment", + "admin", + "custom-port-privilege" + ], + "readAccess": [ + "access-equipment", + "admin", + "custom-port-privilege" + ], + "faults": { + "F1011": "fltInfraRsAccBaseGrpResolveFail" + }, + "events": { + "E4214270": "creation||infra:RsAccBaseGrp", + "E4214271": "modification||infra:RsAccBaseGrp", + "E4214272": "deletion||infra:RsAccBaseGrp" + }, + "stats": { + + }, + "versions": "1.0(1e)-", + "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": [ + "apic" + ], + "classId": "4315", + "className": "RsAccBaseGrp", + "classPkg": "infra", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "Access Access Group", + "comment": [ + "A source relation to the access policy group providing port configuration." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37877", + "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": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40016", + "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 + }, + "fexId": { + "versions": "1.0(1e)-", + "comment": [ + "The interface policy group FEX ID." + ], + "isConfigurable": true, + "propGlobalId": "13122", + "propLocalId": "4015", + "label": "fexId", + "baseType": "scalar:UByte", + "modelType": "infra:FexId", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 101, "max": 199 } + ], + "validValues": [ + { "value": "101", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": 101, + "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": "1.0(1e)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "14689", + "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": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": false, + "propGlobalId": "13121", + "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": "4384", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4384", "localName": "infraAccBaseGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4406", "localName": "infraAccBndlGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "6102", "localName": "infraAccBndlPolGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4416", "localName": "infraAccBndlSubgrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4409", "localName": "infraAccPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "9141", "localName": "infraBrkoutPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "11873", "localName": "infraFcAccBndlGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "11874", "localName": "infraFcAccBndlPolGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "11872", "localName": "infraFcAccPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4386", "localName": "infraFexBndlGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "8243", "localName": "infraSpAccPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "} + ], + "default": "infraAccBaseGrp", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "1.0(1e)-", + "comment": [ + "Select or create an interface policy group to associate to the Access Port selector." + ], + "isConfigurable": true, + "propGlobalId": "13120", + "propLocalId": "77", + "label": "Target-dn", + "baseType": "reference:BinRef", + "modelType": "reln:Dn", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "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/infraRsAccBndlSubgrp.json b/gen/meta/infraRsAccBndlSubgrp.json new file mode 100644 index 000000000..0fb783919 --- /dev/null +++ b/gen/meta/infraRsAccBndlSubgrp.json @@ -0,0 +1,916 @@ +{ + "infra:RsAccBndlSubgrp": { + "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": [ + + ], + "rnFormat": "rsaccBndlSubgrp", + "containedBy": { + "infra:PortBlk": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "n-to-1", + "fromMo": "infra:PortBlk", + "fromRelMo": "infra:RsAccBndlSubgrp", + "toMo": "infra:AccBndlSubgrp", + "toRelMo": "infra:RtAccBndlSubgrp", + "enforceable": true, + "resolvable": true + }, + "dnFormats": [ + "uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}/portblk-{name}/rsaccBndlSubgrp", + "uni/infra/fexprof-{name}/hports-{name}-typ-{type}/portblk-{name}/rsaccBndlSubgrp", + "uni/infra/accportprof-{name}/hports-{name}-typ-{type}/portblk-{name}/rsaccBndlSubgrp" + ], + "writeAccess": [ + "access-equipment", + "admin" + ], + "readAccess": [ + "access-equipment", + "admin" + ], + "faults": { + "F1015": "fltInfraRsAccBndlSubgrpResolveFail" + }, + "events": { + "E4214273": "creation||infra:RsAccBndlSubgrp", + "E4214274": "modification||infra:RsAccBndlSubgrp", + "E4214275": "deletion||infra:RsAccBndlSubgrp" + }, + "stats": { + + }, + "versions": "1.0(1e)-", + "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": [ + "apic" + ], + "classId": "4318", + "className": "RsAccBndlSubgrp", + "classPkg": "infra", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "Access Bundle Sub Group", + "comment": [ + "A source relation to the access bundle subgroup." + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "37879", + "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": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40018", + "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": "1.0(1e)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "14691", + "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": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": false, + "propGlobalId": "13126", + "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": "4416", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4416", "localName": "infraAccBndlSubgrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "} + ], + "default": "infraAccBndlSubgrp", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "1.0(1e)-", + "comment": [ + "The name of the relationship from the port block to the access bundle subgroup." + ], + "isConfigurable": true, + "propGlobalId": "13125", + "propLocalId": "77", + "label": "Target-dn", + "baseType": "reference:BinRef", + "modelType": "reln:Dn", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "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/infraRsSpAccGrp.json b/gen/meta/infraRsSpAccGrp.json new file mode 100644 index 000000000..dd5d89cfd --- /dev/null +++ b/gen/meta/infraRsSpAccGrp.json @@ -0,0 +1,918 @@ +{ + "infra:RsSpAccGrp": { + "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": [ + + ], + "rnFormat": "rsspAccGrp", + "containedBy": { + "infra:SHPortS": "" + }, + "superClasses": [ + "reln:To", + "reln:Inst" + ], + "subClasses": { + + }, + "relationInfo": { + "type": "explicit", + "cardinality": "n-to-1", + "fromMo": "infra:SHPortS", + "fromRelMo": "infra:RsSpAccGrp", + "toMo": "infra:SpAccGrp", + "toRelMo": "infra:RtSpAccGrp", + "enforceable": true, + "resolvable": true + }, + "dnFormats": [ + "uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}/rsspAccGrp" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "faults": { + "F2148": "fltInfraRsSpAccGrpResolveFail" + }, + "events": { + "E4212356": "creation||infra:RsSpAccGrp", + "E4212357": "modification||infra:RsSpAccGrp", + "E4212358": "deletion||infra:RsSpAccGrp" + }, + "stats": { + + }, + "versions": "2.0(1m)-", + "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": [ + "apic" + ], + "classId": "8235", + "className": "RsSpAccGrp", + "classPkg": "infra", + "featureTag": "", + "moCategory": "RelationshipToLocal", + "label": "Spine Access Group", + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38429", + "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": "3.2(1l)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "40568", + "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": "2.0(1m)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "24371", + "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": "2.0(1m)-", + "comment": [ + "The class ID of the target object. This property is managed internally and should not be modified by the user." + ], + "isConfigurable": false, + "propGlobalId": "24356", + "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": "8242", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "8242", "localName": "infraSpAccGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "8243", "localName": "infraSpAccPortGrp", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "unspecified", + "platformFlavors": [ + + ], + "label": "unspecified "} + ], + "default": "infraSpAccGrp", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "tDn": { + "versions": "2.0(1m)-", + "comment": [ + "The distinguished name of the target." + ], + "isConfigurable": true, + "propGlobalId": "24355", + "propLocalId": "77", + "label": "Target-dn", + "baseType": "reference:BinRef", + "modelType": "reln:Dn", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "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/infraSHPortS.json b/gen/meta/infraSHPortS.json new file mode 100644 index 000000000..cf21edd0d --- /dev/null +++ b/gen/meta/infraSHPortS.json @@ -0,0 +1,824 @@ +{ + "infra:SHPortS": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "infra:PortBlk": "", + "infra:RsSpAccGrp": "", + "infra:SelectorIssues": "", + "infra:SubPortBlk": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "portblk-": "infra:PortBlk", + "rbacDom-": "aaa:RbacAnnotation", + "rsspAccGrp": "infra:RsSpAccGrp", + "selectorissues": "infra:SelectorIssues", + "subportblk-": "infra:SubPortBlk", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name", + "type" + ], + "rnFormat": "shports-{name}-typ-{type}", + "containedBy": { + "infra:SpAccPortP": "" + }, + "superClasses": [ + "infra:PortS", + "fabric:APortS", + "fabric:Selector", + "fabric:Def", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + + }, + "relationTo": { + "infra:RsSpAccGrp": "infra:SpAccGrp" + }, + "dnFormats": [ + "uni/infra/spaccportprof-{name}/shports-{name}-typ-{type}" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "faults": { + + }, + "events": { + "E4212371": "creation||infra:SHPortS", + "E4212372": "modification||infra:SHPortS", + "E4212373": "deletion||infra:SHPortS" + }, + "stats": { + + }, + "versions": "2.0(1m)-", + "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": "8234", + "className": "SHPortS", + "classPkg": "infra", + "featureTag": "", + "moCategory": "Regular", + "label": "Spine Access Port Selector", + "comment": [ + "Spine Host/Access Port Selector. This selector is used for applying infrastructure\n policies on selected ports" + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38428", + "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(4d)-", + "isConfigurable": false, + "propGlobalId": "65835", + "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": "User Created "}, + { "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": "40567", + "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": "2.0(1m)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "24370", + "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": "2.0(1m)-", + "comment": [ + "The name of the object." + ], + "isConfigurable": true, + "propGlobalId": "24348", + "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 + }, + "type": { + "versions": "2.0(1m)-", + "comment": [ + "The specific type of the object or component." + ], + "isConfigurable": true, + "propGlobalId": "24349", + "propLocalId": "33", + "label": "Selector Type", + "baseType": "scalar:Enum8", + "modelType": "fabric:Selector", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validValues": [ + { "value": "0", "localName": "ALL", + "platformFlavors": [ + + ], + "label": "ALL "}, + { "value": "1", "localName": "range", + "platformFlavors": [ + + ], + "label": "range "} + ], + "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/infraSpAccPortP.json b/gen/meta/infraSpAccPortP.json new file mode 100644 index 000000000..6375e1d61 --- /dev/null +++ b/gen/meta/infraSpAccPortP.json @@ -0,0 +1,818 @@ +{ + "infra:SpAccPortP": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "fault:Delegate": "", + "health:Inst": "", + "infra:RtSpAccPortP": "", + "infra:RtToInterfaceSpPolProfile": "", + "infra:SHPortS": "", + "tag:AliasDelInst": "", + "tag:AliasInst": "", + "tag:Annotation": "", + "tag:ExtMngdInst": "", + "tag:Inst": "", + "tag:Tag": "" + }, + "rnMap": { + "alias": "tag:AliasInst", + "aliasdel-": "tag:AliasDelInst", + "annotationKey-": "tag:Annotation", + "extmngd": "tag:ExtMngdInst", + "fd-": "fault:Delegate", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "rbacDom-": "aaa:RbacAnnotation", + "rtspAccPortP-": "infra:RtSpAccPortP", + "rttoInterfaceSpPolProfile-": "infra:RtToInterfaceSpPolProfile", + "shports-": "infra:SHPortS", + "tag-": "tag:Inst", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "name" + ], + "rnFormat": "spaccportprof-{name}", + "containedBy": { + "infra:Infra": "" + }, + "superClasses": [ + "infra:PortP", + "infra:Profile", + "fabric:AProfile", + "pol:Def", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + "infra:RtSpAccPortP": "infra:SpineP", + "infra:RtToInterfaceSpPolProfile": "infra:NodeCfg" + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/infra/spaccportprof-{name}" + ], + "writeAccess": [ + "access-connectivity", + "access-equipment", + "admin" + ], + "readAccess": [ + "access-connectivity", + "access-equipment", + "admin", + "ops" + ], + "faults": { + + }, + "events": { + "E4212377": "creation||infra:SpAccPortP", + "E4212378": "modification||infra:SpAccPortP", + "E4212379": "deletion||infra:SpAccPortP" + }, + "stats": { + + }, + "versions": "2.0(1m)-", + "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": "8240", + "className": "SpAccPortP", + "classPkg": "infra", + "featureTag": "", + "moCategory": "Regular", + "label": "Spine Interface Profile", + "comment": [ + "Spine Interface Profile" + ], + "properties": { + "annotation": { + "versions": "3.2(1l)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "38432", + "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(4d)-", + "isConfigurable": false, + "propGlobalId": "65830", + "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": "User Created "}, + { "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": "40571", + "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": "2.0(1m)-", + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "24372", + "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": "2.0(1m)-", + "comment": [ + "The name of the object." + ], + "isConfigurable": true, + "propGlobalId": "24351", + "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": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nodeId": { + "versions": "5.2(4d)-", + "comment": [ + "The ID of the APIC, leaf, or spine." + ], + "isConfigurable": false, + "propGlobalId": "65831", + "propLocalId": "88", + "label": "Node Id", + "baseType": "scalar:Uint16", + "modelType": "fabric:PCNodeId", + "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 + }, + "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/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index b6e1721a4..35c3c7fc9 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -706,6 +706,10 @@ func set{{ .ResourceClassName }}LegacyAttributes(ctx context.Context, diags *dia {{- else if and (ne $AttributeName "") (isNewNamedClassAttributeMatch $Overwrite $ResourceName)}} if childAttributeName == "{{.PropertyName}}" { data.Deprecated{{.ResourceClassName}} = basetypes.NewStringValue(childAttributeValue.(string)) + } + {{- else if eq $Overwrite "target_dn"}} + if childAttributeName == "tDn" { + data.Deprecated{{.ResourceClassName}} = basetypes.NewStringValue(childAttributeValue.(string)) } {{- end}} {{- end}} @@ -882,7 +886,9 @@ func (r *{{.ResourceClassName}}Resource) ModifyPlan(ctx context.Context, req res {{- if eq .Name "Annotation"}} {{ .Name | decapitalize }}Value := planData.{{ .Name }} {{- else if not (isNewNamedClassAttribute $Overwrite) }} + {{- if (ne .Name "TDn")}} {{ .Name | decapitalize }}Value := basetypes.NewStringUnknown() + {{- end}} {{- end}} {{- end}} if stateData != nil && !IsEmptySingleNestedAttribute(stateData.{{ $SetName }}.Attributes()) { @@ -890,7 +896,9 @@ func (r *{{.ResourceClassName}}Resource) ModifyPlan(ctx context.Context, req res {{- range .Properties}} {{- $Overwrite := overwriteProperty .PkgName .SnakeCaseName $.Definitions}} {{- if not (isNewNamedClassAttribute $Overwrite) }} + {{- if (ne .Name "TDn")}} {{ .Name | decapitalize }}Value = newAttributeValues.{{.Name}} + {{- end}} {{- end}} {{- end}} {{- range .Children}} @@ -915,16 +923,16 @@ func (r *{{.ResourceClassName}}Resource) ModifyPlan(ctx context.Context, req res {{- $AttributeName := getLegacyChildAttribute .PkgName $Overwrite . $.LegacyAttributes $.LegacyBlocks}} {{- if or (eq .Name "Annotation") (eq $AttributeName "")}} {{ .Name }}: {{ .Name | decapitalize }}Value, - {{- else}} - {{- if isNewNamedClassAttribute $Overwrite }} - {{- if isNewNamedClassAttributeMatch $Overwrite $ResourceName}} + {{- else if eq .Name "TDn"}} + {{ .Name }}: configData.Deprecated{{ $SetName }}, + {{- else if isNewNamedClassAttribute $Overwrite }} + {{- if isNewNamedClassAttributeMatch $Overwrite $ResourceName}} {{ .Name }}: {{ .Name | decapitalize }}Value, - {{- else}} - {{ .Name }}: basetypes.NewStringValue(""), - {{- end }} {{- else}} + {{ .Name }}: basetypes.NewStringValue(""), + {{- end }} + {{- else}} {{ .Name }}: configData.Deprecated{{ .Name }}, - {{- end}} {{- end}} {{- end}} {{- range .Children}} diff --git a/gen/templates/resource_example_all_attributes.tf.tmpl b/gen/templates/resource_example_all_attributes.tf.tmpl index dd7236feb..4554d6155 100644 --- a/gen/templates/resource_example_all_attributes.tf.tmpl +++ b/gen/templates/resource_example_all_attributes.tf.tmpl @@ -91,15 +91,21 @@ resource "aci_{{$topContext.ResourceName}}" {{- if ne $formatValue.ContainedBy " {{- define "childResourcesAndPropertiesDocExamples" -}} {{- $testvars := .TemplateProperties.TestVars -}} {{- $indent := .TemplateProperties.Indent -}} +{{- $pkgName := .PkgName -}} {{$ChildResourceName := overwriteProperty .PkgName .ResourceName $.Definitions}} {{- if or (not .IdentifiedBy) .MaxOneClassAllowed}} {{ $indent }}{{$ChildResourceName}} = { {{- range .Properties}}{{- if not .ReadOnly }}{{- if ne .NamedPropertyClass ""}} {{ $indent }}{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name {{- else if eq .SnakeCaseName "t_dn" }} - {{- range $index, $testParent := $testvars.parents }}{{$attributeValue := getTestTargetDn $testvars.child_targets $ChildResourceName "target_dn_0" true nil 0 true | replace "test_0" "example_2" }} + {{- $overwriteTDn := getTestValueOverwrite $pkgName "target_dn" "target_dn_0" $.Definitions}} + {{- if ne $overwriteTDn "target_dn_0"}} + {{ $indent }}target_dn = {{ $overwriteTDn }} + {{- else}} + {{- range $index, $testParent := $testvars.parents }}{{$attributeValue := getTestTargetDn $testvars.child_targets $ChildResourceName "target_dn_0" true nil 0 true | replace "test_0" "example_2" }} {{ $indent }}target_dn = {{if containsString $attributeValue "."}}{{$attributeValue}}{{else}}"{{$attributeValue}}"{{end}} - {{- break}} + {{- break}} + {{- end}} {{- end}} {{- else if .IgnoreInTest}} {{ $indent }}{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{.IgnoreInTestExampleValue}} diff --git a/gen/templates/resource_test.go.tmpl b/gen/templates/resource_test.go.tmpl index 27f441902..5a008208d 100644 --- a/gen/templates/resource_test.go.tmpl +++ b/gen/templates/resource_test.go.tmpl @@ -2320,7 +2320,13 @@ resource "aci_{{$.resourceName}}" "test{{- if eq $.resourceClassName $parentClas const testConfig{{$.resourceClassName}}LegacyAttributesWith{{capitalize .class_name}} = {{- if ne $.custom_test_dependency_name nil}} testConfig{{$.custom_test_dependency_name}} + {{- end}} {{- if $dependencies }} testDependencyConfig{{$.resourceClassName}} + {{- end }}{{- if $childDependencies }} testChildDependencyConfig{{$.resourceClassName}} + {{- end }} {{if .class_name}}testConfig{{capitalize .class_name}}Min{{- if ne .parent_dependency ""}}DependencyWith{{capitalize .parent_dependency}}{{if and (ne .parent_dependency_name nil) (ne .parent_dependency_name "")}}{{capitalize .parent_dependency_name }}{{- end }}{{- end}} + {{- end}} ` resource "aci_{{$.resourceName}}" "test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}" { {{- range $key, $value := $.resource_required}} + {{- if $.ignore_in_legacy }} + {{- if not (definedInList $.ignore_in_legacy $key)}} {{$key}} = "{{$value}}" + {{- end}} + {{- else}} + {{$key}} = "{{$value}}" + {{- end}} {{- end}} {{- range $key, $value := $.legacy_attributes}} {{- if isInterfaceSlice $value}}{{$list_value := index $value 0}} @@ -2684,7 +2690,13 @@ resource "aci_{{$.resourceName}}" "test" { const testConfig{{$.resourceClassName}}LegacyAttributes = {{- if $childDependencies }} testChildDependencyConfig{{$.resourceClassName}} + {{- end }}` resource "aci_{{$.resourceName}}" "test" { {{- range $key, $value := $.resource_required}} + {{- if $.ignore_in_legacy }} + {{- if not (definedInList $.ignore_in_legacy $key)}} {{$key}} = "{{$value}}" + {{- end}} + {{- else}} + {{$key}} = "{{$value}}" + {{- end}} {{- end}} {{- range $key, $value := $.legacy_attributes}} {{- if isInterfaceSlice $value}}{{$list_value := index $value 0}} diff --git a/gen/templates/testvars.yaml.tmpl b/gen/templates/testvars.yaml.tmpl index e9f086472..77e2b4aab 100644 --- a/gen/templates/testvars.yaml.tmpl +++ b/gen/templates/testvars.yaml.tmpl @@ -13,6 +13,15 @@ legacy_attributes: {{- end}} {{- end}} {{- end }} + +{{- $ignore := getIgnoreInLegacy .PkgName .Definitions}} +{{- if gt (len $ignore) 0}} + +ignore_in_legacy: + {{- range $ignore}} + - "{{.}}" + {{- end}} +{{- end}} {{- end}} {{- if .LegacyBlocks}} legacy_blocks: diff --git a/gen/testvars/infraAccPortP.yaml b/gen/testvars/infraAccPortP.yaml new file mode 100644 index 000000000..66de65960 --- /dev/null +++ b/gen/testvars/infraAccPortP.yaml @@ -0,0 +1,46 @@ +# 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: "non_existing_name" + +datasource_required: + name: "test_name" + +resource_required: + name: "test_name" + +all: + annotation: "annotation" + description: "description_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + +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" + + +test_type: apic +class_version: 1.0(1e)- diff --git a/gen/testvars/infraFexP.yaml b/gen/testvars/infraFexP.yaml new file mode 100644 index 000000000..66de65960 --- /dev/null +++ b/gen/testvars/infraFexP.yaml @@ -0,0 +1,46 @@ +# 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: "non_existing_name" + +datasource_required: + name: "test_name" + +resource_required: + name: "test_name" + +all: + annotation: "annotation" + description: "description_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + +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" + + +test_type: apic +class_version: 1.0(1e)- diff --git a/gen/testvars/infraHPortS.yaml b/gen/testvars/infraHPortS.yaml new file mode 100644 index 000000000..d7a99954f --- /dev/null +++ b/gen/testvars/infraHPortS.yaml @@ -0,0 +1,98 @@ +# 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). +legacy_attributes: + leaf_interface_profile_dn: "aci_leaf_interface_profile.test.id" + access_port_selector_type: "range" + relation_infra_rs_acc_base_grp: "aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id" + +ignore_in_legacy: + - "port_selector_type" + + +default: + annotation: "orchestrator:terraform" + description: "" + name_alias: "" + owner_key: "" + owner_tag: "" + +datasource_non_existing: + name: "non_existing_name" + port_selector_type: "range" + +datasource_required: + name: "test_name" + port_selector_type: "range" + +resource_required: + name: "test_name" + port_selector_type: "range" + +all: + annotation: "annotation" + description: "description_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + +children: + relation_to_leaf_access_port_policy_group: + - annotation: "annotation_1" + fex_id: "102" + target_dn: "target_dn_1" + deletable_child: true + child_required: false + 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" + + 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: "infraAccPortP" + parent_dependency: "" + parent_dn: "aci_leaf_interface_profile.test.id" + class_in_parent: false + test_type: apic + - class_name: "infraFexP" + parent_dependency: "" + parent_dn: "aci_fex_profile.test.id" + class_in_parent: false + test_type: apic +child_targets: + - class_name: "infraAccPortGrp" + target_dn: "uni/infra/funcprof/accportgrp-leaf_access_port_policy_group_1" + relation_resource_name: "leaf_access_port_policy_group" + static: false + target_dn_ref: "aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id" + parent_dependency: "" + parent_dependency_dn_ref: "" + target_resource_name: "leaf_access_port_policy_group" + parent_dn_key: "parent_dn" + properties: + name: "leaf_access_port_policy_group_1" +class_version: 1.0(1e)- diff --git a/gen/testvars/infraPortBlk.yaml b/gen/testvars/infraPortBlk.yaml new file mode 100644 index 000000000..f28d618bf --- /dev/null +++ b/gen/testvars/infraPortBlk.yaml @@ -0,0 +1,82 @@ +# 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). +legacy_attributes: + access_port_selector_dn: "aci_access_port_selector.test.id" + relation_infra_rs_acc_bndl_subgrp: "" + + +default: + annotation: "orchestrator:terraform" + description: "" + from_card: "1" + from_port: "1" + name_alias: "" + to_card: "1" + to_port: "1" + +datasource_non_existing: + name: "non_existing_name" + +datasource_required: + name: "test_name" + +resource_required: + name: "test_name" + +all: + annotation: "annotation" + description: "description_1" + from_card: "2" + from_port: "3" + name_alias: "name_alias_1" + to_card: "4" + to_port: "5" + +children: + relation_to_pc_vpc_override_policy: + - annotation: "annotation_1" + target_dn: "" + deletable_child: true + child_required: false + 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" + + 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: "infraHPortS" + parent_dependency: "infraAccPortP" + parent_dn: "aci_access_port_selector.test.id" + class_in_parent: false + test_type: apic + - class_name: "infraSHPortS" + parent_dependency: "infraSpAccPortP" + parent_dn: "aci_spine_access_port_selector.test.id" + class_in_parent: false + test_type: apic +class_version: 1.0(1e)- diff --git a/gen/testvars/infraSHPortS.yaml b/gen/testvars/infraSHPortS.yaml new file mode 100644 index 000000000..58305f59e --- /dev/null +++ b/gen/testvars/infraSHPortS.yaml @@ -0,0 +1,92 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +legacy_attributes: + spine_interface_profile_dn: "aci_spine_interface_profile.test.id" + spine_access_port_selector_type: "ALL" + relation_infra_rs_sp_acc_grp: "aci_spine_port_policy_group.test_spine_port_policy_group_0.id" + +ignore_in_legacy: + - "port_selector_type" + + +default: + annotation: "orchestrator:terraform" + description: "" + name_alias: "" + owner_key: "" + owner_tag: "" + +datasource_non_existing: + name: "non_existing_name" + port_selector_type: "ALL" + +datasource_required: + name: "test_name" + port_selector_type: "ALL" + +resource_required: + name: "test_name" + port_selector_type: "ALL" + +all: + annotation: "annotation" + description: "description_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + +children: + relation_to_spine_port_policy_group: + - annotation: "annotation_1" + target_dn: "uni/infra/funcprof/spaccportgrp-spine_port_policy_group_1" + deletable_child: true + child_required: false + 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" + + 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: "infraSpAccPortP" + parent_dependency: "" + parent_dn: "aci_spine_interface_profile.test.id" + class_in_parent: false + test_type: apic +child_targets: + - class_name: "infraSpAccPortGrp" + target_dn: "uni/infra/funcprof/spaccportgrp-spine_port_policy_group_1" + relation_resource_name: "spine_port_policy_group" + static: false + target_dn_ref: "aci_spine_port_policy_group.test_spine_port_policy_group_0.id" + parent_dependency: "" + parent_dependency_dn_ref: "" + target_resource_name: "spine_port_policy_group" + parent_dn_key: "parent_dn" + properties: + name: "spine_port_policy_group_1" +class_version: 2.0(1m)- diff --git a/gen/testvars/infraSpAccPortP.yaml b/gen/testvars/infraSpAccPortP.yaml new file mode 100644 index 000000000..72b45eec9 --- /dev/null +++ b/gen/testvars/infraSpAccPortP.yaml @@ -0,0 +1,46 @@ +# 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: "non_existing_name" + +datasource_required: + name: "test_name" + +resource_required: + name: "test_name" + +all: + annotation: "annotation" + description: "description_1" + name_alias: "name_alias_1" + owner_key: "owner_key_1" + owner_tag: "owner_tag_1" + +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" + + +test_type: apic +class_version: 2.0(1m)- diff --git a/internal/provider/data_source_aci_access_port_block.go b/internal/provider/data_source_aci_access_port_block.go new file mode 100644 index 000000000..1bf174898 --- /dev/null +++ b/internal/provider/data_source_aci_access_port_block.go @@ -0,0 +1,230 @@ +// 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 = &InfraPortBlkDataSource{} + +func NewInfraPortBlkDataSource() datasource.DataSource { + return &InfraPortBlkDataSource{} +} + +// InfraPortBlkDataSource defines the data source implementation. +type InfraPortBlkDataSource struct { + client *client.Client +} + +func (d *InfraPortBlkDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_access_port_block") + resp.TypeName = req.ProviderTypeName + "_access_port_block" + tflog.Debug(ctx, "End metadata of datasource: aci_access_port_block") +} + +func (d *InfraPortBlkDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_access_port_block") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The access_port_block datasource for the 'infraPortBlk' class", + + Attributes: map[string]schema.Attribute{ + // Deprecated attributes + "access_port_selector_dn": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'access_port_selector_dn' is deprecated, please refer to 'parent_dn' instead. The attribute will be removed in the next major version of the provider.", + }, + "relation_infra_rs_acc_bndl_subgrp": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'relation_infra_rs_acc_bndl_subgrp' is deprecated, please refer to 'relation_to_pc_vpc_override_policy' instead. The attribute will be removed in the next major version of the provider.", + }, + // End of deprecated attributes + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Access Port Block 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 Access Port Block object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Access Port Block object.`, + }, + "from_card": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The start of the line card range for the Access Port Block object.`, + }, + "from_port": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The start of the port range for the Access Port Block object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Access Port Block object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Access Port Block object.`, + }, + "to_card": schema.StringAttribute{ + Computed: true, + MarkdownDescription: ` The end of the line card range for the Access Port Block object.`, + }, + "to_port": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The end of the port range for the Access Port Block object.`, + }, + "relation_to_pc_vpc_override_policy": schema.SingleNestedAttribute{ + MarkdownDescription: `A source relation to the access bundle subgroup.`, + Computed: true, + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Pc Vpc Override Policy object.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name (DN) of the target PC VPC Override Policy.`, + }, + "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.`, + }, + }, + }, + }, + }, + }, + "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.`, + }, + }, + }, + }, + }, + Blocks: map[string]schema.Block{}, + } + tflog.Debug(ctx, "End schema of datasource: aci_access_port_block") +} + +func (d *InfraPortBlkDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_access_port_block") + // 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_access_port_block") +} + +func (d *InfraPortBlkDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_access_port_block") + var data *InfraPortBlkResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setInfraPortBlkId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraPortBlkAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_access_port_block with id '%s'", data.Id.ValueString())) + + getAndSetInfraPortBlkAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_access_port_block data source", + fmt.Sprintf("The aci_access_port_block 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_access_port_block with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_access_port_block_test.go b/internal/provider/data_source_aci_access_port_block_test.go new file mode 100644 index 000000000..10fe9252b --- /dev/null +++ b/internal/provider/data_source_aci_access_port_block_test.go @@ -0,0 +1,96 @@ +// 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 TestAccDataSourceInfraPortBlkWithInfraHPortS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraPortBlkDataSourceDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "from_card", "1"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "from_port", "1"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "to_card", "1"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "to_port", "1"), + ), + }, + { + Config: testConfigInfraPortBlkNotExistingInfraHPortS, + ExpectError: regexp.MustCompile("Failed to read aci_access_port_block data source"), + }, + }, + }) +} +func TestAccDataSourceInfraPortBlkWithInfraSHPortS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraPortBlkDataSourceDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "from_card", "1"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "from_port", "1"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "to_card", "1"), + resource.TestCheckResourceAttr("data.aci_access_port_block.test", "to_port", "1"), + ), + }, + { + Config: testConfigInfraPortBlkNotExistingInfraSHPortS, + ExpectError: regexp.MustCompile("Failed to read aci_access_port_block data source"), + }, + }, + }) +} + +const testConfigInfraPortBlkDataSourceDependencyWithInfraHPortS = testConfigInfraPortBlkMinDependencyWithInfraHPortS + ` +data "aci_access_port_block" "test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" + depends_on = [aci_access_port_block.test] +} +` + +const testConfigInfraPortBlkNotExistingInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +data "aci_access_port_block" "test_non_existing" { + parent_dn = aci_access_port_selector.test.id + name = "non_existing_name" +} +` +const testConfigInfraPortBlkDataSourceDependencyWithInfraSHPortS = testConfigInfraPortBlkMinDependencyWithInfraSHPortS + ` +data "aci_access_port_block" "test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" + depends_on = [aci_access_port_block.test] +} +` + +const testConfigInfraPortBlkNotExistingInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +data "aci_access_port_block" "test_non_existing" { + parent_dn = aci_spine_access_port_selector.test.id + name = "non_existing_name" +} +` diff --git a/internal/provider/data_source_aci_access_port_selector.go b/internal/provider/data_source_aci_access_port_selector.go new file mode 100644 index 000000000..46fc65efe --- /dev/null +++ b/internal/provider/data_source_aci_access_port_selector.go @@ -0,0 +1,239 @@ +// 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-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &InfraHPortSDataSource{} + +func NewInfraHPortSDataSource() datasource.DataSource { + return &InfraHPortSDataSource{} +} + +// InfraHPortSDataSource defines the data source implementation. +type InfraHPortSDataSource struct { + client *client.Client +} + +func (d *InfraHPortSDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_access_port_selector") + resp.TypeName = req.ProviderTypeName + "_access_port_selector" + tflog.Debug(ctx, "End metadata of datasource: aci_access_port_selector") +} + +func (d *InfraHPortSDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_access_port_selector") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The access_port_selector datasource for the 'infraHPortS' class", + + Attributes: map[string]schema.Attribute{ + // Deprecated attributes + "leaf_interface_profile_dn": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'leaf_interface_profile_dn' is deprecated, please refer to 'parent_dn' instead. The attribute will be removed in the next major version of the provider.", + }, + "access_port_selector_type": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'access_port_selector_type' is deprecated, please refer to 'port_selector_type' instead. The attribute will be removed in the next major version of the provider.", + }, + "relation_infra_rs_acc_base_grp": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'relation_infra_rs_acc_base_grp' is deprecated, please refer to 'relation_to_leaf_access_port_policy_group' instead. The attribute will be removed in the next major version of the provider.", + }, + // End of deprecated attributes + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Access Port Selector 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 Access Port Selector object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Access Port Selector object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Access Port Selector object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Access Port 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.`, + }, + "port_selector_type": schema.StringAttribute{ + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("ALL", "range"), + }, + MarkdownDescription: `The port selector type of the Access Port Selector object.`, + }, + "relation_to_leaf_access_port_policy_group": schema.SingleNestedAttribute{ + MarkdownDescription: `A source relation to the access policy group providing port configuration.`, + Computed: true, + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Leaf Access Port Policy Group object.`, + }, + "fex_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The interface policy group FEX ID.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Select or create an interface policy group to associate to the Access Port selector.`, + }, + "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.`, + }, + }, + }, + }, + }, + }, + "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.`, + }, + }, + }, + }, + }, + Blocks: map[string]schema.Block{}, + } + tflog.Debug(ctx, "End schema of datasource: aci_access_port_selector") +} + +func (d *InfraHPortSDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_access_port_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_access_port_selector") +} + +func (d *InfraHPortSDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_access_port_selector") + var data *InfraHPortSResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setInfraHPortSId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraHPortSAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_access_port_selector with id '%s'", data.Id.ValueString())) + + getAndSetInfraHPortSAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_access_port_selector data source", + fmt.Sprintf("The aci_access_port_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_access_port_selector with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_access_port_selector_test.go b/internal/provider/data_source_aci_access_port_selector_test.go new file mode 100644 index 000000000..aba4cfb39 --- /dev/null +++ b/internal/provider/data_source_aci_access_port_selector_test.go @@ -0,0 +1,98 @@ +// 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 TestAccDataSourceInfraHPortSWithInfraAccPortP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraHPortSDataSourceDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "owner_tag", ""), + ), + }, + { + Config: testConfigInfraHPortSNotExistingInfraAccPortP, + ExpectError: regexp.MustCompile("Failed to read aci_access_port_selector data source"), + }, + }, + }) +} +func TestAccDataSourceInfraHPortSWithInfraFexP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraHPortSDataSourceDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("data.aci_access_port_selector.test", "owner_tag", ""), + ), + }, + { + Config: testConfigInfraHPortSNotExistingInfraFexP, + ExpectError: regexp.MustCompile("Failed to read aci_access_port_selector data source"), + }, + }, + }) +} + +const testConfigInfraHPortSDataSourceDependencyWithInfraAccPortP = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +data "aci_access_port_selector" "test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" + depends_on = [aci_access_port_selector.test] +} +` + +const testConfigInfraHPortSNotExistingInfraAccPortP = testConfigInfraAccPortPMin + ` +data "aci_access_port_selector" "test_non_existing" { + parent_dn = aci_leaf_interface_profile.test.id + name = "non_existing_name" + port_selector_type = "range" +} +` +const testConfigInfraHPortSDataSourceDependencyWithInfraFexP = testConfigInfraHPortSMinDependencyWithInfraFexP + ` +data "aci_access_port_selector" "test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" + depends_on = [aci_access_port_selector.test] +} +` + +const testConfigInfraHPortSNotExistingInfraFexP = testConfigInfraFexPMin + ` +data "aci_access_port_selector" "test_non_existing" { + parent_dn = aci_fex_profile.test.id + name = "non_existing_name" + port_selector_type = "range" +} +` diff --git a/internal/provider/data_source_aci_fex_profile.go b/internal/provider/data_source_aci_fex_profile.go new file mode 100644 index 000000000..e5b55e1f6 --- /dev/null +++ b/internal/provider/data_source_aci_fex_profile.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 = &InfraFexPDataSource{} + +func NewInfraFexPDataSource() datasource.DataSource { + return &InfraFexPDataSource{} +} + +// InfraFexPDataSource defines the data source implementation. +type InfraFexPDataSource struct { + client *client.Client +} + +func (d *InfraFexPDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_fex_profile") + resp.TypeName = req.ProviderTypeName + "_fex_profile" + tflog.Debug(ctx, "End metadata of datasource: aci_fex_profile") +} + +func (d *InfraFexPDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_fex_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The fex_profile datasource for the 'infraFexP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the FEX Profile 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 FEX Profile object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the FEX Profile object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the FEX Profile object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the FEX Profile 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_fex_profile") +} + +func (d *InfraFexPDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_fex_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_fex_profile") +} + +func (d *InfraFexPDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_fex_profile") + var data *InfraFexPResourceModel + + // 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") + } + + setInfraFexPId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraFexPAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_fex_profile with id '%s'", data.Id.ValueString())) + + getAndSetInfraFexPAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_fex_profile data source", + fmt.Sprintf("The aci_fex_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_fex_profile with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_fex_profile_test.go b/internal/provider/data_source_aci_fex_profile_test.go new file mode 100644 index 000000000..bacbd22af --- /dev/null +++ b/internal/provider/data_source_aci_fex_profile_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 TestAccDataSourceInfraFexP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraFexPDataSource, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_fex_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("data.aci_fex_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("data.aci_fex_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("data.aci_fex_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("data.aci_fex_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + { + Config: testConfigInfraFexPNotExisting, + ExpectError: regexp.MustCompile("Failed to read aci_fex_profile data source"), + }, + }, + }) +} + +const testConfigInfraFexPDataSource = testConfigInfraFexPAll + ` +data "aci_fex_profile" "test" { + name = "test_name" + depends_on = [aci_fex_profile.test] +} +` + +const testConfigInfraFexPNotExisting = testConfigInfraFexPAll + ` +data "aci_fex_profile" "test_non_existing" { + name = "non_existing_name" +} +` diff --git a/internal/provider/data_source_aci_leaf_interface_profile.go b/internal/provider/data_source_aci_leaf_interface_profile.go new file mode 100644 index 000000000..7a4f9e716 --- /dev/null +++ b/internal/provider/data_source_aci_leaf_interface_profile.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 = &InfraAccPortPDataSource{} + +func NewInfraAccPortPDataSource() datasource.DataSource { + return &InfraAccPortPDataSource{} +} + +// InfraAccPortPDataSource defines the data source implementation. +type InfraAccPortPDataSource struct { + client *client.Client +} + +func (d *InfraAccPortPDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_leaf_interface_profile") + resp.TypeName = req.ProviderTypeName + "_leaf_interface_profile" + tflog.Debug(ctx, "End metadata of datasource: aci_leaf_interface_profile") +} + +func (d *InfraAccPortPDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_leaf_interface_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The leaf_interface_profile datasource for the 'infraAccPortP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Leaf Interface Profile 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 Leaf Interface Profile object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Leaf Interface Profile object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Leaf Interface Profile object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Leaf Interface Profile 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_leaf_interface_profile") +} + +func (d *InfraAccPortPDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_leaf_interface_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_leaf_interface_profile") +} + +func (d *InfraAccPortPDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_leaf_interface_profile") + var data *InfraAccPortPResourceModel + + // 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") + } + + setInfraAccPortPId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraAccPortPAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_leaf_interface_profile with id '%s'", data.Id.ValueString())) + + getAndSetInfraAccPortPAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_leaf_interface_profile data source", + fmt.Sprintf("The aci_leaf_interface_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_leaf_interface_profile with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_leaf_interface_profile_test.go b/internal/provider/data_source_aci_leaf_interface_profile_test.go new file mode 100644 index 000000000..c934eebea --- /dev/null +++ b/internal/provider/data_source_aci_leaf_interface_profile_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 TestAccDataSourceInfraAccPortP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraAccPortPDataSource, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_leaf_interface_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("data.aci_leaf_interface_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("data.aci_leaf_interface_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("data.aci_leaf_interface_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("data.aci_leaf_interface_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + { + Config: testConfigInfraAccPortPNotExisting, + ExpectError: regexp.MustCompile("Failed to read aci_leaf_interface_profile data source"), + }, + }, + }) +} + +const testConfigInfraAccPortPDataSource = testConfigInfraAccPortPAll + ` +data "aci_leaf_interface_profile" "test" { + name = "test_name" + depends_on = [aci_leaf_interface_profile.test] +} +` + +const testConfigInfraAccPortPNotExisting = testConfigInfraAccPortPAll + ` +data "aci_leaf_interface_profile" "test_non_existing" { + name = "non_existing_name" +} +` diff --git a/internal/provider/data_source_aci_spine_access_port_selector.go b/internal/provider/data_source_aci_spine_access_port_selector.go new file mode 100644 index 000000000..7fa1e2543 --- /dev/null +++ b/internal/provider/data_source_aci_spine_access_port_selector.go @@ -0,0 +1,235 @@ +// 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-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &InfraSHPortSDataSource{} + +func NewInfraSHPortSDataSource() datasource.DataSource { + return &InfraSHPortSDataSource{} +} + +// InfraSHPortSDataSource defines the data source implementation. +type InfraSHPortSDataSource struct { + client *client.Client +} + +func (d *InfraSHPortSDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_spine_access_port_selector") + resp.TypeName = req.ProviderTypeName + "_spine_access_port_selector" + tflog.Debug(ctx, "End metadata of datasource: aci_spine_access_port_selector") +} + +func (d *InfraSHPortSDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_spine_access_port_selector") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The spine_access_port_selector datasource for the 'infraSHPortS' class", + + Attributes: map[string]schema.Attribute{ + // Deprecated attributes + "spine_interface_profile_dn": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'spine_interface_profile_dn' is deprecated, please refer to 'parent_dn' instead. The attribute will be removed in the next major version of the provider.", + }, + "spine_access_port_selector_type": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'spine_access_port_selector_type' is deprecated, please refer to 'port_selector_type' instead. The attribute will be removed in the next major version of the provider.", + }, + "relation_infra_rs_sp_acc_grp": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'relation_infra_rs_sp_acc_grp' is deprecated, please refer to 'relation_to_spine_port_policy_group' instead. The attribute will be removed in the next major version of the provider.", + }, + // End of deprecated attributes + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Spine Access Port Selector 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 Spine Access Port Selector object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Spine Access Port Selector object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Spine Access Port Selector object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Spine Access Port 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.`, + }, + "port_selector_type": schema.StringAttribute{ + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("ALL", "range"), + }, + MarkdownDescription: `The port selector type of the Spine Access Port Selector object.`, + }, + "relation_to_spine_port_policy_group": schema.SingleNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the Relation To Spine Port Policy Group object.`, + }, + "target_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The distinguished name of the target.`, + }, + "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.`, + }, + }, + }, + }, + }, + }, + "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.`, + }, + }, + }, + }, + }, + Blocks: map[string]schema.Block{}, + } + tflog.Debug(ctx, "End schema of datasource: aci_spine_access_port_selector") +} + +func (d *InfraSHPortSDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_spine_access_port_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_spine_access_port_selector") +} + +func (d *InfraSHPortSDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_spine_access_port_selector") + var data *InfraSHPortSResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setInfraSHPortSId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraSHPortSAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_spine_access_port_selector with id '%s'", data.Id.ValueString())) + + getAndSetInfraSHPortSAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_spine_access_port_selector data source", + fmt.Sprintf("The aci_spine_access_port_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_spine_access_port_selector with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_spine_access_port_selector_test.go b/internal/provider/data_source_aci_spine_access_port_selector_test.go new file mode 100644 index 000000000..6a81bdb33 --- /dev/null +++ b/internal/provider/data_source_aci_spine_access_port_selector_test.go @@ -0,0 +1,56 @@ +// 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 TestAccDataSourceInfraSHPortSWithInfraSpAccPortP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraSHPortSDataSourceDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_spine_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("data.aci_spine_access_port_selector.test", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("data.aci_spine_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_spine_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_spine_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("data.aci_spine_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("data.aci_spine_access_port_selector.test", "owner_tag", ""), + ), + }, + { + Config: testConfigInfraSHPortSNotExistingInfraSpAccPortP, + ExpectError: regexp.MustCompile("Failed to read aci_spine_access_port_selector data source"), + }, + }, + }) +} + +const testConfigInfraSHPortSDataSourceDependencyWithInfraSpAccPortP = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +data "aci_spine_access_port_selector" "test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" + depends_on = [aci_spine_access_port_selector.test] +} +` + +const testConfigInfraSHPortSNotExistingInfraSpAccPortP = testConfigInfraSpAccPortPMin + ` +data "aci_spine_access_port_selector" "test_non_existing" { + parent_dn = aci_spine_interface_profile.test.id + name = "non_existing_name" + port_selector_type = "ALL" +} +` diff --git a/internal/provider/data_source_aci_spine_interface_profile.go b/internal/provider/data_source_aci_spine_interface_profile.go new file mode 100644 index 000000000..118ee6d5c --- /dev/null +++ b/internal/provider/data_source_aci_spine_interface_profile.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 = &InfraSpAccPortPDataSource{} + +func NewInfraSpAccPortPDataSource() datasource.DataSource { + return &InfraSpAccPortPDataSource{} +} + +// InfraSpAccPortPDataSource defines the data source implementation. +type InfraSpAccPortPDataSource struct { + client *client.Client +} + +func (d *InfraSpAccPortPDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_spine_interface_profile") + resp.TypeName = req.ProviderTypeName + "_spine_interface_profile" + tflog.Debug(ctx, "End metadata of datasource: aci_spine_interface_profile") +} + +func (d *InfraSpAccPortPDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_spine_interface_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The spine_interface_profile datasource for the 'infraSpAccPortP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Spine Interface Profile 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 Spine Interface Profile object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the Spine Interface Profile object.`, + }, + "name": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The name of the Spine Interface Profile object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the Spine Interface Profile 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_spine_interface_profile") +} + +func (d *InfraSpAccPortPDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_spine_interface_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_spine_interface_profile") +} + +func (d *InfraSpAccPortPDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_spine_interface_profile") + var data *InfraSpAccPortPResourceModel + + // 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") + } + + setInfraSpAccPortPId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetInfraSpAccPortPAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_spine_interface_profile with id '%s'", data.Id.ValueString())) + + getAndSetInfraSpAccPortPAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_spine_interface_profile data source", + fmt.Sprintf("The aci_spine_interface_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_spine_interface_profile with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_spine_interface_profile_test.go b/internal/provider/data_source_aci_spine_interface_profile_test.go new file mode 100644 index 000000000..2fb2ab1cd --- /dev/null +++ b/internal/provider/data_source_aci_spine_interface_profile_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 TestAccDataSourceInfraSpAccPortP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigInfraSpAccPortPDataSource, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_spine_interface_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("data.aci_spine_interface_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("data.aci_spine_interface_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("data.aci_spine_interface_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("data.aci_spine_interface_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + { + Config: testConfigInfraSpAccPortPNotExisting, + ExpectError: regexp.MustCompile("Failed to read aci_spine_interface_profile data source"), + }, + }, + }) +} + +const testConfigInfraSpAccPortPDataSource = testConfigInfraSpAccPortPAll + ` +data "aci_spine_interface_profile" "test" { + name = "test_name" + depends_on = [aci_spine_interface_profile.test] +} +` + +const testConfigInfraSpAccPortPNotExisting = testConfigInfraSpAccPortPAll + ` +data "aci_spine_interface_profile" "test_non_existing" { + name = "non_existing_name" +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f1cc612a2..5037e2c07 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -251,7 +251,13 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvTrackMemberResource, NewFvVmAttrResource, NewIgmpSnoopPolResource, + NewInfraAccPortPResource, + NewInfraFexPResource, NewInfraHPathSResource, + NewInfraHPortSResource, + NewInfraPortBlkResource, + NewInfraSHPortSResource, + NewInfraSpAccPortPResource, NewL3extConsLblResource, NewL3extInstPResource, NewL3extProvLblResource, @@ -344,7 +350,13 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvTrackMemberDataSource, NewFvVmAttrDataSource, NewIgmpSnoopPolDataSource, + NewInfraAccPortPDataSource, + NewInfraFexPDataSource, NewInfraHPathSDataSource, + NewInfraHPortSDataSource, + NewInfraPortBlkDataSource, + NewInfraSHPortSDataSource, + NewInfraSpAccPortPDataSource, NewL3extConsLblDataSource, NewL3extInstPDataSource, NewL3extProvLblDataSource, diff --git a/internal/provider/resource_aci_access_port_block.go b/internal/provider/resource_aci_access_port_block.go new file mode 100644 index 000000000..1b06a9a29 --- /dev/null +++ b/internal/provider/resource_aci_access_port_block.go @@ -0,0 +1,1347 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-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/objectplanmodifier" + "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 = &InfraPortBlkResource{} +var _ resource.ResourceWithImportState = &InfraPortBlkResource{} + +func NewInfraPortBlkResource() resource.Resource { + return &InfraPortBlkResource{} +} + +// InfraPortBlkResource defines the resource implementation. +type InfraPortBlkResource struct { + client *client.Client +} + +// InfraPortBlkResourceModel describes the resource data model. +type InfraPortBlkResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + FromCard types.String `tfsdk:"from_card"` + FromPort types.String `tfsdk:"from_port"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + ToCard types.String `tfsdk:"to_card"` + ToPort types.String `tfsdk:"to_port"` + InfraRsAccBndlSubgrp types.Object `tfsdk:"relation_to_pc_vpc_override_policy"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` + DeprecatedParentDn types.String `tfsdk:"access_port_selector_dn"` + DeprecatedInfraRsAccBndlSubgrp types.String `tfsdk:"relation_infra_rs_acc_bndl_subgrp"` +} + +func getEmptyInfraPortBlkResourceModel() *InfraPortBlkResourceModel { + return &InfraPortBlkResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + FromCard: basetypes.NewStringNull(), + FromPort: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + ToCard: basetypes.NewStringNull(), + ToPort: basetypes.NewStringNull(), + InfraRsAccBndlSubgrp: types.ObjectNull(map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkType}, + "tags": types.SetType{ElemType: TagTagInfraRsAccBndlSubgrpInfraPortBlkType}, + }), + 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, + }, + }), + DeprecatedParentDn: types.String{}, + DeprecatedInfraRsAccBndlSubgrp: types.String{}, + } +} + +// InfraRsAccBndlSubgrpInfraPortBlkResourceModel describes the resource data model for the children without relation ships. +type InfraRsAccBndlSubgrpInfraPortBlkResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyInfraRsAccBndlSubgrpInfraPortBlkResourceModel() InfraRsAccBndlSubgrpInfraPortBlkResourceModel { + return InfraRsAccBndlSubgrpInfraPortBlkResourceModel{ + 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, + }, + }), + } +} + +var InfraRsAccBndlSubgrpInfraPortBlkType = map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkType}, + "tags": types.SetType{ElemType: TagTagInfraRsAccBndlSubgrpInfraPortBlkType}, +} + +// TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel() TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel { + return TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel() TagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel { + return TagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraRsAccBndlSubgrpInfraPortBlkType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagAnnotationInfraPortBlkResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraPortBlkResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraPortBlkResourceModel() TagAnnotationInfraPortBlkResourceModel { + return TagAnnotationInfraPortBlkResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraPortBlkType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraPortBlkResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraPortBlkResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraPortBlkResourceModel() TagTagInfraPortBlkResourceModel { + return TagTagInfraPortBlkResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraPortBlkType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type InfraPortBlkIdentifier struct { + Name types.String +} + +type InfraPortBlkResourceModelV1 struct { + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + FromCard types.String `tfsdk:"from_card"` + FromPort types.String `tfsdk:"from_port"` + Id types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + ParentDn types.String `tfsdk:"access_port_selector_dn"` + ToCard types.String `tfsdk:"to_card"` + ToPort types.String `tfsdk:"to_port"` + InfraRsAccBndlSubgrp types.String `tfsdk:"relation_infra_rs_acc_bndl_subgrp"` +} + +func (r *InfraPortBlkResource) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { + return map[int64]resource.StateUpgrader{ + 1: { + PriorSchema: &schema.Schema{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "description": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "from_card": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "from_port": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "id": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "name": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "name_alias": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "access_port_selector_dn": schema.StringAttribute{ + Required: true, + Optional: false, + Computed: false, + }, + "to_card": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "to_port": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "relation_infra_rs_acc_bndl_subgrp": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: false, + }, + }, + Blocks: map[string]schema.Block{}, + }, + StateUpgrader: func(ctx context.Context, req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) { + var priorStateData InfraPortBlkResourceModelV1 + + resp.Diagnostics.Append(req.State.Get(ctx, &priorStateData)...) + + if resp.Diagnostics.HasError() { + return + } + + upgradedStateData := InfraPortBlkResourceModel{ + Id: priorStateData.Id, + ParentDn: priorStateData.ParentDn, + Annotation: priorStateData.Annotation, + Descr: priorStateData.Descr, + FromCard: priorStateData.FromCard, + FromPort: priorStateData.FromPort, + Name: priorStateData.Name, + NameAlias: priorStateData.NameAlias, + ToCard: priorStateData.ToCard, + ToPort: priorStateData.ToPort, + DeprecatedParentDn: priorStateData.ParentDn, + DeprecatedInfraRsAccBndlSubgrp: priorStateData.InfraRsAccBndlSubgrp, + } + + InfraRsAccBndlSubgrpObject := InfraRsAccBndlSubgrpInfraPortBlkResourceModel{ + Annotation: basetypes.NewStringNull(), + TDn: priorStateData.InfraRsAccBndlSubgrp, + TagAnnotation: basetypes.NewSetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: basetypes.NewSetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } + infraRsAccBndlSubgrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBndlSubgrpInfraPortBlkType, InfraRsAccBndlSubgrpObject) + upgradedStateData.InfraRsAccBndlSubgrp = infraRsAccBndlSubgrpObject + + upgradedStateData.TagAnnotation = types.SetNull( + types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": basetypes.StringType{}, + "value": basetypes.StringType{}, + }, + }, + ) + + upgradedStateData.TagTag = types.SetNull( + types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": basetypes.StringType{}, + "value": basetypes.StringType{}, + }, + }, + ) + + resp.Diagnostics.Append(resp.State.Set(ctx, upgradedStateData)...) + }, + }, + } +} + +func setInfraPortBlkLegacyAttributes(ctx context.Context, diags *diag.Diagnostics, data, staticData *InfraPortBlkResourceModel, classReadInfo []interface{}) { + data.DeprecatedParentDn = data.ParentDn + data.DeprecatedInfraRsAccBndlSubgrp = basetypes.NewStringNull() + + _, 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 == "infraRsAccBndlSubgrp" { + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "tDn" { + data.DeprecatedInfraRsAccBndlSubgrp = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + } + } + } + } +} + +func (r *InfraPortBlkResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData, configData *InfraPortBlkResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + resp.Diagnostics.Append(req.Config.Get(ctx, &configData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { + setInfraPortBlkId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "infraPortBlk", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + if !configData.InfraRsAccBndlSubgrp.IsNull() && stateData != nil { + if IsEmptySingleNestedAttribute(configData.InfraRsAccBndlSubgrp.Attributes()) { + InfraRsAccBndlSubgrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBndlSubgrpInfraPortBlkType, getEmptyInfraRsAccBndlSubgrpInfraPortBlkResourceModel()) + planData.InfraRsAccBndlSubgrp = InfraRsAccBndlSubgrpObject + } + } + + if !configData.DeprecatedParentDn.IsNull() { + planData.ParentDn = configData.DeprecatedParentDn + } + + if !configData.DeprecatedInfraRsAccBndlSubgrp.IsNull() { + var newAttributeValues InfraRsAccBndlSubgrpInfraPortBlkResourceModel + tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkValue, _ := types.SetValueFrom(ctx, TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkType, make([]TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel, 0)) + tagTagInfraRsAccBndlSubgrpInfraPortBlkValue, _ := types.SetValueFrom(ctx, TagTagInfraRsAccBndlSubgrpInfraPortBlkType, make([]TagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel, 0)) + annotationValue := planData.Annotation + if stateData != nil && !IsEmptySingleNestedAttribute(stateData.InfraRsAccBndlSubgrp.Attributes()) { + stateData.InfraRsAccBndlSubgrp.As(ctx, &newAttributeValues, basetypes.ObjectAsOptions{}) + annotationValue = newAttributeValues.Annotation + tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkValue = newAttributeValues.TagAnnotation + tagTagInfraRsAccBndlSubgrpInfraPortBlkValue = newAttributeValues.TagTag + } + InfraRsAccBndlSubgrp := InfraRsAccBndlSubgrpInfraPortBlkResourceModel{ + Annotation: annotationValue, + TDn: configData.DeprecatedInfraRsAccBndlSubgrp, + TagAnnotation: tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkValue, + TagTag: tagTagInfraRsAccBndlSubgrpInfraPortBlkValue, + } + InfraRsAccBndlSubgrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBndlSubgrpInfraPortBlkType, InfraRsAccBndlSubgrp) + planData.InfraRsAccBndlSubgrp = InfraRsAccBndlSubgrpObject + } + + // Workaround to compare the state with plan to avoid plan changes with only known after apply + if stateData != nil { + avoidInfraPortBlkPlanChangeForKnownAfterApplyOnly(ctx, planData, stateData, configData) + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func avoidInfraPortBlkPlanChangeForKnownAfterApplyOnly(ctx context.Context, planData, stateData, configData *InfraPortBlkResourceModel) { + // Set read-only and deprecated attributes in planData from stateData + if configData.DeprecatedParentDn.IsNull() { + planData.DeprecatedParentDn = stateData.DeprecatedParentDn + } + if configData.DeprecatedInfraRsAccBndlSubgrp.IsNull() { + planData.DeprecatedInfraRsAccBndlSubgrp = stateData.DeprecatedInfraRsAccBndlSubgrp + } + + // Compare the string representation of the planData and stateData because structs cannot be compared directly + if fmt.Sprintf("%s", planData) != fmt.Sprintf("%s", stateData) { + if configData.DeprecatedParentDn.IsNull() { + planData.DeprecatedParentDn = basetypes.NewStringUnknown() + } + if configData.DeprecatedInfraRsAccBndlSubgrp.IsNull() { + planData.DeprecatedInfraRsAccBndlSubgrp = basetypes.NewStringUnknown() + } + } +} + +func (r *InfraPortBlkResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_access_port_block") + resp.TypeName = req.ProviderTypeName + "_access_port_block" + tflog.Debug(ctx, "End metadata of resource: aci_access_port_block") +} + +func (r *InfraPortBlkResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_access_port_block") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The access_port_block resource for the 'infraPortBlk' class", + Version: 2, + + Attributes: map[string]schema.Attribute{ + // Deprecated attributes + "access_port_selector_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + DeprecationMessage: "Attribute 'access_port_selector_dn' is deprecated, please refer to 'parent_dn' instead. The attribute will be removed in the next major version of the provider.", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRoot("parent_dn"), + }...), + }, + }, + "relation_infra_rs_acc_bndl_subgrp": schema.StringAttribute{ + Optional: true, + Computed: true, + DeprecationMessage: "Attribute 'relation_infra_rs_acc_bndl_subgrp' is deprecated, please refer to 'relation_to_pc_vpc_override_policy' instead. The attribute will be removed in the next major version of the provider.", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRoot("relation_to_pc_vpc_override_policy"), + }...), + }, + }, + // End of deprecated attributes + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Access Port Block object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.AtLeastOneOf(path.Expressions{ + path.MatchRoot("access_port_selector_dn"), + }...), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Access Port Block object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Access Port Block object.`, + }, + "from_card": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The start of the line card range for the Access Port Block object.`, + }, + "from_port": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The start of the port range for the Access Port Block object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Access Port Block object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Access Port Block object.`, + }, + "to_card": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: ` The end of the line card range for the Access Port Block object.`, + }, + "to_port": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The end of the port range for the Access Port Block object.`, + }, + "relation_to_pc_vpc_override_policy": schema.SingleNestedAttribute{ + MarkdownDescription: `A source relation to the access bundle subgroup.`, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Relation To Pc Vpc Override Policy object.`, + }, + "target_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name (DN) of the target PC VPC Override Policy.`, + }, + "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.`, + }, + }, + }, + }, + }, + }, + "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.`, + }, + }, + }, + }, + }, + Blocks: map[string]schema.Block{}, + } + tflog.Debug(ctx, "End schema of resource: aci_access_port_block") +} + +func (r *InfraPortBlkResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_access_port_block") + // 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_access_port_block") +} + +func (r *InfraPortBlkResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_access_port_block") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraPortBlkResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setInfraPortBlkId(ctx, stateData) + } + getAndSetInfraPortBlkAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The infraPortBlk object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *InfraPortBlkResourceModel + + // 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() { + setInfraPortBlkId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_access_port_block with id '%s'", data.Id.ValueString())) + + var infraRsAccBndlSubgrpPlan, infraRsAccBndlSubgrpState InfraRsAccBndlSubgrpInfraPortBlkResourceModel + data.InfraRsAccBndlSubgrp.As(ctx, &infraRsAccBndlSubgrpPlan, basetypes.ObjectAsOptions{}) + stateData.InfraRsAccBndlSubgrp.As(ctx, &infraRsAccBndlSubgrpState, basetypes.ObjectAsOptions{}) + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraPortBlkResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraPortBlkResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraPortBlkCreateJsonPayload(ctx, &resp.Diagnostics, true, data, infraRsAccBndlSubgrpPlan, infraRsAccBndlSubgrpState, 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 + } + + getAndSetInfraPortBlkAttributes(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_access_port_block with id '%s'", data.Id.ValueString())) +} + +func (r *InfraPortBlkResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_access_port_block") + var data *InfraPortBlkResourceModel + + // 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_access_port_block with id '%s'", data.Id.ValueString())) + + getAndSetInfraPortBlkAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraPortBlkResourceModel + 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_access_port_block with id '%s'", data.Id.ValueString())) +} + +func (r *InfraPortBlkResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_access_port_block") + var data *InfraPortBlkResourceModel + var stateData *InfraPortBlkResourceModel + + // 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_access_port_block with id '%s'", data.Id.ValueString())) + + var infraRsAccBndlSubgrpPlan, infraRsAccBndlSubgrpState InfraRsAccBndlSubgrpInfraPortBlkResourceModel + data.InfraRsAccBndlSubgrp.As(ctx, &infraRsAccBndlSubgrpPlan, basetypes.ObjectAsOptions{}) + stateData.InfraRsAccBndlSubgrp.As(ctx, &infraRsAccBndlSubgrpState, basetypes.ObjectAsOptions{}) + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraPortBlkResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraPortBlkResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraPortBlkCreateJsonPayload(ctx, &resp.Diagnostics, false, data, infraRsAccBndlSubgrpPlan, infraRsAccBndlSubgrpState, 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 + } + + getAndSetInfraPortBlkAttributes(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_access_port_block with id '%s'", data.Id.ValueString())) +} + +func (r *InfraPortBlkResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_access_port_block") + var data *InfraPortBlkResourceModel + + // 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_access_port_block with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraPortBlk", 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_access_port_block with id '%s'", data.Id.ValueString())) +} + +func (r *InfraPortBlkResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_access_port_block") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraPortBlkResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_access_port_block with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_access_port_block") +} + +func getAndSetInfraPortBlkAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraPortBlkResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraPortBlk,infraRsAccBndlSubgrp,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyInfraPortBlkResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraPortBlk").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraPortBlk").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + readData.Id = basetypes.NewStringValue(attributeValue.(string)) + setInfraPortBlkParentDn(ctx, attributeValue.(string), readData) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "fromCard" { + readData.FromCard = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "fromPort" { + readData.FromPort = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "toCard" { + readData.ToCard = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "toPort" { + readData.ToPort = basetypes.NewStringValue(attributeValue.(string)) + } + } + InfraRsAccBndlSubgrpInfraPortBlkList := make([]InfraRsAccBndlSubgrpInfraPortBlkResourceModel, 0) + TagAnnotationInfraPortBlkList := make([]TagAnnotationInfraPortBlkResourceModel, 0) + TagTagInfraPortBlkList := make([]TagTagInfraPortBlkResourceModel, 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 == "infraRsAccBndlSubgrp" { + InfraRsAccBndlSubgrpInfraPortBlk := getEmptyInfraRsAccBndlSubgrpInfraPortBlkResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + InfraRsAccBndlSubgrpInfraPortBlk.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + InfraRsAccBndlSubgrpInfraPortBlk.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkList := make([]TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel, 0) + TagTagInfraRsAccBndlSubgrpInfraPortBlkList := make([]TagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel, 0) + childrenOfInfraRsAccBndlSubgrpInfraPortBlk, childrenOfInfraRsAccBndlSubgrpInfraPortBlkExist := childClassDetails.(map[string]interface{})["children"] + if childrenOfInfraRsAccBndlSubgrpInfraPortBlkExist { + for _, childInfraRsAccBndlSubgrpInfraPortBlk := range childrenOfInfraRsAccBndlSubgrpInfraPortBlk.([]interface{}) { + for childClassNameInfraRsAccBndlSubgrpInfraPortBlk, childClassDetailsInfraRsAccBndlSubgrpInfraPortBlk := range childInfraRsAccBndlSubgrpInfraPortBlk.(map[string]interface{}) { + if childClassNameInfraRsAccBndlSubgrpInfraPortBlk == "tagAnnotation" { + TagAnnotationInfraRsAccBndlSubgrpInfraPortBlk := getEmptyTagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel() + tagAnnotationchildAttributeValue := childClassDetailsInfraRsAccBndlSubgrpInfraPortBlk.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue { + if childAttributeName == "key" { + TagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkList = append(TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkList, TagAnnotationInfraRsAccBndlSubgrpInfraPortBlk) + } + if childClassNameInfraRsAccBndlSubgrpInfraPortBlk == "tagTag" { + TagTagInfraRsAccBndlSubgrpInfraPortBlk := getEmptyTagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel() + tagTagchildAttributeValue := childClassDetailsInfraRsAccBndlSubgrpInfraPortBlk.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagTagchildAttributeValue { + if childAttributeName == "key" { + TagTagInfraRsAccBndlSubgrpInfraPortBlk.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraRsAccBndlSubgrpInfraPortBlk.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagInfraRsAccBndlSubgrpInfraPortBlkList = append(TagTagInfraRsAccBndlSubgrpInfraPortBlkList, TagTagInfraRsAccBndlSubgrpInfraPortBlk) + } + } + } + } + TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkSet, _ := types.SetValueFrom(ctx, TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkType, TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkList) + InfraRsAccBndlSubgrpInfraPortBlk.TagAnnotation = TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkSet + TagTagInfraRsAccBndlSubgrpInfraPortBlkSet, _ := types.SetValueFrom(ctx, TagTagInfraRsAccBndlSubgrpInfraPortBlkType, TagTagInfraRsAccBndlSubgrpInfraPortBlkList) + InfraRsAccBndlSubgrpInfraPortBlk.TagTag = TagTagInfraRsAccBndlSubgrpInfraPortBlkSet + InfraRsAccBndlSubgrpInfraPortBlkList = append(InfraRsAccBndlSubgrpInfraPortBlkList, InfraRsAccBndlSubgrpInfraPortBlk) + } + if childClassName == "tagAnnotation" { + TagAnnotationInfraPortBlk := getEmptyTagAnnotationInfraPortBlkResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraPortBlk.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraPortBlk.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraPortBlkList = append(TagAnnotationInfraPortBlkList, TagAnnotationInfraPortBlk) + } + if childClassName == "tagTag" { + TagTagInfraPortBlk := getEmptyTagTagInfraPortBlkResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraPortBlk.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraPortBlk.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagInfraPortBlkList = append(TagTagInfraPortBlkList, TagTagInfraPortBlk) + } + } + } + } + if len(InfraRsAccBndlSubgrpInfraPortBlkList) == 1 { + infraRsAccBndlSubgrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBndlSubgrpInfraPortBlkType, InfraRsAccBndlSubgrpInfraPortBlkList[0]) + readData.InfraRsAccBndlSubgrp = infraRsAccBndlSubgrpObject + } else { + infraRsAccBndlSubgrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBndlSubgrpInfraPortBlkType, getEmptyInfraRsAccBndlSubgrpInfraPortBlkResourceModel()) + readData.InfraRsAccBndlSubgrp = infraRsAccBndlSubgrpObject + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationInfraPortBlkList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagInfraPortBlkList) + readData.TagTag = tagTagSet + setInfraPortBlkLegacyAttributes(ctx, diags, readData, data, classReadInfo) + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraPortBlk'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getInfraPortBlkRn(ctx context.Context, data *InfraPortBlkResourceModel) string { + return fmt.Sprintf("portblk-%s", data.Name.ValueString()) +} + +func setInfraPortBlkParentDn(ctx context.Context, dn string, data *InfraPortBlkResourceModel) { + 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 setInfraPortBlkId(ctx context.Context, data *InfraPortBlkResourceModel) { + rn := getInfraPortBlkRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraPortBlkInfraRsAccBndlSubgrpChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraPortBlkResourceModel, infraRsAccBndlSubgrpInfraPortBlkPlan, infraRsAccBndlSubgrpInfraPortBlkState InfraRsAccBndlSubgrpInfraPortBlkResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.InfraRsAccBndlSubgrp.IsNull() && !data.InfraRsAccBndlSubgrp.IsUnknown() { + InfraRsAccBndlSubgrpInfraPortBlkChildren := make([]map[string]interface{}, 0) + childMap := NewAciObject() + if !IsEmptySingleNestedAttribute(data.InfraRsAccBndlSubgrp.Attributes()) { + if !infraRsAccBndlSubgrpInfraPortBlkPlan.Annotation.IsUnknown() && !infraRsAccBndlSubgrpInfraPortBlkPlan.Annotation.IsNull() { + childMap.Attributes["annotation"] = infraRsAccBndlSubgrpInfraPortBlkPlan.Annotation.ValueString() + } else { + childMap.Attributes["annotation"] = globalAnnotation + } + if !infraRsAccBndlSubgrpInfraPortBlkPlan.TDn.IsUnknown() && !infraRsAccBndlSubgrpInfraPortBlkPlan.TDn.IsNull() { + childMap.Attributes["tDn"] = infraRsAccBndlSubgrpInfraPortBlkPlan.TDn.ValueString() + } + + var tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkPlan, tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkState []TagAnnotationInfraRsAccBndlSubgrpInfraPortBlkResourceModel + infraRsAccBndlSubgrpInfraPortBlkPlan.TagAnnotation.ElementsAs(ctx, &tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkPlan, false) + if !infraRsAccBndlSubgrpInfraPortBlkState.TagAnnotation.IsNull() { + infraRsAccBndlSubgrpInfraPortBlkState.TagAnnotation.ElementsAs(ctx, &tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkState, false) + } + if !infraRsAccBndlSubgrpInfraPortBlkPlan.TagAnnotation.IsNull() && !infraRsAccBndlSubgrpInfraPortBlkPlan.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk := range tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkPlan { + tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkChildMap := NewAciObject() + if !tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Key.IsNull() && !tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Key.IsUnknown() { + tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkChildMap.Attributes["key"] = tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Key.ValueString() + } + if !tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Value.IsNull() && !tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Value.IsUnknown() { + tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkChildMap.Attributes["value"] = tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Value.ValueString() + } + InfraRsAccBndlSubgrpInfraPortBlkChildren = append(InfraRsAccBndlSubgrpInfraPortBlkChildren, map[string]interface{}{"tagAnnotation": tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkChildMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk := range tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Key { + delete = false + break + } + } + if delete { + tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkChildMapForDelete := NewAciObject() + tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkChildMapForDelete.Attributes["key"] = tagAnnotationInfraRsAccBndlSubgrpInfraPortBlk.Key.ValueString() + InfraRsAccBndlSubgrpInfraPortBlkChildren = append(InfraRsAccBndlSubgrpInfraPortBlkChildren, map[string]interface{}{"tagAnnotation": tagAnnotationInfraRsAccBndlSubgrpInfraPortBlkChildMapForDelete}) + } + } + } + + var tagTagInfraRsAccBndlSubgrpInfraPortBlkPlan, tagTagInfraRsAccBndlSubgrpInfraPortBlkState []TagTagInfraRsAccBndlSubgrpInfraPortBlkResourceModel + infraRsAccBndlSubgrpInfraPortBlkPlan.TagTag.ElementsAs(ctx, &tagTagInfraRsAccBndlSubgrpInfraPortBlkPlan, false) + if !infraRsAccBndlSubgrpInfraPortBlkState.TagTag.IsNull() { + infraRsAccBndlSubgrpInfraPortBlkState.TagTag.ElementsAs(ctx, &tagTagInfraRsAccBndlSubgrpInfraPortBlkState, false) + } + if !infraRsAccBndlSubgrpInfraPortBlkPlan.TagTag.IsNull() && !infraRsAccBndlSubgrpInfraPortBlkPlan.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraRsAccBndlSubgrpInfraPortBlk := range tagTagInfraRsAccBndlSubgrpInfraPortBlkPlan { + tagTagInfraRsAccBndlSubgrpInfraPortBlkChildMap := NewAciObject() + if !tagTagInfraRsAccBndlSubgrpInfraPortBlk.Key.IsNull() && !tagTagInfraRsAccBndlSubgrpInfraPortBlk.Key.IsUnknown() { + tagTagInfraRsAccBndlSubgrpInfraPortBlkChildMap.Attributes["key"] = tagTagInfraRsAccBndlSubgrpInfraPortBlk.Key.ValueString() + } + if !tagTagInfraRsAccBndlSubgrpInfraPortBlk.Value.IsNull() && !tagTagInfraRsAccBndlSubgrpInfraPortBlk.Value.IsUnknown() { + tagTagInfraRsAccBndlSubgrpInfraPortBlkChildMap.Attributes["value"] = tagTagInfraRsAccBndlSubgrpInfraPortBlk.Value.ValueString() + } + InfraRsAccBndlSubgrpInfraPortBlkChildren = append(InfraRsAccBndlSubgrpInfraPortBlkChildren, map[string]interface{}{"tagTag": tagTagInfraRsAccBndlSubgrpInfraPortBlkChildMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraRsAccBndlSubgrpInfraPortBlk.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTagInfraRsAccBndlSubgrpInfraPortBlk := range tagTagInfraRsAccBndlSubgrpInfraPortBlkState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTagInfraRsAccBndlSubgrpInfraPortBlk.Key { + delete = false + break + } + } + if delete { + tagTagInfraRsAccBndlSubgrpInfraPortBlkChildMapForDelete := NewAciObject() + tagTagInfraRsAccBndlSubgrpInfraPortBlkChildMapForDelete.Attributes["status"] = "deleted" + tagTagInfraRsAccBndlSubgrpInfraPortBlkChildMapForDelete.Attributes["key"] = tagTagInfraRsAccBndlSubgrpInfraPortBlk.Key.ValueString() + InfraRsAccBndlSubgrpInfraPortBlkChildren = append(InfraRsAccBndlSubgrpInfraPortBlkChildren, map[string]interface{}{"tagTag": tagTagInfraRsAccBndlSubgrpInfraPortBlkChildMapForDelete}) + } + } + } + childMap.Children = InfraRsAccBndlSubgrpInfraPortBlkChildren + } else { + childMap.Attributes["status"] = "deleted" + } + childPayloads = append(childPayloads, map[string]interface{}{"infraRsAccBndlSubgrp": childMap}) + } else { + InfraRsAccBndlSubgrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBndlSubgrpInfraPortBlkType, getEmptyInfraRsAccBndlSubgrpInfraPortBlkResourceModel()) + data.InfraRsAccBndlSubgrp = InfraRsAccBndlSubgrpObject + } + + return childPayloads +} + +func getInfraPortBlkTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraPortBlkResourceModel, tagAnnotationInfraPortBlkPlan, tagAnnotationInfraPortBlkState []TagAnnotationInfraPortBlkResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraPortBlk := range tagAnnotationInfraPortBlkPlan { + childMap := NewAciObject() + if !tagAnnotationInfraPortBlk.Key.IsNull() && !tagAnnotationInfraPortBlk.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationInfraPortBlk.Key.ValueString() + } + if !tagAnnotationInfraPortBlk.Value.IsNull() && !tagAnnotationInfraPortBlk.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationInfraPortBlk.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraPortBlk.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationInfraPortBlkState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + tagAnnotationChildMapForDelete := NewAciObject() + tagAnnotationChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraPortBlkTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraPortBlkResourceModel, tagTagInfraPortBlkPlan, tagTagInfraPortBlkState []TagTagInfraPortBlkResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraPortBlk := range tagTagInfraPortBlkPlan { + childMap := NewAciObject() + if !tagTagInfraPortBlk.Key.IsNull() && !tagTagInfraPortBlk.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagInfraPortBlk.Key.ValueString() + } + if !tagTagInfraPortBlk.Value.IsNull() && !tagTagInfraPortBlk.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagInfraPortBlk.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraPortBlk.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagInfraPortBlkState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + tagTagChildMapForDelete := NewAciObject() + tagTagChildMapForDelete.Attributes["status"] = "deleted" + tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraPortBlkCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraPortBlkResourceModel, infraRsAccBndlSubgrpPlan, infraRsAccBndlSubgrpState InfraRsAccBndlSubgrpInfraPortBlkResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraPortBlkResourceModel, tagTagPlan, tagTagState []TagTagInfraPortBlkResourceModel) *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{}{} + + InfraRsAccBndlSubgrpchildPayloads := getInfraPortBlkInfraRsAccBndlSubgrpChildPayloads(ctx, diags, data, infraRsAccBndlSubgrpPlan, infraRsAccBndlSubgrpState) + if InfraRsAccBndlSubgrpchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, InfraRsAccBndlSubgrpchildPayloads...) + + TagAnnotationchildPayloads := getInfraPortBlkTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraPortBlkTagTagChildPayloads(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.FromCard.IsNull() && !data.FromCard.IsUnknown() { + payloadMap["attributes"].(map[string]string)["fromCard"] = data.FromCard.ValueString() + } + if !data.FromPort.IsNull() && !data.FromPort.IsUnknown() { + payloadMap["attributes"].(map[string]string)["fromPort"] = data.FromPort.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.ToCard.IsNull() && !data.ToCard.IsUnknown() { + payloadMap["attributes"].(map[string]string)["toCard"] = data.ToCard.ValueString() + } + if !data.ToPort.IsNull() && !data.ToPort.IsUnknown() { + payloadMap["attributes"].(map[string]string)["toPort"] = data.ToPort.ValueString() + } + payload, err := json.Marshal(map[string]interface{}{"infraPortBlk": 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_access_port_block_test.go b/internal/provider/resource_aci_access_port_block_test.go new file mode 100644 index 000000000..076729a39 --- /dev/null +++ b/internal/provider/resource_aci_access_port_block_test.go @@ -0,0 +1,846 @@ +// 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" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" +) + +func TestAccResourceInfraPortBlkWithInfraHPortS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraPortBlkMinDependencyWithInfraHPortSAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "to_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "to_port", "1"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraPortBlkMinDependencyWithInfraHPortSAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraPortBlkMinDependencyWithInfraHPortSAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "to_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "to_port", "1"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraPortBlkMinDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_port", "1"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraPortBlkAllDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_card", "2"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_port", "3"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_card", "4"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_port", "5"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraPortBlkMinDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraPortBlkResetDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_port", "1"), + ), + }, + // Import testing + { + ResourceName: "aci_access_port_block.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraPortBlkChildrenDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.target_dn", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.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_access_port_block.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigInfraPortBlkChildrenRemoveFromConfigDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.target_dn", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraPortBlkChildrenRemoveOneDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.#", "1"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_access_port_block.test", + tfjsonpath.New("relation_to_pc_vpc_override_policy"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with all children removed + { + Config: testConfigInfraPortBlkChildrenRemoveAllDependencyWithInfraHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.#", "0"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_access_port_block.test", + tfjsonpath.New("relation_to_pc_vpc_override_policy"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with legacy attribute config + { + Config: testConfigInfraPortBlkLegacyAttributesWithInfraHPortS, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with legacy attribute config + { + Config: testConfigInfraPortBlkLegacyAttributesWithInfraHPortS, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} +func TestAccResourceInfraPortBlkWithInfraSHPortS(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraPortBlkMinDependencyWithInfraSHPortSAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "to_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "to_port", "1"), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraPortBlkMinDependencyWithInfraSHPortSAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraPortBlkMinDependencyWithInfraSHPortSAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test", "to_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.allow_test_2", "to_port", "1"), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraPortBlkMinDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_port", "1"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraPortBlkAllDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_card", "2"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_port", "3"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_card", "4"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_port", "5"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraPortBlkMinDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraPortBlkResetDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_port", "1"), + ), + }, + // Import testing + { + ResourceName: "aci_access_port_block.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraPortBlkChildrenDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "from_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_card", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "to_port", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.target_dn", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.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_access_port_block.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigInfraPortBlkChildrenRemoveFromConfigDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.tags.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "relation_to_pc_vpc_override_policy.target_dn", ""), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraPortBlkChildrenRemoveOneDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.#", "1"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_access_port_block.test", + tfjsonpath.New("relation_to_pc_vpc_override_policy"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with all children removed + { + Config: testConfigInfraPortBlkChildrenRemoveAllDependencyWithInfraSHPortS, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_block.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_access_port_block.test", "tags.#", "0"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_access_port_block.test", + tfjsonpath.New("relation_to_pc_vpc_override_policy"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with legacy attribute config + { + Config: testConfigInfraPortBlkLegacyAttributesWithInfraSHPortS, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with legacy attribute config + { + Config: testConfigInfraPortBlkLegacyAttributesWithInfraSHPortS, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testConfigInfraPortBlkMinDependencyWithInfraHPortSAllowExisting = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "allow_test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" +} +resource "aci_access_port_block" "allow_test_2" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" + depends_on = [aci_access_port_block.allow_test] +} +` + +const testConfigInfraPortBlkMinDependencyWithInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" +} +` + +const testConfigInfraPortBlkAllDependencyWithInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" + annotation = "annotation" + description = "description_1" + from_card = "2" + from_port = "3" + name_alias = "name_alias_1" + to_card = "4" + to_port = "5" +} +` + +const testConfigInfraPortBlkResetDependencyWithInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" + annotation = "orchestrator:terraform" + description = "" + from_card = "1" + from_port = "1" + name_alias = "" + to_card = "1" + to_port = "1" +} +` +const testConfigInfraPortBlkChildrenDependencyWithInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_pc_vpc_override_policy = { + annotation = "annotation_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" + }, + ] + target_dn = "" + } + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraPortBlkChildrenRemoveFromConfigDependencyWithInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" +} +` + +const testConfigInfraPortBlkChildrenRemoveOneDependencyWithInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_pc_vpc_override_policy = {} + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraPortBlkChildrenRemoveAllDependencyWithInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_access_port_selector.test.id + name = "test_name" + annotations = [] + relation_to_pc_vpc_override_policy = {} + tags = [] +} +` + +const testConfigInfraPortBlkLegacyAttributesWithInfraHPortS = testConfigInfraHPortSMinDependencyWithInfraAccPortP + ` +resource "aci_access_port_block" "test" { + name = "test_name" + access_port_selector_dn = aci_access_port_selector.test.id + relation_infra_rs_acc_bndl_subgrp = "" +} +` + +const testConfigInfraPortBlkMinDependencyWithInfraSHPortSAllowExisting = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "allow_test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" +} +resource "aci_access_port_block" "allow_test_2" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" + depends_on = [aci_access_port_block.allow_test] +} +` + +const testConfigInfraPortBlkMinDependencyWithInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" +} +` + +const testConfigInfraPortBlkAllDependencyWithInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" + annotation = "annotation" + description = "description_1" + from_card = "2" + from_port = "3" + name_alias = "name_alias_1" + to_card = "4" + to_port = "5" +} +` + +const testConfigInfraPortBlkResetDependencyWithInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" + annotation = "orchestrator:terraform" + description = "" + from_card = "1" + from_port = "1" + name_alias = "" + to_card = "1" + to_port = "1" +} +` +const testConfigInfraPortBlkChildrenDependencyWithInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_pc_vpc_override_policy = { + annotation = "annotation_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" + }, + ] + target_dn = "" + } + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraPortBlkChildrenRemoveFromConfigDependencyWithInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" +} +` + +const testConfigInfraPortBlkChildrenRemoveOneDependencyWithInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_pc_vpc_override_policy = {} + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraPortBlkChildrenRemoveAllDependencyWithInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "test" { + parent_dn = aci_spine_access_port_selector.test.id + name = "test_name" + annotations = [] + relation_to_pc_vpc_override_policy = {} + tags = [] +} +` + +const testConfigInfraPortBlkLegacyAttributesWithInfraSHPortS = testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP + ` +resource "aci_access_port_block" "test" { + name = "test_name" + access_port_selector_dn = aci_access_port_selector.test.id + relation_infra_rs_acc_bndl_subgrp = "" +} +` diff --git a/internal/provider/resource_aci_access_port_selector.go b/internal/provider/resource_aci_access_port_selector.go new file mode 100644 index 000000000..57cb10b8d --- /dev/null +++ b/internal/provider/resource_aci_access_port_selector.go @@ -0,0 +1,1371 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-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/objectplanmodifier" + "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 = &InfraHPortSResource{} +var _ resource.ResourceWithImportState = &InfraHPortSResource{} + +func NewInfraHPortSResource() resource.Resource { + return &InfraHPortSResource{} +} + +// InfraHPortSResource defines the resource implementation. +type InfraHPortSResource struct { + client *client.Client +} + +// InfraHPortSResourceModel describes the resource data model. +type InfraHPortSResourceModel 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"` + Type types.String `tfsdk:"port_selector_type"` + InfraRsAccBaseGrp types.Object `tfsdk:"relation_to_leaf_access_port_policy_group"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` + DeprecatedParentDn types.String `tfsdk:"leaf_interface_profile_dn"` + DeprecatedType types.String `tfsdk:"access_port_selector_type"` + DeprecatedInfraRsAccBaseGrp types.String `tfsdk:"relation_infra_rs_acc_base_grp"` +} + +func getEmptyInfraHPortSResourceModel() *InfraHPortSResourceModel { + return &InfraHPortSResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + Type: basetypes.NewStringNull(), + InfraRsAccBaseGrp: types.ObjectNull(map[string]attr.Type{ + "annotation": types.StringType, + "fex_id": types.StringType, + "target_dn": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationInfraRsAccBaseGrpInfraHPortSType}, + "tags": types.SetType{ElemType: TagTagInfraRsAccBaseGrpInfraHPortSType}, + }), + 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, + }, + }), + DeprecatedParentDn: types.String{}, + DeprecatedType: types.String{}, + DeprecatedInfraRsAccBaseGrp: types.String{}, + } +} + +// InfraRsAccBaseGrpInfraHPortSResourceModel describes the resource data model for the children without relation ships. +type InfraRsAccBaseGrpInfraHPortSResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + FexId types.String `tfsdk:"fex_id"` + TDn types.String `tfsdk:"target_dn"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyInfraRsAccBaseGrpInfraHPortSResourceModel() InfraRsAccBaseGrpInfraHPortSResourceModel { + return InfraRsAccBaseGrpInfraHPortSResourceModel{ + Annotation: basetypes.NewStringNull(), + FexId: 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, + }, + }), + } +} + +var InfraRsAccBaseGrpInfraHPortSType = map[string]attr.Type{ + "annotation": types.StringType, + "fex_id": types.StringType, + "target_dn": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationInfraRsAccBaseGrpInfraHPortSType}, + "tags": types.SetType{ElemType: TagTagInfraRsAccBaseGrpInfraHPortSType}, +} + +// TagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel() TagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel { + return TagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraRsAccBaseGrpInfraHPortSType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraRsAccBaseGrpInfraHPortSResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraRsAccBaseGrpInfraHPortSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraRsAccBaseGrpInfraHPortSResourceModel() TagTagInfraRsAccBaseGrpInfraHPortSResourceModel { + return TagTagInfraRsAccBaseGrpInfraHPortSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraRsAccBaseGrpInfraHPortSType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagAnnotationInfraHPortSResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraHPortSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraHPortSResourceModel() TagAnnotationInfraHPortSResourceModel { + return TagAnnotationInfraHPortSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraHPortSType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraHPortSResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraHPortSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraHPortSResourceModel() TagTagInfraHPortSResourceModel { + return TagTagInfraHPortSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraHPortSType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type InfraHPortSIdentifier struct { + Name types.String + Type types.String +} + +type InfraHPortSResourceModelV1 struct { + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Id types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + ParentDn types.String `tfsdk:"leaf_interface_profile_dn"` + Type types.String `tfsdk:"access_port_selector_type"` + InfraRsAccBaseGrp types.String `tfsdk:"relation_infra_rs_acc_base_grp"` +} + +func (r *InfraHPortSResource) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { + return map[int64]resource.StateUpgrader{ + 1: { + PriorSchema: &schema.Schema{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "description": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "id": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "name": schema.StringAttribute{ + Required: true, + Optional: false, + Computed: false, + }, + "name_alias": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "leaf_interface_profile_dn": schema.StringAttribute{ + Required: true, + Optional: false, + Computed: false, + }, + "access_port_selector_type": schema.StringAttribute{ + Required: true, + Optional: false, + Computed: false, + }, + "relation_infra_rs_acc_base_grp": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: false, + }, + }, + Blocks: map[string]schema.Block{}, + }, + StateUpgrader: func(ctx context.Context, req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) { + var priorStateData InfraHPortSResourceModelV1 + + resp.Diagnostics.Append(req.State.Get(ctx, &priorStateData)...) + + if resp.Diagnostics.HasError() { + return + } + + upgradedStateData := InfraHPortSResourceModel{ + Id: priorStateData.Id, + ParentDn: priorStateData.ParentDn, + Annotation: priorStateData.Annotation, + Descr: priorStateData.Descr, + Name: priorStateData.Name, + NameAlias: priorStateData.NameAlias, + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + Type: priorStateData.Type, + DeprecatedParentDn: priorStateData.ParentDn, + DeprecatedType: priorStateData.Type, + DeprecatedInfraRsAccBaseGrp: priorStateData.InfraRsAccBaseGrp, + } + + InfraRsAccBaseGrpObject := InfraRsAccBaseGrpInfraHPortSResourceModel{ + Annotation: basetypes.NewStringNull(), + FexId: basetypes.NewStringNull(), + TDn: priorStateData.InfraRsAccBaseGrp, + TagAnnotation: basetypes.NewSetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: basetypes.NewSetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } + infraRsAccBaseGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBaseGrpInfraHPortSType, InfraRsAccBaseGrpObject) + upgradedStateData.InfraRsAccBaseGrp = infraRsAccBaseGrpObject + + upgradedStateData.TagAnnotation = types.SetNull( + types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": basetypes.StringType{}, + "value": basetypes.StringType{}, + }, + }, + ) + + upgradedStateData.TagTag = types.SetNull( + types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": basetypes.StringType{}, + "value": basetypes.StringType{}, + }, + }, + ) + + resp.Diagnostics.Append(resp.State.Set(ctx, upgradedStateData)...) + }, + }, + } +} + +func setInfraHPortSLegacyAttributes(ctx context.Context, diags *diag.Diagnostics, data, staticData *InfraHPortSResourceModel, classReadInfo []interface{}) { + data.DeprecatedParentDn = data.ParentDn + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "type" { + data.DeprecatedType = basetypes.NewStringValue(attributeValue.(string)) + } + } + data.DeprecatedInfraRsAccBaseGrp = basetypes.NewStringNull() + + _, 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 == "infraRsAccBaseGrp" { + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "tDn" { + data.DeprecatedInfraRsAccBaseGrp = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + } + } + } + } +} + +func (r *InfraHPortSResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData, configData *InfraHPortSResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + resp.Diagnostics.Append(req.Config.Get(ctx, &configData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() && !planData.Type.IsUnknown() { + setInfraHPortSId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "infraHPortS", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + if !configData.InfraRsAccBaseGrp.IsNull() && stateData != nil { + if IsEmptySingleNestedAttribute(configData.InfraRsAccBaseGrp.Attributes()) { + InfraRsAccBaseGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBaseGrpInfraHPortSType, getEmptyInfraRsAccBaseGrpInfraHPortSResourceModel()) + planData.InfraRsAccBaseGrp = InfraRsAccBaseGrpObject + } + } + + if !configData.DeprecatedParentDn.IsNull() { + planData.ParentDn = configData.DeprecatedParentDn + } + + if !configData.DeprecatedType.IsNull() { + planData.Type = configData.DeprecatedType + } + + if !configData.DeprecatedInfraRsAccBaseGrp.IsNull() { + var newAttributeValues InfraRsAccBaseGrpInfraHPortSResourceModel + tagAnnotationInfraRsAccBaseGrpInfraHPortSValue, _ := types.SetValueFrom(ctx, TagAnnotationInfraRsAccBaseGrpInfraHPortSType, make([]TagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel, 0)) + tagTagInfraRsAccBaseGrpInfraHPortSValue, _ := types.SetValueFrom(ctx, TagTagInfraRsAccBaseGrpInfraHPortSType, make([]TagTagInfraRsAccBaseGrpInfraHPortSResourceModel, 0)) + annotationValue := planData.Annotation + fexIdValue := basetypes.NewStringUnknown() + if stateData != nil && !IsEmptySingleNestedAttribute(stateData.InfraRsAccBaseGrp.Attributes()) { + stateData.InfraRsAccBaseGrp.As(ctx, &newAttributeValues, basetypes.ObjectAsOptions{}) + annotationValue = newAttributeValues.Annotation + fexIdValue = newAttributeValues.FexId + tagAnnotationInfraRsAccBaseGrpInfraHPortSValue = newAttributeValues.TagAnnotation + tagTagInfraRsAccBaseGrpInfraHPortSValue = newAttributeValues.TagTag + } + InfraRsAccBaseGrp := InfraRsAccBaseGrpInfraHPortSResourceModel{ + Annotation: annotationValue, + FexId: fexIdValue, + TDn: configData.DeprecatedInfraRsAccBaseGrp, + TagAnnotation: tagAnnotationInfraRsAccBaseGrpInfraHPortSValue, + TagTag: tagTagInfraRsAccBaseGrpInfraHPortSValue, + } + InfraRsAccBaseGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBaseGrpInfraHPortSType, InfraRsAccBaseGrp) + planData.InfraRsAccBaseGrp = InfraRsAccBaseGrpObject + } + + // Workaround to compare the state with plan to avoid plan changes with only known after apply + if stateData != nil { + avoidInfraHPortSPlanChangeForKnownAfterApplyOnly(ctx, planData, stateData, configData) + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func avoidInfraHPortSPlanChangeForKnownAfterApplyOnly(ctx context.Context, planData, stateData, configData *InfraHPortSResourceModel) { + // Set read-only and deprecated attributes in planData from stateData + if configData.DeprecatedParentDn.IsNull() { + planData.DeprecatedParentDn = stateData.DeprecatedParentDn + } + if configData.DeprecatedType.IsNull() { + planData.DeprecatedType = stateData.DeprecatedType + } + if configData.DeprecatedInfraRsAccBaseGrp.IsNull() { + planData.DeprecatedInfraRsAccBaseGrp = stateData.DeprecatedInfraRsAccBaseGrp + } + + // Compare the string representation of the planData and stateData because structs cannot be compared directly + if fmt.Sprintf("%s", planData) != fmt.Sprintf("%s", stateData) { + if configData.DeprecatedParentDn.IsNull() { + planData.DeprecatedParentDn = basetypes.NewStringUnknown() + } + if configData.DeprecatedType.IsNull() { + planData.DeprecatedType = basetypes.NewStringUnknown() + } + if configData.DeprecatedInfraRsAccBaseGrp.IsNull() { + planData.DeprecatedInfraRsAccBaseGrp = basetypes.NewStringUnknown() + } + } +} + +func (r *InfraHPortSResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_access_port_selector") + resp.TypeName = req.ProviderTypeName + "_access_port_selector" + tflog.Debug(ctx, "End metadata of resource: aci_access_port_selector") +} + +func (r *InfraHPortSResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_access_port_selector") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The access_port_selector resource for the 'infraHPortS' class", + Version: 2, + + Attributes: map[string]schema.Attribute{ + // Deprecated attributes + "leaf_interface_profile_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + DeprecationMessage: "Attribute 'leaf_interface_profile_dn' is deprecated, please refer to 'parent_dn' instead. The attribute will be removed in the next major version of the provider.", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRoot("parent_dn"), + }...), + }, + }, + "access_port_selector_type": schema.StringAttribute{ + Optional: true, + Computed: true, + DeprecationMessage: "Attribute 'access_port_selector_type' is deprecated, please refer to 'port_selector_type' instead. The attribute will be removed in the next major version of the provider.", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRoot("port_selector_type"), + }...), + }, + }, + "relation_infra_rs_acc_base_grp": schema.StringAttribute{ + Optional: true, + Computed: true, + DeprecationMessage: "Attribute 'relation_infra_rs_acc_base_grp' is deprecated, please refer to 'relation_to_leaf_access_port_policy_group' instead. The attribute will be removed in the next major version of the provider.", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRoot("relation_to_leaf_access_port_policy_group"), + }...), + }, + }, + // End of deprecated attributes + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Access Port Selector object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.AtLeastOneOf(path.Expressions{ + path.MatchRoot("leaf_interface_profile_dn"), + }...), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Access Port Selector object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Access Port Selector object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Access Port Selector object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Access Port Selector object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "port_selector_type": schema.StringAttribute{ + Optional: true, + Computed: true, + + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("ALL", "range"), + stringvalidator.AtLeastOneOf(path.Expressions{ + path.MatchRoot("access_port_selector_type"), + }...), + }, + MarkdownDescription: `The port selector type of the Access Port Selector object.`, + }, + "relation_to_leaf_access_port_policy_group": schema.SingleNestedAttribute{ + MarkdownDescription: `A source relation to the access policy group providing port configuration.`, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Relation To Leaf Access Port Policy Group object.`, + }, + "fex_id": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The interface policy group FEX ID.`, + }, + "target_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `Select or create an interface policy group to associate to the Access Port selector.`, + }, + "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.`, + }, + }, + }, + }, + }, + }, + "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.`, + }, + }, + }, + }, + }, + Blocks: map[string]schema.Block{}, + } + tflog.Debug(ctx, "End schema of resource: aci_access_port_selector") +} + +func (r *InfraHPortSResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_access_port_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_access_port_selector") +} + +func (r *InfraHPortSResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_access_port_selector") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraHPortSResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setInfraHPortSId(ctx, stateData) + } + getAndSetInfraHPortSAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The infraHPortS object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *InfraHPortSResourceModel + + // 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() { + setInfraHPortSId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_access_port_selector with id '%s'", data.Id.ValueString())) + + var infraRsAccBaseGrpPlan, infraRsAccBaseGrpState InfraRsAccBaseGrpInfraHPortSResourceModel + data.InfraRsAccBaseGrp.As(ctx, &infraRsAccBaseGrpPlan, basetypes.ObjectAsOptions{}) + stateData.InfraRsAccBaseGrp.As(ctx, &infraRsAccBaseGrpState, basetypes.ObjectAsOptions{}) + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPortSResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraHPortSResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraHPortSCreateJsonPayload(ctx, &resp.Diagnostics, true, data, infraRsAccBaseGrpPlan, infraRsAccBaseGrpState, 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 + } + + getAndSetInfraHPortSAttributes(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_access_port_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPortSResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_access_port_selector") + var data *InfraHPortSResourceModel + + // 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_access_port_selector with id '%s'", data.Id.ValueString())) + + getAndSetInfraHPortSAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraHPortSResourceModel + 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_access_port_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPortSResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_access_port_selector") + var data *InfraHPortSResourceModel + var stateData *InfraHPortSResourceModel + + // 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_access_port_selector with id '%s'", data.Id.ValueString())) + + var infraRsAccBaseGrpPlan, infraRsAccBaseGrpState InfraRsAccBaseGrpInfraHPortSResourceModel + data.InfraRsAccBaseGrp.As(ctx, &infraRsAccBaseGrpPlan, basetypes.ObjectAsOptions{}) + stateData.InfraRsAccBaseGrp.As(ctx, &infraRsAccBaseGrpState, basetypes.ObjectAsOptions{}) + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPortSResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraHPortSResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraHPortSCreateJsonPayload(ctx, &resp.Diagnostics, false, data, infraRsAccBaseGrpPlan, infraRsAccBaseGrpState, 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 + } + + getAndSetInfraHPortSAttributes(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_access_port_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPortSResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_access_port_selector") + var data *InfraHPortSResourceModel + + // 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_access_port_selector with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraHPortS", 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_access_port_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraHPortSResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_access_port_selector") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraHPortSResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_access_port_selector with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_access_port_selector") +} + +func getAndSetInfraHPortSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraHPortSResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraHPortS,infraRsAccBaseGrp,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyInfraHPortSResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraHPortS").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraHPortS").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + readData.Id = basetypes.NewStringValue(attributeValue.(string)) + setInfraHPortSParentDn(ctx, attributeValue.(string), readData) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + readData.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + readData.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "type" { + readData.Type = basetypes.NewStringValue(attributeValue.(string)) + } + } + InfraRsAccBaseGrpInfraHPortSList := make([]InfraRsAccBaseGrpInfraHPortSResourceModel, 0) + TagAnnotationInfraHPortSList := make([]TagAnnotationInfraHPortSResourceModel, 0) + TagTagInfraHPortSList := make([]TagTagInfraHPortSResourceModel, 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 == "infraRsAccBaseGrp" { + InfraRsAccBaseGrpInfraHPortS := getEmptyInfraRsAccBaseGrpInfraHPortSResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + InfraRsAccBaseGrpInfraHPortS.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "fexId" { + InfraRsAccBaseGrpInfraHPortS.FexId = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + InfraRsAccBaseGrpInfraHPortS.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraRsAccBaseGrpInfraHPortSList := make([]TagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel, 0) + TagTagInfraRsAccBaseGrpInfraHPortSList := make([]TagTagInfraRsAccBaseGrpInfraHPortSResourceModel, 0) + childrenOfInfraRsAccBaseGrpInfraHPortS, childrenOfInfraRsAccBaseGrpInfraHPortSExist := childClassDetails.(map[string]interface{})["children"] + if childrenOfInfraRsAccBaseGrpInfraHPortSExist { + for _, childInfraRsAccBaseGrpInfraHPortS := range childrenOfInfraRsAccBaseGrpInfraHPortS.([]interface{}) { + for childClassNameInfraRsAccBaseGrpInfraHPortS, childClassDetailsInfraRsAccBaseGrpInfraHPortS := range childInfraRsAccBaseGrpInfraHPortS.(map[string]interface{}) { + if childClassNameInfraRsAccBaseGrpInfraHPortS == "tagAnnotation" { + TagAnnotationInfraRsAccBaseGrpInfraHPortS := getEmptyTagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel() + tagAnnotationchildAttributeValue := childClassDetailsInfraRsAccBaseGrpInfraHPortS.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue { + if childAttributeName == "key" { + TagAnnotationInfraRsAccBaseGrpInfraHPortS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraRsAccBaseGrpInfraHPortS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationInfraRsAccBaseGrpInfraHPortSList = append(TagAnnotationInfraRsAccBaseGrpInfraHPortSList, TagAnnotationInfraRsAccBaseGrpInfraHPortS) + } + if childClassNameInfraRsAccBaseGrpInfraHPortS == "tagTag" { + TagTagInfraRsAccBaseGrpInfraHPortS := getEmptyTagTagInfraRsAccBaseGrpInfraHPortSResourceModel() + tagTagchildAttributeValue := childClassDetailsInfraRsAccBaseGrpInfraHPortS.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagTagchildAttributeValue { + if childAttributeName == "key" { + TagTagInfraRsAccBaseGrpInfraHPortS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraRsAccBaseGrpInfraHPortS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagInfraRsAccBaseGrpInfraHPortSList = append(TagTagInfraRsAccBaseGrpInfraHPortSList, TagTagInfraRsAccBaseGrpInfraHPortS) + } + } + } + } + TagAnnotationInfraRsAccBaseGrpInfraHPortSSet, _ := types.SetValueFrom(ctx, TagAnnotationInfraRsAccBaseGrpInfraHPortSType, TagAnnotationInfraRsAccBaseGrpInfraHPortSList) + InfraRsAccBaseGrpInfraHPortS.TagAnnotation = TagAnnotationInfraRsAccBaseGrpInfraHPortSSet + TagTagInfraRsAccBaseGrpInfraHPortSSet, _ := types.SetValueFrom(ctx, TagTagInfraRsAccBaseGrpInfraHPortSType, TagTagInfraRsAccBaseGrpInfraHPortSList) + InfraRsAccBaseGrpInfraHPortS.TagTag = TagTagInfraRsAccBaseGrpInfraHPortSSet + InfraRsAccBaseGrpInfraHPortSList = append(InfraRsAccBaseGrpInfraHPortSList, InfraRsAccBaseGrpInfraHPortS) + } + if childClassName == "tagAnnotation" { + TagAnnotationInfraHPortS := getEmptyTagAnnotationInfraHPortSResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraHPortS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraHPortS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraHPortSList = append(TagAnnotationInfraHPortSList, TagAnnotationInfraHPortS) + } + if childClassName == "tagTag" { + TagTagInfraHPortS := getEmptyTagTagInfraHPortSResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraHPortS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraHPortS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagInfraHPortSList = append(TagTagInfraHPortSList, TagTagInfraHPortS) + } + } + } + } + if len(InfraRsAccBaseGrpInfraHPortSList) == 1 { + infraRsAccBaseGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBaseGrpInfraHPortSType, InfraRsAccBaseGrpInfraHPortSList[0]) + readData.InfraRsAccBaseGrp = infraRsAccBaseGrpObject + } else { + infraRsAccBaseGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBaseGrpInfraHPortSType, getEmptyInfraRsAccBaseGrpInfraHPortSResourceModel()) + readData.InfraRsAccBaseGrp = infraRsAccBaseGrpObject + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationInfraHPortSList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagInfraHPortSList) + readData.TagTag = tagTagSet + setInfraHPortSLegacyAttributes(ctx, diags, readData, data, classReadInfo) + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraHPortS'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getInfraHPortSRn(ctx context.Context, data *InfraHPortSResourceModel) string { + return fmt.Sprintf("hports-%s-typ-%s", data.Name.ValueString(), data.Type.ValueString()) +} + +func setInfraHPortSParentDn(ctx context.Context, dn string, data *InfraHPortSResourceModel) { + 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 setInfraHPortSId(ctx context.Context, data *InfraHPortSResourceModel) { + rn := getInfraHPortSRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraHPortSInfraRsAccBaseGrpChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPortSResourceModel, infraRsAccBaseGrpInfraHPortSPlan, infraRsAccBaseGrpInfraHPortSState InfraRsAccBaseGrpInfraHPortSResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.InfraRsAccBaseGrp.IsNull() && !data.InfraRsAccBaseGrp.IsUnknown() { + InfraRsAccBaseGrpInfraHPortSChildren := make([]map[string]interface{}, 0) + childMap := NewAciObject() + if !IsEmptySingleNestedAttribute(data.InfraRsAccBaseGrp.Attributes()) { + if !infraRsAccBaseGrpInfraHPortSPlan.Annotation.IsUnknown() && !infraRsAccBaseGrpInfraHPortSPlan.Annotation.IsNull() { + childMap.Attributes["annotation"] = infraRsAccBaseGrpInfraHPortSPlan.Annotation.ValueString() + } else { + childMap.Attributes["annotation"] = globalAnnotation + } + if !infraRsAccBaseGrpInfraHPortSPlan.FexId.IsUnknown() && !infraRsAccBaseGrpInfraHPortSPlan.FexId.IsNull() { + childMap.Attributes["fexId"] = infraRsAccBaseGrpInfraHPortSPlan.FexId.ValueString() + } + if !infraRsAccBaseGrpInfraHPortSPlan.TDn.IsUnknown() && !infraRsAccBaseGrpInfraHPortSPlan.TDn.IsNull() { + childMap.Attributes["tDn"] = infraRsAccBaseGrpInfraHPortSPlan.TDn.ValueString() + } + + var tagAnnotationInfraRsAccBaseGrpInfraHPortSPlan, tagAnnotationInfraRsAccBaseGrpInfraHPortSState []TagAnnotationInfraRsAccBaseGrpInfraHPortSResourceModel + infraRsAccBaseGrpInfraHPortSPlan.TagAnnotation.ElementsAs(ctx, &tagAnnotationInfraRsAccBaseGrpInfraHPortSPlan, false) + if !infraRsAccBaseGrpInfraHPortSState.TagAnnotation.IsNull() { + infraRsAccBaseGrpInfraHPortSState.TagAnnotation.ElementsAs(ctx, &tagAnnotationInfraRsAccBaseGrpInfraHPortSState, false) + } + if !infraRsAccBaseGrpInfraHPortSPlan.TagAnnotation.IsNull() && !infraRsAccBaseGrpInfraHPortSPlan.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraRsAccBaseGrpInfraHPortS := range tagAnnotationInfraRsAccBaseGrpInfraHPortSPlan { + tagAnnotationInfraRsAccBaseGrpInfraHPortSChildMap := NewAciObject() + if !tagAnnotationInfraRsAccBaseGrpInfraHPortS.Key.IsNull() && !tagAnnotationInfraRsAccBaseGrpInfraHPortS.Key.IsUnknown() { + tagAnnotationInfraRsAccBaseGrpInfraHPortSChildMap.Attributes["key"] = tagAnnotationInfraRsAccBaseGrpInfraHPortS.Key.ValueString() + } + if !tagAnnotationInfraRsAccBaseGrpInfraHPortS.Value.IsNull() && !tagAnnotationInfraRsAccBaseGrpInfraHPortS.Value.IsUnknown() { + tagAnnotationInfraRsAccBaseGrpInfraHPortSChildMap.Attributes["value"] = tagAnnotationInfraRsAccBaseGrpInfraHPortS.Value.ValueString() + } + InfraRsAccBaseGrpInfraHPortSChildren = append(InfraRsAccBaseGrpInfraHPortSChildren, map[string]interface{}{"tagAnnotation": tagAnnotationInfraRsAccBaseGrpInfraHPortSChildMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraRsAccBaseGrpInfraHPortS.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotationInfraRsAccBaseGrpInfraHPortS := range tagAnnotationInfraRsAccBaseGrpInfraHPortSState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotationInfraRsAccBaseGrpInfraHPortS.Key { + delete = false + break + } + } + if delete { + tagAnnotationInfraRsAccBaseGrpInfraHPortSChildMapForDelete := NewAciObject() + tagAnnotationInfraRsAccBaseGrpInfraHPortSChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationInfraRsAccBaseGrpInfraHPortSChildMapForDelete.Attributes["key"] = tagAnnotationInfraRsAccBaseGrpInfraHPortS.Key.ValueString() + InfraRsAccBaseGrpInfraHPortSChildren = append(InfraRsAccBaseGrpInfraHPortSChildren, map[string]interface{}{"tagAnnotation": tagAnnotationInfraRsAccBaseGrpInfraHPortSChildMapForDelete}) + } + } + } + + var tagTagInfraRsAccBaseGrpInfraHPortSPlan, tagTagInfraRsAccBaseGrpInfraHPortSState []TagTagInfraRsAccBaseGrpInfraHPortSResourceModel + infraRsAccBaseGrpInfraHPortSPlan.TagTag.ElementsAs(ctx, &tagTagInfraRsAccBaseGrpInfraHPortSPlan, false) + if !infraRsAccBaseGrpInfraHPortSState.TagTag.IsNull() { + infraRsAccBaseGrpInfraHPortSState.TagTag.ElementsAs(ctx, &tagTagInfraRsAccBaseGrpInfraHPortSState, false) + } + if !infraRsAccBaseGrpInfraHPortSPlan.TagTag.IsNull() && !infraRsAccBaseGrpInfraHPortSPlan.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraRsAccBaseGrpInfraHPortS := range tagTagInfraRsAccBaseGrpInfraHPortSPlan { + tagTagInfraRsAccBaseGrpInfraHPortSChildMap := NewAciObject() + if !tagTagInfraRsAccBaseGrpInfraHPortS.Key.IsNull() && !tagTagInfraRsAccBaseGrpInfraHPortS.Key.IsUnknown() { + tagTagInfraRsAccBaseGrpInfraHPortSChildMap.Attributes["key"] = tagTagInfraRsAccBaseGrpInfraHPortS.Key.ValueString() + } + if !tagTagInfraRsAccBaseGrpInfraHPortS.Value.IsNull() && !tagTagInfraRsAccBaseGrpInfraHPortS.Value.IsUnknown() { + tagTagInfraRsAccBaseGrpInfraHPortSChildMap.Attributes["value"] = tagTagInfraRsAccBaseGrpInfraHPortS.Value.ValueString() + } + InfraRsAccBaseGrpInfraHPortSChildren = append(InfraRsAccBaseGrpInfraHPortSChildren, map[string]interface{}{"tagTag": tagTagInfraRsAccBaseGrpInfraHPortSChildMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraRsAccBaseGrpInfraHPortS.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTagInfraRsAccBaseGrpInfraHPortS := range tagTagInfraRsAccBaseGrpInfraHPortSState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTagInfraRsAccBaseGrpInfraHPortS.Key { + delete = false + break + } + } + if delete { + tagTagInfraRsAccBaseGrpInfraHPortSChildMapForDelete := NewAciObject() + tagTagInfraRsAccBaseGrpInfraHPortSChildMapForDelete.Attributes["status"] = "deleted" + tagTagInfraRsAccBaseGrpInfraHPortSChildMapForDelete.Attributes["key"] = tagTagInfraRsAccBaseGrpInfraHPortS.Key.ValueString() + InfraRsAccBaseGrpInfraHPortSChildren = append(InfraRsAccBaseGrpInfraHPortSChildren, map[string]interface{}{"tagTag": tagTagInfraRsAccBaseGrpInfraHPortSChildMapForDelete}) + } + } + } + childMap.Children = InfraRsAccBaseGrpInfraHPortSChildren + } else { + childMap.Attributes["status"] = "deleted" + } + childPayloads = append(childPayloads, map[string]interface{}{"infraRsAccBaseGrp": childMap}) + } else { + InfraRsAccBaseGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsAccBaseGrpInfraHPortSType, getEmptyInfraRsAccBaseGrpInfraHPortSResourceModel()) + data.InfraRsAccBaseGrp = InfraRsAccBaseGrpObject + } + + return childPayloads +} + +func getInfraHPortSTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPortSResourceModel, tagAnnotationInfraHPortSPlan, tagAnnotationInfraHPortSState []TagAnnotationInfraHPortSResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraHPortS := range tagAnnotationInfraHPortSPlan { + childMap := NewAciObject() + if !tagAnnotationInfraHPortS.Key.IsNull() && !tagAnnotationInfraHPortS.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationInfraHPortS.Key.ValueString() + } + if !tagAnnotationInfraHPortS.Value.IsNull() && !tagAnnotationInfraHPortS.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationInfraHPortS.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraHPortS.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationInfraHPortSState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + tagAnnotationChildMapForDelete := NewAciObject() + tagAnnotationChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraHPortSTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraHPortSResourceModel, tagTagInfraHPortSPlan, tagTagInfraHPortSState []TagTagInfraHPortSResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraHPortS := range tagTagInfraHPortSPlan { + childMap := NewAciObject() + if !tagTagInfraHPortS.Key.IsNull() && !tagTagInfraHPortS.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagInfraHPortS.Key.ValueString() + } + if !tagTagInfraHPortS.Value.IsNull() && !tagTagInfraHPortS.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagInfraHPortS.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraHPortS.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagInfraHPortSState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + tagTagChildMapForDelete := NewAciObject() + tagTagChildMapForDelete.Attributes["status"] = "deleted" + tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraHPortSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraHPortSResourceModel, infraRsAccBaseGrpPlan, infraRsAccBaseGrpState InfraRsAccBaseGrpInfraHPortSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPortSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPortSResourceModel) *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{}{} + + InfraRsAccBaseGrpchildPayloads := getInfraHPortSInfraRsAccBaseGrpChildPayloads(ctx, diags, data, infraRsAccBaseGrpPlan, infraRsAccBaseGrpState) + if InfraRsAccBaseGrpchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, InfraRsAccBaseGrpchildPayloads...) + + TagAnnotationchildPayloads := getInfraHPortSTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraHPortSTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + if !data.OwnerKey.IsNull() && !data.OwnerKey.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerKey"] = data.OwnerKey.ValueString() + } + if !data.OwnerTag.IsNull() && !data.OwnerTag.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerTag"] = data.OwnerTag.ValueString() + } + if !data.Type.IsNull() && !data.Type.IsUnknown() { + payloadMap["attributes"].(map[string]string)["type"] = data.Type.ValueString() + } + payload, err := json.Marshal(map[string]interface{}{"infraHPortS": 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_access_port_selector_test.go b/internal/provider/resource_aci_access_port_selector_test.go new file mode 100644 index 000000000..e6ef72997 --- /dev/null +++ b/internal/provider/resource_aci_access_port_selector_test.go @@ -0,0 +1,860 @@ +// 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" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" +) + +func TestAccResourceInfraHPortSWithInfraAccPortP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPortSMinDependencyWithInfraAccPortPAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPortSMinDependencyWithInfraAccPortPAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPortSMinDependencyWithInfraAccPortPAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPortSMinDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraHPortSAllDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraHPortSMinDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraHPortSResetDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_access_port_selector.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraHPortSChildrenDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.fex_id", "102"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.target_dn", "uni/infra/funcprof/accportgrp-leaf_access_port_policy_group_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.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_access_port_selector.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigInfraHPortSChildrenRemoveFromConfigDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.fex_id", "102"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.target_dn", "uni/infra/funcprof/accportgrp-leaf_access_port_policy_group_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraHPortSChildrenRemoveOneDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.#", "1"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_access_port_selector.test", + tfjsonpath.New("relation_to_leaf_access_port_policy_group"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "fex_id": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with all children removed + { + Config: testConfigInfraHPortSChildrenRemoveAllDependencyWithInfraAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.#", "0"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_access_port_selector.test", + tfjsonpath.New("relation_to_leaf_access_port_policy_group"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "fex_id": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with legacy attribute config + { + Config: testConfigInfraHPortSLegacyAttributesWithInfraAccPortP, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with legacy attribute config + { + Config: testConfigInfraHPortSLegacyAttributesWithInfraAccPortP, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} +func TestAccResourceInfraHPortSWithInfraFexP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPortSMinDependencyWithInfraFexPAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPortSMinDependencyWithInfraFexPAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPortSMinDependencyWithInfraFexPAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraHPortSMinDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraHPortSAllDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraHPortSMinDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraHPortSResetDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_access_port_selector.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraHPortSChildrenDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "port_selector_type", "range"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.fex_id", "102"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.target_dn", "uni/infra/funcprof/accportgrp-leaf_access_port_policy_group_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.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_access_port_selector.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigInfraHPortSChildrenRemoveFromConfigDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.annotations.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.tags.#", "2"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.fex_id", "102"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "relation_to_leaf_access_port_policy_group.target_dn", "uni/infra/funcprof/accportgrp-leaf_access_port_policy_group_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraHPortSChildrenRemoveOneDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.#", "1"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_access_port_selector.test", + tfjsonpath.New("relation_to_leaf_access_port_policy_group"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "fex_id": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with all children removed + { + Config: testConfigInfraHPortSChildrenRemoveAllDependencyWithInfraFexP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_access_port_selector.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_access_port_selector.test", "tags.#", "0"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_access_port_selector.test", + tfjsonpath.New("relation_to_leaf_access_port_policy_group"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "fex_id": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with legacy attribute config + { + Config: testConfigInfraHPortSLegacyAttributesWithInfraFexP, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with legacy attribute config + { + Config: testConfigInfraHPortSLegacyAttributesWithInfraFexP, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testChildDependencyConfigInfraHPortS = ` +resource "aci_leaf_access_port_policy_group" "test_leaf_access_port_policy_group_0"{ + name = "leaf_access_port_policy_group_1" +} +` + +const testConfigInfraHPortSMinDependencyWithInfraAccPortPAllowExisting = testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "allow_test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" +} +resource "aci_access_port_selector" "allow_test_2" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" + depends_on = [aci_access_port_selector.allow_test] +} +` + +const testConfigInfraHPortSMinDependencyWithInfraAccPortP = testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" +} +` + +const testConfigInfraHPortSAllDependencyWithInfraAccPortP = testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" + annotation = "annotation" + description = "description_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" +} +` + +const testConfigInfraHPortSResetDependencyWithInfraAccPortP = testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraHPortSChildrenDependencyWithInfraAccPortP = testChildDependencyConfigInfraHPortS + testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_leaf_access_port_policy_group = { + annotation = "annotation_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" + }, + ] + fex_id = "102" + target_dn = aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id + } + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraHPortSChildrenRemoveFromConfigDependencyWithInfraAccPortP = testChildDependencyConfigInfraHPortS + testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" +} +` + +const testConfigInfraHPortSChildrenRemoveOneDependencyWithInfraAccPortP = testChildDependencyConfigInfraHPortS + testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_leaf_access_port_policy_group = {} + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraHPortSChildrenRemoveAllDependencyWithInfraAccPortP = testChildDependencyConfigInfraHPortS + testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_leaf_interface_profile.test.id + name = "test_name" + port_selector_type = "range" + annotations = [] + relation_to_leaf_access_port_policy_group = {} + tags = [] +} +` + +const testConfigInfraHPortSLegacyAttributesWithInfraAccPortP = testChildDependencyConfigInfraHPortS + testConfigInfraAccPortPMin + ` +resource "aci_access_port_selector" "test" { + name = "test_name" + access_port_selector_type = "range" + leaf_interface_profile_dn = aci_leaf_interface_profile.test.id + relation_infra_rs_acc_base_grp = aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id +} +` + +const testConfigInfraHPortSMinDependencyWithInfraFexPAllowExisting = testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "allow_test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" +} +resource "aci_access_port_selector" "allow_test_2" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" + depends_on = [aci_access_port_selector.allow_test] +} +` + +const testConfigInfraHPortSMinDependencyWithInfraFexP = testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" +} +` + +const testConfigInfraHPortSAllDependencyWithInfraFexP = testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" + annotation = "annotation" + description = "description_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" +} +` + +const testConfigInfraHPortSResetDependencyWithInfraFexP = testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraHPortSChildrenDependencyWithInfraFexP = testChildDependencyConfigInfraHPortS + testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_leaf_access_port_policy_group = { + annotation = "annotation_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" + }, + ] + fex_id = "102" + target_dn = aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id + } + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraHPortSChildrenRemoveFromConfigDependencyWithInfraFexP = testChildDependencyConfigInfraHPortS + testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" +} +` + +const testConfigInfraHPortSChildrenRemoveOneDependencyWithInfraFexP = testChildDependencyConfigInfraHPortS + testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_leaf_access_port_policy_group = {} + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraHPortSChildrenRemoveAllDependencyWithInfraFexP = testChildDependencyConfigInfraHPortS + testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "test" { + parent_dn = aci_fex_profile.test.id + name = "test_name" + port_selector_type = "range" + annotations = [] + relation_to_leaf_access_port_policy_group = {} + tags = [] +} +` + +const testConfigInfraHPortSLegacyAttributesWithInfraFexP = testChildDependencyConfigInfraHPortS + testConfigInfraFexPMin + ` +resource "aci_access_port_selector" "test" { + name = "test_name" + access_port_selector_type = "range" + leaf_interface_profile_dn = aci_leaf_interface_profile.test.id + relation_infra_rs_acc_base_grp = aci_leaf_access_port_policy_group.test_leaf_access_port_policy_group_0.id +} +` diff --git a/internal/provider/resource_aci_fex_profile.go b/internal/provider/resource_aci_fex_profile.go new file mode 100644 index 000000000..076765094 --- /dev/null +++ b/internal/provider/resource_aci_fex_profile.go @@ -0,0 +1,722 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/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 = &InfraFexPResource{} +var _ resource.ResourceWithImportState = &InfraFexPResource{} + +func NewInfraFexPResource() resource.Resource { + return &InfraFexPResource{} +} + +// InfraFexPResource defines the resource implementation. +type InfraFexPResource struct { + client *client.Client +} + +// InfraFexPResourceModel describes the resource data model. +type InfraFexPResourceModel 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"` +} + +func getEmptyInfraFexPResourceModel() *InfraFexPResourceModel { + return &InfraFexPResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: 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, + }, + }), + } +} + +// TagAnnotationInfraFexPResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraFexPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraFexPResourceModel() TagAnnotationInfraFexPResourceModel { + return TagAnnotationInfraFexPResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraFexPType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraFexPResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraFexPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraFexPResourceModel() TagTagInfraFexPResourceModel { + return TagTagInfraFexPResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraFexPType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type InfraFexPIdentifier struct { + Name types.String +} + +func (r *InfraFexPResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *InfraFexPResourceModel + 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.Name.IsUnknown() { + setInfraFexPId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "infraFexP", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *InfraFexPResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_fex_profile") + resp.TypeName = req.ProviderTypeName + "_fex_profile" + tflog.Debug(ctx, "End metadata of resource: aci_fex_profile") +} + +func (r *InfraFexPResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_fex_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The fex_profile resource for the 'infraFexP' class", + Version: 1, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the FEX Profile 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the FEX Profile object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the FEX Profile object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the FEX Profile object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the FEX Profile object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + 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_fex_profile") +} + +func (r *InfraFexPResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_fex_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_fex_profile") +} + +func (r *InfraFexPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_fex_profile") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraFexPResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setInfraFexPId(ctx, stateData) + } + getAndSetInfraFexPAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The infraFexP object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *InfraFexPResourceModel + + // 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() { + setInfraFexPId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_fex_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraFexPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraFexPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraFexPCreateJsonPayload(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 + } + + getAndSetInfraFexPAttributes(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_fex_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraFexPResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_fex_profile") + var data *InfraFexPResourceModel + + // 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_fex_profile with id '%s'", data.Id.ValueString())) + + getAndSetInfraFexPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraFexPResourceModel + 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_fex_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraFexPResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_fex_profile") + var data *InfraFexPResourceModel + var stateData *InfraFexPResourceModel + + // 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_fex_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraFexPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraFexPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraFexPCreateJsonPayload(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 + } + + getAndSetInfraFexPAttributes(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_fex_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraFexPResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_fex_profile") + var data *InfraFexPResourceModel + + // 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_fex_profile with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraFexP", 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_fex_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraFexPResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_fex_profile") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraFexPResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_fex_profile with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_fex_profile") +} + +func getAndSetInfraFexPAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraFexPResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraFexP,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyInfraFexPResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraFexP").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraFexP").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + readData.Id = basetypes.NewStringValue(attributeValue.(string)) + setInfraFexPParentDn(ctx, attributeValue.(string), readData) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + readData.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + readData.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationInfraFexPList := make([]TagAnnotationInfraFexPResourceModel, 0) + TagTagInfraFexPList := make([]TagTagInfraFexPResourceModel, 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" { + TagAnnotationInfraFexP := getEmptyTagAnnotationInfraFexPResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraFexP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraFexP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraFexPList = append(TagAnnotationInfraFexPList, TagAnnotationInfraFexP) + } + if childClassName == "tagTag" { + TagTagInfraFexP := getEmptyTagTagInfraFexPResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraFexP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraFexP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagInfraFexPList = append(TagTagInfraFexPList, TagTagInfraFexP) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationInfraFexPList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagInfraFexPList) + readData.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraFexP'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getInfraFexPRn(ctx context.Context, data *InfraFexPResourceModel) string { + return fmt.Sprintf("fexprof-%s", data.Name.ValueString()) +} + +func setInfraFexPParentDn(ctx context.Context, dn string, data *InfraFexPResourceModel) { + 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 setInfraFexPId(ctx context.Context, data *InfraFexPResourceModel) { + rn := getInfraFexPRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraFexPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraFexPResourceModel, tagAnnotationInfraFexPPlan, tagAnnotationInfraFexPState []TagAnnotationInfraFexPResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraFexP := range tagAnnotationInfraFexPPlan { + childMap := NewAciObject() + if !tagAnnotationInfraFexP.Key.IsNull() && !tagAnnotationInfraFexP.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationInfraFexP.Key.ValueString() + } + if !tagAnnotationInfraFexP.Value.IsNull() && !tagAnnotationInfraFexP.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationInfraFexP.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraFexP.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationInfraFexPState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + tagAnnotationChildMapForDelete := NewAciObject() + tagAnnotationChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraFexPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraFexPResourceModel, tagTagInfraFexPPlan, tagTagInfraFexPState []TagTagInfraFexPResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraFexP := range tagTagInfraFexPPlan { + childMap := NewAciObject() + if !tagTagInfraFexP.Key.IsNull() && !tagTagInfraFexP.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagInfraFexP.Key.ValueString() + } + if !tagTagInfraFexP.Value.IsNull() && !tagTagInfraFexP.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagInfraFexP.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraFexP.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagInfraFexPState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + tagTagChildMapForDelete := NewAciObject() + tagTagChildMapForDelete.Attributes["status"] = "deleted" + tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraFexPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraFexPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraFexPResourceModel, tagTagPlan, tagTagState []TagTagInfraFexPResourceModel) *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 := getInfraFexPTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraFexPTagTagChildPayloads(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{}{"infraFexP": 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_fex_profile_test.go b/internal/provider/resource_aci_fex_profile_test.go new file mode 100644 index 000000000..642d5b7ce --- /dev/null +++ b/internal/provider/resource_aci_fex_profile_test.go @@ -0,0 +1,308 @@ +// 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 TestAccResourceInfraFexP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraFexPMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraFexPMinAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraFexPMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_fex_profile.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraFexPMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraFexPAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraFexPMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraFexPReset, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_fex_profile.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraFexPChildren, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.#", "2"), + ), + }, + // Update with children removed from config + { + Config: testConfigInfraFexPChildrenRemoveFromConfig, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraFexPChildrenRemoveOne, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigInfraFexPChildrenRemoveAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_fex_profile.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_fex_profile.test", "tags.#", "0"), + ), + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testConfigInfraFexPMinAllowExisting = ` +resource "aci_fex_profile" "allow_test" { + name = "test_name" +} +resource "aci_fex_profile" "allow_test_2" { + name = "test_name" + depends_on = [aci_fex_profile.allow_test] +} +` + +const testConfigInfraFexPMin = ` +resource "aci_fex_profile" "test" { + name = "test_name" +} +` + +const testConfigInfraFexPAll = ` +resource "aci_fex_profile" "test" { + name = "test_name" + annotation = "annotation" + description = "description_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" +} +` + +const testConfigInfraFexPReset = ` +resource "aci_fex_profile" "test" { + name = "test_name" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraFexPChildren = ` +resource "aci_fex_profile" "test" { + name = "test_name" + 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 testConfigInfraFexPChildrenRemoveFromConfig = ` +resource "aci_fex_profile" "test" { + name = "test_name" +} +` + +const testConfigInfraFexPChildrenRemoveOne = ` +resource "aci_fex_profile" "test" { + name = "test_name" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraFexPChildrenRemoveAll = ` +resource "aci_fex_profile" "test" { + name = "test_name" + annotations = [] + tags = [] +} +` diff --git a/internal/provider/resource_aci_leaf_interface_profile.go b/internal/provider/resource_aci_leaf_interface_profile.go new file mode 100644 index 000000000..771862477 --- /dev/null +++ b/internal/provider/resource_aci_leaf_interface_profile.go @@ -0,0 +1,722 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/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 = &InfraAccPortPResource{} +var _ resource.ResourceWithImportState = &InfraAccPortPResource{} + +func NewInfraAccPortPResource() resource.Resource { + return &InfraAccPortPResource{} +} + +// InfraAccPortPResource defines the resource implementation. +type InfraAccPortPResource struct { + client *client.Client +} + +// InfraAccPortPResourceModel describes the resource data model. +type InfraAccPortPResourceModel 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"` +} + +func getEmptyInfraAccPortPResourceModel() *InfraAccPortPResourceModel { + return &InfraAccPortPResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: 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, + }, + }), + } +} + +// TagAnnotationInfraAccPortPResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraAccPortPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraAccPortPResourceModel() TagAnnotationInfraAccPortPResourceModel { + return TagAnnotationInfraAccPortPResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraAccPortPType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraAccPortPResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraAccPortPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraAccPortPResourceModel() TagTagInfraAccPortPResourceModel { + return TagTagInfraAccPortPResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraAccPortPType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type InfraAccPortPIdentifier struct { + Name types.String +} + +func (r *InfraAccPortPResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *InfraAccPortPResourceModel + 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.Name.IsUnknown() { + setInfraAccPortPId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "infraAccPortP", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *InfraAccPortPResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_leaf_interface_profile") + resp.TypeName = req.ProviderTypeName + "_leaf_interface_profile" + tflog.Debug(ctx, "End metadata of resource: aci_leaf_interface_profile") +} + +func (r *InfraAccPortPResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_leaf_interface_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The leaf_interface_profile resource for the 'infraAccPortP' class", + Version: 1, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Leaf Interface Profile 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Leaf Interface Profile object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Leaf Interface Profile object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Leaf Interface Profile object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Leaf Interface Profile object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + 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_leaf_interface_profile") +} + +func (r *InfraAccPortPResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_leaf_interface_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_leaf_interface_profile") +} + +func (r *InfraAccPortPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_leaf_interface_profile") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraAccPortPResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setInfraAccPortPId(ctx, stateData) + } + getAndSetInfraAccPortPAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The infraAccPortP object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *InfraAccPortPResourceModel + + // 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() { + setInfraAccPortPId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_leaf_interface_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraAccPortPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraAccPortPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraAccPortPCreateJsonPayload(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 + } + + getAndSetInfraAccPortPAttributes(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_leaf_interface_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraAccPortPResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_leaf_interface_profile") + var data *InfraAccPortPResourceModel + + // 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_leaf_interface_profile with id '%s'", data.Id.ValueString())) + + getAndSetInfraAccPortPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraAccPortPResourceModel + 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_leaf_interface_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraAccPortPResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_leaf_interface_profile") + var data *InfraAccPortPResourceModel + var stateData *InfraAccPortPResourceModel + + // 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_leaf_interface_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraAccPortPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraAccPortPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraAccPortPCreateJsonPayload(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 + } + + getAndSetInfraAccPortPAttributes(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_leaf_interface_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraAccPortPResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_leaf_interface_profile") + var data *InfraAccPortPResourceModel + + // 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_leaf_interface_profile with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraAccPortP", 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_leaf_interface_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraAccPortPResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_leaf_interface_profile") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraAccPortPResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_leaf_interface_profile with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_leaf_interface_profile") +} + +func getAndSetInfraAccPortPAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraAccPortPResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraAccPortP,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyInfraAccPortPResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraAccPortP").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraAccPortP").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + readData.Id = basetypes.NewStringValue(attributeValue.(string)) + setInfraAccPortPParentDn(ctx, attributeValue.(string), readData) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + readData.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + readData.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationInfraAccPortPList := make([]TagAnnotationInfraAccPortPResourceModel, 0) + TagTagInfraAccPortPList := make([]TagTagInfraAccPortPResourceModel, 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" { + TagAnnotationInfraAccPortP := getEmptyTagAnnotationInfraAccPortPResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraAccPortP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraAccPortP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraAccPortPList = append(TagAnnotationInfraAccPortPList, TagAnnotationInfraAccPortP) + } + if childClassName == "tagTag" { + TagTagInfraAccPortP := getEmptyTagTagInfraAccPortPResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraAccPortP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraAccPortP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagInfraAccPortPList = append(TagTagInfraAccPortPList, TagTagInfraAccPortP) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationInfraAccPortPList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagInfraAccPortPList) + readData.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraAccPortP'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getInfraAccPortPRn(ctx context.Context, data *InfraAccPortPResourceModel) string { + return fmt.Sprintf("accportprof-%s", data.Name.ValueString()) +} + +func setInfraAccPortPParentDn(ctx context.Context, dn string, data *InfraAccPortPResourceModel) { + 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 setInfraAccPortPId(ctx context.Context, data *InfraAccPortPResourceModel) { + rn := getInfraAccPortPRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraAccPortPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraAccPortPResourceModel, tagAnnotationInfraAccPortPPlan, tagAnnotationInfraAccPortPState []TagAnnotationInfraAccPortPResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraAccPortP := range tagAnnotationInfraAccPortPPlan { + childMap := NewAciObject() + if !tagAnnotationInfraAccPortP.Key.IsNull() && !tagAnnotationInfraAccPortP.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationInfraAccPortP.Key.ValueString() + } + if !tagAnnotationInfraAccPortP.Value.IsNull() && !tagAnnotationInfraAccPortP.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationInfraAccPortP.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraAccPortP.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationInfraAccPortPState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + tagAnnotationChildMapForDelete := NewAciObject() + tagAnnotationChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraAccPortPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraAccPortPResourceModel, tagTagInfraAccPortPPlan, tagTagInfraAccPortPState []TagTagInfraAccPortPResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraAccPortP := range tagTagInfraAccPortPPlan { + childMap := NewAciObject() + if !tagTagInfraAccPortP.Key.IsNull() && !tagTagInfraAccPortP.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagInfraAccPortP.Key.ValueString() + } + if !tagTagInfraAccPortP.Value.IsNull() && !tagTagInfraAccPortP.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagInfraAccPortP.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraAccPortP.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagInfraAccPortPState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + tagTagChildMapForDelete := NewAciObject() + tagTagChildMapForDelete.Attributes["status"] = "deleted" + tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraAccPortPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraAccPortPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraAccPortPResourceModel, tagTagPlan, tagTagState []TagTagInfraAccPortPResourceModel) *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 := getInfraAccPortPTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraAccPortPTagTagChildPayloads(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{}{"infraAccPortP": 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_leaf_interface_profile_test.go b/internal/provider/resource_aci_leaf_interface_profile_test.go new file mode 100644 index 000000000..9b8323df1 --- /dev/null +++ b/internal/provider/resource_aci_leaf_interface_profile_test.go @@ -0,0 +1,308 @@ +// 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 TestAccResourceInfraAccPortP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraAccPortPMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraAccPortPMinAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraAccPortPMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraAccPortPMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraAccPortPAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraAccPortPMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraAccPortPReset, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_leaf_interface_profile.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraAccPortPChildren, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.#", "2"), + ), + }, + // Update with children removed from config + { + Config: testConfigInfraAccPortPChildrenRemoveFromConfig, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraAccPortPChildrenRemoveOne, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigInfraAccPortPChildrenRemoveAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_leaf_interface_profile.test", "tags.#", "0"), + ), + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testConfigInfraAccPortPMinAllowExisting = ` +resource "aci_leaf_interface_profile" "allow_test" { + name = "test_name" +} +resource "aci_leaf_interface_profile" "allow_test_2" { + name = "test_name" + depends_on = [aci_leaf_interface_profile.allow_test] +} +` + +const testConfigInfraAccPortPMin = ` +resource "aci_leaf_interface_profile" "test" { + name = "test_name" +} +` + +const testConfigInfraAccPortPAll = ` +resource "aci_leaf_interface_profile" "test" { + name = "test_name" + annotation = "annotation" + description = "description_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" +} +` + +const testConfigInfraAccPortPReset = ` +resource "aci_leaf_interface_profile" "test" { + name = "test_name" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraAccPortPChildren = ` +resource "aci_leaf_interface_profile" "test" { + name = "test_name" + 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 testConfigInfraAccPortPChildrenRemoveFromConfig = ` +resource "aci_leaf_interface_profile" "test" { + name = "test_name" +} +` + +const testConfigInfraAccPortPChildrenRemoveOne = ` +resource "aci_leaf_interface_profile" "test" { + name = "test_name" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraAccPortPChildrenRemoveAll = ` +resource "aci_leaf_interface_profile" "test" { + name = "test_name" + annotations = [] + tags = [] +} +` diff --git a/internal/provider/resource_aci_spine_access_port_selector.go b/internal/provider/resource_aci_spine_access_port_selector.go new file mode 100644 index 000000000..e6f2dfa38 --- /dev/null +++ b/internal/provider/resource_aci_spine_access_port_selector.go @@ -0,0 +1,1349 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-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/objectplanmodifier" + "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 = &InfraSHPortSResource{} +var _ resource.ResourceWithImportState = &InfraSHPortSResource{} + +func NewInfraSHPortSResource() resource.Resource { + return &InfraSHPortSResource{} +} + +// InfraSHPortSResource defines the resource implementation. +type InfraSHPortSResource struct { + client *client.Client +} + +// InfraSHPortSResourceModel describes the resource data model. +type InfraSHPortSResourceModel 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"` + Type types.String `tfsdk:"port_selector_type"` + InfraRsSpAccGrp types.Object `tfsdk:"relation_to_spine_port_policy_group"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` + DeprecatedParentDn types.String `tfsdk:"spine_interface_profile_dn"` + DeprecatedType types.String `tfsdk:"spine_access_port_selector_type"` + DeprecatedInfraRsSpAccGrp types.String `tfsdk:"relation_infra_rs_sp_acc_grp"` +} + +func getEmptyInfraSHPortSResourceModel() *InfraSHPortSResourceModel { + return &InfraSHPortSResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + Type: basetypes.NewStringNull(), + InfraRsSpAccGrp: types.ObjectNull(map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationInfraRsSpAccGrpInfraSHPortSType}, + "tags": types.SetType{ElemType: TagTagInfraRsSpAccGrpInfraSHPortSType}, + }), + 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, + }, + }), + DeprecatedParentDn: types.String{}, + DeprecatedType: types.String{}, + DeprecatedInfraRsSpAccGrp: types.String{}, + } +} + +// InfraRsSpAccGrpInfraSHPortSResourceModel describes the resource data model for the children without relation ships. +type InfraRsSpAccGrpInfraSHPortSResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + TDn types.String `tfsdk:"target_dn"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +func getEmptyInfraRsSpAccGrpInfraSHPortSResourceModel() InfraRsSpAccGrpInfraSHPortSResourceModel { + return InfraRsSpAccGrpInfraSHPortSResourceModel{ + 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, + }, + }), + } +} + +var InfraRsSpAccGrpInfraSHPortSType = map[string]attr.Type{ + "annotation": types.StringType, + "target_dn": types.StringType, + "annotations": types.SetType{ElemType: TagAnnotationInfraRsSpAccGrpInfraSHPortSType}, + "tags": types.SetType{ElemType: TagTagInfraRsSpAccGrpInfraSHPortSType}, +} + +// TagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel() TagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel { + return TagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraRsSpAccGrpInfraSHPortSType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraRsSpAccGrpInfraSHPortSResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraRsSpAccGrpInfraSHPortSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraRsSpAccGrpInfraSHPortSResourceModel() TagTagInfraRsSpAccGrpInfraSHPortSResourceModel { + return TagTagInfraRsSpAccGrpInfraSHPortSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraRsSpAccGrpInfraSHPortSType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagAnnotationInfraSHPortSResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraSHPortSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraSHPortSResourceModel() TagAnnotationInfraSHPortSResourceModel { + return TagAnnotationInfraSHPortSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraSHPortSType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraSHPortSResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraSHPortSResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraSHPortSResourceModel() TagTagInfraSHPortSResourceModel { + return TagTagInfraSHPortSResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraSHPortSType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type InfraSHPortSIdentifier struct { + Name types.String + Type types.String +} + +type InfraSHPortSResourceModelV1 struct { + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + Id types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + ParentDn types.String `tfsdk:"spine_interface_profile_dn"` + Type types.String `tfsdk:"spine_access_port_selector_type"` + InfraRsSpAccGrp types.String `tfsdk:"relation_infra_rs_sp_acc_grp"` +} + +func (r *InfraSHPortSResource) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { + return map[int64]resource.StateUpgrader{ + 1: { + PriorSchema: &schema.Schema{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "description": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "id": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "name": schema.StringAttribute{ + Required: true, + Optional: false, + Computed: false, + }, + "name_alias": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: true, + }, + "spine_interface_profile_dn": schema.StringAttribute{ + Required: true, + Optional: false, + Computed: false, + }, + "spine_access_port_selector_type": schema.StringAttribute{ + Required: true, + Optional: false, + Computed: false, + }, + "relation_infra_rs_sp_acc_grp": schema.StringAttribute{ + Required: false, + Optional: true, + Computed: false, + }, + }, + Blocks: map[string]schema.Block{}, + }, + StateUpgrader: func(ctx context.Context, req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) { + var priorStateData InfraSHPortSResourceModelV1 + + resp.Diagnostics.Append(req.State.Get(ctx, &priorStateData)...) + + if resp.Diagnostics.HasError() { + return + } + + upgradedStateData := InfraSHPortSResourceModel{ + Id: priorStateData.Id, + ParentDn: priorStateData.ParentDn, + Annotation: priorStateData.Annotation, + Descr: priorStateData.Descr, + Name: priorStateData.Name, + NameAlias: priorStateData.NameAlias, + OwnerKey: basetypes.NewStringNull(), + OwnerTag: basetypes.NewStringNull(), + Type: priorStateData.Type, + DeprecatedParentDn: priorStateData.ParentDn, + DeprecatedType: priorStateData.Type, + DeprecatedInfraRsSpAccGrp: priorStateData.InfraRsSpAccGrp, + } + + InfraRsSpAccGrpObject := InfraRsSpAccGrpInfraSHPortSResourceModel{ + Annotation: basetypes.NewStringNull(), + TDn: priorStateData.InfraRsSpAccGrp, + TagAnnotation: basetypes.NewSetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + TagTag: basetypes.NewSetNull(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, + }), + } + infraRsSpAccGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsSpAccGrpInfraSHPortSType, InfraRsSpAccGrpObject) + upgradedStateData.InfraRsSpAccGrp = infraRsSpAccGrpObject + + upgradedStateData.TagAnnotation = types.SetNull( + types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": basetypes.StringType{}, + "value": basetypes.StringType{}, + }, + }, + ) + + upgradedStateData.TagTag = types.SetNull( + types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": basetypes.StringType{}, + "value": basetypes.StringType{}, + }, + }, + ) + + resp.Diagnostics.Append(resp.State.Set(ctx, upgradedStateData)...) + }, + }, + } +} + +func setInfraSHPortSLegacyAttributes(ctx context.Context, diags *diag.Diagnostics, data, staticData *InfraSHPortSResourceModel, classReadInfo []interface{}) { + data.DeprecatedParentDn = data.ParentDn + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "type" { + data.DeprecatedType = basetypes.NewStringValue(attributeValue.(string)) + } + } + data.DeprecatedInfraRsSpAccGrp = basetypes.NewStringNull() + + _, 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 == "infraRsSpAccGrp" { + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "tDn" { + data.DeprecatedInfraRsSpAccGrp = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + } + } + } + } +} + +func (r *InfraSHPortSResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData, configData *InfraSHPortSResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + resp.Diagnostics.Append(req.Config.Get(ctx, &configData)...) + + if resp.Diagnostics.HasError() { + return + } + + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() && !planData.Type.IsUnknown() { + setInfraSHPortSId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "infraSHPortS", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + if !configData.InfraRsSpAccGrp.IsNull() && stateData != nil { + if IsEmptySingleNestedAttribute(configData.InfraRsSpAccGrp.Attributes()) { + InfraRsSpAccGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsSpAccGrpInfraSHPortSType, getEmptyInfraRsSpAccGrpInfraSHPortSResourceModel()) + planData.InfraRsSpAccGrp = InfraRsSpAccGrpObject + } + } + + if !configData.DeprecatedParentDn.IsNull() { + planData.ParentDn = configData.DeprecatedParentDn + } + + if !configData.DeprecatedType.IsNull() { + planData.Type = configData.DeprecatedType + } + + if !configData.DeprecatedInfraRsSpAccGrp.IsNull() { + var newAttributeValues InfraRsSpAccGrpInfraSHPortSResourceModel + tagAnnotationInfraRsSpAccGrpInfraSHPortSValue, _ := types.SetValueFrom(ctx, TagAnnotationInfraRsSpAccGrpInfraSHPortSType, make([]TagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel, 0)) + tagTagInfraRsSpAccGrpInfraSHPortSValue, _ := types.SetValueFrom(ctx, TagTagInfraRsSpAccGrpInfraSHPortSType, make([]TagTagInfraRsSpAccGrpInfraSHPortSResourceModel, 0)) + annotationValue := planData.Annotation + if stateData != nil && !IsEmptySingleNestedAttribute(stateData.InfraRsSpAccGrp.Attributes()) { + stateData.InfraRsSpAccGrp.As(ctx, &newAttributeValues, basetypes.ObjectAsOptions{}) + annotationValue = newAttributeValues.Annotation + tagAnnotationInfraRsSpAccGrpInfraSHPortSValue = newAttributeValues.TagAnnotation + tagTagInfraRsSpAccGrpInfraSHPortSValue = newAttributeValues.TagTag + } + InfraRsSpAccGrp := InfraRsSpAccGrpInfraSHPortSResourceModel{ + Annotation: annotationValue, + TDn: configData.DeprecatedInfraRsSpAccGrp, + TagAnnotation: tagAnnotationInfraRsSpAccGrpInfraSHPortSValue, + TagTag: tagTagInfraRsSpAccGrpInfraSHPortSValue, + } + InfraRsSpAccGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsSpAccGrpInfraSHPortSType, InfraRsSpAccGrp) + planData.InfraRsSpAccGrp = InfraRsSpAccGrpObject + } + + // Workaround to compare the state with plan to avoid plan changes with only known after apply + if stateData != nil { + avoidInfraSHPortSPlanChangeForKnownAfterApplyOnly(ctx, planData, stateData, configData) + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func avoidInfraSHPortSPlanChangeForKnownAfterApplyOnly(ctx context.Context, planData, stateData, configData *InfraSHPortSResourceModel) { + // Set read-only and deprecated attributes in planData from stateData + if configData.DeprecatedParentDn.IsNull() { + planData.DeprecatedParentDn = stateData.DeprecatedParentDn + } + if configData.DeprecatedType.IsNull() { + planData.DeprecatedType = stateData.DeprecatedType + } + if configData.DeprecatedInfraRsSpAccGrp.IsNull() { + planData.DeprecatedInfraRsSpAccGrp = stateData.DeprecatedInfraRsSpAccGrp + } + + // Compare the string representation of the planData and stateData because structs cannot be compared directly + if fmt.Sprintf("%s", planData) != fmt.Sprintf("%s", stateData) { + if configData.DeprecatedParentDn.IsNull() { + planData.DeprecatedParentDn = basetypes.NewStringUnknown() + } + if configData.DeprecatedType.IsNull() { + planData.DeprecatedType = basetypes.NewStringUnknown() + } + if configData.DeprecatedInfraRsSpAccGrp.IsNull() { + planData.DeprecatedInfraRsSpAccGrp = basetypes.NewStringUnknown() + } + } +} + +func (r *InfraSHPortSResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_spine_access_port_selector") + resp.TypeName = req.ProviderTypeName + "_spine_access_port_selector" + tflog.Debug(ctx, "End metadata of resource: aci_spine_access_port_selector") +} + +func (r *InfraSHPortSResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_spine_access_port_selector") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The spine_access_port_selector resource for the 'infraSHPortS' class", + Version: 2, + + Attributes: map[string]schema.Attribute{ + // Deprecated attributes + "spine_interface_profile_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + DeprecationMessage: "Attribute 'spine_interface_profile_dn' is deprecated, please refer to 'parent_dn' instead. The attribute will be removed in the next major version of the provider.", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRoot("parent_dn"), + }...), + }, + }, + "spine_access_port_selector_type": schema.StringAttribute{ + Optional: true, + Computed: true, + DeprecationMessage: "Attribute 'spine_access_port_selector_type' is deprecated, please refer to 'port_selector_type' instead. The attribute will be removed in the next major version of the provider.", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRoot("port_selector_type"), + }...), + }, + }, + "relation_infra_rs_sp_acc_grp": schema.StringAttribute{ + Optional: true, + Computed: true, + DeprecationMessage: "Attribute 'relation_infra_rs_sp_acc_grp' is deprecated, please refer to 'relation_to_spine_port_policy_group' instead. The attribute will be removed in the next major version of the provider.", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRoot("relation_to_spine_port_policy_group"), + }...), + }, + }, + // End of deprecated attributes + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Spine Access Port Selector object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.AtLeastOneOf(path.Expressions{ + path.MatchRoot("spine_interface_profile_dn"), + }...), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Spine Access Port Selector object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Spine Access Port Selector object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Spine Access Port Selector object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Spine Access Port Selector object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`, + }, + "port_selector_type": schema.StringAttribute{ + Optional: true, + Computed: true, + + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.OneOf("ALL", "range"), + stringvalidator.AtLeastOneOf(path.Expressions{ + path.MatchRoot("spine_access_port_selector_type"), + }...), + }, + MarkdownDescription: `The port selector type of the Spine Access Port Selector object.`, + }, + "relation_to_spine_port_policy_group": schema.SingleNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the Relation To Spine Port Policy Group object.`, + }, + "target_dn": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The distinguished name of the target.`, + }, + "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.`, + }, + }, + }, + }, + }, + }, + "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.`, + }, + }, + }, + }, + }, + Blocks: map[string]schema.Block{}, + } + tflog.Debug(ctx, "End schema of resource: aci_spine_access_port_selector") +} + +func (r *InfraSHPortSResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_spine_access_port_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_spine_access_port_selector") +} + +func (r *InfraSHPortSResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_spine_access_port_selector") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraSHPortSResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setInfraSHPortSId(ctx, stateData) + } + getAndSetInfraSHPortSAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The infraSHPortS object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *InfraSHPortSResourceModel + + // 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() { + setInfraSHPortSId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_spine_access_port_selector with id '%s'", data.Id.ValueString())) + + var infraRsSpAccGrpPlan, infraRsSpAccGrpState InfraRsSpAccGrpInfraSHPortSResourceModel + data.InfraRsSpAccGrp.As(ctx, &infraRsSpAccGrpPlan, basetypes.ObjectAsOptions{}) + stateData.InfraRsSpAccGrp.As(ctx, &infraRsSpAccGrpState, basetypes.ObjectAsOptions{}) + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraSHPortSResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraSHPortSResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraSHPortSCreateJsonPayload(ctx, &resp.Diagnostics, true, data, infraRsSpAccGrpPlan, infraRsSpAccGrpState, 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 + } + + getAndSetInfraSHPortSAttributes(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_spine_access_port_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraSHPortSResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_spine_access_port_selector") + var data *InfraSHPortSResourceModel + + // 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_spine_access_port_selector with id '%s'", data.Id.ValueString())) + + getAndSetInfraSHPortSAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraSHPortSResourceModel + 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_spine_access_port_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraSHPortSResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_spine_access_port_selector") + var data *InfraSHPortSResourceModel + var stateData *InfraSHPortSResourceModel + + // 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_spine_access_port_selector with id '%s'", data.Id.ValueString())) + + var infraRsSpAccGrpPlan, infraRsSpAccGrpState InfraRsSpAccGrpInfraSHPortSResourceModel + data.InfraRsSpAccGrp.As(ctx, &infraRsSpAccGrpPlan, basetypes.ObjectAsOptions{}) + stateData.InfraRsSpAccGrp.As(ctx, &infraRsSpAccGrpState, basetypes.ObjectAsOptions{}) + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraSHPortSResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraSHPortSResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraSHPortSCreateJsonPayload(ctx, &resp.Diagnostics, false, data, infraRsSpAccGrpPlan, infraRsSpAccGrpState, 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 + } + + getAndSetInfraSHPortSAttributes(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_spine_access_port_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraSHPortSResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_spine_access_port_selector") + var data *InfraSHPortSResourceModel + + // 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_spine_access_port_selector with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraSHPortS", 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_spine_access_port_selector with id '%s'", data.Id.ValueString())) +} + +func (r *InfraSHPortSResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_spine_access_port_selector") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraSHPortSResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_spine_access_port_selector with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_spine_access_port_selector") +} + +func getAndSetInfraSHPortSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraSHPortSResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraSHPortS,infraRsSpAccGrp,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyInfraSHPortSResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraSHPortS").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraSHPortS").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + readData.Id = basetypes.NewStringValue(attributeValue.(string)) + setInfraSHPortSParentDn(ctx, attributeValue.(string), readData) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + readData.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + readData.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "type" { + readData.Type = basetypes.NewStringValue(attributeValue.(string)) + } + } + InfraRsSpAccGrpInfraSHPortSList := make([]InfraRsSpAccGrpInfraSHPortSResourceModel, 0) + TagAnnotationInfraSHPortSList := make([]TagAnnotationInfraSHPortSResourceModel, 0) + TagTagInfraSHPortSList := make([]TagTagInfraSHPortSResourceModel, 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 == "infraRsSpAccGrp" { + InfraRsSpAccGrpInfraSHPortS := getEmptyInfraRsSpAccGrpInfraSHPortSResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + InfraRsSpAccGrpInfraSHPortS.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "tDn" { + InfraRsSpAccGrpInfraSHPortS.TDn = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraRsSpAccGrpInfraSHPortSList := make([]TagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel, 0) + TagTagInfraRsSpAccGrpInfraSHPortSList := make([]TagTagInfraRsSpAccGrpInfraSHPortSResourceModel, 0) + childrenOfInfraRsSpAccGrpInfraSHPortS, childrenOfInfraRsSpAccGrpInfraSHPortSExist := childClassDetails.(map[string]interface{})["children"] + if childrenOfInfraRsSpAccGrpInfraSHPortSExist { + for _, childInfraRsSpAccGrpInfraSHPortS := range childrenOfInfraRsSpAccGrpInfraSHPortS.([]interface{}) { + for childClassNameInfraRsSpAccGrpInfraSHPortS, childClassDetailsInfraRsSpAccGrpInfraSHPortS := range childInfraRsSpAccGrpInfraSHPortS.(map[string]interface{}) { + if childClassNameInfraRsSpAccGrpInfraSHPortS == "tagAnnotation" { + TagAnnotationInfraRsSpAccGrpInfraSHPortS := getEmptyTagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel() + tagAnnotationchildAttributeValue := childClassDetailsInfraRsSpAccGrpInfraSHPortS.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue { + if childAttributeName == "key" { + TagAnnotationInfraRsSpAccGrpInfraSHPortS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraRsSpAccGrpInfraSHPortS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationInfraRsSpAccGrpInfraSHPortSList = append(TagAnnotationInfraRsSpAccGrpInfraSHPortSList, TagAnnotationInfraRsSpAccGrpInfraSHPortS) + } + if childClassNameInfraRsSpAccGrpInfraSHPortS == "tagTag" { + TagTagInfraRsSpAccGrpInfraSHPortS := getEmptyTagTagInfraRsSpAccGrpInfraSHPortSResourceModel() + tagTagchildAttributeValue := childClassDetailsInfraRsSpAccGrpInfraSHPortS.(map[string]interface{})["attributes"].(map[string]interface{}) + for childAttributeName, childAttributeValue := range tagTagchildAttributeValue { + if childAttributeName == "key" { + TagTagInfraRsSpAccGrpInfraSHPortS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraRsSpAccGrpInfraSHPortS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagInfraRsSpAccGrpInfraSHPortSList = append(TagTagInfraRsSpAccGrpInfraSHPortSList, TagTagInfraRsSpAccGrpInfraSHPortS) + } + } + } + } + TagAnnotationInfraRsSpAccGrpInfraSHPortSSet, _ := types.SetValueFrom(ctx, TagAnnotationInfraRsSpAccGrpInfraSHPortSType, TagAnnotationInfraRsSpAccGrpInfraSHPortSList) + InfraRsSpAccGrpInfraSHPortS.TagAnnotation = TagAnnotationInfraRsSpAccGrpInfraSHPortSSet + TagTagInfraRsSpAccGrpInfraSHPortSSet, _ := types.SetValueFrom(ctx, TagTagInfraRsSpAccGrpInfraSHPortSType, TagTagInfraRsSpAccGrpInfraSHPortSList) + InfraRsSpAccGrpInfraSHPortS.TagTag = TagTagInfraRsSpAccGrpInfraSHPortSSet + InfraRsSpAccGrpInfraSHPortSList = append(InfraRsSpAccGrpInfraSHPortSList, InfraRsSpAccGrpInfraSHPortS) + } + if childClassName == "tagAnnotation" { + TagAnnotationInfraSHPortS := getEmptyTagAnnotationInfraSHPortSResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraSHPortS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraSHPortS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraSHPortSList = append(TagAnnotationInfraSHPortSList, TagAnnotationInfraSHPortS) + } + if childClassName == "tagTag" { + TagTagInfraSHPortS := getEmptyTagTagInfraSHPortSResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraSHPortS.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraSHPortS.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagInfraSHPortSList = append(TagTagInfraSHPortSList, TagTagInfraSHPortS) + } + } + } + } + if len(InfraRsSpAccGrpInfraSHPortSList) == 1 { + infraRsSpAccGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsSpAccGrpInfraSHPortSType, InfraRsSpAccGrpInfraSHPortSList[0]) + readData.InfraRsSpAccGrp = infraRsSpAccGrpObject + } else { + infraRsSpAccGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsSpAccGrpInfraSHPortSType, getEmptyInfraRsSpAccGrpInfraSHPortSResourceModel()) + readData.InfraRsSpAccGrp = infraRsSpAccGrpObject + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationInfraSHPortSList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagInfraSHPortSList) + readData.TagTag = tagTagSet + setInfraSHPortSLegacyAttributes(ctx, diags, readData, data, classReadInfo) + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraSHPortS'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getInfraSHPortSRn(ctx context.Context, data *InfraSHPortSResourceModel) string { + return fmt.Sprintf("shports-%s-typ-%s", data.Name.ValueString(), data.Type.ValueString()) +} + +func setInfraSHPortSParentDn(ctx context.Context, dn string, data *InfraSHPortSResourceModel) { + 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 setInfraSHPortSId(ctx context.Context, data *InfraSHPortSResourceModel) { + rn := getInfraSHPortSRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraSHPortSInfraRsSpAccGrpChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraSHPortSResourceModel, infraRsSpAccGrpInfraSHPortSPlan, infraRsSpAccGrpInfraSHPortSState InfraRsSpAccGrpInfraSHPortSResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.InfraRsSpAccGrp.IsNull() && !data.InfraRsSpAccGrp.IsUnknown() { + InfraRsSpAccGrpInfraSHPortSChildren := make([]map[string]interface{}, 0) + childMap := NewAciObject() + if !IsEmptySingleNestedAttribute(data.InfraRsSpAccGrp.Attributes()) { + if !infraRsSpAccGrpInfraSHPortSPlan.Annotation.IsUnknown() && !infraRsSpAccGrpInfraSHPortSPlan.Annotation.IsNull() { + childMap.Attributes["annotation"] = infraRsSpAccGrpInfraSHPortSPlan.Annotation.ValueString() + } else { + childMap.Attributes["annotation"] = globalAnnotation + } + if !infraRsSpAccGrpInfraSHPortSPlan.TDn.IsUnknown() && !infraRsSpAccGrpInfraSHPortSPlan.TDn.IsNull() { + childMap.Attributes["tDn"] = infraRsSpAccGrpInfraSHPortSPlan.TDn.ValueString() + } + + var tagAnnotationInfraRsSpAccGrpInfraSHPortSPlan, tagAnnotationInfraRsSpAccGrpInfraSHPortSState []TagAnnotationInfraRsSpAccGrpInfraSHPortSResourceModel + infraRsSpAccGrpInfraSHPortSPlan.TagAnnotation.ElementsAs(ctx, &tagAnnotationInfraRsSpAccGrpInfraSHPortSPlan, false) + if !infraRsSpAccGrpInfraSHPortSState.TagAnnotation.IsNull() { + infraRsSpAccGrpInfraSHPortSState.TagAnnotation.ElementsAs(ctx, &tagAnnotationInfraRsSpAccGrpInfraSHPortSState, false) + } + if !infraRsSpAccGrpInfraSHPortSPlan.TagAnnotation.IsNull() && !infraRsSpAccGrpInfraSHPortSPlan.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraRsSpAccGrpInfraSHPortS := range tagAnnotationInfraRsSpAccGrpInfraSHPortSPlan { + tagAnnotationInfraRsSpAccGrpInfraSHPortSChildMap := NewAciObject() + if !tagAnnotationInfraRsSpAccGrpInfraSHPortS.Key.IsNull() && !tagAnnotationInfraRsSpAccGrpInfraSHPortS.Key.IsUnknown() { + tagAnnotationInfraRsSpAccGrpInfraSHPortSChildMap.Attributes["key"] = tagAnnotationInfraRsSpAccGrpInfraSHPortS.Key.ValueString() + } + if !tagAnnotationInfraRsSpAccGrpInfraSHPortS.Value.IsNull() && !tagAnnotationInfraRsSpAccGrpInfraSHPortS.Value.IsUnknown() { + tagAnnotationInfraRsSpAccGrpInfraSHPortSChildMap.Attributes["value"] = tagAnnotationInfraRsSpAccGrpInfraSHPortS.Value.ValueString() + } + InfraRsSpAccGrpInfraSHPortSChildren = append(InfraRsSpAccGrpInfraSHPortSChildren, map[string]interface{}{"tagAnnotation": tagAnnotationInfraRsSpAccGrpInfraSHPortSChildMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraRsSpAccGrpInfraSHPortS.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotationInfraRsSpAccGrpInfraSHPortS := range tagAnnotationInfraRsSpAccGrpInfraSHPortSState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotationInfraRsSpAccGrpInfraSHPortS.Key { + delete = false + break + } + } + if delete { + tagAnnotationInfraRsSpAccGrpInfraSHPortSChildMapForDelete := NewAciObject() + tagAnnotationInfraRsSpAccGrpInfraSHPortSChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationInfraRsSpAccGrpInfraSHPortSChildMapForDelete.Attributes["key"] = tagAnnotationInfraRsSpAccGrpInfraSHPortS.Key.ValueString() + InfraRsSpAccGrpInfraSHPortSChildren = append(InfraRsSpAccGrpInfraSHPortSChildren, map[string]interface{}{"tagAnnotation": tagAnnotationInfraRsSpAccGrpInfraSHPortSChildMapForDelete}) + } + } + } + + var tagTagInfraRsSpAccGrpInfraSHPortSPlan, tagTagInfraRsSpAccGrpInfraSHPortSState []TagTagInfraRsSpAccGrpInfraSHPortSResourceModel + infraRsSpAccGrpInfraSHPortSPlan.TagTag.ElementsAs(ctx, &tagTagInfraRsSpAccGrpInfraSHPortSPlan, false) + if !infraRsSpAccGrpInfraSHPortSState.TagTag.IsNull() { + infraRsSpAccGrpInfraSHPortSState.TagTag.ElementsAs(ctx, &tagTagInfraRsSpAccGrpInfraSHPortSState, false) + } + if !infraRsSpAccGrpInfraSHPortSPlan.TagTag.IsNull() && !infraRsSpAccGrpInfraSHPortSPlan.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraRsSpAccGrpInfraSHPortS := range tagTagInfraRsSpAccGrpInfraSHPortSPlan { + tagTagInfraRsSpAccGrpInfraSHPortSChildMap := NewAciObject() + if !tagTagInfraRsSpAccGrpInfraSHPortS.Key.IsNull() && !tagTagInfraRsSpAccGrpInfraSHPortS.Key.IsUnknown() { + tagTagInfraRsSpAccGrpInfraSHPortSChildMap.Attributes["key"] = tagTagInfraRsSpAccGrpInfraSHPortS.Key.ValueString() + } + if !tagTagInfraRsSpAccGrpInfraSHPortS.Value.IsNull() && !tagTagInfraRsSpAccGrpInfraSHPortS.Value.IsUnknown() { + tagTagInfraRsSpAccGrpInfraSHPortSChildMap.Attributes["value"] = tagTagInfraRsSpAccGrpInfraSHPortS.Value.ValueString() + } + InfraRsSpAccGrpInfraSHPortSChildren = append(InfraRsSpAccGrpInfraSHPortSChildren, map[string]interface{}{"tagTag": tagTagInfraRsSpAccGrpInfraSHPortSChildMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraRsSpAccGrpInfraSHPortS.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTagInfraRsSpAccGrpInfraSHPortS := range tagTagInfraRsSpAccGrpInfraSHPortSState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTagInfraRsSpAccGrpInfraSHPortS.Key { + delete = false + break + } + } + if delete { + tagTagInfraRsSpAccGrpInfraSHPortSChildMapForDelete := NewAciObject() + tagTagInfraRsSpAccGrpInfraSHPortSChildMapForDelete.Attributes["status"] = "deleted" + tagTagInfraRsSpAccGrpInfraSHPortSChildMapForDelete.Attributes["key"] = tagTagInfraRsSpAccGrpInfraSHPortS.Key.ValueString() + InfraRsSpAccGrpInfraSHPortSChildren = append(InfraRsSpAccGrpInfraSHPortSChildren, map[string]interface{}{"tagTag": tagTagInfraRsSpAccGrpInfraSHPortSChildMapForDelete}) + } + } + } + childMap.Children = InfraRsSpAccGrpInfraSHPortSChildren + } else { + childMap.Attributes["status"] = "deleted" + } + childPayloads = append(childPayloads, map[string]interface{}{"infraRsSpAccGrp": childMap}) + } else { + InfraRsSpAccGrpObject, _ := types.ObjectValueFrom(ctx, InfraRsSpAccGrpInfraSHPortSType, getEmptyInfraRsSpAccGrpInfraSHPortSResourceModel()) + data.InfraRsSpAccGrp = InfraRsSpAccGrpObject + } + + return childPayloads +} + +func getInfraSHPortSTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraSHPortSResourceModel, tagAnnotationInfraSHPortSPlan, tagAnnotationInfraSHPortSState []TagAnnotationInfraSHPortSResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraSHPortS := range tagAnnotationInfraSHPortSPlan { + childMap := NewAciObject() + if !tagAnnotationInfraSHPortS.Key.IsNull() && !tagAnnotationInfraSHPortS.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationInfraSHPortS.Key.ValueString() + } + if !tagAnnotationInfraSHPortS.Value.IsNull() && !tagAnnotationInfraSHPortS.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationInfraSHPortS.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraSHPortS.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationInfraSHPortSState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + tagAnnotationChildMapForDelete := NewAciObject() + tagAnnotationChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraSHPortSTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraSHPortSResourceModel, tagTagInfraSHPortSPlan, tagTagInfraSHPortSState []TagTagInfraSHPortSResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraSHPortS := range tagTagInfraSHPortSPlan { + childMap := NewAciObject() + if !tagTagInfraSHPortS.Key.IsNull() && !tagTagInfraSHPortS.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagInfraSHPortS.Key.ValueString() + } + if !tagTagInfraSHPortS.Value.IsNull() && !tagTagInfraSHPortS.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagInfraSHPortS.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraSHPortS.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagInfraSHPortSState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + tagTagChildMapForDelete := NewAciObject() + tagTagChildMapForDelete.Attributes["status"] = "deleted" + tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraSHPortSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraSHPortSResourceModel, infraRsSpAccGrpPlan, infraRsSpAccGrpState InfraRsSpAccGrpInfraSHPortSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraSHPortSResourceModel, tagTagPlan, tagTagState []TagTagInfraSHPortSResourceModel) *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{}{} + + InfraRsSpAccGrpchildPayloads := getInfraSHPortSInfraRsSpAccGrpChildPayloads(ctx, diags, data, infraRsSpAccGrpPlan, infraRsSpAccGrpState) + if InfraRsSpAccGrpchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, InfraRsSpAccGrpchildPayloads...) + + TagAnnotationchildPayloads := getInfraSHPortSTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraSHPortSTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + if !data.OwnerKey.IsNull() && !data.OwnerKey.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerKey"] = data.OwnerKey.ValueString() + } + if !data.OwnerTag.IsNull() && !data.OwnerTag.IsUnknown() { + payloadMap["attributes"].(map[string]string)["ownerTag"] = data.OwnerTag.ValueString() + } + if !data.Type.IsNull() && !data.Type.IsUnknown() { + payloadMap["attributes"].(map[string]string)["type"] = data.Type.ValueString() + } + payload, err := json.Marshal(map[string]interface{}{"infraSHPortS": 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_spine_access_port_selector_test.go b/internal/provider/resource_aci_spine_access_port_selector_test.go new file mode 100644 index 000000000..40544ae16 --- /dev/null +++ b/internal/provider/resource_aci_spine_access_port_selector_test.go @@ -0,0 +1,436 @@ +// 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" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" +) + +func TestAccResourceInfraSHPortSWithInfraSpAccPortP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraSHPortSMinDependencyWithInfraSpAccPortPAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraSHPortSMinDependencyWithInfraSpAccPortPAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraSHPortSMinDependencyWithInfraSpAccPortPAllowExisting, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraSHPortSAllDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "port_selector_type", "ALL"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraSHPortSResetDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_spine_access_port_selector.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraSHPortSChildrenDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "port_selector_type", "ALL"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.target_dn", "uni/infra/funcprof/spaccportgrp-spine_port_policy_group_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.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_spine_access_port_selector.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children removed from config + { + Config: testConfigInfraSHPortSChildrenRemoveFromConfigDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.annotations.#", "2"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.tags.#", "2"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "relation_to_spine_port_policy_group.target_dn", "uni/infra/funcprof/spaccportgrp-spine_port_policy_group_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraSHPortSChildrenRemoveOneDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.#", "1"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_spine_access_port_selector.test", + tfjsonpath.New("relation_to_spine_port_policy_group"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with all children removed + { + Config: testConfigInfraSHPortSChildrenRemoveAllDependencyWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_spine_access_port_selector.test", "tags.#", "0"), + ), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("aci_spine_access_port_selector.test", + tfjsonpath.New("relation_to_spine_port_policy_group"), + knownvalue.MapExact( + map[string]knownvalue.Check{ + "annotation": knownvalue.Null(), + "annotations": knownvalue.Null(), + "tags": knownvalue.Null(), + "target_dn": knownvalue.Null(), + }, + ), + ), + }, + }, + // Update with legacy attribute config + { + Config: testConfigInfraSHPortSLegacyAttributesWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "1.0(1e)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with legacy attribute config + { + Config: testConfigInfraSHPortSLegacyAttributesWithInfraSpAccPortP, + ExpectNonEmptyPlan: false, + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testChildDependencyConfigInfraSHPortS = ` +resource "aci_spine_port_policy_group" "test_spine_port_policy_group_0"{ + name = "spine_port_policy_group_1" +} +` + +const testConfigInfraSHPortSMinDependencyWithInfraSpAccPortPAllowExisting = testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "allow_test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" +} +resource "aci_spine_access_port_selector" "allow_test_2" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" + depends_on = [aci_spine_access_port_selector.allow_test] +} +` + +const testConfigInfraSHPortSMinDependencyWithInfraSpAccPortP = testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" +} +` + +const testConfigInfraSHPortSAllDependencyWithInfraSpAccPortP = testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" + annotation = "annotation" + description = "description_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" +} +` + +const testConfigInfraSHPortSResetDependencyWithInfraSpAccPortP = testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraSHPortSChildrenDependencyWithInfraSpAccPortP = testChildDependencyConfigInfraSHPortS + testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_spine_port_policy_group = { + annotation = "annotation_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" + }, + ] + target_dn = aci_spine_port_policy_group.test_spine_port_policy_group_0.id + } + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraSHPortSChildrenRemoveFromConfigDependencyWithInfraSpAccPortP = testChildDependencyConfigInfraSHPortS + testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" +} +` + +const testConfigInfraSHPortSChildrenRemoveOneDependencyWithInfraSpAccPortP = testChildDependencyConfigInfraSHPortS + testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + relation_to_spine_port_policy_group = {} + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraSHPortSChildrenRemoveAllDependencyWithInfraSpAccPortP = testChildDependencyConfigInfraSHPortS + testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "test" { + parent_dn = aci_spine_interface_profile.test.id + name = "test_name" + port_selector_type = "ALL" + annotations = [] + relation_to_spine_port_policy_group = {} + tags = [] +} +` + +const testConfigInfraSHPortSLegacyAttributesWithInfraSpAccPortP = testChildDependencyConfigInfraSHPortS + testConfigInfraSpAccPortPMin + ` +resource "aci_spine_access_port_selector" "test" { + name = "test_name" + relation_infra_rs_sp_acc_grp = aci_spine_port_policy_group.test_spine_port_policy_group_0.id + spine_access_port_selector_type = "ALL" + spine_interface_profile_dn = aci_spine_interface_profile.test.id +} +` diff --git a/internal/provider/resource_aci_spine_interface_profile.go b/internal/provider/resource_aci_spine_interface_profile.go new file mode 100644 index 000000000..eed04b49f --- /dev/null +++ b/internal/provider/resource_aci_spine_interface_profile.go @@ -0,0 +1,722 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/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 = &InfraSpAccPortPResource{} +var _ resource.ResourceWithImportState = &InfraSpAccPortPResource{} + +func NewInfraSpAccPortPResource() resource.Resource { + return &InfraSpAccPortPResource{} +} + +// InfraSpAccPortPResource defines the resource implementation. +type InfraSpAccPortPResource struct { + client *client.Client +} + +// InfraSpAccPortPResourceModel describes the resource data model. +type InfraSpAccPortPResourceModel 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"` +} + +func getEmptyInfraSpAccPortPResourceModel() *InfraSpAccPortPResourceModel { + return &InfraSpAccPortPResourceModel{ + Id: basetypes.NewStringNull(), + ParentDn: basetypes.NewStringNull(), + Annotation: basetypes.NewStringNull(), + Descr: basetypes.NewStringNull(), + Name: basetypes.NewStringNull(), + NameAlias: basetypes.NewStringNull(), + OwnerKey: basetypes.NewStringNull(), + OwnerTag: 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, + }, + }), + } +} + +// TagAnnotationInfraSpAccPortPResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationInfraSpAccPortPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagAnnotationInfraSpAccPortPResourceModel() TagAnnotationInfraSpAccPortPResourceModel { + return TagAnnotationInfraSpAccPortPResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagAnnotationInfraSpAccPortPType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +// TagTagInfraSpAccPortPResourceModel describes the resource data model for the children without relation ships. +type TagTagInfraSpAccPortPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +func getEmptyTagTagInfraSpAccPortPResourceModel() TagTagInfraSpAccPortPResourceModel { + return TagTagInfraSpAccPortPResourceModel{ + Key: basetypes.NewStringNull(), + Value: basetypes.NewStringNull(), + } +} + +var TagTagInfraSpAccPortPType = types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "key": types.StringType, + "value": types.StringType, + }, +} + +type InfraSpAccPortPIdentifier struct { + Name types.String +} + +func (r *InfraSpAccPortPResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.Plan.Raw.IsNull() { + var planData, stateData *InfraSpAccPortPResourceModel + 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.Name.IsUnknown() { + setInfraSpAccPortPId(ctx, planData) + } + + if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { + CheckDn(ctx, &resp.Diagnostics, r.client, "infraSpAccPortP", planData.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...) + } +} + +func (r *InfraSpAccPortPResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_spine_interface_profile") + resp.TypeName = req.ProviderTypeName + "_spine_interface_profile" + tflog.Debug(ctx, "End metadata of resource: aci_spine_interface_profile") +} + +func (r *InfraSpAccPortPResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_spine_interface_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The spine_interface_profile resource for the 'infraSpAccPortP' class", + Version: 1, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the Spine Interface Profile 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the Spine Interface Profile object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The description of the Spine Interface Profile object.`, + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The name of the Spine Interface Profile object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + MarkdownDescription: `The name alias of the Spine Interface Profile object.`, + }, + "owner_key": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + 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(), + SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + }, + 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_spine_interface_profile") +} + +func (r *InfraSpAccPortPResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_spine_interface_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_spine_interface_profile") +} + +func (r *InfraSpAccPortPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_spine_interface_profile") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *InfraSpAccPortPResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + if stateData.Id.IsUnknown() || stateData.Id.IsNull() { + setInfraSpAccPortPId(ctx, stateData) + } + getAndSetInfraSpAccPortPAttributes(ctx, &resp.Diagnostics, r.client, stateData) + if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { + resp.Diagnostics.AddError( + "Object Already Exists", + fmt.Sprintf("The infraSpAccPortP object with DN '%s' already exists.", stateData.Id.ValueString()), + ) + return + } + + var data *InfraSpAccPortPResourceModel + + // 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() { + setInfraSpAccPortPId(ctx, data) + } + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_spine_interface_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraSpAccPortPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraSpAccPortPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraSpAccPortPCreateJsonPayload(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 + } + + getAndSetInfraSpAccPortPAttributes(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_spine_interface_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraSpAccPortPResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_spine_interface_profile") + var data *InfraSpAccPortPResourceModel + + // 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_spine_interface_profile with id '%s'", data.Id.ValueString())) + + getAndSetInfraSpAccPortPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *InfraSpAccPortPResourceModel + 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_spine_interface_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraSpAccPortPResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_spine_interface_profile") + var data *InfraSpAccPortPResourceModel + var stateData *InfraSpAccPortPResourceModel + + // 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_spine_interface_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraSpAccPortPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagInfraSpAccPortPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getInfraSpAccPortPCreateJsonPayload(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 + } + + getAndSetInfraSpAccPortPAttributes(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_spine_interface_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraSpAccPortPResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_spine_interface_profile") + var data *InfraSpAccPortPResourceModel + + // 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_spine_interface_profile with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "infraSpAccPortP", 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_spine_interface_profile with id '%s'", data.Id.ValueString())) +} + +func (r *InfraSpAccPortPResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_spine_interface_profile") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *InfraSpAccPortPResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_spine_interface_profile with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_spine_interface_profile") +} + +func getAndSetInfraSpAccPortPAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraSpAccPortPResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraSpAccPortP,tagAnnotation,tagTag"), "GET", nil) + + readData := getEmptyInfraSpAccPortPResourceModel() + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("infraSpAccPortP").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("infraSpAccPortP").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + readData.Id = basetypes.NewStringValue(attributeValue.(string)) + setInfraSpAccPortPParentDn(ctx, attributeValue.(string), readData) + } + if attributeName == "annotation" { + readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + readData.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + readData.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + readData.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerKey" { + readData.OwnerKey = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "ownerTag" { + readData.OwnerTag = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationInfraSpAccPortPList := make([]TagAnnotationInfraSpAccPortPResourceModel, 0) + TagTagInfraSpAccPortPList := make([]TagTagInfraSpAccPortPResourceModel, 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" { + TagAnnotationInfraSpAccPortP := getEmptyTagAnnotationInfraSpAccPortPResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationInfraSpAccPortP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationInfraSpAccPortP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagAnnotationInfraSpAccPortPList = append(TagAnnotationInfraSpAccPortPList, TagAnnotationInfraSpAccPortP) + } + if childClassName == "tagTag" { + TagTagInfraSpAccPortP := getEmptyTagTagInfraSpAccPortPResourceModel() + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagInfraSpAccPortP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagInfraSpAccPortP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + + } + TagTagInfraSpAccPortPList = append(TagTagInfraSpAccPortPList, TagTagInfraSpAccPortP) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationInfraSpAccPortPList) + readData.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagInfraSpAccPortPList) + readData.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'infraSpAccPortP'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + readData.Id = basetypes.NewStringNull() + } + *data = *readData +} + +func getInfraSpAccPortPRn(ctx context.Context, data *InfraSpAccPortPResourceModel) string { + return fmt.Sprintf("spaccportprof-%s", data.Name.ValueString()) +} + +func setInfraSpAccPortPParentDn(ctx context.Context, dn string, data *InfraSpAccPortPResourceModel) { + 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 setInfraSpAccPortPId(ctx context.Context, data *InfraSpAccPortPResourceModel) { + rn := getInfraSpAccPortPRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getInfraSpAccPortPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraSpAccPortPResourceModel, tagAnnotationInfraSpAccPortPPlan, tagAnnotationInfraSpAccPortPState []TagAnnotationInfraSpAccPortPResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotationInfraSpAccPortP := range tagAnnotationInfraSpAccPortPPlan { + childMap := NewAciObject() + if !tagAnnotationInfraSpAccPortP.Key.IsNull() && !tagAnnotationInfraSpAccPortP.Key.IsUnknown() { + childMap.Attributes["key"] = tagAnnotationInfraSpAccPortP.Key.ValueString() + } + if !tagAnnotationInfraSpAccPortP.Value.IsNull() && !tagAnnotationInfraSpAccPortP.Value.IsUnknown() { + childMap.Attributes["value"] = tagAnnotationInfraSpAccPortP.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotationInfraSpAccPortP.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationInfraSpAccPortPState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + tagAnnotationChildMapForDelete := NewAciObject() + tagAnnotationChildMapForDelete.Attributes["status"] = "deleted" + tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraSpAccPortPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraSpAccPortPResourceModel, tagTagInfraSpAccPortPPlan, tagTagInfraSpAccPortPState []TagTagInfraSpAccPortPResourceModel) []map[string]interface{} { + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTagInfraSpAccPortP := range tagTagInfraSpAccPortPPlan { + childMap := NewAciObject() + if !tagTagInfraSpAccPortP.Key.IsNull() && !tagTagInfraSpAccPortP.Key.IsUnknown() { + childMap.Attributes["key"] = tagTagInfraSpAccPortP.Key.ValueString() + } + if !tagTagInfraSpAccPortP.Value.IsNull() && !tagTagInfraSpAccPortP.Value.IsUnknown() { + childMap.Attributes["value"] = tagTagInfraSpAccPortP.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTagInfraSpAccPortP.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagInfraSpAccPortPState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + tagTagChildMapForDelete := NewAciObject() + tagTagChildMapForDelete.Attributes["status"] = "deleted" + tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getInfraSpAccPortPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraSpAccPortPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraSpAccPortPResourceModel, tagTagPlan, tagTagState []TagTagInfraSpAccPortPResourceModel) *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 := getInfraSpAccPortPTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getInfraSpAccPortPTagTagChildPayloads(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{}{"infraSpAccPortP": 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_spine_interface_profile_test.go b/internal/provider/resource_aci_spine_interface_profile_test.go new file mode 100644 index 000000000..506507e8c --- /dev/null +++ b/internal/provider/resource_aci_spine_interface_profile_test.go @@ -0,0 +1,308 @@ +// 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 TestAccResourceInfraSpAccPortP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraSpAccPortPMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraSpAccPortPMinAllowExisting, + ExpectError: regexp.MustCompile("Object Already Exists"), + }, + }, + }) + + setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraSpAccPortPMinAllowExisting, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.allow_test_2", "owner_tag", ""), + ), + }, + }, + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "apic", "2.0(1m)-") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigInfraSpAccPortPMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_tag", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigInfraSpAccPortPAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigInfraSpAccPortPMin, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "description", "description_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_key", "owner_key_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_tag", "owner_tag_1"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigInfraSpAccPortPReset, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name", "test_name"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_tag", ""), + ), + }, + // Import testing + { + ResourceName: "aci_spine_interface_profile.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update with children + { + Config: testConfigInfraSpAccPortPChildren, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.#", "2"), + ), + }, + // Update with children removed from config + { + Config: testConfigInfraSpAccPortPChildrenRemoveFromConfig, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.1.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigInfraSpAccPortPChildrenRemoveOne, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.0.value", "test_value"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigInfraSpAccPortPChildrenRemoveAll, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_key", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "owner_tag", ""), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_spine_interface_profile.test", "tags.#", "0"), + ), + }, + }, + CheckDestroy: testCheckResourceDestroy, + }) +} + +const testConfigInfraSpAccPortPMinAllowExisting = ` +resource "aci_spine_interface_profile" "allow_test" { + name = "test_name" +} +resource "aci_spine_interface_profile" "allow_test_2" { + name = "test_name" + depends_on = [aci_spine_interface_profile.allow_test] +} +` + +const testConfigInfraSpAccPortPMin = ` +resource "aci_spine_interface_profile" "test" { + name = "test_name" +} +` + +const testConfigInfraSpAccPortPAll = ` +resource "aci_spine_interface_profile" "test" { + name = "test_name" + annotation = "annotation" + description = "description_1" + name_alias = "name_alias_1" + owner_key = "owner_key_1" + owner_tag = "owner_tag_1" +} +` + +const testConfigInfraSpAccPortPReset = ` +resource "aci_spine_interface_profile" "test" { + name = "test_name" + annotation = "orchestrator:terraform" + description = "" + name_alias = "" + owner_key = "" + owner_tag = "" +} +` +const testConfigInfraSpAccPortPChildren = ` +resource "aci_spine_interface_profile" "test" { + name = "test_name" + 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 testConfigInfraSpAccPortPChildrenRemoveFromConfig = ` +resource "aci_spine_interface_profile" "test" { + name = "test_name" +} +` + +const testConfigInfraSpAccPortPChildrenRemoveOne = ` +resource "aci_spine_interface_profile" "test" { + name = "test_name" + annotations = [ + { + key = "key_1" + value = "test_value" + }, + ] + tags = [ + { + key = "key_1" + value = "test_value" + }, + ] +} +` + +const testConfigInfraSpAccPortPChildrenRemoveAll = ` +resource "aci_spine_interface_profile" "test" { + name = "test_name" + annotations = [] + tags = [] +} +` From 6b5e5db72dc73801826bb2301f71bfd3e4ab6e13 Mon Sep 17 00:00:00 2001 From: akinross Date: Tue, 11 Nov 2025 20:34:59 +0100 Subject: [PATCH 3/5] [ignore] Change documenation for target_dn in access_port_selector --- docs/data-sources/access_port_selector.md | 2 +- docs/resources/access_port_selector.md | 2 +- gen/definitions/properties.yaml | 4 +++- internal/provider/data_source_aci_access_port_selector.go | 2 +- internal/provider/resource_aci_access_port_selector.go | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/data-sources/access_port_selector.md b/docs/data-sources/access_port_selector.md index cdc50209a..2e8b85ef0 100644 --- a/docs/data-sources/access_port_selector.md +++ b/docs/data-sources/access_port_selector.md @@ -68,7 +68,7 @@ data "aci_access_port_selector" "example_fex_profile" { * `relation_to_leaf_access_port_policy_group` - (map) A map of Relation To Leaf Access Port Policy Group (ACI object [infraRsAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBaseGrp/overview)) pointing to Access Interface Policy Group (ACI Object [infraAccBaseGrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBaseGrp/overview)). * `annotation` (annotation) - (string) The annotation of the Relation To Leaf Access Port Policy Group object. This attribute is supported in ACI versions: 3.2(1l) and later. * `fex_id` (fexId) - (string) The interface policy group FEX ID. - * `target_dn` (tDn) - (string) Select or create an interface policy group to associate to the Access Port selector. + * `target_dn` (tDn) - (string) The distinguished name of the target. * `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/resources/access_port_selector.md b/docs/resources/access_port_selector.md index 869b60fba..106ab7ce7 100644 --- a/docs/resources/access_port_selector.md +++ b/docs/resources/access_port_selector.md @@ -170,7 +170,7 @@ All examples for the Access Port Selector resource can be found in the [examples - Default: `"orchestrator:terraform"` * `fex_id` (fexId) - (string) The interface policy group FEX ID. - Default: `"101"` - * `target_dn` (tDn) - (string) Select or create an interface policy group to associate to the Access Port selector. + * `target_dn` (tDn) - (string) The distinguished name of the target. * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. #### Required #### diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 93751eb85..d0ccb5abc 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -2776,6 +2776,8 @@ infraHPortS: - "port_selector_type" infraRsAccBaseGrp: + documentation: + tDn: "The distinguished name of the target." test_values: all: fex_id: "102" @@ -2826,7 +2828,7 @@ infraPortBlk: parent_dn: "aci_access_port_selector.test.id" - class_name: "infraZHPortS" parent_dependency: "infraSpAccPortP" - parent_dn: "aaci_spine_access_port_selector.test.id" + parent_dn: "aci_spine_access_port_selector.test.id" test_values: default: from_card: "1" diff --git a/internal/provider/data_source_aci_access_port_selector.go b/internal/provider/data_source_aci_access_port_selector.go index 46fc65efe..4f0b3400f 100644 --- a/internal/provider/data_source_aci_access_port_selector.go +++ b/internal/provider/data_source_aci_access_port_selector.go @@ -109,7 +109,7 @@ func (d *InfraHPortSDataSource) Schema(ctx context.Context, req datasource.Schem }, "target_dn": schema.StringAttribute{ Computed: true, - MarkdownDescription: `Select or create an interface policy group to associate to the Access Port selector.`, + MarkdownDescription: `The distinguished name of the target.`, }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, diff --git a/internal/provider/resource_aci_access_port_selector.go b/internal/provider/resource_aci_access_port_selector.go index 57cb10b8d..74a7934b1 100644 --- a/internal/provider/resource_aci_access_port_selector.go +++ b/internal/provider/resource_aci_access_port_selector.go @@ -638,7 +638,7 @@ func (r *InfraHPortSResource) Schema(ctx context.Context, req resource.SchemaReq PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, - MarkdownDescription: `Select or create an interface policy group to associate to the Access Port selector.`, + MarkdownDescription: `The distinguished name of the target.`, }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, From 82b568bdb2e38372d0c992593590b9a9917e5665 Mon Sep 17 00:00:00 2001 From: akinross Date: Wed, 12 Nov 2025 21:30:15 +0100 Subject: [PATCH 4/5] [ignore] remove parent_dn attribute with default single valid dn pointing to infra --- docs/data-sources/fex_profile.md | 8 ----- docs/data-sources/leaf_interface_profile.md | 8 ----- docs/data-sources/spine_interface_profile.md | 8 ----- docs/resources/fex_profile.md | 5 --- docs/resources/leaf_interface_profile.md | 5 --- docs/resources/spine_interface_profile.md | 5 --- gen/definitions/classes.yaml | 9 +++++ gen/definitions/properties.yaml | 12 ------- .../provider/data_source_aci_fex_profile.go | 9 ----- .../data_source_aci_leaf_interface_profile.go | 9 ----- ...data_source_aci_spine_interface_profile.go | 9 ----- internal/provider/resource_aci_fex_profile.go | 36 +++---------------- .../resource_aci_leaf_interface_profile.go | 36 +++---------------- .../resource_aci_spine_interface_profile.go | 36 +++---------------- 14 files changed, 21 insertions(+), 174 deletions(-) diff --git a/docs/data-sources/fex_profile.md b/docs/data-sources/fex_profile.md index 84a7c368b..28546c0f1 100644 --- a/docs/data-sources/fex_profile.md +++ b/docs/data-sources/fex_profile.md @@ -42,14 +42,6 @@ data "aci_fex_profile" "example" { * `name` (name) - (string) The name of the FEX Profile 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` - ### Read-Only ### * `id` - (string) The distinguished name (DN) of the FEX Profile object. diff --git a/docs/data-sources/leaf_interface_profile.md b/docs/data-sources/leaf_interface_profile.md index 8622c7c57..49a490950 100644 --- a/docs/data-sources/leaf_interface_profile.md +++ b/docs/data-sources/leaf_interface_profile.md @@ -42,14 +42,6 @@ data "aci_leaf_interface_profile" "example" { * `name` (name) - (string) The name of the Leaf Interface Profile 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` - ### Read-Only ### * `id` - (string) The distinguished name (DN) of the Leaf Interface Profile object. diff --git a/docs/data-sources/spine_interface_profile.md b/docs/data-sources/spine_interface_profile.md index ba300881c..975eddcf8 100644 --- a/docs/data-sources/spine_interface_profile.md +++ b/docs/data-sources/spine_interface_profile.md @@ -42,14 +42,6 @@ data "aci_spine_interface_profile" "example" { * `name` (name) - (string) The name of the Spine Interface Profile 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` - ### Read-Only ### * `id` - (string) The distinguished name (DN) of the Spine Interface Profile object. diff --git a/docs/resources/fex_profile.md b/docs/resources/fex_profile.md index bed97b700..9582c0d3f 100644 --- a/docs/resources/fex_profile.md +++ b/docs/resources/fex_profile.md @@ -82,11 +82,6 @@ All examples for the FEX Profile resource can be found in the [examples](https:/ ### 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 FEX Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. - Default: `"orchestrator:terraform"` * `description` (descr) - (string) The description of the FEX Profile object. diff --git a/docs/resources/leaf_interface_profile.md b/docs/resources/leaf_interface_profile.md index da76297b6..fd4f325b9 100644 --- a/docs/resources/leaf_interface_profile.md +++ b/docs/resources/leaf_interface_profile.md @@ -82,11 +82,6 @@ All examples for the Leaf Interface Profile resource can be found in the [exampl ### 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 Leaf Interface Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. - Default: `"orchestrator:terraform"` * `description` (descr) - (string) The description of the Leaf Interface Profile object. diff --git a/docs/resources/spine_interface_profile.md b/docs/resources/spine_interface_profile.md index cb0e43c1e..49dabd947 100644 --- a/docs/resources/spine_interface_profile.md +++ b/docs/resources/spine_interface_profile.md @@ -82,11 +82,6 @@ All examples for the Spine Interface Profile resource can be found in the [examp ### 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 Spine Interface Profile object. This attribute is supported in ACI versions: 3.2(1l) and later. - Default: `"orchestrator:terraform"` * `description` (descr) - (string) The description of the Spine Interface Profile object. diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index da35619d8..31112f897 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -1144,6 +1144,9 @@ infraAccPortP: ui_locations: - "Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Interfaces" migration_version: 1 + contained_by: + - "polUni" + rn_prepend: "infra" infraSpAccPortP: resource_name: "spine_interface_profile" @@ -1151,6 +1154,9 @@ infraSpAccPortP: ui_locations: - "Fabric -> Access Policies -> Interfaces -> Spine Interfaces -> Profiles" migration_version: 1 + contained_by: + - "polUni" + rn_prepend: "infra" infraFexP: resource_name: "fex_profile" @@ -1158,6 +1164,9 @@ infraFexP: ui_locations: - "Fabric -> Access Policies -> Interfaces -> Leaf Interfaces -> Profiles -> Fex Interfaces" migration_version: 1 + contained_by: + - "polUni" + rn_prepend: "infra" infraHPortS: resource_name: "access_port_selector" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index d0ccb5abc..312ceabe0 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -2746,18 +2746,6 @@ vnsLDevIf: logical_device: "uni/tn-test_tenant_imported_device/lDevVip-test_imported_device" custom_test_dependency_name: "ImportedVnsLDevVipWithFvTenant" -infraAccPortP: - default_values: - parent_dn: "uni/infra" - -infraSpAccPortP: - default_values: - parent_dn: "uni/infra" - -infraFexP: - default_values: - parent_dn: "uni/infra" - infraHPortS: overwrites: type: port_selector_type diff --git a/internal/provider/data_source_aci_fex_profile.go b/internal/provider/data_source_aci_fex_profile.go index e5b55e1f6..7e18066ea 100644 --- a/internal/provider/data_source_aci_fex_profile.go +++ b/internal/provider/data_source_aci_fex_profile.go @@ -12,7 +12,6 @@ import ( "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" ) @@ -45,10 +44,6 @@ func (d *InfraFexPDataSource) Schema(ctx context.Context, req datasource.SchemaR Computed: true, MarkdownDescription: "The distinguished name (DN) of the FEX Profile 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 FEX Profile object.`, @@ -143,10 +138,6 @@ func (d *InfraFexPDataSource) Read(ctx context.Context, req datasource.ReadReque return } - if data.ParentDn.IsNull() || data.ParentDn.IsUnknown() { - data.ParentDn = basetypes.NewStringValue("uni/infra") - } - setInfraFexPId(ctx, data) // Create a copy of the Id for when not found during getAndSetInfraFexPAttributes diff --git a/internal/provider/data_source_aci_leaf_interface_profile.go b/internal/provider/data_source_aci_leaf_interface_profile.go index 7a4f9e716..6f63b8dbb 100644 --- a/internal/provider/data_source_aci_leaf_interface_profile.go +++ b/internal/provider/data_source_aci_leaf_interface_profile.go @@ -12,7 +12,6 @@ import ( "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" ) @@ -45,10 +44,6 @@ func (d *InfraAccPortPDataSource) Schema(ctx context.Context, req datasource.Sch Computed: true, MarkdownDescription: "The distinguished name (DN) of the Leaf Interface Profile 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 Leaf Interface Profile object.`, @@ -143,10 +138,6 @@ func (d *InfraAccPortPDataSource) Read(ctx context.Context, req datasource.ReadR return } - if data.ParentDn.IsNull() || data.ParentDn.IsUnknown() { - data.ParentDn = basetypes.NewStringValue("uni/infra") - } - setInfraAccPortPId(ctx, data) // Create a copy of the Id for when not found during getAndSetInfraAccPortPAttributes diff --git a/internal/provider/data_source_aci_spine_interface_profile.go b/internal/provider/data_source_aci_spine_interface_profile.go index 118ee6d5c..ac07cc6fc 100644 --- a/internal/provider/data_source_aci_spine_interface_profile.go +++ b/internal/provider/data_source_aci_spine_interface_profile.go @@ -12,7 +12,6 @@ import ( "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" ) @@ -45,10 +44,6 @@ func (d *InfraSpAccPortPDataSource) Schema(ctx context.Context, req datasource.S Computed: true, MarkdownDescription: "The distinguished name (DN) of the Spine Interface Profile 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 Spine Interface Profile object.`, @@ -143,10 +138,6 @@ func (d *InfraSpAccPortPDataSource) Read(ctx context.Context, req datasource.Rea return } - if data.ParentDn.IsNull() || data.ParentDn.IsUnknown() { - data.ParentDn = basetypes.NewStringValue("uni/infra") - } - setInfraSpAccPortPId(ctx, data) // Create a copy of the Id for when not found during getAndSetInfraSpAccPortPAttributes diff --git a/internal/provider/resource_aci_fex_profile.go b/internal/provider/resource_aci_fex_profile.go index 076765094..4d4dc0737 100644 --- a/internal/provider/resource_aci_fex_profile.go +++ b/internal/provider/resource_aci_fex_profile.go @@ -8,6 +8,7 @@ import ( "context" "encoding/json" "fmt" + "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -41,7 +42,6 @@ type InfraFexPResource struct { // InfraFexPResourceModel describes the resource data model. type InfraFexPResourceModel 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"` @@ -55,7 +55,6 @@ type InfraFexPResourceModel struct { func getEmptyInfraFexPResourceModel() *InfraFexPResourceModel { return &InfraFexPResourceModel{ Id: basetypes.NewStringNull(), - ParentDn: basetypes.NewStringNull(), Annotation: basetypes.NewStringNull(), Descr: basetypes.NewStringNull(), Name: basetypes.NewStringNull(), @@ -131,7 +130,7 @@ func (r *InfraFexPResource) ModifyPlan(ctx context.Context, req resource.ModifyP return } - if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.Name.IsUnknown() { setInfraFexPId(ctx, planData) } @@ -167,16 +166,6 @@ func (r *InfraFexPResource) Schema(ctx context.Context, req resource.SchemaReque 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, @@ -483,7 +472,6 @@ func getAndSetInfraFexPAttributes(ctx context.Context, diags *diag.Diagnostics, for attributeName, attributeValue := range attributes { if attributeName == "dn" { readData.Id = basetypes.NewStringValue(attributeValue.(string)) - setInfraFexPParentDn(ctx, attributeValue.(string), readData) } if attributeName == "annotation" { readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) @@ -558,28 +546,12 @@ func getAndSetInfraFexPAttributes(ctx context.Context, diags *diag.Diagnostics, } func getInfraFexPRn(ctx context.Context, data *InfraFexPResourceModel) string { - return fmt.Sprintf("fexprof-%s", data.Name.ValueString()) -} - -func setInfraFexPParentDn(ctx context.Context, dn string, data *InfraFexPResourceModel) { - 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]) + return fmt.Sprintf("infra/fexprof-%s", data.Name.ValueString()) } func setInfraFexPId(ctx context.Context, data *InfraFexPResourceModel) { rn := getInfraFexPRn(ctx, data) - data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", strings.Split([]string{"uni/infra/fexprof-{name}"}[0], "/")[0], rn)) } func getInfraFexPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraFexPResourceModel, tagAnnotationInfraFexPPlan, tagAnnotationInfraFexPState []TagAnnotationInfraFexPResourceModel) []map[string]interface{} { diff --git a/internal/provider/resource_aci_leaf_interface_profile.go b/internal/provider/resource_aci_leaf_interface_profile.go index 771862477..0695202c8 100644 --- a/internal/provider/resource_aci_leaf_interface_profile.go +++ b/internal/provider/resource_aci_leaf_interface_profile.go @@ -8,6 +8,7 @@ import ( "context" "encoding/json" "fmt" + "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -41,7 +42,6 @@ type InfraAccPortPResource struct { // InfraAccPortPResourceModel describes the resource data model. type InfraAccPortPResourceModel 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"` @@ -55,7 +55,6 @@ type InfraAccPortPResourceModel struct { func getEmptyInfraAccPortPResourceModel() *InfraAccPortPResourceModel { return &InfraAccPortPResourceModel{ Id: basetypes.NewStringNull(), - ParentDn: basetypes.NewStringNull(), Annotation: basetypes.NewStringNull(), Descr: basetypes.NewStringNull(), Name: basetypes.NewStringNull(), @@ -131,7 +130,7 @@ func (r *InfraAccPortPResource) ModifyPlan(ctx context.Context, req resource.Mod return } - if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.Name.IsUnknown() { setInfraAccPortPId(ctx, planData) } @@ -167,16 +166,6 @@ func (r *InfraAccPortPResource) Schema(ctx context.Context, req resource.SchemaR 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, @@ -483,7 +472,6 @@ func getAndSetInfraAccPortPAttributes(ctx context.Context, diags *diag.Diagnosti for attributeName, attributeValue := range attributes { if attributeName == "dn" { readData.Id = basetypes.NewStringValue(attributeValue.(string)) - setInfraAccPortPParentDn(ctx, attributeValue.(string), readData) } if attributeName == "annotation" { readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) @@ -558,28 +546,12 @@ func getAndSetInfraAccPortPAttributes(ctx context.Context, diags *diag.Diagnosti } func getInfraAccPortPRn(ctx context.Context, data *InfraAccPortPResourceModel) string { - return fmt.Sprintf("accportprof-%s", data.Name.ValueString()) -} - -func setInfraAccPortPParentDn(ctx context.Context, dn string, data *InfraAccPortPResourceModel) { - 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]) + return fmt.Sprintf("infra/accportprof-%s", data.Name.ValueString()) } func setInfraAccPortPId(ctx context.Context, data *InfraAccPortPResourceModel) { rn := getInfraAccPortPRn(ctx, data) - data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", strings.Split([]string{"uni/infra/accportprof-{name}"}[0], "/")[0], rn)) } func getInfraAccPortPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraAccPortPResourceModel, tagAnnotationInfraAccPortPPlan, tagAnnotationInfraAccPortPState []TagAnnotationInfraAccPortPResourceModel) []map[string]interface{} { diff --git a/internal/provider/resource_aci_spine_interface_profile.go b/internal/provider/resource_aci_spine_interface_profile.go index eed04b49f..1468f7720 100644 --- a/internal/provider/resource_aci_spine_interface_profile.go +++ b/internal/provider/resource_aci_spine_interface_profile.go @@ -8,6 +8,7 @@ import ( "context" "encoding/json" "fmt" + "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -41,7 +42,6 @@ type InfraSpAccPortPResource struct { // InfraSpAccPortPResourceModel describes the resource data model. type InfraSpAccPortPResourceModel 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"` @@ -55,7 +55,6 @@ type InfraSpAccPortPResourceModel struct { func getEmptyInfraSpAccPortPResourceModel() *InfraSpAccPortPResourceModel { return &InfraSpAccPortPResourceModel{ Id: basetypes.NewStringNull(), - ParentDn: basetypes.NewStringNull(), Annotation: basetypes.NewStringNull(), Descr: basetypes.NewStringNull(), Name: basetypes.NewStringNull(), @@ -131,7 +130,7 @@ func (r *InfraSpAccPortPResource) ModifyPlan(ctx context.Context, req resource.M return } - if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { + if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.Name.IsUnknown() { setInfraSpAccPortPId(ctx, planData) } @@ -167,16 +166,6 @@ func (r *InfraSpAccPortPResource) Schema(ctx context.Context, req resource.Schem 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, @@ -483,7 +472,6 @@ func getAndSetInfraSpAccPortPAttributes(ctx context.Context, diags *diag.Diagnos for attributeName, attributeValue := range attributes { if attributeName == "dn" { readData.Id = basetypes.NewStringValue(attributeValue.(string)) - setInfraSpAccPortPParentDn(ctx, attributeValue.(string), readData) } if attributeName == "annotation" { readData.Annotation = basetypes.NewStringValue(attributeValue.(string)) @@ -558,28 +546,12 @@ func getAndSetInfraSpAccPortPAttributes(ctx context.Context, diags *diag.Diagnos } func getInfraSpAccPortPRn(ctx context.Context, data *InfraSpAccPortPResourceModel) string { - return fmt.Sprintf("spaccportprof-%s", data.Name.ValueString()) -} - -func setInfraSpAccPortPParentDn(ctx context.Context, dn string, data *InfraSpAccPortPResourceModel) { - 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]) + return fmt.Sprintf("infra/spaccportprof-%s", data.Name.ValueString()) } func setInfraSpAccPortPId(ctx context.Context, data *InfraSpAccPortPResourceModel) { rn := getInfraSpAccPortPRn(ctx, data) - data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", strings.Split([]string{"uni/infra/spaccportprof-{name}"}[0], "/")[0], rn)) } func getInfraSpAccPortPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *InfraSpAccPortPResourceModel, tagAnnotationInfraSpAccPortPPlan, tagAnnotationInfraSpAccPortPState []TagAnnotationInfraSpAccPortPResourceModel) []map[string]interface{} { From 0b6994d86d7b47048a07c79315c5598a59b22767 Mon Sep 17 00:00:00 2001 From: akinross Date: Wed, 12 Nov 2025 22:56:19 +0100 Subject: [PATCH 5/5] [ignore] capitalize abbreviated object description --- docs/data-sources/access_port_block.md | 4 ++-- docs/resources/access_port_block.md | 4 ++-- gen/definitions/properties.yaml | 2 +- internal/provider/data_source_aci_access_port_block.go | 2 +- internal/provider/resource_aci_access_port_block.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/data-sources/access_port_block.md b/docs/data-sources/access_port_block.md index e3fcc2441..23e21542d 100644 --- a/docs/data-sources/access_port_block.md +++ b/docs/data-sources/access_port_block.md @@ -64,8 +64,8 @@ data "aci_access_port_block" "example_spine_access_port_selector" { * `name_alias` (nameAlias) - (string) The name alias of the Access Port Block object. This attribute is supported in ACI versions: 2.2(1k) and later. * `to_card` (toCard) - (string) The end of the line card range for the Access Port Block object. * `to_port` (toPort) - (string) The end of the port range for the Access Port Block object. -* `relation_to_pc_vpc_override_policy` - (map) A map of Relation To Pc Vpc Override Policy (ACI object [infraRsAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBndlSubgrp/overview)) pointing to PC VPC Override Policy (ACI Object [infraAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBndlSubgrp/overview)). - * `annotation` (annotation) - (string) The annotation of the Relation To Pc Vpc Override Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. +* `relation_to_pc_vpc_override_policy` - (map) A map of Relation To PC VPC Override Policy (ACI object [infraRsAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBndlSubgrp/overview)) pointing to Leaf Access Bundle Policy Sub Group (ACI Object [infraAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBndlSubgrp/overview)). + * `annotation` (annotation) - (string) The annotation of the Relation To PC VPC Override Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. * `target_dn` (tDn) - (string) The distinguished name (DN) of the target PC VPC Override Policy. * `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/resources/access_port_block.md b/docs/resources/access_port_block.md index 26a8051db..a305f1439 100644 --- a/docs/resources/access_port_block.md +++ b/docs/resources/access_port_block.md @@ -167,10 +167,10 @@ All examples for the Access Port Block resource can be found in the [examples](h - Default: `"1"` * `to_port` (toPort) - (string) The end of the port range for the Access Port Block object. - Default: `"1"` -* `relation_to_pc_vpc_override_policy` - (map) A map of Relation To Pc Vpc Override Policy (ACI object [infraRsAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBndlSubgrp/overview)) pointing to PC VPC Override Policy (ACI Object [infraAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBndlSubgrp/overview)) which can be configured using the [aci_leaf_access_bundle_policy_sub_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/leaf_access_bundle_policy_sub_group) resource. +* `relation_to_pc_vpc_override_policy` - (map) A map of Relation To PC VPC Override Policy (ACI object [infraRsAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraRsAccBndlSubgrp/overview)) pointing to Leaf Access Bundle Policy Sub Group (ACI Object [infraAccBndlSubgrp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/infraAccBndlSubgrp/overview)) which can be configured using the [aci_leaf_access_bundle_policy_sub_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/leaf_access_bundle_policy_sub_group) resource. #### Optional #### - * `annotation` (annotation) - (string) The annotation of the Relation To Pc Vpc Override Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. + * `annotation` (annotation) - (string) The annotation of the Relation To PC VPC Override Policy object. This attribute is supported in ACI versions: 3.2(1l) and later. - Default: `"orchestrator:terraform"` * `target_dn` (tDn) - (string) The distinguished name (DN) of the target PC VPC Override Policy. * `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. diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 312ceabe0..cf8530986 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -87,7 +87,7 @@ global: Lacp Enhanced Lag Policy: "LACP Enhanced Lag Policy" Vmm: "VMM" Policys: "Policies" - Leaf Access Bundle Policy Sub Group: "PC VPC Override Policy" + Pc Vpc Override Policy: "PC VPC Override Policy" Fex: "FEX" ignores: - "userdom" diff --git a/internal/provider/data_source_aci_access_port_block.go b/internal/provider/data_source_aci_access_port_block.go index 1bf174898..516438f4f 100644 --- a/internal/provider/data_source_aci_access_port_block.go +++ b/internal/provider/data_source_aci_access_port_block.go @@ -96,7 +96,7 @@ func (d *InfraPortBlkDataSource) Schema(ctx context.Context, req datasource.Sche Attributes: map[string]schema.Attribute{ "annotation": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The annotation of the Relation To Pc Vpc Override Policy object.`, + MarkdownDescription: `The annotation of the Relation To PC VPC Override Policy object.`, }, "target_dn": schema.StringAttribute{ Computed: true, diff --git a/internal/provider/resource_aci_access_port_block.go b/internal/provider/resource_aci_access_port_block.go index 1b06a9a29..2578336e2 100644 --- a/internal/provider/resource_aci_access_port_block.go +++ b/internal/provider/resource_aci_access_port_block.go @@ -606,7 +606,7 @@ func (r *InfraPortBlkResource) Schema(ctx context.Context, req resource.SchemaRe PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, - MarkdownDescription: `The annotation of the Relation To Pc Vpc Override Policy object.`, + MarkdownDescription: `The annotation of the Relation To PC VPC Override Policy object.`, }, "target_dn": schema.StringAttribute{ Optional: true,