diff --git a/README.md b/README.md index daa9b5830..2fcdd3167 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,94 @@ 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 +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 + +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 new file mode 100644 index 000000000..f3e726589 --- /dev/null +++ b/cmd/conversion/main.go @@ -0,0 +1,424 @@ +package main + +import ( + "encoding/json" + "flag" + "fmt" + "log" + "os" + "os/exec" + "strings" + + "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 { + 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(terraformDir string) (string, error) { + planBin := "plan.bin" + planJSON := "plan.json" + + if err := os.Chdir(terraformDir); 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) + } + 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) + } + + os.Remove("plan.bin") + os.Remove("plan.json") + + 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 +} + +type TreeNode struct { + Attributes map[string]interface{} `json:"attributes,omitempty"` + Children map[string]*TreeNode `json:"children,omitempty"` + ClassName string `json:"-"` +} + +func NewTreeNode(className string, attributes map[string]interface{}) *TreeNode { + return &TreeNode{ + ClassName: className, + Attributes: attributes, + Children: make(map[string]*TreeNode), + } +} + +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 := 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) + } + } + } + + buildParentPath(dnMap, rootNode, resourceType, dn, attributes, children) + } + } + + 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{}) { + if dn == "" && resourceType == "" { + return + } + + 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 + } + + for _, child := range children { + for childClassName, childData := range child { + childAttributes := safeMapInterface(childData.(map[string]interface{}), "attributes") + childDn := safeString(childAttributes, "dn") + + childKey := childDn + if childDn == "" { + childKey = generateUniqueKeyForNonDnNode(childClassName, childAttributes) + } + + if _, exists := leafNode.Children[childKey]; !exists { + childNode := NewTreeNode(childClassName, childAttributes) + leafNode.Children[childKey] = childNode + dnMap[childKey] = childNode + } + + 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}) + } + } + } + } + } +} + +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"]) +} + +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 + } + } + + return cursor +} + +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) + } + + 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 +} + +func exportTree(node *TreeNode) map[string]interface{} { + if node == nil { + return nil + } + + result := map[string]interface{}{ + 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, exportTree(child)) + } + 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 + } + return nil +} + +func safeString(data map[string]interface{}, key string) string { + if value, ok := data[key].(string); ok { + return value + } + return "" +} + +func main() { + testFlag := flag.Bool("test", false, "Run the test to POST payload to APIC and validate change") + terraformDir := flag.String("dir", ".", "Path to the directory containing Terraform file") + + flag.Parse() + + planJSON, err := runTerraform(*terraformDir) + 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) + + aciTree := constructTree(payloadList) + + err = writeToFile(payloadFile, aciTree) + if err != nil { + log.Fatalf("Error writing output file: %v", err) + } + + 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 new file mode 100644 index 000000000..d1ea5a748 --- /dev/null +++ b/cmd/conversion/main.tf @@ -0,0 +1,343 @@ +terraform { + required_providers { + aci = { + source = "CiscoDevNet/aci" + } + } +} + +# Configure the provider with your Cisco APIC credentials. +provider "aci" { + # APIC Username + username = "admin" + # APIC Password + password = "" + # APIC URL + url = "https://sandboxapicdc.cisco.com" + insecure = true +} + +# Defines an Application EPG Resource. +/* +resource "aci_application_epg" "fooapplication_epg" { + parent_dn = "uni/tn-mgmt/ap-default" + name = "new_epg" + description = "from terraform" + annotation = "tag_epg" + contract_exception_tag = "0" + 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" + + relation_to_bridge_domain= [{ + annotation = "annotation1" + bridge_domain_name = "default" + }] +} +*/ + +/* +resource "aci_application_epg" "fooapplication_epg5" { + parent_dn = "uni/tn-mgmt/ap-default555" + name = "new_epg5" + 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" + +} +*/ + +//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" + } + ] +} +*/ + +/* +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" + 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/convert_funcs/access_interface_override.go b/convert_funcs/access_interface_override.go new file mode 100644 index 000000000..47c59b31a --- /dev/null +++ b/convert_funcs/access_interface_override.go @@ -0,0 +1,121 @@ +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/annotation.go b/convert_funcs/annotation.go new file mode 100644 index 000000000..407c3ba13 --- /dev/null +++ b/convert_funcs/annotation.go @@ -0,0 +1,53 @@ +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/application_epg.go b/convert_funcs/application_epg.go new file mode 100644 index 000000000..286853671 --- /dev/null +++ b/convert_funcs/application_epg.go @@ -0,0 +1,361 @@ +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["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = 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/custom_qos_policy.go b/convert_funcs/custom_qos_policy.go new file mode 100644 index 000000000..4ca632370 --- /dev/null +++ b/convert_funcs/custom_qos_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 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/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/endpoint_security_group.go b/convert_funcs/endpoint_security_group.go new file mode 100644 index 000000000..fcb0694af --- /dev/null +++ b/convert_funcs/endpoint_security_group.go @@ -0,0 +1,178 @@ +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["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = 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/endpoint_tag_ip.go b/convert_funcs/endpoint_tag_ip.go new file mode 100644 index 000000000..d7826bebc --- /dev/null +++ b/convert_funcs/endpoint_tag_ip.go @@ -0,0 +1,90 @@ +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["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/endpoint_tag_mac.go b/convert_funcs/endpoint_tag_mac.go new file mode 100644 index 000000000..7a5425167 --- /dev/null +++ b/convert_funcs/endpoint_tag_mac.go @@ -0,0 +1,90 @@ +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["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/epg_useg_ad_group_attribute.go b/convert_funcs/epg_useg_ad_group_attribute.go new file mode 100644 index 000000000..35b75c7f5 --- /dev/null +++ b/convert_funcs/epg_useg_ad_group_attribute.go @@ -0,0 +1,96 @@ +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/epg_useg_block_statement.go b/convert_funcs/epg_useg_block_statement.go new file mode 100644 index 000000000..098405c21 --- /dev/null +++ b/convert_funcs/epg_useg_block_statement.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 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["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 := 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/epg_useg_dns_attribute.go b/convert_funcs/epg_useg_dns_attribute.go new file mode 100644 index 000000000..9244e1b07 --- /dev/null +++ b/convert_funcs/epg_useg_dns_attribute.go @@ -0,0 +1,96 @@ +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/epg_useg_ip_attribute.go b/convert_funcs/epg_useg_ip_attribute.go new file mode 100644 index 000000000..fe610277f --- /dev/null +++ b/convert_funcs/epg_useg_ip_attribute.go @@ -0,0 +1,96 @@ +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) + } + 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/epg_useg_mac_attribute.go b/convert_funcs/epg_useg_mac_attribute.go new file mode 100644 index 000000000..fa41a11d8 --- /dev/null +++ b/convert_funcs/epg_useg_mac_attribute.go @@ -0,0 +1,96 @@ +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/epg_useg_sub_block_statement.go b/convert_funcs/epg_useg_sub_block_statement.go new file mode 100644 index 000000000..40c81b5eb --- /dev/null +++ b/convert_funcs/epg_useg_sub_block_statement.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 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["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/epg_useg_vm_attribute.go b/convert_funcs/epg_useg_vm_attribute.go new file mode 100644 index 000000000..99a2c5f17 --- /dev/null +++ b/convert_funcs/epg_useg_vm_attribute.go @@ -0,0 +1,102 @@ +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["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["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/external_management_network_instance_profile.go b/convert_funcs/external_management_network_instance_profile.go new file mode 100644 index 000000000..e201d027a --- /dev/null +++ b/convert_funcs/external_management_network_instance_profile.go @@ -0,0 +1,99 @@ +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) + } + 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/external_management_network_subnet.go b/convert_funcs/external_management_network_subnet.go new file mode 100644 index 000000000..636b7c28e --- /dev/null +++ b/convert_funcs/external_management_network_subnet.go @@ -0,0 +1,90 @@ +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/l3out_consumer_label.go b/convert_funcs/l3out_consumer_label.go new file mode 100644 index 000000000..727077b24 --- /dev/null +++ b/convert_funcs/l3out_consumer_label.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 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_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = 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/l3out_node_sid_profile.go b/convert_funcs/l3out_node_sid_profile.go new file mode 100644 index 000000000..a78838ed4 --- /dev/null +++ b/convert_funcs/l3out_node_sid_profile.go @@ -0,0 +1,90 @@ +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) + } + 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/l3out_provider_label.go b/convert_funcs/l3out_provider_label.go new file mode 100644 index 000000000..ef5f1d1f1 --- /dev/null +++ b/convert_funcs/l3out_provider_label.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 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) + } + 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/l3out_redistribute_policy.go b/convert_funcs/l3out_redistribute_policy.go new file mode 100644 index 000000000..d43bb002e --- /dev/null +++ b/convert_funcs/l3out_redistribute_policy.go @@ -0,0 +1,81 @@ +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["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/netflow_monitor_policy.go b/convert_funcs/netflow_monitor_policy.go new file mode 100644 index 000000000..f63cc59b8 --- /dev/null +++ b/convert_funcs/netflow_monitor_policy.go @@ -0,0 +1,121 @@ +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/netflow_record_policy.go b/convert_funcs/netflow_record_policy.go new file mode 100644 index 000000000..31a710c2e --- /dev/null +++ b/convert_funcs/netflow_record_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 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/out_of_band_contract.go b/convert_funcs/out_of_band_contract.go new file mode 100644 index 000000000..d37ff1503 --- /dev/null +++ b/convert_funcs/out_of_band_contract.go @@ -0,0 +1,90 @@ +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["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 := 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/pim_route_map_entry.go b/convert_funcs/pim_route_map_entry.go new file mode 100644 index 000000000..f9e093a8d --- /dev/null +++ b/convert_funcs/pim_route_map_entry.go @@ -0,0 +1,96 @@ +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["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["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/pim_route_map_policy.go b/convert_funcs/pim_route_map_policy.go new file mode 100644 index 000000000..378248080 --- /dev/null +++ b/convert_funcs/pim_route_map_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 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/relation_to_consumed_contract.go b/convert_funcs/relation_to_consumed_contract.go new file mode 100644 index 000000000..41b8f5b41 --- /dev/null +++ b/convert_funcs/relation_to_consumed_contract.go @@ -0,0 +1,81 @@ +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["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/relation_to_consumed_out_of_band_contract.go b/convert_funcs/relation_to_consumed_out_of_band_contract.go new file mode 100644 index 000000000..24e61ed42 --- /dev/null +++ b/convert_funcs/relation_to_consumed_out_of_band_contract.go @@ -0,0 +1,81 @@ +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["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/relation_to_contract_master.go b/convert_funcs/relation_to_contract_master.go new file mode 100644 index 000000000..1f53779a8 --- /dev/null +++ b/convert_funcs/relation_to_contract_master.go @@ -0,0 +1,81 @@ +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/relation_to_domain.go b/convert_funcs/relation_to_domain.go new file mode 100644 index 000000000..13632b6cd --- /dev/null +++ b/convert_funcs/relation_to_domain.go @@ -0,0 +1,108 @@ +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["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["ipam_dhcp_override"].(string); ok && v != "" { + data.IpamDhcpOverride = 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["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["secondary_encapsulation_inner"].(string); ok && v != "" { + data.SecondaryEncapInner = types.StringValue(v) + } + if v, ok := attributes["target_dn"].(string); ok && v != "" { + data.TDn = 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/relation_to_fibre_channel_path.go b/convert_funcs/relation_to_fibre_channel_path.go new file mode 100644 index 000000000..2df16c263 --- /dev/null +++ b/convert_funcs/relation_to_fibre_channel_path.go @@ -0,0 +1,87 @@ +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) + } + 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/relation_to_imported_contract.go b/convert_funcs/relation_to_imported_contract.go new file mode 100644 index 000000000..48af55578 --- /dev/null +++ b/convert_funcs/relation_to_imported_contract.go @@ -0,0 +1,81 @@ +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["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/relation_to_intra_epg_contract.go b/convert_funcs/relation_to_intra_epg_contract.go new file mode 100644 index 000000000..2ac34e549 --- /dev/null +++ b/convert_funcs/relation_to_intra_epg_contract.go @@ -0,0 +1,81 @@ +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/relation_to_netflow_exporter.go b/convert_funcs/relation_to_netflow_exporter.go new file mode 100644 index 000000000..0fe3ca7e6 --- /dev/null +++ b/convert_funcs/relation_to_netflow_exporter.go @@ -0,0 +1,81 @@ +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/relation_to_provided_contract.go b/convert_funcs/relation_to_provided_contract.go new file mode 100644 index 000000000..18d1d0233 --- /dev/null +++ b/convert_funcs/relation_to_provided_contract.go @@ -0,0 +1,81 @@ +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["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/relation_to_static_leaf.go b/convert_funcs/relation_to_static_leaf.go new file mode 100644 index 000000000..3b72c56de --- /dev/null +++ b/convert_funcs/relation_to_static_leaf.go @@ -0,0 +1,87 @@ +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["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/relation_to_static_path.go b/convert_funcs/relation_to_static_path.go new file mode 100644 index 000000000..99c63446f --- /dev/null +++ b/convert_funcs/relation_to_static_path.go @@ -0,0 +1,90 @@ +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["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/relation_to_taboo_contract.go b/convert_funcs/relation_to_taboo_contract.go new file mode 100644 index 000000000..5c2138db0 --- /dev/null +++ b/convert_funcs/relation_to_taboo_contract.go @@ -0,0 +1,81 @@ +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/relation_to_vrf_fallback_route_group.go b/convert_funcs/relation_to_vrf_fallback_route_group.go new file mode 100644 index 000000000..a9d1df0d8 --- /dev/null +++ b/convert_funcs/relation_to_vrf_fallback_route_group.go @@ -0,0 +1,81 @@ +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/resourceMap.go b/convert_funcs/resourceMap.go new file mode 100644 index 000000000..b016e57f8 --- /dev/null +++ b/convert_funcs/resourceMap.go @@ -0,0 +1,95 @@ +package convert_funcs + +type createFunc func(map[string]interface{}, string) map[string]interface{} + +var ResourceMap = map[string]createFunc{ + "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_relation_to_consumed_out_of_band_contract": CreateMgmtRsOoBCons, + + "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/route_control_profile.go b/convert_funcs/route_control_profile.go new file mode 100644 index 000000000..15b44cf36 --- /dev/null +++ b/convert_funcs/route_control_profile.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 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["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 := 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/tag.go b/convert_funcs/tag.go new file mode 100644 index 000000000..905c29bf5 --- /dev/null +++ b/convert_funcs/tag.go @@ -0,0 +1,53 @@ +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/trust_control_policy.go b/convert_funcs/trust_control_policy.go new file mode 100644 index 000000000..20655dc73 --- /dev/null +++ b/convert_funcs/trust_control_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 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["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 := 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/vrf_fallback_route.go b/convert_funcs/vrf_fallback_route.go new file mode 100644 index 000000000..b0ce548cb --- /dev/null +++ b/convert_funcs/vrf_fallback_route.go @@ -0,0 +1,90 @@ +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/vrf_fallback_route_group.go b/convert_funcs/vrf_fallback_route_group.go new file mode 100644 index 000000000..9595504ef --- /dev/null +++ b/convert_funcs/vrf_fallback_route_group.go @@ -0,0 +1,121 @@ +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/vrf_fallback_route_group_member.go b/convert_funcs/vrf_fallback_route_group_member.go new file mode 100644 index 000000000..a3f59795c --- /dev/null +++ b/convert_funcs/vrf_fallback_route_group_member.go @@ -0,0 +1,90 @@ +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/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 22f389cab..4b7f91b6c 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,8 @@ 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, + "lowercaseFirst": LowercaseFirst, "snakeCase": Underscore, "validatorString": ValidatorString, "containsString": ContainsString, @@ -216,6 +219,13 @@ 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 GetNewChildAttributes(legacyAttributes map[string]LegacyAttribute, properties map[string]Property) []Property { result := []Property{} for _, property := range properties { @@ -396,6 +406,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") { @@ -451,7 +463,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 } @@ -473,7 +487,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) @@ -580,6 +594,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 @@ -694,6 +709,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")) @@ -775,6 +792,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("%s.go", model.ResourceName), conversionPath, model) } } @@ -915,6 +933,7 @@ type Property struct { Versions string NamedPropertyClass string IgnoreInTestExampleValue string + GoType string ValidValues []string IdentifiedBy []interface{} Validators []interface{} @@ -1030,6 +1049,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) @@ -1216,6 +1255,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) } @@ -1428,6 +1472,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 new file mode 100644 index 000000000..cc9aa0277 --- /dev/null +++ b/gen/templates/conversion.go.tmpl @@ -0,0 +1,84 @@ +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 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 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 }} + + + + {{- 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..916d04fad 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() @@ -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/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..40a2b1fec --- /dev/null +++ b/gen/templates/resourceMap.go.tmpl @@ -0,0 +1,13 @@ + + +package convert_funcs + +type createFunc func(map[string]interface{}, string) map[string]interface{} + +var ResourceMap = map[string]createFunc{ + {{- range . }} + {{- if or (and .IdentifiedBy (not (and .MaxOneClassAllowed (hasPrefix .RnFormat "rs")))) .Include}} + "aci_{{ .ResourceName }}": Create{{ .ResourceClassName }}, + {{end}} + {{end}} +} 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{} 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 +}