From bfc2e9bd2459702487b9b6b18eec542f6354acec Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Wed, 21 Aug 2024 14:00:28 -0700 Subject: [PATCH 01/10] [ignore] added template --- cmd/conversion/main.go | 281 +++++++++++++ cmd/conversion/main.tf | 344 +++++++++++++++ cmd/conversion/payload.json | 5 + cmd/conversion/plan.bin | Bin 0 -> 4927 bytes cmd/conversion/plan.json | 1 + .../conversion_access_interface_override.go | 123 ++++++ convert_funcs/conversion_annotation.go | 55 +++ convert_funcs/conversion_application_epg.go | 393 ++++++++++++++++++ convert_funcs/conversion_custom_qos_policy.go | 95 +++++ .../conversion_data_plane_policing_policy.go | 158 +++++++ .../conversion_endpoint_security_group.go | 195 +++++++++ convert_funcs/conversion_endpoint_tag_ip.go | 95 +++++ convert_funcs/conversion_endpoint_tag_mac.go | 95 +++++ .../conversion_epg_useg_ad_group_attribute.go | 98 +++++ .../conversion_epg_useg_block_statement.go | 104 +++++ .../conversion_epg_useg_dns_attribute.go | 98 +++++ .../conversion_epg_useg_ip_attribute.go | 101 +++++ .../conversion_epg_useg_mac_attribute.go | 98 +++++ ...conversion_epg_useg_sub_block_statement.go | 98 +++++ .../conversion_epg_useg_vm_attribute.go | 110 +++++ ...nal_management_network_instance_profile.go | 104 +++++ ...sion_external_management_network_subnet.go | 92 ++++ .../conversion_l3out_consumer_label.go | 101 +++++ .../conversion_l3out_node_sid_profile.go | 95 +++++ .../conversion_l3out_provider_label.go | 98 +++++ .../conversion_l3out_redistribute_policy.go | 86 ++++ .../conversion_netflow_monitor_policy.go | 123 ++++++ .../conversion_netflow_record_policy.go | 95 +++++ .../conversion_out_of_band_contract.go | 104 +++++ .../conversion_pim_route_map_entry.go | 104 +++++ .../conversion_pim_route_map_policy.go | 95 +++++ ...onversion_relation_to_consumed_contract.go | 86 ++++ ...lation_to_consumed_out_of_band_contract.go | 86 ++++ .../conversion_relation_to_contract_master.go | 83 ++++ .../conversion_relation_to_domain.go | 155 +++++++ ...nversion_relation_to_fibre_channel_path.go | 92 ++++ ...onversion_relation_to_imported_contract.go | 86 ++++ ...nversion_relation_to_intra_epg_contract.go | 83 ++++ ...conversion_relation_to_netflow_exporter.go | 83 ++++ ...onversion_relation_to_provided_contract.go | 89 ++++ .../conversion_relation_to_static_leaf.go | 95 +++++ .../conversion_relation_to_static_path.go | 98 +++++ .../conversion_relation_to_taboo_contract.go | 83 ++++ ...on_relation_to_vrf_fallback_route_group.go | 83 ++++ .../conversion_route_control_profile.go | 101 +++++ convert_funcs/conversion_tag.go | 55 +++ .../conversion_trust_control_policy.go | 113 +++++ .../conversion_vrf_fallback_route.go | 92 ++++ .../conversion_vrf_fallback_route_group.go | 123 ++++++ ...version_vrf_fallback_route_group_member.go | 92 ++++ convert_funcs/dn_to_aci.go | 247 +++++++++++ convert_funcs/getAciClass.go | 57 +++ convert_funcs/resourceMap.go | 5 + gen/generator.go | 103 +++++ gen/templates/conversion.go.tmpl | 88 ++++ gen/templates/datasource.go.tmpl | 2 +- gen/templates/getAciClass.go.tmpl | 16 + gen/templates/new.go.tmpl | 24 ++ gen/templates/resource.go.tmpl | 18 +- gen/templates/resourceMap.go.tmpl | 11 + ...ta_source_aci_access_interface_override.go | 2 +- .../provider/data_source_aci_annotation.go | 2 +- .../data_source_aci_application_epg.go | 2 +- .../data_source_aci_custom_qos_policy.go | 2 +- ...a_source_aci_data_plane_policing_policy.go | 2 +- ...data_source_aci_endpoint_security_group.go | 2 +- .../data_source_aci_endpoint_tag_ip.go | 2 +- .../data_source_aci_endpoint_tag_mac.go | 2 +- ..._source_aci_epg_useg_ad_group_attribute.go | 2 +- ...ata_source_aci_epg_useg_block_statement.go | 2 +- .../data_source_aci_epg_useg_dns_attribute.go | 2 +- .../data_source_aci_epg_useg_ip_attribute.go | 2 +- .../data_source_aci_epg_useg_mac_attribute.go | 2 +- ...source_aci_epg_useg_sub_block_statement.go | 2 +- .../data_source_aci_epg_useg_vm_attribute.go | 2 +- ...nal_management_network_instance_profile.go | 2 +- ..._aci_external_management_network_subnet.go | 2 +- .../data_source_aci_l3out_consumer_label.go | 2 +- .../data_source_aci_l3out_node_sid_profile.go | 2 +- .../data_source_aci_l3out_provider_label.go | 2 +- ...ta_source_aci_l3out_redistribute_policy.go | 2 +- .../data_source_aci_netflow_monitor_policy.go | 2 +- .../data_source_aci_netflow_record_policy.go | 2 +- .../data_source_aci_out_of_band_contract.go | 2 +- .../data_source_aci_pim_route_map_entry.go | 2 +- .../data_source_aci_pim_route_map_policy.go | 2 +- ...ource_aci_relation_to_consumed_contract.go | 2 +- ...lation_to_consumed_out_of_band_contract.go | 2 +- ..._source_aci_relation_to_contract_master.go | 2 +- .../data_source_aci_relation_to_domain.go | 2 +- ...urce_aci_relation_to_fibre_channel_path.go | 2 +- ...ource_aci_relation_to_imported_contract.go | 2 +- ...urce_aci_relation_to_intra_epg_contract.go | 2 +- ...source_aci_relation_to_netflow_exporter.go | 2 +- ...ource_aci_relation_to_provided_contract.go | 2 +- ...data_source_aci_relation_to_static_leaf.go | 2 +- ...data_source_aci_relation_to_static_path.go | 2 +- ...a_source_aci_relation_to_taboo_contract.go | 2 +- ...ci_relation_to_vrf_fallback_route_group.go | 2 +- .../data_source_aci_route_control_profile.go | 2 +- internal/provider/data_source_aci_tag.go | 2 +- .../data_source_aci_trust_control_policy.go | 2 +- .../data_source_aci_vrf_fallback_route.go | 2 +- ...ata_source_aci_vrf_fallback_route_group.go | 2 +- ...rce_aci_vrf_fallback_route_group_member.go | 2 +- .../resource_aci_access_interface_override.go | 14 +- internal/provider/resource_aci_annotation.go | 12 +- .../provider/resource_aci_application_epg.go | 14 +- .../resource_aci_custom_qos_policy.go | 14 +- ...resource_aci_data_plane_policing_policy.go | 14 +- .../resource_aci_endpoint_security_group.go | 14 +- .../provider/resource_aci_endpoint_tag_ip.go | 14 +- .../provider/resource_aci_endpoint_tag_mac.go | 14 +- ...esource_aci_epg_useg_ad_group_attribute.go | 14 +- .../resource_aci_epg_useg_block_statement.go | 14 +- .../resource_aci_epg_useg_dns_attribute.go | 14 +- .../resource_aci_epg_useg_ip_attribute.go | 14 +- .../resource_aci_epg_useg_mac_attribute.go | 14 +- ...source_aci_epg_useg_sub_block_statement.go | 14 +- .../resource_aci_epg_useg_vm_attribute.go | 14 +- ...nal_management_network_instance_profile.go | 14 +- ..._aci_external_management_network_subnet.go | 14 +- .../resource_aci_l3out_consumer_label.go | 14 +- .../resource_aci_l3out_node_sid_profile.go | 14 +- .../resource_aci_l3out_provider_label.go | 14 +- .../resource_aci_l3out_redistribute_policy.go | 14 +- .../resource_aci_netflow_monitor_policy.go | 14 +- .../resource_aci_netflow_record_policy.go | 14 +- .../resource_aci_out_of_band_contract.go | 14 +- .../resource_aci_pim_route_map_entry.go | 14 +- .../resource_aci_pim_route_map_policy.go | 14 +- ...ource_aci_relation_to_consumed_contract.go | 14 +- ...lation_to_consumed_out_of_band_contract.go | 14 +- ...esource_aci_relation_to_contract_master.go | 14 +- .../resource_aci_relation_to_domain.go | 14 +- ...urce_aci_relation_to_fibre_channel_path.go | 14 +- ...ource_aci_relation_to_imported_contract.go | 14 +- ...urce_aci_relation_to_intra_epg_contract.go | 14 +- ...source_aci_relation_to_netflow_exporter.go | 14 +- ...ource_aci_relation_to_provided_contract.go | 14 +- .../resource_aci_relation_to_static_leaf.go | 14 +- .../resource_aci_relation_to_static_path.go | 14 +- ...resource_aci_relation_to_taboo_contract.go | 14 +- ...ci_relation_to_vrf_fallback_route_group.go | 14 +- .../resource_aci_route_control_profile.go | 14 +- internal/provider/resource_aci_tag.go | 12 +- .../resource_aci_trust_control_policy.go | 14 +- .../resource_aci_vrf_fallback_route.go | 14 +- .../resource_aci_vrf_fallback_route_group.go | 14 +- ...rce_aci_vrf_fallback_route_group_member.go | 14 +- 150 files changed, 6341 insertions(+), 368 deletions(-) create mode 100644 cmd/conversion/main.go create mode 100644 cmd/conversion/main.tf create mode 100644 cmd/conversion/payload.json create mode 100755 cmd/conversion/plan.bin create mode 100644 cmd/conversion/plan.json create mode 100644 convert_funcs/conversion_access_interface_override.go create mode 100644 convert_funcs/conversion_annotation.go create mode 100644 convert_funcs/conversion_application_epg.go create mode 100644 convert_funcs/conversion_custom_qos_policy.go create mode 100644 convert_funcs/conversion_data_plane_policing_policy.go create mode 100644 convert_funcs/conversion_endpoint_security_group.go create mode 100644 convert_funcs/conversion_endpoint_tag_ip.go create mode 100644 convert_funcs/conversion_endpoint_tag_mac.go create mode 100644 convert_funcs/conversion_epg_useg_ad_group_attribute.go create mode 100644 convert_funcs/conversion_epg_useg_block_statement.go create mode 100644 convert_funcs/conversion_epg_useg_dns_attribute.go create mode 100644 convert_funcs/conversion_epg_useg_ip_attribute.go create mode 100644 convert_funcs/conversion_epg_useg_mac_attribute.go create mode 100644 convert_funcs/conversion_epg_useg_sub_block_statement.go create mode 100644 convert_funcs/conversion_epg_useg_vm_attribute.go create mode 100644 convert_funcs/conversion_external_management_network_instance_profile.go create mode 100644 convert_funcs/conversion_external_management_network_subnet.go create mode 100644 convert_funcs/conversion_l3out_consumer_label.go create mode 100644 convert_funcs/conversion_l3out_node_sid_profile.go create mode 100644 convert_funcs/conversion_l3out_provider_label.go create mode 100644 convert_funcs/conversion_l3out_redistribute_policy.go create mode 100644 convert_funcs/conversion_netflow_monitor_policy.go create mode 100644 convert_funcs/conversion_netflow_record_policy.go create mode 100644 convert_funcs/conversion_out_of_band_contract.go create mode 100644 convert_funcs/conversion_pim_route_map_entry.go create mode 100644 convert_funcs/conversion_pim_route_map_policy.go create mode 100644 convert_funcs/conversion_relation_to_consumed_contract.go create mode 100644 convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go create mode 100644 convert_funcs/conversion_relation_to_contract_master.go create mode 100644 convert_funcs/conversion_relation_to_domain.go create mode 100644 convert_funcs/conversion_relation_to_fibre_channel_path.go create mode 100644 convert_funcs/conversion_relation_to_imported_contract.go create mode 100644 convert_funcs/conversion_relation_to_intra_epg_contract.go create mode 100644 convert_funcs/conversion_relation_to_netflow_exporter.go create mode 100644 convert_funcs/conversion_relation_to_provided_contract.go create mode 100644 convert_funcs/conversion_relation_to_static_leaf.go create mode 100644 convert_funcs/conversion_relation_to_static_path.go create mode 100644 convert_funcs/conversion_relation_to_taboo_contract.go create mode 100644 convert_funcs/conversion_relation_to_vrf_fallback_route_group.go create mode 100644 convert_funcs/conversion_route_control_profile.go create mode 100644 convert_funcs/conversion_tag.go create mode 100644 convert_funcs/conversion_trust_control_policy.go create mode 100644 convert_funcs/conversion_vrf_fallback_route.go create mode 100644 convert_funcs/conversion_vrf_fallback_route_group.go create mode 100644 convert_funcs/conversion_vrf_fallback_route_group_member.go create mode 100644 convert_funcs/dn_to_aci.go create mode 100644 convert_funcs/getAciClass.go create mode 100644 convert_funcs/resourceMap.go create mode 100644 gen/templates/conversion.go.tmpl create mode 100644 gen/templates/getAciClass.go.tmpl create mode 100644 gen/templates/new.go.tmpl create mode 100644 gen/templates/resourceMap.go.tmpl diff --git a/cmd/conversion/main.go b/cmd/conversion/main.go new file mode 100644 index 000000000..a45895302 --- /dev/null +++ b/cmd/conversion/main.go @@ -0,0 +1,281 @@ +package main + +import ( + "encoding/json" + "fmt" + "log" + "os" + "os/exec" + "strings" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/convert_funcs" +) + +type Plan struct { + PlannedValues struct { + RootModule struct { + Resources []Resource `json:"resources"` + } `json:"root_module"` + } `json:"planned_values"` + Changes []Change `json:"resource_changes"` +} + +type Resource struct { + Type string `json:"type"` + Name string `json:"name"` + Values map[string]interface{} `json:"values"` +} + +type Change struct { + Type string `json:"type"` + Change struct { + Actions []string `json:"actions"` + Before map[string]interface{} `json:"before"` + } `json:"change"` +} + +func runTerraform() (string, error) { + planBin := "plan.bin" + planJSON := "plan.json" + + if err := exec.Command("terraform", "plan", "-out="+planBin).Run(); err != nil { + return "", fmt.Errorf("failed to run terraform plan: %w", err) + } + + output, err := os.Create(planJSON) + if err != nil { + return "", fmt.Errorf("failed to create json file: %w", err) + } + defer output.Close() + + cmdShow := exec.Command("terraform", "show", "-json", planBin) + cmdShow.Stdout = output + if err := cmdShow.Run(); err != nil { + return "", fmt.Errorf("failed to run terraform show: %w", err) + } + + return planJSON, nil +} + +func readPlan(jsonFile string) (Plan, error) { + var plan Plan + data, err := os.ReadFile(jsonFile) + if err != nil { + return plan, fmt.Errorf("failed to read input file: %w", err) + } + + if err := json.Unmarshal(data, &plan); err != nil { + return plan, fmt.Errorf("failed to parse input file: %w", err) + } + + return plan, nil +} + +func writeToFile(outputFile string, data map[string]interface{}) error { + outputData, err := json.MarshalIndent(data, "", " ") + if err != nil { + return fmt.Errorf("failed to convert data to JSON: %w", err) + } + + if err := os.WriteFile(outputFile, outputData, 0644); err != nil { + return fmt.Errorf("failed to write output file: %w", err) + } + + return nil +} + +func createPayload(resourceType string, values map[string]interface{}, status string) map[string]interface{} { + if createFunc, exists := convert_funcs.ResourceMap[resourceType]; exists { + payload := createFunc(values, status) + return payload + } + return nil +} + +func createPayloadList(plan Plan) []map[string]interface{} { + var data []map[string]interface{} + + for _, change := range plan.Changes { + if len(change.Change.Actions) > 0 && change.Change.Actions[0] == "delete" { + payload := createPayload(change.Type, change.Change.Before, "deleted") + if payload != nil { + data = append(data, payload) + } + } + } + + for _, resource := range plan.PlannedValues.RootModule.Resources { + payload := createPayload(resource.Type, resource.Values, "") + if payload != nil { + for _, value := range payload { + if obj, ok := value.(map[string]interface{}); ok { + if attributes, ok := obj["attributes"].(map[string]interface{}); ok { + if parentDn, ok := resource.Values["parent_dn"].(string); ok && parentDn != "" { + attributes["parent_dn"] = parentDn + } + } + } + } + data = append(data, payload) + } + } + + return data +} + +// Work in progress... "panic: assignment to entry in nil map" for cases where AciClassMap() returns "" in this function +func constructTree(resources []map[string]interface{}) map[string]interface{} { + rootNode := map[string]interface{}{ + "children": []map[string]interface{}{}, + } + + nodeMap := map[string]map[string]interface{}{ + "uni": rootNode, + } + + for _, resourceList := range resources { + for resourceType, resourceData := range resourceList { + resourceAttributes := resourceData.(map[string]interface{}) + attributes := resourceAttributes["attributes"].(map[string]interface{}) + dn := attributes["dn"].(string) + + parentDn, hasParentDn := attributes["parent_dn"].(string) + if !hasParentDn || parentDn == "" { + pathSegments := strings.Split(dn, "/") + if len(pathSegments) > 1 { + parentDn = strings.Join(pathSegments[:len(pathSegments)-1], "/") + + } else { + parentDn = "uni" + } + } + + if _, parentExists := nodeMap[parentDn]; !parentExists { + createParentPath(nodeMap, parentDn) + } + + currentNode, nodeExists := nodeMap[dn] + if !nodeExists { + currentNode = map[string]interface{}{ + "attributes": attributes, + "children": resourceAttributes["children"], + } + } else { + + existingChildren, ok := currentNode["children"].([]map[string]interface{}) + if !ok || existingChildren == nil { + existingChildren = []map[string]interface{}{} + } + + newChildren, ok := resourceAttributes["children"].([]map[string]interface{}) + if ok && newChildren != nil { + currentNode["children"] = append(existingChildren, newChildren...) + } else { + currentNode["children"] = existingChildren + } + } + + parentNode := nodeMap[parentDn] + + className := convert_funcs.GetAciClass(strings.Split(dn, "/")[len(strings.Split(dn, "/"))-1]) + if className == "" { + className = resourceType + } + + parentChildren, ok := parentNode["children"].([]map[string]interface{}) + if !ok || parentChildren == nil { + parentChildren = []map[string]interface{}{} + } + + parentNode["children"] = append(parentChildren, map[string]interface{}{className: currentNode}) + + nodeMap[dn] = currentNode + } + } + + return map[string]interface{}{ + "uni": rootNode, + } +} + +func createParentPath(nodeMap map[string]map[string]interface{}, parentDn string) { + pathSegments := strings.Split(parentDn, "/") + currentDn := "uni" + var lastValidNode map[string]interface{} + + for _, segment := range pathSegments[1:] { + currentDn += "/" + segment + + className := convert_funcs.GetAciClass(strings.Split(segment, "-")[0]) + + if className == "" { + className = segment + } + + if _, exists := nodeMap[currentDn]; !exists { + newNode := map[string]interface{}{ + "attributes": map[string]interface{}{ + "dn": currentDn, + }, + "children": []map[string]interface{}{}, // Ensure children is always initialized + } + + // Attach this node to the last valid node or the root if at the top level + if lastValidNode == nil { + if _, ok := nodeMap["uni"]["children"]; !ok { + nodeMap["uni"]["children"] = []map[string]interface{}{} + } + nodeMap["uni"]["children"] = append(nodeMap["uni"]["children"].([]map[string]interface{}), map[string]interface{}{className: newNode}) + } else { + if _, ok := lastValidNode["children"]; !ok { + lastValidNode["children"] = []map[string]interface{}{} + } + lastValidNode["children"] = append(lastValidNode["children"].([]map[string]interface{}), map[string]interface{}{className: newNode}) + } + + nodeMap[currentDn] = newNode + } + + // Update the last valid node reference + lastValidNode = nodeMap[currentDn] + } +} + +func main() { + + if len(os.Args) != 1 { + fmt.Println("Usage: no arguments needed") + os.Exit(1) + } + + outputFile := "payload.json" + + planJSON, err := runTerraform() + if err != nil { + log.Fatalf("Error running Terraform: %v", err) + } + + plan, err := readPlan(planJSON) + if err != nil { + log.Fatalf("Error reading plan: %v", err) + } + + payloadList := createPayloadList(plan) + + jsonData, err := json.MarshalIndent(payloadList, "", " ") + if err != nil { + fmt.Println("Error:", err) + return + } + + fmt.Println(string(jsonData)) + + aciPayload := constructTree(payloadList) + + err = writeToFile(outputFile, aciPayload) + if err != nil { + log.Fatalf("Error writing output file: %v", err) + } + + fmt.Printf("ACI Payload written to %s\n", outputFile) +} diff --git a/cmd/conversion/main.tf b/cmd/conversion/main.tf new file mode 100644 index 000000000..4112b2153 --- /dev/null +++ b/cmd/conversion/main.tf @@ -0,0 +1,344 @@ +terraform { + required_providers { + aci = { + source = "CiscoDevNet/aci" + } + } +} + +# Configure the provider with your Cisco APIC credentials. +provider "aci" { + # APIC Username + username = "admin" + # APIC Password + password = "ins3965!" + # APIC URL + url = "https://173.36.219.79" + insecure = true +} + +# Defines an Application EPG Resource. + +resource "aci_application_epg" "fooapplication_epg" { + parent_dn = "uni/tn-common/ap-default" + name = "new_epg" + description = "from terraform" + annotation = "tag_epg" + contract_exception_tag = "0" + flood_in_encapsulation = "disabled" + forwarding_control = "none" + + relation_to_bridge_domain= [{ + annotation = "annotation1" + bridge_domain_name = "default" + }] +} + + +resource "aci_application_epg" "fooapplication_epg2" { + parent_dn = "uni/tn-common/ap-default222" + name = "new_epg2" + description = "from terraform" + annotation = "tag_epg" + contract_exception_tag = "0" + flood_in_encapsulation = "disabled" + forwarding_control = "none" + + relation_to_bridge_domain= [{ + annotation = "annotation1" + bridge_domain_name = "default" + }] +} + + +# Define an ACI Tenant Resource. + +/* +resource "aci_endpoint_tag_ip" "full_example_tenant" { + parent_dn = "uni/tn-common" + annotation = "annotation" + vrf_name = "test_ctx_name" + id_attribute = "1" + ip = "10.0.0.2" + name = "WOW" + name_alias = "name_alias" + annotations = [ + { + key = "key_0" + value = "vaule_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} +*/ + +//SUCCESS +/* +resource "aci_vrf_fallback_route_group" "full_example_vrf" { + parent_dn = "uni/tn-common" + annotation = "annotation" + description = "description" + name = "fallback_route_group" + name_alias = "name_alias" + vrf_fallback_route_group_members = [ + { + annotation = "annotation_1" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + fallback_member = "2.2.2.2" + } + ] + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} +*/ +/* +resource "aci_external_management_network_instance_profile" "full_example" { + annotation = "woidid" + description = "description" + name = "test_name" + name_alias = "name_alias" + priority = "level1" + relation_to_consumed_out_of_band_contracts = [ + { + annotation = "annotation_1" + priority = "level1" + out_of_band_contract_name = "aci_out_of_band_contract.example.name" + } + ] + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} +*/ +/* SUCCESS + +resource "aci_external_management_network_instance_profile" "full_example333" { + annotation = "annotation" + description = "description" + name = "test_name" + name_alias = "name_alias" + priority = "level1" + relation_to_consumed_out_of_band_contracts = [ + { + annotation = "annotation_1" + priority = "level1" + out_of_band_contract_name = "aci_out_of_band_contract.example.name" + } + ] + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +*/ + +/* +resource "aci_netflow_monitor_policy" "full_example_tenant" { + parent_dn = "uni/tn-mgmt/extmgmt-default/instp-test_name" + annotation = "annotation" + description = "description" + name = "netfow_monitor" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + relation_to_netflow_exporters = [ + { + annotation = "annotation_1" + netflow_exporter_policy_name = "aci_netflow_exporter_policy.example.name" + } + ] + relation_to_netflow_record = [ + { + annotation = "annotation_1" + netflow_record_policy_name = "aci_netflow_record_policy.example.name" + } + ] + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} +*/ + + +/* +resource "aci_tag" "example_tenant" { + parent_dn = "uni/tn-example_tenant" + key = "test_key" + value = "test_value" +} +*/ + + +/* + + + +*/ + +//DEFINES AN ACI ANNOTATION ------- TEST + + +resource "aci_annotation" "terraform_annotation" { + parent_dn = "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name" + key = "test_key" + value = "test_value" +} + + +resource "aci_annotation" "terraform_annotation2" { + parent_dn = "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]" + key = "test_keya" + value = "test_valuea" +} + + + +/* +resource "aci_pim_route_map_policy" "full_example_tenant" { + parent_dn = "uni/tn-demo_tenant" + annotation = "annotation" + description = "description" + name = "test_name" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} +*/ + +# Define an ACI Tenant VRF Resource. +# resource "aci_vrf" "terraform_vrf" { +# tenant_dn = aci_tenant.terraform_tenant.id +# description = "VRF Created Using Terraform" +# name = var.vrf +# } + +# # Define an ACI Tenant BD Resource. +# resource "aci_bridge_domain" "terraform_bd" { +# tenant_dn = aci_tenant.terraform_tenant.id +# relation_fv_rs_ctx = aci_vrf.terraform_vrf.id +# description = "BD Created Using Terraform" +# name = var.bd +# } + +# # Define an ACI Tenant BD Subnet Resource. +# resource "aci_subnet" "terraform_bd_subnet" { +# parent_dn = aci_bridge_domain.terraform_bd.id +# description = "Subnet Created Using Terraform" +# ip = var.subnet +# } + +# # Define an ACI Filter Resource. +# resource "aci_filter" "terraform_filter" { +# for_each = var.filters +# tenant_dn = aci_tenant.terraform_tenant.id +# description = "This is filter ${each.key} created by terraform" +# name = each.value.filter +# } + +# # Define an ACI Filter Entry Resource. +# resource "aci_filter_entry" "terraform_filter_entry" { +# for_each = var.filters +# filter_dn = aci_filter.terraform_filter[each.key].id +# name = each.value.entry +# ether_t = "ipv4" +# prot = each.value.protocol +# d_from_port = each.value.port +# d_to_port = each.value.port +# } + +# # Define an ACI Contract Resource. +# resource "aci_contract" "terraform_contract" { +# for_each = var.contracts +# tenant_dn = aci_tenant.terraform_tenant.id +# name = each.value.contract +# description = "Contract created using Terraform" +# } + +# # Define an ACI Contract Subject Resource. +# resource "aci_contract_subject" "terraform_contract_subject" { +# for_each = var.contracts +# contract_dn = aci_contract.terraform_contract[each.key].id +# name = each.value.subject +# relation_vz_rs_subj_filt_att = [aci_filter.terraform_filter[each.value.filter].id] +# } + +# # Define an ACI Application Profile Resource. +# resource "aci_application_profile" "terraform_ap" { +# tenant_dn = aci_tenant.terraform_tenant.id +# name = var.ap +# description = "App Profile Created Using Terraform" +# } + + + +# # Associate the EPG Resources with a VMM Domain. +# resource "aci_epg_to_domain" "terraform_epg_domain" { +# for_each = var.epgs +# application_epg_dn = aci_application_epg.terraform_epg[each.key].id +# tdn = "uni/vmmp-VMware/dom-aci_terraform_lab" +# } + +# # Associate the EPGs with the contrats +# resource "aci_epg_to_contract" "terraform_epg_contract" { +# for_each = var.epg_contracts +# application_epg_dn = aci_application_epg.terraform_epg[each.value.epg].id +# contract_dn = aci_contract.terraform_contract[each.value.contract].id +# contract_type = each.value.contract_type +# } + diff --git a/cmd/conversion/payload.json b/cmd/conversion/payload.json new file mode 100644 index 000000000..2b8a9ab49 --- /dev/null +++ b/cmd/conversion/payload.json @@ -0,0 +1,5 @@ +{ + "uni": { + "children": [] + } +} \ No newline at end of file diff --git a/cmd/conversion/plan.bin b/cmd/conversion/plan.bin new file mode 100755 index 0000000000000000000000000000000000000000..367ab57f3917c749c2a4b10de485e72d49037506 GIT binary patch literal 4927 zcmaJ_bySqw*B(F`=^i=+q`SKt>Fyc2y9DWGXhab%A>APK&JXXm z?$zu1?tRYMXRY(c-s{=#yVkSMb9B^E?hykp?$(hzi3#8rpaC!ezF<#R8+QYJQ~;8M z{xJB+px1*+k@y9wqA|;?F$TTSqj+SwPVo>D^+yVdn1m!GIp+exXZ{{X>rZXK3zL4V z#ibFk$O(~KTS+OL@#(yIv}|mwtZf~!lnJrYNE4rKmn<%eN4?|xhK{>Wj#t0F{<;^2 zJ;jYUT{Ej*sc?HUU9-tUj(s>@v;!ljWXtrA{>W$Z^j$mWv>zLhu+YYLVPlM(@0h0H z=(Ljfp>tEE`(n%Bhnm?(#r^_q7IXd5EsI7*V&BQ!Tc}OZ$JbF*^^SDevP-mBFL7~K z4pG}))KQ(bHazDCbjV;kHxtgmh3yti4o?MIY)2EPW=-M#OVg$g9sA3oW#W zpXAs6pb8V?I_TcDm2et(TiL(75+kLj+bmrIKAU&2244=4am$TI4aHa=Bn>TmND5CE z#$(lvxp!DG@Eme$@2J_%l++xGN5-iPB{PS!-P(^vASTIwRnu1>*y+zrb8=%9e%1!y zybt@={W;89bH|Uz+$T%^ND^~bUpq~v!Jdi_N47C|>Y+6n(2wjlDU)WpOEZZns#a+i zX00S55V;q9lubG{R99Hg<24r+4#>y&xGDgA+fg72!_iSHy00WkZ{@N_F@bqGY(^&p zv0XXi{OTZpCOW7D>TD=E#dKuU*BXT(fZJ%I^bTmy47wFGyC+v-deR&ZPYr~&Xr?el z-N}~&7bbb5;wLXLpfyo=S=8aBmkf)+$v1N{3~2eCuUVv6c3Ylk0ketV@+g^!CE>@J z4|Eb1$K`?Vi-bkWZNpQ1bufc(?}c+ z$~C2Cm>+9bqHd*YUN!ftM5W+92!_m7#aVep%0>$0$7#-pSKFpuWL3pbThwpAkI2Gy zSDJ)f@Q=)=Zi;tV7I)V!wZCuh*m(G*TuQD$r83s(atB)#_D62fw(a3INDa2!twVJHuX^dvbC` zRY>)TwHYJ`!Z6QcfpRB*7%(?GUOT8cM(2)U-#)$=EAVf>vTXMba65JnyuRIx+M1&K z#ti@<5IXAU7=r?d%Y^p;fN?wkK<8iO1pQAr@$t3s1^ulj3geo%QFQpR+dbuU&0IkoP(Sg&T!bbqSOh8oN-sfgmNpCl!1Q%A+6Q#+u^oiI>n z`1XMK@C2q3V9L*+lBQuA>0dhsRJhjjN=mZ!^0k0cX+jtQg6l0 zsm58mPztDCtw@s=Pg2+M1q4NCs~p znR=4WmO>)tsOic{YAZYCftD)v#6>$v&8S$+3Vp=PPBekp74`G^Pw{G&{BSeUaU`M> z;pJ`73KXEnoc^-#&!xe{`xa3#3H2o`%U=*v)~?r)tFYB?j?@50=XC|LmB;}EPmhMQ}HVt(yG2Q`^#C8 zXjRU5StcpC-DF4#sfR2RPYfg2m7Tocp%7+Jj+YR#EupMNqQ1%geM*!ms!N;&rRww~ zIy`2QVOXj;M^NlTQ)91wa-&j~+948E=T>?LwG17bK#VtzBZ*8(pIWoy^(GlLD9}g= z)5)AF{Zen@_w1j_>0^0!Jm4$lc%#H#KQJJI!fyYa<;}x4i92PbkB~*)QT*YW>P}?` z#C5FG_lSGU2BVCpt~6be+V~hK%?N2OSM(Nob_^U}o^pKbAYgHoe`N9e4|eP5O7J@^ zD?d404#MYrWpDcQ_aS6XiQ7-?8BlAI(SUHJzH9nL{}#DvxZ>A3`($>){e77_&k7oi zl1gQQ2WqOF99gF@fQ+K}%eZ=!TZi_U;yJ2IE9o%5iM-ORU64lA*S2)g{1PBaA@-1@ z>k%YmX=@P|L86Ln2TLSo+ZqVAXg|l-WeSQdZrNuI{$i;q=^@tBZONg<&3*l3=JODf zW-e3rNCp{}CqvM5(vsTnt>#}Zj%HR+zr%F?24OG4SfRaGmgiIv6{D_XLWkGZR2+(d>97u7nxhs`D?Y^7^rK zcO06L6aK*?`Jq#h*^)WF65kZp_~TlJS#1v$F7>GW8`7N&%#H?&7h63 z7&U0kEm@wPo~E09U6Oojzlt{{)D`bvO@TsE9-6{GS@Dh#`^AiB^NC@(rFb)wo?f8N zmDQ`>0_PWrs!8J9%BpTbZr`*l;esd$>|0ffol~wshf<0eTyE6HpXu85uQ>*59k5Nh zOrhj0D(#Bk=s0%d*&qFU0Q? z8t1zw(%~4`as%S1vgc`UQ^W(;w1UxdKZsn}M>%kVPFof((On-1Pj0Q&)dC7@V+Y!a-3%Q0mPH zds5--r_$Qo9_I<8>dwX};}l&wbJPM&#P7ADRk3Q}|TXNZzby1%s} z7OO)!TuDXN!JZ$SQB-|1jO1x%w*U@?TG^?wp?%cK-BBAaw>?ji*HEcz+lN_5>{ce> zr!r49Y-C+9b?9ejz0(34JM$nX!CM3)UyDOpA@#r!o%+;gQ8BLCv8hGJU+@g;MB(fw zQ~^nkxzYx_O*jydJzLYQDoMEg`T@8D^I@^u)h&tx%7rgQWjEv3^*>d+Mp$&hEKCd$ z``L;C`N?k-*d#xL9kc|oquciV&3N)@k-3lD##JQpHp8GMW{!FAR0d zq>l>3A?03wRUOfa^k!Y3N(SsyGI zC7HQUV@&IeW$woA|6PI#%3P?~?oL1A-!Be71~Hc}$lKcn?BVUk?kRki*^JY4X#SDZiImk5hOZebgG`B^RHbL|EmPtXY+c9;|0I>N6m|wU zpS@gsAKDm(Xeex3q4inSUS(M=oNSW@xn6`yg*KhNJ~}=1J6k-ycs^1xzx~Z=weaHX zczuFwH6$dsZG_WK+A7gXc2RrvE>DYoZ-vFPpozu@v$~3Q5?Y@Ue z7o^n(^g;rzw;vyu`^AR_jh*$>-uhoJPPFyxp0?1wXcJy_>vai4e+wCZZBetO* zq+f^lTvsDa9}KZu(B$L%$82^mc@Y_lAe{N`)f6(Wjk!9a-F5FFd*3x%#HQ zJcVZ^dtx}N;Glx0QGrax?OfeBm``0~FUP9;6{*5~JHb4&QMg*hc9rK_3T7YSEjh!q!<{l{>6s?qY*P9~8B9;OL?z zFPM}pa5UzVabQnVv*^ZBNCcr^aFrF(^lMuf0c11N7h%!J12bMm;^ovBmH?mDdMRSE zp;vu-zCk{Rq`zdFH$FMN263Jk3QKuMUozfo?s^}O_&OQ>q_JsG7WT}SCoAD7)<#~v z-6m+yaiDrYfow+zn7q8>GZxCk^Q`Iq#b=WvT)6>T!pYB(`V*6H=@BUu_M^?hM8{qN(EEpl3LR4Lb0tB&|&yN(t}KpV{y#!fT|G4%HXagxEEDMp8s$)Sl4!_Vo9}CleU-&WafpEW`$tS z4bhBzP9qx*-N>$-^Voal`IWhhrbCkZ*c^^fq=rBN^-n1BOgS!A)5Cq8yVOsh<(XUg z_bHUo8&7+IH>(r99^Z-nk_~`N$nG%;05E)~S32rQ$i#r3k1@acsvnOr|HN-kGruSQ zYGi&`ub?hU_;LCl`~RQq literal 0 HcmV?d00001 diff --git a/cmd/conversion/plan.json b/cmd/conversion/plan.json new file mode 100644 index 000000000..401610775 --- /dev/null +++ b/cmd/conversion/plan.json @@ -0,0 +1 @@ +{"format_version":"1.2","terraform_version":"1.8.5","planned_values":{"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"sensitive_values":{}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"sensitive_values":{}},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":2,"values":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default/epg-new_epg","name":"new_epg","parent_dn":"uni/tn-common/ap-default","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"sensitive_values":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":2,"values":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default222","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default222/epg-new_epg2","name":"new_epg2","parent_dn":"uni/tn-common/ap-default222","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"sensitive_values":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}]}},"resource_changes":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default/epg-new_epg","name":"new_epg","parent_dn":"uni/tn-common/ap-default","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"after_unknown":{"admin_state":true,"annotations":true,"epg_useg_block_statement":true,"has_mcast_source":true,"has_multicast_source":true,"intra_epg_isolation":true,"is_attr_based_epg":true,"match_criteria":true,"match_t":true,"name_alias":true,"pc_enf_pref":true,"pc_tag":true,"pref_gr_memb":true,"preferred_group_member":true,"prio":true,"priority":true,"relation_fv_rs_aepg_mon_pol":true,"relation_fv_rs_bd":true,"relation_fv_rs_cons":true,"relation_fv_rs_cons_if":true,"relation_fv_rs_cust_qos_pol":true,"relation_fv_rs_dpp_pol":true,"relation_fv_rs_fc_path_att":true,"relation_fv_rs_intra_epg":true,"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":true,"relation_fv_rs_prot_by":true,"relation_fv_rs_prov":true,"relation_fv_rs_sec_inherited":true,"relation_fv_rs_trust_ctrl":true,"relation_to_application_epg_monitoring_policy":true,"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":true,"relation_to_contract_masters":true,"relation_to_custom_qos_policy":true,"relation_to_data_plane_policing_policy":true,"relation_to_domains":true,"relation_to_fibre_channel_paths":true,"relation_to_imported_contracts":true,"relation_to_intra_epg_contracts":true,"relation_to_provided_contracts":true,"relation_to_static_leafs":true,"relation_to_static_paths":true,"relation_to_taboo_contracts":true,"relation_to_trust_control_policy":true,"shutdown":true,"tags":true,"useg_epg":true},"before_sensitive":false,"after_sensitive":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default222","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default222/epg-new_epg2","name":"new_epg2","parent_dn":"uni/tn-common/ap-default222","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"after_unknown":{"admin_state":true,"annotations":true,"epg_useg_block_statement":true,"has_mcast_source":true,"has_multicast_source":true,"intra_epg_isolation":true,"is_attr_based_epg":true,"match_criteria":true,"match_t":true,"name_alias":true,"pc_enf_pref":true,"pc_tag":true,"pref_gr_memb":true,"preferred_group_member":true,"prio":true,"priority":true,"relation_fv_rs_aepg_mon_pol":true,"relation_fv_rs_bd":true,"relation_fv_rs_cons":true,"relation_fv_rs_cons_if":true,"relation_fv_rs_cust_qos_pol":true,"relation_fv_rs_dpp_pol":true,"relation_fv_rs_fc_path_att":true,"relation_fv_rs_intra_epg":true,"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":true,"relation_fv_rs_prot_by":true,"relation_fv_rs_prov":true,"relation_fv_rs_sec_inherited":true,"relation_fv_rs_trust_ctrl":true,"relation_to_application_epg_monitoring_policy":true,"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":true,"relation_to_contract_masters":true,"relation_to_custom_qos_policy":true,"relation_to_data_plane_policing_policy":true,"relation_to_domains":true,"relation_to_fibre_channel_paths":true,"relation_to_imported_contracts":true,"relation_to_intra_epg_contracts":true,"relation_to_provided_contracts":true,"relation_to_static_leafs":true,"relation_to_static_paths":true,"relation_to_taboo_contracts":true,"relation_to_trust_control_policy":true,"shutdown":true,"tags":true,"useg_epg":true},"before_sensitive":false,"after_sensitive":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}}],"configuration":{"provider_config":{"aci":{"name":"aci","full_name":"registry.terraform.io/ciscodevnet/aci","expressions":{"insecure":{"constant_value":true},"password":{"constant_value":"ins3965!"},"url":{"constant_value":"https://173.36.219.79"},"username":{"constant_value":"admin"}}}},"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_key"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name"},"value":{"constant_value":"test_value"}},"schema_version":0},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_keya"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]"},"value":{"constant_value":"test_valuea"}},"schema_version":0},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"tag_epg"},"contract_exception_tag":{"constant_value":"0"},"description":{"constant_value":"from terraform"},"flood_in_encapsulation":{"constant_value":"disabled"},"forwarding_control":{"constant_value":"none"},"name":{"constant_value":"new_epg"},"parent_dn":{"constant_value":"uni/tn-common/ap-default"},"relation_to_bridge_domain":{"constant_value":[{"annotation":"annotation1","bridge_domain_name":"default"}]}},"schema_version":2},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"tag_epg"},"contract_exception_tag":{"constant_value":"0"},"description":{"constant_value":"from terraform"},"flood_in_encapsulation":{"constant_value":"disabled"},"forwarding_control":{"constant_value":"none"},"name":{"constant_value":"new_epg2"},"parent_dn":{"constant_value":"uni/tn-common/ap-default222"},"relation_to_bridge_domain":{"constant_value":[{"annotation":"annotation1","bridge_domain_name":"default"}]}},"schema_version":2}]}},"timestamp":"2024-08-21T20:55:24Z","applyable":true,"complete":true,"errored":false} diff --git a/convert_funcs/conversion_access_interface_override.go b/convert_funcs/conversion_access_interface_override.go new file mode 100644 index 000000000..f359c2b5e --- /dev/null +++ b/convert_funcs/conversion_access_interface_override.go @@ -0,0 +1,123 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateInfraHPathS(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.InfraHPathSResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planInfraRsHPathAtt := convertToInfraRsHPathAttInfraHPathS(attributes["relation_to_host_path"]) + planInfraRsPathToAccBaseGrp := convertToInfraRsPathToAccBaseGrpInfraHPathS(attributes["relation_to_access_interface_policy_group"]) + planTagAnnotation := convertToTagAnnotationInfraHPathS(attributes["annotations"]) + planTagTag := convertToTagTagInfraHPathS(attributes["tags"]) + + if status == "deleted" { + + provider.SetInfraHPathSId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "infraHPathS", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciInfraHPathS := provider.GetInfraHPathSCreateJsonPayload(ctx, &diags, true, data, planInfraRsHPathAtt, planInfraRsHPathAtt, planInfraRsPathToAccBaseGrp, planInfraRsPathToAccBaseGrp, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciInfraHPathS.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetInfraHPathSId(ctx, data) + attrs := payload["infraHPathS"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToInfraRsHPathAttInfraHPathS(resources interface{}) []provider.InfraRsHPathAttInfraHPathSResourceModel { + var planResources []provider.InfraRsHPathAttInfraHPathSResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.InfraRsHPathAttInfraHPathSResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TDn: types.StringValue(resourceMap["target_dn"].(string)), + }) + } + } + return planResources +} +func convertToInfraRsPathToAccBaseGrpInfraHPathS(resources interface{}) []provider.InfraRsPathToAccBaseGrpInfraHPathSResourceModel { + var planResources []provider.InfraRsPathToAccBaseGrpInfraHPathSResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.InfraRsPathToAccBaseGrpInfraHPathSResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TDn: types.StringValue(resourceMap["target_dn"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationInfraHPathS(resources interface{}) []provider.TagAnnotationInfraHPathSResourceModel { + var planResources []provider.TagAnnotationInfraHPathSResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationInfraHPathSResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagInfraHPathS(resources interface{}) []provider.TagTagInfraHPathSResourceModel { + var planResources []provider.TagTagInfraHPathSResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagInfraHPathSResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_annotation.go b/convert_funcs/conversion_annotation.go new file mode 100644 index 000000000..5926aeb5a --- /dev/null +++ b/convert_funcs/conversion_annotation.go @@ -0,0 +1,55 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateTagAnnotation(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.TagAnnotationResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["key"].(string); ok && v != "" { + data.Key = types.StringValue(v) + } + if v, ok := attributes["value"].(string); ok && v != "" { + data.Value = types.StringValue(v) + } + + if status == "deleted" { + + provider.SetTagAnnotationId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "tagAnnotation", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciTagAnnotation := provider.GetTagAnnotationCreateJsonPayload(ctx, &diags, true, data) + + jsonPayload := newAciTagAnnotation.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetTagAnnotationId(ctx, data) + attrs := payload["tagAnnotation"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} diff --git a/convert_funcs/conversion_application_epg.go b/convert_funcs/conversion_application_epg.go new file mode 100644 index 000000000..85934689f --- /dev/null +++ b/convert_funcs/conversion_application_epg.go @@ -0,0 +1,393 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvAEPg(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvAEPgResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["contract_exception_tag"].(string); ok && v != "" { + data.ExceptionTag = types.StringValue(v) + } + if v, ok := attributes["flood_in_encapsulation"].(string); ok && v != "" { + data.FloodOnEncap = types.StringValue(v) + } + if v, ok := attributes["forwarding_control"].(string); ok && v != "" { + data.FwdCtrl = types.StringValue(v) + } + if v, ok := attributes["has_multicast_source"].(string); ok && v != "" { + data.HasMcastSource = types.StringValue(v) + } + if v, ok := attributes["useg_epg"].(string); ok && v != "" { + data.IsAttrBasedEPg = types.StringValue(v) + } + if v, ok := attributes["match_criteria"].(string); ok && v != "" { + data.MatchT = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["intra_epg_isolation"].(string); ok && v != "" { + data.PcEnfPref = types.StringValue(v) + } + if v, ok := attributes["pc_tag"].(string); ok && v != "" { + data.PcTag = types.StringValue(v) + } + if v, ok := attributes["preferred_group_member"].(string); ok && v != "" { + data.PrefGrMemb = types.StringValue(v) + } + if v, ok := attributes["priority"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["admin_state"].(string); ok && v != "" { + data.Shutdown = types.StringValue(v) + } + planFvCrtrn := convertToFvCrtrnFvAEPg(attributes["epg_useg_block_statement"]) + planFvRsAEPgMonPol := convertToFvRsAEPgMonPolFvAEPg(attributes["relation_to_application_epg_monitoring_policy"]) + planFvRsBd := convertToFvRsBdFvAEPg(attributes["relation_to_bridge_domain"]) + planFvRsCons := convertToFvRsConsFvAEPg(attributes["relation_to_consumed_contracts"]) + planFvRsConsIf := convertToFvRsConsIfFvAEPg(attributes["relation_to_imported_contracts"]) + planFvRsCustQosPol := convertToFvRsCustQosPolFvAEPg(attributes["relation_to_custom_qos_policy"]) + planFvRsDomAtt := convertToFvRsDomAttFvAEPg(attributes["relation_to_domains"]) + planFvRsDppPol := convertToFvRsDppPolFvAEPg(attributes["relation_to_data_plane_policing_policy"]) + planFvRsFcPathAtt := convertToFvRsFcPathAttFvAEPg(attributes["relation_to_fibre_channel_paths"]) + planFvRsIntraEpg := convertToFvRsIntraEpgFvAEPg(attributes["relation_to_intra_epg_contracts"]) + planFvRsNodeAtt := convertToFvRsNodeAttFvAEPg(attributes["relation_to_static_leafs"]) + planFvRsPathAtt := convertToFvRsPathAttFvAEPg(attributes["relation_to_static_paths"]) + planFvRsProtBy := convertToFvRsProtByFvAEPg(attributes["relation_to_taboo_contracts"]) + planFvRsProv := convertToFvRsProvFvAEPg(attributes["relation_to_provided_contracts"]) + planFvRsSecInherited := convertToFvRsSecInheritedFvAEPg(attributes["relation_to_contract_masters"]) + planFvRsTrustCtrl := convertToFvRsTrustCtrlFvAEPg(attributes["relation_to_trust_control_policy"]) + planTagAnnotation := convertToTagAnnotationFvAEPg(attributes["annotations"]) + planTagTag := convertToTagTagFvAEPg(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvAEPgId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvAEPg", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvAEPg := provider.GetFvAEPgCreateJsonPayload(ctx, &diags, true, data, planFvCrtrn, planFvCrtrn, planFvRsAEPgMonPol, planFvRsAEPgMonPol, planFvRsBd, planFvRsBd, planFvRsCons, planFvRsCons, planFvRsConsIf, planFvRsConsIf, planFvRsCustQosPol, planFvRsCustQosPol, planFvRsDomAtt, planFvRsDomAtt, planFvRsDppPol, planFvRsDppPol, planFvRsFcPathAtt, planFvRsFcPathAtt, planFvRsIntraEpg, planFvRsIntraEpg, planFvRsNodeAtt, planFvRsNodeAtt, planFvRsPathAtt, planFvRsPathAtt, planFvRsProtBy, planFvRsProtBy, planFvRsProv, planFvRsProv, planFvRsSecInherited, planFvRsSecInherited, planFvRsTrustCtrl, planFvRsTrustCtrl, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvAEPg.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvAEPgId(ctx, data) + attrs := payload["fvAEPg"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToFvCrtrnFvAEPg(resources interface{}) []provider.FvCrtrnFvAEPgResourceModel { + var planResources []provider.FvCrtrnFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvCrtrnFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Descr: types.StringValue(resourceMap["description"].(string)), + Match: types.StringValue(resourceMap["match"].(string)), + Name: types.StringValue(resourceMap["name"].(string)), + NameAlias: types.StringValue(resourceMap["name_alias"].(string)), + OwnerKey: types.StringValue(resourceMap["owner_key"].(string)), + OwnerTag: types.StringValue(resourceMap["owner_tag"].(string)), + Prec: types.StringValue(resourceMap["precedence"].(string)), + Scope: types.StringValue(resourceMap["scope"].(string)), + }) + } + } + return planResources +} +func convertToFvRsAEPgMonPolFvAEPg(resources interface{}) []provider.FvRsAEPgMonPolFvAEPgResourceModel { + var planResources []provider.FvRsAEPgMonPolFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsAEPgMonPolFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnMonEPGPolName: types.StringValue(resourceMap["monitoring_policy_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsBdFvAEPg(resources interface{}) []provider.FvRsBdFvAEPgResourceModel { + var planResources []provider.FvRsBdFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsBdFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnFvBDName: types.StringValue(resourceMap["bridge_domain_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsConsFvAEPg(resources interface{}) []provider.FvRsConsFvAEPgResourceModel { + var planResources []provider.FvRsConsFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsConsFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Prio: types.StringValue(resourceMap["priority"].(string)), + TnVzBrCPName: types.StringValue(resourceMap["contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsConsIfFvAEPg(resources interface{}) []provider.FvRsConsIfFvAEPgResourceModel { + var planResources []provider.FvRsConsIfFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsConsIfFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Prio: types.StringValue(resourceMap["priority"].(string)), + TnVzCPIfName: types.StringValue(resourceMap["imported_contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsCustQosPolFvAEPg(resources interface{}) []provider.FvRsCustQosPolFvAEPgResourceModel { + var planResources []provider.FvRsCustQosPolFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsCustQosPolFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnQosCustomPolName: types.StringValue(resourceMap["custom_qos_policy_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsDomAttFvAEPg(resources interface{}) []provider.FvRsDomAttFvAEPgResourceModel { + var planResources []provider.FvRsDomAttFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsDomAttFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + BindingType: types.StringValue(resourceMap["binding_type"].(string)), + ClassPref: types.StringValue(resourceMap["class_preference"].(string)), + CustomEpgName: types.StringValue(resourceMap["custom_epg_name"].(string)), + Delimiter: types.StringValue(resourceMap["delimiter"].(string)), + Encap: types.StringValue(resourceMap["encapsulation"].(string)), + EncapMode: types.StringValue(resourceMap["encapsulation_mode"].(string)), + EpgCos: types.StringValue(resourceMap["epg_cos"].(string)), + EpgCosPref: types.StringValue(resourceMap["epg_cos_pref"].(string)), + InstrImedcy: types.StringValue(resourceMap["deployment_immediacy"].(string)), + IpamDhcpOverride: types.StringValue(resourceMap["ipam_dhcp_override"].(string)), + IpamEnabled: types.StringValue(resourceMap["ipam_enabled"].(string)), + IpamGateway: types.StringValue(resourceMap["ipam_gateway"].(string)), + LagPolicyName: types.StringValue(resourceMap["lag_policy_name"].(string)), + NetflowDir: types.StringValue(resourceMap["netflow_direction"].(string)), + NetflowPref: types.StringValue(resourceMap["enable_netflow"].(string)), + NumPorts: types.StringValue(resourceMap["number_of_ports"].(string)), + PortAllocation: types.StringValue(resourceMap["port_allocation"].(string)), + PrimaryEncap: types.StringValue(resourceMap["primary_encapsulation"].(string)), + PrimaryEncapInner: types.StringValue(resourceMap["primary_encapsulation_inner"].(string)), + ResImedcy: types.StringValue(resourceMap["resolution_immediacy"].(string)), + SecondaryEncapInner: types.StringValue(resourceMap["secondary_encapsulation_inner"].(string)), + SwitchingMode: types.StringValue(resourceMap["switching_mode"].(string)), + TDn: types.StringValue(resourceMap["target_dn"].(string)), + Untagged: types.StringValue(resourceMap["untagged"].(string)), + VnetOnly: types.StringValue(resourceMap["vnet_only"].(string)), + }) + } + } + return planResources +} +func convertToFvRsDppPolFvAEPg(resources interface{}) []provider.FvRsDppPolFvAEPgResourceModel { + var planResources []provider.FvRsDppPolFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsDppPolFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnQosDppPolName: types.StringValue(resourceMap["data_plane_policing_policy_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsFcPathAttFvAEPg(resources interface{}) []provider.FvRsFcPathAttFvAEPgResourceModel { + var planResources []provider.FvRsFcPathAttFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsFcPathAttFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Descr: types.StringValue(resourceMap["description"].(string)), + TDn: types.StringValue(resourceMap["target_dn"].(string)), + Vsan: types.StringValue(resourceMap["vsan"].(string)), + VsanMode: types.StringValue(resourceMap["vsan_mode"].(string)), + }) + } + } + return planResources +} +func convertToFvRsIntraEpgFvAEPg(resources interface{}) []provider.FvRsIntraEpgFvAEPgResourceModel { + var planResources []provider.FvRsIntraEpgFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsIntraEpgFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnVzBrCPName: types.StringValue(resourceMap["contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsNodeAttFvAEPg(resources interface{}) []provider.FvRsNodeAttFvAEPgResourceModel { + var planResources []provider.FvRsNodeAttFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsNodeAttFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Descr: types.StringValue(resourceMap["description"].(string)), + Encap: types.StringValue(resourceMap["encapsulation"].(string)), + InstrImedcy: types.StringValue(resourceMap["deployment_immediacy"].(string)), + Mode: types.StringValue(resourceMap["mode"].(string)), + TDn: types.StringValue(resourceMap["target_dn"].(string)), + }) + } + } + return planResources +} +func convertToFvRsPathAttFvAEPg(resources interface{}) []provider.FvRsPathAttFvAEPgResourceModel { + var planResources []provider.FvRsPathAttFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsPathAttFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Descr: types.StringValue(resourceMap["description"].(string)), + Encap: types.StringValue(resourceMap["encapsulation"].(string)), + InstrImedcy: types.StringValue(resourceMap["deployment_immediacy"].(string)), + Mode: types.StringValue(resourceMap["mode"].(string)), + PrimaryEncap: types.StringValue(resourceMap["primary_encapsulation"].(string)), + TDn: types.StringValue(resourceMap["target_dn"].(string)), + }) + } + } + return planResources +} +func convertToFvRsProtByFvAEPg(resources interface{}) []provider.FvRsProtByFvAEPgResourceModel { + var planResources []provider.FvRsProtByFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsProtByFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnVzTabooName: types.StringValue(resourceMap["taboo_contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsProvFvAEPg(resources interface{}) []provider.FvRsProvFvAEPgResourceModel { + var planResources []provider.FvRsProvFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsProvFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + MatchT: types.StringValue(resourceMap["match_criteria"].(string)), + Prio: types.StringValue(resourceMap["priority"].(string)), + TnVzBrCPName: types.StringValue(resourceMap["contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsSecInheritedFvAEPg(resources interface{}) []provider.FvRsSecInheritedFvAEPgResourceModel { + var planResources []provider.FvRsSecInheritedFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsSecInheritedFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TDn: types.StringValue(resourceMap["target_dn"].(string)), + }) + } + } + return planResources +} +func convertToFvRsTrustCtrlFvAEPg(resources interface{}) []provider.FvRsTrustCtrlFvAEPgResourceModel { + var planResources []provider.FvRsTrustCtrlFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsTrustCtrlFvAEPgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnFhsTrustCtrlPolName: types.StringValue(resourceMap["trust_control_policy_name"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationFvAEPg(resources interface{}) []provider.TagAnnotationFvAEPgResourceModel { + var planResources []provider.TagAnnotationFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvAEPgResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvAEPg(resources interface{}) []provider.TagTagFvAEPgResourceModel { + var planResources []provider.TagTagFvAEPgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvAEPgResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_custom_qos_policy.go b/convert_funcs/conversion_custom_qos_policy.go new file mode 100644 index 000000000..83a34c3a1 --- /dev/null +++ b/convert_funcs/conversion_custom_qos_policy.go @@ -0,0 +1,95 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateQosCustomPol(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.QosCustomPolResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationQosCustomPol(attributes["annotations"]) + planTagTag := convertToTagTagQosCustomPol(attributes["tags"]) + + if status == "deleted" { + + provider.SetQosCustomPolId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "qosCustomPol", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciQosCustomPol := provider.GetQosCustomPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciQosCustomPol.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetQosCustomPolId(ctx, data) + attrs := payload["qosCustomPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationQosCustomPol(resources interface{}) []provider.TagAnnotationQosCustomPolResourceModel { + var planResources []provider.TagAnnotationQosCustomPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationQosCustomPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagQosCustomPol(resources interface{}) []provider.TagTagQosCustomPolResourceModel { + var planResources []provider.TagTagQosCustomPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagQosCustomPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_data_plane_policing_policy.go b/convert_funcs/conversion_data_plane_policing_policy.go new file mode 100644 index 000000000..5dbc3c78f --- /dev/null +++ b/convert_funcs/conversion_data_plane_policing_policy.go @@ -0,0 +1,158 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateQosDppPol(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.QosDppPolResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["admin_state"].(string); ok && v != "" { + data.AdminSt = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["excessive_burst"].(string); ok && v != "" { + data.Be = types.StringValue(v) + } + if v, ok := attributes["excessive_burst_unit"].(string); ok && v != "" { + data.BeUnit = types.StringValue(v) + } + if v, ok := attributes["burst"].(string); ok && v != "" { + data.Burst = types.StringValue(v) + } + if v, ok := attributes["burst_unit"].(string); ok && v != "" { + data.BurstUnit = types.StringValue(v) + } + if v, ok := attributes["conform_action"].(string); ok && v != "" { + data.ConformAction = types.StringValue(v) + } + if v, ok := attributes["conform_mark_cos"].(string); ok && v != "" { + data.ConformMarkCos = types.StringValue(v) + } + if v, ok := attributes["conform_mark_dscp"].(string); ok && v != "" { + data.ConformMarkDscp = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["exceed_action"].(string); ok && v != "" { + data.ExceedAction = types.StringValue(v) + } + if v, ok := attributes["exceed_mark_cos"].(string); ok && v != "" { + data.ExceedMarkCos = types.StringValue(v) + } + if v, ok := attributes["exceed_mark_dscp"].(string); ok && v != "" { + data.ExceedMarkDscp = types.StringValue(v) + } + if v, ok := attributes["mode"].(string); ok && v != "" { + data.Mode = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["peak_rate"].(string); ok && v != "" { + data.Pir = types.StringValue(v) + } + if v, ok := attributes["peak_rate_unit"].(string); ok && v != "" { + data.PirUnit = types.StringValue(v) + } + if v, ok := attributes["rate"].(string); ok && v != "" { + data.Rate = types.StringValue(v) + } + if v, ok := attributes["rate_unit"].(string); ok && v != "" { + data.RateUnit = types.StringValue(v) + } + if v, ok := attributes["sharing_mode"].(string); ok && v != "" { + data.SharingMode = types.StringValue(v) + } + if v, ok := attributes["type"].(string); ok && v != "" { + data.Type = types.StringValue(v) + } + if v, ok := attributes["violate_action"].(string); ok && v != "" { + data.ViolateAction = types.StringValue(v) + } + if v, ok := attributes["violate_mark_cos"].(string); ok && v != "" { + data.ViolateMarkCos = types.StringValue(v) + } + if v, ok := attributes["violate_mark_dscp"].(string); ok && v != "" { + data.ViolateMarkDscp = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationQosDppPol(attributes["annotations"]) + planTagTag := convertToTagTagQosDppPol(attributes["tags"]) + + if status == "deleted" { + + provider.SetQosDppPolId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "qosDppPol", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciQosDppPol := provider.GetQosDppPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciQosDppPol.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetQosDppPolId(ctx, data) + attrs := payload["qosDppPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationQosDppPol(resources interface{}) []provider.TagAnnotationQosDppPolResourceModel { + var planResources []provider.TagAnnotationQosDppPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationQosDppPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagQosDppPol(resources interface{}) []provider.TagTagQosDppPolResourceModel { + var planResources []provider.TagTagQosDppPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagQosDppPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_endpoint_security_group.go b/convert_funcs/conversion_endpoint_security_group.go new file mode 100644 index 000000000..6d25ebfcf --- /dev/null +++ b/convert_funcs/conversion_endpoint_security_group.go @@ -0,0 +1,195 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvESg(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvESgResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["exception_tag"].(string); ok && v != "" { + data.ExceptionTag = types.StringValue(v) + } + if v, ok := attributes["match_criteria"].(string); ok && v != "" { + data.MatchT = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["intra_esg_isolation"].(string); ok && v != "" { + data.PcEnfPref = types.StringValue(v) + } + if v, ok := attributes["pc_tag"].(string); ok && v != "" { + data.PcTag = types.StringValue(v) + } + if v, ok := attributes["preferred_group_member"].(string); ok && v != "" { + data.PrefGrMemb = types.StringValue(v) + } + if v, ok := attributes["admin_state"].(string); ok && v != "" { + data.Shutdown = types.StringValue(v) + } + planFvRsCons := convertToFvRsConsFvESg(attributes["relation_to_consumed_contracts"]) + planFvRsConsIf := convertToFvRsConsIfFvESg(attributes["relation_to_imported_contracts"]) + planFvRsIntraEpg := convertToFvRsIntraEpgFvESg(attributes["relation_to_intra_epg_contracts"]) + planFvRsProv := convertToFvRsProvFvESg(attributes["relation_to_provided_contracts"]) + planFvRsScope := convertToFvRsScopeFvESg(attributes["relation_to_vrf"]) + planFvRsSecInherited := convertToFvRsSecInheritedFvESg(attributes["relation_to_contract_masters"]) + planTagAnnotation := convertToTagAnnotationFvESg(attributes["annotations"]) + planTagTag := convertToTagTagFvESg(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvESgId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvESg", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvESg := provider.GetFvESgCreateJsonPayload(ctx, &diags, true, data, planFvRsCons, planFvRsCons, planFvRsConsIf, planFvRsConsIf, planFvRsIntraEpg, planFvRsIntraEpg, planFvRsProv, planFvRsProv, planFvRsScope, planFvRsScope, planFvRsSecInherited, planFvRsSecInherited, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvESg.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvESgId(ctx, data) + attrs := payload["fvESg"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToFvRsConsFvESg(resources interface{}) []provider.FvRsConsFvESgResourceModel { + var planResources []provider.FvRsConsFvESgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsConsFvESgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Prio: types.StringValue(resourceMap["priority"].(string)), + TnVzBrCPName: types.StringValue(resourceMap["contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsConsIfFvESg(resources interface{}) []provider.FvRsConsIfFvESgResourceModel { + var planResources []provider.FvRsConsIfFvESgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsConsIfFvESgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Prio: types.StringValue(resourceMap["priority"].(string)), + TnVzCPIfName: types.StringValue(resourceMap["imported_contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsIntraEpgFvESg(resources interface{}) []provider.FvRsIntraEpgFvESgResourceModel { + var planResources []provider.FvRsIntraEpgFvESgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsIntraEpgFvESgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnVzBrCPName: types.StringValue(resourceMap["contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsProvFvESg(resources interface{}) []provider.FvRsProvFvESgResourceModel { + var planResources []provider.FvRsProvFvESgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsProvFvESgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + MatchT: types.StringValue(resourceMap["match_criteria"].(string)), + Prio: types.StringValue(resourceMap["priority"].(string)), + TnVzBrCPName: types.StringValue(resourceMap["contract_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsScopeFvESg(resources interface{}) []provider.FvRsScopeFvESgResourceModel { + var planResources []provider.FvRsScopeFvESgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsScopeFvESgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnFvCtxName: types.StringValue(resourceMap["vrf_name"].(string)), + }) + } + } + return planResources +} +func convertToFvRsSecInheritedFvESg(resources interface{}) []provider.FvRsSecInheritedFvESgResourceModel { + var planResources []provider.FvRsSecInheritedFvESgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvRsSecInheritedFvESgResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TDn: types.StringValue(resourceMap["target_dn"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationFvESg(resources interface{}) []provider.TagAnnotationFvESgResourceModel { + var planResources []provider.TagAnnotationFvESgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvESgResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvESg(resources interface{}) []provider.TagTagFvESgResourceModel { + var planResources []provider.TagTagFvESgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvESgResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_endpoint_tag_ip.go b/convert_funcs/conversion_endpoint_tag_ip.go new file mode 100644 index 000000000..30d5a9241 --- /dev/null +++ b/convert_funcs/conversion_endpoint_tag_ip.go @@ -0,0 +1,95 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvEpIpTag(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvEpIpTagResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["vrf_name"].(string); ok && v != "" { + data.CtxName = types.StringValue(v) + } + if v, ok := attributes["id_attribute"].(string); ok && v != "" { + data.FvEpIpTagId = types.StringValue(v) + } + if v, ok := attributes["ip"].(string); ok && v != "" { + data.Ip = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvEpIpTag(attributes["annotations"]) + planTagTag := convertToTagTagFvEpIpTag(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvEpIpTagId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvEpIpTag", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvEpIpTag := provider.GetFvEpIpTagCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvEpIpTag.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvEpIpTagId(ctx, data) + attrs := payload["fvEpIpTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvEpIpTag(resources interface{}) []provider.TagAnnotationFvEpIpTagResourceModel { + var planResources []provider.TagAnnotationFvEpIpTagResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvEpIpTagResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvEpIpTag(resources interface{}) []provider.TagTagFvEpIpTagResourceModel { + var planResources []provider.TagTagFvEpIpTagResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvEpIpTagResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_endpoint_tag_mac.go b/convert_funcs/conversion_endpoint_tag_mac.go new file mode 100644 index 000000000..4d1e0b767 --- /dev/null +++ b/convert_funcs/conversion_endpoint_tag_mac.go @@ -0,0 +1,95 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvEpMacTag(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvEpMacTagResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["bd_name"].(string); ok && v != "" { + data.BdName = types.StringValue(v) + } + if v, ok := attributes["id_attribute"].(string); ok && v != "" { + data.FvEpMacTagId = types.StringValue(v) + } + if v, ok := attributes["mac"].(string); ok && v != "" { + data.Mac = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvEpMacTag(attributes["annotations"]) + planTagTag := convertToTagTagFvEpMacTag(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvEpMacTagId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvEpMacTag", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvEpMacTag := provider.GetFvEpMacTagCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvEpMacTag.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvEpMacTagId(ctx, data) + attrs := payload["fvEpMacTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvEpMacTag(resources interface{}) []provider.TagAnnotationFvEpMacTagResourceModel { + var planResources []provider.TagAnnotationFvEpMacTagResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvEpMacTagResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvEpMacTag(resources interface{}) []provider.TagTagFvEpMacTagResourceModel { + var planResources []provider.TagTagFvEpMacTagResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvEpMacTagResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_epg_useg_ad_group_attribute.go b/convert_funcs/conversion_epg_useg_ad_group_attribute.go new file mode 100644 index 000000000..5e59eb0c1 --- /dev/null +++ b/convert_funcs/conversion_epg_useg_ad_group_attribute.go @@ -0,0 +1,98 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvIdGroupAttr(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvIdGroupAttrResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["selector"].(string); ok && v != "" { + data.Selector = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvIdGroupAttr(attributes["annotations"]) + planTagTag := convertToTagTagFvIdGroupAttr(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvIdGroupAttrId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvIdGroupAttr", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvIdGroupAttr := provider.GetFvIdGroupAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvIdGroupAttr.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvIdGroupAttrId(ctx, data) + attrs := payload["fvIdGroupAttr"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvIdGroupAttr(resources interface{}) []provider.TagAnnotationFvIdGroupAttrResourceModel { + var planResources []provider.TagAnnotationFvIdGroupAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvIdGroupAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvIdGroupAttr(resources interface{}) []provider.TagTagFvIdGroupAttrResourceModel { + var planResources []provider.TagTagFvIdGroupAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvIdGroupAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_epg_useg_block_statement.go b/convert_funcs/conversion_epg_useg_block_statement.go new file mode 100644 index 000000000..d65b09419 --- /dev/null +++ b/convert_funcs/conversion_epg_useg_block_statement.go @@ -0,0 +1,104 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvCrtrn(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvCrtrnResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["match"].(string); ok && v != "" { + data.Match = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["precedence"].(string); ok && v != "" { + data.Prec = types.StringValue(v) + } + if v, ok := attributes["scope"].(string); ok && v != "" { + data.Scope = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvCrtrn(attributes["annotations"]) + planTagTag := convertToTagTagFvCrtrn(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvCrtrnId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvCrtrn", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvCrtrn := provider.GetFvCrtrnCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvCrtrn.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvCrtrnId(ctx, data) + attrs := payload["fvCrtrn"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvCrtrn(resources interface{}) []provider.TagAnnotationFvCrtrnResourceModel { + var planResources []provider.TagAnnotationFvCrtrnResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvCrtrnResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvCrtrn(resources interface{}) []provider.TagTagFvCrtrnResourceModel { + var planResources []provider.TagTagFvCrtrnResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvCrtrnResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_epg_useg_dns_attribute.go b/convert_funcs/conversion_epg_useg_dns_attribute.go new file mode 100644 index 000000000..ef9db4227 --- /dev/null +++ b/convert_funcs/conversion_epg_useg_dns_attribute.go @@ -0,0 +1,98 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvDnsAttr(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvDnsAttrResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["filter"].(string); ok && v != "" { + data.Filter = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvDnsAttr(attributes["annotations"]) + planTagTag := convertToTagTagFvDnsAttr(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvDnsAttrId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvDnsAttr", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvDnsAttr := provider.GetFvDnsAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvDnsAttr.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvDnsAttrId(ctx, data) + attrs := payload["fvDnsAttr"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvDnsAttr(resources interface{}) []provider.TagAnnotationFvDnsAttrResourceModel { + var planResources []provider.TagAnnotationFvDnsAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvDnsAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvDnsAttr(resources interface{}) []provider.TagTagFvDnsAttrResourceModel { + var planResources []provider.TagTagFvDnsAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvDnsAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_epg_useg_ip_attribute.go b/convert_funcs/conversion_epg_useg_ip_attribute.go new file mode 100644 index 000000000..f73e78d1e --- /dev/null +++ b/convert_funcs/conversion_epg_useg_ip_attribute.go @@ -0,0 +1,101 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvIpAttr(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvIpAttrResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["ip"].(string); ok && v != "" { + data.Ip = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["use_epg_subnet"].(string); ok && v != "" { + data.UsefvSubnet = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvIpAttr(attributes["annotations"]) + planTagTag := convertToTagTagFvIpAttr(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvIpAttrId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvIpAttr", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvIpAttr := provider.GetFvIpAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvIpAttr.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvIpAttrId(ctx, data) + attrs := payload["fvIpAttr"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvIpAttr(resources interface{}) []provider.TagAnnotationFvIpAttrResourceModel { + var planResources []provider.TagAnnotationFvIpAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvIpAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvIpAttr(resources interface{}) []provider.TagTagFvIpAttrResourceModel { + var planResources []provider.TagTagFvIpAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvIpAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_epg_useg_mac_attribute.go b/convert_funcs/conversion_epg_useg_mac_attribute.go new file mode 100644 index 000000000..b328d5098 --- /dev/null +++ b/convert_funcs/conversion_epg_useg_mac_attribute.go @@ -0,0 +1,98 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvMacAttr(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvMacAttrResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["mac"].(string); ok && v != "" { + data.Mac = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvMacAttr(attributes["annotations"]) + planTagTag := convertToTagTagFvMacAttr(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvMacAttrId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvMacAttr", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvMacAttr := provider.GetFvMacAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvMacAttr.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvMacAttrId(ctx, data) + attrs := payload["fvMacAttr"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvMacAttr(resources interface{}) []provider.TagAnnotationFvMacAttrResourceModel { + var planResources []provider.TagAnnotationFvMacAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvMacAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvMacAttr(resources interface{}) []provider.TagTagFvMacAttrResourceModel { + var planResources []provider.TagTagFvMacAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvMacAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_epg_useg_sub_block_statement.go b/convert_funcs/conversion_epg_useg_sub_block_statement.go new file mode 100644 index 000000000..b810d9541 --- /dev/null +++ b/convert_funcs/conversion_epg_useg_sub_block_statement.go @@ -0,0 +1,98 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvSCrtrn(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvSCrtrnResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["match"].(string); ok && v != "" { + data.Match = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvSCrtrn(attributes["annotations"]) + planTagTag := convertToTagTagFvSCrtrn(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvSCrtrnId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvSCrtrn", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvSCrtrn := provider.GetFvSCrtrnCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvSCrtrn.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvSCrtrnId(ctx, data) + attrs := payload["fvSCrtrn"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvSCrtrn(resources interface{}) []provider.TagAnnotationFvSCrtrnResourceModel { + var planResources []provider.TagAnnotationFvSCrtrnResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvSCrtrnResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvSCrtrn(resources interface{}) []provider.TagTagFvSCrtrnResourceModel { + var planResources []provider.TagTagFvSCrtrnResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvSCrtrnResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_epg_useg_vm_attribute.go b/convert_funcs/conversion_epg_useg_vm_attribute.go new file mode 100644 index 000000000..8b33cbc5c --- /dev/null +++ b/convert_funcs/conversion_epg_useg_vm_attribute.go @@ -0,0 +1,110 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvVmAttr(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvVmAttrResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["category"].(string); ok && v != "" { + data.Category = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["label_name"].(string); ok && v != "" { + data.LabelName = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["operator"].(string); ok && v != "" { + data.Operator = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["type"].(string); ok && v != "" { + data.Type = types.StringValue(v) + } + if v, ok := attributes["value"].(string); ok && v != "" { + data.Value = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvVmAttr(attributes["annotations"]) + planTagTag := convertToTagTagFvVmAttr(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvVmAttrId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvVmAttr", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvVmAttr := provider.GetFvVmAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvVmAttr.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvVmAttrId(ctx, data) + attrs := payload["fvVmAttr"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvVmAttr(resources interface{}) []provider.TagAnnotationFvVmAttrResourceModel { + var planResources []provider.TagAnnotationFvVmAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvVmAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvVmAttr(resources interface{}) []provider.TagTagFvVmAttrResourceModel { + var planResources []provider.TagTagFvVmAttrResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvVmAttrResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_external_management_network_instance_profile.go b/convert_funcs/conversion_external_management_network_instance_profile.go new file mode 100644 index 000000000..19cba8f1a --- /dev/null +++ b/convert_funcs/conversion_external_management_network_instance_profile.go @@ -0,0 +1,104 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateMgmtInstP(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.MgmtInstPResourceModel{} + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["priority"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + planMgmtRsOoBCons := convertToMgmtRsOoBConsMgmtInstP(attributes["relation_to_consumed_out_of_band_contracts"]) + planTagAnnotation := convertToTagAnnotationMgmtInstP(attributes["annotations"]) + planTagTag := convertToTagTagMgmtInstP(attributes["tags"]) + + if status == "deleted" { + + provider.SetMgmtInstPId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "mgmtInstP", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciMgmtInstP := provider.GetMgmtInstPCreateJsonPayload(ctx, &diags, true, data, planMgmtRsOoBCons, planMgmtRsOoBCons, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtInstP.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetMgmtInstPId(ctx, data) + attrs := payload["mgmtInstP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToMgmtRsOoBConsMgmtInstP(resources interface{}) []provider.MgmtRsOoBConsMgmtInstPResourceModel { + var planResources []provider.MgmtRsOoBConsMgmtInstPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.MgmtRsOoBConsMgmtInstPResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Prio: types.StringValue(resourceMap["priority"].(string)), + TnVzOOBBrCPName: types.StringValue(resourceMap["out_of_band_contract_name"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationMgmtInstP(resources interface{}) []provider.TagAnnotationMgmtInstPResourceModel { + var planResources []provider.TagAnnotationMgmtInstPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationMgmtInstPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagMgmtInstP(resources interface{}) []provider.TagTagMgmtInstPResourceModel { + var planResources []provider.TagTagMgmtInstPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagMgmtInstPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_external_management_network_subnet.go b/convert_funcs/conversion_external_management_network_subnet.go new file mode 100644 index 000000000..3b8d0c344 --- /dev/null +++ b/convert_funcs/conversion_external_management_network_subnet.go @@ -0,0 +1,92 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateMgmtSubnet(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.MgmtSubnetResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["ip"].(string); ok && v != "" { + data.Ip = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationMgmtSubnet(attributes["annotations"]) + planTagTag := convertToTagTagMgmtSubnet(attributes["tags"]) + + if status == "deleted" { + + provider.SetMgmtSubnetId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "mgmtSubnet", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciMgmtSubnet := provider.GetMgmtSubnetCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtSubnet.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetMgmtSubnetId(ctx, data) + attrs := payload["mgmtSubnet"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationMgmtSubnet(resources interface{}) []provider.TagAnnotationMgmtSubnetResourceModel { + var planResources []provider.TagAnnotationMgmtSubnetResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationMgmtSubnetResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagMgmtSubnet(resources interface{}) []provider.TagTagMgmtSubnetResourceModel { + var planResources []provider.TagTagMgmtSubnetResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagMgmtSubnetResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_l3out_consumer_label.go b/convert_funcs/conversion_l3out_consumer_label.go new file mode 100644 index 000000000..e6e986e23 --- /dev/null +++ b/convert_funcs/conversion_l3out_consumer_label.go @@ -0,0 +1,101 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateL3extConsLbl(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.L3extConsLblResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner"].(string); ok && v != "" { + data.Owner = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["tag"].(string); ok && v != "" { + data.Tag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extConsLbl(attributes["annotations"]) + planTagTag := convertToTagTagL3extConsLbl(attributes["tags"]) + + if status == "deleted" { + + provider.SetL3extConsLblId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "l3extConsLbl", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciL3extConsLbl := provider.GetL3extConsLblCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extConsLbl.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetL3extConsLblId(ctx, data) + attrs := payload["l3extConsLbl"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationL3extConsLbl(resources interface{}) []provider.TagAnnotationL3extConsLblResourceModel { + var planResources []provider.TagAnnotationL3extConsLblResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationL3extConsLblResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagL3extConsLbl(resources interface{}) []provider.TagTagL3extConsLblResourceModel { + var planResources []provider.TagTagL3extConsLblResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagL3extConsLblResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_l3out_node_sid_profile.go b/convert_funcs/conversion_l3out_node_sid_profile.go new file mode 100644 index 000000000..a63b2c7aa --- /dev/null +++ b/convert_funcs/conversion_l3out_node_sid_profile.go @@ -0,0 +1,95 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateMplsNodeSidP(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.MplsNodeSidPResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["loopback_address"].(string); ok && v != "" { + data.LoopbackAddr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["segment_id"].(string); ok && v != "" { + data.Sidoffset = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationMplsNodeSidP(attributes["annotations"]) + planTagTag := convertToTagTagMplsNodeSidP(attributes["tags"]) + + if status == "deleted" { + + provider.SetMplsNodeSidPId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "mplsNodeSidP", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciMplsNodeSidP := provider.GetMplsNodeSidPCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMplsNodeSidP.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetMplsNodeSidPId(ctx, data) + attrs := payload["mplsNodeSidP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationMplsNodeSidP(resources interface{}) []provider.TagAnnotationMplsNodeSidPResourceModel { + var planResources []provider.TagAnnotationMplsNodeSidPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationMplsNodeSidPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagMplsNodeSidP(resources interface{}) []provider.TagTagMplsNodeSidPResourceModel { + var planResources []provider.TagTagMplsNodeSidPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagMplsNodeSidPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_l3out_provider_label.go b/convert_funcs/conversion_l3out_provider_label.go new file mode 100644 index 000000000..63118a5a7 --- /dev/null +++ b/convert_funcs/conversion_l3out_provider_label.go @@ -0,0 +1,98 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateL3extProvLbl(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.L3extProvLblResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["tag"].(string); ok && v != "" { + data.Tag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extProvLbl(attributes["annotations"]) + planTagTag := convertToTagTagL3extProvLbl(attributes["tags"]) + + if status == "deleted" { + + provider.SetL3extProvLblId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "l3extProvLbl", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciL3extProvLbl := provider.GetL3extProvLblCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extProvLbl.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetL3extProvLblId(ctx, data) + attrs := payload["l3extProvLbl"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationL3extProvLbl(resources interface{}) []provider.TagAnnotationL3extProvLblResourceModel { + var planResources []provider.TagAnnotationL3extProvLblResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationL3extProvLblResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagL3extProvLbl(resources interface{}) []provider.TagTagL3extProvLblResourceModel { + var planResources []provider.TagTagL3extProvLblResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagL3extProvLblResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_l3out_redistribute_policy.go b/convert_funcs/conversion_l3out_redistribute_policy.go new file mode 100644 index 000000000..ccf1f7fb2 --- /dev/null +++ b/convert_funcs/conversion_l3out_redistribute_policy.go @@ -0,0 +1,86 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateL3extRsRedistributePol(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.L3extRsRedistributePolResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["source"].(string); ok && v != "" { + data.Src = types.StringValue(v) + } + if v, ok := attributes["route_control_profile_name"].(string); ok && v != "" { + data.TnRtctrlProfileName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extRsRedistributePol(attributes["annotations"]) + planTagTag := convertToTagTagL3extRsRedistributePol(attributes["tags"]) + + if status == "deleted" { + + provider.SetL3extRsRedistributePolId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "l3extRsRedistributePol", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciL3extRsRedistributePol := provider.GetL3extRsRedistributePolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extRsRedistributePol.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetL3extRsRedistributePolId(ctx, data) + attrs := payload["l3extRsRedistributePol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationL3extRsRedistributePol(resources interface{}) []provider.TagAnnotationL3extRsRedistributePolResourceModel { + var planResources []provider.TagAnnotationL3extRsRedistributePolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationL3extRsRedistributePolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagL3extRsRedistributePol(resources interface{}) []provider.TagTagL3extRsRedistributePolResourceModel { + var planResources []provider.TagTagL3extRsRedistributePolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagL3extRsRedistributePolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_netflow_monitor_policy.go b/convert_funcs/conversion_netflow_monitor_policy.go new file mode 100644 index 000000000..05f2c72d5 --- /dev/null +++ b/convert_funcs/conversion_netflow_monitor_policy.go @@ -0,0 +1,123 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateNetflowMonitorPol(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.NetflowMonitorPolResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planNetflowRsMonitorToExporter := convertToNetflowRsMonitorToExporterNetflowMonitorPol(attributes["relation_to_netflow_exporters"]) + planNetflowRsMonitorToRecord := convertToNetflowRsMonitorToRecordNetflowMonitorPol(attributes["relation_to_netflow_record"]) + planTagAnnotation := convertToTagAnnotationNetflowMonitorPol(attributes["annotations"]) + planTagTag := convertToTagTagNetflowMonitorPol(attributes["tags"]) + + if status == "deleted" { + + provider.SetNetflowMonitorPolId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "netflowMonitorPol", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciNetflowMonitorPol := provider.GetNetflowMonitorPolCreateJsonPayload(ctx, &diags, true, data, planNetflowRsMonitorToExporter, planNetflowRsMonitorToExporter, planNetflowRsMonitorToRecord, planNetflowRsMonitorToRecord, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciNetflowMonitorPol.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetNetflowMonitorPolId(ctx, data) + attrs := payload["netflowMonitorPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToNetflowRsMonitorToExporterNetflowMonitorPol(resources interface{}) []provider.NetflowRsMonitorToExporterNetflowMonitorPolResourceModel { + var planResources []provider.NetflowRsMonitorToExporterNetflowMonitorPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.NetflowRsMonitorToExporterNetflowMonitorPolResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnNetflowExporterPolName: types.StringValue(resourceMap["netflow_exporter_policy_name"].(string)), + }) + } + } + return planResources +} +func convertToNetflowRsMonitorToRecordNetflowMonitorPol(resources interface{}) []provider.NetflowRsMonitorToRecordNetflowMonitorPolResourceModel { + var planResources []provider.NetflowRsMonitorToRecordNetflowMonitorPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.NetflowRsMonitorToRecordNetflowMonitorPolResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + TnNetflowRecordPolName: types.StringValue(resourceMap["netflow_record_policy_name"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationNetflowMonitorPol(resources interface{}) []provider.TagAnnotationNetflowMonitorPolResourceModel { + var planResources []provider.TagAnnotationNetflowMonitorPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationNetflowMonitorPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagNetflowMonitorPol(resources interface{}) []provider.TagTagNetflowMonitorPolResourceModel { + var planResources []provider.TagTagNetflowMonitorPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagNetflowMonitorPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_netflow_record_policy.go b/convert_funcs/conversion_netflow_record_policy.go new file mode 100644 index 000000000..261a88856 --- /dev/null +++ b/convert_funcs/conversion_netflow_record_policy.go @@ -0,0 +1,95 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateNetflowRecordPol(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.NetflowRecordPolResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationNetflowRecordPol(attributes["annotations"]) + planTagTag := convertToTagTagNetflowRecordPol(attributes["tags"]) + + if status == "deleted" { + + provider.SetNetflowRecordPolId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "netflowRecordPol", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciNetflowRecordPol := provider.GetNetflowRecordPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciNetflowRecordPol.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetNetflowRecordPolId(ctx, data) + attrs := payload["netflowRecordPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationNetflowRecordPol(resources interface{}) []provider.TagAnnotationNetflowRecordPolResourceModel { + var planResources []provider.TagAnnotationNetflowRecordPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationNetflowRecordPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagNetflowRecordPol(resources interface{}) []provider.TagTagNetflowRecordPolResourceModel { + var planResources []provider.TagTagNetflowRecordPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagNetflowRecordPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_out_of_band_contract.go b/convert_funcs/conversion_out_of_band_contract.go new file mode 100644 index 000000000..c0a727714 --- /dev/null +++ b/convert_funcs/conversion_out_of_band_contract.go @@ -0,0 +1,104 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateVzOOBBrCP(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.VzOOBBrCPResourceModel{} + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["intent"].(string); ok && v != "" { + data.Intent = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["priority"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["scope"].(string); ok && v != "" { + data.Scope = types.StringValue(v) + } + if v, ok := attributes["target_dscp"].(string); ok && v != "" { + data.TargetDscp = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationVzOOBBrCP(attributes["annotations"]) + planTagTag := convertToTagTagVzOOBBrCP(attributes["tags"]) + + if status == "deleted" { + + provider.SetVzOOBBrCPId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "vzOOBBrCP", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciVzOOBBrCP := provider.GetVzOOBBrCPCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciVzOOBBrCP.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetVzOOBBrCPId(ctx, data) + attrs := payload["vzOOBBrCP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationVzOOBBrCP(resources interface{}) []provider.TagAnnotationVzOOBBrCPResourceModel { + var planResources []provider.TagAnnotationVzOOBBrCPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationVzOOBBrCPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagVzOOBBrCP(resources interface{}) []provider.TagTagVzOOBBrCPResourceModel { + var planResources []provider.TagTagVzOOBBrCPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagVzOOBBrCPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_pim_route_map_entry.go b/convert_funcs/conversion_pim_route_map_entry.go new file mode 100644 index 000000000..b92804832 --- /dev/null +++ b/convert_funcs/conversion_pim_route_map_entry.go @@ -0,0 +1,104 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreatePimRouteMapEntry(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.PimRouteMapEntryResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["action"].(string); ok && v != "" { + data.Action = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["group_ip"].(string); ok && v != "" { + data.Grp = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["order"].(string); ok && v != "" { + data.Order = types.StringValue(v) + } + if v, ok := attributes["rendezvous_point_ip"].(string); ok && v != "" { + data.Rp = types.StringValue(v) + } + if v, ok := attributes["source_ip"].(string); ok && v != "" { + data.Src = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationPimRouteMapEntry(attributes["annotations"]) + planTagTag := convertToTagTagPimRouteMapEntry(attributes["tags"]) + + if status == "deleted" { + + provider.SetPimRouteMapEntryId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "pimRouteMapEntry", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciPimRouteMapEntry := provider.GetPimRouteMapEntryCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciPimRouteMapEntry.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetPimRouteMapEntryId(ctx, data) + attrs := payload["pimRouteMapEntry"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationPimRouteMapEntry(resources interface{}) []provider.TagAnnotationPimRouteMapEntryResourceModel { + var planResources []provider.TagAnnotationPimRouteMapEntryResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationPimRouteMapEntryResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagPimRouteMapEntry(resources interface{}) []provider.TagTagPimRouteMapEntryResourceModel { + var planResources []provider.TagTagPimRouteMapEntryResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagPimRouteMapEntryResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_pim_route_map_policy.go b/convert_funcs/conversion_pim_route_map_policy.go new file mode 100644 index 000000000..459cc7c6a --- /dev/null +++ b/convert_funcs/conversion_pim_route_map_policy.go @@ -0,0 +1,95 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreatePimRouteMapPol(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.PimRouteMapPolResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationPimRouteMapPol(attributes["annotations"]) + planTagTag := convertToTagTagPimRouteMapPol(attributes["tags"]) + + if status == "deleted" { + + provider.SetPimRouteMapPolId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "pimRouteMapPol", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciPimRouteMapPol := provider.GetPimRouteMapPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciPimRouteMapPol.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetPimRouteMapPolId(ctx, data) + attrs := payload["pimRouteMapPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationPimRouteMapPol(resources interface{}) []provider.TagAnnotationPimRouteMapPolResourceModel { + var planResources []provider.TagAnnotationPimRouteMapPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationPimRouteMapPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagPimRouteMapPol(resources interface{}) []provider.TagTagPimRouteMapPolResourceModel { + var planResources []provider.TagTagPimRouteMapPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagPimRouteMapPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_consumed_contract.go b/convert_funcs/conversion_relation_to_consumed_contract.go new file mode 100644 index 000000000..2e8f8efbc --- /dev/null +++ b/convert_funcs/conversion_relation_to_consumed_contract.go @@ -0,0 +1,86 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsCons(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsConsResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["priority"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["contract_name"].(string); ok && v != "" { + data.TnVzBrCPName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsCons(attributes["annotations"]) + planTagTag := convertToTagTagFvRsCons(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsConsId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsCons", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsCons := provider.GetFvRsConsCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsCons.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsConsId(ctx, data) + attrs := payload["fvRsCons"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsCons(resources interface{}) []provider.TagAnnotationFvRsConsResourceModel { + var planResources []provider.TagAnnotationFvRsConsResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsConsResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsCons(resources interface{}) []provider.TagTagFvRsConsResourceModel { + var planResources []provider.TagTagFvRsConsResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsConsResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go b/convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go new file mode 100644 index 000000000..6a6531a7c --- /dev/null +++ b/convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go @@ -0,0 +1,86 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateMgmtRsOoBCons(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.MgmtRsOoBConsResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["priority"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["out_of_band_contract_name"].(string); ok && v != "" { + data.TnVzOOBBrCPName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationMgmtRsOoBCons(attributes["annotations"]) + planTagTag := convertToTagTagMgmtRsOoBCons(attributes["tags"]) + + if status == "deleted" { + + provider.SetMgmtRsOoBConsId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "mgmtRsOoBCons", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciMgmtRsOoBCons := provider.GetMgmtRsOoBConsCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtRsOoBCons.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetMgmtRsOoBConsId(ctx, data) + attrs := payload["mgmtRsOoBCons"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationMgmtRsOoBCons(resources interface{}) []provider.TagAnnotationMgmtRsOoBConsResourceModel { + var planResources []provider.TagAnnotationMgmtRsOoBConsResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationMgmtRsOoBConsResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagMgmtRsOoBCons(resources interface{}) []provider.TagTagMgmtRsOoBConsResourceModel { + var planResources []provider.TagTagMgmtRsOoBConsResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagMgmtRsOoBConsResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_contract_master.go b/convert_funcs/conversion_relation_to_contract_master.go new file mode 100644 index 000000000..8a7a5d036 --- /dev/null +++ b/convert_funcs/conversion_relation_to_contract_master.go @@ -0,0 +1,83 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsSecInherited(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsSecInheritedResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["target_dn"].(string); ok && v != "" { + data.TDn = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsSecInherited(attributes["annotations"]) + planTagTag := convertToTagTagFvRsSecInherited(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsSecInheritedId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsSecInherited", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsSecInherited := provider.GetFvRsSecInheritedCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsSecInherited.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsSecInheritedId(ctx, data) + attrs := payload["fvRsSecInherited"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsSecInherited(resources interface{}) []provider.TagAnnotationFvRsSecInheritedResourceModel { + var planResources []provider.TagAnnotationFvRsSecInheritedResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsSecInheritedResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsSecInherited(resources interface{}) []provider.TagTagFvRsSecInheritedResourceModel { + var planResources []provider.TagTagFvRsSecInheritedResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsSecInheritedResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_domain.go b/convert_funcs/conversion_relation_to_domain.go new file mode 100644 index 000000000..84f6a4c11 --- /dev/null +++ b/convert_funcs/conversion_relation_to_domain.go @@ -0,0 +1,155 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsDomAtt(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsDomAttResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["binding_type"].(string); ok && v != "" { + data.BindingType = types.StringValue(v) + } + if v, ok := attributes["class_preference"].(string); ok && v != "" { + data.ClassPref = types.StringValue(v) + } + if v, ok := attributes["custom_epg_name"].(string); ok && v != "" { + data.CustomEpgName = types.StringValue(v) + } + if v, ok := attributes["delimiter"].(string); ok && v != "" { + data.Delimiter = types.StringValue(v) + } + if v, ok := attributes["encapsulation"].(string); ok && v != "" { + data.Encap = types.StringValue(v) + } + if v, ok := attributes["encapsulation_mode"].(string); ok && v != "" { + data.EncapMode = types.StringValue(v) + } + if v, ok := attributes["epg_cos"].(string); ok && v != "" { + data.EpgCos = types.StringValue(v) + } + if v, ok := attributes["epg_cos_pref"].(string); ok && v != "" { + data.EpgCosPref = types.StringValue(v) + } + if v, ok := attributes["deployment_immediacy"].(string); ok && v != "" { + data.InstrImedcy = types.StringValue(v) + } + if v, ok := attributes["ipam_dhcp_override"].(string); ok && v != "" { + data.IpamDhcpOverride = types.StringValue(v) + } + if v, ok := attributes["ipam_enabled"].(string); ok && v != "" { + data.IpamEnabled = types.StringValue(v) + } + if v, ok := attributes["ipam_gateway"].(string); ok && v != "" { + data.IpamGateway = types.StringValue(v) + } + if v, ok := attributes["lag_policy_name"].(string); ok && v != "" { + data.LagPolicyName = types.StringValue(v) + } + if v, ok := attributes["netflow_direction"].(string); ok && v != "" { + data.NetflowDir = types.StringValue(v) + } + if v, ok := attributes["enable_netflow"].(string); ok && v != "" { + data.NetflowPref = types.StringValue(v) + } + if v, ok := attributes["number_of_ports"].(string); ok && v != "" { + data.NumPorts = types.StringValue(v) + } + if v, ok := attributes["port_allocation"].(string); ok && v != "" { + data.PortAllocation = types.StringValue(v) + } + if v, ok := attributes["primary_encapsulation"].(string); ok && v != "" { + data.PrimaryEncap = types.StringValue(v) + } + if v, ok := attributes["primary_encapsulation_inner"].(string); ok && v != "" { + data.PrimaryEncapInner = types.StringValue(v) + } + if v, ok := attributes["resolution_immediacy"].(string); ok && v != "" { + data.ResImedcy = types.StringValue(v) + } + if v, ok := attributes["secondary_encapsulation_inner"].(string); ok && v != "" { + data.SecondaryEncapInner = types.StringValue(v) + } + if v, ok := attributes["switching_mode"].(string); ok && v != "" { + data.SwitchingMode = types.StringValue(v) + } + if v, ok := attributes["target_dn"].(string); ok && v != "" { + data.TDn = types.StringValue(v) + } + if v, ok := attributes["untagged"].(string); ok && v != "" { + data.Untagged = types.StringValue(v) + } + if v, ok := attributes["vnet_only"].(string); ok && v != "" { + data.VnetOnly = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsDomAtt(attributes["annotations"]) + planTagTag := convertToTagTagFvRsDomAtt(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsDomAttId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsDomAtt", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsDomAtt := provider.GetFvRsDomAttCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsDomAtt.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsDomAttId(ctx, data) + attrs := payload["fvRsDomAtt"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsDomAtt(resources interface{}) []provider.TagAnnotationFvRsDomAttResourceModel { + var planResources []provider.TagAnnotationFvRsDomAttResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsDomAttResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsDomAtt(resources interface{}) []provider.TagTagFvRsDomAttResourceModel { + var planResources []provider.TagTagFvRsDomAttResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsDomAttResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_fibre_channel_path.go b/convert_funcs/conversion_relation_to_fibre_channel_path.go new file mode 100644 index 000000000..f3fb08a37 --- /dev/null +++ b/convert_funcs/conversion_relation_to_fibre_channel_path.go @@ -0,0 +1,92 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsFcPathAtt(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsFcPathAttResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["target_dn"].(string); ok && v != "" { + data.TDn = types.StringValue(v) + } + if v, ok := attributes["vsan"].(string); ok && v != "" { + data.Vsan = types.StringValue(v) + } + if v, ok := attributes["vsan_mode"].(string); ok && v != "" { + data.VsanMode = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsFcPathAtt(attributes["annotations"]) + planTagTag := convertToTagTagFvRsFcPathAtt(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsFcPathAttId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsFcPathAtt", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsFcPathAtt := provider.GetFvRsFcPathAttCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsFcPathAtt.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsFcPathAttId(ctx, data) + attrs := payload["fvRsFcPathAtt"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsFcPathAtt(resources interface{}) []provider.TagAnnotationFvRsFcPathAttResourceModel { + var planResources []provider.TagAnnotationFvRsFcPathAttResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsFcPathAttResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsFcPathAtt(resources interface{}) []provider.TagTagFvRsFcPathAttResourceModel { + var planResources []provider.TagTagFvRsFcPathAttResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsFcPathAttResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_imported_contract.go b/convert_funcs/conversion_relation_to_imported_contract.go new file mode 100644 index 000000000..03af73bfc --- /dev/null +++ b/convert_funcs/conversion_relation_to_imported_contract.go @@ -0,0 +1,86 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsConsIf(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsConsIfResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["priority"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["imported_contract_name"].(string); ok && v != "" { + data.TnVzCPIfName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsConsIf(attributes["annotations"]) + planTagTag := convertToTagTagFvRsConsIf(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsConsIfId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsConsIf", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsConsIf := provider.GetFvRsConsIfCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsConsIf.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsConsIfId(ctx, data) + attrs := payload["fvRsConsIf"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsConsIf(resources interface{}) []provider.TagAnnotationFvRsConsIfResourceModel { + var planResources []provider.TagAnnotationFvRsConsIfResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsConsIfResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsConsIf(resources interface{}) []provider.TagTagFvRsConsIfResourceModel { + var planResources []provider.TagTagFvRsConsIfResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsConsIfResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_intra_epg_contract.go b/convert_funcs/conversion_relation_to_intra_epg_contract.go new file mode 100644 index 000000000..f92f22dc9 --- /dev/null +++ b/convert_funcs/conversion_relation_to_intra_epg_contract.go @@ -0,0 +1,83 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsIntraEpg(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsIntraEpgResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["contract_name"].(string); ok && v != "" { + data.TnVzBrCPName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsIntraEpg(attributes["annotations"]) + planTagTag := convertToTagTagFvRsIntraEpg(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsIntraEpgId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsIntraEpg", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsIntraEpg := provider.GetFvRsIntraEpgCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsIntraEpg.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsIntraEpgId(ctx, data) + attrs := payload["fvRsIntraEpg"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsIntraEpg(resources interface{}) []provider.TagAnnotationFvRsIntraEpgResourceModel { + var planResources []provider.TagAnnotationFvRsIntraEpgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsIntraEpgResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsIntraEpg(resources interface{}) []provider.TagTagFvRsIntraEpgResourceModel { + var planResources []provider.TagTagFvRsIntraEpgResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsIntraEpgResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_netflow_exporter.go b/convert_funcs/conversion_relation_to_netflow_exporter.go new file mode 100644 index 000000000..a5f855800 --- /dev/null +++ b/convert_funcs/conversion_relation_to_netflow_exporter.go @@ -0,0 +1,83 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateNetflowRsMonitorToExporter(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.NetflowRsMonitorToExporterResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["netflow_exporter_policy_name"].(string); ok && v != "" { + data.TnNetflowExporterPolName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationNetflowRsMonitorToExporter(attributes["annotations"]) + planTagTag := convertToTagTagNetflowRsMonitorToExporter(attributes["tags"]) + + if status == "deleted" { + + provider.SetNetflowRsMonitorToExporterId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "netflowRsMonitorToExporter", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciNetflowRsMonitorToExporter := provider.GetNetflowRsMonitorToExporterCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciNetflowRsMonitorToExporter.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetNetflowRsMonitorToExporterId(ctx, data) + attrs := payload["netflowRsMonitorToExporter"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationNetflowRsMonitorToExporter(resources interface{}) []provider.TagAnnotationNetflowRsMonitorToExporterResourceModel { + var planResources []provider.TagAnnotationNetflowRsMonitorToExporterResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationNetflowRsMonitorToExporterResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagNetflowRsMonitorToExporter(resources interface{}) []provider.TagTagNetflowRsMonitorToExporterResourceModel { + var planResources []provider.TagTagNetflowRsMonitorToExporterResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagNetflowRsMonitorToExporterResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_provided_contract.go b/convert_funcs/conversion_relation_to_provided_contract.go new file mode 100644 index 000000000..4e04f6832 --- /dev/null +++ b/convert_funcs/conversion_relation_to_provided_contract.go @@ -0,0 +1,89 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsProv(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsProvResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["match_criteria"].(string); ok && v != "" { + data.MatchT = types.StringValue(v) + } + if v, ok := attributes["priority"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["contract_name"].(string); ok && v != "" { + data.TnVzBrCPName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsProv(attributes["annotations"]) + planTagTag := convertToTagTagFvRsProv(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsProvId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsProv", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsProv := provider.GetFvRsProvCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsProv.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsProvId(ctx, data) + attrs := payload["fvRsProv"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsProv(resources interface{}) []provider.TagAnnotationFvRsProvResourceModel { + var planResources []provider.TagAnnotationFvRsProvResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsProvResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsProv(resources interface{}) []provider.TagTagFvRsProvResourceModel { + var planResources []provider.TagTagFvRsProvResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsProvResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_static_leaf.go b/convert_funcs/conversion_relation_to_static_leaf.go new file mode 100644 index 000000000..cbe81a5d5 --- /dev/null +++ b/convert_funcs/conversion_relation_to_static_leaf.go @@ -0,0 +1,95 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsNodeAtt(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsNodeAttResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["encapsulation"].(string); ok && v != "" { + data.Encap = types.StringValue(v) + } + if v, ok := attributes["deployment_immediacy"].(string); ok && v != "" { + data.InstrImedcy = types.StringValue(v) + } + if v, ok := attributes["mode"].(string); ok && v != "" { + data.Mode = types.StringValue(v) + } + if v, ok := attributes["target_dn"].(string); ok && v != "" { + data.TDn = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsNodeAtt(attributes["annotations"]) + planTagTag := convertToTagTagFvRsNodeAtt(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsNodeAttId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsNodeAtt", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsNodeAtt := provider.GetFvRsNodeAttCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsNodeAtt.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsNodeAttId(ctx, data) + attrs := payload["fvRsNodeAtt"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsNodeAtt(resources interface{}) []provider.TagAnnotationFvRsNodeAttResourceModel { + var planResources []provider.TagAnnotationFvRsNodeAttResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsNodeAttResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsNodeAtt(resources interface{}) []provider.TagTagFvRsNodeAttResourceModel { + var planResources []provider.TagTagFvRsNodeAttResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsNodeAttResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_static_path.go b/convert_funcs/conversion_relation_to_static_path.go new file mode 100644 index 000000000..9bcf9f3ce --- /dev/null +++ b/convert_funcs/conversion_relation_to_static_path.go @@ -0,0 +1,98 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsPathAtt(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsPathAttResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["encapsulation"].(string); ok && v != "" { + data.Encap = types.StringValue(v) + } + if v, ok := attributes["deployment_immediacy"].(string); ok && v != "" { + data.InstrImedcy = types.StringValue(v) + } + if v, ok := attributes["mode"].(string); ok && v != "" { + data.Mode = types.StringValue(v) + } + if v, ok := attributes["primary_encapsulation"].(string); ok && v != "" { + data.PrimaryEncap = types.StringValue(v) + } + if v, ok := attributes["target_dn"].(string); ok && v != "" { + data.TDn = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsPathAtt(attributes["annotations"]) + planTagTag := convertToTagTagFvRsPathAtt(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsPathAttId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsPathAtt", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsPathAtt := provider.GetFvRsPathAttCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsPathAtt.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsPathAttId(ctx, data) + attrs := payload["fvRsPathAtt"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsPathAtt(resources interface{}) []provider.TagAnnotationFvRsPathAttResourceModel { + var planResources []provider.TagAnnotationFvRsPathAttResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsPathAttResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsPathAtt(resources interface{}) []provider.TagTagFvRsPathAttResourceModel { + var planResources []provider.TagTagFvRsPathAttResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsPathAttResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_taboo_contract.go b/convert_funcs/conversion_relation_to_taboo_contract.go new file mode 100644 index 000000000..61b8f45fa --- /dev/null +++ b/convert_funcs/conversion_relation_to_taboo_contract.go @@ -0,0 +1,83 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvRsProtBy(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvRsProtByResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["taboo_contract_name"].(string); ok && v != "" { + data.TnVzTabooName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvRsProtBy(attributes["annotations"]) + planTagTag := convertToTagTagFvRsProtBy(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvRsProtById(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsProtBy", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvRsProtBy := provider.GetFvRsProtByCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvRsProtBy.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvRsProtById(ctx, data) + attrs := payload["fvRsProtBy"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvRsProtBy(resources interface{}) []provider.TagAnnotationFvRsProtByResourceModel { + var planResources []provider.TagAnnotationFvRsProtByResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvRsProtByResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvRsProtBy(resources interface{}) []provider.TagTagFvRsProtByResourceModel { + var planResources []provider.TagTagFvRsProtByResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvRsProtByResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_vrf_fallback_route_group.go b/convert_funcs/conversion_relation_to_vrf_fallback_route_group.go new file mode 100644 index 000000000..c58372afc --- /dev/null +++ b/convert_funcs/conversion_relation_to_vrf_fallback_route_group.go @@ -0,0 +1,83 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateL3extRsOutToFBRGroup(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.L3extRsOutToFBRGroupResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["target_dn"].(string); ok && v != "" { + data.TDn = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extRsOutToFBRGroup(attributes["annotations"]) + planTagTag := convertToTagTagL3extRsOutToFBRGroup(attributes["tags"]) + + if status == "deleted" { + + provider.SetL3extRsOutToFBRGroupId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "l3extRsOutToFBRGroup", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciL3extRsOutToFBRGroup := provider.GetL3extRsOutToFBRGroupCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extRsOutToFBRGroup.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetL3extRsOutToFBRGroupId(ctx, data) + attrs := payload["l3extRsOutToFBRGroup"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationL3extRsOutToFBRGroup(resources interface{}) []provider.TagAnnotationL3extRsOutToFBRGroupResourceModel { + var planResources []provider.TagAnnotationL3extRsOutToFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationL3extRsOutToFBRGroupResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagL3extRsOutToFBRGroup(resources interface{}) []provider.TagTagL3extRsOutToFBRGroupResourceModel { + var planResources []provider.TagTagL3extRsOutToFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagL3extRsOutToFBRGroupResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_route_control_profile.go b/convert_funcs/conversion_route_control_profile.go new file mode 100644 index 000000000..fb92c7fc9 --- /dev/null +++ b/convert_funcs/conversion_route_control_profile.go @@ -0,0 +1,101 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateRtctrlProfile(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.RtctrlProfileResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["route_map_continue"].(string); ok && v != "" { + data.AutoContinue = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["route_control_profile_type"].(string); ok && v != "" { + data.Type = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationRtctrlProfile(attributes["annotations"]) + planTagTag := convertToTagTagRtctrlProfile(attributes["tags"]) + + if status == "deleted" { + + provider.SetRtctrlProfileId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "rtctrlProfile", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciRtctrlProfile := provider.GetRtctrlProfileCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciRtctrlProfile.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetRtctrlProfileId(ctx, data) + attrs := payload["rtctrlProfile"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationRtctrlProfile(resources interface{}) []provider.TagAnnotationRtctrlProfileResourceModel { + var planResources []provider.TagAnnotationRtctrlProfileResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationRtctrlProfileResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagRtctrlProfile(resources interface{}) []provider.TagTagRtctrlProfileResourceModel { + var planResources []provider.TagTagRtctrlProfileResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagRtctrlProfileResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_tag.go b/convert_funcs/conversion_tag.go new file mode 100644 index 000000000..4d320b5cd --- /dev/null +++ b/convert_funcs/conversion_tag.go @@ -0,0 +1,55 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateTagTag(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.TagTagResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["key"].(string); ok && v != "" { + data.Key = types.StringValue(v) + } + if v, ok := attributes["value"].(string); ok && v != "" { + data.Value = types.StringValue(v) + } + + if status == "deleted" { + + provider.SetTagTagId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "tagTag", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciTagTag := provider.GetTagTagCreateJsonPayload(ctx, &diags, true, data) + + jsonPayload := newAciTagTag.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetTagTagId(ctx, data) + attrs := payload["tagTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} diff --git a/convert_funcs/conversion_trust_control_policy.go b/convert_funcs/conversion_trust_control_policy.go new file mode 100644 index 000000000..c1bdc2132 --- /dev/null +++ b/convert_funcs/conversion_trust_control_policy.go @@ -0,0 +1,113 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFhsTrustCtrlPol(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FhsTrustCtrlPolResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["has_dhcpv4_server"].(string); ok && v != "" { + data.HasDhcpv4Server = types.StringValue(v) + } + if v, ok := attributes["has_dhcpv6_server"].(string); ok && v != "" { + data.HasDhcpv6Server = types.StringValue(v) + } + if v, ok := attributes["has_ipv6_router"].(string); ok && v != "" { + data.HasIpv6Router = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["trust_arp"].(string); ok && v != "" { + data.TrustArp = types.StringValue(v) + } + if v, ok := attributes["trust_nd"].(string); ok && v != "" { + data.TrustNd = types.StringValue(v) + } + if v, ok := attributes["trust_ra"].(string); ok && v != "" { + data.TrustRa = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFhsTrustCtrlPol(attributes["annotations"]) + planTagTag := convertToTagTagFhsTrustCtrlPol(attributes["tags"]) + + if status == "deleted" { + + provider.SetFhsTrustCtrlPolId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fhsTrustCtrlPol", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFhsTrustCtrlPol := provider.GetFhsTrustCtrlPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFhsTrustCtrlPol.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFhsTrustCtrlPolId(ctx, data) + attrs := payload["fhsTrustCtrlPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFhsTrustCtrlPol(resources interface{}) []provider.TagAnnotationFhsTrustCtrlPolResourceModel { + var planResources []provider.TagAnnotationFhsTrustCtrlPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFhsTrustCtrlPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFhsTrustCtrlPol(resources interface{}) []provider.TagTagFhsTrustCtrlPolResourceModel { + var planResources []provider.TagTagFhsTrustCtrlPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFhsTrustCtrlPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_vrf_fallback_route.go b/convert_funcs/conversion_vrf_fallback_route.go new file mode 100644 index 000000000..7415adb83 --- /dev/null +++ b/convert_funcs/conversion_vrf_fallback_route.go @@ -0,0 +1,92 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvFBRoute(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvFBRouteResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["prefix_address"].(string); ok && v != "" { + data.FbrPrefix = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvFBRoute(attributes["annotations"]) + planTagTag := convertToTagTagFvFBRoute(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvFBRouteId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvFBRoute", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvFBRoute := provider.GetFvFBRouteCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvFBRoute.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvFBRouteId(ctx, data) + attrs := payload["fvFBRoute"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvFBRoute(resources interface{}) []provider.TagAnnotationFvFBRouteResourceModel { + var planResources []provider.TagAnnotationFvFBRouteResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvFBRouteResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvFBRoute(resources interface{}) []provider.TagTagFvFBRouteResourceModel { + var planResources []provider.TagTagFvFBRouteResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvFBRouteResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_vrf_fallback_route_group.go b/convert_funcs/conversion_vrf_fallback_route_group.go new file mode 100644 index 000000000..acbefc535 --- /dev/null +++ b/convert_funcs/conversion_vrf_fallback_route_group.go @@ -0,0 +1,123 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvFBRGroup(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvFBRGroupResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planFvFBRMember := convertToFvFBRMemberFvFBRGroup(attributes["vrf_fallback_route_group_members"]) + planFvFBRoute := convertToFvFBRouteFvFBRGroup(attributes["vrf_fallback_routes"]) + planTagAnnotation := convertToTagAnnotationFvFBRGroup(attributes["annotations"]) + planTagTag := convertToTagTagFvFBRGroup(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvFBRGroupId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvFBRGroup", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvFBRGroup := provider.GetFvFBRGroupCreateJsonPayload(ctx, &diags, true, data, planFvFBRMember, planFvFBRMember, planFvFBRoute, planFvFBRoute, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvFBRGroup.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvFBRGroupId(ctx, data) + attrs := payload["fvFBRGroup"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToFvFBRMemberFvFBRGroup(resources interface{}) []provider.FvFBRMemberFvFBRGroupResourceModel { + var planResources []provider.FvFBRMemberFvFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvFBRMemberFvFBRGroupResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Descr: types.StringValue(resourceMap["description"].(string)), + Name: types.StringValue(resourceMap["name"].(string)), + NameAlias: types.StringValue(resourceMap["name_alias"].(string)), + RnhAddr: types.StringValue(resourceMap["fallback_member"].(string)), + }) + } + } + return planResources +} +func convertToFvFBRouteFvFBRGroup(resources interface{}) []provider.FvFBRouteFvFBRGroupResourceModel { + var planResources []provider.FvFBRouteFvFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.FvFBRouteFvFBRGroupResourceModel{ + Annotation: types.StringValue(resourceMap["annotation"].(string)), + Descr: types.StringValue(resourceMap["description"].(string)), + FbrPrefix: types.StringValue(resourceMap["prefix_address"].(string)), + Name: types.StringValue(resourceMap["name"].(string)), + NameAlias: types.StringValue(resourceMap["name_alias"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationFvFBRGroup(resources interface{}) []provider.TagAnnotationFvFBRGroupResourceModel { + var planResources []provider.TagAnnotationFvFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvFBRGroupResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvFBRGroup(resources interface{}) []provider.TagTagFvFBRGroupResourceModel { + var planResources []provider.TagTagFvFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvFBRGroupResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_vrf_fallback_route_group_member.go b/convert_funcs/conversion_vrf_fallback_route_group_member.go new file mode 100644 index 000000000..1c6a0ba9f --- /dev/null +++ b/convert_funcs/conversion_vrf_fallback_route_group_member.go @@ -0,0 +1,92 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateFvFBRMember(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvFBRMemberResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["fallback_member"].(string); ok && v != "" { + data.RnhAddr = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvFBRMember(attributes["annotations"]) + planTagTag := convertToTagTagFvFBRMember(attributes["tags"]) + + if status == "deleted" { + + provider.SetFvFBRMemberId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvFBRMember", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + newAciFvFBRMember := provider.GetFvFBRMemberCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvFBRMember.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetFvFBRMemberId(ctx, data) + attrs := payload["fvFBRMember"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationFvFBRMember(resources interface{}) []provider.TagAnnotationFvFBRMemberResourceModel { + var planResources []provider.TagAnnotationFvFBRMemberResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvFBRMemberResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvFBRMember(resources interface{}) []provider.TagTagFvFBRMemberResourceModel { + var planResources []provider.TagTagFvFBRMemberResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvFBRMemberResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/dn_to_aci.go b/convert_funcs/dn_to_aci.go new file mode 100644 index 000000000..85fe7de78 --- /dev/null +++ b/convert_funcs/dn_to_aci.go @@ -0,0 +1,247 @@ +package convert_funcs + +func dn_to_class(prefix string) string { + + mapping := map[string]string{ + + "tagAnnotation-rsHPathAtt": "infraRsHPathAtt", + + "tagTag-rsHPathAtt": "infraRsHPathAtt", + + "tagAnnotation-rscons": "fvRsCons", + + "tagTag-rscons": "fvRsCons", + + "mgmtRsOoBCons-instp": "mgmtInstP", + + "tagAnnotation-instp": "mgmtInstP", + + "tagTag-instp": "mgmtInstP", + + "tagAnnotation-rsmonitorToExporter": "netflowRsMonitorToExporter", + + "tagTag-rsmonitorToExporter": "netflowRsMonitorToExporter", + + "tagAnnotation-rtmap": "pimRouteMapPol", + + "tagTag-rtmap": "pimRouteMapPol", + + "tagAnnotation-crtrn": "fvCrtrn", + + "tagTag-crtrn": "fvCrtrn", + + "tagAnnotation-rsconsIf": "fvRsConsIf", + + "tagTag-rsconsIf": "fvRsConsIf", + + // "tagAnnotation-crtrn": "fvSCrtrn", + + // "tagTag-crtrn": "fvSCrtrn", + + "tagAnnotation-subnet": "mgmtSubnet", + + "tagTag-subnet": "mgmtSubnet", + + "tagAnnotation-qosdpppol": "qosDppPol", + + "tagTag-qosdpppol": "qosDppPol", + + "fvCrtrn-epg": "fvAEPg", + + "fvRsAEPgMonPol-epg": "fvAEPg", + + "fvRsBd-epg": "fvAEPg", + + "fvRsCons-epg": "fvAEPg", + + "fvRsConsIf-epg": "fvAEPg", + + "fvRsCustQosPol-epg": "fvAEPg", + + "fvRsDomAtt-epg": "fvAEPg", + + "fvRsDppPol-epg": "fvAEPg", + + "fvRsFcPathAtt-epg": "fvAEPg", + + "fvRsIntraEpg-epg": "fvAEPg", + + "fvRsNodeAtt-epg": "fvAEPg", + + "fvRsPathAtt-epg": "fvAEPg", + + "fvRsProtBy-epg": "fvAEPg", + + "fvRsProv-epg": "fvAEPg", + + "fvRsSecInherited-epg": "fvAEPg", + + "fvRsTrustCtrl-epg": "fvAEPg", + + "tagAnnotation-epg": "fvAEPg", + + "tagTag-epg": "fvAEPg", + + "tagAnnotation-dnsattr": "fvDnsAttr", + + "tagTag-dnsattr": "fvDnsAttr", + + "tagAnnotation-recordpol": "netflowRecordPol", + + "tagTag-recordpol": "netflowRecordPol", + + "fvFBRMember-fbrg": "fvFBRGroup", + + "fvFBRoute-fbrg": "fvFBRGroup", + + "tagAnnotation-fbrg": "fvFBRGroup", + + "tagTag-fbrg": "fvFBRGroup", + + "tagAnnotation-rsfcPathAtt": "fvRsFcPathAtt", + + "tagTag-rsfcPathAtt": "fvRsFcPathAtt", + + "tagAnnotation-pfx": "fvFBRoute", + + "tagTag-pfx": "fvFBRoute", + + "tagAnnotation-oobbrc": "vzOOBBrCP", + + "tagTag-oobbrc": "vzOOBBrCP", + + "tagAnnotation-qoscustom": "qosCustomPol", + + "tagTag-qoscustom": "qosCustomPol", + + "tagAnnotation-idgattr": "fvIdGroupAttr", + + "tagTag-idgattr": "fvIdGroupAttr", + + "tagAnnotation-rspathAtt": "fvRsPathAtt", + + "tagTag-rspathAtt": "fvRsPathAtt", + + "tagAnnotation-provlbl": "l3extProvLbl", + + "tagTag-provlbl": "l3extProvLbl", + + "tagAnnotation-trustctrlpol": "fhsTrustCtrlPol", + + "tagTag-trustctrlpol": "fhsTrustCtrlPol", + + "tagAnnotation-epiptag": "fvEpIpTag", + + "tagTag-epiptag": "fvEpIpTag", + + "tagAnnotation-epmactag": "fvEpMacTag", + + "tagTag-epmactag": "fvEpMacTag", + + "tagAnnotation-ipattr": "fvIpAttr", + + "tagTag-ipattr": "fvIpAttr", + + "tagAnnotation-nodesidp": "mplsNodeSidP", + + "tagTag-nodesidp": "mplsNodeSidP", + + "tagAnnotation-prof": "rtctrlProfile", + + "tagTag-prof": "rtctrlProfile", + + "tagAnnotation-rsprov": "fvRsProv", + + "tagTag-rsprov": "fvRsProv", + + "tagAnnotation-conslbl": "l3extConsLbl", + + "tagTag-conslbl": "l3extConsLbl", + + "netflowRsMonitorToExporter-monitorpol": "netflowMonitorPol", + + "netflowRsMonitorToRecord-monitorpol": "netflowMonitorPol", + + "tagAnnotation-monitorpol": "netflowMonitorPol", + + "tagTag-monitorpol": "netflowMonitorPol", + + "tagAnnotation-rsdomAtt": "fvRsDomAtt", + + "tagTag-rsdomAtt": "fvRsDomAtt", + + "tagAnnotation-rsooBCons": "mgmtRsOoBCons", + + "tagTag-rsooBCons": "mgmtRsOoBCons", + + "tagAnnotation-rsintraEpg": "fvRsIntraEpg", + + "tagTag-rsintraEpg": "fvRsIntraEpg", + + "tagAnnotation-rsprotBy": "fvRsProtBy", + + "tagTag-rsprotBy": "fvRsProtBy", + + "tagAnnotation-rsoutToFBRGroup": "l3extRsOutToFBRGroup", + + "tagTag-rsoutToFBRGroup": "l3extRsOutToFBRGroup", + + "fvRsCons-esg": "fvESg", + + "fvRsConsIf-esg": "fvESg", + + "fvRsIntraEpg-esg": "fvESg", + + "fvRsProv-esg": "fvESg", + + "fvRsScope-esg": "fvESg", + + "fvRsSecInherited-esg": "fvESg", + + "tagAnnotation-esg": "fvESg", + + "tagTag-esg": "fvESg", + + "tagAnnotation-macattr": "fvMacAttr", + + "tagTag-macattr": "fvMacAttr", + + "tagAnnotation-rssecInherited": "fvRsSecInherited", + + "tagTag-rssecInherited": "fvRsSecInherited", + + "tagAnnotation-rtmapentry": "pimRouteMapEntry", + + "tagTag-rtmapentry": "pimRouteMapEntry", + + "tagAnnotation-rsnodeAtt": "fvRsNodeAtt", + + "tagTag-rsnodeAtt": "fvRsNodeAtt", + + "tagAnnotation-nexthop": "fvFBRMember", + + "tagTag-nexthop": "fvFBRMember", + + "tagAnnotation-rsredistributePol": "l3extRsRedistributePol", + + "tagTag-rsredistributePol": "l3extRsRedistributePol", + + "tagAnnotation-vmattr": "fvVmAttr", + + "tagTag-vmattr": "fvVmAttr", + + "infraRsHPathAtt-hpaths": "infraHPathS", + + "infraRsPathToAccBaseGrp-hpaths": "infraHPathS", + + "tagAnnotation-hpaths": "infraHPathS", + + "tagTag-hpaths": "infraHPathS", + } + + if className, found := mapping[prefix]; found { + return className + } + + return "" +} diff --git a/convert_funcs/getAciClass.go b/convert_funcs/getAciClass.go new file mode 100644 index 000000000..c2e22c14b --- /dev/null +++ b/convert_funcs/getAciClass.go @@ -0,0 +1,57 @@ +package convert_funcs + +func GetAciClass(prefix string) string { + mapping := map[string]string{ + "rsHPathAtt": "infraRsHPathAtt", + "rscons": "fvRsCons", + "instp": "mgmtInstP", + "rsmonitorToExporter": "netflowRsMonitorToExporter", + "rtmap": "pimRouteMapPol", + "crtrn": "fvCrtrn", + "rsconsIf": "fvRsConsIf", + //"crtrn": "fvSCrtrn", + "subnet": "mgmtSubnet", + "qosdpppol": "qosDppPol", + "epg": "fvAEPg", + "dnsattr": "fvDnsAttr", + "annotationKey": "tagAnnotation", + "recordpol": "netflowRecordPol", + "fbrg": "fvFBRGroup", + "rsfcPathAtt": "fvRsFcPathAtt", + "pfx": "fvFBRoute", + "oobbrc": "vzOOBBrCP", + "qoscustom": "qosCustomPol", + "idgattr": "fvIdGroupAttr", + "rspathAtt": "fvRsPathAtt", + "provlbl": "l3extProvLbl", + "trustctrlpol": "fhsTrustCtrlPol", + "epiptag": "fvEpIpTag", + "epmactag": "fvEpMacTag", + "ipattr": "fvIpAttr", + "nodesidp": "mplsNodeSidP", + "prof": "rtctrlProfile", + "rsprov": "fvRsProv", + "conslbl": "l3extConsLbl", + "monitorpol": "netflowMonitorPol", + "rsdomAtt": "fvRsDomAtt", + "rsooBCons": "mgmtRsOoBCons", + "rsintraEpg": "fvRsIntraEpg", + "rsprotBy": "fvRsProtBy", + "rsoutToFBRGroup": "l3extRsOutToFBRGroup", + "esg": "fvESg", + "macattr": "fvMacAttr", + "rssecInherited": "fvRsSecInherited", + "rtmapentry": "pimRouteMapEntry", + "rsnodeAtt": "fvRsNodeAtt", + "tagKey": "tagTag", + "nexthop": "fvFBRMember", + "rsredistributePol": "l3extRsRedistributePol", + "vmattr": "fvVmAttr", + "hpaths": "infraHPathS", + } + + if class, found := mapping[prefix]; found { + return class + } + return "" +} diff --git a/convert_funcs/resourceMap.go b/convert_funcs/resourceMap.go new file mode 100644 index 000000000..eb7ccd6f5 --- /dev/null +++ b/convert_funcs/resourceMap.go @@ -0,0 +1,5 @@ +package convert_funcs + +type createFunc func(map[string]interface{}, string) map[string]interface{} + +var ResourceMap = map[string]createFunc{} diff --git a/gen/generator.go b/gen/generator.go index 22f389cab..9b41acffe 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -71,6 +71,7 @@ const ( resourcesDocsPath = "./docs/resources" datasourcesDocsPath = "./docs/data-sources" providerPath = "./internal/provider/" + conversionPath = "./convert_funcs" ) const providerName = "aci" @@ -80,6 +81,9 @@ const pubhupDevnetBaseUrl = "https://pubhub.devnetcloud.com/media/model-doc-late // The map contains a key which is the name of the function used in the template and a value which is the function itself // The functions itself are defined in the current file var templateFuncs = template.FuncMap{ + "extractPrefix": extractPrefix, + "trimRnName": trimRnName, + "lowercaseFirst": LowercaseFirst, "snakeCase": Underscore, "validatorString": ValidatorString, "containsString": ContainsString, @@ -216,6 +220,21 @@ func GetChildAttributesFromBlocks(className string, legacyBlocks []LegacyBlock) return legacyAttributes } +func LowercaseFirst(str string) string { + if len(str) == 0 { + return str + } + return strings.ToLower(string(str[0])) + str[1:] +} + +func extractPrefix(rnFormat string) string { + segments := strings.Split(rnFormat, "/") + lastSegment := segments[len(segments)-1] + + prefix := strings.SplitN(lastSegment, "-", 2)[0] + + return prefix +} func GetNewChildAttributes(legacyAttributes map[string]LegacyAttribute, properties map[string]Property) []Property { result := []Property{} for _, property := range properties { @@ -433,6 +452,34 @@ func renderTemplate(templateName, outputFileName, outputPath string, outputData outputFile.Write(bytes) } +func renderTemplateModels(templateName, outputFileName, outputPath string, outputData interface{}) { + templateData, err := os.ReadFile(fmt.Sprintf("%s/%s", templatePath, templateName)) + if err != nil { + panic(err) + } + var buffer bytes.Buffer + tmpl := template.Must(template.New("").Funcs(templateFuncs).Parse(string(templateData))) + + err = tmpl.Execute(&buffer, outputData) + if err != nil { + panic(err) + } + bytes := buffer.Bytes() + if strings.Contains(templateName, "go.tmpl") { + bytes, err = format.Source(buffer.Bytes()) + if err != nil { + os.WriteFile(fmt.Sprintf("%s/failed_render.go", outputPath), buffer.Bytes(), 0644) + panic(err) + } + } + + outputFile, err := os.Create(fmt.Sprintf("%s/%s", outputPath, outputFileName)) + if err != nil { + panic(err) + } + outputFile.Write(bytes) +} + // Creates a map of models for the resources and datasources from the meta data and definitions func getClassModels(definitions Definitions) map[string]Model { files, err := os.ReadDir(metaPath) @@ -580,6 +627,7 @@ func cleanDirectories() { cleanDirectory(resourcesDocsPath, []string{}) cleanDirectory(datasourcesDocsPath, []string{}) cleanDirectory(testVarsPath, []string{}) + cleanDirectory(conversionPath, []string{}) // The *ExamplesPath directories are removed and recreated to ensure all previously rendered files are removed // The provider example file is not removed because it contains static provider configuration @@ -775,6 +823,25 @@ func main() { renderTemplate("datasource.md.tmpl", fmt.Sprintf("%s.md", model.ResourceName), datasourcesDocsPath, model) renderTemplate("resource_test.go.tmpl", fmt.Sprintf("resource_%s_%s_test.go", providerName, model.ResourceName), providerPath, model) renderTemplate("datasource_test.go.tmpl", fmt.Sprintf("data_source_%s_%s_test.go", providerName, model.ResourceName), providerPath, model) + renderTemplate("conversion.go.tmpl", fmt.Sprintf("conversion_%s.go", model.ResourceName), conversionPath, model) + + allModels := []Model{} + + for _, model := range classModels { + if len(model.IdentifiedBy) > 0 || model.Include { + model.ResourceName = GetResourceName(model.PkgName, definitions) + + allModels = append(allModels, model) + } + } + + data := map[string]interface{}{ + "Models": allModels, + } + + renderTemplateModels("resourceMap.go.tmpl", "resourceMap.go", conversionPath, data) + renderTemplateModels("getAciClass.go.tmpl", "getAciClass.go", conversionPath, data) + renderTemplateModels("new.go.tmpl", "dn_to_aci.go", conversionPath, data) } } @@ -1030,6 +1097,26 @@ func (m *Model) SetClassLabel(classDetails interface{}, child bool) { } } +func trimRnName(resourceNamingFormat string) string { + placeholderRegex := regexp.MustCompile(`\{[^}]}`) + + resourceNamingWithoutPlaceholders := placeholderRegex.ReplaceAllString(resourceNamingFormat, "") + + prefix := "" + + for _, character := range resourceNamingWithoutPlaceholders { + if character == '-' || character == '/' || character == '_' { + break + } + prefix += string(character) + } + + if len(prefix) > 0 { + return prefix + } + return "" +} + // Remove duplicates from a slice of interfaces func uniqueInterfaceSlice(interfaceSlice []interface{}) []interface{} { keys := make(map[interface{}]bool) @@ -2029,6 +2116,22 @@ func getTestDependency(className string, targetMap map[interface{}]interface{}, return testDependency } +func mergeDuplicateKeys(mapping map[string]map[string]string) map[string]map[string]string { + mergedMapping := make(map[string]map[string]string) + + for childClass, prefixMap := range mapping { + if existingMap, found := mergedMapping[childClass]; found { + for prefix, className := range prefixMap { + existingMap[prefix] = className + } + } else { + mergedMapping[childClass] = prefixMap + } + } + + return mergedMapping +} + func GetTestTargetDn(targets []interface{}, resourceName, targetDnValue string, reference bool, targetClasses interface{}, index int) string { var filteredTargets []interface{} diff --git a/gen/templates/conversion.go.tmpl b/gen/templates/conversion.go.tmpl new file mode 100644 index 000000000..c624ae62f --- /dev/null +++ b/gen/templates/conversion.go.tmpl @@ -0,0 +1,88 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +{{- $resourceClassName := .ResourceClassName }} +{{- $resourceName := .ResourceName }} +{{- $properties := .Properties }} +{{- $children := .Children }} + +func Create{{ $resourceClassName }}(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.{{ $resourceClassName }}ResourceModel{} + + {{- if .HasParent }} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + {{- end }} + + {{- range $properties }} + if v, ok := attributes["{{ overwriteProperty .PkgName .SnakeCaseName $.Definitions }}"].(string); ok && v != "" { + data.{{ if eq .Name "Id" }}{{ $resourceClassName }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} = types.StringValue(v) + } + {{- end }} + + {{- range $children }} + plan{{ .ResourceClassName }} := convertTo{{ .ResourceClassName }}{{ $resourceClassName }}(attributes["{{ .ResourceName }}"]) + {{- end }} + + + if status == "deleted" { + + provider.Set{{ $resourceClassName }}Id(ctx, data) + + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "{{ lowercaseFirst $resourceClassName }}", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + + } + + + newAci{{ $resourceClassName }} := provider.Get{{ $resourceClassName }}CreateJsonPayload(ctx, &diags, true, data + {{- range $children }}, plan{{ .ResourceClassName }}, plan{{ .ResourceClassName }}{{- end }}) + + jsonPayload := newAci{{ $resourceClassName }}.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.Set{{ $resourceClassName }}Id(ctx, data) + attrs := payload["{{ lowercaseFirst $resourceClassName }}"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} + +{{- range $children }} +func convertTo{{ .ResourceClassName }}{{ $resourceClassName }}(resources interface{}) []provider.{{ .ResourceClassName }}{{ $resourceClassName }}ResourceModel { + var planResources []provider.{{ .ResourceClassName }}{{ $resourceClassName }}ResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.{{ .ResourceClassName }}{{ $resourceClassName }}ResourceModel{ + {{- range .Properties }} + {{ .Name }}: types.StringValue(resourceMap["{{ overwriteProperty .PkgName .SnakeCaseName $.Definitions }}"].(string)), + {{- end }} + }) + } + } + return planResources +} +{{- end }} diff --git a/gen/templates/datasource.go.tmpl b/gen/templates/datasource.go.tmpl index d81952e21..3cbe50a42 100644 --- a/gen/templates/datasource.go.tmpl +++ b/gen/templates/datasource.go.tmpl @@ -202,7 +202,7 @@ func (d *{{.ResourceClassName}}DataSource) Read(ctx context.Context, req datasou } {{- end}} - set{{.ResourceClassName}}Id(ctx, data) + Set{{.ResourceClassName}}Id(ctx, data) // Create a copy of the Id for when not found during getAndSet{{.ResourceClassName}}Attributes cachedId := data.Id.ValueString() diff --git a/gen/templates/getAciClass.go.tmpl b/gen/templates/getAciClass.go.tmpl new file mode 100644 index 000000000..7a3136294 --- /dev/null +++ b/gen/templates/getAciClass.go.tmpl @@ -0,0 +1,16 @@ +package convert_funcs + +func GetAciClass(prefix string) string { + mapping := map[string]string{ + + {{- range $pkgName, $model := .Models }} + "{{ extractPrefix $model.RnFormat }}": "{{ lowercaseFirst $model.ResourceClassName }}", + {{- end }} + } + + if class, found := mapping[prefix]; found { + return class + } + return "" +} + diff --git a/gen/templates/new.go.tmpl b/gen/templates/new.go.tmpl new file mode 100644 index 000000000..00fe1471b --- /dev/null +++ b/gen/templates/new.go.tmpl @@ -0,0 +1,24 @@ +package convert_funcs + + +func dn_to_class(prefix string) string { + + mapping := map[string]string{ + + {{- range $pkgName, $model := .Models }} + + {{- range $childClass := $model.ChildClasses }} + + "{{ $childClass }}-{{ extractPrefix $model.RnFormat }}": + "{{ lowercaseFirst $model.ResourceClassName }}", + + {{- end }} + {{- end }} + } + + if className, found := mapping[prefix]; found { + return className + } + + return "" +} \ No newline at end of file diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index 961d5983a..a953b613a 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -529,7 +529,7 @@ func (r *{{.ResourceClassName}}Resource) ModifyPlan(ctx context.Context, req res } if (planData.Id.IsUnknown() || planData.Id.IsNull()) {{if .HasParent }}&& !planData.ParentDn.IsUnknown() {{end}}{{range .Properties}}{{if .IsNaming}}&& !planData.{{ .Name }}.IsUnknown() {{end}}{{end}}{ - set{{.ResourceClassName}}Id(ctx, planData) + Set{{.ResourceClassName}}Id(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -1116,7 +1116,7 @@ func (r *{{.ResourceClassName}}Resource) Create(ctx context.Context, req resourc var stateData *{{.ResourceClassName}}ResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - set{{.ResourceClassName}}Id(ctx, stateData) + Set{{.ResourceClassName}}Id(ctx, stateData) } getAndSet{{.ResourceClassName}}Attributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -1138,7 +1138,7 @@ func (r *{{.ResourceClassName}}Resource) Create(ctx context.Context, req resourc } if data.Id.IsUnknown() || data.Id.IsNull() { - set{{.ResourceClassName}}Id(ctx, data) + Set{{.ResourceClassName}}Id(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_{{.ResourceName}} with id '%s'", data.Id.ValueString())) @@ -1149,9 +1149,9 @@ func (r *{{.ResourceClassName}}Resource) Create(ctx context.Context, req resourc data.{{ .ResourceClassName }}.ElementsAs(ctx, &{{.PkgName}}Plan, false) stateData.{{ .ResourceClassName }}.ElementsAs(ctx, &{{.PkgName}}State, false) {{- end}} - jsonPayload := get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, true, data{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State{{- end}}) + jsonPayload := Get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, true, data{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State{{- end}}) {{- else}} - jsonPayload := get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, true, data) + jsonPayload := Get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, true, data) {{- end}} if resp.Diagnostics.HasError() { @@ -1221,9 +1221,9 @@ func (r *{{.ResourceClassName}}Resource) Update(ctx context.Context, req resourc data.{{ .ResourceClassName }}.ElementsAs(ctx, &{{.PkgName}}Plan, false) stateData.{{ .ResourceClassName }}.ElementsAs(ctx, &{{.PkgName}}State, false) {{- end}} - jsonPayload := get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, false, data{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State{{- end}}) + jsonPayload := Get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, false, data{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State{{- end}}) {{- else}} - jsonPayload := get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, false, data) + jsonPayload := Get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, false, data) {{- end}} if resp.Diagnostics.HasError() { @@ -1450,7 +1450,7 @@ func set{{.ResourceClassName}}ParentDn(ctx context.Context, dn string, data *{{. } {{- end}} -func set{{.ResourceClassName}}Id(ctx context.Context, data *{{.ResourceClassName}}ResourceModel) { +func Set{{.ResourceClassName}}Id(ctx context.Context, data *{{.ResourceClassName}}ResourceModel) { rn := get{{.ResourceClassName}}Rn(ctx, data) {{- if .HasParent}} data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) @@ -1550,7 +1550,7 @@ func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context } {{- end}} -func get{{.ResourceClassName}}CreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *{{.ResourceClassName}}ResourceModel{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State []{{.ResourceClassName}}{{$.ResourceClassName}}ResourceModel{{- end}}) *container.Container { +func Get{{.ResourceClassName}}CreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *{{.ResourceClassName}}ResourceModel{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State []{{.ResourceClassName}}{{$.ResourceClassName}}ResourceModel{{- end}}) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/gen/templates/resourceMap.go.tmpl b/gen/templates/resourceMap.go.tmpl new file mode 100644 index 000000000..f7565c212 --- /dev/null +++ b/gen/templates/resourceMap.go.tmpl @@ -0,0 +1,11 @@ +package convert_funcs + +type createFunc func(map[string]interface{}, string) map[string]interface{} + +var ResourceMap = map[string]createFunc{ + {{- if or (and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))) .Include}} + {{- range $pkgName, $model := .Models }} + "aci_{{ $model.ResourceName }}": Create{{ $model.ResourceClassName }}, + {{- end }} + {{- end }} +} \ No newline at end of file diff --git a/internal/provider/data_source_aci_access_interface_override.go b/internal/provider/data_source_aci_access_interface_override.go index 7169293f2..0068858bf 100644 --- a/internal/provider/data_source_aci_access_interface_override.go +++ b/internal/provider/data_source_aci_access_interface_override.go @@ -179,7 +179,7 @@ func (d *InfraHPathSDataSource) Read(ctx context.Context, req datasource.ReadReq data.ParentDn = basetypes.NewStringValue("uni/infra") } - setInfraHPathSId(ctx, data) + SetInfraHPathSId(ctx, data) // Create a copy of the Id for when not found during getAndSetInfraHPathSAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_annotation.go b/internal/provider/data_source_aci_annotation.go index 43d7e58bf..e5ce1911d 100644 --- a/internal/provider/data_source_aci_annotation.go +++ b/internal/provider/data_source_aci_annotation.go @@ -94,7 +94,7 @@ func (d *TagAnnotationDataSource) Read(ctx context.Context, req datasource.ReadR return } - setTagAnnotationId(ctx, data) + SetTagAnnotationId(ctx, data) // Create a copy of the Id for when not found during getAndSetTagAnnotationAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_application_epg.go b/internal/provider/data_source_aci_application_epg.go index de99aa916..7a86e14bc 100644 --- a/internal/provider/data_source_aci_application_epg.go +++ b/internal/provider/data_source_aci_application_epg.go @@ -764,7 +764,7 @@ func (d *FvAEPgDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - setFvAEPgId(ctx, data) + SetFvAEPgId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvAEPgAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_custom_qos_policy.go b/internal/provider/data_source_aci_custom_qos_policy.go index 3c1d8b011..4c2a1ded2 100644 --- a/internal/provider/data_source_aci_custom_qos_policy.go +++ b/internal/provider/data_source_aci_custom_qos_policy.go @@ -142,7 +142,7 @@ func (d *QosCustomPolDataSource) Read(ctx context.Context, req datasource.ReadRe return } - setQosCustomPolId(ctx, data) + SetQosCustomPolId(ctx, data) // Create a copy of the Id for when not found during getAndSetQosCustomPolAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_data_plane_policing_policy.go b/internal/provider/data_source_aci_data_plane_policing_policy.go index 46080b866..f19d5e567 100644 --- a/internal/provider/data_source_aci_data_plane_policing_policy.go +++ b/internal/provider/data_source_aci_data_plane_policing_policy.go @@ -231,7 +231,7 @@ func (d *QosDppPolDataSource) Read(ctx context.Context, req datasource.ReadReque data.ParentDn = basetypes.NewStringValue("uni/infra") } - setQosDppPolId(ctx, data) + SetQosDppPolId(ctx, data) // Create a copy of the Id for when not found during getAndSetQosDppPolAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_endpoint_security_group.go b/internal/provider/data_source_aci_endpoint_security_group.go index 8175d8e48..9199bffc7 100644 --- a/internal/provider/data_source_aci_endpoint_security_group.go +++ b/internal/provider/data_source_aci_endpoint_security_group.go @@ -355,7 +355,7 @@ func (d *FvESgDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - setFvESgId(ctx, data) + SetFvESgId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvESgAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_endpoint_tag_ip.go b/internal/provider/data_source_aci_endpoint_tag_ip.go index 297fe97c9..14938e1f8 100644 --- a/internal/provider/data_source_aci_endpoint_tag_ip.go +++ b/internal/provider/data_source_aci_endpoint_tag_ip.go @@ -142,7 +142,7 @@ func (d *FvEpIpTagDataSource) Read(ctx context.Context, req datasource.ReadReque return } - setFvEpIpTagId(ctx, data) + SetFvEpIpTagId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvEpIpTagAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_endpoint_tag_mac.go b/internal/provider/data_source_aci_endpoint_tag_mac.go index 0c340436c..8a563cb5a 100644 --- a/internal/provider/data_source_aci_endpoint_tag_mac.go +++ b/internal/provider/data_source_aci_endpoint_tag_mac.go @@ -142,7 +142,7 @@ func (d *FvEpMacTagDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - setFvEpMacTagId(ctx, data) + SetFvEpMacTagId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvEpMacTagAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_epg_useg_ad_group_attribute.go b/internal/provider/data_source_aci_epg_useg_ad_group_attribute.go index 833cc43c2..9dbe3195b 100644 --- a/internal/provider/data_source_aci_epg_useg_ad_group_attribute.go +++ b/internal/provider/data_source_aci_epg_useg_ad_group_attribute.go @@ -146,7 +146,7 @@ func (d *FvIdGroupAttrDataSource) Read(ctx context.Context, req datasource.ReadR return } - setFvIdGroupAttrId(ctx, data) + SetFvIdGroupAttrId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvIdGroupAttrAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_epg_useg_block_statement.go b/internal/provider/data_source_aci_epg_useg_block_statement.go index 82fefe889..04c58f4ca 100644 --- a/internal/provider/data_source_aci_epg_useg_block_statement.go +++ b/internal/provider/data_source_aci_epg_useg_block_statement.go @@ -154,7 +154,7 @@ func (d *FvCrtrnDataSource) Read(ctx context.Context, req datasource.ReadRequest return } - setFvCrtrnId(ctx, data) + SetFvCrtrnId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvCrtrnAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_epg_useg_dns_attribute.go b/internal/provider/data_source_aci_epg_useg_dns_attribute.go index c3b988c0b..e7c668760 100644 --- a/internal/provider/data_source_aci_epg_useg_dns_attribute.go +++ b/internal/provider/data_source_aci_epg_useg_dns_attribute.go @@ -146,7 +146,7 @@ func (d *FvDnsAttrDataSource) Read(ctx context.Context, req datasource.ReadReque return } - setFvDnsAttrId(ctx, data) + SetFvDnsAttrId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvDnsAttrAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_epg_useg_ip_attribute.go b/internal/provider/data_source_aci_epg_useg_ip_attribute.go index ad21d6468..d723ab882 100644 --- a/internal/provider/data_source_aci_epg_useg_ip_attribute.go +++ b/internal/provider/data_source_aci_epg_useg_ip_attribute.go @@ -150,7 +150,7 @@ func (d *FvIpAttrDataSource) Read(ctx context.Context, req datasource.ReadReques return } - setFvIpAttrId(ctx, data) + SetFvIpAttrId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvIpAttrAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_epg_useg_mac_attribute.go b/internal/provider/data_source_aci_epg_useg_mac_attribute.go index 7c1e5b2c1..564ef5c3b 100644 --- a/internal/provider/data_source_aci_epg_useg_mac_attribute.go +++ b/internal/provider/data_source_aci_epg_useg_mac_attribute.go @@ -146,7 +146,7 @@ func (d *FvMacAttrDataSource) Read(ctx context.Context, req datasource.ReadReque return } - setFvMacAttrId(ctx, data) + SetFvMacAttrId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvMacAttrAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_epg_useg_sub_block_statement.go b/internal/provider/data_source_aci_epg_useg_sub_block_statement.go index 3c80cdf14..1356d3442 100644 --- a/internal/provider/data_source_aci_epg_useg_sub_block_statement.go +++ b/internal/provider/data_source_aci_epg_useg_sub_block_statement.go @@ -146,7 +146,7 @@ func (d *FvSCrtrnDataSource) Read(ctx context.Context, req datasource.ReadReques return } - setFvSCrtrnId(ctx, data) + SetFvSCrtrnId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvSCrtrnAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_epg_useg_vm_attribute.go b/internal/provider/data_source_aci_epg_useg_vm_attribute.go index dea35be8e..c0b7de6cb 100644 --- a/internal/provider/data_source_aci_epg_useg_vm_attribute.go +++ b/internal/provider/data_source_aci_epg_useg_vm_attribute.go @@ -162,7 +162,7 @@ func (d *FvVmAttrDataSource) Read(ctx context.Context, req datasource.ReadReques return } - setFvVmAttrId(ctx, data) + SetFvVmAttrId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvVmAttrAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_external_management_network_instance_profile.go b/internal/provider/data_source_aci_external_management_network_instance_profile.go index ec73384ec..39e6db619 100644 --- a/internal/provider/data_source_aci_external_management_network_instance_profile.go +++ b/internal/provider/data_source_aci_external_management_network_instance_profile.go @@ -154,7 +154,7 @@ func (d *MgmtInstPDataSource) Read(ctx context.Context, req datasource.ReadReque return } - setMgmtInstPId(ctx, data) + SetMgmtInstPId(ctx, data) // Create a copy of the Id for when not found during getAndSetMgmtInstPAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_external_management_network_subnet.go b/internal/provider/data_source_aci_external_management_network_subnet.go index c14f87be2..9dd4f7ec6 100644 --- a/internal/provider/data_source_aci_external_management_network_subnet.go +++ b/internal/provider/data_source_aci_external_management_network_subnet.go @@ -138,7 +138,7 @@ func (d *MgmtSubnetDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - setMgmtSubnetId(ctx, data) + SetMgmtSubnetId(ctx, data) // Create a copy of the Id for when not found during getAndSetMgmtSubnetAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_l3out_consumer_label.go b/internal/provider/data_source_aci_l3out_consumer_label.go index 8781de9e8..f395d5669 100644 --- a/internal/provider/data_source_aci_l3out_consumer_label.go +++ b/internal/provider/data_source_aci_l3out_consumer_label.go @@ -150,7 +150,7 @@ func (d *L3extConsLblDataSource) Read(ctx context.Context, req datasource.ReadRe return } - setL3extConsLblId(ctx, data) + SetL3extConsLblId(ctx, data) // Create a copy of the Id for when not found during getAndSetL3extConsLblAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_l3out_node_sid_profile.go b/internal/provider/data_source_aci_l3out_node_sid_profile.go index 0452ddff9..e022dc4c9 100644 --- a/internal/provider/data_source_aci_l3out_node_sid_profile.go +++ b/internal/provider/data_source_aci_l3out_node_sid_profile.go @@ -142,7 +142,7 @@ func (d *MplsNodeSidPDataSource) Read(ctx context.Context, req datasource.ReadRe return } - setMplsNodeSidPId(ctx, data) + SetMplsNodeSidPId(ctx, data) // Create a copy of the Id for when not found during getAndSetMplsNodeSidPAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_l3out_provider_label.go b/internal/provider/data_source_aci_l3out_provider_label.go index 24d96f1ef..ed64911dd 100644 --- a/internal/provider/data_source_aci_l3out_provider_label.go +++ b/internal/provider/data_source_aci_l3out_provider_label.go @@ -146,7 +146,7 @@ func (d *L3extProvLblDataSource) Read(ctx context.Context, req datasource.ReadRe return } - setL3extProvLblId(ctx, data) + SetL3extProvLblId(ctx, data) // Create a copy of the Id for when not found during getAndSetL3extProvLblAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_l3out_redistribute_policy.go b/internal/provider/data_source_aci_l3out_redistribute_policy.go index 63f2003f1..4419e5343 100644 --- a/internal/provider/data_source_aci_l3out_redistribute_policy.go +++ b/internal/provider/data_source_aci_l3out_redistribute_policy.go @@ -130,7 +130,7 @@ func (d *L3extRsRedistributePolDataSource) Read(ctx context.Context, req datasou return } - setL3extRsRedistributePolId(ctx, data) + SetL3extRsRedistributePolId(ctx, data) // Create a copy of the Id for when not found during getAndSetL3extRsRedistributePolAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_netflow_monitor_policy.go b/internal/provider/data_source_aci_netflow_monitor_policy.go index df3d82f21..90e7862a9 100644 --- a/internal/provider/data_source_aci_netflow_monitor_policy.go +++ b/internal/provider/data_source_aci_netflow_monitor_policy.go @@ -179,7 +179,7 @@ func (d *NetflowMonitorPolDataSource) Read(ctx context.Context, req datasource.R data.ParentDn = basetypes.NewStringValue("uni/infra") } - setNetflowMonitorPolId(ctx, data) + SetNetflowMonitorPolId(ctx, data) // Create a copy of the Id for when not found during getAndSetNetflowMonitorPolAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_netflow_record_policy.go b/internal/provider/data_source_aci_netflow_record_policy.go index adac0bdc7..84a903aa2 100644 --- a/internal/provider/data_source_aci_netflow_record_policy.go +++ b/internal/provider/data_source_aci_netflow_record_policy.go @@ -158,7 +158,7 @@ func (d *NetflowRecordPolDataSource) Read(ctx context.Context, req datasource.Re data.ParentDn = basetypes.NewStringValue("uni/infra") } - setNetflowRecordPolId(ctx, data) + SetNetflowRecordPolId(ctx, data) // Create a copy of the Id for when not found during getAndSetNetflowRecordPolAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_out_of_band_contract.go b/internal/provider/data_source_aci_out_of_band_contract.go index d81a82045..d38de8145 100644 --- a/internal/provider/data_source_aci_out_of_band_contract.go +++ b/internal/provider/data_source_aci_out_of_band_contract.go @@ -154,7 +154,7 @@ func (d *VzOOBBrCPDataSource) Read(ctx context.Context, req datasource.ReadReque return } - setVzOOBBrCPId(ctx, data) + SetVzOOBBrCPId(ctx, data) // Create a copy of the Id for when not found during getAndSetVzOOBBrCPAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_pim_route_map_entry.go b/internal/provider/data_source_aci_pim_route_map_entry.go index 4df1c989f..0c067a10d 100644 --- a/internal/provider/data_source_aci_pim_route_map_entry.go +++ b/internal/provider/data_source_aci_pim_route_map_entry.go @@ -154,7 +154,7 @@ func (d *PimRouteMapEntryDataSource) Read(ctx context.Context, req datasource.Re return } - setPimRouteMapEntryId(ctx, data) + SetPimRouteMapEntryId(ctx, data) // Create a copy of the Id for when not found during getAndSetPimRouteMapEntryAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_pim_route_map_policy.go b/internal/provider/data_source_aci_pim_route_map_policy.go index 4959e5239..fb96f6f89 100644 --- a/internal/provider/data_source_aci_pim_route_map_policy.go +++ b/internal/provider/data_source_aci_pim_route_map_policy.go @@ -142,7 +142,7 @@ func (d *PimRouteMapPolDataSource) Read(ctx context.Context, req datasource.Read return } - setPimRouteMapPolId(ctx, data) + SetPimRouteMapPolId(ctx, data) // Create a copy of the Id for when not found during getAndSetPimRouteMapPolAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_consumed_contract.go b/internal/provider/data_source_aci_relation_to_consumed_contract.go index fb0409a1c..2c69c76a5 100644 --- a/internal/provider/data_source_aci_relation_to_consumed_contract.go +++ b/internal/provider/data_source_aci_relation_to_consumed_contract.go @@ -130,7 +130,7 @@ func (d *FvRsConsDataSource) Read(ctx context.Context, req datasource.ReadReques return } - setFvRsConsId(ctx, data) + SetFvRsConsId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsConsAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract.go b/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract.go index 6c1609301..8eeebaff1 100644 --- a/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract.go +++ b/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract.go @@ -130,7 +130,7 @@ func (d *MgmtRsOoBConsDataSource) Read(ctx context.Context, req datasource.ReadR return } - setMgmtRsOoBConsId(ctx, data) + SetMgmtRsOoBConsId(ctx, data) // Create a copy of the Id for when not found during getAndSetMgmtRsOoBConsAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_contract_master.go b/internal/provider/data_source_aci_relation_to_contract_master.go index dfcc7e29a..44fba6792 100644 --- a/internal/provider/data_source_aci_relation_to_contract_master.go +++ b/internal/provider/data_source_aci_relation_to_contract_master.go @@ -126,7 +126,7 @@ func (d *FvRsSecInheritedDataSource) Read(ctx context.Context, req datasource.Re return } - setFvRsSecInheritedId(ctx, data) + SetFvRsSecInheritedId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsSecInheritedAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_domain.go b/internal/provider/data_source_aci_relation_to_domain.go index 557e80707..5bfc7f4b1 100644 --- a/internal/provider/data_source_aci_relation_to_domain.go +++ b/internal/provider/data_source_aci_relation_to_domain.go @@ -222,7 +222,7 @@ func (d *FvRsDomAttDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - setFvRsDomAttId(ctx, data) + SetFvRsDomAttId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsDomAttAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_fibre_channel_path.go b/internal/provider/data_source_aci_relation_to_fibre_channel_path.go index 6c7828180..f5f4d4bf6 100644 --- a/internal/provider/data_source_aci_relation_to_fibre_channel_path.go +++ b/internal/provider/data_source_aci_relation_to_fibre_channel_path.go @@ -138,7 +138,7 @@ func (d *FvRsFcPathAttDataSource) Read(ctx context.Context, req datasource.ReadR return } - setFvRsFcPathAttId(ctx, data) + SetFvRsFcPathAttId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsFcPathAttAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_imported_contract.go b/internal/provider/data_source_aci_relation_to_imported_contract.go index 4c0faf3cb..81f6f2b70 100644 --- a/internal/provider/data_source_aci_relation_to_imported_contract.go +++ b/internal/provider/data_source_aci_relation_to_imported_contract.go @@ -130,7 +130,7 @@ func (d *FvRsConsIfDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - setFvRsConsIfId(ctx, data) + SetFvRsConsIfId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsConsIfAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_intra_epg_contract.go b/internal/provider/data_source_aci_relation_to_intra_epg_contract.go index 721ff488f..4049e0388 100644 --- a/internal/provider/data_source_aci_relation_to_intra_epg_contract.go +++ b/internal/provider/data_source_aci_relation_to_intra_epg_contract.go @@ -126,7 +126,7 @@ func (d *FvRsIntraEpgDataSource) Read(ctx context.Context, req datasource.ReadRe return } - setFvRsIntraEpgId(ctx, data) + SetFvRsIntraEpgId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsIntraEpgAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_netflow_exporter.go b/internal/provider/data_source_aci_relation_to_netflow_exporter.go index cca30ef3e..55fbeae64 100644 --- a/internal/provider/data_source_aci_relation_to_netflow_exporter.go +++ b/internal/provider/data_source_aci_relation_to_netflow_exporter.go @@ -126,7 +126,7 @@ func (d *NetflowRsMonitorToExporterDataSource) Read(ctx context.Context, req dat return } - setNetflowRsMonitorToExporterId(ctx, data) + SetNetflowRsMonitorToExporterId(ctx, data) // Create a copy of the Id for when not found during getAndSetNetflowRsMonitorToExporterAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_provided_contract.go b/internal/provider/data_source_aci_relation_to_provided_contract.go index d5ee6faef..1f55d1df4 100644 --- a/internal/provider/data_source_aci_relation_to_provided_contract.go +++ b/internal/provider/data_source_aci_relation_to_provided_contract.go @@ -134,7 +134,7 @@ func (d *FvRsProvDataSource) Read(ctx context.Context, req datasource.ReadReques return } - setFvRsProvId(ctx, data) + SetFvRsProvId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsProvAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_static_leaf.go b/internal/provider/data_source_aci_relation_to_static_leaf.go index 50fdc2638..91c927bb7 100644 --- a/internal/provider/data_source_aci_relation_to_static_leaf.go +++ b/internal/provider/data_source_aci_relation_to_static_leaf.go @@ -142,7 +142,7 @@ func (d *FvRsNodeAttDataSource) Read(ctx context.Context, req datasource.ReadReq return } - setFvRsNodeAttId(ctx, data) + SetFvRsNodeAttId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsNodeAttAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_static_path.go b/internal/provider/data_source_aci_relation_to_static_path.go index c4c6bf060..b4a298dc6 100644 --- a/internal/provider/data_source_aci_relation_to_static_path.go +++ b/internal/provider/data_source_aci_relation_to_static_path.go @@ -146,7 +146,7 @@ func (d *FvRsPathAttDataSource) Read(ctx context.Context, req datasource.ReadReq return } - setFvRsPathAttId(ctx, data) + SetFvRsPathAttId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsPathAttAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_taboo_contract.go b/internal/provider/data_source_aci_relation_to_taboo_contract.go index 526c245ae..b00ee693a 100644 --- a/internal/provider/data_source_aci_relation_to_taboo_contract.go +++ b/internal/provider/data_source_aci_relation_to_taboo_contract.go @@ -126,7 +126,7 @@ func (d *FvRsProtByDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - setFvRsProtById(ctx, data) + SetFvRsProtById(ctx, data) // Create a copy of the Id for when not found during getAndSetFvRsProtByAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group.go b/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group.go index f0c93fa19..fbe7dd280 100644 --- a/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group.go +++ b/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group.go @@ -126,7 +126,7 @@ func (d *L3extRsOutToFBRGroupDataSource) Read(ctx context.Context, req datasourc return } - setL3extRsOutToFBRGroupId(ctx, data) + SetL3extRsOutToFBRGroupId(ctx, data) // Create a copy of the Id for when not found during getAndSetL3extRsOutToFBRGroupAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_route_control_profile.go b/internal/provider/data_source_aci_route_control_profile.go index a78e1669d..5995d134b 100644 --- a/internal/provider/data_source_aci_route_control_profile.go +++ b/internal/provider/data_source_aci_route_control_profile.go @@ -150,7 +150,7 @@ func (d *RtctrlProfileDataSource) Read(ctx context.Context, req datasource.ReadR return } - setRtctrlProfileId(ctx, data) + SetRtctrlProfileId(ctx, data) // Create a copy of the Id for when not found during getAndSetRtctrlProfileAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_tag.go b/internal/provider/data_source_aci_tag.go index 806e81c8a..925d76df4 100644 --- a/internal/provider/data_source_aci_tag.go +++ b/internal/provider/data_source_aci_tag.go @@ -94,7 +94,7 @@ func (d *TagTagDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - setTagTagId(ctx, data) + SetTagTagId(ctx, data) // Create a copy of the Id for when not found during getAndSetTagTagAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_trust_control_policy.go b/internal/provider/data_source_aci_trust_control_policy.go index 807847c9d..4231b58c7 100644 --- a/internal/provider/data_source_aci_trust_control_policy.go +++ b/internal/provider/data_source_aci_trust_control_policy.go @@ -166,7 +166,7 @@ func (d *FhsTrustCtrlPolDataSource) Read(ctx context.Context, req datasource.Rea return } - setFhsTrustCtrlPolId(ctx, data) + SetFhsTrustCtrlPolId(ctx, data) // Create a copy of the Id for when not found during getAndSetFhsTrustCtrlPolAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_vrf_fallback_route.go b/internal/provider/data_source_aci_vrf_fallback_route.go index 2411e0961..4199bab0a 100644 --- a/internal/provider/data_source_aci_vrf_fallback_route.go +++ b/internal/provider/data_source_aci_vrf_fallback_route.go @@ -138,7 +138,7 @@ func (d *FvFBRouteDataSource) Read(ctx context.Context, req datasource.ReadReque return } - setFvFBRouteId(ctx, data) + SetFvFBRouteId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvFBRouteAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_vrf_fallback_route_group.go b/internal/provider/data_source_aci_vrf_fallback_route_group.go index d5270596a..de96cd204 100644 --- a/internal/provider/data_source_aci_vrf_fallback_route_group.go +++ b/internal/provider/data_source_aci_vrf_fallback_route_group.go @@ -190,7 +190,7 @@ func (d *FvFBRGroupDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - setFvFBRGroupId(ctx, data) + SetFvFBRGroupId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvFBRGroupAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/data_source_aci_vrf_fallback_route_group_member.go b/internal/provider/data_source_aci_vrf_fallback_route_group_member.go index 11bc2a747..16c6e3ce5 100644 --- a/internal/provider/data_source_aci_vrf_fallback_route_group_member.go +++ b/internal/provider/data_source_aci_vrf_fallback_route_group_member.go @@ -138,7 +138,7 @@ func (d *FvFBRMemberDataSource) Read(ctx context.Context, req datasource.ReadReq return } - setFvFBRMemberId(ctx, data) + SetFvFBRMemberId(ctx, data) // Create a copy of the Id for when not found during getAndSetFvFBRMemberAttributes cachedId := data.Id.ValueString() diff --git a/internal/provider/resource_aci_access_interface_override.go b/internal/provider/resource_aci_access_interface_override.go index e0034b32d..bf47757df 100644 --- a/internal/provider/resource_aci_access_interface_override.go +++ b/internal/provider/resource_aci_access_interface_override.go @@ -162,7 +162,7 @@ func (r *InfraHPathSResource) ModifyPlan(ctx context.Context, req resource.Modif } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setInfraHPathSId(ctx, planData) + SetInfraHPathSId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -407,7 +407,7 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq var stateData *InfraHPathSResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setInfraHPathSId(ctx, stateData) + SetInfraHPathSId(ctx, stateData) } getAndSetInfraHPathSAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -428,7 +428,7 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq } if data.Id.IsUnknown() || data.Id.IsNull() { - setInfraHPathSId(ctx, data) + SetInfraHPathSId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_access_interface_override with id '%s'", data.Id.ValueString())) @@ -445,7 +445,7 @@ func (r *InfraHPathSResource) Create(ctx context.Context, req resource.CreateReq var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, true, data, infraRsHPathAttPlan, infraRsHPathAttState, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, true, data, infraRsHPathAttPlan, infraRsHPathAttState, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -516,7 +516,7 @@ func (r *InfraHPathSResource) Update(ctx context.Context, req resource.UpdateReq var tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, false, data, infraRsHPathAttPlan, infraRsHPathAttState, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetInfraHPathSCreateJsonPayload(ctx, &resp.Diagnostics, false, data, infraRsHPathAttPlan, infraRsHPathAttState, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -711,7 +711,7 @@ func setInfraHPathSParentDn(ctx context.Context, dn string, data *InfraHPathSRes data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setInfraHPathSId(ctx context.Context, data *InfraHPathSResourceModel) { +func SetInfraHPathSId(ctx context.Context, data *InfraHPathSResourceModel) { rn := getInfraHPathSRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -850,7 +850,7 @@ func getInfraHPathSTagTagChildPayloads(ctx context.Context, diags *diag.Diagnost return childPayloads } -func getInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraHPathSResourceModel, infraRsHPathAttPlan, infraRsHPathAttState []InfraRsHPathAttInfraHPathSResourceModel, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState []InfraRsPathToAccBaseGrpInfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) *container.Container { +func GetInfraHPathSCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *InfraHPathSResourceModel, infraRsHPathAttPlan, infraRsHPathAttState []InfraRsHPathAttInfraHPathSResourceModel, infraRsPathToAccBaseGrpPlan, infraRsPathToAccBaseGrpState []InfraRsPathToAccBaseGrpInfraHPathSResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationInfraHPathSResourceModel, tagTagPlan, tagTagState []TagTagInfraHPathSResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_annotation.go b/internal/provider/resource_aci_annotation.go index f35aad4bc..d9aca3dda 100644 --- a/internal/provider/resource_aci_annotation.go +++ b/internal/provider/resource_aci_annotation.go @@ -69,7 +69,7 @@ func (r *TagAnnotationResource) ModifyPlan(ctx context.Context, req resource.Mod } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Key.IsUnknown() { - setTagAnnotationId(ctx, planData) + SetTagAnnotationId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -168,12 +168,12 @@ func (r *TagAnnotationResource) Create(ctx context.Context, req resource.CreateR } if data.Id.IsUnknown() || data.Id.IsNull() { - setTagAnnotationId(ctx, data) + SetTagAnnotationId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_annotation with id '%s'", data.Id.ValueString())) - jsonPayload := getTagAnnotationCreateJsonPayload(ctx, &resp.Diagnostics, true, data) + jsonPayload := GetTagAnnotationCreateJsonPayload(ctx, &resp.Diagnostics, true, data) if resp.Diagnostics.HasError() { return @@ -230,7 +230,7 @@ func (r *TagAnnotationResource) Update(ctx context.Context, req resource.UpdateR tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_annotation with id '%s'", data.Id.ValueString())) - jsonPayload := getTagAnnotationCreateJsonPayload(ctx, &resp.Diagnostics, false, data) + jsonPayload := GetTagAnnotationCreateJsonPayload(ctx, &resp.Diagnostics, false, data) if resp.Diagnostics.HasError() { return @@ -344,12 +344,12 @@ func setTagAnnotationParentDn(ctx context.Context, dn string, data *TagAnnotatio data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setTagAnnotationId(ctx context.Context, data *TagAnnotationResourceModel) { +func SetTagAnnotationId(ctx context.Context, data *TagAnnotationResourceModel) { rn := getTagAnnotationRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } -func getTagAnnotationCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *TagAnnotationResourceModel) *container.Container { +func GetTagAnnotationCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *TagAnnotationResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_application_epg.go b/internal/provider/resource_aci_application_epg.go index 39be5de51..ecc6a00a4 100644 --- a/internal/provider/resource_aci_application_epg.go +++ b/internal/provider/resource_aci_application_epg.go @@ -1510,7 +1510,7 @@ func (r *FvAEPgResource) ModifyPlan(ctx context.Context, req resource.ModifyPlan } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFvAEPgId(ctx, planData) + SetFvAEPgId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -3931,7 +3931,7 @@ func (r *FvAEPgResource) Create(ctx context.Context, req resource.CreateRequest, var stateData *FvAEPgResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvAEPgId(ctx, stateData) + SetFvAEPgId(ctx, stateData) } getAndSetFvAEPgAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -3952,7 +3952,7 @@ func (r *FvAEPgResource) Create(ctx context.Context, req resource.CreateRequest, } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvAEPgId(ctx, data) + SetFvAEPgId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_application_epg with id '%s'", data.Id.ValueString())) @@ -4011,7 +4011,7 @@ func (r *FvAEPgResource) Create(ctx context.Context, req resource.CreateRequest, var tagTagPlan, tagTagState []TagTagFvAEPgResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvAEPgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvCrtrnPlan, fvCrtrnState, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState, fvRsBdPlan, fvRsBdState, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsCustQosPolPlan, fvRsCustQosPolState, fvRsDomAttPlan, fvRsDomAttState, fvRsDppPolPlan, fvRsDppPolState, fvRsFcPathAttPlan, fvRsFcPathAttState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsNodeAttPlan, fvRsNodeAttState, fvRsPathAttPlan, fvRsPathAttState, fvRsProtByPlan, fvRsProtByState, fvRsProvPlan, fvRsProvState, fvRsSecInheritedPlan, fvRsSecInheritedState, fvRsTrustCtrlPlan, fvRsTrustCtrlState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvAEPgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvCrtrnPlan, fvCrtrnState, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState, fvRsBdPlan, fvRsBdState, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsCustQosPolPlan, fvRsCustQosPolState, fvRsDomAttPlan, fvRsDomAttState, fvRsDppPolPlan, fvRsDppPolState, fvRsFcPathAttPlan, fvRsFcPathAttState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsNodeAttPlan, fvRsNodeAttState, fvRsPathAttPlan, fvRsPathAttState, fvRsProtByPlan, fvRsProtByState, fvRsProvPlan, fvRsProvState, fvRsSecInheritedPlan, fvRsSecInheritedState, fvRsTrustCtrlPlan, fvRsTrustCtrlState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -4124,7 +4124,7 @@ func (r *FvAEPgResource) Update(ctx context.Context, req resource.UpdateRequest, var tagTagPlan, tagTagState []TagTagFvAEPgResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvAEPgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvCrtrnPlan, fvCrtrnState, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState, fvRsBdPlan, fvRsBdState, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsCustQosPolPlan, fvRsCustQosPolState, fvRsDomAttPlan, fvRsDomAttState, fvRsDppPolPlan, fvRsDppPolState, fvRsFcPathAttPlan, fvRsFcPathAttState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsNodeAttPlan, fvRsNodeAttState, fvRsPathAttPlan, fvRsPathAttState, fvRsProtByPlan, fvRsProtByState, fvRsProvPlan, fvRsProvState, fvRsSecInheritedPlan, fvRsSecInheritedState, fvRsTrustCtrlPlan, fvRsTrustCtrlState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvAEPgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvCrtrnPlan, fvCrtrnState, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState, fvRsBdPlan, fvRsBdState, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsCustQosPolPlan, fvRsCustQosPolState, fvRsDomAttPlan, fvRsDomAttState, fvRsDppPolPlan, fvRsDppPolState, fvRsFcPathAttPlan, fvRsFcPathAttState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsNodeAttPlan, fvRsNodeAttState, fvRsPathAttPlan, fvRsPathAttState, fvRsProtByPlan, fvRsProtByState, fvRsProvPlan, fvRsProvState, fvRsSecInheritedPlan, fvRsSecInheritedState, fvRsTrustCtrlPlan, fvRsTrustCtrlState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -4704,7 +4704,7 @@ func setFvAEPgParentDn(ctx context.Context, dn string, data *FvAEPgResourceModel data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvAEPgId(ctx context.Context, data *FvAEPgResourceModel) { +func SetFvAEPgId(ctx context.Context, data *FvAEPgResourceModel) { rn := getFvAEPgRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -5505,7 +5505,7 @@ func getFvAEPgTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, return childPayloads } -func getFvAEPgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvAEPgResourceModel, fvCrtrnPlan, fvCrtrnState []FvCrtrnFvAEPgResourceModel, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState []FvRsAEPgMonPolFvAEPgResourceModel, fvRsBdPlan, fvRsBdState []FvRsBdFvAEPgResourceModel, fvRsConsPlan, fvRsConsState []FvRsConsFvAEPgResourceModel, fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvAEPgResourceModel, fvRsCustQosPolPlan, fvRsCustQosPolState []FvRsCustQosPolFvAEPgResourceModel, fvRsDomAttPlan, fvRsDomAttState []FvRsDomAttFvAEPgResourceModel, fvRsDppPolPlan, fvRsDppPolState []FvRsDppPolFvAEPgResourceModel, fvRsFcPathAttPlan, fvRsFcPathAttState []FvRsFcPathAttFvAEPgResourceModel, fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvAEPgResourceModel, fvRsNodeAttPlan, fvRsNodeAttState []FvRsNodeAttFvAEPgResourceModel, fvRsPathAttPlan, fvRsPathAttState []FvRsPathAttFvAEPgResourceModel, fvRsProtByPlan, fvRsProtByState []FvRsProtByFvAEPgResourceModel, fvRsProvPlan, fvRsProvState []FvRsProvFvAEPgResourceModel, fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvAEPgResourceModel, fvRsTrustCtrlPlan, fvRsTrustCtrlState []FvRsTrustCtrlFvAEPgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvAEPgResourceModel, tagTagPlan, tagTagState []TagTagFvAEPgResourceModel) *container.Container { +func GetFvAEPgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvAEPgResourceModel, fvCrtrnPlan, fvCrtrnState []FvCrtrnFvAEPgResourceModel, fvRsAEPgMonPolPlan, fvRsAEPgMonPolState []FvRsAEPgMonPolFvAEPgResourceModel, fvRsBdPlan, fvRsBdState []FvRsBdFvAEPgResourceModel, fvRsConsPlan, fvRsConsState []FvRsConsFvAEPgResourceModel, fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvAEPgResourceModel, fvRsCustQosPolPlan, fvRsCustQosPolState []FvRsCustQosPolFvAEPgResourceModel, fvRsDomAttPlan, fvRsDomAttState []FvRsDomAttFvAEPgResourceModel, fvRsDppPolPlan, fvRsDppPolState []FvRsDppPolFvAEPgResourceModel, fvRsFcPathAttPlan, fvRsFcPathAttState []FvRsFcPathAttFvAEPgResourceModel, fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvAEPgResourceModel, fvRsNodeAttPlan, fvRsNodeAttState []FvRsNodeAttFvAEPgResourceModel, fvRsPathAttPlan, fvRsPathAttState []FvRsPathAttFvAEPgResourceModel, fvRsProtByPlan, fvRsProtByState []FvRsProtByFvAEPgResourceModel, fvRsProvPlan, fvRsProvState []FvRsProvFvAEPgResourceModel, fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvAEPgResourceModel, fvRsTrustCtrlPlan, fvRsTrustCtrlState []FvRsTrustCtrlFvAEPgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvAEPgResourceModel, tagTagPlan, tagTagState []TagTagFvAEPgResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_custom_qos_policy.go b/internal/provider/resource_aci_custom_qos_policy.go index f439e24b3..432cd561f 100644 --- a/internal/provider/resource_aci_custom_qos_policy.go +++ b/internal/provider/resource_aci_custom_qos_policy.go @@ -120,7 +120,7 @@ func (r *QosCustomPolResource) ModifyPlan(ctx context.Context, req resource.Modi } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setQosCustomPolId(ctx, planData) + SetQosCustomPolId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -302,7 +302,7 @@ func (r *QosCustomPolResource) Create(ctx context.Context, req resource.CreateRe var stateData *QosCustomPolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setQosCustomPolId(ctx, stateData) + SetQosCustomPolId(ctx, stateData) } getAndSetQosCustomPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -323,7 +323,7 @@ func (r *QosCustomPolResource) Create(ctx context.Context, req resource.CreateRe } if data.Id.IsUnknown() || data.Id.IsNull() { - setQosCustomPolId(ctx, data) + SetQosCustomPolId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_custom_qos_policy with id '%s'", data.Id.ValueString())) @@ -334,7 +334,7 @@ func (r *QosCustomPolResource) Create(ctx context.Context, req resource.CreateRe var tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -399,7 +399,7 @@ func (r *QosCustomPolResource) Update(ctx context.Context, req resource.UpdateRe var tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -564,7 +564,7 @@ func setQosCustomPolParentDn(ctx context.Context, dn string, data *QosCustomPolR data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setQosCustomPolId(ctx context.Context, data *QosCustomPolResourceModel) { +func SetQosCustomPolId(ctx context.Context, data *QosCustomPolResourceModel) { rn := getQosCustomPolRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -648,7 +648,7 @@ func getQosCustomPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getQosCustomPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosCustomPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel, tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel) *container.Container { +func GetQosCustomPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosCustomPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel, tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_data_plane_policing_policy.go b/internal/provider/resource_aci_data_plane_policing_policy.go index e4762cdc6..e1a88f445 100644 --- a/internal/provider/resource_aci_data_plane_policing_policy.go +++ b/internal/provider/resource_aci_data_plane_policing_policy.go @@ -164,7 +164,7 @@ func (r *QosDppPolResource) ModifyPlan(ctx context.Context, req resource.ModifyP } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setQosDppPolId(ctx, planData) + SetQosDppPolId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -594,7 +594,7 @@ func (r *QosDppPolResource) Create(ctx context.Context, req resource.CreateReque var stateData *QosDppPolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setQosDppPolId(ctx, stateData) + SetQosDppPolId(ctx, stateData) } getAndSetQosDppPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -615,7 +615,7 @@ func (r *QosDppPolResource) Create(ctx context.Context, req resource.CreateReque } if data.Id.IsUnknown() || data.Id.IsNull() { - setQosDppPolId(ctx, data) + SetQosDppPolId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_data_plane_policing_policy with id '%s'", data.Id.ValueString())) @@ -626,7 +626,7 @@ func (r *QosDppPolResource) Create(ctx context.Context, req resource.CreateReque var tagTagPlan, tagTagState []TagTagQosDppPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getQosDppPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetQosDppPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -691,7 +691,7 @@ func (r *QosDppPolResource) Update(ctx context.Context, req resource.UpdateReque var tagTagPlan, tagTagState []TagTagQosDppPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getQosDppPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetQosDppPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -919,7 +919,7 @@ func setQosDppPolParentDn(ctx context.Context, dn string, data *QosDppPolResourc data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setQosDppPolId(ctx context.Context, data *QosDppPolResourceModel) { +func SetQosDppPolId(ctx context.Context, data *QosDppPolResourceModel) { rn := getQosDppPolRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -1003,7 +1003,7 @@ func getQosDppPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getQosDppPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosDppPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDppPolResourceModel, tagTagPlan, tagTagState []TagTagQosDppPolResourceModel) *container.Container { +func GetQosDppPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosDppPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDppPolResourceModel, tagTagPlan, tagTagState []TagTagQosDppPolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_endpoint_security_group.go b/internal/provider/resource_aci_endpoint_security_group.go index 1d113bfdd..f092d113d 100644 --- a/internal/provider/resource_aci_endpoint_security_group.go +++ b/internal/provider/resource_aci_endpoint_security_group.go @@ -730,7 +730,7 @@ func (r *FvESgResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanR } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFvESgId(ctx, planData) + SetFvESgId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -1701,7 +1701,7 @@ func (r *FvESgResource) Create(ctx context.Context, req resource.CreateRequest, var stateData *FvESgResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvESgId(ctx, stateData) + SetFvESgId(ctx, stateData) } getAndSetFvESgAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -1722,7 +1722,7 @@ func (r *FvESgResource) Create(ctx context.Context, req resource.CreateRequest, } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvESgId(ctx, data) + SetFvESgId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString())) @@ -1751,7 +1751,7 @@ func (r *FvESgResource) Create(ctx context.Context, req resource.CreateRequest, var tagTagPlan, tagTagState []TagTagFvESgResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvESgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsProvPlan, fvRsProvState, fvRsScopePlan, fvRsScopeState, fvRsSecInheritedPlan, fvRsSecInheritedState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvESgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsProvPlan, fvRsProvState, fvRsScopePlan, fvRsScopeState, fvRsSecInheritedPlan, fvRsSecInheritedState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -1834,7 +1834,7 @@ func (r *FvESgResource) Update(ctx context.Context, req resource.UpdateRequest, var tagTagPlan, tagTagState []TagTagFvESgResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvESgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsProvPlan, fvRsProvState, fvRsScopePlan, fvRsScopeState, fvRsSecInheritedPlan, fvRsSecInheritedState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvESgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsProvPlan, fvRsProvState, fvRsScopePlan, fvRsScopeState, fvRsSecInheritedPlan, fvRsSecInheritedState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -2114,7 +2114,7 @@ func setFvESgParentDn(ctx context.Context, dn string, data *FvESgResourceModel) data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvESgId(ctx context.Context, data *FvESgResourceModel) { +func SetFvESgId(ctx context.Context, data *FvESgResourceModel) { rn := getFvESgRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -2444,7 +2444,7 @@ func getFvESgTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, d return childPayloads } -func getFvESgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvESgResourceModel, fvRsConsPlan, fvRsConsState []FvRsConsFvESgResourceModel, fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvESgResourceModel, fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvESgResourceModel, fvRsProvPlan, fvRsProvState []FvRsProvFvESgResourceModel, fvRsScopePlan, fvRsScopeState []FvRsScopeFvESgResourceModel, fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvESgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvESgResourceModel, tagTagPlan, tagTagState []TagTagFvESgResourceModel) *container.Container { +func GetFvESgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvESgResourceModel, fvRsConsPlan, fvRsConsState []FvRsConsFvESgResourceModel, fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvESgResourceModel, fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvESgResourceModel, fvRsProvPlan, fvRsProvState []FvRsProvFvESgResourceModel, fvRsScopePlan, fvRsScopeState []FvRsScopeFvESgResourceModel, fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvESgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvESgResourceModel, tagTagPlan, tagTagState []TagTagFvESgResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_endpoint_tag_ip.go b/internal/provider/resource_aci_endpoint_tag_ip.go index e91a43b3b..7e1aa6d28 100644 --- a/internal/provider/resource_aci_endpoint_tag_ip.go +++ b/internal/provider/resource_aci_endpoint_tag_ip.go @@ -121,7 +121,7 @@ func (r *FvEpIpTagResource) ModifyPlan(ctx context.Context, req resource.ModifyP } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.CtxName.IsUnknown() && !planData.Ip.IsUnknown() { - setFvEpIpTagId(ctx, planData) + SetFvEpIpTagId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -303,7 +303,7 @@ func (r *FvEpIpTagResource) Create(ctx context.Context, req resource.CreateReque var stateData *FvEpIpTagResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvEpIpTagId(ctx, stateData) + SetFvEpIpTagId(ctx, stateData) } getAndSetFvEpIpTagAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -324,7 +324,7 @@ func (r *FvEpIpTagResource) Create(ctx context.Context, req resource.CreateReque } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvEpIpTagId(ctx, data) + SetFvEpIpTagId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_endpoint_tag_ip with id '%s'", data.Id.ValueString())) @@ -335,7 +335,7 @@ func (r *FvEpIpTagResource) Create(ctx context.Context, req resource.CreateReque var tagTagPlan, tagTagState []TagTagFvEpIpTagResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvEpIpTagCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvEpIpTagCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -400,7 +400,7 @@ func (r *FvEpIpTagResource) Update(ctx context.Context, req resource.UpdateReque var tagTagPlan, tagTagState []TagTagFvEpIpTagResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvEpIpTagCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvEpIpTagCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -567,7 +567,7 @@ func setFvEpIpTagParentDn(ctx context.Context, dn string, data *FvEpIpTagResourc data.ParentDn = basetypes.NewStringValue(parentDn) } -func setFvEpIpTagId(ctx context.Context, data *FvEpIpTagResourceModel) { +func SetFvEpIpTagId(ctx context.Context, data *FvEpIpTagResourceModel) { rn := getFvEpIpTagRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -651,7 +651,7 @@ func getFvEpIpTagTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getFvEpIpTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvEpIpTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpIpTagResourceModel, tagTagPlan, tagTagState []TagTagFvEpIpTagResourceModel) *container.Container { +func GetFvEpIpTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvEpIpTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpIpTagResourceModel, tagTagPlan, tagTagState []TagTagFvEpIpTagResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_endpoint_tag_mac.go b/internal/provider/resource_aci_endpoint_tag_mac.go index d2fbe0468..273088be2 100644 --- a/internal/provider/resource_aci_endpoint_tag_mac.go +++ b/internal/provider/resource_aci_endpoint_tag_mac.go @@ -121,7 +121,7 @@ func (r *FvEpMacTagResource) ModifyPlan(ctx context.Context, req resource.Modify } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.BdName.IsUnknown() && !planData.Mac.IsUnknown() { - setFvEpMacTagId(ctx, planData) + SetFvEpMacTagId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -303,7 +303,7 @@ func (r *FvEpMacTagResource) Create(ctx context.Context, req resource.CreateRequ var stateData *FvEpMacTagResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvEpMacTagId(ctx, stateData) + SetFvEpMacTagId(ctx, stateData) } getAndSetFvEpMacTagAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -324,7 +324,7 @@ func (r *FvEpMacTagResource) Create(ctx context.Context, req resource.CreateRequ } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvEpMacTagId(ctx, data) + SetFvEpMacTagId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_endpoint_tag_mac with id '%s'", data.Id.ValueString())) @@ -335,7 +335,7 @@ func (r *FvEpMacTagResource) Create(ctx context.Context, req resource.CreateRequ var tagTagPlan, tagTagState []TagTagFvEpMacTagResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvEpMacTagCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvEpMacTagCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -400,7 +400,7 @@ func (r *FvEpMacTagResource) Update(ctx context.Context, req resource.UpdateRequ var tagTagPlan, tagTagState []TagTagFvEpMacTagResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvEpMacTagCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvEpMacTagCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -567,7 +567,7 @@ func setFvEpMacTagParentDn(ctx context.Context, dn string, data *FvEpMacTagResou data.ParentDn = basetypes.NewStringValue(parentDn) } -func setFvEpMacTagId(ctx context.Context, data *FvEpMacTagResourceModel) { +func SetFvEpMacTagId(ctx context.Context, data *FvEpMacTagResourceModel) { rn := getFvEpMacTagRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -651,7 +651,7 @@ func getFvEpMacTagTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getFvEpMacTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvEpMacTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpMacTagResourceModel, tagTagPlan, tagTagState []TagTagFvEpMacTagResourceModel) *container.Container { +func GetFvEpMacTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvEpMacTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpMacTagResourceModel, tagTagPlan, tagTagState []TagTagFvEpMacTagResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_epg_useg_ad_group_attribute.go b/internal/provider/resource_aci_epg_useg_ad_group_attribute.go index b207cc0ae..81bf1c0f2 100644 --- a/internal/provider/resource_aci_epg_useg_ad_group_attribute.go +++ b/internal/provider/resource_aci_epg_useg_ad_group_attribute.go @@ -122,7 +122,7 @@ func (r *FvIdGroupAttrResource) ModifyPlan(ctx context.Context, req resource.Mod } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Selector.IsUnknown() { - setFvIdGroupAttrId(ctx, planData) + SetFvIdGroupAttrId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -313,7 +313,7 @@ func (r *FvIdGroupAttrResource) Create(ctx context.Context, req resource.CreateR var stateData *FvIdGroupAttrResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvIdGroupAttrId(ctx, stateData) + SetFvIdGroupAttrId(ctx, stateData) } getAndSetFvIdGroupAttrAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -334,7 +334,7 @@ func (r *FvIdGroupAttrResource) Create(ctx context.Context, req resource.CreateR } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvIdGroupAttrId(ctx, data) + SetFvIdGroupAttrId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_epg_useg_ad_group_attribute with id '%s'", data.Id.ValueString())) @@ -345,7 +345,7 @@ func (r *FvIdGroupAttrResource) Create(ctx context.Context, req resource.CreateR var tagTagPlan, tagTagState []TagTagFvIdGroupAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvIdGroupAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvIdGroupAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -410,7 +410,7 @@ func (r *FvIdGroupAttrResource) Update(ctx context.Context, req resource.UpdateR var tagTagPlan, tagTagState []TagTagFvIdGroupAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvIdGroupAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvIdGroupAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -578,7 +578,7 @@ func setFvIdGroupAttrParentDn(ctx context.Context, dn string, data *FvIdGroupAtt data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvIdGroupAttrId(ctx context.Context, data *FvIdGroupAttrResourceModel) { +func SetFvIdGroupAttrId(ctx context.Context, data *FvIdGroupAttrResourceModel) { rn := getFvIdGroupAttrRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -662,7 +662,7 @@ func getFvIdGroupAttrTagTagChildPayloads(ctx context.Context, diags *diag.Diagno return childPayloads } -func getFvIdGroupAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvIdGroupAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvIdGroupAttrResourceModel, tagTagPlan, tagTagState []TagTagFvIdGroupAttrResourceModel) *container.Container { +func GetFvIdGroupAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvIdGroupAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvIdGroupAttrResourceModel, tagTagPlan, tagTagState []TagTagFvIdGroupAttrResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_epg_useg_block_statement.go b/internal/provider/resource_aci_epg_useg_block_statement.go index 2aec3c938..bcd27f9b2 100644 --- a/internal/provider/resource_aci_epg_useg_block_statement.go +++ b/internal/provider/resource_aci_epg_useg_block_statement.go @@ -122,7 +122,7 @@ func (r *FvCrtrnResource) ModifyPlan(ctx context.Context, req resource.ModifyPla } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() { - setFvCrtrnId(ctx, planData) + SetFvCrtrnId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -337,7 +337,7 @@ func (r *FvCrtrnResource) Create(ctx context.Context, req resource.CreateRequest var stateData *FvCrtrnResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvCrtrnId(ctx, stateData) + SetFvCrtrnId(ctx, stateData) } getAndSetFvCrtrnAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -358,7 +358,7 @@ func (r *FvCrtrnResource) Create(ctx context.Context, req resource.CreateRequest } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvCrtrnId(ctx, data) + SetFvCrtrnId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_epg_useg_block_statement with id '%s'", data.Id.ValueString())) @@ -369,7 +369,7 @@ func (r *FvCrtrnResource) Create(ctx context.Context, req resource.CreateRequest var tagTagPlan, tagTagState []TagTagFvCrtrnResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvCrtrnCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvCrtrnCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -434,7 +434,7 @@ func (r *FvCrtrnResource) Update(ctx context.Context, req resource.UpdateRequest var tagTagPlan, tagTagState []TagTagFvCrtrnResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvCrtrnCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvCrtrnCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -602,7 +602,7 @@ func setFvCrtrnParentDn(ctx context.Context, dn string, data *FvCrtrnResourceMod data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvCrtrnId(ctx context.Context, data *FvCrtrnResourceModel) { +func SetFvCrtrnId(ctx context.Context, data *FvCrtrnResourceModel) { rn := getFvCrtrnRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -686,7 +686,7 @@ func getFvCrtrnTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, return childPayloads } -func getFvCrtrnCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvCrtrnResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvCrtrnResourceModel, tagTagPlan, tagTagState []TagTagFvCrtrnResourceModel) *container.Container { +func GetFvCrtrnCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvCrtrnResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvCrtrnResourceModel, tagTagPlan, tagTagState []TagTagFvCrtrnResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_epg_useg_dns_attribute.go b/internal/provider/resource_aci_epg_useg_dns_attribute.go index 7ff6a5da9..fcf19fede 100644 --- a/internal/provider/resource_aci_epg_useg_dns_attribute.go +++ b/internal/provider/resource_aci_epg_useg_dns_attribute.go @@ -122,7 +122,7 @@ func (r *FvDnsAttrResource) ModifyPlan(ctx context.Context, req resource.ModifyP } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFvDnsAttrId(ctx, planData) + SetFvDnsAttrId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -313,7 +313,7 @@ func (r *FvDnsAttrResource) Create(ctx context.Context, req resource.CreateReque var stateData *FvDnsAttrResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvDnsAttrId(ctx, stateData) + SetFvDnsAttrId(ctx, stateData) } getAndSetFvDnsAttrAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -334,7 +334,7 @@ func (r *FvDnsAttrResource) Create(ctx context.Context, req resource.CreateReque } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvDnsAttrId(ctx, data) + SetFvDnsAttrId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_epg_useg_dns_attribute with id '%s'", data.Id.ValueString())) @@ -345,7 +345,7 @@ func (r *FvDnsAttrResource) Create(ctx context.Context, req resource.CreateReque var tagTagPlan, tagTagState []TagTagFvDnsAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvDnsAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvDnsAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -410,7 +410,7 @@ func (r *FvDnsAttrResource) Update(ctx context.Context, req resource.UpdateReque var tagTagPlan, tagTagState []TagTagFvDnsAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvDnsAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvDnsAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -578,7 +578,7 @@ func setFvDnsAttrParentDn(ctx context.Context, dn string, data *FvDnsAttrResourc data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvDnsAttrId(ctx context.Context, data *FvDnsAttrResourceModel) { +func SetFvDnsAttrId(ctx context.Context, data *FvDnsAttrResourceModel) { rn := getFvDnsAttrRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -662,7 +662,7 @@ func getFvDnsAttrTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getFvDnsAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvDnsAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvDnsAttrResourceModel, tagTagPlan, tagTagState []TagTagFvDnsAttrResourceModel) *container.Container { +func GetFvDnsAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvDnsAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvDnsAttrResourceModel, tagTagPlan, tagTagState []TagTagFvDnsAttrResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_epg_useg_ip_attribute.go b/internal/provider/resource_aci_epg_useg_ip_attribute.go index 223ccc876..2827d46ff 100644 --- a/internal/provider/resource_aci_epg_useg_ip_attribute.go +++ b/internal/provider/resource_aci_epg_useg_ip_attribute.go @@ -126,7 +126,7 @@ func (r *FvIpAttrResource) ModifyPlan(ctx context.Context, req resource.ModifyPl } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFvIpAttrId(ctx, planData) + SetFvIpAttrId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -328,7 +328,7 @@ func (r *FvIpAttrResource) Create(ctx context.Context, req resource.CreateReques var stateData *FvIpAttrResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvIpAttrId(ctx, stateData) + SetFvIpAttrId(ctx, stateData) } getAndSetFvIpAttrAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -349,7 +349,7 @@ func (r *FvIpAttrResource) Create(ctx context.Context, req resource.CreateReques } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvIpAttrId(ctx, data) + SetFvIpAttrId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_epg_useg_ip_attribute with id '%s'", data.Id.ValueString())) @@ -360,7 +360,7 @@ func (r *FvIpAttrResource) Create(ctx context.Context, req resource.CreateReques var tagTagPlan, tagTagState []TagTagFvIpAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvIpAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvIpAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -425,7 +425,7 @@ func (r *FvIpAttrResource) Update(ctx context.Context, req resource.UpdateReques var tagTagPlan, tagTagState []TagTagFvIpAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvIpAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvIpAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -596,7 +596,7 @@ func setFvIpAttrParentDn(ctx context.Context, dn string, data *FvIpAttrResourceM data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvIpAttrId(ctx context.Context, data *FvIpAttrResourceModel) { +func SetFvIpAttrId(ctx context.Context, data *FvIpAttrResourceModel) { rn := getFvIpAttrRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -680,7 +680,7 @@ func getFvIpAttrTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics return childPayloads } -func getFvIpAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvIpAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvIpAttrResourceModel, tagTagPlan, tagTagState []TagTagFvIpAttrResourceModel) *container.Container { +func GetFvIpAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvIpAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvIpAttrResourceModel, tagTagPlan, tagTagState []TagTagFvIpAttrResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_epg_useg_mac_attribute.go b/internal/provider/resource_aci_epg_useg_mac_attribute.go index 19144cb50..0403c51e4 100644 --- a/internal/provider/resource_aci_epg_useg_mac_attribute.go +++ b/internal/provider/resource_aci_epg_useg_mac_attribute.go @@ -122,7 +122,7 @@ func (r *FvMacAttrResource) ModifyPlan(ctx context.Context, req resource.ModifyP } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFvMacAttrId(ctx, planData) + SetFvMacAttrId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -312,7 +312,7 @@ func (r *FvMacAttrResource) Create(ctx context.Context, req resource.CreateReque var stateData *FvMacAttrResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvMacAttrId(ctx, stateData) + SetFvMacAttrId(ctx, stateData) } getAndSetFvMacAttrAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -333,7 +333,7 @@ func (r *FvMacAttrResource) Create(ctx context.Context, req resource.CreateReque } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvMacAttrId(ctx, data) + SetFvMacAttrId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_epg_useg_mac_attribute with id '%s'", data.Id.ValueString())) @@ -344,7 +344,7 @@ func (r *FvMacAttrResource) Create(ctx context.Context, req resource.CreateReque var tagTagPlan, tagTagState []TagTagFvMacAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvMacAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvMacAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -409,7 +409,7 @@ func (r *FvMacAttrResource) Update(ctx context.Context, req resource.UpdateReque var tagTagPlan, tagTagState []TagTagFvMacAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvMacAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvMacAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -577,7 +577,7 @@ func setFvMacAttrParentDn(ctx context.Context, dn string, data *FvMacAttrResourc data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvMacAttrId(ctx context.Context, data *FvMacAttrResourceModel) { +func SetFvMacAttrId(ctx context.Context, data *FvMacAttrResourceModel) { rn := getFvMacAttrRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -661,7 +661,7 @@ func getFvMacAttrTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getFvMacAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvMacAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvMacAttrResourceModel, tagTagPlan, tagTagState []TagTagFvMacAttrResourceModel) *container.Container { +func GetFvMacAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvMacAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvMacAttrResourceModel, tagTagPlan, tagTagState []TagTagFvMacAttrResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_epg_useg_sub_block_statement.go b/internal/provider/resource_aci_epg_useg_sub_block_statement.go index ce88b1af6..b6ae1027c 100644 --- a/internal/provider/resource_aci_epg_useg_sub_block_statement.go +++ b/internal/provider/resource_aci_epg_useg_sub_block_statement.go @@ -124,7 +124,7 @@ func (r *FvSCrtrnResource) ModifyPlan(ctx context.Context, req resource.ModifyPl } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFvSCrtrnId(ctx, planData) + SetFvSCrtrnId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -318,7 +318,7 @@ func (r *FvSCrtrnResource) Create(ctx context.Context, req resource.CreateReques var stateData *FvSCrtrnResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvSCrtrnId(ctx, stateData) + SetFvSCrtrnId(ctx, stateData) } getAndSetFvSCrtrnAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -339,7 +339,7 @@ func (r *FvSCrtrnResource) Create(ctx context.Context, req resource.CreateReques } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvSCrtrnId(ctx, data) + SetFvSCrtrnId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_epg_useg_sub_block_statement with id '%s'", data.Id.ValueString())) @@ -350,7 +350,7 @@ func (r *FvSCrtrnResource) Create(ctx context.Context, req resource.CreateReques var tagTagPlan, tagTagState []TagTagFvSCrtrnResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvSCrtrnCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvSCrtrnCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -415,7 +415,7 @@ func (r *FvSCrtrnResource) Update(ctx context.Context, req resource.UpdateReques var tagTagPlan, tagTagState []TagTagFvSCrtrnResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvSCrtrnCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvSCrtrnCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -583,7 +583,7 @@ func setFvSCrtrnParentDn(ctx context.Context, dn string, data *FvSCrtrnResourceM data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvSCrtrnId(ctx context.Context, data *FvSCrtrnResourceModel) { +func SetFvSCrtrnId(ctx context.Context, data *FvSCrtrnResourceModel) { rn := getFvSCrtrnRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -667,7 +667,7 @@ func getFvSCrtrnTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics return childPayloads } -func getFvSCrtrnCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvSCrtrnResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvSCrtrnResourceModel, tagTagPlan, tagTagState []TagTagFvSCrtrnResourceModel) *container.Container { +func GetFvSCrtrnCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvSCrtrnResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvSCrtrnResourceModel, tagTagPlan, tagTagState []TagTagFvSCrtrnResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_epg_useg_vm_attribute.go b/internal/provider/resource_aci_epg_useg_vm_attribute.go index 3dfbc1bea..27b0b3672 100644 --- a/internal/provider/resource_aci_epg_useg_vm_attribute.go +++ b/internal/provider/resource_aci_epg_useg_vm_attribute.go @@ -132,7 +132,7 @@ func (r *FvVmAttrResource) ModifyPlan(ctx context.Context, req resource.ModifyPl } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFvVmAttrId(ctx, planData) + SetFvVmAttrId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -364,7 +364,7 @@ func (r *FvVmAttrResource) Create(ctx context.Context, req resource.CreateReques var stateData *FvVmAttrResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvVmAttrId(ctx, stateData) + SetFvVmAttrId(ctx, stateData) } getAndSetFvVmAttrAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -385,7 +385,7 @@ func (r *FvVmAttrResource) Create(ctx context.Context, req resource.CreateReques } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvVmAttrId(ctx, data) + SetFvVmAttrId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_epg_useg_vm_attribute with id '%s'", data.Id.ValueString())) @@ -396,7 +396,7 @@ func (r *FvVmAttrResource) Create(ctx context.Context, req resource.CreateReques var tagTagPlan, tagTagState []TagTagFvVmAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvVmAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvVmAttrCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -461,7 +461,7 @@ func (r *FvVmAttrResource) Update(ctx context.Context, req resource.UpdateReques var tagTagPlan, tagTagState []TagTagFvVmAttrResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvVmAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvVmAttrCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -641,7 +641,7 @@ func setFvVmAttrParentDn(ctx context.Context, dn string, data *FvVmAttrResourceM data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvVmAttrId(ctx context.Context, data *FvVmAttrResourceModel) { +func SetFvVmAttrId(ctx context.Context, data *FvVmAttrResourceModel) { rn := getFvVmAttrRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -725,7 +725,7 @@ func getFvVmAttrTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics return childPayloads } -func getFvVmAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvVmAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvVmAttrResourceModel, tagTagPlan, tagTagState []TagTagFvVmAttrResourceModel) *container.Container { +func GetFvVmAttrCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvVmAttrResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvVmAttrResourceModel, tagTagPlan, tagTagState []TagTagFvVmAttrResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_external_management_network_instance_profile.go b/internal/provider/resource_aci_external_management_network_instance_profile.go index 33e195cfa..238d4b2d7 100644 --- a/internal/provider/resource_aci_external_management_network_instance_profile.go +++ b/internal/provider/resource_aci_external_management_network_instance_profile.go @@ -141,7 +141,7 @@ func (r *MgmtInstPResource) ModifyPlan(ctx context.Context, req resource.ModifyP } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.Name.IsUnknown() { - setMgmtInstPId(ctx, planData) + SetMgmtInstPId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -347,7 +347,7 @@ func (r *MgmtInstPResource) Create(ctx context.Context, req resource.CreateReque var stateData *MgmtInstPResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setMgmtInstPId(ctx, stateData) + SetMgmtInstPId(ctx, stateData) } getAndSetMgmtInstPAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -368,7 +368,7 @@ func (r *MgmtInstPResource) Create(ctx context.Context, req resource.CreateReque } if data.Id.IsUnknown() || data.Id.IsNull() { - setMgmtInstPId(ctx, data) + SetMgmtInstPId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_external_management_network_instance_profile with id '%s'", data.Id.ValueString())) @@ -382,7 +382,7 @@ func (r *MgmtInstPResource) Create(ctx context.Context, req resource.CreateReque var tagTagPlan, tagTagState []TagTagMgmtInstPResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getMgmtInstPCreateJsonPayload(ctx, &resp.Diagnostics, true, data, mgmtRsOoBConsPlan, mgmtRsOoBConsState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtInstPCreateJsonPayload(ctx, &resp.Diagnostics, true, data, mgmtRsOoBConsPlan, mgmtRsOoBConsState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -450,7 +450,7 @@ func (r *MgmtInstPResource) Update(ctx context.Context, req resource.UpdateReque var tagTagPlan, tagTagState []TagTagMgmtInstPResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getMgmtInstPCreateJsonPayload(ctx, &resp.Diagnostics, false, data, mgmtRsOoBConsPlan, mgmtRsOoBConsState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtInstPCreateJsonPayload(ctx, &resp.Diagnostics, false, data, mgmtRsOoBConsPlan, mgmtRsOoBConsState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -613,7 +613,7 @@ func getMgmtInstPRn(ctx context.Context, data *MgmtInstPResourceModel) string { return rn } -func setMgmtInstPId(ctx context.Context, data *MgmtInstPResourceModel) { +func SetMgmtInstPId(ctx context.Context, data *MgmtInstPResourceModel) { rn := getMgmtInstPRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", strings.Split([]string{"uni/tn-mgmt/extmgmt-default/instp-{name}"}[0], "/")[0], rn)) } @@ -741,7 +741,7 @@ func getMgmtInstPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getMgmtInstPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *MgmtInstPResourceModel, mgmtRsOoBConsPlan, mgmtRsOoBConsState []MgmtRsOoBConsMgmtInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtInstPResourceModel, tagTagPlan, tagTagState []TagTagMgmtInstPResourceModel) *container.Container { +func GetMgmtInstPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *MgmtInstPResourceModel, mgmtRsOoBConsPlan, mgmtRsOoBConsState []MgmtRsOoBConsMgmtInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtInstPResourceModel, tagTagPlan, tagTagState []TagTagMgmtInstPResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_external_management_network_subnet.go b/internal/provider/resource_aci_external_management_network_subnet.go index c875e5b6e..bf6e5d4c2 100644 --- a/internal/provider/resource_aci_external_management_network_subnet.go +++ b/internal/provider/resource_aci_external_management_network_subnet.go @@ -118,7 +118,7 @@ func (r *MgmtSubnetResource) ModifyPlan(ctx context.Context, req resource.Modify } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Ip.IsUnknown() { - setMgmtSubnetId(ctx, planData) + SetMgmtSubnetId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -291,7 +291,7 @@ func (r *MgmtSubnetResource) Create(ctx context.Context, req resource.CreateRequ var stateData *MgmtSubnetResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setMgmtSubnetId(ctx, stateData) + SetMgmtSubnetId(ctx, stateData) } getAndSetMgmtSubnetAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -312,7 +312,7 @@ func (r *MgmtSubnetResource) Create(ctx context.Context, req resource.CreateRequ } if data.Id.IsUnknown() || data.Id.IsNull() { - setMgmtSubnetId(ctx, data) + SetMgmtSubnetId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_external_management_network_subnet with id '%s'", data.Id.ValueString())) @@ -323,7 +323,7 @@ func (r *MgmtSubnetResource) Create(ctx context.Context, req resource.CreateRequ var tagTagPlan, tagTagState []TagTagMgmtSubnetResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getMgmtSubnetCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtSubnetCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -388,7 +388,7 @@ func (r *MgmtSubnetResource) Update(ctx context.Context, req resource.UpdateRequ var tagTagPlan, tagTagState []TagTagMgmtSubnetResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getMgmtSubnetCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtSubnetCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -550,7 +550,7 @@ func setMgmtSubnetParentDn(ctx context.Context, dn string, data *MgmtSubnetResou data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setMgmtSubnetId(ctx context.Context, data *MgmtSubnetResourceModel) { +func SetMgmtSubnetId(ctx context.Context, data *MgmtSubnetResourceModel) { rn := getMgmtSubnetRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -634,7 +634,7 @@ func getMgmtSubnetTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getMgmtSubnetCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *MgmtSubnetResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtSubnetResourceModel, tagTagPlan, tagTagState []TagTagMgmtSubnetResourceModel) *container.Container { +func GetMgmtSubnetCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *MgmtSubnetResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtSubnetResourceModel, tagTagPlan, tagTagState []TagTagMgmtSubnetResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_l3out_consumer_label.go b/internal/provider/resource_aci_l3out_consumer_label.go index f77f157bd..ebda66dd1 100644 --- a/internal/provider/resource_aci_l3out_consumer_label.go +++ b/internal/provider/resource_aci_l3out_consumer_label.go @@ -126,7 +126,7 @@ func (r *L3extConsLblResource) ModifyPlan(ctx context.Context, req resource.Modi } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setL3extConsLblId(ctx, planData) + SetL3extConsLblId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -332,7 +332,7 @@ func (r *L3extConsLblResource) Create(ctx context.Context, req resource.CreateRe var stateData *L3extConsLblResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setL3extConsLblId(ctx, stateData) + SetL3extConsLblId(ctx, stateData) } getAndSetL3extConsLblAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -353,7 +353,7 @@ func (r *L3extConsLblResource) Create(ctx context.Context, req resource.CreateRe } if data.Id.IsUnknown() || data.Id.IsNull() { - setL3extConsLblId(ctx, data) + SetL3extConsLblId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_consumer_label with id '%s'", data.Id.ValueString())) @@ -364,7 +364,7 @@ func (r *L3extConsLblResource) Create(ctx context.Context, req resource.CreateRe var tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -429,7 +429,7 @@ func (r *L3extConsLblResource) Update(ctx context.Context, req resource.UpdateRe var tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -600,7 +600,7 @@ func setL3extConsLblParentDn(ctx context.Context, dn string, data *L3extConsLblR data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setL3extConsLblId(ctx context.Context, data *L3extConsLblResourceModel) { +func SetL3extConsLblId(ctx context.Context, data *L3extConsLblResourceModel) { rn := getL3extConsLblRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -684,7 +684,7 @@ func getL3extConsLblTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { +func GetL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_l3out_node_sid_profile.go b/internal/provider/resource_aci_l3out_node_sid_profile.go index 2baeb0223..57fa1d0bb 100644 --- a/internal/provider/resource_aci_l3out_node_sid_profile.go +++ b/internal/provider/resource_aci_l3out_node_sid_profile.go @@ -120,7 +120,7 @@ func (r *MplsNodeSidPResource) ModifyPlan(ctx context.Context, req resource.Modi } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Sidoffset.IsUnknown() { - setMplsNodeSidPId(ctx, planData) + SetMplsNodeSidPId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -302,7 +302,7 @@ func (r *MplsNodeSidPResource) Create(ctx context.Context, req resource.CreateRe var stateData *MplsNodeSidPResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setMplsNodeSidPId(ctx, stateData) + SetMplsNodeSidPId(ctx, stateData) } getAndSetMplsNodeSidPAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -323,7 +323,7 @@ func (r *MplsNodeSidPResource) Create(ctx context.Context, req resource.CreateRe } if data.Id.IsUnknown() || data.Id.IsNull() { - setMplsNodeSidPId(ctx, data) + SetMplsNodeSidPId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) @@ -334,7 +334,7 @@ func (r *MplsNodeSidPResource) Create(ctx context.Context, req resource.CreateRe var tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getMplsNodeSidPCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMplsNodeSidPCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -399,7 +399,7 @@ func (r *MplsNodeSidPResource) Update(ctx context.Context, req resource.UpdateRe var tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getMplsNodeSidPCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMplsNodeSidPCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -564,7 +564,7 @@ func setMplsNodeSidPParentDn(ctx context.Context, dn string, data *MplsNodeSidPR data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setMplsNodeSidPId(ctx context.Context, data *MplsNodeSidPResourceModel) { +func SetMplsNodeSidPId(ctx context.Context, data *MplsNodeSidPResourceModel) { rn := getMplsNodeSidPRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -648,7 +648,7 @@ func getMplsNodeSidPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getMplsNodeSidPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *MplsNodeSidPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMplsNodeSidPResourceModel, tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel) *container.Container { +func GetMplsNodeSidPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *MplsNodeSidPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMplsNodeSidPResourceModel, tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_l3out_provider_label.go b/internal/provider/resource_aci_l3out_provider_label.go index 2f5106fd5..46f1cf709 100644 --- a/internal/provider/resource_aci_l3out_provider_label.go +++ b/internal/provider/resource_aci_l3out_provider_label.go @@ -124,7 +124,7 @@ func (r *L3extProvLblResource) ModifyPlan(ctx context.Context, req resource.Modi } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setL3extProvLblId(ctx, planData) + SetL3extProvLblId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -318,7 +318,7 @@ func (r *L3extProvLblResource) Create(ctx context.Context, req resource.CreateRe var stateData *L3extProvLblResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setL3extProvLblId(ctx, stateData) + SetL3extProvLblId(ctx, stateData) } getAndSetL3extProvLblAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -339,7 +339,7 @@ func (r *L3extProvLblResource) Create(ctx context.Context, req resource.CreateRe } if data.Id.IsUnknown() || data.Id.IsNull() { - setL3extProvLblId(ctx, data) + SetL3extProvLblId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_provider_label with id '%s'", data.Id.ValueString())) @@ -350,7 +350,7 @@ func (r *L3extProvLblResource) Create(ctx context.Context, req resource.CreateRe var tagTagPlan, tagTagState []TagTagL3extProvLblResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extProvLblCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extProvLblCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -415,7 +415,7 @@ func (r *L3extProvLblResource) Update(ctx context.Context, req resource.UpdateRe var tagTagPlan, tagTagState []TagTagL3extProvLblResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extProvLblCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extProvLblCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -583,7 +583,7 @@ func setL3extProvLblParentDn(ctx context.Context, dn string, data *L3extProvLblR data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setL3extProvLblId(ctx context.Context, data *L3extProvLblResourceModel) { +func SetL3extProvLblId(ctx context.Context, data *L3extProvLblResourceModel) { rn := getL3extProvLblRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -667,7 +667,7 @@ func getL3extProvLblTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getL3extProvLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extProvLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extProvLblResourceModel, tagTagPlan, tagTagState []TagTagL3extProvLblResourceModel) *container.Container { +func GetL3extProvLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extProvLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extProvLblResourceModel, tagTagPlan, tagTagState []TagTagL3extProvLblResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_l3out_redistribute_policy.go b/internal/provider/resource_aci_l3out_redistribute_policy.go index 0154d7350..e08bc3917 100644 --- a/internal/provider/resource_aci_l3out_redistribute_policy.go +++ b/internal/provider/resource_aci_l3out_redistribute_policy.go @@ -117,7 +117,7 @@ func (r *L3extRsRedistributePolResource) ModifyPlan(ctx context.Context, req res } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Src.IsUnknown() && !planData.TnRtctrlProfileName.IsUnknown() { - setL3extRsRedistributePolId(ctx, planData) + SetL3extRsRedistributePolId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -275,7 +275,7 @@ func (r *L3extRsRedistributePolResource) Create(ctx context.Context, req resourc var stateData *L3extRsRedistributePolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setL3extRsRedistributePolId(ctx, stateData) + SetL3extRsRedistributePolId(ctx, stateData) } getAndSetL3extRsRedistributePolAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -296,7 +296,7 @@ func (r *L3extRsRedistributePolResource) Create(ctx context.Context, req resourc } if data.Id.IsUnknown() || data.Id.IsNull() { - setL3extRsRedistributePolId(ctx, data) + SetL3extRsRedistributePolId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_redistribute_policy with id '%s'", data.Id.ValueString())) @@ -307,7 +307,7 @@ func (r *L3extRsRedistributePolResource) Create(ctx context.Context, req resourc var tagTagPlan, tagTagState []TagTagL3extRsRedistributePolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extRsRedistributePolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extRsRedistributePolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -372,7 +372,7 @@ func (r *L3extRsRedistributePolResource) Update(ctx context.Context, req resourc var tagTagPlan, tagTagState []TagTagL3extRsRedistributePolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extRsRedistributePolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extRsRedistributePolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -528,7 +528,7 @@ func setL3extRsRedistributePolParentDn(ctx context.Context, dn string, data *L3e data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setL3extRsRedistributePolId(ctx context.Context, data *L3extRsRedistributePolResourceModel) { +func SetL3extRsRedistributePolId(ctx context.Context, data *L3extRsRedistributePolResourceModel) { rn := getL3extRsRedistributePolRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -612,7 +612,7 @@ func getL3extRsRedistributePolTagTagChildPayloads(ctx context.Context, diags *di return childPayloads } -func getL3extRsRedistributePolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extRsRedistributePolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsRedistributePolResourceModel, tagTagPlan, tagTagState []TagTagL3extRsRedistributePolResourceModel) *container.Container { +func GetL3extRsRedistributePolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extRsRedistributePolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsRedistributePolResourceModel, tagTagPlan, tagTagState []TagTagL3extRsRedistributePolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_netflow_monitor_policy.go b/internal/provider/resource_aci_netflow_monitor_policy.go index a437ebe7e..5bdd0c920 100644 --- a/internal/provider/resource_aci_netflow_monitor_policy.go +++ b/internal/provider/resource_aci_netflow_monitor_policy.go @@ -162,7 +162,7 @@ func (r *NetflowMonitorPolResource) ModifyPlan(ctx context.Context, req resource } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setNetflowMonitorPolId(ctx, planData) + SetNetflowMonitorPolId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -404,7 +404,7 @@ func (r *NetflowMonitorPolResource) Create(ctx context.Context, req resource.Cre var stateData *NetflowMonitorPolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setNetflowMonitorPolId(ctx, stateData) + SetNetflowMonitorPolId(ctx, stateData) } getAndSetNetflowMonitorPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -425,7 +425,7 @@ func (r *NetflowMonitorPolResource) Create(ctx context.Context, req resource.Cre } if data.Id.IsUnknown() || data.Id.IsNull() { - setNetflowMonitorPolId(ctx, data) + SetNetflowMonitorPolId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_netflow_monitor_policy with id '%s'", data.Id.ValueString())) @@ -442,7 +442,7 @@ func (r *NetflowMonitorPolResource) Create(ctx context.Context, req resource.Cre var tagTagPlan, tagTagState []TagTagNetflowMonitorPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getNetflowMonitorPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowMonitorPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -513,7 +513,7 @@ func (r *NetflowMonitorPolResource) Update(ctx context.Context, req resource.Upd var tagTagPlan, tagTagState []TagTagNetflowMonitorPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getNetflowMonitorPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowMonitorPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -708,7 +708,7 @@ func setNetflowMonitorPolParentDn(ctx context.Context, dn string, data *NetflowM data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setNetflowMonitorPolId(ctx context.Context, data *NetflowMonitorPolResourceModel) { +func SetNetflowMonitorPolId(ctx context.Context, data *NetflowMonitorPolResourceModel) { rn := getNetflowMonitorPolRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -862,7 +862,7 @@ func getNetflowMonitorPolTagTagChildPayloads(ctx context.Context, diags *diag.Di return childPayloads } -func getNetflowMonitorPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *NetflowMonitorPolResourceModel, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState []NetflowRsMonitorToExporterNetflowMonitorPolResourceModel, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState []NetflowRsMonitorToRecordNetflowMonitorPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowMonitorPolResourceModel, tagTagPlan, tagTagState []TagTagNetflowMonitorPolResourceModel) *container.Container { +func GetNetflowMonitorPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *NetflowMonitorPolResourceModel, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState []NetflowRsMonitorToExporterNetflowMonitorPolResourceModel, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState []NetflowRsMonitorToRecordNetflowMonitorPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowMonitorPolResourceModel, tagTagPlan, tagTagState []TagTagNetflowMonitorPolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_netflow_record_policy.go b/internal/provider/resource_aci_netflow_record_policy.go index 68791837d..0b3c6708c 100644 --- a/internal/provider/resource_aci_netflow_record_policy.go +++ b/internal/provider/resource_aci_netflow_record_policy.go @@ -127,7 +127,7 @@ func (r *NetflowRecordPolResource) ModifyPlan(ctx context.Context, req resource. } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setNetflowRecordPolId(ctx, planData) + SetNetflowRecordPolId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -341,7 +341,7 @@ func (r *NetflowRecordPolResource) Create(ctx context.Context, req resource.Crea var stateData *NetflowRecordPolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setNetflowRecordPolId(ctx, stateData) + SetNetflowRecordPolId(ctx, stateData) } getAndSetNetflowRecordPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -362,7 +362,7 @@ func (r *NetflowRecordPolResource) Create(ctx context.Context, req resource.Crea } if data.Id.IsUnknown() || data.Id.IsNull() { - setNetflowRecordPolId(ctx, data) + SetNetflowRecordPolId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_netflow_record_policy with id '%s'", data.Id.ValueString())) @@ -373,7 +373,7 @@ func (r *NetflowRecordPolResource) Create(ctx context.Context, req resource.Crea var tagTagPlan, tagTagState []TagTagNetflowRecordPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getNetflowRecordPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowRecordPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -438,7 +438,7 @@ func (r *NetflowRecordPolResource) Update(ctx context.Context, req resource.Upda var tagTagPlan, tagTagState []TagTagNetflowRecordPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getNetflowRecordPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowRecordPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -619,7 +619,7 @@ func setNetflowRecordPolParentDn(ctx context.Context, dn string, data *NetflowRe data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setNetflowRecordPolId(ctx context.Context, data *NetflowRecordPolResourceModel) { +func SetNetflowRecordPolId(ctx context.Context, data *NetflowRecordPolResourceModel) { rn := getNetflowRecordPolRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -703,7 +703,7 @@ func getNetflowRecordPolTagTagChildPayloads(ctx context.Context, diags *diag.Dia return childPayloads } -func getNetflowRecordPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *NetflowRecordPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowRecordPolResourceModel, tagTagPlan, tagTagState []TagTagNetflowRecordPolResourceModel) *container.Container { +func GetNetflowRecordPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *NetflowRecordPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowRecordPolResourceModel, tagTagPlan, tagTagState []TagTagNetflowRecordPolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_out_of_band_contract.go b/internal/provider/resource_aci_out_of_band_contract.go index d2dd35512..002ea5faf 100644 --- a/internal/provider/resource_aci_out_of_band_contract.go +++ b/internal/provider/resource_aci_out_of_band_contract.go @@ -128,7 +128,7 @@ func (r *VzOOBBrCPResource) ModifyPlan(ctx context.Context, req resource.ModifyP } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.Name.IsUnknown() { - setVzOOBBrCPId(ctx, planData) + SetVzOOBBrCPId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -350,7 +350,7 @@ func (r *VzOOBBrCPResource) Create(ctx context.Context, req resource.CreateReque var stateData *VzOOBBrCPResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setVzOOBBrCPId(ctx, stateData) + SetVzOOBBrCPId(ctx, stateData) } getAndSetVzOOBBrCPAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -371,7 +371,7 @@ func (r *VzOOBBrCPResource) Create(ctx context.Context, req resource.CreateReque } if data.Id.IsUnknown() || data.Id.IsNull() { - setVzOOBBrCPId(ctx, data) + SetVzOOBBrCPId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_out_of_band_contract with id '%s'", data.Id.ValueString())) @@ -382,7 +382,7 @@ func (r *VzOOBBrCPResource) Create(ctx context.Context, req resource.CreateReque var tagTagPlan, tagTagState []TagTagVzOOBBrCPResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getVzOOBBrCPCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetVzOOBBrCPCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -447,7 +447,7 @@ func (r *VzOOBBrCPResource) Update(ctx context.Context, req resource.UpdateReque var tagTagPlan, tagTagState []TagTagVzOOBBrCPResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getVzOOBBrCPCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetVzOOBBrCPCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -607,7 +607,7 @@ func getVzOOBBrCPRn(ctx context.Context, data *VzOOBBrCPResourceModel) string { return rn } -func setVzOOBBrCPId(ctx context.Context, data *VzOOBBrCPResourceModel) { +func SetVzOOBBrCPId(ctx context.Context, data *VzOOBBrCPResourceModel) { rn := getVzOOBBrCPRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", strings.Split([]string{"uni/tn-mgmt/oobbrc-{name}"}[0], "/")[0], rn)) } @@ -691,7 +691,7 @@ func getVzOOBBrCPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getVzOOBBrCPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *VzOOBBrCPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationVzOOBBrCPResourceModel, tagTagPlan, tagTagState []TagTagVzOOBBrCPResourceModel) *container.Container { +func GetVzOOBBrCPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *VzOOBBrCPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationVzOOBBrCPResourceModel, tagTagPlan, tagTagState []TagTagVzOOBBrCPResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_pim_route_map_entry.go b/internal/provider/resource_aci_pim_route_map_entry.go index 8f7a243f4..4d80d6100 100644 --- a/internal/provider/resource_aci_pim_route_map_entry.go +++ b/internal/provider/resource_aci_pim_route_map_entry.go @@ -128,7 +128,7 @@ func (r *PimRouteMapEntryResource) ModifyPlan(ctx context.Context, req resource. } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Order.IsUnknown() { - setPimRouteMapEntryId(ctx, planData) + SetPimRouteMapEntryId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -340,7 +340,7 @@ func (r *PimRouteMapEntryResource) Create(ctx context.Context, req resource.Crea var stateData *PimRouteMapEntryResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setPimRouteMapEntryId(ctx, stateData) + SetPimRouteMapEntryId(ctx, stateData) } getAndSetPimRouteMapEntryAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -361,7 +361,7 @@ func (r *PimRouteMapEntryResource) Create(ctx context.Context, req resource.Crea } if data.Id.IsUnknown() || data.Id.IsNull() { - setPimRouteMapEntryId(ctx, data) + SetPimRouteMapEntryId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_pim_route_map_entry with id '%s'", data.Id.ValueString())) @@ -372,7 +372,7 @@ func (r *PimRouteMapEntryResource) Create(ctx context.Context, req resource.Crea var tagTagPlan, tagTagState []TagTagPimRouteMapEntryResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getPimRouteMapEntryCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetPimRouteMapEntryCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -437,7 +437,7 @@ func (r *PimRouteMapEntryResource) Update(ctx context.Context, req resource.Upda var tagTagPlan, tagTagState []TagTagPimRouteMapEntryResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getPimRouteMapEntryCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetPimRouteMapEntryCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -611,7 +611,7 @@ func setPimRouteMapEntryParentDn(ctx context.Context, dn string, data *PimRouteM data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setPimRouteMapEntryId(ctx context.Context, data *PimRouteMapEntryResourceModel) { +func SetPimRouteMapEntryId(ctx context.Context, data *PimRouteMapEntryResourceModel) { rn := getPimRouteMapEntryRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -695,7 +695,7 @@ func getPimRouteMapEntryTagTagChildPayloads(ctx context.Context, diags *diag.Dia return childPayloads } -func getPimRouteMapEntryCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *PimRouteMapEntryResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPimRouteMapEntryResourceModel, tagTagPlan, tagTagState []TagTagPimRouteMapEntryResourceModel) *container.Container { +func GetPimRouteMapEntryCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *PimRouteMapEntryResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPimRouteMapEntryResourceModel, tagTagPlan, tagTagState []TagTagPimRouteMapEntryResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_pim_route_map_policy.go b/internal/provider/resource_aci_pim_route_map_policy.go index eeedc889e..62f685ec7 100644 --- a/internal/provider/resource_aci_pim_route_map_policy.go +++ b/internal/provider/resource_aci_pim_route_map_policy.go @@ -120,7 +120,7 @@ func (r *PimRouteMapPolResource) ModifyPlan(ctx context.Context, req resource.Mo } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setPimRouteMapPolId(ctx, planData) + SetPimRouteMapPolId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -302,7 +302,7 @@ func (r *PimRouteMapPolResource) Create(ctx context.Context, req resource.Create var stateData *PimRouteMapPolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setPimRouteMapPolId(ctx, stateData) + SetPimRouteMapPolId(ctx, stateData) } getAndSetPimRouteMapPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -323,7 +323,7 @@ func (r *PimRouteMapPolResource) Create(ctx context.Context, req resource.Create } if data.Id.IsUnknown() || data.Id.IsNull() { - setPimRouteMapPolId(ctx, data) + SetPimRouteMapPolId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_pim_route_map_policy with id '%s'", data.Id.ValueString())) @@ -334,7 +334,7 @@ func (r *PimRouteMapPolResource) Create(ctx context.Context, req resource.Create var tagTagPlan, tagTagState []TagTagPimRouteMapPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getPimRouteMapPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetPimRouteMapPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -399,7 +399,7 @@ func (r *PimRouteMapPolResource) Update(ctx context.Context, req resource.Update var tagTagPlan, tagTagState []TagTagPimRouteMapPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getPimRouteMapPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetPimRouteMapPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -564,7 +564,7 @@ func setPimRouteMapPolParentDn(ctx context.Context, dn string, data *PimRouteMap data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setPimRouteMapPolId(ctx context.Context, data *PimRouteMapPolResourceModel) { +func SetPimRouteMapPolId(ctx context.Context, data *PimRouteMapPolResourceModel) { rn := getPimRouteMapPolRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -648,7 +648,7 @@ func getPimRouteMapPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagn return childPayloads } -func getPimRouteMapPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *PimRouteMapPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPimRouteMapPolResourceModel, tagTagPlan, tagTagState []TagTagPimRouteMapPolResourceModel) *container.Container { +func GetPimRouteMapPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *PimRouteMapPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPimRouteMapPolResourceModel, tagTagPlan, tagTagState []TagTagPimRouteMapPolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_consumed_contract.go b/internal/provider/resource_aci_relation_to_consumed_contract.go index 908ca446e..d2172b8ec 100644 --- a/internal/provider/resource_aci_relation_to_consumed_contract.go +++ b/internal/provider/resource_aci_relation_to_consumed_contract.go @@ -116,7 +116,7 @@ func (r *FvRsConsResource) ModifyPlan(ctx context.Context, req resource.ModifyPl } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TnVzBrCPName.IsUnknown() { - setFvRsConsId(ctx, planData) + SetFvRsConsId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -274,7 +274,7 @@ func (r *FvRsConsResource) Create(ctx context.Context, req resource.CreateReques var stateData *FvRsConsResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsConsId(ctx, stateData) + SetFvRsConsId(ctx, stateData) } getAndSetFvRsConsAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -295,7 +295,7 @@ func (r *FvRsConsResource) Create(ctx context.Context, req resource.CreateReques } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsConsId(ctx, data) + SetFvRsConsId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_consumed_contract with id '%s'", data.Id.ValueString())) @@ -306,7 +306,7 @@ func (r *FvRsConsResource) Create(ctx context.Context, req resource.CreateReques var tagTagPlan, tagTagState []TagTagFvRsConsResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsConsCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsConsCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -371,7 +371,7 @@ func (r *FvRsConsResource) Update(ctx context.Context, req resource.UpdateReques var tagTagPlan, tagTagState []TagTagFvRsConsResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsConsCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsConsCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -527,7 +527,7 @@ func setFvRsConsParentDn(ctx context.Context, dn string, data *FvRsConsResourceM data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsConsId(ctx context.Context, data *FvRsConsResourceModel) { +func SetFvRsConsId(ctx context.Context, data *FvRsConsResourceModel) { rn := getFvRsConsRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -611,7 +611,7 @@ func getFvRsConsTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics return childPayloads } -func getFvRsConsCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsConsResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsConsResourceModel, tagTagPlan, tagTagState []TagTagFvRsConsResourceModel) *container.Container { +func GetFvRsConsCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsConsResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsConsResourceModel, tagTagPlan, tagTagState []TagTagFvRsConsResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go b/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go index 44c0fdcba..1bb370a72 100644 --- a/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go +++ b/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go @@ -116,7 +116,7 @@ func (r *MgmtRsOoBConsResource) ModifyPlan(ctx context.Context, req resource.Mod } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TnVzOOBBrCPName.IsUnknown() { - setMgmtRsOoBConsId(ctx, planData) + SetMgmtRsOoBConsId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -274,7 +274,7 @@ func (r *MgmtRsOoBConsResource) Create(ctx context.Context, req resource.CreateR var stateData *MgmtRsOoBConsResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setMgmtRsOoBConsId(ctx, stateData) + SetMgmtRsOoBConsId(ctx, stateData) } getAndSetMgmtRsOoBConsAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -295,7 +295,7 @@ func (r *MgmtRsOoBConsResource) Create(ctx context.Context, req resource.CreateR } if data.Id.IsUnknown() || data.Id.IsNull() { - setMgmtRsOoBConsId(ctx, data) + SetMgmtRsOoBConsId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_consumed_out_of_band_contract with id '%s'", data.Id.ValueString())) @@ -306,7 +306,7 @@ func (r *MgmtRsOoBConsResource) Create(ctx context.Context, req resource.CreateR var tagTagPlan, tagTagState []TagTagMgmtRsOoBConsResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getMgmtRsOoBConsCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtRsOoBConsCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -371,7 +371,7 @@ func (r *MgmtRsOoBConsResource) Update(ctx context.Context, req resource.UpdateR var tagTagPlan, tagTagState []TagTagMgmtRsOoBConsResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getMgmtRsOoBConsCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtRsOoBConsCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -527,7 +527,7 @@ func setMgmtRsOoBConsParentDn(ctx context.Context, dn string, data *MgmtRsOoBCon data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setMgmtRsOoBConsId(ctx context.Context, data *MgmtRsOoBConsResourceModel) { +func SetMgmtRsOoBConsId(ctx context.Context, data *MgmtRsOoBConsResourceModel) { rn := getMgmtRsOoBConsRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -611,7 +611,7 @@ func getMgmtRsOoBConsTagTagChildPayloads(ctx context.Context, diags *diag.Diagno return childPayloads } -func getMgmtRsOoBConsCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *MgmtRsOoBConsResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtRsOoBConsResourceModel, tagTagPlan, tagTagState []TagTagMgmtRsOoBConsResourceModel) *container.Container { +func GetMgmtRsOoBConsCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *MgmtRsOoBConsResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtRsOoBConsResourceModel, tagTagPlan, tagTagState []TagTagMgmtRsOoBConsResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_contract_master.go b/internal/provider/resource_aci_relation_to_contract_master.go index 60e5eb3da..3218c18ae 100644 --- a/internal/provider/resource_aci_relation_to_contract_master.go +++ b/internal/provider/resource_aci_relation_to_contract_master.go @@ -112,7 +112,7 @@ func (r *FvRsSecInheritedResource) ModifyPlan(ctx context.Context, req resource. } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { - setFvRsSecInheritedId(ctx, planData) + SetFvRsSecInheritedId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -258,7 +258,7 @@ func (r *FvRsSecInheritedResource) Create(ctx context.Context, req resource.Crea var stateData *FvRsSecInheritedResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsSecInheritedId(ctx, stateData) + SetFvRsSecInheritedId(ctx, stateData) } getAndSetFvRsSecInheritedAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -279,7 +279,7 @@ func (r *FvRsSecInheritedResource) Create(ctx context.Context, req resource.Crea } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsSecInheritedId(ctx, data) + SetFvRsSecInheritedId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_contract_master with id '%s'", data.Id.ValueString())) @@ -290,7 +290,7 @@ func (r *FvRsSecInheritedResource) Create(ctx context.Context, req resource.Crea var tagTagPlan, tagTagState []TagTagFvRsSecInheritedResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsSecInheritedCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsSecInheritedCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -355,7 +355,7 @@ func (r *FvRsSecInheritedResource) Update(ctx context.Context, req resource.Upda var tagTagPlan, tagTagState []TagTagFvRsSecInheritedResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsSecInheritedCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsSecInheritedCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -508,7 +508,7 @@ func setFvRsSecInheritedParentDn(ctx context.Context, dn string, data *FvRsSecIn data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsSecInheritedId(ctx context.Context, data *FvRsSecInheritedResourceModel) { +func SetFvRsSecInheritedId(ctx context.Context, data *FvRsSecInheritedResourceModel) { rn := getFvRsSecInheritedRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -592,7 +592,7 @@ func getFvRsSecInheritedTagTagChildPayloads(ctx context.Context, diags *diag.Dia return childPayloads } -func getFvRsSecInheritedCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsSecInheritedResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsSecInheritedResourceModel, tagTagPlan, tagTagState []TagTagFvRsSecInheritedResourceModel) *container.Container { +func GetFvRsSecInheritedCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsSecInheritedResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsSecInheritedResourceModel, tagTagPlan, tagTagState []TagTagFvRsSecInheritedResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_domain.go b/internal/provider/resource_aci_relation_to_domain.go index 0aef9ea28..0ee2eb3e4 100644 --- a/internal/provider/resource_aci_relation_to_domain.go +++ b/internal/provider/resource_aci_relation_to_domain.go @@ -162,7 +162,7 @@ func (r *FvRsDomAttResource) ModifyPlan(ctx context.Context, req resource.Modify } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { - setFvRsDomAttId(ctx, planData) + SetFvRsDomAttId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -567,7 +567,7 @@ func (r *FvRsDomAttResource) Create(ctx context.Context, req resource.CreateRequ var stateData *FvRsDomAttResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsDomAttId(ctx, stateData) + SetFvRsDomAttId(ctx, stateData) } getAndSetFvRsDomAttAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -588,7 +588,7 @@ func (r *FvRsDomAttResource) Create(ctx context.Context, req resource.CreateRequ } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsDomAttId(ctx, data) + SetFvRsDomAttId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_domain with id '%s'", data.Id.ValueString())) @@ -599,7 +599,7 @@ func (r *FvRsDomAttResource) Create(ctx context.Context, req resource.CreateRequ var tagTagPlan, tagTagState []TagTagFvRsDomAttResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsDomAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsDomAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -664,7 +664,7 @@ func (r *FvRsDomAttResource) Update(ctx context.Context, req resource.UpdateRequ var tagTagPlan, tagTagState []TagTagFvRsDomAttResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsDomAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsDomAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -893,7 +893,7 @@ func setFvRsDomAttParentDn(ctx context.Context, dn string, data *FvRsDomAttResou data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsDomAttId(ctx context.Context, data *FvRsDomAttResourceModel) { +func SetFvRsDomAttId(ctx context.Context, data *FvRsDomAttResourceModel) { rn := getFvRsDomAttRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -977,7 +977,7 @@ func getFvRsDomAttTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getFvRsDomAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsDomAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsDomAttResourceModel, tagTagPlan, tagTagState []TagTagFvRsDomAttResourceModel) *container.Container { +func GetFvRsDomAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsDomAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsDomAttResourceModel, tagTagPlan, tagTagState []TagTagFvRsDomAttResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_fibre_channel_path.go b/internal/provider/resource_aci_relation_to_fibre_channel_path.go index c0f7580df..47a54d1e6 100644 --- a/internal/provider/resource_aci_relation_to_fibre_channel_path.go +++ b/internal/provider/resource_aci_relation_to_fibre_channel_path.go @@ -120,7 +120,7 @@ func (r *FvRsFcPathAttResource) ModifyPlan(ctx context.Context, req resource.Mod } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { - setFvRsFcPathAttId(ctx, planData) + SetFvRsFcPathAttId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -296,7 +296,7 @@ func (r *FvRsFcPathAttResource) Create(ctx context.Context, req resource.CreateR var stateData *FvRsFcPathAttResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsFcPathAttId(ctx, stateData) + SetFvRsFcPathAttId(ctx, stateData) } getAndSetFvRsFcPathAttAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -317,7 +317,7 @@ func (r *FvRsFcPathAttResource) Create(ctx context.Context, req resource.CreateR } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsFcPathAttId(ctx, data) + SetFvRsFcPathAttId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_fibre_channel_path with id '%s'", data.Id.ValueString())) @@ -328,7 +328,7 @@ func (r *FvRsFcPathAttResource) Create(ctx context.Context, req resource.CreateR var tagTagPlan, tagTagState []TagTagFvRsFcPathAttResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsFcPathAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsFcPathAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -393,7 +393,7 @@ func (r *FvRsFcPathAttResource) Update(ctx context.Context, req resource.UpdateR var tagTagPlan, tagTagState []TagTagFvRsFcPathAttResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsFcPathAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsFcPathAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -555,7 +555,7 @@ func setFvRsFcPathAttParentDn(ctx context.Context, dn string, data *FvRsFcPathAt data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsFcPathAttId(ctx context.Context, data *FvRsFcPathAttResourceModel) { +func SetFvRsFcPathAttId(ctx context.Context, data *FvRsFcPathAttResourceModel) { rn := getFvRsFcPathAttRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -639,7 +639,7 @@ func getFvRsFcPathAttTagTagChildPayloads(ctx context.Context, diags *diag.Diagno return childPayloads } -func getFvRsFcPathAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsFcPathAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsFcPathAttResourceModel, tagTagPlan, tagTagState []TagTagFvRsFcPathAttResourceModel) *container.Container { +func GetFvRsFcPathAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsFcPathAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsFcPathAttResourceModel, tagTagPlan, tagTagState []TagTagFvRsFcPathAttResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_imported_contract.go b/internal/provider/resource_aci_relation_to_imported_contract.go index 9c78ee9da..15517e0c7 100644 --- a/internal/provider/resource_aci_relation_to_imported_contract.go +++ b/internal/provider/resource_aci_relation_to_imported_contract.go @@ -116,7 +116,7 @@ func (r *FvRsConsIfResource) ModifyPlan(ctx context.Context, req resource.Modify } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TnVzCPIfName.IsUnknown() { - setFvRsConsIfId(ctx, planData) + SetFvRsConsIfId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -274,7 +274,7 @@ func (r *FvRsConsIfResource) Create(ctx context.Context, req resource.CreateRequ var stateData *FvRsConsIfResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsConsIfId(ctx, stateData) + SetFvRsConsIfId(ctx, stateData) } getAndSetFvRsConsIfAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -295,7 +295,7 @@ func (r *FvRsConsIfResource) Create(ctx context.Context, req resource.CreateRequ } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsConsIfId(ctx, data) + SetFvRsConsIfId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_imported_contract with id '%s'", data.Id.ValueString())) @@ -306,7 +306,7 @@ func (r *FvRsConsIfResource) Create(ctx context.Context, req resource.CreateRequ var tagTagPlan, tagTagState []TagTagFvRsConsIfResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsConsIfCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsConsIfCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -371,7 +371,7 @@ func (r *FvRsConsIfResource) Update(ctx context.Context, req resource.UpdateRequ var tagTagPlan, tagTagState []TagTagFvRsConsIfResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsConsIfCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsConsIfCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -527,7 +527,7 @@ func setFvRsConsIfParentDn(ctx context.Context, dn string, data *FvRsConsIfResou data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsConsIfId(ctx context.Context, data *FvRsConsIfResourceModel) { +func SetFvRsConsIfId(ctx context.Context, data *FvRsConsIfResourceModel) { rn := getFvRsConsIfRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -611,7 +611,7 @@ func getFvRsConsIfTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getFvRsConsIfCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsConsIfResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsConsIfResourceModel, tagTagPlan, tagTagState []TagTagFvRsConsIfResourceModel) *container.Container { +func GetFvRsConsIfCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsConsIfResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsConsIfResourceModel, tagTagPlan, tagTagState []TagTagFvRsConsIfResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_intra_epg_contract.go b/internal/provider/resource_aci_relation_to_intra_epg_contract.go index 159fc250f..7921e6f5d 100644 --- a/internal/provider/resource_aci_relation_to_intra_epg_contract.go +++ b/internal/provider/resource_aci_relation_to_intra_epg_contract.go @@ -112,7 +112,7 @@ func (r *FvRsIntraEpgResource) ModifyPlan(ctx context.Context, req resource.Modi } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TnVzBrCPName.IsUnknown() { - setFvRsIntraEpgId(ctx, planData) + SetFvRsIntraEpgId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -258,7 +258,7 @@ func (r *FvRsIntraEpgResource) Create(ctx context.Context, req resource.CreateRe var stateData *FvRsIntraEpgResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsIntraEpgId(ctx, stateData) + SetFvRsIntraEpgId(ctx, stateData) } getAndSetFvRsIntraEpgAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -279,7 +279,7 @@ func (r *FvRsIntraEpgResource) Create(ctx context.Context, req resource.CreateRe } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsIntraEpgId(ctx, data) + SetFvRsIntraEpgId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_intra_epg_contract with id '%s'", data.Id.ValueString())) @@ -290,7 +290,7 @@ func (r *FvRsIntraEpgResource) Create(ctx context.Context, req resource.CreateRe var tagTagPlan, tagTagState []TagTagFvRsIntraEpgResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsIntraEpgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsIntraEpgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -355,7 +355,7 @@ func (r *FvRsIntraEpgResource) Update(ctx context.Context, req resource.UpdateRe var tagTagPlan, tagTagState []TagTagFvRsIntraEpgResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsIntraEpgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsIntraEpgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -508,7 +508,7 @@ func setFvRsIntraEpgParentDn(ctx context.Context, dn string, data *FvRsIntraEpgR data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsIntraEpgId(ctx context.Context, data *FvRsIntraEpgResourceModel) { +func SetFvRsIntraEpgId(ctx context.Context, data *FvRsIntraEpgResourceModel) { rn := getFvRsIntraEpgRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -592,7 +592,7 @@ func getFvRsIntraEpgTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getFvRsIntraEpgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsIntraEpgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsIntraEpgResourceModel, tagTagPlan, tagTagState []TagTagFvRsIntraEpgResourceModel) *container.Container { +func GetFvRsIntraEpgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsIntraEpgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsIntraEpgResourceModel, tagTagPlan, tagTagState []TagTagFvRsIntraEpgResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_netflow_exporter.go b/internal/provider/resource_aci_relation_to_netflow_exporter.go index 00b84a3fb..1cd0abb8c 100644 --- a/internal/provider/resource_aci_relation_to_netflow_exporter.go +++ b/internal/provider/resource_aci_relation_to_netflow_exporter.go @@ -112,7 +112,7 @@ func (r *NetflowRsMonitorToExporterResource) ModifyPlan(ctx context.Context, req } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TnNetflowExporterPolName.IsUnknown() { - setNetflowRsMonitorToExporterId(ctx, planData) + SetNetflowRsMonitorToExporterId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -258,7 +258,7 @@ func (r *NetflowRsMonitorToExporterResource) Create(ctx context.Context, req res var stateData *NetflowRsMonitorToExporterResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setNetflowRsMonitorToExporterId(ctx, stateData) + SetNetflowRsMonitorToExporterId(ctx, stateData) } getAndSetNetflowRsMonitorToExporterAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -279,7 +279,7 @@ func (r *NetflowRsMonitorToExporterResource) Create(ctx context.Context, req res } if data.Id.IsUnknown() || data.Id.IsNull() { - setNetflowRsMonitorToExporterId(ctx, data) + SetNetflowRsMonitorToExporterId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_netflow_exporter with id '%s'", data.Id.ValueString())) @@ -290,7 +290,7 @@ func (r *NetflowRsMonitorToExporterResource) Create(ctx context.Context, req res var tagTagPlan, tagTagState []TagTagNetflowRsMonitorToExporterResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getNetflowRsMonitorToExporterCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowRsMonitorToExporterCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -355,7 +355,7 @@ func (r *NetflowRsMonitorToExporterResource) Update(ctx context.Context, req res var tagTagPlan, tagTagState []TagTagNetflowRsMonitorToExporterResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getNetflowRsMonitorToExporterCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowRsMonitorToExporterCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -508,7 +508,7 @@ func setNetflowRsMonitorToExporterParentDn(ctx context.Context, dn string, data data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setNetflowRsMonitorToExporterId(ctx context.Context, data *NetflowRsMonitorToExporterResourceModel) { +func SetNetflowRsMonitorToExporterId(ctx context.Context, data *NetflowRsMonitorToExporterResourceModel) { rn := getNetflowRsMonitorToExporterRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -592,7 +592,7 @@ func getNetflowRsMonitorToExporterTagTagChildPayloads(ctx context.Context, diags return childPayloads } -func getNetflowRsMonitorToExporterCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *NetflowRsMonitorToExporterResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowRsMonitorToExporterResourceModel, tagTagPlan, tagTagState []TagTagNetflowRsMonitorToExporterResourceModel) *container.Container { +func GetNetflowRsMonitorToExporterCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *NetflowRsMonitorToExporterResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowRsMonitorToExporterResourceModel, tagTagPlan, tagTagState []TagTagNetflowRsMonitorToExporterResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_provided_contract.go b/internal/provider/resource_aci_relation_to_provided_contract.go index 020dae4e6..cd66ff455 100644 --- a/internal/provider/resource_aci_relation_to_provided_contract.go +++ b/internal/provider/resource_aci_relation_to_provided_contract.go @@ -118,7 +118,7 @@ func (r *FvRsProvResource) ModifyPlan(ctx context.Context, req resource.ModifyPl } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TnVzBrCPName.IsUnknown() { - setFvRsProvId(ctx, planData) + SetFvRsProvId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -288,7 +288,7 @@ func (r *FvRsProvResource) Create(ctx context.Context, req resource.CreateReques var stateData *FvRsProvResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsProvId(ctx, stateData) + SetFvRsProvId(ctx, stateData) } getAndSetFvRsProvAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -309,7 +309,7 @@ func (r *FvRsProvResource) Create(ctx context.Context, req resource.CreateReques } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsProvId(ctx, data) + SetFvRsProvId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_provided_contract with id '%s'", data.Id.ValueString())) @@ -320,7 +320,7 @@ func (r *FvRsProvResource) Create(ctx context.Context, req resource.CreateReques var tagTagPlan, tagTagState []TagTagFvRsProvResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsProvCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsProvCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -385,7 +385,7 @@ func (r *FvRsProvResource) Update(ctx context.Context, req resource.UpdateReques var tagTagPlan, tagTagState []TagTagFvRsProvResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsProvCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsProvCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -544,7 +544,7 @@ func setFvRsProvParentDn(ctx context.Context, dn string, data *FvRsProvResourceM data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsProvId(ctx context.Context, data *FvRsProvResourceModel) { +func SetFvRsProvId(ctx context.Context, data *FvRsProvResourceModel) { rn := getFvRsProvRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -628,7 +628,7 @@ func getFvRsProvTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics return childPayloads } -func getFvRsProvCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsProvResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsProvResourceModel, tagTagPlan, tagTagState []TagTagFvRsProvResourceModel) *container.Container { +func GetFvRsProvCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsProvResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsProvResourceModel, tagTagPlan, tagTagState []TagTagFvRsProvResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_static_leaf.go b/internal/provider/resource_aci_relation_to_static_leaf.go index a46ee4af4..a9ad3f90e 100644 --- a/internal/provider/resource_aci_relation_to_static_leaf.go +++ b/internal/provider/resource_aci_relation_to_static_leaf.go @@ -122,7 +122,7 @@ func (r *FvRsNodeAttResource) ModifyPlan(ctx context.Context, req resource.Modif } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { - setFvRsNodeAttId(ctx, planData) + SetFvRsNodeAttId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -309,7 +309,7 @@ func (r *FvRsNodeAttResource) Create(ctx context.Context, req resource.CreateReq var stateData *FvRsNodeAttResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsNodeAttId(ctx, stateData) + SetFvRsNodeAttId(ctx, stateData) } getAndSetFvRsNodeAttAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -330,7 +330,7 @@ func (r *FvRsNodeAttResource) Create(ctx context.Context, req resource.CreateReq } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsNodeAttId(ctx, data) + SetFvRsNodeAttId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_static_leaf with id '%s'", data.Id.ValueString())) @@ -341,7 +341,7 @@ func (r *FvRsNodeAttResource) Create(ctx context.Context, req resource.CreateReq var tagTagPlan, tagTagState []TagTagFvRsNodeAttResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsNodeAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsNodeAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -406,7 +406,7 @@ func (r *FvRsNodeAttResource) Update(ctx context.Context, req resource.UpdateReq var tagTagPlan, tagTagState []TagTagFvRsNodeAttResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsNodeAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsNodeAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -571,7 +571,7 @@ func setFvRsNodeAttParentDn(ctx context.Context, dn string, data *FvRsNodeAttRes data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsNodeAttId(ctx context.Context, data *FvRsNodeAttResourceModel) { +func SetFvRsNodeAttId(ctx context.Context, data *FvRsNodeAttResourceModel) { rn := getFvRsNodeAttRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -655,7 +655,7 @@ func getFvRsNodeAttTagTagChildPayloads(ctx context.Context, diags *diag.Diagnost return childPayloads } -func getFvRsNodeAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsNodeAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsNodeAttResourceModel, tagTagPlan, tagTagState []TagTagFvRsNodeAttResourceModel) *container.Container { +func GetFvRsNodeAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsNodeAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsNodeAttResourceModel, tagTagPlan, tagTagState []TagTagFvRsNodeAttResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_static_path.go b/internal/provider/resource_aci_relation_to_static_path.go index 0e99bd3e7..2b6a965e5 100644 --- a/internal/provider/resource_aci_relation_to_static_path.go +++ b/internal/provider/resource_aci_relation_to_static_path.go @@ -124,7 +124,7 @@ func (r *FvRsPathAttResource) ModifyPlan(ctx context.Context, req resource.Modif } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { - setFvRsPathAttId(ctx, planData) + SetFvRsPathAttId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -320,7 +320,7 @@ func (r *FvRsPathAttResource) Create(ctx context.Context, req resource.CreateReq var stateData *FvRsPathAttResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsPathAttId(ctx, stateData) + SetFvRsPathAttId(ctx, stateData) } getAndSetFvRsPathAttAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -341,7 +341,7 @@ func (r *FvRsPathAttResource) Create(ctx context.Context, req resource.CreateReq } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsPathAttId(ctx, data) + SetFvRsPathAttId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_static_path with id '%s'", data.Id.ValueString())) @@ -352,7 +352,7 @@ func (r *FvRsPathAttResource) Create(ctx context.Context, req resource.CreateReq var tagTagPlan, tagTagState []TagTagFvRsPathAttResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsPathAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsPathAttCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -417,7 +417,7 @@ func (r *FvRsPathAttResource) Update(ctx context.Context, req resource.UpdateReq var tagTagPlan, tagTagState []TagTagFvRsPathAttResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsPathAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsPathAttCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -585,7 +585,7 @@ func setFvRsPathAttParentDn(ctx context.Context, dn string, data *FvRsPathAttRes data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsPathAttId(ctx context.Context, data *FvRsPathAttResourceModel) { +func SetFvRsPathAttId(ctx context.Context, data *FvRsPathAttResourceModel) { rn := getFvRsPathAttRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -669,7 +669,7 @@ func getFvRsPathAttTagTagChildPayloads(ctx context.Context, diags *diag.Diagnost return childPayloads } -func getFvRsPathAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsPathAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsPathAttResourceModel, tagTagPlan, tagTagState []TagTagFvRsPathAttResourceModel) *container.Container { +func GetFvRsPathAttCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsPathAttResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsPathAttResourceModel, tagTagPlan, tagTagState []TagTagFvRsPathAttResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_taboo_contract.go b/internal/provider/resource_aci_relation_to_taboo_contract.go index e1faf9691..599fc2cc6 100644 --- a/internal/provider/resource_aci_relation_to_taboo_contract.go +++ b/internal/provider/resource_aci_relation_to_taboo_contract.go @@ -112,7 +112,7 @@ func (r *FvRsProtByResource) ModifyPlan(ctx context.Context, req resource.Modify } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TnVzTabooName.IsUnknown() { - setFvRsProtById(ctx, planData) + SetFvRsProtById(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -258,7 +258,7 @@ func (r *FvRsProtByResource) Create(ctx context.Context, req resource.CreateRequ var stateData *FvRsProtByResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvRsProtById(ctx, stateData) + SetFvRsProtById(ctx, stateData) } getAndSetFvRsProtByAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -279,7 +279,7 @@ func (r *FvRsProtByResource) Create(ctx context.Context, req resource.CreateRequ } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvRsProtById(ctx, data) + SetFvRsProtById(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_taboo_contract with id '%s'", data.Id.ValueString())) @@ -290,7 +290,7 @@ func (r *FvRsProtByResource) Create(ctx context.Context, req resource.CreateRequ var tagTagPlan, tagTagState []TagTagFvRsProtByResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsProtByCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsProtByCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -355,7 +355,7 @@ func (r *FvRsProtByResource) Update(ctx context.Context, req resource.UpdateRequ var tagTagPlan, tagTagState []TagTagFvRsProtByResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvRsProtByCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvRsProtByCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -508,7 +508,7 @@ func setFvRsProtByParentDn(ctx context.Context, dn string, data *FvRsProtByResou data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvRsProtById(ctx context.Context, data *FvRsProtByResourceModel) { +func SetFvRsProtById(ctx context.Context, data *FvRsProtByResourceModel) { rn := getFvRsProtByRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -592,7 +592,7 @@ func getFvRsProtByTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getFvRsProtByCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsProtByResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsProtByResourceModel, tagTagPlan, tagTagState []TagTagFvRsProtByResourceModel) *container.Container { +func GetFvRsProtByCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvRsProtByResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvRsProtByResourceModel, tagTagPlan, tagTagState []TagTagFvRsProtByResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go index 4a76b2499..88fd83809 100644 --- a/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go +++ b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go @@ -112,7 +112,7 @@ func (r *L3extRsOutToFBRGroupResource) ModifyPlan(ctx context.Context, req resou } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.TDn.IsUnknown() { - setL3extRsOutToFBRGroupId(ctx, planData) + SetL3extRsOutToFBRGroupId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -258,7 +258,7 @@ func (r *L3extRsOutToFBRGroupResource) Create(ctx context.Context, req resource. var stateData *L3extRsOutToFBRGroupResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setL3extRsOutToFBRGroupId(ctx, stateData) + SetL3extRsOutToFBRGroupId(ctx, stateData) } getAndSetL3extRsOutToFBRGroupAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -279,7 +279,7 @@ func (r *L3extRsOutToFBRGroupResource) Create(ctx context.Context, req resource. } if data.Id.IsUnknown() || data.Id.IsNull() { - setL3extRsOutToFBRGroupId(ctx, data) + SetL3extRsOutToFBRGroupId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) @@ -290,7 +290,7 @@ func (r *L3extRsOutToFBRGroupResource) Create(ctx context.Context, req resource. var tagTagPlan, tagTagState []TagTagL3extRsOutToFBRGroupResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extRsOutToFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extRsOutToFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -355,7 +355,7 @@ func (r *L3extRsOutToFBRGroupResource) Update(ctx context.Context, req resource. var tagTagPlan, tagTagState []TagTagL3extRsOutToFBRGroupResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getL3extRsOutToFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extRsOutToFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -508,7 +508,7 @@ func setL3extRsOutToFBRGroupParentDn(ctx context.Context, dn string, data *L3ext data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setL3extRsOutToFBRGroupId(ctx context.Context, data *L3extRsOutToFBRGroupResourceModel) { +func SetL3extRsOutToFBRGroupId(ctx context.Context, data *L3extRsOutToFBRGroupResourceModel) { rn := getL3extRsOutToFBRGroupRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -592,7 +592,7 @@ func getL3extRsOutToFBRGroupTagTagChildPayloads(ctx context.Context, diags *diag return childPayloads } -func getL3extRsOutToFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extRsOutToFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsOutToFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagL3extRsOutToFBRGroupResourceModel) *container.Container { +func GetL3extRsOutToFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *L3extRsOutToFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsOutToFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagL3extRsOutToFBRGroupResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_route_control_profile.go b/internal/provider/resource_aci_route_control_profile.go index 76c6892d4..21ce74b97 100644 --- a/internal/provider/resource_aci_route_control_profile.go +++ b/internal/provider/resource_aci_route_control_profile.go @@ -126,7 +126,7 @@ func (r *RtctrlProfileResource) ModifyPlan(ctx context.Context, req resource.Mod } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setRtctrlProfileId(ctx, planData) + SetRtctrlProfileId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -332,7 +332,7 @@ func (r *RtctrlProfileResource) Create(ctx context.Context, req resource.CreateR var stateData *RtctrlProfileResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setRtctrlProfileId(ctx, stateData) + SetRtctrlProfileId(ctx, stateData) } getAndSetRtctrlProfileAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -353,7 +353,7 @@ func (r *RtctrlProfileResource) Create(ctx context.Context, req resource.CreateR } if data.Id.IsUnknown() || data.Id.IsNull() { - setRtctrlProfileId(ctx, data) + SetRtctrlProfileId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_route_control_profile with id '%s'", data.Id.ValueString())) @@ -364,7 +364,7 @@ func (r *RtctrlProfileResource) Create(ctx context.Context, req resource.CreateR var tagTagPlan, tagTagState []TagTagRtctrlProfileResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getRtctrlProfileCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetRtctrlProfileCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -429,7 +429,7 @@ func (r *RtctrlProfileResource) Update(ctx context.Context, req resource.UpdateR var tagTagPlan, tagTagState []TagTagRtctrlProfileResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getRtctrlProfileCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetRtctrlProfileCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -600,7 +600,7 @@ func setRtctrlProfileParentDn(ctx context.Context, dn string, data *RtctrlProfil data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setRtctrlProfileId(ctx context.Context, data *RtctrlProfileResourceModel) { +func SetRtctrlProfileId(ctx context.Context, data *RtctrlProfileResourceModel) { rn := getRtctrlProfileRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -684,7 +684,7 @@ func getRtctrlProfileTagTagChildPayloads(ctx context.Context, diags *diag.Diagno return childPayloads } -func getRtctrlProfileCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *RtctrlProfileResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationRtctrlProfileResourceModel, tagTagPlan, tagTagState []TagTagRtctrlProfileResourceModel) *container.Container { +func GetRtctrlProfileCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *RtctrlProfileResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationRtctrlProfileResourceModel, tagTagPlan, tagTagState []TagTagRtctrlProfileResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_tag.go b/internal/provider/resource_aci_tag.go index 8af2c92a0..a1b4c62a4 100644 --- a/internal/provider/resource_aci_tag.go +++ b/internal/provider/resource_aci_tag.go @@ -69,7 +69,7 @@ func (r *TagTagResource) ModifyPlan(ctx context.Context, req resource.ModifyPlan } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Key.IsUnknown() { - setTagTagId(ctx, planData) + SetTagTagId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -168,12 +168,12 @@ func (r *TagTagResource) Create(ctx context.Context, req resource.CreateRequest, } if data.Id.IsUnknown() || data.Id.IsNull() { - setTagTagId(ctx, data) + SetTagTagId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_tag with id '%s'", data.Id.ValueString())) - jsonPayload := getTagTagCreateJsonPayload(ctx, &resp.Diagnostics, true, data) + jsonPayload := GetTagTagCreateJsonPayload(ctx, &resp.Diagnostics, true, data) if resp.Diagnostics.HasError() { return @@ -230,7 +230,7 @@ func (r *TagTagResource) Update(ctx context.Context, req resource.UpdateRequest, tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_tag with id '%s'", data.Id.ValueString())) - jsonPayload := getTagTagCreateJsonPayload(ctx, &resp.Diagnostics, false, data) + jsonPayload := GetTagTagCreateJsonPayload(ctx, &resp.Diagnostics, false, data) if resp.Diagnostics.HasError() { return @@ -344,12 +344,12 @@ func setTagTagParentDn(ctx context.Context, dn string, data *TagTagResourceModel data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setTagTagId(ctx context.Context, data *TagTagResourceModel) { +func SetTagTagId(ctx context.Context, data *TagTagResourceModel) { rn := getTagTagRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } -func getTagTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *TagTagResourceModel) *container.Container { +func GetTagTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *TagTagResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_trust_control_policy.go b/internal/provider/resource_aci_trust_control_policy.go index 95de08d92..1ed809ed5 100644 --- a/internal/provider/resource_aci_trust_control_policy.go +++ b/internal/provider/resource_aci_trust_control_policy.go @@ -134,7 +134,7 @@ func (r *FhsTrustCtrlPolResource) ModifyPlan(ctx context.Context, req resource.M } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFhsTrustCtrlPolId(ctx, planData) + SetFhsTrustCtrlPolId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -388,7 +388,7 @@ func (r *FhsTrustCtrlPolResource) Create(ctx context.Context, req resource.Creat var stateData *FhsTrustCtrlPolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFhsTrustCtrlPolId(ctx, stateData) + SetFhsTrustCtrlPolId(ctx, stateData) } getAndSetFhsTrustCtrlPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -409,7 +409,7 @@ func (r *FhsTrustCtrlPolResource) Create(ctx context.Context, req resource.Creat } if data.Id.IsUnknown() || data.Id.IsNull() { - setFhsTrustCtrlPolId(ctx, data) + SetFhsTrustCtrlPolId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_trust_control_policy with id '%s'", data.Id.ValueString())) @@ -420,7 +420,7 @@ func (r *FhsTrustCtrlPolResource) Create(ctx context.Context, req resource.Creat var tagTagPlan, tagTagState []TagTagFhsTrustCtrlPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFhsTrustCtrlPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFhsTrustCtrlPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -485,7 +485,7 @@ func (r *FhsTrustCtrlPolResource) Update(ctx context.Context, req resource.Updat var tagTagPlan, tagTagState []TagTagFhsTrustCtrlPolResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFhsTrustCtrlPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFhsTrustCtrlPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -668,7 +668,7 @@ func setFhsTrustCtrlPolParentDn(ctx context.Context, dn string, data *FhsTrustCt data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFhsTrustCtrlPolId(ctx context.Context, data *FhsTrustCtrlPolResourceModel) { +func SetFhsTrustCtrlPolId(ctx context.Context, data *FhsTrustCtrlPolResourceModel) { rn := getFhsTrustCtrlPolRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -752,7 +752,7 @@ func getFhsTrustCtrlPolTagTagChildPayloads(ctx context.Context, diags *diag.Diag return childPayloads } -func getFhsTrustCtrlPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FhsTrustCtrlPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFhsTrustCtrlPolResourceModel, tagTagPlan, tagTagState []TagTagFhsTrustCtrlPolResourceModel) *container.Container { +func GetFhsTrustCtrlPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FhsTrustCtrlPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFhsTrustCtrlPolResourceModel, tagTagPlan, tagTagState []TagTagFhsTrustCtrlPolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_vrf_fallback_route.go b/internal/provider/resource_aci_vrf_fallback_route.go index 7c0136f42..59abd900e 100644 --- a/internal/provider/resource_aci_vrf_fallback_route.go +++ b/internal/provider/resource_aci_vrf_fallback_route.go @@ -118,7 +118,7 @@ func (r *FvFBRouteResource) ModifyPlan(ctx context.Context, req resource.ModifyP } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.FbrPrefix.IsUnknown() { - setFvFBRouteId(ctx, planData) + SetFvFBRouteId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -291,7 +291,7 @@ func (r *FvFBRouteResource) Create(ctx context.Context, req resource.CreateReque var stateData *FvFBRouteResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvFBRouteId(ctx, stateData) + SetFvFBRouteId(ctx, stateData) } getAndSetFvFBRouteAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -312,7 +312,7 @@ func (r *FvFBRouteResource) Create(ctx context.Context, req resource.CreateReque } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvFBRouteId(ctx, data) + SetFvFBRouteId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) @@ -323,7 +323,7 @@ func (r *FvFBRouteResource) Create(ctx context.Context, req resource.CreateReque var tagTagPlan, tagTagState []TagTagFvFBRouteResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvFBRouteCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRouteCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -388,7 +388,7 @@ func (r *FvFBRouteResource) Update(ctx context.Context, req resource.UpdateReque var tagTagPlan, tagTagState []TagTagFvFBRouteResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvFBRouteCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRouteCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -550,7 +550,7 @@ func setFvFBRouteParentDn(ctx context.Context, dn string, data *FvFBRouteResourc data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvFBRouteId(ctx context.Context, data *FvFBRouteResourceModel) { +func SetFvFBRouteId(ctx context.Context, data *FvFBRouteResourceModel) { rn := getFvFBRouteRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -634,7 +634,7 @@ func getFvFBRouteTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getFvFBRouteCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvFBRouteResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRouteResourceModel, tagTagPlan, tagTagState []TagTagFvFBRouteResourceModel) *container.Container { +func GetFvFBRouteCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvFBRouteResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRouteResourceModel, tagTagPlan, tagTagState []TagTagFvFBRouteResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_vrf_fallback_route_group.go b/internal/provider/resource_aci_vrf_fallback_route_group.go index 3b80910de..9261605fd 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group.go @@ -176,7 +176,7 @@ func (r *FvFBRGroupResource) ModifyPlan(ctx context.Context, req resource.Modify } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() { - setFvFBRGroupId(ctx, planData) + SetFvFBRGroupId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -445,7 +445,7 @@ func (r *FvFBRGroupResource) Create(ctx context.Context, req resource.CreateRequ var stateData *FvFBRGroupResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvFBRGroupId(ctx, stateData) + SetFvFBRGroupId(ctx, stateData) } getAndSetFvFBRGroupAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -466,7 +466,7 @@ func (r *FvFBRGroupResource) Create(ctx context.Context, req resource.CreateRequ } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvFBRGroupId(ctx, data) + SetFvFBRGroupId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) @@ -483,7 +483,7 @@ func (r *FvFBRGroupResource) Create(ctx context.Context, req resource.CreateRequ var tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvFBRMemberPlan, fvFBRMemberState, fvFBRoutePlan, fvFBRouteState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvFBRMemberPlan, fvFBRMemberState, fvFBRoutePlan, fvFBRouteState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -554,7 +554,7 @@ func (r *FvFBRGroupResource) Update(ctx context.Context, req resource.UpdateRequ var tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvFBRMemberPlan, fvFBRMemberState, fvFBRoutePlan, fvFBRouteState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvFBRMemberPlan, fvFBRMemberState, fvFBRoutePlan, fvFBRouteState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -761,7 +761,7 @@ func setFvFBRGroupParentDn(ctx context.Context, dn string, data *FvFBRGroupResou data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvFBRGroupId(ctx context.Context, data *FvFBRGroupResourceModel) { +func SetFvFBRGroupId(ctx context.Context, data *FvFBRGroupResourceModel) { rn := getFvFBRGroupRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -945,7 +945,7 @@ func getFvFBRGroupTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getFvFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvFBRGroupResourceModel, fvFBRMemberPlan, fvFBRMemberState []FvFBRMemberFvFBRGroupResourceModel, fvFBRoutePlan, fvFBRouteState []FvFBRouteFvFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel) *container.Container { +func GetFvFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvFBRGroupResourceModel, fvFBRMemberPlan, fvFBRMemberState []FvFBRMemberFvFBRGroupResourceModel, fvFBRoutePlan, fvFBRouteState []FvFBRouteFvFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} diff --git a/internal/provider/resource_aci_vrf_fallback_route_group_member.go b/internal/provider/resource_aci_vrf_fallback_route_group_member.go index fa6e2291a..ef4ab4fd2 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group_member.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group_member.go @@ -118,7 +118,7 @@ func (r *FvFBRMemberResource) ModifyPlan(ctx context.Context, req resource.Modif } if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.RnhAddr.IsUnknown() { - setFvFBRMemberId(ctx, planData) + SetFvFBRMemberId(ctx, planData) } if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() { @@ -291,7 +291,7 @@ func (r *FvFBRMemberResource) Create(ctx context.Context, req resource.CreateReq var stateData *FvFBRMemberResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) if stateData.Id.IsUnknown() || stateData.Id.IsNull() { - setFvFBRMemberId(ctx, stateData) + SetFvFBRMemberId(ctx, stateData) } getAndSetFvFBRMemberAttributes(ctx, &resp.Diagnostics, r.client, stateData) if !globalAllowExistingOnCreate && !stateData.Id.IsNull() { @@ -312,7 +312,7 @@ func (r *FvFBRMemberResource) Create(ctx context.Context, req resource.CreateReq } if data.Id.IsUnknown() || data.Id.IsNull() { - setFvFBRMemberId(ctx, data) + SetFvFBRMemberId(ctx, data) } tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_vrf_fallback_route_group_member with id '%s'", data.Id.ValueString())) @@ -323,7 +323,7 @@ func (r *FvFBRMemberResource) Create(ctx context.Context, req resource.CreateReq var tagTagPlan, tagTagState []TagTagFvFBRMemberResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvFBRMemberCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRMemberCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -388,7 +388,7 @@ func (r *FvFBRMemberResource) Update(ctx context.Context, req resource.UpdateReq var tagTagPlan, tagTagState []TagTagFvFBRMemberResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvFBRMemberCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRMemberCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -550,7 +550,7 @@ func setFvFBRMemberParentDn(ctx context.Context, dn string, data *FvFBRMemberRes data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) } -func setFvFBRMemberId(ctx context.Context, data *FvFBRMemberResourceModel) { +func SetFvFBRMemberId(ctx context.Context, data *FvFBRMemberResourceModel) { rn := getFvFBRMemberRn(ctx, data) data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) } @@ -634,7 +634,7 @@ func getFvFBRMemberTagTagChildPayloads(ctx context.Context, diags *diag.Diagnost return childPayloads } -func getFvFBRMemberCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvFBRMemberResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRMemberResourceModel, tagTagPlan, tagTagState []TagTagFvFBRMemberResourceModel) *container.Container { +func GetFvFBRMemberCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvFBRMemberResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRMemberResourceModel, tagTagPlan, tagTagState []TagTagFvFBRMemberResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} From 5d04147d67982ebaf606504236549a54fe4450df Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Wed, 21 Aug 2024 14:03:37 -0700 Subject: [PATCH 02/10] [ignore] --- cmd/conversion/plan.bin | Bin 4927 -> 4928 bytes cmd/conversion/plan.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/conversion/plan.bin b/cmd/conversion/plan.bin index 367ab57f3917c749c2a4b10de485e72d49037506..345ff10ce01ba2944fb9ee362c53eab654ca1ee5 100755 GIT binary patch delta 1462 zcmdn5c0i3Mz?+#xgn4O4G53A-?`M18@2!3R>a+HI+wWoV(pxnxW?g;FmYg_OvQ$Q@ z-dQ>IQeQx_9T3LpyK{>yQ??&&XA$?X0pIBRDtrvU3)^}~+tpgW-y!ql0+2--IE<;-=9^OEnMWX)sIE{+=AXNm!<=-Ih_FrTVTz^CeFz-v>G8*gelO z{-oyjFHUt6sXyVE5>k~b_1*B5gi*I4kI+%GQ!j$1=&7gdfA~zpYsw=9l?5pww{B?@Dmc~!e9AiH|MB=lqv$IIipd&IAt$$m2pzvD#{SHw@>iLM?vkD;_OR5p%HDnY z8*~a6_5HrL$I!n`@6`_7!qeJS8he!fakhk}?y*$7&&hqolDVEaYhtyP`V)nveY}m5 z4=-@c65bT76xW@5Kg?Qq{qBDZCW2R{XI@)dti5@;7F8|eb>%t&l3LB>#krn zA<624>i2XLHp?S!sk?w-&ag#LOFiYy|K5Vdb0!Ekr+NwGHf?mMowqVyZ0Zjk=`Rh> zTV%`}%wBFSP7t_gIekO@8LJ--H&3db72kPH_}OwcVZ#eoc=vv=R6NdG7PVr|1bL}B zAu@ln=bLnP?N5`rrNQ2O(NgmFc?^2^**m(`Eh2cmhI{+$qz5ju3}x@*W|b2$fZToZYQ4I)Nw8T zW3*`Bkpl`F6sHPJUQ}>z$+UKltw!r6x}QDyCVSniD|39>O75O4yn3kL;-G?~)Y-@9 z4q2}(>f@WTYNzequ*av_G}-U?%-JZL*0;J|*S>t)-*2BH3=2=E#qW>QSy07Ys+974@p}FA_iejl>c68;OGKoJsd5U}TKZEdJ zbFJsz-hI&8J5hhn)pvI@+y8z)^zUw5#rE>ofA2RxIIr+SpMl~3{{U}x4)%71_rfd; z3}^Tm7?6vP$;=I+eIv}@-|H5M&tXk+SZdhnpTSGQxL;S70AO%080JKLl> z+w2+7zWaM4_UED#MeU_W-|l(;_V)LE-=EcTpV$BY@lN#WTPt!8UR-nEK!W@AnFWt8 z)JsTdPA+SCWt2Gc(GJ~#^_=WUUVVn1`2*)#Y}kml6Iei}dd_-?&s-O<|ITghQ7p-=5mD1ag-MAWNAEox$17nc1t%C?>n5qmn2WgJg{xsRdM#> zkJD3``=&_-M%4EyExz>n@*e-d;}ar#7EagL7MeDFQHiBud#{0d;35%rMMl-dx6(W( z-kQMeUCsGvu~2w&O;){(=4NMJaicaR*Qsy3R0}2E79^aTvONFy6{k}xN)tlUW;}oK z`_MF1zbkL+PUW3jys+CU&->2D9y#vw9ra9!p)>RSPLv;FDm~{=-yiiv?i{D3*UIGD z1UCzlre`g0riz_Ex^Dj5y@gk5>ltQoyt-{7eRAhq%L_aKZVPzbEEVIkpGltO{CO-| z!E8d(t4}Wb2pwRJvZ(^XH0#65Fg@`_%2!pKNLLlb$O4 z$(ea_*W&uOlhpz`ub*+2e!9TiVtG=1Z?RKd-V9wMfldAU{?1z=FTKM!a-&<%`rIq? z7Wp}To!1wwFvqCw-c~Ob=_`jUS#6aodJcqowf^~1mns?(cHq_HSr|X>r)?!n2!C zT&sVyeU+tpSe9Y~6Vd3-z50hR$O!c~ObC0Wd+r$6ft#S2S!l8;>`r(~zlQ(=`@*-1qSI}Z@ zQ!rr_-WykKX3AxLKO@##Wbw&M+H0r3fB#EnzRWv~&8eoT95FN0PwV$QKO7VN_Rh;S zZ`t)*t+XG${dQ_@*^XavJBrG4-{w{P{(Haq!Fh!r`V0*J{|9)pa~v`0x+%oMz;K42 zfdRSnm>k0*$7B;SxrSvG)0@1>8m!77o-b=Bh7%;ht8`WP4(wgE9a11FG#0e_&Y zO45o;5=&A;Ls%IYL1h`b?%qqX>vMq`CIB%Hif(CExNhBoqSP{=5hB>km>eM_<9!;e zI5|HrEi+v|S64qbF*8rEBn_vvbC+hzY67hUVNn!o?@!(@BrAmJ)XDFJWEevxa|=sL WK_pq(fO;9&fN&lo14FkUhz9`lb8gT8 diff --git a/cmd/conversion/plan.json b/cmd/conversion/plan.json index 401610775..c78cbaa43 100644 --- a/cmd/conversion/plan.json +++ b/cmd/conversion/plan.json @@ -1 +1 @@ -{"format_version":"1.2","terraform_version":"1.8.5","planned_values":{"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"sensitive_values":{}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"sensitive_values":{}},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":2,"values":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default/epg-new_epg","name":"new_epg","parent_dn":"uni/tn-common/ap-default","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"sensitive_values":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":2,"values":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default222","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default222/epg-new_epg2","name":"new_epg2","parent_dn":"uni/tn-common/ap-default222","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"sensitive_values":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}]}},"resource_changes":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default/epg-new_epg","name":"new_epg","parent_dn":"uni/tn-common/ap-default","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"after_unknown":{"admin_state":true,"annotations":true,"epg_useg_block_statement":true,"has_mcast_source":true,"has_multicast_source":true,"intra_epg_isolation":true,"is_attr_based_epg":true,"match_criteria":true,"match_t":true,"name_alias":true,"pc_enf_pref":true,"pc_tag":true,"pref_gr_memb":true,"preferred_group_member":true,"prio":true,"priority":true,"relation_fv_rs_aepg_mon_pol":true,"relation_fv_rs_bd":true,"relation_fv_rs_cons":true,"relation_fv_rs_cons_if":true,"relation_fv_rs_cust_qos_pol":true,"relation_fv_rs_dpp_pol":true,"relation_fv_rs_fc_path_att":true,"relation_fv_rs_intra_epg":true,"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":true,"relation_fv_rs_prot_by":true,"relation_fv_rs_prov":true,"relation_fv_rs_sec_inherited":true,"relation_fv_rs_trust_ctrl":true,"relation_to_application_epg_monitoring_policy":true,"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":true,"relation_to_contract_masters":true,"relation_to_custom_qos_policy":true,"relation_to_data_plane_policing_policy":true,"relation_to_domains":true,"relation_to_fibre_channel_paths":true,"relation_to_imported_contracts":true,"relation_to_intra_epg_contracts":true,"relation_to_provided_contracts":true,"relation_to_static_leafs":true,"relation_to_static_paths":true,"relation_to_taboo_contracts":true,"relation_to_trust_control_policy":true,"shutdown":true,"tags":true,"useg_epg":true},"before_sensitive":false,"after_sensitive":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default222","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default222/epg-new_epg2","name":"new_epg2","parent_dn":"uni/tn-common/ap-default222","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"after_unknown":{"admin_state":true,"annotations":true,"epg_useg_block_statement":true,"has_mcast_source":true,"has_multicast_source":true,"intra_epg_isolation":true,"is_attr_based_epg":true,"match_criteria":true,"match_t":true,"name_alias":true,"pc_enf_pref":true,"pc_tag":true,"pref_gr_memb":true,"preferred_group_member":true,"prio":true,"priority":true,"relation_fv_rs_aepg_mon_pol":true,"relation_fv_rs_bd":true,"relation_fv_rs_cons":true,"relation_fv_rs_cons_if":true,"relation_fv_rs_cust_qos_pol":true,"relation_fv_rs_dpp_pol":true,"relation_fv_rs_fc_path_att":true,"relation_fv_rs_intra_epg":true,"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":true,"relation_fv_rs_prot_by":true,"relation_fv_rs_prov":true,"relation_fv_rs_sec_inherited":true,"relation_fv_rs_trust_ctrl":true,"relation_to_application_epg_monitoring_policy":true,"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":true,"relation_to_contract_masters":true,"relation_to_custom_qos_policy":true,"relation_to_data_plane_policing_policy":true,"relation_to_domains":true,"relation_to_fibre_channel_paths":true,"relation_to_imported_contracts":true,"relation_to_intra_epg_contracts":true,"relation_to_provided_contracts":true,"relation_to_static_leafs":true,"relation_to_static_paths":true,"relation_to_taboo_contracts":true,"relation_to_trust_control_policy":true,"shutdown":true,"tags":true,"useg_epg":true},"before_sensitive":false,"after_sensitive":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}}],"configuration":{"provider_config":{"aci":{"name":"aci","full_name":"registry.terraform.io/ciscodevnet/aci","expressions":{"insecure":{"constant_value":true},"password":{"constant_value":"ins3965!"},"url":{"constant_value":"https://173.36.219.79"},"username":{"constant_value":"admin"}}}},"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_key"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name"},"value":{"constant_value":"test_value"}},"schema_version":0},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_keya"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]"},"value":{"constant_value":"test_valuea"}},"schema_version":0},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"tag_epg"},"contract_exception_tag":{"constant_value":"0"},"description":{"constant_value":"from terraform"},"flood_in_encapsulation":{"constant_value":"disabled"},"forwarding_control":{"constant_value":"none"},"name":{"constant_value":"new_epg"},"parent_dn":{"constant_value":"uni/tn-common/ap-default"},"relation_to_bridge_domain":{"constant_value":[{"annotation":"annotation1","bridge_domain_name":"default"}]}},"schema_version":2},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"tag_epg"},"contract_exception_tag":{"constant_value":"0"},"description":{"constant_value":"from terraform"},"flood_in_encapsulation":{"constant_value":"disabled"},"forwarding_control":{"constant_value":"none"},"name":{"constant_value":"new_epg2"},"parent_dn":{"constant_value":"uni/tn-common/ap-default222"},"relation_to_bridge_domain":{"constant_value":[{"annotation":"annotation1","bridge_domain_name":"default"}]}},"schema_version":2}]}},"timestamp":"2024-08-21T20:55:24Z","applyable":true,"complete":true,"errored":false} +{"format_version":"1.2","terraform_version":"1.8.5","planned_values":{"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"sensitive_values":{}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"sensitive_values":{}},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":2,"values":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default/epg-new_epg","name":"new_epg","parent_dn":"uni/tn-common/ap-default","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"sensitive_values":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":2,"values":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default222","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default222/epg-new_epg2","name":"new_epg2","parent_dn":"uni/tn-common/ap-default222","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"sensitive_values":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}]}},"resource_changes":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default/epg-new_epg","name":"new_epg","parent_dn":"uni/tn-common/ap-default","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"after_unknown":{"admin_state":true,"annotations":true,"epg_useg_block_statement":true,"has_mcast_source":true,"has_multicast_source":true,"intra_epg_isolation":true,"is_attr_based_epg":true,"match_criteria":true,"match_t":true,"name_alias":true,"pc_enf_pref":true,"pc_tag":true,"pref_gr_memb":true,"preferred_group_member":true,"prio":true,"priority":true,"relation_fv_rs_aepg_mon_pol":true,"relation_fv_rs_bd":true,"relation_fv_rs_cons":true,"relation_fv_rs_cons_if":true,"relation_fv_rs_cust_qos_pol":true,"relation_fv_rs_dpp_pol":true,"relation_fv_rs_fc_path_att":true,"relation_fv_rs_intra_epg":true,"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":true,"relation_fv_rs_prot_by":true,"relation_fv_rs_prov":true,"relation_fv_rs_sec_inherited":true,"relation_fv_rs_trust_ctrl":true,"relation_to_application_epg_monitoring_policy":true,"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":true,"relation_to_contract_masters":true,"relation_to_custom_qos_policy":true,"relation_to_data_plane_policing_policy":true,"relation_to_domains":true,"relation_to_fibre_channel_paths":true,"relation_to_imported_contracts":true,"relation_to_intra_epg_contracts":true,"relation_to_provided_contracts":true,"relation_to_static_leafs":true,"relation_to_static_paths":true,"relation_to_taboo_contracts":true,"relation_to_trust_control_policy":true,"shutdown":true,"tags":true,"useg_epg":true},"before_sensitive":false,"after_sensitive":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default222","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default222/epg-new_epg2","name":"new_epg2","parent_dn":"uni/tn-common/ap-default222","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"after_unknown":{"admin_state":true,"annotations":true,"epg_useg_block_statement":true,"has_mcast_source":true,"has_multicast_source":true,"intra_epg_isolation":true,"is_attr_based_epg":true,"match_criteria":true,"match_t":true,"name_alias":true,"pc_enf_pref":true,"pc_tag":true,"pref_gr_memb":true,"preferred_group_member":true,"prio":true,"priority":true,"relation_fv_rs_aepg_mon_pol":true,"relation_fv_rs_bd":true,"relation_fv_rs_cons":true,"relation_fv_rs_cons_if":true,"relation_fv_rs_cust_qos_pol":true,"relation_fv_rs_dpp_pol":true,"relation_fv_rs_fc_path_att":true,"relation_fv_rs_intra_epg":true,"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":true,"relation_fv_rs_prot_by":true,"relation_fv_rs_prov":true,"relation_fv_rs_sec_inherited":true,"relation_fv_rs_trust_ctrl":true,"relation_to_application_epg_monitoring_policy":true,"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":true,"relation_to_contract_masters":true,"relation_to_custom_qos_policy":true,"relation_to_data_plane_policing_policy":true,"relation_to_domains":true,"relation_to_fibre_channel_paths":true,"relation_to_imported_contracts":true,"relation_to_intra_epg_contracts":true,"relation_to_provided_contracts":true,"relation_to_static_leafs":true,"relation_to_static_paths":true,"relation_to_taboo_contracts":true,"relation_to_trust_control_policy":true,"shutdown":true,"tags":true,"useg_epg":true},"before_sensitive":false,"after_sensitive":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}}],"configuration":{"provider_config":{"aci":{"name":"aci","full_name":"registry.terraform.io/ciscodevnet/aci","expressions":{"insecure":{"constant_value":true},"password":{"constant_value":"ins3965!"},"url":{"constant_value":"https://173.36.219.79"},"username":{"constant_value":"admin"}}}},"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_key"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name"},"value":{"constant_value":"test_value"}},"schema_version":0},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_keya"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]"},"value":{"constant_value":"test_valuea"}},"schema_version":0},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"tag_epg"},"contract_exception_tag":{"constant_value":"0"},"description":{"constant_value":"from terraform"},"flood_in_encapsulation":{"constant_value":"disabled"},"forwarding_control":{"constant_value":"none"},"name":{"constant_value":"new_epg"},"parent_dn":{"constant_value":"uni/tn-common/ap-default"},"relation_to_bridge_domain":{"constant_value":[{"annotation":"annotation1","bridge_domain_name":"default"}]}},"schema_version":2},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"tag_epg"},"contract_exception_tag":{"constant_value":"0"},"description":{"constant_value":"from terraform"},"flood_in_encapsulation":{"constant_value":"disabled"},"forwarding_control":{"constant_value":"none"},"name":{"constant_value":"new_epg2"},"parent_dn":{"constant_value":"uni/tn-common/ap-default222"},"relation_to_bridge_domain":{"constant_value":[{"annotation":"annotation1","bridge_domain_name":"default"}]}},"schema_version":2}]}},"timestamp":"2024-08-21T21:02:04Z","applyable":true,"complete":true,"errored":false} From b6a37a64bf7eb821aa6bfb8d3364c0b0582a2eef Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Wed, 21 Aug 2024 21:34:34 -0700 Subject: [PATCH 03/10] [minor_changes] Revised converter and fixed legacy documentation --- cmd/conversion/main.go | 25 ++- cmd/conversion/main.tf | 20 ++- cmd/conversion/payload.json | 97 +++++++++++- cmd/conversion/plan.bin | Bin 4928 -> 4349 bytes cmd/conversion/plan.json | 2 +- convert_funcs/dn_to_aci.go | 247 ------------------------------ convert_funcs/getAciClass.go | 76 ++++----- convert_funcs/resourceMap.go | 49 +++++- gen/generator.go | 2 +- gen/templates/getAciClass.go.tmpl | 8 +- gen/templates/new.go.tmpl | 2 +- gen/templates/resourceMap.go.tmpl | 2 - 12 files changed, 209 insertions(+), 321 deletions(-) delete mode 100644 convert_funcs/dn_to_aci.go diff --git a/cmd/conversion/main.go b/cmd/conversion/main.go index a45895302..61d702f53 100644 --- a/cmd/conversion/main.go +++ b/cmd/conversion/main.go @@ -123,7 +123,9 @@ func createPayloadList(plan Plan) []map[string]interface{} { return data } -// Work in progress... "panic: assignment to entry in nil map" for cases where AciClassMap() returns "" in this function +var lastValidNode map[string]interface{} + +// Work in progress... func constructTree(resources []map[string]interface{}) map[string]interface{} { rootNode := map[string]interface{}{ "children": []map[string]interface{}{}, @@ -144,15 +146,12 @@ func constructTree(resources []map[string]interface{}) map[string]interface{} { pathSegments := strings.Split(dn, "/") if len(pathSegments) > 1 { parentDn = strings.Join(pathSegments[:len(pathSegments)-1], "/") - } else { parentDn = "uni" } } - if _, parentExists := nodeMap[parentDn]; !parentExists { - createParentPath(nodeMap, parentDn) - } + createParentPath(nodeMap, parentDn) currentNode, nodeExists := nodeMap[dn] if !nodeExists { @@ -177,17 +176,12 @@ func constructTree(resources []map[string]interface{}) map[string]interface{} { parentNode := nodeMap[parentDn] - className := convert_funcs.GetAciClass(strings.Split(dn, "/")[len(strings.Split(dn, "/"))-1]) - if className == "" { - className = resourceType - } - parentChildren, ok := parentNode["children"].([]map[string]interface{}) if !ok || parentChildren == nil { parentChildren = []map[string]interface{}{} } - parentNode["children"] = append(parentChildren, map[string]interface{}{className: currentNode}) + parentNode["children"] = append(parentChildren, map[string]interface{}{resourceType: currentNode}) nodeMap[dn] = currentNode } @@ -201,15 +195,16 @@ func constructTree(resources []map[string]interface{}) map[string]interface{} { func createParentPath(nodeMap map[string]map[string]interface{}, parentDn string) { pathSegments := strings.Split(parentDn, "/") currentDn := "uni" - var lastValidNode map[string]interface{} for _, segment := range pathSegments[1:] { currentDn += "/" + segment - className := convert_funcs.GetAciClass(strings.Split(segment, "-")[0]) + className := convert_funcs.AciClassMap(strings.Split(segment, "-")[0]) if className == "" { + //Intended to be 'continue' to skip intermediate segments in dn, currently causes error className = segment + } if _, exists := nodeMap[currentDn]; !exists { @@ -217,10 +212,9 @@ func createParentPath(nodeMap map[string]map[string]interface{}, parentDn string "attributes": map[string]interface{}{ "dn": currentDn, }, - "children": []map[string]interface{}{}, // Ensure children is always initialized + "children": []map[string]interface{}{}, } - // Attach this node to the last valid node or the root if at the top level if lastValidNode == nil { if _, ok := nodeMap["uni"]["children"]; !ok { nodeMap["uni"]["children"] = []map[string]interface{}{} @@ -236,7 +230,6 @@ func createParentPath(nodeMap map[string]map[string]interface{}, parentDn string nodeMap[currentDn] = newNode } - // Update the last valid node reference lastValidNode = nodeMap[currentDn] } } diff --git a/cmd/conversion/main.tf b/cmd/conversion/main.tf index 4112b2153..9e9c28d55 100644 --- a/cmd/conversion/main.tf +++ b/cmd/conversion/main.tf @@ -9,16 +9,16 @@ terraform { # Configure the provider with your Cisco APIC credentials. provider "aci" { # APIC Username - username = "admin" + username = " " # APIC Password - password = "ins3965!" + password = " " # APIC URL - url = "https://173.36.219.79" + url = " " insecure = true } # Defines an Application EPG Resource. - +/* resource "aci_application_epg" "fooapplication_epg" { parent_dn = "uni/tn-common/ap-default" name = "new_epg" @@ -33,8 +33,8 @@ resource "aci_application_epg" "fooapplication_epg" { bridge_domain_name = "default" }] } - - +*/ +/* resource "aci_application_epg" "fooapplication_epg2" { parent_dn = "uni/tn-common/ap-default222" name = "new_epg2" @@ -50,7 +50,7 @@ resource "aci_application_epg" "fooapplication_epg2" { }] } - +*/ # Define an ACI Tenant Resource. /* @@ -107,8 +107,7 @@ resource "aci_vrf_fallback_route_group" "full_example_vrf" { } ] } -*/ -/* + resource "aci_external_management_network_instance_profile" "full_example" { annotation = "woidid" description = "description" @@ -237,7 +236,6 @@ resource "aci_annotation" "terraform_annotation2" { -/* resource "aci_pim_route_map_policy" "full_example_tenant" { parent_dn = "uni/tn-demo_tenant" annotation = "annotation" @@ -259,7 +257,7 @@ resource "aci_pim_route_map_policy" "full_example_tenant" { } ] } -*/ + # Define an ACI Tenant VRF Resource. # resource "aci_vrf" "terraform_vrf" { diff --git a/cmd/conversion/payload.json b/cmd/conversion/payload.json index 2b8a9ab49..f84e84906 100644 --- a/cmd/conversion/payload.json +++ b/cmd/conversion/payload.json @@ -1,5 +1,100 @@ { "uni": { - "children": [] + "children": [ + { + "tn-common": { + "attributes": { + "dn": "uni/tn-common" + }, + "children": [ + { + "eptags": { + "attributes": { + "dn": "uni/tn-common/eptags" + }, + "children": [ + { + "fvEpIpTag": { + "attributes": { + "dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name" + }, + "children": [ + { + "tagAnnotation": { + "attributes": { + "dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]", + "key": "test_key", + "parent_dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name", + "status": "created", + "value": "test_value" + }, + "children": [ + { + "tagAnnotation": { + "attributes": { + "dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]", + "key": "test_keya", + "parent_dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]", + "status": "created", + "value": "test_valuea" + }, + "children": null + } + }, + { + "tn-demo_tenant": { + "attributes": { + "dn": "uni/tn-demo_tenant" + }, + "children": [ + { + "pimRouteMapPol": { + "attributes": { + "annotation": "annotation", + "descr": "description", + "dn": "uni/tn-demo_tenant/rtmap-test_name", + "name": "test_name", + "nameAlias": "name_alias", + "ownerKey": "owner_key", + "ownerTag": "owner_tag", + "parent_dn": "uni/tn-demo_tenant", + "status": "created" + }, + "children": [ + { + "tagAnnotation": { + "attributes": { + "key": "key_0", + "value": "value_1" + } + } + }, + { + "tagTag": { + "attributes": { + "key": "key_0", + "value": "value_1" + } + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } + } + ] } } \ No newline at end of file diff --git a/cmd/conversion/plan.bin b/cmd/conversion/plan.bin index 345ff10ce01ba2944fb9ee362c53eab654ca1ee5..3c5b96fb0d80b44dc1f8d201eba244ffc1ad809e 100755 GIT binary patch delta 2440 zcmZ`*XHXMZ7Y#KC0VI&ng7hv$h%{jV=|rVUkpMx2(7O~tA|;efz+h;GvNT~SN{1j) zR-`v6p-5RkdQ${h5tR@2n;rEl_s#ur=FK^C?|U=%+;*|Af*?}_4J`+N;q+{mr-1k{ zu(mGOij+1SyEaGn;~u9eg#^PsH_=^_KtH5=Dayr#p~Lx5RJnJE)fFAsxRWmsjZMNl zSbZ%rB{4OHba!$JKZ!yWoy@>@xg_V7aH z+C*xUo-?Wl&p>A69)4`>FE$d_9_ot;JrQ>&4zVuX7dLU(KiJMAsMn36jTuCB#-Uwd z38X9Uf&Lt1aqiF1K*VE>0x)fyz>^wO(<9cZ10ZFIqkmD4Nj^fcGoad?lLussun0SR zAK>e!5L3~9lVZ(4v};#++E&SY*+Fd1+HT{^c2K0ye0Tj2g5_;d%kkLd>>Z5H-GN(! zHCBpENBpkO+Zw?81r)Iyw9GsAt)rUxil}m){futejb07}&r{!{hBCOrlT5{qyB`f= za<=E2upHO|sHh3K%Ykt^OWE?9ls&+Foy8aSKq*5c9jwd&n3KmHU|A2jG+K zgyPxk;L2i^XrWqHahAjAInkzcU86rA9)1xCt!y8z001W^rU)Rz z7qSMSj|u>gr3C<9&8!>{mjC#AAC_yKDhOW~ko}no^sZ&%- zOV34x$!h&@=jb-_Wf8Pf0L*`MX{|*cM-~8QzGPFJfZ%UHvSQWyRkFaB5(UKc$}WDQ ze;9>Mj-dA}r1a9*e4T)&mRw z^~U&>c<~M7sY4aX-EG~fB{*s_QT2|M`1uwU zuYDkzAoGzl*IAdfDU;=&CO1bt+R&Q5WhH_}A@T~$GK}hNR$}VyaD&wQldHWUd(R9q zIG61k1=J;4_>KJaxr_wHV7K!okn_%c0eUtJ_t20r4z=0Z7hCT=2HkZF#RD;YmOyK6 z{X`Lwl}BaQRpqgeqOMNYBWBfp97t$@2^)sbh}D~tVQg-)(zLUggcm61DH&<%KrQdu z8=wpYBm`MtBAS5efeSQE(T4%>D{5*ycix0pR{iF6yg2PTIlNoetJNv#_!h5NMt&7t z0-xP(?k~+4yx2R=aUu2Fq&LQ=gj8~SbZMyH%-qg_x0RR?F{rh~NZzd9RXm=1Zjw@j zumeKX8DuHHc=~NkU!8b1p+GMK_DSJhTqMkauZC;Q&#d!_*8vj*xLiE#bn8o;sKevFG2$32daWd5{nISWH5oHJtZC2Zm~&sv zfc-eHe5_x(vbhExaKpsx0;k>J3`}ykQULzK;=JWa<}6vUd#5PGH7vQ%L@D&p9BSg3 zgK2jScnfNs+hpY4!`h(L<{3z7Ge`IY^yCbK!u-Nme;Vbh_2)IK@e{AI@R?m;Ys9zL zWMLJpmKZcHV})wJ9W&sjvs{2Sj(0!jaa0qfze2b{K3HZtr>hK997J? zoDg5l<`%Y2$_~Gj!DSd~J?t*}ffEs3euX4V5-#WbdXkkZOO78DW<;o`XRXeyncmL4 zB({$@4n_s^rOs~a(#Jq~+q>_A^5J+3RoMVe#g8J|)<;P+3k_Wrg9qttU8&}v@f_K% zv`mxEP0sjC3<2pqlHVNKW5Fp1L*zQO@b4G}luAi<<_uJgqiCTk+McxcL!h35j>^gT z4mofj({wI~PkUyAzXBP!Y(1~K3;l|`5WiAm^NlY2k3!EBC|_*pE-bG67}R0yj*BzV zxE>hY%GO*uYdsBU4$5z?srWV`joXED$0VBHTNuO)WqUvwyhnB#P;gBehbdfUN+`UI zoieGEG*`iewE69ZKCiG)9MeYi`Lt?b>E6OM!L5D&+W}y)X3MHN&j@(x{t}qY)8<2;T8#i$XPV{-B*Cf9LkFus(2bag05l3V(a53Ak zm=iRjL{PL}-{X)VNj2h|J|m_>zsGga;kmChl_yPfbE(RMf%&RbX{;g70;uRP_h|N6 ztd0~#|AB?7{Hp`Ix)bJqyum!PQ2jMM0MI7zvo{d8K^M{(JT(F*DJ! zY?ni9zgr5in2rDMwZRlYMa=>DXPJQ5!o~(>lTZDn;WW>@<$D0B0e~Raz#yj}mz$P! z0IIX4<3HI+qkNU#rxe0zf_`F;eP_$~1-JyCN?`uC#*e+R|D+K^b5?<~uaB!cTFzTW z&fCe|M>fdy|5lUp#FJ0*w34%g{G^n_c&bF~0CR)?y9?qj7)A|dB7)d?c>aA$cly!* P0R8F7J@sQF)-&`k&@e8; delta 3012 zcmZ{mc{mjO7RLu;EQ5?C+bGM(zLi80GnVYU8G8&dW63hcPMWd~!!-61@mjJ>hGJxm zp_F}#7E3BIMTtlVukO9?z4hFC&v|}-e4pR*{XOS*{y3krE7^IB%f_4qC;(tTNCY;6 zOB_F7*MnKM>j;7x3EXBiGL#*6WS4aKgTRbvK~W4-r4-D_m6dgOE1GXUi1Az*;yO_u zPBnnYuxbdH2msko{{HZ^H2Mz{Q#kxyx|knKbPuS}y4X6Cqnc{da_^NaC`|`SpZTuKhUd02UmW4ORERRns*S!tiwd(^8s1(V#Fgffwn&5BX z+tv1gH67+2NnoQh4mYBJ%CHy>U3-nzxv}hvp9de6EuFdzAH=@z781(%N*_C@j95Oo zXpYY~wJB$v2wbY{E+Eg`+z~(LsV}}VC~=D)XGpUGDh?H=ry9m}z7KZgtDb^N=gWL1 z$baBM^L#mC;M%s}^8+1py%cRMfPV`2LPiIOZmNG2K2B8U;(M&w$2gy@BJ0)hWh15*b6zOB##ga@%SJCzhblI*JZu>B;&ZtGpwYi90J+fh~#@RdYEm&B5FI_M7b=@ znav)Z6qWu^wN5FxgtRl;rf!|2^07%dxL+|^u1#u>Bf$>crY-rJ1N=;z1<&G_5p!C0 zUZR}DeNE)e2zx&NeOoCvV!&&A9sb(ZJ%9$}S)T7?O^9NBg-CIlzE~O#@o;iLF`s`e z{hWj*`Qqs>GMnBSAnixS=$3DbZ&GJibUj5i?eo__4@s-VL;-<8DH zuP!D)HT5+=&_djKN44|n@B^p6>%Z)k85C-s+-^fq}k~V~Zcv7TForlAT`!`Da`s8?3+IMC`tpE9_0>@Vp#Y@kxG30NF8a z%8_8(v)O8&;$E7sQ{nCoybftHt0EW8)~3bvu`~3jHwEJZyvJ-h@b>Ln&S-g@*3Mpl za{E{bluMq*lfHcRaORELvNaWptgs$6uW?+Li3IJP6M$Gj$4s5#DR zfxAVGYaivp*r<^E!`1N3KnHg0o|A zm#{;bY|UdqQ$L!dw^^o*M{<3SqpNj4YRhYL{s4xVN5?{gba(X9{K^F2& zeRIuAiuG<9NNmlxb4T)dcmrZ|&1jSAm8OX2V=(lo*vcaorB&x3$IMJyl(JVx0QyEc zcam#acD$W;7jw^f_61GBo+GIO z@^jtMu1y=f=V4JvB@GO@=yf+s-JsL$ZEi|ds;WEJ#=bm;S?0moo@5GfVx^)+i7)VG zJ-gUXsrIUlgD?#*id$>vQUmljg`eOCZQP1K@iaHO=JUl@mg~8LO?|n6TRtwR{;;Kt z6Lm5+qm}(-&Ue@7uWBA+u5DfVI^P=kytKc6jfxUHl0BPNrX`&QBl}9J+gwsvQAamR zDFNGSQhhnanVr|dp3)XHN=CC%&}R4q#Y3h3e3>}Yi9666U7Y9NdDk;17rZwDK^79b z&h(gfNi9z%&LmKZl%HJ^9Tl^=RaPVkt{$UGtHF4)dD(a}k0!c4wWH;gz8oDLl^B0m znzrjTb!b?#l@Lx5VG*pjoPJ`c@+}|u_87K)#lFH#rygc&8)>tRdeBkmcRLktO4Lz3 zXBrR{@ZHL7?IcTz;#~FfmSO*>rL#tvDgok-UnH84J4%mgyunVb&i%p-CQU||gk*zo zbM{XkB7;gJZukq5M5Z&pL&lB0E%gF4w8?t6kA&eu=g)X^_z67EOr5-eN%mb8%Z)@U zSX*1^6%-b^mAnfHDbYTww;vjYzZ~}M1JrUko@%99yDj_j^y0d}`;>bVZG#zW>|jK< z4l8`)dT+W;j+!>wEHGRu9!}(*dv`j?Mzp62D%7l) zADvlD`O(9Kb@80UME9dS&E!EJt@7TP4OCp*AR1VhP#YN|uJ|+aRYYEr%y8Xo_BU8F zGAH}36~@s|jhVRCa5Coo z+K+3W8>N{LdAg7hJlzwqNpC0(M&0L%?r6hb6K0T~DgIYoTSi=+?DrWtMiKdGbVGUF zFBosDli-9#JR{siE&nL9>T-HGdtguWLUIrF1m z$s1c*!%-$F_fZkIj-CnGNy#f#J*rp2-%8$?24yff)#|cFbg5AVv6IrgDbg1fr(8BZ zl@m`8U_O>wh9@VcU25-JSUkLZfuCcX;LQ(yI8M$)yGWmmd76EdajHKcOENx^>#*v~ z1Ikqz6MY5=)yD)m_T?a8+*r{0nBmKT4qcKte$t&)P~nT)%CGi8f5URie1A~Eh1Xj@LSEhgt$nkrGVzB-mf&aot55~rviCF;f z_tq-t1RWokCLK5$56(~Q{3mPy9IoH&P}YCjm9aQ<`2Vfo z*I)Dh_QU`yAgh=~gzx8G{d?V6C|)S@99LE>FZ6%iQh1>(cHDq0Rj`QYKh3NMZ3O^8 O2YH(b07!%URDS`_VnibV diff --git a/cmd/conversion/plan.json b/cmd/conversion/plan.json index c78cbaa43..6e7d65ccb 100644 --- a/cmd/conversion/plan.json +++ b/cmd/conversion/plan.json @@ -1 +1 @@ -{"format_version":"1.2","terraform_version":"1.8.5","planned_values":{"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"sensitive_values":{}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"sensitive_values":{}},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":2,"values":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default/epg-new_epg","name":"new_epg","parent_dn":"uni/tn-common/ap-default","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"sensitive_values":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":2,"values":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default222","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default222/epg-new_epg2","name":"new_epg2","parent_dn":"uni/tn-common/ap-default222","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"sensitive_values":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}]}},"resource_changes":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default/epg-new_epg","name":"new_epg","parent_dn":"uni/tn-common/ap-default","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"after_unknown":{"admin_state":true,"annotations":true,"epg_useg_block_statement":true,"has_mcast_source":true,"has_multicast_source":true,"intra_epg_isolation":true,"is_attr_based_epg":true,"match_criteria":true,"match_t":true,"name_alias":true,"pc_enf_pref":true,"pc_tag":true,"pref_gr_memb":true,"preferred_group_member":true,"prio":true,"priority":true,"relation_fv_rs_aepg_mon_pol":true,"relation_fv_rs_bd":true,"relation_fv_rs_cons":true,"relation_fv_rs_cons_if":true,"relation_fv_rs_cust_qos_pol":true,"relation_fv_rs_dpp_pol":true,"relation_fv_rs_fc_path_att":true,"relation_fv_rs_intra_epg":true,"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":true,"relation_fv_rs_prot_by":true,"relation_fv_rs_prov":true,"relation_fv_rs_sec_inherited":true,"relation_fv_rs_trust_ctrl":true,"relation_to_application_epg_monitoring_policy":true,"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":true,"relation_to_contract_masters":true,"relation_to_custom_qos_policy":true,"relation_to_data_plane_policing_policy":true,"relation_to_domains":true,"relation_to_fibre_channel_paths":true,"relation_to_imported_contracts":true,"relation_to_intra_epg_contracts":true,"relation_to_provided_contracts":true,"relation_to_static_leafs":true,"relation_to_static_paths":true,"relation_to_taboo_contracts":true,"relation_to_trust_control_policy":true,"shutdown":true,"tags":true,"useg_epg":true},"before_sensitive":false,"after_sensitive":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"tag_epg","application_profile_dn":"uni/tn-common/ap-default222","contract_exception_tag":"0","description":"from terraform","exception_tag":"0","flood_in_encapsulation":"disabled","flood_on_encap":"disabled","forwarding_control":"none","fwd_ctrl":"none","id":"uni/tn-common/ap-default222/epg-new_epg2","name":"new_epg2","parent_dn":"uni/tn-common/ap-default222","relation_fv_rs_node_att":[],"relation_to_bridge_domain":[{"annotation":"annotation1","bridge_domain_name":"default"}]},"after_unknown":{"admin_state":true,"annotations":true,"epg_useg_block_statement":true,"has_mcast_source":true,"has_multicast_source":true,"intra_epg_isolation":true,"is_attr_based_epg":true,"match_criteria":true,"match_t":true,"name_alias":true,"pc_enf_pref":true,"pc_tag":true,"pref_gr_memb":true,"preferred_group_member":true,"prio":true,"priority":true,"relation_fv_rs_aepg_mon_pol":true,"relation_fv_rs_bd":true,"relation_fv_rs_cons":true,"relation_fv_rs_cons_if":true,"relation_fv_rs_cust_qos_pol":true,"relation_fv_rs_dpp_pol":true,"relation_fv_rs_fc_path_att":true,"relation_fv_rs_intra_epg":true,"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":true,"relation_fv_rs_prot_by":true,"relation_fv_rs_prov":true,"relation_fv_rs_sec_inherited":true,"relation_fv_rs_trust_ctrl":true,"relation_to_application_epg_monitoring_policy":true,"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":true,"relation_to_contract_masters":true,"relation_to_custom_qos_policy":true,"relation_to_data_plane_policing_policy":true,"relation_to_domains":true,"relation_to_fibre_channel_paths":true,"relation_to_imported_contracts":true,"relation_to_intra_epg_contracts":true,"relation_to_provided_contracts":true,"relation_to_static_leafs":true,"relation_to_static_paths":true,"relation_to_taboo_contracts":true,"relation_to_trust_control_policy":true,"shutdown":true,"tags":true,"useg_epg":true},"before_sensitive":false,"after_sensitive":{"annotations":[],"epg_useg_block_statement":[],"relation_fv_rs_cons":[],"relation_fv_rs_cons_if":[],"relation_fv_rs_fc_path_att":[],"relation_fv_rs_intra_epg":[],"relation_fv_rs_node_att":[],"relation_fv_rs_path_att":[],"relation_fv_rs_prot_by":[],"relation_fv_rs_prov":[],"relation_fv_rs_sec_inherited":[],"relation_to_application_epg_monitoring_policy":[],"relation_to_bridge_domain":[{}],"relation_to_consumed_contracts":[],"relation_to_contract_masters":[],"relation_to_custom_qos_policy":[],"relation_to_data_plane_policing_policy":[],"relation_to_domains":[],"relation_to_fibre_channel_paths":[],"relation_to_imported_contracts":[],"relation_to_intra_epg_contracts":[],"relation_to_provided_contracts":[],"relation_to_static_leafs":[],"relation_to_static_paths":[],"relation_to_taboo_contracts":[],"relation_to_trust_control_policy":[],"tags":[]}}}],"configuration":{"provider_config":{"aci":{"name":"aci","full_name":"registry.terraform.io/ciscodevnet/aci","expressions":{"insecure":{"constant_value":true},"password":{"constant_value":"ins3965!"},"url":{"constant_value":"https://173.36.219.79"},"username":{"constant_value":"admin"}}}},"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_key"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name"},"value":{"constant_value":"test_value"}},"schema_version":0},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_keya"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]"},"value":{"constant_value":"test_valuea"}},"schema_version":0},{"address":"aci_application_epg.fooapplication_epg","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"tag_epg"},"contract_exception_tag":{"constant_value":"0"},"description":{"constant_value":"from terraform"},"flood_in_encapsulation":{"constant_value":"disabled"},"forwarding_control":{"constant_value":"none"},"name":{"constant_value":"new_epg"},"parent_dn":{"constant_value":"uni/tn-common/ap-default"},"relation_to_bridge_domain":{"constant_value":[{"annotation":"annotation1","bridge_domain_name":"default"}]}},"schema_version":2},{"address":"aci_application_epg.fooapplication_epg2","mode":"managed","type":"aci_application_epg","name":"fooapplication_epg2","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"tag_epg"},"contract_exception_tag":{"constant_value":"0"},"description":{"constant_value":"from terraform"},"flood_in_encapsulation":{"constant_value":"disabled"},"forwarding_control":{"constant_value":"none"},"name":{"constant_value":"new_epg2"},"parent_dn":{"constant_value":"uni/tn-common/ap-default222"},"relation_to_bridge_domain":{"constant_value":[{"annotation":"annotation1","bridge_domain_name":"default"}]}},"schema_version":2}]}},"timestamp":"2024-08-21T21:02:04Z","applyable":true,"complete":true,"errored":false} +{"format_version":"1.2","terraform_version":"1.8.5","planned_values":{"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"sensitive_values":{}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"sensitive_values":{}},{"address":"aci_pim_route_map_policy.full_example_tenant","mode":"managed","type":"aci_pim_route_map_policy","name":"full_example_tenant","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"annotation":"annotation","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","id":"uni/tn-demo_tenant/rtmap-test_name","name":"test_name","name_alias":"name_alias","owner_key":"owner_key","owner_tag":"owner_tag","parent_dn":"uni/tn-demo_tenant","tags":[{"key":"key_0","value":"value_1"}]},"sensitive_values":{"annotations":[{}],"tags":[{}]}}]}},"resource_changes":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_pim_route_map_policy.full_example_tenant","mode":"managed","type":"aci_pim_route_map_policy","name":"full_example_tenant","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"annotation","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","id":"uni/tn-demo_tenant/rtmap-test_name","name":"test_name","name_alias":"name_alias","owner_key":"owner_key","owner_tag":"owner_tag","parent_dn":"uni/tn-demo_tenant","tags":[{"key":"key_0","value":"value_1"}]},"after_unknown":{},"before_sensitive":false,"after_sensitive":{"annotations":[{}],"tags":[{}]}}}],"configuration":{"provider_config":{"aci":{"name":"aci","full_name":"registry.terraform.io/ciscodevnet/aci","expressions":{"insecure":{"constant_value":true},"password":{"constant_value":"ins3965!"},"url":{"constant_value":"https://173.36.219.79"},"username":{"constant_value":"admin"}}}},"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_key"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name"},"value":{"constant_value":"test_value"}},"schema_version":0},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_keya"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]"},"value":{"constant_value":"test_valuea"}},"schema_version":0},{"address":"aci_pim_route_map_policy.full_example_tenant","mode":"managed","type":"aci_pim_route_map_policy","name":"full_example_tenant","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"annotation"},"annotations":{"constant_value":[{"key":"key_0","value":"value_1"}]},"description":{"constant_value":"description"},"name":{"constant_value":"test_name"},"name_alias":{"constant_value":"name_alias"},"owner_key":{"constant_value":"owner_key"},"owner_tag":{"constant_value":"owner_tag"},"parent_dn":{"constant_value":"uni/tn-demo_tenant"},"tags":{"constant_value":[{"key":"key_0","value":"value_1"}]}},"schema_version":0}]}},"timestamp":"2024-08-22T04:31:24Z","applyable":true,"complete":true,"errored":false} diff --git a/convert_funcs/dn_to_aci.go b/convert_funcs/dn_to_aci.go deleted file mode 100644 index 85fe7de78..000000000 --- a/convert_funcs/dn_to_aci.go +++ /dev/null @@ -1,247 +0,0 @@ -package convert_funcs - -func dn_to_class(prefix string) string { - - mapping := map[string]string{ - - "tagAnnotation-rsHPathAtt": "infraRsHPathAtt", - - "tagTag-rsHPathAtt": "infraRsHPathAtt", - - "tagAnnotation-rscons": "fvRsCons", - - "tagTag-rscons": "fvRsCons", - - "mgmtRsOoBCons-instp": "mgmtInstP", - - "tagAnnotation-instp": "mgmtInstP", - - "tagTag-instp": "mgmtInstP", - - "tagAnnotation-rsmonitorToExporter": "netflowRsMonitorToExporter", - - "tagTag-rsmonitorToExporter": "netflowRsMonitorToExporter", - - "tagAnnotation-rtmap": "pimRouteMapPol", - - "tagTag-rtmap": "pimRouteMapPol", - - "tagAnnotation-crtrn": "fvCrtrn", - - "tagTag-crtrn": "fvCrtrn", - - "tagAnnotation-rsconsIf": "fvRsConsIf", - - "tagTag-rsconsIf": "fvRsConsIf", - - // "tagAnnotation-crtrn": "fvSCrtrn", - - // "tagTag-crtrn": "fvSCrtrn", - - "tagAnnotation-subnet": "mgmtSubnet", - - "tagTag-subnet": "mgmtSubnet", - - "tagAnnotation-qosdpppol": "qosDppPol", - - "tagTag-qosdpppol": "qosDppPol", - - "fvCrtrn-epg": "fvAEPg", - - "fvRsAEPgMonPol-epg": "fvAEPg", - - "fvRsBd-epg": "fvAEPg", - - "fvRsCons-epg": "fvAEPg", - - "fvRsConsIf-epg": "fvAEPg", - - "fvRsCustQosPol-epg": "fvAEPg", - - "fvRsDomAtt-epg": "fvAEPg", - - "fvRsDppPol-epg": "fvAEPg", - - "fvRsFcPathAtt-epg": "fvAEPg", - - "fvRsIntraEpg-epg": "fvAEPg", - - "fvRsNodeAtt-epg": "fvAEPg", - - "fvRsPathAtt-epg": "fvAEPg", - - "fvRsProtBy-epg": "fvAEPg", - - "fvRsProv-epg": "fvAEPg", - - "fvRsSecInherited-epg": "fvAEPg", - - "fvRsTrustCtrl-epg": "fvAEPg", - - "tagAnnotation-epg": "fvAEPg", - - "tagTag-epg": "fvAEPg", - - "tagAnnotation-dnsattr": "fvDnsAttr", - - "tagTag-dnsattr": "fvDnsAttr", - - "tagAnnotation-recordpol": "netflowRecordPol", - - "tagTag-recordpol": "netflowRecordPol", - - "fvFBRMember-fbrg": "fvFBRGroup", - - "fvFBRoute-fbrg": "fvFBRGroup", - - "tagAnnotation-fbrg": "fvFBRGroup", - - "tagTag-fbrg": "fvFBRGroup", - - "tagAnnotation-rsfcPathAtt": "fvRsFcPathAtt", - - "tagTag-rsfcPathAtt": "fvRsFcPathAtt", - - "tagAnnotation-pfx": "fvFBRoute", - - "tagTag-pfx": "fvFBRoute", - - "tagAnnotation-oobbrc": "vzOOBBrCP", - - "tagTag-oobbrc": "vzOOBBrCP", - - "tagAnnotation-qoscustom": "qosCustomPol", - - "tagTag-qoscustom": "qosCustomPol", - - "tagAnnotation-idgattr": "fvIdGroupAttr", - - "tagTag-idgattr": "fvIdGroupAttr", - - "tagAnnotation-rspathAtt": "fvRsPathAtt", - - "tagTag-rspathAtt": "fvRsPathAtt", - - "tagAnnotation-provlbl": "l3extProvLbl", - - "tagTag-provlbl": "l3extProvLbl", - - "tagAnnotation-trustctrlpol": "fhsTrustCtrlPol", - - "tagTag-trustctrlpol": "fhsTrustCtrlPol", - - "tagAnnotation-epiptag": "fvEpIpTag", - - "tagTag-epiptag": "fvEpIpTag", - - "tagAnnotation-epmactag": "fvEpMacTag", - - "tagTag-epmactag": "fvEpMacTag", - - "tagAnnotation-ipattr": "fvIpAttr", - - "tagTag-ipattr": "fvIpAttr", - - "tagAnnotation-nodesidp": "mplsNodeSidP", - - "tagTag-nodesidp": "mplsNodeSidP", - - "tagAnnotation-prof": "rtctrlProfile", - - "tagTag-prof": "rtctrlProfile", - - "tagAnnotation-rsprov": "fvRsProv", - - "tagTag-rsprov": "fvRsProv", - - "tagAnnotation-conslbl": "l3extConsLbl", - - "tagTag-conslbl": "l3extConsLbl", - - "netflowRsMonitorToExporter-monitorpol": "netflowMonitorPol", - - "netflowRsMonitorToRecord-monitorpol": "netflowMonitorPol", - - "tagAnnotation-monitorpol": "netflowMonitorPol", - - "tagTag-monitorpol": "netflowMonitorPol", - - "tagAnnotation-rsdomAtt": "fvRsDomAtt", - - "tagTag-rsdomAtt": "fvRsDomAtt", - - "tagAnnotation-rsooBCons": "mgmtRsOoBCons", - - "tagTag-rsooBCons": "mgmtRsOoBCons", - - "tagAnnotation-rsintraEpg": "fvRsIntraEpg", - - "tagTag-rsintraEpg": "fvRsIntraEpg", - - "tagAnnotation-rsprotBy": "fvRsProtBy", - - "tagTag-rsprotBy": "fvRsProtBy", - - "tagAnnotation-rsoutToFBRGroup": "l3extRsOutToFBRGroup", - - "tagTag-rsoutToFBRGroup": "l3extRsOutToFBRGroup", - - "fvRsCons-esg": "fvESg", - - "fvRsConsIf-esg": "fvESg", - - "fvRsIntraEpg-esg": "fvESg", - - "fvRsProv-esg": "fvESg", - - "fvRsScope-esg": "fvESg", - - "fvRsSecInherited-esg": "fvESg", - - "tagAnnotation-esg": "fvESg", - - "tagTag-esg": "fvESg", - - "tagAnnotation-macattr": "fvMacAttr", - - "tagTag-macattr": "fvMacAttr", - - "tagAnnotation-rssecInherited": "fvRsSecInherited", - - "tagTag-rssecInherited": "fvRsSecInherited", - - "tagAnnotation-rtmapentry": "pimRouteMapEntry", - - "tagTag-rtmapentry": "pimRouteMapEntry", - - "tagAnnotation-rsnodeAtt": "fvRsNodeAtt", - - "tagTag-rsnodeAtt": "fvRsNodeAtt", - - "tagAnnotation-nexthop": "fvFBRMember", - - "tagTag-nexthop": "fvFBRMember", - - "tagAnnotation-rsredistributePol": "l3extRsRedistributePol", - - "tagTag-rsredistributePol": "l3extRsRedistributePol", - - "tagAnnotation-vmattr": "fvVmAttr", - - "tagTag-vmattr": "fvVmAttr", - - "infraRsHPathAtt-hpaths": "infraHPathS", - - "infraRsPathToAccBaseGrp-hpaths": "infraHPathS", - - "tagAnnotation-hpaths": "infraHPathS", - - "tagTag-hpaths": "infraHPathS", - } - - if className, found := mapping[prefix]; found { - return className - } - - return "" -} diff --git a/convert_funcs/getAciClass.go b/convert_funcs/getAciClass.go index c2e22c14b..5ebc91ac0 100644 --- a/convert_funcs/getAciClass.go +++ b/convert_funcs/getAciClass.go @@ -1,53 +1,55 @@ package convert_funcs -func GetAciClass(prefix string) string { +type GetAciClass func(string) string + +func AciClassMap(prefix string) string { mapping := map[string]string{ - "rsHPathAtt": "infraRsHPathAtt", + "hpaths": "infraHPathS", + "macattr": "fvMacAttr", "rscons": "fvRsCons", - "instp": "mgmtInstP", + "trustctrlpol": "fhsTrustCtrlPol", + "conslbl": "l3extConsLbl", + "qoscustom": "qosCustomPol", + "ipattr": "fvIpAttr", + "recordpol": "netflowRecordPol", + "rsintraEpg": "fvRsIntraEpg", + "rspathAtt": "fvRsPathAtt", "rsmonitorToExporter": "netflowRsMonitorToExporter", - "rtmap": "pimRouteMapPol", + "rsprotBy": "fvRsProtBy", + "vmattr": "fvVmAttr", + "subnet": "mgmtSubnet", + "epmactag": "fvEpMacTag", + "fbrg": "fvFBRGroup", + "idgattr": "fvIdGroupAttr", "crtrn": "fvCrtrn", + "nexthop": "fvFBRMember", "rsconsIf": "fvRsConsIf", - //"crtrn": "fvSCrtrn", - "subnet": "mgmtSubnet", - "qosdpppol": "qosDppPol", - "epg": "fvAEPg", - "dnsattr": "fvDnsAttr", + "monitorpol": "netflowMonitorPol", + "epg": "fvAEPg", + "esg": "fvESg", + "rssecInherited": "fvRsSecInherited", + "rtmapentry": "pimRouteMapEntry", + "tagKey": "tagTag", + "rsoutToFBRGroup": "l3extRsOutToFBRGroup", + // "crtrn": "fvSCrtrn", + "rsredistributePol": "l3extRsRedistributePol", + "instp": "mgmtInstP", "annotationKey": "tagAnnotation", - "recordpol": "netflowRecordPol", - "fbrg": "fvFBRGroup", - "rsfcPathAtt": "fvRsFcPathAtt", - "pfx": "fvFBRoute", + "rsHPathAtt": "infraRsHPathAtt", + "qosdpppol": "qosDppPol", "oobbrc": "vzOOBBrCP", - "qoscustom": "qosCustomPol", - "idgattr": "fvIdGroupAttr", - "rspathAtt": "fvRsPathAtt", - "provlbl": "l3extProvLbl", - "trustctrlpol": "fhsTrustCtrlPol", - "epiptag": "fvEpIpTag", - "epmactag": "fvEpMacTag", - "ipattr": "fvIpAttr", + "pfx": "fvFBRoute", + "rsfcPathAtt": "fvRsFcPathAtt", + "rsprov": "fvRsProv", + "rsooBCons": "mgmtRsOoBCons", "nodesidp": "mplsNodeSidP", + "dnsattr": "fvDnsAttr", "prof": "rtctrlProfile", - "rsprov": "fvRsProv", - "conslbl": "l3extConsLbl", - "monitorpol": "netflowMonitorPol", "rsdomAtt": "fvRsDomAtt", - "rsooBCons": "mgmtRsOoBCons", - "rsintraEpg": "fvRsIntraEpg", - "rsprotBy": "fvRsProtBy", - "rsoutToFBRGroup": "l3extRsOutToFBRGroup", - "esg": "fvESg", - "macattr": "fvMacAttr", - "rssecInherited": "fvRsSecInherited", - "rtmapentry": "pimRouteMapEntry", "rsnodeAtt": "fvRsNodeAtt", - "tagKey": "tagTag", - "nexthop": "fvFBRMember", - "rsredistributePol": "l3extRsRedistributePol", - "vmattr": "fvVmAttr", - "hpaths": "infraHPathS", + "provlbl": "l3extProvLbl", + "epiptag": "fvEpIpTag", + "rtmap": "pimRouteMapPol", } if class, found := mapping[prefix]; found { diff --git a/convert_funcs/resourceMap.go b/convert_funcs/resourceMap.go index eb7ccd6f5..b7910b591 100644 --- a/convert_funcs/resourceMap.go +++ b/convert_funcs/resourceMap.go @@ -2,4 +2,51 @@ package convert_funcs type createFunc func(map[string]interface{}, string) map[string]interface{} -var ResourceMap = map[string]createFunc{} +var ResourceMap = map[string]createFunc{ + "aci_access_interface_override": CreateInfraHPathS, + "aci_epg_useg_mac_attribute": CreateFvMacAttr, + "aci_relation_to_consumed_contract": CreateFvRsCons, + "aci_trust_control_policy": CreateFhsTrustCtrlPol, + "aci_l3out_consumer_label": CreateL3extConsLbl, + "aci_custom_qos_policy": CreateQosCustomPol, + "aci_epg_useg_ip_attribute": CreateFvIpAttr, + "aci_netflow_record_policy": CreateNetflowRecordPol, + "aci_relation_to_intra_epg_contract": CreateFvRsIntraEpg, + "aci_relation_to_static_path": CreateFvRsPathAtt, + "aci_relation_to_netflow_exporter": CreateNetflowRsMonitorToExporter, + "aci_relation_to_taboo_contract": CreateFvRsProtBy, + "aci_epg_useg_vm_attribute": CreateFvVmAttr, + "aci_external_management_network_subnet": CreateMgmtSubnet, + "aci_endpoint_tag_mac": CreateFvEpMacTag, + "aci_vrf_fallback_route_group": CreateFvFBRGroup, + "aci_epg_useg_ad_group_attribute": CreateFvIdGroupAttr, + "aci_epg_useg_block_statement": CreateFvCrtrn, + "aci_vrf_fallback_route_group_member": CreateFvFBRMember, + "aci_relation_to_imported_contract": CreateFvRsConsIf, + "aci_netflow_monitor_policy": CreateNetflowMonitorPol, + "aci_application_epg": CreateFvAEPg, + "aci_endpoint_security_group": CreateFvESg, + "aci_relation_to_contract_master": CreateFvRsSecInherited, + "aci_pim_route_map_entry": CreatePimRouteMapEntry, + "aci_tag": CreateTagTag, + "aci_relation_to_vrf_fallback_route_group": CreateL3extRsOutToFBRGroup, + "aci_epg_useg_sub_block_statement": CreateFvSCrtrn, + "aci_l3out_redistribute_policy": CreateL3extRsRedistributePol, + "aci_external_management_network_instance_profile": CreateMgmtInstP, + "aci_annotation": CreateTagAnnotation, + //"aci_relation_to_host_path": CreateInfraRsHPathAtt, + "aci_data_plane_policing_policy": CreateQosDppPol, + "aci_out_of_band_contract": CreateVzOOBBrCP, + "aci_vrf_fallback_route": CreateFvFBRoute, + "aci_relation_to_fibre_channel_path": CreateFvRsFcPathAtt, + "aci_relation_to_provided_contract": CreateFvRsProv, + "aci_relation_to_consumed_out_of_band_contract": CreateMgmtRsOoBCons, + "aci_l3out_node_sid_profile": CreateMplsNodeSidP, + "aci_epg_useg_dns_attribute": CreateFvDnsAttr, + "aci_route_control_profile": CreateRtctrlProfile, + "aci_relation_to_domain": CreateFvRsDomAtt, + "aci_relation_to_static_leaf": CreateFvRsNodeAtt, + "aci_l3out_provider_label": CreateL3extProvLbl, + "aci_endpoint_tag_ip": CreateFvEpIpTag, + "aci_pim_route_map_policy": CreatePimRouteMapPol, +} diff --git a/gen/generator.go b/gen/generator.go index 9b41acffe..2afa66bb0 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -841,7 +841,7 @@ func main() { renderTemplateModels("resourceMap.go.tmpl", "resourceMap.go", conversionPath, data) renderTemplateModels("getAciClass.go.tmpl", "getAciClass.go", conversionPath, data) - renderTemplateModels("new.go.tmpl", "dn_to_aci.go", conversionPath, data) + //renderTemplateModels("new.go.tmpl", "dn_to_aci.go", conversionPath, data) } } diff --git a/gen/templates/getAciClass.go.tmpl b/gen/templates/getAciClass.go.tmpl index 7a3136294..a5ae3e891 100644 --- a/gen/templates/getAciClass.go.tmpl +++ b/gen/templates/getAciClass.go.tmpl @@ -1,9 +1,11 @@ package convert_funcs -func GetAciClass(prefix string) string { + +type GetAciClass func(string) string + +func AciClassMap(prefix string) string { mapping := map[string]string{ - - {{- range $pkgName, $model := .Models }} + {{- range $index, $model := .Models }} "{{ extractPrefix $model.RnFormat }}": "{{ lowercaseFirst $model.ResourceClassName }}", {{- end }} } diff --git a/gen/templates/new.go.tmpl b/gen/templates/new.go.tmpl index 00fe1471b..9b9300cfb 100644 --- a/gen/templates/new.go.tmpl +++ b/gen/templates/new.go.tmpl @@ -21,4 +21,4 @@ func dn_to_class(prefix string) string { } return "" -} \ No newline at end of file +} \ No newline at end of file diff --git a/gen/templates/resourceMap.go.tmpl b/gen/templates/resourceMap.go.tmpl index f7565c212..f17ad41c9 100644 --- a/gen/templates/resourceMap.go.tmpl +++ b/gen/templates/resourceMap.go.tmpl @@ -3,9 +3,7 @@ package convert_funcs type createFunc func(map[string]interface{}, string) map[string]interface{} var ResourceMap = map[string]createFunc{ - {{- if or (and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))) .Include}} {{- range $pkgName, $model := .Models }} "aci_{{ $model.ResourceName }}": Create{{ $model.ResourceClassName }}, {{- end }} - {{- end }} } \ No newline at end of file From c15ec82eb7b7d45889df78287845e3964219d56d Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Sun, 25 Aug 2024 11:51:23 -0700 Subject: [PATCH 04/10] [minor_changes] Revised converter, templates, and documentation --- README.md | 12 + cmd/conversion/main.go | 230 +++++++++++------- cmd/conversion/main.tf | 65 ++--- cmd/conversion/payload.json | 100 -------- cmd/conversion/plan.bin | Bin 4349 -> 0 bytes cmd/conversion/plan.json | 1 - ...erride.go => access_interface_override.go} | 2 - ...conversion_annotation.go => annotation.go} | 2 - ..._application_epg.go => application_epg.go} | 32 --- .../conversion_data_plane_policing_policy.go | 158 ------------ ...tom_qos_policy.go => custom_qos_policy.go} | 2 - convert_funcs/data_plane_policing_policy.go | 93 +++++++ ...ty_group.go => endpoint_security_group.go} | 17 -- ..._endpoint_tag_ip.go => endpoint_tag_ip.go} | 5 - ...ndpoint_tag_mac.go => endpoint_tag_mac.go} | 5 - ...bute.go => epg_useg_ad_group_attribute.go} | 2 - ...atement.go => epg_useg_block_statement.go} | 11 - ...attribute.go => epg_useg_dns_attribute.go} | 2 - ..._attribute.go => epg_useg_ip_attribute.go} | 5 - ...attribute.go => epg_useg_mac_attribute.go} | 2 - ...ent.go => epg_useg_sub_block_statement.go} | 5 - ..._attribute.go => epg_useg_vm_attribute.go} | 8 - ...al_management_network_instance_profile.go} | 5 - ... => external_management_network_subnet.go} | 2 - convert_funcs/getAciClass.go | 59 ----- ...sumer_label.go => l3out_consumer_label.go} | 8 - ...d_profile.go => l3out_node_sid_profile.go} | 5 - ...vider_label.go => l3out_provider_label.go} | 5 - ...policy.go => l3out_redistribute_policy.go} | 5 - ...or_policy.go => netflow_monitor_policy.go} | 2 - ...ord_policy.go => netflow_record_policy.go} | 2 - ...nd_contract.go => out_of_band_contract.go} | 14 -- ...te_map_entry.go => pim_route_map_entry.go} | 8 - ..._map_policy.go => pim_route_map_policy.go} | 2 - ...ct.go => relation_to_consumed_contract.go} | 5 - ...ation_to_consumed_out_of_band_contract.go} | 5 - ...ster.go => relation_to_contract_master.go} | 2 - ...ion_to_domain.go => relation_to_domain.go} | 47 ---- ...h.go => relation_to_fibre_channel_path.go} | 5 - ...ct.go => relation_to_imported_contract.go} | 5 - ...t.go => relation_to_intra_epg_contract.go} | 2 - ...ter.go => relation_to_netflow_exporter.go} | 2 - ...ct.go => relation_to_provided_contract.go} | 8 - ...tic_leaf.go => relation_to_static_leaf.go} | 8 - ...tic_path.go => relation_to_static_path.go} | 8 - ...tract.go => relation_to_taboo_contract.go} | 2 - ...> relation_to_vrf_fallback_route_group.go} | 2 - convert_funcs/resourceMap.go | 131 ++++++---- ...ol_profile.go => route_control_profile.go} | 8 - convert_funcs/{conversion_tag.go => tag.go} | 2 - ...trol_policy.go => trust_control_policy.go} | 20 -- ...allback_route.go => vrf_fallback_route.go} | 2 - ...e_group.go => vrf_fallback_route_group.go} | 2 - ....go => vrf_fallback_route_group_member.go} | 2 - dict/dict.go | 80 ++++++ gen/generator.go | 86 +++++-- gen/templates/conversion.go.tmpl | 68 +++--- gen/templates/datasource.go.tmpl | 2 +- gen/templates/getAciClass.go.tmpl | 18 -- gen/templates/new.go.tmpl | 24 -- gen/templates/resourceMap.go.tmpl | 12 +- 61 files changed, 550 insertions(+), 884 deletions(-) delete mode 100644 cmd/conversion/payload.json delete mode 100755 cmd/conversion/plan.bin delete mode 100644 cmd/conversion/plan.json rename convert_funcs/{conversion_access_interface_override.go => access_interface_override.go} (99%) rename convert_funcs/{conversion_annotation.go => annotation.go} (99%) rename convert_funcs/{conversion_application_epg.go => application_epg.go} (94%) delete mode 100644 convert_funcs/conversion_data_plane_policing_policy.go rename convert_funcs/{conversion_custom_qos_policy.go => custom_qos_policy.go} (99%) create mode 100644 convert_funcs/data_plane_policing_policy.go rename convert_funcs/{conversion_endpoint_security_group.go => endpoint_security_group.go} (93%) rename convert_funcs/{conversion_endpoint_tag_ip.go => endpoint_tag_ip.go} (96%) rename convert_funcs/{conversion_endpoint_tag_mac.go => endpoint_tag_mac.go} (96%) rename convert_funcs/{conversion_epg_useg_ad_group_attribute.go => epg_useg_ad_group_attribute.go} (99%) rename convert_funcs/{conversion_epg_useg_block_statement.go => epg_useg_block_statement.go} (91%) rename convert_funcs/{conversion_epg_useg_dns_attribute.go => epg_useg_dns_attribute.go} (99%) rename convert_funcs/{conversion_epg_useg_ip_attribute.go => epg_useg_ip_attribute.go} (96%) rename convert_funcs/{conversion_epg_useg_mac_attribute.go => epg_useg_mac_attribute.go} (99%) rename convert_funcs/{conversion_epg_useg_sub_block_statement.go => epg_useg_sub_block_statement.go} (97%) rename convert_funcs/{conversion_epg_useg_vm_attribute.go => epg_useg_vm_attribute.go} (94%) rename convert_funcs/{conversion_external_management_network_instance_profile.go => external_management_network_instance_profile.go} (97%) rename convert_funcs/{conversion_external_management_network_subnet.go => external_management_network_subnet.go} (99%) delete mode 100644 convert_funcs/getAciClass.go rename convert_funcs/{conversion_l3out_consumer_label.go => l3out_consumer_label.go} (94%) rename convert_funcs/{conversion_l3out_node_sid_profile.go => l3out_node_sid_profile.go} (96%) rename convert_funcs/{conversion_l3out_provider_label.go => l3out_provider_label.go} (97%) rename convert_funcs/{conversion_l3out_redistribute_policy.go => l3out_redistribute_policy.go} (97%) rename convert_funcs/{conversion_netflow_monitor_policy.go => netflow_monitor_policy.go} (99%) rename convert_funcs/{conversion_netflow_record_policy.go => netflow_record_policy.go} (99%) rename convert_funcs/{conversion_out_of_band_contract.go => out_of_band_contract.go} (88%) rename convert_funcs/{conversion_pim_route_map_entry.go => pim_route_map_entry.go} (94%) rename convert_funcs/{conversion_pim_route_map_policy.go => pim_route_map_policy.go} (99%) rename convert_funcs/{conversion_relation_to_consumed_contract.go => relation_to_consumed_contract.go} (96%) rename convert_funcs/{conversion_relation_to_consumed_out_of_band_contract.go => relation_to_consumed_out_of_band_contract.go} (96%) rename convert_funcs/{conversion_relation_to_contract_master.go => relation_to_contract_master.go} (99%) rename convert_funcs/{conversion_relation_to_domain.go => relation_to_domain.go} (70%) rename convert_funcs/{conversion_relation_to_fibre_channel_path.go => relation_to_fibre_channel_path.go} (96%) rename convert_funcs/{conversion_relation_to_imported_contract.go => relation_to_imported_contract.go} (96%) rename convert_funcs/{conversion_relation_to_intra_epg_contract.go => relation_to_intra_epg_contract.go} (99%) rename convert_funcs/{conversion_relation_to_netflow_exporter.go => relation_to_netflow_exporter.go} (99%) rename convert_funcs/{conversion_relation_to_provided_contract.go => relation_to_provided_contract.go} (93%) rename convert_funcs/{conversion_relation_to_static_leaf.go => relation_to_static_leaf.go} (93%) rename convert_funcs/{conversion_relation_to_static_path.go => relation_to_static_path.go} (93%) rename convert_funcs/{conversion_relation_to_taboo_contract.go => relation_to_taboo_contract.go} (99%) rename convert_funcs/{conversion_relation_to_vrf_fallback_route_group.go => relation_to_vrf_fallback_route_group.go} (99%) rename convert_funcs/{conversion_route_control_profile.go => route_control_profile.go} (93%) rename convert_funcs/{conversion_tag.go => tag.go} (99%) rename convert_funcs/{conversion_trust_control_policy.go => trust_control_policy.go} (83%) rename convert_funcs/{conversion_vrf_fallback_route.go => vrf_fallback_route.go} (99%) rename convert_funcs/{conversion_vrf_fallback_route_group.go => vrf_fallback_route_group.go} (99%) rename convert_funcs/{conversion_vrf_fallback_route_group_member.go => vrf_fallback_route_group_member.go} (99%) create mode 100644 dict/dict.go delete mode 100644 gen/templates/getAciClass.go.tmpl delete mode 100644 gen/templates/new.go.tmpl diff --git a/README.md b/README.md index daa9b5830..dd5c0e036 100644 --- a/README.md +++ b/README.md @@ -288,4 +288,16 @@ To compile the provider, run `make build`. This will build the provider with san NOTE: Currently only resource properties supports the reflecting manual changes made in CISCO ACI. Manual changes to relationship is not taken care by the provider. +### Payload Generation +To export a Terraform Plan as an ACI Payload: + +1. Navigate to conversion directory +$cd cmd/conversion + +2. Create your desired configuration in main.tf + +3. Run: +$ go run main.go + +4. Payload will be written to payload.json \ No newline at end of file diff --git a/cmd/conversion/main.go b/cmd/conversion/main.go index 61d702f53..dee41ac72 100644 --- a/cmd/conversion/main.go +++ b/cmd/conversion/main.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/CiscoDevNet/terraform-provider-aci/v2/convert_funcs" + "github.com/CiscoDevNet/terraform-provider-aci/v2/dict" ) type Plan struct { @@ -123,119 +124,182 @@ func createPayloadList(plan Plan) []map[string]interface{} { return data } -var lastValidNode map[string]interface{} +type TreeNode struct { + Attributes map[string]interface{} `json:"attributes,omitempty"` + Children map[string]*TreeNode `json:"children,omitempty"` + ClassName string `json:"-"` +} -// Work in progress... -func constructTree(resources []map[string]interface{}) map[string]interface{} { - rootNode := map[string]interface{}{ - "children": []map[string]interface{}{}, +func NewTreeNode(className string, attributes map[string]interface{}) *TreeNode { + return &TreeNode{ + ClassName: className, + Attributes: attributes, + Children: make(map[string]*TreeNode), } +} - nodeMap := map[string]map[string]interface{}{ - "uni": rootNode, - } +func constructTree(resources []map[string]interface{}) map[string]interface{} { + rootNode := NewTreeNode("uni", map[string]interface{}{"dn": "uni"}) + + dnMap := make(map[string]*TreeNode) + dnMap["uni"] = rootNode for _, resourceList := range resources { for resourceType, resourceData := range resourceList { resourceAttributes := resourceData.(map[string]interface{}) - attributes := resourceAttributes["attributes"].(map[string]interface{}) - dn := attributes["dn"].(string) - - parentDn, hasParentDn := attributes["parent_dn"].(string) - if !hasParentDn || parentDn == "" { - pathSegments := strings.Split(dn, "/") - if len(pathSegments) > 1 { - parentDn = strings.Join(pathSegments[:len(pathSegments)-1], "/") - } else { - parentDn = "uni" + attributes := safeMapInterface(resourceAttributes, "attributes") + dn := safeString(attributes, "dn") + + var children []map[string]interface{} + if rawChildren, ok := resourceAttributes["children"].([]interface{}); ok { + for _, child := range rawChildren { + if childMap, ok := child.(map[string]interface{}); ok { + children = append(children, childMap) + } } } - createParentPath(nodeMap, parentDn) + buildParentPath(dnMap, rootNode, resourceType, dn, attributes, children) + } + } - currentNode, nodeExists := nodeMap[dn] - if !nodeExists { - currentNode = map[string]interface{}{ - "attributes": attributes, - "children": resourceAttributes["children"], - } - } else { + return map[string]interface{}{rootNode.ClassName: exportTree(rootNode)} +} - existingChildren, ok := currentNode["children"].([]map[string]interface{}) - if !ok || existingChildren == nil { - existingChildren = []map[string]interface{}{} - } +func buildParentPath(dnMap map[string]*TreeNode, rootNode *TreeNode, resourceType, dn string, attributes map[string]interface{}, children []map[string]interface{}) { + if dn == "" && resourceType == "" { + return + } - newChildren, ok := resourceAttributes["children"].([]map[string]interface{}) - if ok && newChildren != nil { - currentNode["children"] = append(existingChildren, newChildren...) - } else { - currentNode["children"] = existingChildren - } - } + cursor := rootNode + if dn != "" { + cursor = traverseOrCreatePath(dnMap, rootNode, resourceType, dn) + } + + var leafNode *TreeNode + if existingLeafNode, exists := dnMap[dn]; exists { + + for key, value := range attributes { + existingLeafNode.Attributes[key] = value + } + leafNode = existingLeafNode + } else { + leafNode = NewTreeNode(resourceType, attributes) + cursor.Children[dn] = leafNode + dnMap[dn] = leafNode + } - parentNode := nodeMap[parentDn] + for _, child := range children { + for childClassName, childData := range child { + childAttributes := safeMapInterface(childData.(map[string]interface{}), "attributes") + childDn := safeString(childAttributes, "dn") - parentChildren, ok := parentNode["children"].([]map[string]interface{}) - if !ok || parentChildren == nil { - parentChildren = []map[string]interface{}{} + childKey := childDn + if childDn == "" { + childKey = generateUniqueKeyForNonDnNode(childClassName, childAttributes) } - parentNode["children"] = append(parentChildren, map[string]interface{}{resourceType: currentNode}) + if _, exists := leafNode.Children[childKey]; !exists { + childNode := NewTreeNode(childClassName, childAttributes) + leafNode.Children[childKey] = childNode + dnMap[childKey] = childNode + } - nodeMap[dn] = currentNode + if grandChildren, ok := childData.(map[string]interface{})["children"].([]interface{}); ok { + for _, grandchild := range grandChildren { + if grandchildMap, ok := grandchild.(map[string]interface{}); ok { + buildParentPath(dnMap, leafNode, childClassName, childDn, safeMapInterface(grandchildMap, "attributes"), []map[string]interface{}{grandchildMap}) + } + } + } } } +} - return map[string]interface{}{ - "uni": rootNode, - } +func generateUniqueKeyForNonDnNode(resourceType string, attributes map[string]interface{}) string { + return fmt.Sprintf("%s-%v", resourceType, attributes["name"]) } -func createParentPath(nodeMap map[string]map[string]interface{}, parentDn string) { - pathSegments := strings.Split(parentDn, "/") - currentDn := "uni" +func traverseOrCreatePath(dnMap map[string]*TreeNode, rootNode *TreeNode, resourceType, dn string) *TreeNode { + pathSegments := strings.Split(dn, "/") + cursor := rootNode + + classNames := parseClassNames(pathSegments, resourceType) + + for i := 1; i < len(pathSegments); i++ { + className := classNames[i-1] + currentDn := strings.Join(pathSegments[:i+1], "/") + + if existingNode, exists := dnMap[currentDn]; exists { + cursor = existingNode + } else { + newNode := NewTreeNode(className, map[string]interface{}{ + "dn": currentDn, + }) + cursor.Children[currentDn] = newNode + cursor = newNode + dnMap[currentDn] = newNode + } + } - for _, segment := range pathSegments[1:] { - currentDn += "/" + segment + return cursor +} - className := convert_funcs.AciClassMap(strings.Split(segment, "-")[0]) +func parseClassNames(pathSegments []string, resourceType string) []string { + classNames := []string{resourceType} + for i := len(pathSegments) - 2; i >= 0; i-- { + prefix := strings.Split(pathSegments[i], "-")[0] + if pathSegments[i] == "uni" { + break + } + className := dict.GetDnToAciClassMap(classNames[len(classNames)-1], prefix) + classNames = append(classNames, className) + } - if className == "" { - //Intended to be 'continue' to skip intermediate segments in dn, currently causes error - className = segment + for i, j := 0, len(classNames)-1; i < j; i, j = i+1, j-1 { + classNames[i], classNames[j] = classNames[j], classNames[i] + } + return classNames - } +} - if _, exists := nodeMap[currentDn]; !exists { - newNode := map[string]interface{}{ - "attributes": map[string]interface{}{ - "dn": currentDn, - }, - "children": []map[string]interface{}{}, - } +func exportTree(node *TreeNode) map[string]interface{} { + if node == nil { + return nil + } - if lastValidNode == nil { - if _, ok := nodeMap["uni"]["children"]; !ok { - nodeMap["uni"]["children"] = []map[string]interface{}{} - } - nodeMap["uni"]["children"] = append(nodeMap["uni"]["children"].([]map[string]interface{}), map[string]interface{}{className: newNode}) - } else { - if _, ok := lastValidNode["children"]; !ok { - lastValidNode["children"] = []map[string]interface{}{} - } - lastValidNode["children"] = append(lastValidNode["children"].([]map[string]interface{}), map[string]interface{}{className: newNode}) - } + result := map[string]interface{}{ + "attributes": node.Attributes, + } - nodeMap[currentDn] = newNode + if len(node.Children) > 0 { + children := []map[string]interface{}{} + for _, child := range node.Children { + children = append(children, map[string]interface{}{ + child.ClassName: exportTree(child), + }) } + result["children"] = children + } + + return result +} - lastValidNode = nodeMap[currentDn] +func safeMapInterface(data map[string]interface{}, key string) map[string]interface{} { + if value, ok := data[key].(map[string]interface{}); ok { + return value } + return nil } -func main() { +func safeString(data map[string]interface{}, key string) string { + if value, ok := data[key].(string); ok { + return value + } + return "" +} +func main() { if len(os.Args) != 1 { fmt.Println("Usage: no arguments needed") os.Exit(1) @@ -255,17 +319,9 @@ func main() { payloadList := createPayloadList(plan) - jsonData, err := json.MarshalIndent(payloadList, "", " ") - if err != nil { - fmt.Println("Error:", err) - return - } - - fmt.Println(string(jsonData)) - - aciPayload := constructTree(payloadList) + aciTree := constructTree(payloadList) - err = writeToFile(outputFile, aciPayload) + err = writeToFile(outputFile, aciTree) if err != nil { log.Fatalf("Error writing output file: %v", err) } diff --git a/cmd/conversion/main.tf b/cmd/conversion/main.tf index 9e9c28d55..aea7400a4 100644 --- a/cmd/conversion/main.tf +++ b/cmd/conversion/main.tf @@ -9,18 +9,18 @@ terraform { # Configure the provider with your Cisco APIC credentials. provider "aci" { # APIC Username - username = " " + username = "" # APIC Password - password = " " + password = "" # APIC URL - url = " " + url = "" insecure = true } # Defines an Application EPG Resource. /* resource "aci_application_epg" "fooapplication_epg" { - parent_dn = "uni/tn-common/ap-default" + parent_dn = "uni/tn-mgmt/ap-default" name = "new_epg" description = "from terraform" annotation = "tag_epg" @@ -28,6 +28,18 @@ resource "aci_application_epg" "fooapplication_epg" { flood_in_encapsulation = "disabled" forwarding_control = "none" +} +*/ +/* +resource "aci_application_epg" "fooapplication_epg2" { + parent_dn = "uni/tn-common/ap-default222" + name = "new_epg2" + description = "from terraform" + annotation = "tag_epg" + contract_exception_tag = "0" + flood_in_encapsulation = "disabled" + forwarding_control = "none" + relation_to_bridge_domain= [{ annotation = "annotation1" bridge_domain_name = "default" @@ -35,9 +47,9 @@ resource "aci_application_epg" "fooapplication_epg" { } */ /* -resource "aci_application_epg" "fooapplication_epg2" { - parent_dn = "uni/tn-common/ap-default222" - name = "new_epg2" +resource "aci_application_epg" "fooapplication_epg5" { + parent_dn = "uni/tn-common/ap-default232" + name = "new_epg5" description = "from terraform" annotation = "tag_epg" contract_exception_tag = "0" @@ -49,10 +61,9 @@ resource "aci_application_epg" "fooapplication_epg2" { bridge_domain_name = "default" }] } - */ -# Define an ACI Tenant Resource. +# Define an ACI Tenant Resource. /* resource "aci_endpoint_tag_ip" "full_example_tenant" { parent_dn = "uni/tn-common" @@ -62,22 +73,11 @@ resource "aci_endpoint_tag_ip" "full_example_tenant" { ip = "10.0.0.2" name = "WOW" name_alias = "name_alias" - annotations = [ - { - key = "key_0" - value = "vaule_1" - } - ] - tags = [ - { - key = "key_0" - value = "value_1" - } - ] + } */ -//SUCCESS + /* resource "aci_vrf_fallback_route_group" "full_example_vrf" { parent_dn = "uni/tn-common" @@ -107,7 +107,8 @@ resource "aci_vrf_fallback_route_group" "full_example_vrf" { } ] } - +*/ +/* resource "aci_external_management_network_instance_profile" "full_example" { annotation = "woidid" description = "description" @@ -135,8 +136,8 @@ resource "aci_external_management_network_instance_profile" "full_example" { ] } */ -/* SUCCESS +/* resource "aci_external_management_network_instance_profile" "full_example333" { annotation = "annotation" description = "description" @@ -163,12 +164,12 @@ resource "aci_external_management_network_instance_profile" "full_example333" { } ] } - */ + /* resource "aci_netflow_monitor_policy" "full_example_tenant" { - parent_dn = "uni/tn-mgmt/extmgmt-default/instp-test_name" + parent_dn = "uni/tn-mgmt" annotation = "annotation" description = "description" name = "netfow_monitor" @@ -220,22 +221,22 @@ resource "aci_tag" "example_tenant" { //DEFINES AN ACI ANNOTATION ------- TEST - +/* resource "aci_annotation" "terraform_annotation" { parent_dn = "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name" key = "test_key" value = "test_value" } - - +*/ +/* resource "aci_annotation" "terraform_annotation2" { parent_dn = "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]" key = "test_keya" value = "test_valuea" } +*/ - - +/* resource "aci_pim_route_map_policy" "full_example_tenant" { parent_dn = "uni/tn-demo_tenant" annotation = "annotation" @@ -257,7 +258,7 @@ resource "aci_pim_route_map_policy" "full_example_tenant" { } ] } - +*/ # Define an ACI Tenant VRF Resource. # resource "aci_vrf" "terraform_vrf" { diff --git a/cmd/conversion/payload.json b/cmd/conversion/payload.json deleted file mode 100644 index f84e84906..000000000 --- a/cmd/conversion/payload.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "uni": { - "children": [ - { - "tn-common": { - "attributes": { - "dn": "uni/tn-common" - }, - "children": [ - { - "eptags": { - "attributes": { - "dn": "uni/tn-common/eptags" - }, - "children": [ - { - "fvEpIpTag": { - "attributes": { - "dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name" - }, - "children": [ - { - "tagAnnotation": { - "attributes": { - "dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]", - "key": "test_key", - "parent_dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name", - "status": "created", - "value": "test_value" - }, - "children": [ - { - "tagAnnotation": { - "attributes": { - "dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]", - "key": "test_keya", - "parent_dn": "uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]", - "status": "created", - "value": "test_valuea" - }, - "children": null - } - }, - { - "tn-demo_tenant": { - "attributes": { - "dn": "uni/tn-demo_tenant" - }, - "children": [ - { - "pimRouteMapPol": { - "attributes": { - "annotation": "annotation", - "descr": "description", - "dn": "uni/tn-demo_tenant/rtmap-test_name", - "name": "test_name", - "nameAlias": "name_alias", - "ownerKey": "owner_key", - "ownerTag": "owner_tag", - "parent_dn": "uni/tn-demo_tenant", - "status": "created" - }, - "children": [ - { - "tagAnnotation": { - "attributes": { - "key": "key_0", - "value": "value_1" - } - } - }, - { - "tagTag": { - "attributes": { - "key": "key_0", - "value": "value_1" - } - } - } - ] - } - } - ] - } - } - ] - } - } - ] - } - } - ] - } - } - ] - } - } - ] - } -} \ No newline at end of file diff --git a/cmd/conversion/plan.bin b/cmd/conversion/plan.bin deleted file mode 100755 index 3c5b96fb0d80b44dc1f8d201eba244ffc1ad809e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4349 zcmaKvc{tST`^N`aV(eq=yRlRxMkuoHl_entGuiiLtfB0Z!Ppsztl7fQL}Gl)QpUcQ zB|@?rBPWgc>ifISsnhj4=lxvIAI~4peckuxb6@ZKd6^hdodN;qPS!>>$1T7wq5+%+ z1UUP8BD`;!Qv)dY@ZHWeY4{{|4Ny##r!z1%8K`u=i1Yin|% z&5BoHQ3|6mIG?*Rkr}1q053(+HPdqs<{A2l565?e_=FrwxMd75e~geYwj=Fr6roj` zMqCW(AX;PK?$G;~%R97wpk@i~Z(yWRo@z1Msd%9>EW9P1xqgp!{3D34pu->=F5l(f z;Ks=VG&H&qy1(P^<0}_a({Xd$k}kuhL#Y;D$EaW@K5J>SdbkmAS7ff|*?*KcVM4&Kh{FNPLkjo#B*_)Soc>{kNz_ATl}W$UQm<|mA1O&T)0k5oDVIiF zh04Xu28{(@&2#%AXK6&}ssVAD1;5;?&LZ3#pVC(b&Tc0qE%3)Ar187ZXl{#eUkzw; zl4FJrCJyQ46I88j9(F1ISqtB2-%QF$^WskSKi2~MS&OuSYhD0G{_#k} zF*_kTdhd)#s#!7E;jF>p?&sMuKi|W_DF>C&TS%R5`)o32_tz>1?4&$HsCXevfd7b2n z{?~lj|Cg_WkGHd%%Xu&9^IixyZA(6woyCF>K6s!jgd9b&oR-4m;8}Y^g|*a?OXpn$cG;~8Vle6GZ@TltqsOXu<|wRv z!K0<<$T5DQ3Xa;!7h1e_`i`KY#iT}RdWd!h2;wFXlJ%r+9FxafGZn~`o(5EjeXv`B zi`C|Kx+@)|u^Zm+v?MInTWF2K9)6z9w?CdlzdSmun1I|^pW!V0+=jg> z1$POt2_9TnY12(=7GleN#VS9+fx6C-AFD!8%4fTfC?u{^b?z%oYLrV#IE_ci_!}K` zLOQ*JyPiz8iWbL(8YKkk>`2DM#|L81-lOFq22W&FV&P2=I&7kUyf^HWT45~*QZXdH zNopFqq<2>viM=X(hPnmD&TX0vFUgvuxcxASL+&^Oo(1nBnvF1IR4KE(LdjP8BI?&N08hm2#l66<-8H9ALxhJ+%IDT3_Hi z*K8lini`HcJw~O{P@Z{jsv6G!S?zT;xboAR<8Q0g9^GPPV&_ZD+MXx(4fD-%0c>Tr z5Dp15uW9f>tX64FvNW~&X_QxLCKGI!g>}+hBn^{NL^9In0`7#iSv|C~+ovj9NHW04 z7=)xk&V%N)cZ)e2vQXrO_Z+o$^%ytT&lYV#QImyQJ(FQSw#IozWH0nT=LLWlsOOw__lI z%%e#!?+Q%C?U9cI1XD8`JKpw;obZ12kMzxJ&$i^rvoDO(N{wu2!76kz<5xU<*WYPQ zJe`oEk!JHw<6c-m&$4NTsn1P+<`=h#bD()HcDJ)>_|~W~?=_~S)C#=3=XQ<^4k|gT+(AF7gdiE&epYJq5jv6 zO$9h@`ltD%2J3{NFK@7zALq_A%lB-S20MqQlo($O**60ldlcO3aQ0sWw$HB7a}(pN zTrSPgVX~$VQ1@LXr|IP8=0^!xpT?`Z4PP-pqqjZkcb zu;y3?pOIe49jEZ z^_O*vs7%M#(C#a~%nL=zA!k_)ZGxJoUovCwT07tlzD1SOFWpaQV08`sjCmM#A%{yp z#B$ILvdd`{U40oNiV>~m{C=GONTxZVUzFZRB|HDq?25_l+za9)BXSVjzc+JcLz^ZB z%-hiu2z(4h-B6bC=al~6$0mlkty0dbPyVf`pa?voa;m55Z zZ*Fi3^BFxtvMH1~AA_F)FKc+5iUBJhm%<(lWez1mxG4UKOl? zA(t%Yl()d&VFC%uSgRxIu>X{Jq=ETkE4TRKtI5FEmTpP$#;Vtl(e13Ql{1#_0IdO! zTd_4q!)KGWpxiNuW_RZM2OheE>AZ$Fad4;_mEBZQZdwQw&ptkRF?qIz3uaY#U6)r> zB%WclfhDU!^z7S`72$P~-y;&5%?ZDGQ7!n>KGk^*`zv>~C4z+4TNp)#IpA=K$6+v% z61hfCh)u6~K=Junk`bp1i@^}a_r7~oOQW4rUT*k7vp8Eh>!3I|yh0d4&~@KOOHmB_ zWKWB0(Ga=L*}d?wr0}4MZmm>`?3=64JR7IaGY>4?e{?YOG*;`(xNhVPW!cU>o2KKx zCZkzyiOLWS0Du?zw@J?Nx5?<^80hJQlyOJ;{CulE_+)1C{_j;{4*386gB+A!T zE=e7x3X!3Xvwmu&elmRj?-=Yz^!NmUJCrxfZWZ$-|OVb>rsO43({+*^7QG+bKMy zLnOeL(Syn5@P>%v`a;}$LFBaYw8V7b08Y)xb3gn_IF{7DK_mu}CO7vV_LPh-e07^H z+$U|$_H#~$h26pRNIR(6Kd@IE+$8#5@*$5}46dv=cn_+@7mxyik)%c94pvX#`Lx4P zgjzvrT`(RUOkTLVSrK?YJhYe8R{K4OJlT(HTOu|IKEf$Zd*MAoXrC)i@53t+RJ?p} z_&LvM-0YR6Iv&x({e+&v56eF7(}hQe#vx(h+nZG#|wlN zwe~P1x%xOKg0vZ2XP=UK*g^CT|N43x-*WFB{$2$BO8D_t;neLvdL}>27H)rE{Pxx8 z-5|5Q#YDa?LgSeR0;sC%PAqXbpn9QJ&-mrZ-Nd7M>Nkly2&#b-6O`a}h<$w{rv@+iQ85 zN_3Xo7A&0{;|b1sIpvfTQ!UBwY<$upteytQdwAW{k$QUioNZ34rBcQnyBpQ%G_i{! zXl3eiomzgBU!WQiF5>+Ce)Y9xltDm{j$A8~lBDHInF3F z!<%VEo=td~81R07@TxoAS=?z%z0(V3J#wdBxNHsOegOimIG$6PO2rLO3*Le$~~( zP)i{R1>NXHrms2*)J%Fw6tbhaMLabwUJJxc^Z>FT!bS7~TD+9;*+MJ6Qc~S2ck-gz!viVrX{heDIOq#E6vkmM-oA(dA6+TYpc6`&Q$Zi#= zBPCyoeFK?!3Nomn@;zOoGi^0gR+wQ2=xp16--5*~ zHNKIcpm2dAKBHkBv{t6n8v5p(o|{U2?#y_{v-szkavb|hV8kRvOt!*P-?ekgQW;Ma z+78)Aw6YtdfI>Y>n(n>Jkn#6p>DYA+Muu~)1d93)sL>XcmRPoj{cv~3izWUjLPf?r zhLKy3wto>6e{qnCk z^8>(sik1>^LgjzQvEOh13Ku_+=ch)0-u^oP{T||17ye;;KNWLQZ-DbZGs*9fezn#g wuKiO5^uI>>|2+KnSigSnzh}k9aKf?wV$CK-)F=N40H8Tpk4~7^fceMizhOs)u>b%7 diff --git a/cmd/conversion/plan.json b/cmd/conversion/plan.json deleted file mode 100644 index 6e7d65ccb..000000000 --- a/cmd/conversion/plan.json +++ /dev/null @@ -1 +0,0 @@ -{"format_version":"1.2","terraform_version":"1.8.5","planned_values":{"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"sensitive_values":{}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"sensitive_values":{}},{"address":"aci_pim_route_map_policy.full_example_tenant","mode":"managed","type":"aci_pim_route_map_policy","name":"full_example_tenant","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"annotation":"annotation","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","id":"uni/tn-demo_tenant/rtmap-test_name","name":"test_name","name_alias":"name_alias","owner_key":"owner_key","owner_tag":"owner_tag","parent_dn":"uni/tn-demo_tenant","tags":[{"key":"key_0","value":"value_1"}]},"sensitive_values":{"annotations":[{}],"tags":[{}]}}]}},"resource_changes":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","key":"test_key","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name","value":"test_value"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"id":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]/annotationKey-[test_keya]","key":"test_keya","parent_dn":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]","value":"test_valuea"},"after_unknown":{},"before_sensitive":false,"after_sensitive":{}}},{"address":"aci_pim_route_map_policy.full_example_tenant","mode":"managed","type":"aci_pim_route_map_policy","name":"full_example_tenant","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"annotation","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","id":"uni/tn-demo_tenant/rtmap-test_name","name":"test_name","name_alias":"name_alias","owner_key":"owner_key","owner_tag":"owner_tag","parent_dn":"uni/tn-demo_tenant","tags":[{"key":"key_0","value":"value_1"}]},"after_unknown":{},"before_sensitive":false,"after_sensitive":{"annotations":[{}],"tags":[{}]}}}],"configuration":{"provider_config":{"aci":{"name":"aci","full_name":"registry.terraform.io/ciscodevnet/aci","expressions":{"insecure":{"constant_value":true},"password":{"constant_value":"ins3965!"},"url":{"constant_value":"https://173.36.219.79"},"username":{"constant_value":"admin"}}}},"root_module":{"resources":[{"address":"aci_annotation.terraform_annotation","mode":"managed","type":"aci_annotation","name":"terraform_annotation","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_key"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name"},"value":{"constant_value":"test_value"}},"schema_version":0},{"address":"aci_annotation.terraform_annotation2","mode":"managed","type":"aci_annotation","name":"terraform_annotation2","provider_config_key":"aci","expressions":{"key":{"constant_value":"test_keya"},"parent_dn":{"constant_value":"uni/tn-common/eptags/epiptag-[10.0.0.2]-test_ctx_name/annotationKey-[test_key]"},"value":{"constant_value":"test_valuea"}},"schema_version":0},{"address":"aci_pim_route_map_policy.full_example_tenant","mode":"managed","type":"aci_pim_route_map_policy","name":"full_example_tenant","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"annotation"},"annotations":{"constant_value":[{"key":"key_0","value":"value_1"}]},"description":{"constant_value":"description"},"name":{"constant_value":"test_name"},"name_alias":{"constant_value":"name_alias"},"owner_key":{"constant_value":"owner_key"},"owner_tag":{"constant_value":"owner_tag"},"parent_dn":{"constant_value":"uni/tn-demo_tenant"},"tags":{"constant_value":[{"key":"key_0","value":"value_1"}]}},"schema_version":0}]}},"timestamp":"2024-08-22T04:31:24Z","applyable":true,"complete":true,"errored":false} diff --git a/convert_funcs/conversion_access_interface_override.go b/convert_funcs/access_interface_override.go similarity index 99% rename from convert_funcs/conversion_access_interface_override.go rename to convert_funcs/access_interface_override.go index f359c2b5e..47c59b31a 100644 --- a/convert_funcs/conversion_access_interface_override.go +++ b/convert_funcs/access_interface_override.go @@ -41,7 +41,6 @@ func CreateInfraHPathS(attributes map[string]interface{}, status string) map[str planTagTag := convertToTagTagInfraHPathS(attributes["tags"]) if status == "deleted" { - provider.SetInfraHPathSId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "infraHPathS", data.Id.ValueString()) @@ -51,7 +50,6 @@ func CreateInfraHPathS(attributes map[string]interface{}, status string) map[str json.Unmarshal(jsonPayload, &customData) return customData } - } newAciInfraHPathS := provider.GetInfraHPathSCreateJsonPayload(ctx, &diags, true, data, planInfraRsHPathAtt, planInfraRsHPathAtt, planInfraRsPathToAccBaseGrp, planInfraRsPathToAccBaseGrp, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_annotation.go b/convert_funcs/annotation.go similarity index 99% rename from convert_funcs/conversion_annotation.go rename to convert_funcs/annotation.go index 5926aeb5a..407c3ba13 100644 --- a/convert_funcs/conversion_annotation.go +++ b/convert_funcs/annotation.go @@ -25,7 +25,6 @@ func CreateTagAnnotation(attributes map[string]interface{}, status string) map[s } if status == "deleted" { - provider.SetTagAnnotationId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "tagAnnotation", data.Id.ValueString()) @@ -35,7 +34,6 @@ func CreateTagAnnotation(attributes map[string]interface{}, status string) map[s json.Unmarshal(jsonPayload, &customData) return customData } - } newAciTagAnnotation := provider.GetTagAnnotationCreateJsonPayload(ctx, &diags, true, data) diff --git a/convert_funcs/conversion_application_epg.go b/convert_funcs/application_epg.go similarity index 94% rename from convert_funcs/conversion_application_epg.go rename to convert_funcs/application_epg.go index 85934689f..286853671 100644 --- a/convert_funcs/conversion_application_epg.go +++ b/convert_funcs/application_epg.go @@ -26,42 +26,12 @@ func CreateFvAEPg(attributes map[string]interface{}, status string) map[string]i if v, ok := attributes["contract_exception_tag"].(string); ok && v != "" { data.ExceptionTag = types.StringValue(v) } - if v, ok := attributes["flood_in_encapsulation"].(string); ok && v != "" { - data.FloodOnEncap = types.StringValue(v) - } - if v, ok := attributes["forwarding_control"].(string); ok && v != "" { - data.FwdCtrl = types.StringValue(v) - } - if v, ok := attributes["has_multicast_source"].(string); ok && v != "" { - data.HasMcastSource = types.StringValue(v) - } - if v, ok := attributes["useg_epg"].(string); ok && v != "" { - data.IsAttrBasedEPg = types.StringValue(v) - } - if v, ok := attributes["match_criteria"].(string); ok && v != "" { - data.MatchT = types.StringValue(v) - } if v, ok := attributes["name"].(string); ok && v != "" { data.Name = types.StringValue(v) } if v, ok := attributes["name_alias"].(string); ok && v != "" { data.NameAlias = types.StringValue(v) } - if v, ok := attributes["intra_epg_isolation"].(string); ok && v != "" { - data.PcEnfPref = types.StringValue(v) - } - if v, ok := attributes["pc_tag"].(string); ok && v != "" { - data.PcTag = types.StringValue(v) - } - if v, ok := attributes["preferred_group_member"].(string); ok && v != "" { - data.PrefGrMemb = types.StringValue(v) - } - if v, ok := attributes["priority"].(string); ok && v != "" { - data.Prio = types.StringValue(v) - } - if v, ok := attributes["admin_state"].(string); ok && v != "" { - data.Shutdown = types.StringValue(v) - } planFvCrtrn := convertToFvCrtrnFvAEPg(attributes["epg_useg_block_statement"]) planFvRsAEPgMonPol := convertToFvRsAEPgMonPolFvAEPg(attributes["relation_to_application_epg_monitoring_policy"]) planFvRsBd := convertToFvRsBdFvAEPg(attributes["relation_to_bridge_domain"]) @@ -82,7 +52,6 @@ func CreateFvAEPg(attributes map[string]interface{}, status string) map[string]i planTagTag := convertToTagTagFvAEPg(attributes["tags"]) if status == "deleted" { - provider.SetFvAEPgId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvAEPg", data.Id.ValueString()) @@ -92,7 +61,6 @@ func CreateFvAEPg(attributes map[string]interface{}, status string) map[string]i json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvAEPg := provider.GetFvAEPgCreateJsonPayload(ctx, &diags, true, data, planFvCrtrn, planFvCrtrn, planFvRsAEPgMonPol, planFvRsAEPgMonPol, planFvRsBd, planFvRsBd, planFvRsCons, planFvRsCons, planFvRsConsIf, planFvRsConsIf, planFvRsCustQosPol, planFvRsCustQosPol, planFvRsDomAtt, planFvRsDomAtt, planFvRsDppPol, planFvRsDppPol, planFvRsFcPathAtt, planFvRsFcPathAtt, planFvRsIntraEpg, planFvRsIntraEpg, planFvRsNodeAtt, planFvRsNodeAtt, planFvRsPathAtt, planFvRsPathAtt, planFvRsProtBy, planFvRsProtBy, planFvRsProv, planFvRsProv, planFvRsSecInherited, planFvRsSecInherited, planFvRsTrustCtrl, planFvRsTrustCtrl, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_data_plane_policing_policy.go b/convert_funcs/conversion_data_plane_policing_policy.go deleted file mode 100644 index 5dbc3c78f..000000000 --- a/convert_funcs/conversion_data_plane_policing_policy.go +++ /dev/null @@ -1,158 +0,0 @@ -package convert_funcs - -import ( - "context" - "encoding/json" - - "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" - "github.com/ciscoecosystem/aci-go-client/v2/container" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func CreateQosDppPol(attributes map[string]interface{}, status string) map[string]interface{} { - ctx := context.Background() - var diags diag.Diagnostics - data := &provider.QosDppPolResourceModel{} - if v, ok := attributes["parent_dn"].(string); ok && v != "" { - data.ParentDn = types.StringValue(v) - } - if v, ok := attributes["admin_state"].(string); ok && v != "" { - data.AdminSt = types.StringValue(v) - } - if v, ok := attributes["annotation"].(string); ok && v != "" { - data.Annotation = types.StringValue(v) - } - if v, ok := attributes["excessive_burst"].(string); ok && v != "" { - data.Be = types.StringValue(v) - } - if v, ok := attributes["excessive_burst_unit"].(string); ok && v != "" { - data.BeUnit = types.StringValue(v) - } - if v, ok := attributes["burst"].(string); ok && v != "" { - data.Burst = types.StringValue(v) - } - if v, ok := attributes["burst_unit"].(string); ok && v != "" { - data.BurstUnit = types.StringValue(v) - } - if v, ok := attributes["conform_action"].(string); ok && v != "" { - data.ConformAction = types.StringValue(v) - } - if v, ok := attributes["conform_mark_cos"].(string); ok && v != "" { - data.ConformMarkCos = types.StringValue(v) - } - if v, ok := attributes["conform_mark_dscp"].(string); ok && v != "" { - data.ConformMarkDscp = types.StringValue(v) - } - if v, ok := attributes["description"].(string); ok && v != "" { - data.Descr = types.StringValue(v) - } - if v, ok := attributes["exceed_action"].(string); ok && v != "" { - data.ExceedAction = types.StringValue(v) - } - if v, ok := attributes["exceed_mark_cos"].(string); ok && v != "" { - data.ExceedMarkCos = types.StringValue(v) - } - if v, ok := attributes["exceed_mark_dscp"].(string); ok && v != "" { - data.ExceedMarkDscp = types.StringValue(v) - } - if v, ok := attributes["mode"].(string); ok && v != "" { - data.Mode = types.StringValue(v) - } - if v, ok := attributes["name"].(string); ok && v != "" { - data.Name = types.StringValue(v) - } - if v, ok := attributes["name_alias"].(string); ok && v != "" { - data.NameAlias = types.StringValue(v) - } - if v, ok := attributes["owner_key"].(string); ok && v != "" { - data.OwnerKey = types.StringValue(v) - } - if v, ok := attributes["owner_tag"].(string); ok && v != "" { - data.OwnerTag = types.StringValue(v) - } - if v, ok := attributes["peak_rate"].(string); ok && v != "" { - data.Pir = types.StringValue(v) - } - if v, ok := attributes["peak_rate_unit"].(string); ok && v != "" { - data.PirUnit = types.StringValue(v) - } - if v, ok := attributes["rate"].(string); ok && v != "" { - data.Rate = types.StringValue(v) - } - if v, ok := attributes["rate_unit"].(string); ok && v != "" { - data.RateUnit = types.StringValue(v) - } - if v, ok := attributes["sharing_mode"].(string); ok && v != "" { - data.SharingMode = types.StringValue(v) - } - if v, ok := attributes["type"].(string); ok && v != "" { - data.Type = types.StringValue(v) - } - if v, ok := attributes["violate_action"].(string); ok && v != "" { - data.ViolateAction = types.StringValue(v) - } - if v, ok := attributes["violate_mark_cos"].(string); ok && v != "" { - data.ViolateMarkCos = types.StringValue(v) - } - if v, ok := attributes["violate_mark_dscp"].(string); ok && v != "" { - data.ViolateMarkDscp = types.StringValue(v) - } - planTagAnnotation := convertToTagAnnotationQosDppPol(attributes["annotations"]) - planTagTag := convertToTagTagQosDppPol(attributes["tags"]) - - if status == "deleted" { - - provider.SetQosDppPolId(ctx, data) - - deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "qosDppPol", data.Id.ValueString()) - if deletePayload != nil { - jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) - var customData map[string]interface{} - json.Unmarshal(jsonPayload, &customData) - return customData - } - - } - - newAciQosDppPol := provider.GetQosDppPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) - - jsonPayload := newAciQosDppPol.EncodeJSON(container.EncodeOptIndent("", " ")) - - var customData map[string]interface{} - json.Unmarshal(jsonPayload, &customData) - - payload := customData - - provider.SetQosDppPolId(ctx, data) - attrs := payload["qosDppPol"].(map[string]interface{})["attributes"].(map[string]interface{}) - attrs["dn"] = data.Id.ValueString() - - return payload -} -func convertToTagAnnotationQosDppPol(resources interface{}) []provider.TagAnnotationQosDppPolResourceModel { - var planResources []provider.TagAnnotationQosDppPolResourceModel - if resources, ok := resources.([]interface{}); ok { - for _, resource := range resources { - resourceMap := resource.(map[string]interface{}) - planResources = append(planResources, provider.TagAnnotationQosDppPolResourceModel{ - Key: types.StringValue(resourceMap["key"].(string)), - Value: types.StringValue(resourceMap["value"].(string)), - }) - } - } - return planResources -} -func convertToTagTagQosDppPol(resources interface{}) []provider.TagTagQosDppPolResourceModel { - var planResources []provider.TagTagQosDppPolResourceModel - if resources, ok := resources.([]interface{}); ok { - for _, resource := range resources { - resourceMap := resource.(map[string]interface{}) - planResources = append(planResources, provider.TagTagQosDppPolResourceModel{ - Key: types.StringValue(resourceMap["key"].(string)), - Value: types.StringValue(resourceMap["value"].(string)), - }) - } - } - return planResources -} diff --git a/convert_funcs/conversion_custom_qos_policy.go b/convert_funcs/custom_qos_policy.go similarity index 99% rename from convert_funcs/conversion_custom_qos_policy.go rename to convert_funcs/custom_qos_policy.go index 83a34c3a1..4ca632370 100644 --- a/convert_funcs/conversion_custom_qos_policy.go +++ b/convert_funcs/custom_qos_policy.go @@ -39,7 +39,6 @@ func CreateQosCustomPol(attributes map[string]interface{}, status string) map[st planTagTag := convertToTagTagQosCustomPol(attributes["tags"]) if status == "deleted" { - provider.SetQosCustomPolId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "qosCustomPol", data.Id.ValueString()) @@ -49,7 +48,6 @@ func CreateQosCustomPol(attributes map[string]interface{}, status string) map[st json.Unmarshal(jsonPayload, &customData) return customData } - } newAciQosCustomPol := provider.GetQosCustomPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/data_plane_policing_policy.go b/convert_funcs/data_plane_policing_policy.go new file mode 100644 index 000000000..5890c2f1b --- /dev/null +++ b/convert_funcs/data_plane_policing_policy.go @@ -0,0 +1,93 @@ +package convert_funcs + +import ( + "context" + "encoding/json" + + "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func CreateQosDppPol(attributes map[string]interface{}, status string) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.QosDppPolResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationQosDppPol(attributes["annotations"]) + planTagTag := convertToTagTagQosDppPol(attributes["tags"]) + + if status == "deleted" { + provider.SetQosDppPolId(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "qosDppPol", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } + } + + newAciQosDppPol := provider.GetQosDppPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciQosDppPol.EncodeJSON(container.EncodeOptIndent("", " ")) + + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + + payload := customData + + provider.SetQosDppPolId(ctx, data) + attrs := payload["qosDppPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + return payload +} +func convertToTagAnnotationQosDppPol(resources interface{}) []provider.TagAnnotationQosDppPolResourceModel { + var planResources []provider.TagAnnotationQosDppPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationQosDppPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagQosDppPol(resources interface{}) []provider.TagTagQosDppPolResourceModel { + var planResources []provider.TagTagQosDppPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagQosDppPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_endpoint_security_group.go b/convert_funcs/endpoint_security_group.go similarity index 93% rename from convert_funcs/conversion_endpoint_security_group.go rename to convert_funcs/endpoint_security_group.go index 6d25ebfcf..fcb0694af 100644 --- a/convert_funcs/conversion_endpoint_security_group.go +++ b/convert_funcs/endpoint_security_group.go @@ -26,27 +26,12 @@ func CreateFvESg(attributes map[string]interface{}, status string) map[string]in if v, ok := attributes["exception_tag"].(string); ok && v != "" { data.ExceptionTag = types.StringValue(v) } - if v, ok := attributes["match_criteria"].(string); ok && v != "" { - data.MatchT = types.StringValue(v) - } if v, ok := attributes["name"].(string); ok && v != "" { data.Name = types.StringValue(v) } if v, ok := attributes["name_alias"].(string); ok && v != "" { data.NameAlias = types.StringValue(v) } - if v, ok := attributes["intra_esg_isolation"].(string); ok && v != "" { - data.PcEnfPref = types.StringValue(v) - } - if v, ok := attributes["pc_tag"].(string); ok && v != "" { - data.PcTag = types.StringValue(v) - } - if v, ok := attributes["preferred_group_member"].(string); ok && v != "" { - data.PrefGrMemb = types.StringValue(v) - } - if v, ok := attributes["admin_state"].(string); ok && v != "" { - data.Shutdown = types.StringValue(v) - } planFvRsCons := convertToFvRsConsFvESg(attributes["relation_to_consumed_contracts"]) planFvRsConsIf := convertToFvRsConsIfFvESg(attributes["relation_to_imported_contracts"]) planFvRsIntraEpg := convertToFvRsIntraEpgFvESg(attributes["relation_to_intra_epg_contracts"]) @@ -57,7 +42,6 @@ func CreateFvESg(attributes map[string]interface{}, status string) map[string]in planTagTag := convertToTagTagFvESg(attributes["tags"]) if status == "deleted" { - provider.SetFvESgId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvESg", data.Id.ValueString()) @@ -67,7 +51,6 @@ func CreateFvESg(attributes map[string]interface{}, status string) map[string]in json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvESg := provider.GetFvESgCreateJsonPayload(ctx, &diags, true, data, planFvRsCons, planFvRsCons, planFvRsConsIf, planFvRsConsIf, planFvRsIntraEpg, planFvRsIntraEpg, planFvRsProv, planFvRsProv, planFvRsScope, planFvRsScope, planFvRsSecInherited, planFvRsSecInherited, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_endpoint_tag_ip.go b/convert_funcs/endpoint_tag_ip.go similarity index 96% rename from convert_funcs/conversion_endpoint_tag_ip.go rename to convert_funcs/endpoint_tag_ip.go index 30d5a9241..d7826bebc 100644 --- a/convert_funcs/conversion_endpoint_tag_ip.go +++ b/convert_funcs/endpoint_tag_ip.go @@ -23,9 +23,6 @@ func CreateFvEpIpTag(attributes map[string]interface{}, status string) map[strin if v, ok := attributes["vrf_name"].(string); ok && v != "" { data.CtxName = types.StringValue(v) } - if v, ok := attributes["id_attribute"].(string); ok && v != "" { - data.FvEpIpTagId = types.StringValue(v) - } if v, ok := attributes["ip"].(string); ok && v != "" { data.Ip = types.StringValue(v) } @@ -39,7 +36,6 @@ func CreateFvEpIpTag(attributes map[string]interface{}, status string) map[strin planTagTag := convertToTagTagFvEpIpTag(attributes["tags"]) if status == "deleted" { - provider.SetFvEpIpTagId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvEpIpTag", data.Id.ValueString()) @@ -49,7 +45,6 @@ func CreateFvEpIpTag(attributes map[string]interface{}, status string) map[strin json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvEpIpTag := provider.GetFvEpIpTagCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_endpoint_tag_mac.go b/convert_funcs/endpoint_tag_mac.go similarity index 96% rename from convert_funcs/conversion_endpoint_tag_mac.go rename to convert_funcs/endpoint_tag_mac.go index 4d1e0b767..7a5425167 100644 --- a/convert_funcs/conversion_endpoint_tag_mac.go +++ b/convert_funcs/endpoint_tag_mac.go @@ -23,9 +23,6 @@ func CreateFvEpMacTag(attributes map[string]interface{}, status string) map[stri if v, ok := attributes["bd_name"].(string); ok && v != "" { data.BdName = types.StringValue(v) } - if v, ok := attributes["id_attribute"].(string); ok && v != "" { - data.FvEpMacTagId = types.StringValue(v) - } if v, ok := attributes["mac"].(string); ok && v != "" { data.Mac = types.StringValue(v) } @@ -39,7 +36,6 @@ func CreateFvEpMacTag(attributes map[string]interface{}, status string) map[stri planTagTag := convertToTagTagFvEpMacTag(attributes["tags"]) if status == "deleted" { - provider.SetFvEpMacTagId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvEpMacTag", data.Id.ValueString()) @@ -49,7 +45,6 @@ func CreateFvEpMacTag(attributes map[string]interface{}, status string) map[stri json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvEpMacTag := provider.GetFvEpMacTagCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_epg_useg_ad_group_attribute.go b/convert_funcs/epg_useg_ad_group_attribute.go similarity index 99% rename from convert_funcs/conversion_epg_useg_ad_group_attribute.go rename to convert_funcs/epg_useg_ad_group_attribute.go index 5e59eb0c1..35b75c7f5 100644 --- a/convert_funcs/conversion_epg_useg_ad_group_attribute.go +++ b/convert_funcs/epg_useg_ad_group_attribute.go @@ -42,7 +42,6 @@ func CreateFvIdGroupAttr(attributes map[string]interface{}, status string) map[s planTagTag := convertToTagTagFvIdGroupAttr(attributes["tags"]) if status == "deleted" { - provider.SetFvIdGroupAttrId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvIdGroupAttr", data.Id.ValueString()) @@ -52,7 +51,6 @@ func CreateFvIdGroupAttr(attributes map[string]interface{}, status string) map[s json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvIdGroupAttr := provider.GetFvIdGroupAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_epg_useg_block_statement.go b/convert_funcs/epg_useg_block_statement.go similarity index 91% rename from convert_funcs/conversion_epg_useg_block_statement.go rename to convert_funcs/epg_useg_block_statement.go index d65b09419..098405c21 100644 --- a/convert_funcs/conversion_epg_useg_block_statement.go +++ b/convert_funcs/epg_useg_block_statement.go @@ -23,9 +23,6 @@ func CreateFvCrtrn(attributes map[string]interface{}, status string) map[string] if v, ok := attributes["description"].(string); ok && v != "" { data.Descr = types.StringValue(v) } - if v, ok := attributes["match"].(string); ok && v != "" { - data.Match = types.StringValue(v) - } if v, ok := attributes["name"].(string); ok && v != "" { data.Name = types.StringValue(v) } @@ -38,17 +35,10 @@ func CreateFvCrtrn(attributes map[string]interface{}, status string) map[string] if v, ok := attributes["owner_tag"].(string); ok && v != "" { data.OwnerTag = types.StringValue(v) } - if v, ok := attributes["precedence"].(string); ok && v != "" { - data.Prec = types.StringValue(v) - } - if v, ok := attributes["scope"].(string); ok && v != "" { - data.Scope = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationFvCrtrn(attributes["annotations"]) planTagTag := convertToTagTagFvCrtrn(attributes["tags"]) if status == "deleted" { - provider.SetFvCrtrnId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvCrtrn", data.Id.ValueString()) @@ -58,7 +48,6 @@ func CreateFvCrtrn(attributes map[string]interface{}, status string) map[string] json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvCrtrn := provider.GetFvCrtrnCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_epg_useg_dns_attribute.go b/convert_funcs/epg_useg_dns_attribute.go similarity index 99% rename from convert_funcs/conversion_epg_useg_dns_attribute.go rename to convert_funcs/epg_useg_dns_attribute.go index ef9db4227..9244e1b07 100644 --- a/convert_funcs/conversion_epg_useg_dns_attribute.go +++ b/convert_funcs/epg_useg_dns_attribute.go @@ -42,7 +42,6 @@ func CreateFvDnsAttr(attributes map[string]interface{}, status string) map[strin planTagTag := convertToTagTagFvDnsAttr(attributes["tags"]) if status == "deleted" { - provider.SetFvDnsAttrId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvDnsAttr", data.Id.ValueString()) @@ -52,7 +51,6 @@ func CreateFvDnsAttr(attributes map[string]interface{}, status string) map[strin json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvDnsAttr := provider.GetFvDnsAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_epg_useg_ip_attribute.go b/convert_funcs/epg_useg_ip_attribute.go similarity index 96% rename from convert_funcs/conversion_epg_useg_ip_attribute.go rename to convert_funcs/epg_useg_ip_attribute.go index f73e78d1e..fe610277f 100644 --- a/convert_funcs/conversion_epg_useg_ip_attribute.go +++ b/convert_funcs/epg_useg_ip_attribute.go @@ -38,14 +38,10 @@ func CreateFvIpAttr(attributes map[string]interface{}, status string) map[string if v, ok := attributes["owner_tag"].(string); ok && v != "" { data.OwnerTag = types.StringValue(v) } - if v, ok := attributes["use_epg_subnet"].(string); ok && v != "" { - data.UsefvSubnet = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationFvIpAttr(attributes["annotations"]) planTagTag := convertToTagTagFvIpAttr(attributes["tags"]) if status == "deleted" { - provider.SetFvIpAttrId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvIpAttr", data.Id.ValueString()) @@ -55,7 +51,6 @@ func CreateFvIpAttr(attributes map[string]interface{}, status string) map[string json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvIpAttr := provider.GetFvIpAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_epg_useg_mac_attribute.go b/convert_funcs/epg_useg_mac_attribute.go similarity index 99% rename from convert_funcs/conversion_epg_useg_mac_attribute.go rename to convert_funcs/epg_useg_mac_attribute.go index b328d5098..fa41a11d8 100644 --- a/convert_funcs/conversion_epg_useg_mac_attribute.go +++ b/convert_funcs/epg_useg_mac_attribute.go @@ -42,7 +42,6 @@ func CreateFvMacAttr(attributes map[string]interface{}, status string) map[strin planTagTag := convertToTagTagFvMacAttr(attributes["tags"]) if status == "deleted" { - provider.SetFvMacAttrId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvMacAttr", data.Id.ValueString()) @@ -52,7 +51,6 @@ func CreateFvMacAttr(attributes map[string]interface{}, status string) map[strin json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvMacAttr := provider.GetFvMacAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_epg_useg_sub_block_statement.go b/convert_funcs/epg_useg_sub_block_statement.go similarity index 97% rename from convert_funcs/conversion_epg_useg_sub_block_statement.go rename to convert_funcs/epg_useg_sub_block_statement.go index b810d9541..40c81b5eb 100644 --- a/convert_funcs/conversion_epg_useg_sub_block_statement.go +++ b/convert_funcs/epg_useg_sub_block_statement.go @@ -23,9 +23,6 @@ func CreateFvSCrtrn(attributes map[string]interface{}, status string) map[string if v, ok := attributes["description"].(string); ok && v != "" { data.Descr = types.StringValue(v) } - if v, ok := attributes["match"].(string); ok && v != "" { - data.Match = types.StringValue(v) - } if v, ok := attributes["name"].(string); ok && v != "" { data.Name = types.StringValue(v) } @@ -42,7 +39,6 @@ func CreateFvSCrtrn(attributes map[string]interface{}, status string) map[string planTagTag := convertToTagTagFvSCrtrn(attributes["tags"]) if status == "deleted" { - provider.SetFvSCrtrnId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvSCrtrn", data.Id.ValueString()) @@ -52,7 +48,6 @@ func CreateFvSCrtrn(attributes map[string]interface{}, status string) map[string json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvSCrtrn := provider.GetFvSCrtrnCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_epg_useg_vm_attribute.go b/convert_funcs/epg_useg_vm_attribute.go similarity index 94% rename from convert_funcs/conversion_epg_useg_vm_attribute.go rename to convert_funcs/epg_useg_vm_attribute.go index 8b33cbc5c..99a2c5f17 100644 --- a/convert_funcs/conversion_epg_useg_vm_attribute.go +++ b/convert_funcs/epg_useg_vm_attribute.go @@ -35,18 +35,12 @@ func CreateFvVmAttr(attributes map[string]interface{}, status string) map[string if v, ok := attributes["name_alias"].(string); ok && v != "" { data.NameAlias = types.StringValue(v) } - if v, ok := attributes["operator"].(string); ok && v != "" { - data.Operator = types.StringValue(v) - } if v, ok := attributes["owner_key"].(string); ok && v != "" { data.OwnerKey = types.StringValue(v) } if v, ok := attributes["owner_tag"].(string); ok && v != "" { data.OwnerTag = types.StringValue(v) } - if v, ok := attributes["type"].(string); ok && v != "" { - data.Type = types.StringValue(v) - } if v, ok := attributes["value"].(string); ok && v != "" { data.Value = types.StringValue(v) } @@ -54,7 +48,6 @@ func CreateFvVmAttr(attributes map[string]interface{}, status string) map[string planTagTag := convertToTagTagFvVmAttr(attributes["tags"]) if status == "deleted" { - provider.SetFvVmAttrId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvVmAttr", data.Id.ValueString()) @@ -64,7 +57,6 @@ func CreateFvVmAttr(attributes map[string]interface{}, status string) map[string json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvVmAttr := provider.GetFvVmAttrCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_external_management_network_instance_profile.go b/convert_funcs/external_management_network_instance_profile.go similarity index 97% rename from convert_funcs/conversion_external_management_network_instance_profile.go rename to convert_funcs/external_management_network_instance_profile.go index 19cba8f1a..e201d027a 100644 --- a/convert_funcs/conversion_external_management_network_instance_profile.go +++ b/convert_funcs/external_management_network_instance_profile.go @@ -26,15 +26,11 @@ func CreateMgmtInstP(attributes map[string]interface{}, status string) map[strin if v, ok := attributes["name_alias"].(string); ok && v != "" { data.NameAlias = types.StringValue(v) } - if v, ok := attributes["priority"].(string); ok && v != "" { - data.Prio = types.StringValue(v) - } planMgmtRsOoBCons := convertToMgmtRsOoBConsMgmtInstP(attributes["relation_to_consumed_out_of_band_contracts"]) planTagAnnotation := convertToTagAnnotationMgmtInstP(attributes["annotations"]) planTagTag := convertToTagTagMgmtInstP(attributes["tags"]) if status == "deleted" { - provider.SetMgmtInstPId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "mgmtInstP", data.Id.ValueString()) @@ -44,7 +40,6 @@ func CreateMgmtInstP(attributes map[string]interface{}, status string) map[strin json.Unmarshal(jsonPayload, &customData) return customData } - } newAciMgmtInstP := provider.GetMgmtInstPCreateJsonPayload(ctx, &diags, true, data, planMgmtRsOoBCons, planMgmtRsOoBCons, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_external_management_network_subnet.go b/convert_funcs/external_management_network_subnet.go similarity index 99% rename from convert_funcs/conversion_external_management_network_subnet.go rename to convert_funcs/external_management_network_subnet.go index 3b8d0c344..636b7c28e 100644 --- a/convert_funcs/conversion_external_management_network_subnet.go +++ b/convert_funcs/external_management_network_subnet.go @@ -36,7 +36,6 @@ func CreateMgmtSubnet(attributes map[string]interface{}, status string) map[stri planTagTag := convertToTagTagMgmtSubnet(attributes["tags"]) if status == "deleted" { - provider.SetMgmtSubnetId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "mgmtSubnet", data.Id.ValueString()) @@ -46,7 +45,6 @@ func CreateMgmtSubnet(attributes map[string]interface{}, status string) map[stri json.Unmarshal(jsonPayload, &customData) return customData } - } newAciMgmtSubnet := provider.GetMgmtSubnetCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/getAciClass.go b/convert_funcs/getAciClass.go deleted file mode 100644 index 5ebc91ac0..000000000 --- a/convert_funcs/getAciClass.go +++ /dev/null @@ -1,59 +0,0 @@ -package convert_funcs - -type GetAciClass func(string) string - -func AciClassMap(prefix string) string { - mapping := map[string]string{ - "hpaths": "infraHPathS", - "macattr": "fvMacAttr", - "rscons": "fvRsCons", - "trustctrlpol": "fhsTrustCtrlPol", - "conslbl": "l3extConsLbl", - "qoscustom": "qosCustomPol", - "ipattr": "fvIpAttr", - "recordpol": "netflowRecordPol", - "rsintraEpg": "fvRsIntraEpg", - "rspathAtt": "fvRsPathAtt", - "rsmonitorToExporter": "netflowRsMonitorToExporter", - "rsprotBy": "fvRsProtBy", - "vmattr": "fvVmAttr", - "subnet": "mgmtSubnet", - "epmactag": "fvEpMacTag", - "fbrg": "fvFBRGroup", - "idgattr": "fvIdGroupAttr", - "crtrn": "fvCrtrn", - "nexthop": "fvFBRMember", - "rsconsIf": "fvRsConsIf", - "monitorpol": "netflowMonitorPol", - "epg": "fvAEPg", - "esg": "fvESg", - "rssecInherited": "fvRsSecInherited", - "rtmapentry": "pimRouteMapEntry", - "tagKey": "tagTag", - "rsoutToFBRGroup": "l3extRsOutToFBRGroup", - // "crtrn": "fvSCrtrn", - "rsredistributePol": "l3extRsRedistributePol", - "instp": "mgmtInstP", - "annotationKey": "tagAnnotation", - "rsHPathAtt": "infraRsHPathAtt", - "qosdpppol": "qosDppPol", - "oobbrc": "vzOOBBrCP", - "pfx": "fvFBRoute", - "rsfcPathAtt": "fvRsFcPathAtt", - "rsprov": "fvRsProv", - "rsooBCons": "mgmtRsOoBCons", - "nodesidp": "mplsNodeSidP", - "dnsattr": "fvDnsAttr", - "prof": "rtctrlProfile", - "rsdomAtt": "fvRsDomAtt", - "rsnodeAtt": "fvRsNodeAtt", - "provlbl": "l3extProvLbl", - "epiptag": "fvEpIpTag", - "rtmap": "pimRouteMapPol", - } - - if class, found := mapping[prefix]; found { - return class - } - return "" -} diff --git a/convert_funcs/conversion_l3out_consumer_label.go b/convert_funcs/l3out_consumer_label.go similarity index 94% rename from convert_funcs/conversion_l3out_consumer_label.go rename to convert_funcs/l3out_consumer_label.go index e6e986e23..727077b24 100644 --- a/convert_funcs/conversion_l3out_consumer_label.go +++ b/convert_funcs/l3out_consumer_label.go @@ -29,23 +29,16 @@ func CreateL3extConsLbl(attributes map[string]interface{}, status string) map[st if v, ok := attributes["name_alias"].(string); ok && v != "" { data.NameAlias = types.StringValue(v) } - if v, ok := attributes["owner"].(string); ok && v != "" { - data.Owner = types.StringValue(v) - } if v, ok := attributes["owner_key"].(string); ok && v != "" { data.OwnerKey = types.StringValue(v) } if v, ok := attributes["owner_tag"].(string); ok && v != "" { data.OwnerTag = types.StringValue(v) } - if v, ok := attributes["tag"].(string); ok && v != "" { - data.Tag = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationL3extConsLbl(attributes["annotations"]) planTagTag := convertToTagTagL3extConsLbl(attributes["tags"]) if status == "deleted" { - provider.SetL3extConsLblId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "l3extConsLbl", data.Id.ValueString()) @@ -55,7 +48,6 @@ func CreateL3extConsLbl(attributes map[string]interface{}, status string) map[st json.Unmarshal(jsonPayload, &customData) return customData } - } newAciL3extConsLbl := provider.GetL3extConsLblCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_l3out_node_sid_profile.go b/convert_funcs/l3out_node_sid_profile.go similarity index 96% rename from convert_funcs/conversion_l3out_node_sid_profile.go rename to convert_funcs/l3out_node_sid_profile.go index a63b2c7aa..a78838ed4 100644 --- a/convert_funcs/conversion_l3out_node_sid_profile.go +++ b/convert_funcs/l3out_node_sid_profile.go @@ -32,14 +32,10 @@ func CreateMplsNodeSidP(attributes map[string]interface{}, status string) map[st if v, ok := attributes["name_alias"].(string); ok && v != "" { data.NameAlias = types.StringValue(v) } - if v, ok := attributes["segment_id"].(string); ok && v != "" { - data.Sidoffset = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationMplsNodeSidP(attributes["annotations"]) planTagTag := convertToTagTagMplsNodeSidP(attributes["tags"]) if status == "deleted" { - provider.SetMplsNodeSidPId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "mplsNodeSidP", data.Id.ValueString()) @@ -49,7 +45,6 @@ func CreateMplsNodeSidP(attributes map[string]interface{}, status string) map[st json.Unmarshal(jsonPayload, &customData) return customData } - } newAciMplsNodeSidP := provider.GetMplsNodeSidPCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_l3out_provider_label.go b/convert_funcs/l3out_provider_label.go similarity index 97% rename from convert_funcs/conversion_l3out_provider_label.go rename to convert_funcs/l3out_provider_label.go index 63118a5a7..ef5f1d1f1 100644 --- a/convert_funcs/conversion_l3out_provider_label.go +++ b/convert_funcs/l3out_provider_label.go @@ -35,14 +35,10 @@ func CreateL3extProvLbl(attributes map[string]interface{}, status string) map[st if v, ok := attributes["owner_tag"].(string); ok && v != "" { data.OwnerTag = types.StringValue(v) } - if v, ok := attributes["tag"].(string); ok && v != "" { - data.Tag = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationL3extProvLbl(attributes["annotations"]) planTagTag := convertToTagTagL3extProvLbl(attributes["tags"]) if status == "deleted" { - provider.SetL3extProvLblId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "l3extProvLbl", data.Id.ValueString()) @@ -52,7 +48,6 @@ func CreateL3extProvLbl(attributes map[string]interface{}, status string) map[st json.Unmarshal(jsonPayload, &customData) return customData } - } newAciL3extProvLbl := provider.GetL3extProvLblCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_l3out_redistribute_policy.go b/convert_funcs/l3out_redistribute_policy.go similarity index 97% rename from convert_funcs/conversion_l3out_redistribute_policy.go rename to convert_funcs/l3out_redistribute_policy.go index ccf1f7fb2..d43bb002e 100644 --- a/convert_funcs/conversion_l3out_redistribute_policy.go +++ b/convert_funcs/l3out_redistribute_policy.go @@ -20,9 +20,6 @@ func CreateL3extRsRedistributePol(attributes map[string]interface{}, status stri if v, ok := attributes["annotation"].(string); ok && v != "" { data.Annotation = types.StringValue(v) } - if v, ok := attributes["source"].(string); ok && v != "" { - data.Src = types.StringValue(v) - } if v, ok := attributes["route_control_profile_name"].(string); ok && v != "" { data.TnRtctrlProfileName = types.StringValue(v) } @@ -30,7 +27,6 @@ func CreateL3extRsRedistributePol(attributes map[string]interface{}, status stri planTagTag := convertToTagTagL3extRsRedistributePol(attributes["tags"]) if status == "deleted" { - provider.SetL3extRsRedistributePolId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "l3extRsRedistributePol", data.Id.ValueString()) @@ -40,7 +36,6 @@ func CreateL3extRsRedistributePol(attributes map[string]interface{}, status stri json.Unmarshal(jsonPayload, &customData) return customData } - } newAciL3extRsRedistributePol := provider.GetL3extRsRedistributePolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_netflow_monitor_policy.go b/convert_funcs/netflow_monitor_policy.go similarity index 99% rename from convert_funcs/conversion_netflow_monitor_policy.go rename to convert_funcs/netflow_monitor_policy.go index 05f2c72d5..f63cc59b8 100644 --- a/convert_funcs/conversion_netflow_monitor_policy.go +++ b/convert_funcs/netflow_monitor_policy.go @@ -41,7 +41,6 @@ func CreateNetflowMonitorPol(attributes map[string]interface{}, status string) m planTagTag := convertToTagTagNetflowMonitorPol(attributes["tags"]) if status == "deleted" { - provider.SetNetflowMonitorPolId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "netflowMonitorPol", data.Id.ValueString()) @@ -51,7 +50,6 @@ func CreateNetflowMonitorPol(attributes map[string]interface{}, status string) m json.Unmarshal(jsonPayload, &customData) return customData } - } newAciNetflowMonitorPol := provider.GetNetflowMonitorPolCreateJsonPayload(ctx, &diags, true, data, planNetflowRsMonitorToExporter, planNetflowRsMonitorToExporter, planNetflowRsMonitorToRecord, planNetflowRsMonitorToRecord, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_netflow_record_policy.go b/convert_funcs/netflow_record_policy.go similarity index 99% rename from convert_funcs/conversion_netflow_record_policy.go rename to convert_funcs/netflow_record_policy.go index 261a88856..31a710c2e 100644 --- a/convert_funcs/conversion_netflow_record_policy.go +++ b/convert_funcs/netflow_record_policy.go @@ -39,7 +39,6 @@ func CreateNetflowRecordPol(attributes map[string]interface{}, status string) ma planTagTag := convertToTagTagNetflowRecordPol(attributes["tags"]) if status == "deleted" { - provider.SetNetflowRecordPolId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "netflowRecordPol", data.Id.ValueString()) @@ -49,7 +48,6 @@ func CreateNetflowRecordPol(attributes map[string]interface{}, status string) ma json.Unmarshal(jsonPayload, &customData) return customData } - } newAciNetflowRecordPol := provider.GetNetflowRecordPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_out_of_band_contract.go b/convert_funcs/out_of_band_contract.go similarity index 88% rename from convert_funcs/conversion_out_of_band_contract.go rename to convert_funcs/out_of_band_contract.go index c0a727714..d37ff1503 100644 --- a/convert_funcs/conversion_out_of_band_contract.go +++ b/convert_funcs/out_of_band_contract.go @@ -20,9 +20,6 @@ func CreateVzOOBBrCP(attributes map[string]interface{}, status string) map[strin if v, ok := attributes["description"].(string); ok && v != "" { data.Descr = types.StringValue(v) } - if v, ok := attributes["intent"].(string); ok && v != "" { - data.Intent = types.StringValue(v) - } if v, ok := attributes["name"].(string); ok && v != "" { data.Name = types.StringValue(v) } @@ -35,20 +32,10 @@ func CreateVzOOBBrCP(attributes map[string]interface{}, status string) map[strin if v, ok := attributes["owner_tag"].(string); ok && v != "" { data.OwnerTag = types.StringValue(v) } - if v, ok := attributes["priority"].(string); ok && v != "" { - data.Prio = types.StringValue(v) - } - if v, ok := attributes["scope"].(string); ok && v != "" { - data.Scope = types.StringValue(v) - } - if v, ok := attributes["target_dscp"].(string); ok && v != "" { - data.TargetDscp = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationVzOOBBrCP(attributes["annotations"]) planTagTag := convertToTagTagVzOOBBrCP(attributes["tags"]) if status == "deleted" { - provider.SetVzOOBBrCPId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "vzOOBBrCP", data.Id.ValueString()) @@ -58,7 +45,6 @@ func CreateVzOOBBrCP(attributes map[string]interface{}, status string) map[strin json.Unmarshal(jsonPayload, &customData) return customData } - } newAciVzOOBBrCP := provider.GetVzOOBBrCPCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_pim_route_map_entry.go b/convert_funcs/pim_route_map_entry.go similarity index 94% rename from convert_funcs/conversion_pim_route_map_entry.go rename to convert_funcs/pim_route_map_entry.go index b92804832..f9e093a8d 100644 --- a/convert_funcs/conversion_pim_route_map_entry.go +++ b/convert_funcs/pim_route_map_entry.go @@ -17,9 +17,6 @@ func CreatePimRouteMapEntry(attributes map[string]interface{}, status string) ma if v, ok := attributes["parent_dn"].(string); ok && v != "" { data.ParentDn = types.StringValue(v) } - if v, ok := attributes["action"].(string); ok && v != "" { - data.Action = types.StringValue(v) - } if v, ok := attributes["annotation"].(string); ok && v != "" { data.Annotation = types.StringValue(v) } @@ -35,9 +32,6 @@ func CreatePimRouteMapEntry(attributes map[string]interface{}, status string) ma if v, ok := attributes["name_alias"].(string); ok && v != "" { data.NameAlias = types.StringValue(v) } - if v, ok := attributes["order"].(string); ok && v != "" { - data.Order = types.StringValue(v) - } if v, ok := attributes["rendezvous_point_ip"].(string); ok && v != "" { data.Rp = types.StringValue(v) } @@ -48,7 +42,6 @@ func CreatePimRouteMapEntry(attributes map[string]interface{}, status string) ma planTagTag := convertToTagTagPimRouteMapEntry(attributes["tags"]) if status == "deleted" { - provider.SetPimRouteMapEntryId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "pimRouteMapEntry", data.Id.ValueString()) @@ -58,7 +51,6 @@ func CreatePimRouteMapEntry(attributes map[string]interface{}, status string) ma json.Unmarshal(jsonPayload, &customData) return customData } - } newAciPimRouteMapEntry := provider.GetPimRouteMapEntryCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_pim_route_map_policy.go b/convert_funcs/pim_route_map_policy.go similarity index 99% rename from convert_funcs/conversion_pim_route_map_policy.go rename to convert_funcs/pim_route_map_policy.go index 459cc7c6a..378248080 100644 --- a/convert_funcs/conversion_pim_route_map_policy.go +++ b/convert_funcs/pim_route_map_policy.go @@ -39,7 +39,6 @@ func CreatePimRouteMapPol(attributes map[string]interface{}, status string) map[ planTagTag := convertToTagTagPimRouteMapPol(attributes["tags"]) if status == "deleted" { - provider.SetPimRouteMapPolId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "pimRouteMapPol", data.Id.ValueString()) @@ -49,7 +48,6 @@ func CreatePimRouteMapPol(attributes map[string]interface{}, status string) map[ json.Unmarshal(jsonPayload, &customData) return customData } - } newAciPimRouteMapPol := provider.GetPimRouteMapPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_consumed_contract.go b/convert_funcs/relation_to_consumed_contract.go similarity index 96% rename from convert_funcs/conversion_relation_to_consumed_contract.go rename to convert_funcs/relation_to_consumed_contract.go index 2e8f8efbc..41b8f5b41 100644 --- a/convert_funcs/conversion_relation_to_consumed_contract.go +++ b/convert_funcs/relation_to_consumed_contract.go @@ -20,9 +20,6 @@ func CreateFvRsCons(attributes map[string]interface{}, status string) map[string if v, ok := attributes["annotation"].(string); ok && v != "" { data.Annotation = types.StringValue(v) } - if v, ok := attributes["priority"].(string); ok && v != "" { - data.Prio = types.StringValue(v) - } if v, ok := attributes["contract_name"].(string); ok && v != "" { data.TnVzBrCPName = types.StringValue(v) } @@ -30,7 +27,6 @@ func CreateFvRsCons(attributes map[string]interface{}, status string) map[string planTagTag := convertToTagTagFvRsCons(attributes["tags"]) if status == "deleted" { - provider.SetFvRsConsId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsCons", data.Id.ValueString()) @@ -40,7 +36,6 @@ func CreateFvRsCons(attributes map[string]interface{}, status string) map[string json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsCons := provider.GetFvRsConsCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go b/convert_funcs/relation_to_consumed_out_of_band_contract.go similarity index 96% rename from convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go rename to convert_funcs/relation_to_consumed_out_of_band_contract.go index 6a6531a7c..24e61ed42 100644 --- a/convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go +++ b/convert_funcs/relation_to_consumed_out_of_band_contract.go @@ -20,9 +20,6 @@ func CreateMgmtRsOoBCons(attributes map[string]interface{}, status string) map[s if v, ok := attributes["annotation"].(string); ok && v != "" { data.Annotation = types.StringValue(v) } - if v, ok := attributes["priority"].(string); ok && v != "" { - data.Prio = types.StringValue(v) - } if v, ok := attributes["out_of_band_contract_name"].(string); ok && v != "" { data.TnVzOOBBrCPName = types.StringValue(v) } @@ -30,7 +27,6 @@ func CreateMgmtRsOoBCons(attributes map[string]interface{}, status string) map[s planTagTag := convertToTagTagMgmtRsOoBCons(attributes["tags"]) if status == "deleted" { - provider.SetMgmtRsOoBConsId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "mgmtRsOoBCons", data.Id.ValueString()) @@ -40,7 +36,6 @@ func CreateMgmtRsOoBCons(attributes map[string]interface{}, status string) map[s json.Unmarshal(jsonPayload, &customData) return customData } - } newAciMgmtRsOoBCons := provider.GetMgmtRsOoBConsCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_contract_master.go b/convert_funcs/relation_to_contract_master.go similarity index 99% rename from convert_funcs/conversion_relation_to_contract_master.go rename to convert_funcs/relation_to_contract_master.go index 8a7a5d036..1f53779a8 100644 --- a/convert_funcs/conversion_relation_to_contract_master.go +++ b/convert_funcs/relation_to_contract_master.go @@ -27,7 +27,6 @@ func CreateFvRsSecInherited(attributes map[string]interface{}, status string) ma planTagTag := convertToTagTagFvRsSecInherited(attributes["tags"]) if status == "deleted" { - provider.SetFvRsSecInheritedId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsSecInherited", data.Id.ValueString()) @@ -37,7 +36,6 @@ func CreateFvRsSecInherited(attributes map[string]interface{}, status string) ma json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsSecInherited := provider.GetFvRsSecInheritedCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_domain.go b/convert_funcs/relation_to_domain.go similarity index 70% rename from convert_funcs/conversion_relation_to_domain.go rename to convert_funcs/relation_to_domain.go index 84f6a4c11..13632b6cd 100644 --- a/convert_funcs/conversion_relation_to_domain.go +++ b/convert_funcs/relation_to_domain.go @@ -20,12 +20,6 @@ func CreateFvRsDomAtt(attributes map[string]interface{}, status string) map[stri if v, ok := attributes["annotation"].(string); ok && v != "" { data.Annotation = types.StringValue(v) } - if v, ok := attributes["binding_type"].(string); ok && v != "" { - data.BindingType = types.StringValue(v) - } - if v, ok := attributes["class_preference"].(string); ok && v != "" { - data.ClassPref = types.StringValue(v) - } if v, ok := attributes["custom_epg_name"].(string); ok && v != "" { data.CustomEpgName = types.StringValue(v) } @@ -35,71 +29,31 @@ func CreateFvRsDomAtt(attributes map[string]interface{}, status string) map[stri if v, ok := attributes["encapsulation"].(string); ok && v != "" { data.Encap = types.StringValue(v) } - if v, ok := attributes["encapsulation_mode"].(string); ok && v != "" { - data.EncapMode = types.StringValue(v) - } - if v, ok := attributes["epg_cos"].(string); ok && v != "" { - data.EpgCos = types.StringValue(v) - } - if v, ok := attributes["epg_cos_pref"].(string); ok && v != "" { - data.EpgCosPref = types.StringValue(v) - } - if v, ok := attributes["deployment_immediacy"].(string); ok && v != "" { - data.InstrImedcy = types.StringValue(v) - } if v, ok := attributes["ipam_dhcp_override"].(string); ok && v != "" { data.IpamDhcpOverride = types.StringValue(v) } - if v, ok := attributes["ipam_enabled"].(string); ok && v != "" { - data.IpamEnabled = types.StringValue(v) - } if v, ok := attributes["ipam_gateway"].(string); ok && v != "" { data.IpamGateway = types.StringValue(v) } if v, ok := attributes["lag_policy_name"].(string); ok && v != "" { data.LagPolicyName = types.StringValue(v) } - if v, ok := attributes["netflow_direction"].(string); ok && v != "" { - data.NetflowDir = types.StringValue(v) - } - if v, ok := attributes["enable_netflow"].(string); ok && v != "" { - data.NetflowPref = types.StringValue(v) - } - if v, ok := attributes["number_of_ports"].(string); ok && v != "" { - data.NumPorts = types.StringValue(v) - } - if v, ok := attributes["port_allocation"].(string); ok && v != "" { - data.PortAllocation = types.StringValue(v) - } if v, ok := attributes["primary_encapsulation"].(string); ok && v != "" { data.PrimaryEncap = types.StringValue(v) } if v, ok := attributes["primary_encapsulation_inner"].(string); ok && v != "" { data.PrimaryEncapInner = types.StringValue(v) } - if v, ok := attributes["resolution_immediacy"].(string); ok && v != "" { - data.ResImedcy = types.StringValue(v) - } if v, ok := attributes["secondary_encapsulation_inner"].(string); ok && v != "" { data.SecondaryEncapInner = types.StringValue(v) } - if v, ok := attributes["switching_mode"].(string); ok && v != "" { - data.SwitchingMode = types.StringValue(v) - } if v, ok := attributes["target_dn"].(string); ok && v != "" { data.TDn = types.StringValue(v) } - if v, ok := attributes["untagged"].(string); ok && v != "" { - data.Untagged = types.StringValue(v) - } - if v, ok := attributes["vnet_only"].(string); ok && v != "" { - data.VnetOnly = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationFvRsDomAtt(attributes["annotations"]) planTagTag := convertToTagTagFvRsDomAtt(attributes["tags"]) if status == "deleted" { - provider.SetFvRsDomAttId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsDomAtt", data.Id.ValueString()) @@ -109,7 +63,6 @@ func CreateFvRsDomAtt(attributes map[string]interface{}, status string) map[stri json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsDomAtt := provider.GetFvRsDomAttCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_fibre_channel_path.go b/convert_funcs/relation_to_fibre_channel_path.go similarity index 96% rename from convert_funcs/conversion_relation_to_fibre_channel_path.go rename to convert_funcs/relation_to_fibre_channel_path.go index f3fb08a37..2df16c263 100644 --- a/convert_funcs/conversion_relation_to_fibre_channel_path.go +++ b/convert_funcs/relation_to_fibre_channel_path.go @@ -29,14 +29,10 @@ func CreateFvRsFcPathAtt(attributes map[string]interface{}, status string) map[s if v, ok := attributes["vsan"].(string); ok && v != "" { data.Vsan = types.StringValue(v) } - if v, ok := attributes["vsan_mode"].(string); ok && v != "" { - data.VsanMode = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationFvRsFcPathAtt(attributes["annotations"]) planTagTag := convertToTagTagFvRsFcPathAtt(attributes["tags"]) if status == "deleted" { - provider.SetFvRsFcPathAttId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsFcPathAtt", data.Id.ValueString()) @@ -46,7 +42,6 @@ func CreateFvRsFcPathAtt(attributes map[string]interface{}, status string) map[s json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsFcPathAtt := provider.GetFvRsFcPathAttCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_imported_contract.go b/convert_funcs/relation_to_imported_contract.go similarity index 96% rename from convert_funcs/conversion_relation_to_imported_contract.go rename to convert_funcs/relation_to_imported_contract.go index 03af73bfc..48af55578 100644 --- a/convert_funcs/conversion_relation_to_imported_contract.go +++ b/convert_funcs/relation_to_imported_contract.go @@ -20,9 +20,6 @@ func CreateFvRsConsIf(attributes map[string]interface{}, status string) map[stri if v, ok := attributes["annotation"].(string); ok && v != "" { data.Annotation = types.StringValue(v) } - if v, ok := attributes["priority"].(string); ok && v != "" { - data.Prio = types.StringValue(v) - } if v, ok := attributes["imported_contract_name"].(string); ok && v != "" { data.TnVzCPIfName = types.StringValue(v) } @@ -30,7 +27,6 @@ func CreateFvRsConsIf(attributes map[string]interface{}, status string) map[stri planTagTag := convertToTagTagFvRsConsIf(attributes["tags"]) if status == "deleted" { - provider.SetFvRsConsIfId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsConsIf", data.Id.ValueString()) @@ -40,7 +36,6 @@ func CreateFvRsConsIf(attributes map[string]interface{}, status string) map[stri json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsConsIf := provider.GetFvRsConsIfCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_intra_epg_contract.go b/convert_funcs/relation_to_intra_epg_contract.go similarity index 99% rename from convert_funcs/conversion_relation_to_intra_epg_contract.go rename to convert_funcs/relation_to_intra_epg_contract.go index f92f22dc9..2ac34e549 100644 --- a/convert_funcs/conversion_relation_to_intra_epg_contract.go +++ b/convert_funcs/relation_to_intra_epg_contract.go @@ -27,7 +27,6 @@ func CreateFvRsIntraEpg(attributes map[string]interface{}, status string) map[st planTagTag := convertToTagTagFvRsIntraEpg(attributes["tags"]) if status == "deleted" { - provider.SetFvRsIntraEpgId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsIntraEpg", data.Id.ValueString()) @@ -37,7 +36,6 @@ func CreateFvRsIntraEpg(attributes map[string]interface{}, status string) map[st json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsIntraEpg := provider.GetFvRsIntraEpgCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_netflow_exporter.go b/convert_funcs/relation_to_netflow_exporter.go similarity index 99% rename from convert_funcs/conversion_relation_to_netflow_exporter.go rename to convert_funcs/relation_to_netflow_exporter.go index a5f855800..0fe3ca7e6 100644 --- a/convert_funcs/conversion_relation_to_netflow_exporter.go +++ b/convert_funcs/relation_to_netflow_exporter.go @@ -27,7 +27,6 @@ func CreateNetflowRsMonitorToExporter(attributes map[string]interface{}, status planTagTag := convertToTagTagNetflowRsMonitorToExporter(attributes["tags"]) if status == "deleted" { - provider.SetNetflowRsMonitorToExporterId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "netflowRsMonitorToExporter", data.Id.ValueString()) @@ -37,7 +36,6 @@ func CreateNetflowRsMonitorToExporter(attributes map[string]interface{}, status json.Unmarshal(jsonPayload, &customData) return customData } - } newAciNetflowRsMonitorToExporter := provider.GetNetflowRsMonitorToExporterCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_provided_contract.go b/convert_funcs/relation_to_provided_contract.go similarity index 93% rename from convert_funcs/conversion_relation_to_provided_contract.go rename to convert_funcs/relation_to_provided_contract.go index 4e04f6832..18d1d0233 100644 --- a/convert_funcs/conversion_relation_to_provided_contract.go +++ b/convert_funcs/relation_to_provided_contract.go @@ -20,12 +20,6 @@ func CreateFvRsProv(attributes map[string]interface{}, status string) map[string if v, ok := attributes["annotation"].(string); ok && v != "" { data.Annotation = types.StringValue(v) } - if v, ok := attributes["match_criteria"].(string); ok && v != "" { - data.MatchT = types.StringValue(v) - } - if v, ok := attributes["priority"].(string); ok && v != "" { - data.Prio = types.StringValue(v) - } if v, ok := attributes["contract_name"].(string); ok && v != "" { data.TnVzBrCPName = types.StringValue(v) } @@ -33,7 +27,6 @@ func CreateFvRsProv(attributes map[string]interface{}, status string) map[string planTagTag := convertToTagTagFvRsProv(attributes["tags"]) if status == "deleted" { - provider.SetFvRsProvId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsProv", data.Id.ValueString()) @@ -43,7 +36,6 @@ func CreateFvRsProv(attributes map[string]interface{}, status string) map[string json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsProv := provider.GetFvRsProvCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_static_leaf.go b/convert_funcs/relation_to_static_leaf.go similarity index 93% rename from convert_funcs/conversion_relation_to_static_leaf.go rename to convert_funcs/relation_to_static_leaf.go index cbe81a5d5..3b72c56de 100644 --- a/convert_funcs/conversion_relation_to_static_leaf.go +++ b/convert_funcs/relation_to_static_leaf.go @@ -26,12 +26,6 @@ func CreateFvRsNodeAtt(attributes map[string]interface{}, status string) map[str if v, ok := attributes["encapsulation"].(string); ok && v != "" { data.Encap = types.StringValue(v) } - if v, ok := attributes["deployment_immediacy"].(string); ok && v != "" { - data.InstrImedcy = types.StringValue(v) - } - if v, ok := attributes["mode"].(string); ok && v != "" { - data.Mode = types.StringValue(v) - } if v, ok := attributes["target_dn"].(string); ok && v != "" { data.TDn = types.StringValue(v) } @@ -39,7 +33,6 @@ func CreateFvRsNodeAtt(attributes map[string]interface{}, status string) map[str planTagTag := convertToTagTagFvRsNodeAtt(attributes["tags"]) if status == "deleted" { - provider.SetFvRsNodeAttId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsNodeAtt", data.Id.ValueString()) @@ -49,7 +42,6 @@ func CreateFvRsNodeAtt(attributes map[string]interface{}, status string) map[str json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsNodeAtt := provider.GetFvRsNodeAttCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_static_path.go b/convert_funcs/relation_to_static_path.go similarity index 93% rename from convert_funcs/conversion_relation_to_static_path.go rename to convert_funcs/relation_to_static_path.go index 9bcf9f3ce..99c63446f 100644 --- a/convert_funcs/conversion_relation_to_static_path.go +++ b/convert_funcs/relation_to_static_path.go @@ -26,12 +26,6 @@ func CreateFvRsPathAtt(attributes map[string]interface{}, status string) map[str if v, ok := attributes["encapsulation"].(string); ok && v != "" { data.Encap = types.StringValue(v) } - if v, ok := attributes["deployment_immediacy"].(string); ok && v != "" { - data.InstrImedcy = types.StringValue(v) - } - if v, ok := attributes["mode"].(string); ok && v != "" { - data.Mode = types.StringValue(v) - } if v, ok := attributes["primary_encapsulation"].(string); ok && v != "" { data.PrimaryEncap = types.StringValue(v) } @@ -42,7 +36,6 @@ func CreateFvRsPathAtt(attributes map[string]interface{}, status string) map[str planTagTag := convertToTagTagFvRsPathAtt(attributes["tags"]) if status == "deleted" { - provider.SetFvRsPathAttId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsPathAtt", data.Id.ValueString()) @@ -52,7 +45,6 @@ func CreateFvRsPathAtt(attributes map[string]interface{}, status string) map[str json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsPathAtt := provider.GetFvRsPathAttCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_taboo_contract.go b/convert_funcs/relation_to_taboo_contract.go similarity index 99% rename from convert_funcs/conversion_relation_to_taboo_contract.go rename to convert_funcs/relation_to_taboo_contract.go index 61b8f45fa..5c2138db0 100644 --- a/convert_funcs/conversion_relation_to_taboo_contract.go +++ b/convert_funcs/relation_to_taboo_contract.go @@ -27,7 +27,6 @@ func CreateFvRsProtBy(attributes map[string]interface{}, status string) map[stri planTagTag := convertToTagTagFvRsProtBy(attributes["tags"]) if status == "deleted" { - provider.SetFvRsProtById(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvRsProtBy", data.Id.ValueString()) @@ -37,7 +36,6 @@ func CreateFvRsProtBy(attributes map[string]interface{}, status string) map[stri json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvRsProtBy := provider.GetFvRsProtByCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_relation_to_vrf_fallback_route_group.go b/convert_funcs/relation_to_vrf_fallback_route_group.go similarity index 99% rename from convert_funcs/conversion_relation_to_vrf_fallback_route_group.go rename to convert_funcs/relation_to_vrf_fallback_route_group.go index c58372afc..a9d1df0d8 100644 --- a/convert_funcs/conversion_relation_to_vrf_fallback_route_group.go +++ b/convert_funcs/relation_to_vrf_fallback_route_group.go @@ -27,7 +27,6 @@ func CreateL3extRsOutToFBRGroup(attributes map[string]interface{}, status string planTagTag := convertToTagTagL3extRsOutToFBRGroup(attributes["tags"]) if status == "deleted" { - provider.SetL3extRsOutToFBRGroupId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "l3extRsOutToFBRGroup", data.Id.ValueString()) @@ -37,7 +36,6 @@ func CreateL3extRsOutToFBRGroup(attributes map[string]interface{}, status string json.Unmarshal(jsonPayload, &customData) return customData } - } newAciL3extRsOutToFBRGroup := provider.GetL3extRsOutToFBRGroupCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/resourceMap.go b/convert_funcs/resourceMap.go index b7910b591..b016e57f8 100644 --- a/convert_funcs/resourceMap.go +++ b/convert_funcs/resourceMap.go @@ -3,50 +3,93 @@ package convert_funcs type createFunc func(map[string]interface{}, string) map[string]interface{} var ResourceMap = map[string]createFunc{ - "aci_access_interface_override": CreateInfraHPathS, - "aci_epg_useg_mac_attribute": CreateFvMacAttr, - "aci_relation_to_consumed_contract": CreateFvRsCons, - "aci_trust_control_policy": CreateFhsTrustCtrlPol, - "aci_l3out_consumer_label": CreateL3extConsLbl, - "aci_custom_qos_policy": CreateQosCustomPol, - "aci_epg_useg_ip_attribute": CreateFvIpAttr, - "aci_netflow_record_policy": CreateNetflowRecordPol, - "aci_relation_to_intra_epg_contract": CreateFvRsIntraEpg, - "aci_relation_to_static_path": CreateFvRsPathAtt, - "aci_relation_to_netflow_exporter": CreateNetflowRsMonitorToExporter, - "aci_relation_to_taboo_contract": CreateFvRsProtBy, - "aci_epg_useg_vm_attribute": CreateFvVmAttr, - "aci_external_management_network_subnet": CreateMgmtSubnet, - "aci_endpoint_tag_mac": CreateFvEpMacTag, - "aci_vrf_fallback_route_group": CreateFvFBRGroup, - "aci_epg_useg_ad_group_attribute": CreateFvIdGroupAttr, - "aci_epg_useg_block_statement": CreateFvCrtrn, - "aci_vrf_fallback_route_group_member": CreateFvFBRMember, - "aci_relation_to_imported_contract": CreateFvRsConsIf, - "aci_netflow_monitor_policy": CreateNetflowMonitorPol, - "aci_application_epg": CreateFvAEPg, - "aci_endpoint_security_group": CreateFvESg, - "aci_relation_to_contract_master": CreateFvRsSecInherited, - "aci_pim_route_map_entry": CreatePimRouteMapEntry, - "aci_tag": CreateTagTag, - "aci_relation_to_vrf_fallback_route_group": CreateL3extRsOutToFBRGroup, - "aci_epg_useg_sub_block_statement": CreateFvSCrtrn, - "aci_l3out_redistribute_policy": CreateL3extRsRedistributePol, + "aci_trust_control_policy": CreateFhsTrustCtrlPol, + + "aci_application_epg": CreateFvAEPg, + + "aci_epg_useg_block_statement": CreateFvCrtrn, + + "aci_epg_useg_dns_attribute": CreateFvDnsAttr, + + "aci_endpoint_security_group": CreateFvESg, + + "aci_endpoint_tag_ip": CreateFvEpIpTag, + + "aci_endpoint_tag_mac": CreateFvEpMacTag, + + "aci_vrf_fallback_route_group": CreateFvFBRGroup, + + "aci_vrf_fallback_route_group_member": CreateFvFBRMember, + + "aci_vrf_fallback_route": CreateFvFBRoute, + + "aci_epg_useg_ad_group_attribute": CreateFvIdGroupAttr, + + "aci_epg_useg_ip_attribute": CreateFvIpAttr, + + "aci_epg_useg_mac_attribute": CreateFvMacAttr, + + "aci_relation_to_consumed_contract": CreateFvRsCons, + + "aci_relation_to_imported_contract": CreateFvRsConsIf, + + "aci_relation_to_domain": CreateFvRsDomAtt, + + "aci_relation_to_fibre_channel_path": CreateFvRsFcPathAtt, + + "aci_relation_to_intra_epg_contract": CreateFvRsIntraEpg, + + "aci_relation_to_static_leaf": CreateFvRsNodeAtt, + + "aci_relation_to_static_path": CreateFvRsPathAtt, + + "aci_relation_to_taboo_contract": CreateFvRsProtBy, + + "aci_relation_to_provided_contract": CreateFvRsProv, + + "aci_relation_to_contract_master": CreateFvRsSecInherited, + + "aci_epg_useg_sub_block_statement": CreateFvSCrtrn, + + "aci_epg_useg_vm_attribute": CreateFvVmAttr, + + "aci_access_interface_override": CreateInfraHPathS, + + "aci_l3out_consumer_label": CreateL3extConsLbl, + + "aci_l3out_provider_label": CreateL3extProvLbl, + + "aci_relation_to_vrf_fallback_route_group": CreateL3extRsOutToFBRGroup, + + "aci_l3out_redistribute_policy": CreateL3extRsRedistributePol, + "aci_external_management_network_instance_profile": CreateMgmtInstP, - "aci_annotation": CreateTagAnnotation, - //"aci_relation_to_host_path": CreateInfraRsHPathAtt, - "aci_data_plane_policing_policy": CreateQosDppPol, - "aci_out_of_band_contract": CreateVzOOBBrCP, - "aci_vrf_fallback_route": CreateFvFBRoute, - "aci_relation_to_fibre_channel_path": CreateFvRsFcPathAtt, - "aci_relation_to_provided_contract": CreateFvRsProv, + "aci_relation_to_consumed_out_of_band_contract": CreateMgmtRsOoBCons, - "aci_l3out_node_sid_profile": CreateMplsNodeSidP, - "aci_epg_useg_dns_attribute": CreateFvDnsAttr, - "aci_route_control_profile": CreateRtctrlProfile, - "aci_relation_to_domain": CreateFvRsDomAtt, - "aci_relation_to_static_leaf": CreateFvRsNodeAtt, - "aci_l3out_provider_label": CreateL3extProvLbl, - "aci_endpoint_tag_ip": CreateFvEpIpTag, - "aci_pim_route_map_policy": CreatePimRouteMapPol, + + "aci_external_management_network_subnet": CreateMgmtSubnet, + + "aci_l3out_node_sid_profile": CreateMplsNodeSidP, + + "aci_netflow_monitor_policy": CreateNetflowMonitorPol, + + "aci_netflow_record_policy": CreateNetflowRecordPol, + + "aci_relation_to_netflow_exporter": CreateNetflowRsMonitorToExporter, + + "aci_pim_route_map_entry": CreatePimRouteMapEntry, + + "aci_pim_route_map_policy": CreatePimRouteMapPol, + + "aci_custom_qos_policy": CreateQosCustomPol, + + "aci_data_plane_policing_policy": CreateQosDppPol, + + "aci_route_control_profile": CreateRtctrlProfile, + + "aci_annotation": CreateTagAnnotation, + + "aci_tag": CreateTagTag, + + "aci_out_of_band_contract": CreateVzOOBBrCP, } diff --git a/convert_funcs/conversion_route_control_profile.go b/convert_funcs/route_control_profile.go similarity index 93% rename from convert_funcs/conversion_route_control_profile.go rename to convert_funcs/route_control_profile.go index fb92c7fc9..15b44cf36 100644 --- a/convert_funcs/conversion_route_control_profile.go +++ b/convert_funcs/route_control_profile.go @@ -20,9 +20,6 @@ func CreateRtctrlProfile(attributes map[string]interface{}, status string) map[s if v, ok := attributes["annotation"].(string); ok && v != "" { data.Annotation = types.StringValue(v) } - if v, ok := attributes["route_map_continue"].(string); ok && v != "" { - data.AutoContinue = types.StringValue(v) - } if v, ok := attributes["description"].(string); ok && v != "" { data.Descr = types.StringValue(v) } @@ -38,14 +35,10 @@ func CreateRtctrlProfile(attributes map[string]interface{}, status string) map[s if v, ok := attributes["owner_tag"].(string); ok && v != "" { data.OwnerTag = types.StringValue(v) } - if v, ok := attributes["route_control_profile_type"].(string); ok && v != "" { - data.Type = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationRtctrlProfile(attributes["annotations"]) planTagTag := convertToTagTagRtctrlProfile(attributes["tags"]) if status == "deleted" { - provider.SetRtctrlProfileId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "rtctrlProfile", data.Id.ValueString()) @@ -55,7 +48,6 @@ func CreateRtctrlProfile(attributes map[string]interface{}, status string) map[s json.Unmarshal(jsonPayload, &customData) return customData } - } newAciRtctrlProfile := provider.GetRtctrlProfileCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_tag.go b/convert_funcs/tag.go similarity index 99% rename from convert_funcs/conversion_tag.go rename to convert_funcs/tag.go index 4d320b5cd..905c29bf5 100644 --- a/convert_funcs/conversion_tag.go +++ b/convert_funcs/tag.go @@ -25,7 +25,6 @@ func CreateTagTag(attributes map[string]interface{}, status string) map[string]i } if status == "deleted" { - provider.SetTagTagId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "tagTag", data.Id.ValueString()) @@ -35,7 +34,6 @@ func CreateTagTag(attributes map[string]interface{}, status string) map[string]i json.Unmarshal(jsonPayload, &customData) return customData } - } newAciTagTag := provider.GetTagTagCreateJsonPayload(ctx, &diags, true, data) diff --git a/convert_funcs/conversion_trust_control_policy.go b/convert_funcs/trust_control_policy.go similarity index 83% rename from convert_funcs/conversion_trust_control_policy.go rename to convert_funcs/trust_control_policy.go index c1bdc2132..20655dc73 100644 --- a/convert_funcs/conversion_trust_control_policy.go +++ b/convert_funcs/trust_control_policy.go @@ -23,15 +23,6 @@ func CreateFhsTrustCtrlPol(attributes map[string]interface{}, status string) map if v, ok := attributes["description"].(string); ok && v != "" { data.Descr = types.StringValue(v) } - if v, ok := attributes["has_dhcpv4_server"].(string); ok && v != "" { - data.HasDhcpv4Server = types.StringValue(v) - } - if v, ok := attributes["has_dhcpv6_server"].(string); ok && v != "" { - data.HasDhcpv6Server = types.StringValue(v) - } - if v, ok := attributes["has_ipv6_router"].(string); ok && v != "" { - data.HasIpv6Router = types.StringValue(v) - } if v, ok := attributes["name"].(string); ok && v != "" { data.Name = types.StringValue(v) } @@ -44,20 +35,10 @@ func CreateFhsTrustCtrlPol(attributes map[string]interface{}, status string) map if v, ok := attributes["owner_tag"].(string); ok && v != "" { data.OwnerTag = types.StringValue(v) } - if v, ok := attributes["trust_arp"].(string); ok && v != "" { - data.TrustArp = types.StringValue(v) - } - if v, ok := attributes["trust_nd"].(string); ok && v != "" { - data.TrustNd = types.StringValue(v) - } - if v, ok := attributes["trust_ra"].(string); ok && v != "" { - data.TrustRa = types.StringValue(v) - } planTagAnnotation := convertToTagAnnotationFhsTrustCtrlPol(attributes["annotations"]) planTagTag := convertToTagTagFhsTrustCtrlPol(attributes["tags"]) if status == "deleted" { - provider.SetFhsTrustCtrlPolId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fhsTrustCtrlPol", data.Id.ValueString()) @@ -67,7 +48,6 @@ func CreateFhsTrustCtrlPol(attributes map[string]interface{}, status string) map json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFhsTrustCtrlPol := provider.GetFhsTrustCtrlPolCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_vrf_fallback_route.go b/convert_funcs/vrf_fallback_route.go similarity index 99% rename from convert_funcs/conversion_vrf_fallback_route.go rename to convert_funcs/vrf_fallback_route.go index 7415adb83..b0ce548cb 100644 --- a/convert_funcs/conversion_vrf_fallback_route.go +++ b/convert_funcs/vrf_fallback_route.go @@ -36,7 +36,6 @@ func CreateFvFBRoute(attributes map[string]interface{}, status string) map[strin planTagTag := convertToTagTagFvFBRoute(attributes["tags"]) if status == "deleted" { - provider.SetFvFBRouteId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvFBRoute", data.Id.ValueString()) @@ -46,7 +45,6 @@ func CreateFvFBRoute(attributes map[string]interface{}, status string) map[strin json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvFBRoute := provider.GetFvFBRouteCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_vrf_fallback_route_group.go b/convert_funcs/vrf_fallback_route_group.go similarity index 99% rename from convert_funcs/conversion_vrf_fallback_route_group.go rename to convert_funcs/vrf_fallback_route_group.go index acbefc535..9595504ef 100644 --- a/convert_funcs/conversion_vrf_fallback_route_group.go +++ b/convert_funcs/vrf_fallback_route_group.go @@ -35,7 +35,6 @@ func CreateFvFBRGroup(attributes map[string]interface{}, status string) map[stri planTagTag := convertToTagTagFvFBRGroup(attributes["tags"]) if status == "deleted" { - provider.SetFvFBRGroupId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvFBRGroup", data.Id.ValueString()) @@ -45,7 +44,6 @@ func CreateFvFBRGroup(attributes map[string]interface{}, status string) map[stri json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvFBRGroup := provider.GetFvFBRGroupCreateJsonPayload(ctx, &diags, true, data, planFvFBRMember, planFvFBRMember, planFvFBRoute, planFvFBRoute, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/convert_funcs/conversion_vrf_fallback_route_group_member.go b/convert_funcs/vrf_fallback_route_group_member.go similarity index 99% rename from convert_funcs/conversion_vrf_fallback_route_group_member.go rename to convert_funcs/vrf_fallback_route_group_member.go index 1c6a0ba9f..a3f59795c 100644 --- a/convert_funcs/conversion_vrf_fallback_route_group_member.go +++ b/convert_funcs/vrf_fallback_route_group_member.go @@ -36,7 +36,6 @@ func CreateFvFBRMember(attributes map[string]interface{}, status string) map[str planTagTag := convertToTagTagFvFBRMember(attributes["tags"]) if status == "deleted" { - provider.SetFvFBRMemberId(ctx, data) deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "fvFBRMember", data.Id.ValueString()) @@ -46,7 +45,6 @@ func CreateFvFBRMember(attributes map[string]interface{}, status string) map[str json.Unmarshal(jsonPayload, &customData) return customData } - } newAciFvFBRMember := provider.GetFvFBRMemberCreateJsonPayload(ctx, &diags, true, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) diff --git a/dict/dict.go b/dict/dict.go new file mode 100644 index 000000000..251dac954 --- /dev/null +++ b/dict/dict.go @@ -0,0 +1,80 @@ +package dict + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "strings" +) + +func GetDnToAciClassMap(childClass string, parentPrefix string) string { + rnMapping := make(map[string]map[string]string) + + resp, err := http.Get("https://pubhub.devnetcloud.com/media/model-doc-latest/docs/doc/jsonmeta/aci-meta.json") + if err != nil { + fmt.Printf("Error fetching metadata from URL: %v\n", err) + return "" + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + fmt.Printf("Error fetching metadata: received non-200 status code %d\n", resp.StatusCode) + return "" + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + fmt.Printf("Error reading response body: %v\n", err) + return "" + } + + var metaData map[string]interface{} + err = json.Unmarshal(body, &metaData) + if err != nil { + fmt.Printf("Error unmarshalling JSON: %v\n", err) + return "" + } + + classes, ok := metaData["classes"].(map[string]interface{}) + if !ok { + fmt.Println("Invalid format for classes in metadata") + return "" + } + + for aciClassName, aciClassInfoRaw := range classes { + aciClassInfo, ok := aciClassInfoRaw.(map[string]interface{}) + if !ok { + continue + } + + rnFormat, ok := aciClassInfo["rnFormat"].(string) + if !ok { + continue + } + rnPrefix := strings.Split(rnFormat, "-")[0] + + rnMap, ok := aciClassInfo["rnMap"].(map[string]interface{}) + if !ok { + continue + } + + for _, childClassRaw := range rnMap { + childClass, ok := childClassRaw.(string) + if !ok { + continue + } + + if _, exists := rnMapping[childClass]; !exists { + rnMapping[childClass] = map[string]string{} + } + rnMapping[childClass][rnPrefix] = aciClassName + } + } + + if class, found := rnMapping[childClass][parentPrefix]; found { + return class + } + + return "" +} diff --git a/gen/generator.go b/gen/generator.go index 2afa66bb0..a67d04341 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -81,8 +81,10 @@ const pubhupDevnetBaseUrl = "https://pubhub.devnetcloud.com/media/model-doc-late // The map contains a key which is the name of the function used in the template and a value which is the function itself // The functions itself are defined in the current file var templateFuncs = template.FuncMap{ + "isStringType": isStringType, + "trimPrefixBasedOnClass": trimPrefixBasedOnClass, + "getRnPrefix": getRnPrefix, "extractPrefix": extractPrefix, - "trimRnName": trimRnName, "lowercaseFirst": LowercaseFirst, "snakeCase": Underscore, "validatorString": ValidatorString, @@ -137,6 +139,30 @@ func ContainsRequired(properties map[string]Property) bool { return false } +func trimPrefixBasedOnClass(rnFormat string, resourceClassName string) string { + // Split the rnFormat by the "-" character to separate segments + segments := strings.Split(rnFormat, "-") + + // If there is only one segment, return it as is + if len(segments) == 1 { + return segments[0] + } + + // If there are multiple segments, we can apply a more sophisticated rule. + // Let's assume the goal is to find the segment that most likely matches the prefix structure: + // Typically, the prefix is the first or second segment. + + // Example dynamic rule: The prefix is often the segment that does not contain brackets "[]" + for _, segment := range segments { + if !strings.Contains(segment, "[") && !strings.Contains(segment, "]") { + return segment + } + } + + // Fallback: return the first segment if no other rule applies + return segments[0] +} + func Replace(oldValue, newValue, inputString string) string { return strings.Replace(inputString, oldValue, newValue, -1) } @@ -188,6 +214,11 @@ func GetPropertyNameForLegacyAttribute(name string, legacyAttributes map[string] } return "" } +func getRnPrefix(rnFormat string) string { + // Split the rnFormat by "-" and take the first element + parts := strings.Split(rnFormat, "-") + return parts[0] +} func GetLegacyChildAttribute(className, overwriteProperty string, property Property, legacyAttributes map[string]LegacyAttribute, legacyBlocks []LegacyBlock) string { @@ -415,6 +446,8 @@ func renderTemplate(templateName, outputFileName, outputPath string, outputData // The templates have a different data structure, thus based on the template name the output data is casted to the correct type if templateName == "provider.go.tmpl" { err = tmpl.Execute(&buffer, outputData.(map[string]Model)) + } else if templateName == "resourceMap.go.tmpl" { + err = tmpl.Execute(&buffer, outputData.(map[string]Model)) } else if templateName == "index.md.tmpl" { err = tmpl.Execute(&buffer, outputData.(ProviderModel)) } else if strings.Contains(templateName, "_test.go.tmpl") { @@ -498,7 +531,9 @@ func getClassModels(definitions Definitions) map[string]Model { classModel := Model{PkgName: pkgName} classModel.setClassModel(metaPath, false, definitions, []string{}, pkgNames) + classModel.ResourceName = GetResourceName(pkgName, definitions) classModels[pkgName] = classModel + } return classModels } @@ -520,7 +555,7 @@ func getTestVars(model Model) (map[string]interface{}, error) { return testVarsMap, nil } -// Retrieves the property and classs overwrite definitions from the definitions YAML files +// Retrieves the property and classes overwrite definitions from the definitions YAML files func getDefinitions() Definitions { definitions := Definitions{} files, err := os.ReadDir(definitionsPath) @@ -742,6 +777,8 @@ func main() { annotationUnsupported := genAnnotationUnsupported() renderTemplate("provider.go.tmpl", "provider.go", providerPath, classModels) + renderTemplate("resourceMap.go.tmpl", "resourceMap.go", conversionPath, classModels) + renderTemplate("index.md.tmpl", "index.md", docsPath, ProviderModel{Example: string(getExampleCode(providerExamplePath))}) if len(annotationUnsupported) > 0 { err := os.Remove(filepath.Join(providerPath, "annotation_unsupported.go")) @@ -823,25 +860,7 @@ func main() { renderTemplate("datasource.md.tmpl", fmt.Sprintf("%s.md", model.ResourceName), datasourcesDocsPath, model) renderTemplate("resource_test.go.tmpl", fmt.Sprintf("resource_%s_%s_test.go", providerName, model.ResourceName), providerPath, model) renderTemplate("datasource_test.go.tmpl", fmt.Sprintf("data_source_%s_%s_test.go", providerName, model.ResourceName), providerPath, model) - renderTemplate("conversion.go.tmpl", fmt.Sprintf("conversion_%s.go", model.ResourceName), conversionPath, model) - - allModels := []Model{} - - for _, model := range classModels { - if len(model.IdentifiedBy) > 0 || model.Include { - model.ResourceName = GetResourceName(model.PkgName, definitions) - - allModels = append(allModels, model) - } - } - - data := map[string]interface{}{ - "Models": allModels, - } - - renderTemplateModels("resourceMap.go.tmpl", "resourceMap.go", conversionPath, data) - renderTemplateModels("getAciClass.go.tmpl", "getAciClass.go", conversionPath, data) - //renderTemplateModels("new.go.tmpl", "dn_to_aci.go", conversionPath, data) + renderTemplate("conversion.go.tmpl", fmt.Sprintf("%s.go", model.ResourceName), conversionPath, model) } } @@ -982,10 +1001,12 @@ type Property struct { Versions string NamedPropertyClass string IgnoreInTestExampleValue string - ValidValues []string - IdentifiedBy []interface{} - Validators []interface{} - IdentifyProperties []Property + GoType string // Add this field + + ValidValues []string + IdentifiedBy []interface{} + Validators []interface{} + IdentifyProperties []Property // Below booleans are used during template rendering to determine correct rendering the go code IsNaming bool CreateOnly bool @@ -1303,6 +1324,11 @@ func (m *Model) SetResourceNotesAndWarnigns(classPkgName string, definitions Def } } +func isStringType(property Property) bool { + // Logic to determine if a property is of type "types.String" + return property.GoType == "types.String" +} + func (m *Model) SetResourceNameAsDescription(classPkgName string, definitions Definitions) { m.ResourceNameAsDescription = GetResourceNameAsDescription(GetResourceName(classPkgName, definitions), definitions) } @@ -1515,6 +1541,16 @@ func (m *Model) SetClassProperties(classDetails interface{}) { m.HasNamedProperties = true } + uiType := propertyValue.(map[string]interface{})["uitype"].(string) + + if uiType == "string" { + property.GoType = "types.String" + } else if uiType == "set" { + property.GoType = "types.Set" + } else if uiType == "list" { + property.GoType = "types.List" + } + properties[propertyName] = property } diff --git a/gen/templates/conversion.go.tmpl b/gen/templates/conversion.go.tmpl index c624ae62f..cc9aa0277 100644 --- a/gen/templates/conversion.go.tmpl +++ b/gen/templates/conversion.go.tmpl @@ -10,15 +10,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -{{- $resourceClassName := .ResourceClassName }} -{{- $resourceName := .ResourceName }} -{{- $properties := .Properties }} -{{- $children := .Children }} - -func Create{{ $resourceClassName }}(attributes map[string]interface{}, status string) map[string]interface{} { +func Create{{ .ResourceClassName }}(attributes map[string]interface{}, status string) map[string]interface{} { ctx := context.Background() var diags diag.Diagnostics - data := &provider.{{ $resourceClassName }}ResourceModel{} + data := &provider.{{ .ResourceClassName }}ResourceModel{} {{- if .HasParent }} if v, ok := attributes["parent_dn"].(string); ok && v != "" { @@ -26,57 +21,58 @@ func Create{{ $resourceClassName }}(attributes map[string]interface{}, status st } {{- end }} - {{- range $properties }} - if v, ok := attributes["{{ overwriteProperty .PkgName .SnakeCaseName $.Definitions }}"].(string); ok && v != "" { - data.{{ if eq .Name "Id" }}{{ $resourceClassName }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} = types.StringValue(v) - } - {{- end }} - {{- range $children }} - plan{{ .ResourceClassName }} := convertTo{{ .ResourceClassName }}{{ $resourceClassName }}(attributes["{{ .ResourceName }}"]) - {{- end }} + {{- range .Properties }} + {{- if eq .GoType "types.String" }} + if v, ok := attributes["{{ overwriteProperty .PkgName .SnakeCaseName $.Definitions }}"].(string); ok && v != "" { + data.{{ if eq .Name "Id" }}{{ $.ResourceClassName }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} = types.StringValue(v) + } + {{- end }} +{{- end }} + - if status == "deleted" { + {{- range .Children }} + plan{{ .ResourceClassName }} := convertTo{{ .ResourceClassName }}{{ $.ResourceClassName }}(attributes["{{ .ResourceName }}"]) + {{- end }} - provider.Set{{ $resourceClassName }}Id(ctx, data) - - deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "{{ lowercaseFirst $resourceClassName }}", data.Id.ValueString()) - if deletePayload != nil { - jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) - var customData map[string]interface{} - json.Unmarshal(jsonPayload, &customData) - return customData - } - + if status == "deleted" { + provider.Set{{ .ResourceClassName }}Id(ctx, data) + + deletePayload := provider.GetDeleteJsonPayload(ctx, &diags, "{{ lowercaseFirst .ResourceClassName }}", data.Id.ValueString()) + if deletePayload != nil { + jsonPayload := deletePayload.EncodeJSON(container.EncodeOptIndent("", " ")) + var customData map[string]interface{} + json.Unmarshal(jsonPayload, &customData) + return customData + } } + newAci{{ .ResourceClassName }} := provider.Get{{ .ResourceClassName }}CreateJsonPayload(ctx, &diags, true, data + {{- range .Children }}, plan{{ .ResourceClassName }}, plan{{ .ResourceClassName }}{{- end }}) - newAci{{ $resourceClassName }} := provider.Get{{ $resourceClassName }}CreateJsonPayload(ctx, &diags, true, data - {{- range $children }}, plan{{ .ResourceClassName }}, plan{{ .ResourceClassName }}{{- end }}) - - jsonPayload := newAci{{ $resourceClassName }}.EncodeJSON(container.EncodeOptIndent("", " ")) + jsonPayload := newAci{{ .ResourceClassName }}.EncodeJSON(container.EncodeOptIndent("", " ")) var customData map[string]interface{} json.Unmarshal(jsonPayload, &customData) payload := customData - provider.Set{{ $resourceClassName }}Id(ctx, data) - attrs := payload["{{ lowercaseFirst $resourceClassName }}"].(map[string]interface{})["attributes"].(map[string]interface{}) + provider.Set{{ .ResourceClassName }}Id(ctx, data) + attrs := payload["{{ lowercaseFirst .ResourceClassName }}"].(map[string]interface{})["attributes"].(map[string]interface{}) attrs["dn"] = data.Id.ValueString() return payload } -{{- range $children }} -func convertTo{{ .ResourceClassName }}{{ $resourceClassName }}(resources interface{}) []provider.{{ .ResourceClassName }}{{ $resourceClassName }}ResourceModel { - var planResources []provider.{{ .ResourceClassName }}{{ $resourceClassName }}ResourceModel +{{- range .Children }} +func convertTo{{ .ResourceClassName }}{{ $.ResourceClassName }}(resources interface{}) []provider.{{ .ResourceClassName }}{{ $.ResourceClassName }}ResourceModel { + var planResources []provider.{{ .ResourceClassName }}{{ $.ResourceClassName }}ResourceModel if resources, ok := resources.([]interface{}); ok { for _, resource := range resources { resourceMap := resource.(map[string]interface{}) - planResources = append(planResources, provider.{{ .ResourceClassName }}{{ $resourceClassName }}ResourceModel{ + planResources = append(planResources, provider.{{ .ResourceClassName }}{{ $.ResourceClassName }}ResourceModel{ {{- range .Properties }} {{ .Name }}: types.StringValue(resourceMap["{{ overwriteProperty .PkgName .SnakeCaseName $.Definitions }}"].(string)), {{- end }} diff --git a/gen/templates/datasource.go.tmpl b/gen/templates/datasource.go.tmpl index 3cbe50a42..916d04fad 100644 --- a/gen/templates/datasource.go.tmpl +++ b/gen/templates/datasource.go.tmpl @@ -222,4 +222,4 @@ func (d *{{.ResourceClassName}}DataSource) Read(ctx context.Context, req datasou // Save data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_{{.ResourceName}} with id '%s'", data.Id.ValueString())) -} +} \ No newline at end of file diff --git a/gen/templates/getAciClass.go.tmpl b/gen/templates/getAciClass.go.tmpl deleted file mode 100644 index a5ae3e891..000000000 --- a/gen/templates/getAciClass.go.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -package convert_funcs - - -type GetAciClass func(string) string - -func AciClassMap(prefix string) string { - mapping := map[string]string{ - {{- range $index, $model := .Models }} - "{{ extractPrefix $model.RnFormat }}": "{{ lowercaseFirst $model.ResourceClassName }}", - {{- end }} - } - - if class, found := mapping[prefix]; found { - return class - } - return "" -} - diff --git a/gen/templates/new.go.tmpl b/gen/templates/new.go.tmpl deleted file mode 100644 index 9b9300cfb..000000000 --- a/gen/templates/new.go.tmpl +++ /dev/null @@ -1,24 +0,0 @@ -package convert_funcs - - -func dn_to_class(prefix string) string { - - mapping := map[string]string{ - - {{- range $pkgName, $model := .Models }} - - {{- range $childClass := $model.ChildClasses }} - - "{{ $childClass }}-{{ extractPrefix $model.RnFormat }}": - "{{ lowercaseFirst $model.ResourceClassName }}", - - {{- end }} - {{- end }} - } - - if className, found := mapping[prefix]; found { - return className - } - - return "" -} \ No newline at end of file diff --git a/gen/templates/resourceMap.go.tmpl b/gen/templates/resourceMap.go.tmpl index f17ad41c9..40a2b1fec 100644 --- a/gen/templates/resourceMap.go.tmpl +++ b/gen/templates/resourceMap.go.tmpl @@ -1,9 +1,13 @@ + + package convert_funcs type createFunc func(map[string]interface{}, string) map[string]interface{} var ResourceMap = map[string]createFunc{ - {{- range $pkgName, $model := .Models }} - "aci_{{ $model.ResourceName }}": Create{{ $model.ResourceClassName }}, - {{- end }} -} \ No newline at end of file + {{- range . }} + {{- if or (and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))) .Include}} + "aci_{{ .ResourceName }}": Create{{ .ResourceClassName }}, + {{end}} + {{end}} +} From 13934c52e07876208d3601310d8acec505037266 Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Sun, 25 Aug 2024 14:48:40 -0700 Subject: [PATCH 05/10] [ignore] --- gen/generator.go | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/gen/generator.go b/gen/generator.go index a67d04341..cd7b4f257 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -82,9 +82,6 @@ const pubhupDevnetBaseUrl = "https://pubhub.devnetcloud.com/media/model-doc-late // The functions itself are defined in the current file var templateFuncs = template.FuncMap{ "isStringType": isStringType, - "trimPrefixBasedOnClass": trimPrefixBasedOnClass, - "getRnPrefix": getRnPrefix, - "extractPrefix": extractPrefix, "lowercaseFirst": LowercaseFirst, "snakeCase": Underscore, "validatorString": ValidatorString, @@ -139,30 +136,6 @@ func ContainsRequired(properties map[string]Property) bool { return false } -func trimPrefixBasedOnClass(rnFormat string, resourceClassName string) string { - // Split the rnFormat by the "-" character to separate segments - segments := strings.Split(rnFormat, "-") - - // If there is only one segment, return it as is - if len(segments) == 1 { - return segments[0] - } - - // If there are multiple segments, we can apply a more sophisticated rule. - // Let's assume the goal is to find the segment that most likely matches the prefix structure: - // Typically, the prefix is the first or second segment. - - // Example dynamic rule: The prefix is often the segment that does not contain brackets "[]" - for _, segment := range segments { - if !strings.Contains(segment, "[") && !strings.Contains(segment, "]") { - return segment - } - } - - // Fallback: return the first segment if no other rule applies - return segments[0] -} - func Replace(oldValue, newValue, inputString string) string { return strings.Replace(inputString, oldValue, newValue, -1) } @@ -214,11 +187,6 @@ func GetPropertyNameForLegacyAttribute(name string, legacyAttributes map[string] } return "" } -func getRnPrefix(rnFormat string) string { - // Split the rnFormat by "-" and take the first element - parts := strings.Split(rnFormat, "-") - return parts[0] -} func GetLegacyChildAttribute(className, overwriteProperty string, property Property, legacyAttributes map[string]LegacyAttribute, legacyBlocks []LegacyBlock) string { @@ -258,14 +226,6 @@ func LowercaseFirst(str string) string { return strings.ToLower(string(str[0])) + str[1:] } -func extractPrefix(rnFormat string) string { - segments := strings.Split(rnFormat, "/") - lastSegment := segments[len(segments)-1] - - prefix := strings.SplitN(lastSegment, "-", 2)[0] - - return prefix -} func GetNewChildAttributes(legacyAttributes map[string]LegacyAttribute, properties map[string]Property) []Property { result := []Property{} for _, property := range properties { From 6af4375d97c1b008ce1621a3b3e342ad41c0eaef Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Sun, 25 Aug 2024 15:18:40 -0700 Subject: [PATCH 06/10] [ignore] --- gen/generator.go | 53 ------------------------------------------------ 1 file changed, 53 deletions(-) diff --git a/gen/generator.go b/gen/generator.go index cd7b4f257..2fdc0bb6d 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -445,59 +445,6 @@ func renderTemplate(templateName, outputFileName, outputPath string, outputData outputFile.Write(bytes) } -func renderTemplateModels(templateName, outputFileName, outputPath string, outputData interface{}) { - templateData, err := os.ReadFile(fmt.Sprintf("%s/%s", templatePath, templateName)) - if err != nil { - panic(err) - } - var buffer bytes.Buffer - tmpl := template.Must(template.New("").Funcs(templateFuncs).Parse(string(templateData))) - - err = tmpl.Execute(&buffer, outputData) - if err != nil { - panic(err) - } - bytes := buffer.Bytes() - if strings.Contains(templateName, "go.tmpl") { - bytes, err = format.Source(buffer.Bytes()) - if err != nil { - os.WriteFile(fmt.Sprintf("%s/failed_render.go", outputPath), buffer.Bytes(), 0644) - panic(err) - } - } - - outputFile, err := os.Create(fmt.Sprintf("%s/%s", outputPath, outputFileName)) - if err != nil { - panic(err) - } - outputFile.Write(bytes) -} - -// Creates a map of models for the resources and datasources from the meta data and definitions -func getClassModels(definitions Definitions) map[string]Model { - files, err := os.ReadDir(metaPath) - if err != nil { - panic(err) - } - classModels := make(map[string]Model) - pkgNames := []string{} - for _, file := range files { - if path.Ext(file.Name()) != ".json" { - continue - } - pkgNames = append(pkgNames, strings.TrimSuffix(file.Name(), path.Ext(file.Name()))) - } - for _, pkgName := range pkgNames { - - classModel := Model{PkgName: pkgName} - classModel.setClassModel(metaPath, false, definitions, []string{}, pkgNames) - classModel.ResourceName = GetResourceName(pkgName, definitions) - classModels[pkgName] = classModel - - } - return classModels -} - // Retrieves the testVars for a model from the testVars YAML file func getTestVars(model Model) (map[string]interface{}, error) { testVarsMap := make(map[string]interface{}) From 4a6e0c57f4f25674df424ee8f4e0ecae0395b2ed Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Sun, 25 Aug 2024 15:27:10 -0700 Subject: [PATCH 07/10] [ignore] --- gen/generator.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gen/generator.go b/gen/generator.go index 2fdc0bb6d..eab17441f 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -445,6 +445,31 @@ func renderTemplate(templateName, outputFileName, outputPath string, outputData outputFile.Write(bytes) } +// Creates a map of models for the resources and datasources from the meta data and definitions +func getClassModels(definitions Definitions) map[string]Model { + files, err := os.ReadDir(metaPath) + if err != nil { + panic(err) + } + classModels := make(map[string]Model) + pkgNames := []string{} + for _, file := range files { + if path.Ext(file.Name()) != ".json" { + continue + } + pkgNames = append(pkgNames, strings.TrimSuffix(file.Name(), path.Ext(file.Name()))) + } + for _, pkgName := range pkgNames { + + classModel := Model{PkgName: pkgName} + classModel.setClassModel(metaPath, false, definitions, []string{}, pkgNames) + classModel.ResourceName = GetResourceName(pkgName, definitions) + classModels[pkgName] = classModel + + } + return classModels +} + // Retrieves the testVars for a model from the testVars YAML file func getTestVars(model Model) (map[string]interface{}, error) { testVarsMap := make(map[string]interface{}) From 23d0e1a52dc2848ccfa9afa81e563a3b04ac2be8 Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Wed, 28 Aug 2024 15:30:56 -0700 Subject: [PATCH 08/10] [minor_changes] added test and revised documentation --- README.md | 80 ++++++++++++++++++++++++- cmd/conversion/main.go | 130 +++++++++++++++++++++++++++++++++++------ cmd/conversion/main.tf | 10 ++-- gen/generator.go | 27 ++------- test/test.go | 113 +++++++++++++++++++++++++++++++++++ 5 files changed, 313 insertions(+), 47 deletions(-) create mode 100644 test/test.go diff --git a/README.md b/README.md index dd5c0e036..19e484706 100644 --- a/README.md +++ b/README.md @@ -286,7 +286,7 @@ To compile the provider, run `make build`. This will build the provider with san } ``` -NOTE: Currently only resource properties supports the reflecting manual changes made in CISCO ACI. Manual changes to relationship is not taken care by the provider. +NOTE: Currently only resource properties supports the reflecting manual changes made in Cisco ACI. Manual changes to relationship is not taken care by the provider. ### Payload Generation @@ -300,4 +300,80 @@ $cd cmd/conversion 3. Run: $ go run main.go -4. Payload will be written to payload.json \ No newline at end of file +4. Payload will be written to payload.json + +Example Terraform configuration: + +resource "aci_application_epg" "fooapplication_epg2" { + parent_dn = "uni/tn-common/ap-default222" + name = "new_epg2" + description = "from terraform" + annotation = "tag_epg" + contract_exception_tag = "0" + flood_in_encapsulation = "disabled" + + relation_to_bridge_domain= [{ + annotation = "annotation1" + bridge_domain_name = "default" + }] +} + +payload.json output: + +{ + "imdata": [ + { + "fvTenant": { + "attributes": { + "dn": "uni/tn-common" + }, + "children": [ + { + "fvAp": { + "attributes": { + "dn": "uni/tn-common/ap-default222" + }, + "children": [ + { + "fvAEPg": { + "attributes": { + "annotation": "tag_epg", + "descr": "from terraform", + "dn": "uni/tn-common/ap-default222/epg-new_epg2", + "exceptionTag": "0", + "name": "new_epg2", + "status": "created" + }, + "children": [ + { + "fvRsBd": { + "attributes": { + "annotation": "annotation1", + "tnFvBDName": "default" + } + } + } + ] + } + } + ] + } + } + ] + } + } + ] +} + + +Default expects main.tf to be in the same file as converter. To run the converter with your Terraform file in a seperate directory, run: + +$ go run main.go -dir path/to/your/main/tf + +To test to confirm if a generated payload is valid, use test flag: + +$ go run main.go -test + +This will POST payload.json to the specificed APIC in test.go, then checks to see if Terraform Plan reflects these changes as expected (no changes planned = success) + + \ No newline at end of file diff --git a/cmd/conversion/main.go b/cmd/conversion/main.go index dee41ac72..6f072d347 100644 --- a/cmd/conversion/main.go +++ b/cmd/conversion/main.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "flag" "fmt" "log" "os" @@ -10,6 +11,11 @@ import ( "github.com/CiscoDevNet/terraform-provider-aci/v2/convert_funcs" "github.com/CiscoDevNet/terraform-provider-aci/v2/dict" + "github.com/CiscoDevNet/terraform-provider-aci/v2/test" +) + +const ( + payloadFile = "payload.json" ) type Plan struct { @@ -35,17 +41,25 @@ type Change struct { } `json:"change"` } -func runTerraform() (string, error) { +func runTerraform(workingDir string) (string, error) { planBin := "plan.bin" planJSON := "plan.json" + if err := os.Chdir(workingDir); err != nil { + return "", fmt.Errorf("failed to change directory: %w", err) + } + + if err := exec.Command("terraform", "init").Run(); err != nil { + return "", fmt.Errorf("failed to run terraform init: %w", err) + } + if err := exec.Command("terraform", "plan", "-out="+planBin).Run(); err != nil { return "", fmt.Errorf("failed to run terraform plan: %w", err) } output, err := os.Create(planJSON) if err != nil { - return "", fmt.Errorf("failed to create json file: %w", err) + return "", fmt.Errorf("failed to create JSON file: %w", err) } defer output.Close() @@ -69,6 +83,9 @@ func readPlan(jsonFile string) (Plan, error) { return plan, fmt.Errorf("failed to parse input file: %w", err) } + os.Remove("plan.bin") + os.Remove("plan.json") + return plan, nil } @@ -163,7 +180,21 @@ func constructTree(resources []map[string]interface{}) map[string]interface{} { } } - return map[string]interface{}{rootNode.ClassName: exportTree(rootNode)} + removeParentDn(rootNode) + + tenants := filterTenants(rootNode) + if len(tenants) > 1 { + return map[string]interface{}{ + "polUni": map[string]interface{}{ + "attributes": map[string]interface{}{}, + "children": tenants, + }, + } + } + + return map[string]interface{}{ + "imdata": tenants, + } } func buildParentPath(dnMap map[string]*TreeNode, rootNode *TreeNode, resourceType, dn string, attributes map[string]interface{}, children []map[string]interface{}) { @@ -178,7 +209,6 @@ func buildParentPath(dnMap map[string]*TreeNode, rootNode *TreeNode, resourceTyp var leafNode *TreeNode if existingLeafNode, exists := dnMap[dn]; exists { - for key, value := range attributes { existingLeafNode.Attributes[key] = value } @@ -216,6 +246,16 @@ func buildParentPath(dnMap map[string]*TreeNode, rootNode *TreeNode, resourceTyp } } +func filterTenants(node *TreeNode) []map[string]interface{} { + tenants := []map[string]interface{}{} + for _, child := range node.Children { + if child.ClassName == "fvTenant" { + tenants = append(tenants, exportTree(child)) + } + } + return tenants +} + func generateUniqueKeyForNonDnNode(resourceType string, attributes map[string]interface{}) string { return fmt.Sprintf("%s-%v", resourceType, attributes["name"]) } @@ -260,7 +300,6 @@ func parseClassNames(pathSegments []string, resourceType string) []string { classNames[i], classNames[j] = classNames[j], classNames[i] } return classNames - } func exportTree(node *TreeNode) map[string]interface{} { @@ -269,22 +308,34 @@ func exportTree(node *TreeNode) map[string]interface{} { } result := map[string]interface{}{ - "attributes": node.Attributes, + node.ClassName: map[string]interface{}{ + "attributes": node.Attributes, + }, } if len(node.Children) > 0 { children := []map[string]interface{}{} for _, child := range node.Children { - children = append(children, map[string]interface{}{ - child.ClassName: exportTree(child), - }) + children = append(children, exportTree(child)) } - result["children"] = children + result[node.ClassName].(map[string]interface{})["children"] = children } return result } +func removeParentDn(node *TreeNode) { + if node == nil { + return + } + + delete(node.Attributes, "parent_dn") + + for _, child := range node.Children { + removeParentDn(child) + } +} + func safeMapInterface(data map[string]interface{}, key string) map[string]interface{} { if value, ok := data[key].(map[string]interface{}); ok { return value @@ -300,14 +351,12 @@ func safeString(data map[string]interface{}, key string) string { } func main() { - if len(os.Args) != 1 { - fmt.Println("Usage: no arguments needed") - os.Exit(1) - } + testFlag := flag.Bool("test", false, "Run the test to POST payload to APIC and validate change") + workingDir := flag.String("dir", ".", "Path to the directory containing Terraform file") - outputFile := "payload.json" + flag.Parse() - planJSON, err := runTerraform() + planJSON, err := runTerraform(*workingDir) if err != nil { log.Fatalf("Error running Terraform: %v", err) } @@ -321,10 +370,55 @@ func main() { aciTree := constructTree(payloadList) - err = writeToFile(outputFile, aciTree) + err = writeToFile(payloadFile, aciTree) if err != nil { log.Fatalf("Error writing output file: %v", err) } - fmt.Printf("ACI Payload written to %s\n", outputFile) + fmt.Printf("ACI Payload written to %s\n", payloadFile) + + if *testFlag { + fmt.Println("Testing...") + + if _, err := os.Stat(payloadFile); os.IsNotExist(err) { + fmt.Printf("Expected %s not found: %v\n", payloadFile, err) + os.Exit(3) + } + + payload, err := os.ReadFile(payloadFile) + if err != nil { + fmt.Printf("Failed to read %s: %v\n", payloadFile, err) + os.Exit(4) + } + + token, err := test.GetAPICLoginToken() + if err != nil { + fmt.Printf("Failed to obtain login token: %v\n", err) + os.Exit(5) + } + + err = test.PostToAPIC(token, payload) + if err != nil { + fmt.Printf("Failed to post payload to APIC: %v\n", err) + os.Exit(6) + } + + emptyPlan, err := test.CheckTerraformPlan() + if err != nil { + fmt.Printf("Terraform plan failed: %v\n", err) + os.Exit(7) + } + + if !emptyPlan { + fmt.Println("Terraform plan detected changes, the conversion was not successful") + + os.Remove("plan.bin") + os.Remove("plan.json") + os.Exit(8) + } + + os.Remove("plan.bin") + os.Remove("plan.json") + fmt.Println("Test passed: The conversion was successful") + } } diff --git a/cmd/conversion/main.tf b/cmd/conversion/main.tf index aea7400a4..d1ea5a748 100644 --- a/cmd/conversion/main.tf +++ b/cmd/conversion/main.tf @@ -9,11 +9,11 @@ terraform { # Configure the provider with your Cisco APIC credentials. provider "aci" { # APIC Username - username = "" + username = "admin" # APIC Password password = "" # APIC URL - url = "" + url = "https://sandboxapicdc.cisco.com" insecure = true } @@ -38,7 +38,6 @@ resource "aci_application_epg" "fooapplication_epg2" { annotation = "tag_epg" contract_exception_tag = "0" flood_in_encapsulation = "disabled" - forwarding_control = "none" relation_to_bridge_domain= [{ annotation = "annotation1" @@ -46,9 +45,10 @@ resource "aci_application_epg" "fooapplication_epg2" { }] } */ + /* resource "aci_application_epg" "fooapplication_epg5" { - parent_dn = "uni/tn-common/ap-default232" + parent_dn = "uni/tn-mgmt/ap-default555" name = "new_epg5" description = "from terraform" annotation = "tag_epg" @@ -77,7 +77,7 @@ resource "aci_endpoint_tag_ip" "full_example_tenant" { } */ - +//SUCCESS /* resource "aci_vrf_fallback_route_group" "full_example_vrf" { parent_dn = "uni/tn-common" diff --git a/gen/generator.go b/gen/generator.go index eab17441f..4b7f91b6c 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -933,12 +933,11 @@ type Property struct { Versions string NamedPropertyClass string IgnoreInTestExampleValue string - GoType string // Add this field - - ValidValues []string - IdentifiedBy []interface{} - Validators []interface{} - IdentifyProperties []Property + GoType string + ValidValues []string + IdentifiedBy []interface{} + Validators []interface{} + IdentifyProperties []Property // Below booleans are used during template rendering to determine correct rendering the go code IsNaming bool CreateOnly bool @@ -2084,22 +2083,6 @@ func getTestDependency(className string, targetMap map[interface{}]interface{}, return testDependency } -func mergeDuplicateKeys(mapping map[string]map[string]string) map[string]map[string]string { - mergedMapping := make(map[string]map[string]string) - - for childClass, prefixMap := range mapping { - if existingMap, found := mergedMapping[childClass]; found { - for prefix, className := range prefixMap { - existingMap[prefix] = className - } - } else { - mergedMapping[childClass] = prefixMap - } - } - - return mergedMapping -} - func GetTestTargetDn(targets []interface{}, resourceName, targetDnValue string, reference bool, targetClasses interface{}, index int) string { var filteredTargets []interface{} diff --git a/test/test.go b/test/test.go new file mode 100644 index 000000000..172a8da4d --- /dev/null +++ b/test/test.go @@ -0,0 +1,113 @@ +package test + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "os" + "os/exec" +) + +const ( + apicURL = "https://sandboxapicdc.cisco.com/api/node/mo/uni.json" + apicLoginURL = "https://sandboxapicdc.cisco.com/api/aaaLogin.json" + apicUsername = "admin" + apicPassword = "" +) + +func GetAPICLoginToken() (string, error) { + loginBody := map[string]interface{}{ + "aaaUser": map[string]interface{}{ + "attributes": map[string]string{ + "name": apicUsername, + "pwd": apicPassword, + }, + }, + } + + payloadBytes, err := json.Marshal(loginBody) + if err != nil { + return "", fmt.Errorf("failed to marshal login payload: %w", err) + } + + resp, err := http.Post(apicLoginURL, "application/json", bytes.NewBuffer(payloadBytes)) + if err != nil { + return "", fmt.Errorf("failed to send login request: %w", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(resp.Body) + return "", fmt.Errorf("unexpected status code %d: %s", resp.StatusCode, string(body)) + } + + var response map[string]interface{} + if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { + return "", fmt.Errorf("failed to decode login response: %w", err) + } + + token, ok := response["imdata"].([]interface{})[0].(map[string]interface{})["aaaLogin"].(map[string]interface{})["attributes"].(map[string]interface{})["token"].(string) + if !ok { + return "", fmt.Errorf("failed to extract token from response") + } + + return token, nil + +} + +func PostToAPIC(token string, payload []byte) error { + client := &http.Client{} + + req, err := http.NewRequest("POST", apicURL, bytes.NewBuffer(payload)) + if err != nil { + return fmt.Errorf("failed to create request: %w", err) + } + req.Header.Set("Cookie", "APIC-cookie="+token) + req.Header.Set("Content-Type", "application/json") + + resp, err := client.Do(req) + if err != nil { + return fmt.Errorf("failed to send request: %w", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(resp.Body) + return fmt.Errorf("unexpected status code %d: %s", resp.StatusCode, string(body)) + } + + return nil +} + +func CheckTerraformPlan() (bool, error) { + planBin := "plan.bin" + planJSON := "plan.json" + + cmdBin := exec.Command("terraform", "plan", "-refresh-only", "-out="+planBin) + if err := cmdBin.Run(); err != nil { + return false, fmt.Errorf("failed to run terraform plan: %w", err) + } + + cmdOutJson := exec.Command("terraform", "show", "-json", planBin) + output, err := cmdOutJson.Output() + if err != nil { + return false, fmt.Errorf("failed to show terraform plan: %w", err) + } + + if err := os.WriteFile(planJSON, output, 0644); err != nil { + return false, fmt.Errorf("failed to write JSON plan to file: %w", err) + } + + var plan map[string]interface{} + if err := json.Unmarshal(output, &plan); err != nil { + return false, fmt.Errorf("failed to parse terraform plan output: %w", err) + } + + if changes, ok := plan["planned_values"].(map[string]interface{})["root_module"].(map[string]interface{}); ok && len(changes) == 0 { + return true, nil + } + + return false, nil +} From 95c8bd0f4ae41bfe297292a91144f14786f23753 Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Wed, 28 Aug 2024 15:49:57 -0700 Subject: [PATCH 09/10] [ignore] --- cmd/conversion/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/conversion/main.go b/cmd/conversion/main.go index 6f072d347..f3e726589 100644 --- a/cmd/conversion/main.go +++ b/cmd/conversion/main.go @@ -41,11 +41,11 @@ type Change struct { } `json:"change"` } -func runTerraform(workingDir string) (string, error) { +func runTerraform(terraformDir string) (string, error) { planBin := "plan.bin" planJSON := "plan.json" - if err := os.Chdir(workingDir); err != nil { + if err := os.Chdir(terraformDir); err != nil { return "", fmt.Errorf("failed to change directory: %w", err) } @@ -352,11 +352,11 @@ func safeString(data map[string]interface{}, key string) string { func main() { testFlag := flag.Bool("test", false, "Run the test to POST payload to APIC and validate change") - workingDir := flag.String("dir", ".", "Path to the directory containing Terraform file") + terraformDir := flag.String("dir", ".", "Path to the directory containing Terraform file") flag.Parse() - planJSON, err := runTerraform(*workingDir) + planJSON, err := runTerraform(*terraformDir) if err != nil { log.Fatalf("Error running Terraform: %v", err) } From 1c801612c32a5c777eade4dad620c70a322ed0d1 Mon Sep 17 00:00:00 2001 From: Haris Malik Date: Wed, 28 Aug 2024 15:51:15 -0700 Subject: [PATCH 10/10] [ignore] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 19e484706..2fcdd3167 100644 --- a/README.md +++ b/README.md @@ -368,7 +368,7 @@ payload.json output: Default expects main.tf to be in the same file as converter. To run the converter with your Terraform file in a seperate directory, run: -$ go run main.go -dir path/to/your/main/tf +$ go run main.go -dir path/to/your/main.tf To test to confirm if a generated payload is valid, use test flag: