diff --git a/README.md b/README.md index daa9b5830..44d19de32 100644 --- a/README.md +++ b/README.md @@ -288,4 +288,11 @@ 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. +#### Using the converter +The aci_converter.go is a tool that can be used to convert the Terraform configuration to an ACI payload. + +1. Navigate to the converter directory +2. Create configuration in main.tf +3. Run `go run converter.go` +4. The ACI payload for the Terraform Plan will be written to payload.json diff --git a/SU.txt b/SU.txt new file mode 100644 index 000000000..be3f9f7f8 --- /dev/null +++ b/SU.txt @@ -0,0 +1,31 @@ +7/29 +- implement the getChildpayload functions from the provider to create child object payloads + +- all items are being created successfully + +- I am going to test the PCV simulations to make sure that the formatting is correct + +- Once that is done I will make the template for the revised create() function + +- I will put out a PR later today for some feedback + + + + + + +Fix constructTree() -- FIXED tentitvely + +Fix duplicate headers + + +Create template for create() -- +1. Dn representation needed, check meta for definitions + +Push PR, assign Akini + +7/30 + + + + diff --git a/conversion/aci_converter.go b/conversion/aci_converter.go new file mode 100644 index 000000000..cb358b03d --- /dev/null +++ b/conversion/aci_converter.go @@ -0,0 +1,1968 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "log" + "os" + "os/exec" + + "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" +) + +// Represents parts of Terraform Plan we are interested in +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"` +} + +type createFunc func(map[string]interface{}) map[string]interface{} + +// Map to query create() functions +var resourceMap = map[string]createFunc{ + "aci_endpoint_tag_ip": createEndpointTagIP, + "aci_vrf_fallback_route_group": createVrfFallbackRouteGroup, + "aci_pim_route_map_policy": createPimRouteMapPol, + "aci_l3out_consumer_label": createL3extConsLbl, + "aci_external_management_network_instance_profile": createMgmtInstP, + "aci_external_management_subnet": createMgmtSubnet, + "aci_endpoint_tag_mac": createFvEpMacTag, + "aci_netflow_monitor_policy": createNetflowMonitorPol, + "aci_l3out_redistribute_policy": createL3extRsRedistributePol, + "aci_out_of_band_contract": createVzOOBBrCP, + "aci_relation_to_consumed_out_of_band_contract": createMgmtRsOoBCons, + "aci_relation_to_netflow_exporter": createNetflowRsMonitorToExporter, + "aci_pim_route_map_entry": createPimRouteMapEntry, + "aci_l3out_node_sid_profile": createMplsNodeSidP, +} + +func resourceTypeToMapKey(resourceType string) string { + switch resourceType { + case "aci_endpoint_tag_ip": + return "fvEpIpTag" + case "aci_external_management_network_instance_profile": + return "mgmtInstP" + case "aci_l3out_consumer_label": + return " l3extConsLbl" + case "aci_vrf_fallback_route_group": + return "fvFBRGroup" + case "aci_pim_route_map_policy": + return "pimRouteMapPol" + case "aci_netflow_monitor_pol": + return "netflowMonitorPol" + case "aci_external_management_subnet": + return "mgmtSubnet" + case "aci_l3out_redistribute_policy": + return " l3extRsRedistributePol" + case "aci_out_of_band_contract": + return "VzOOBBrCP" + case "aci_relation_to_consumed_out_of_band_contract": + return "mgmtRsOoBCons" + case "aci_relation_to_netflow_exporter": + return "netflowRsMonitorToExporter" + case "aci_l3out_node_sid_profile": + return "mplsNodeSidP" + + default: + return resourceType + } +} + +// Executes Terraform commands to create input JSON +func runTerraform() (string, error) { + planBin := "plan.bin" + planJson := "plan.json" + + if err := exec.Command("terraform", "plan", "-out="+planBin).Run(); err != nil { + return "", fmt.Errorf("failed to run terraform plan: %w", err) + } + + output, err := os.Create(planJson) + if err != nil { + return "", fmt.Errorf("failed to create json file: %w", err) + } + defer output.Close() + + cmdShow := exec.Command("terraform", "show", "-json", planBin) + cmdShow.Stdout = output + if err := cmdShow.Run(); err != nil { + return "", fmt.Errorf("failed to run terraform show: %w", err) + } + + return planJson, nil +} + +// Converts Plan json into bytes, then unmarshalls into Plan struct +func readPlan(jsonFile string) (Plan, error) { + var plan Plan + data, err := os.ReadFile(jsonFile) + if err != nil { + return plan, fmt.Errorf("failed to read input file: %w", err) + } + + if err := json.Unmarshal(data, &plan); err != nil { + return plan, fmt.Errorf("failed to parse input file: %w", err) + } + + return plan, nil +} + +func writeToFile(outputFile string, data map[string]interface{}) error { + var dataList []map[string]interface{} + for key, value := range data { + dataList = append(dataList, map[string]interface{}{key: value}) + } + + traverseAndRemoveAttributes(dataList) + + updatedData := make(map[string]interface{}) + for _, item := range dataList { + for key, value := range item { + updatedData[key] = value + } + } + + outputData, err := json.MarshalIndent(updatedData, "", " ") + 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 createItem(resourceType string, values map[string]interface{}, status string) map[string]interface{} { + if create, exists := resourceMap[resourceType]; exists { + item := create(values) + if status == "deleted" && item != nil { + if attributes, ok := item[resourceTypeToMapKey(resourceType)].(map[string]interface{}); ok { + if attrs, ok := attributes["attributes"].(map[string]interface{}); ok { + if status != "" { + attrs["status"] = status + } + } + } + } + return item + } + return nil +} + +// Ranges through resource created/deleted and resources, creates each item, adds to []map[string]interface{} +func createItemList(plan Plan) []map[string]interface{} { + var data []map[string]interface{} + + // Create deleted items + for _, change := range plan.Changes { + if len(change.Change.Actions) > 0 && change.Change.Actions[0] == "delete" { + item := createItem(change.Type, change.Change.Before, "deleted") + if item != nil { + data = append(data, item) + } + } + } + + // Create-created items and include parent_dn if exists for tree construction + for _, resource := range plan.PlannedValues.RootModule.Resources { + item := createItem(resource.Type, resource.Values, "") + if item != nil { + for _, value := range item { + 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, item) + } + } + + return data +} + +func constructTree(data []map[string]interface{}) []map[string]interface{} { + resourceMap := make(map[string]map[string]interface{}) + parentChildMap := make(map[string][]map[string]interface{}) + + for _, item := range data { + for key, value := range item { + if obj, ok := value.(map[string]interface{}); ok { + if attributes, ok := obj["attributes"].(map[string]interface{}); ok { + if dn, ok := attributes["dn"].(string); ok { + resourceMap[dn] = map[string]interface{}{key: obj} + if parentDn, ok := attributes["parent_dn"].(string); ok && parentDn != "" { + parentChildMap[parentDn] = append(parentChildMap[parentDn], map[string]interface{}{key: obj}) + } + } + } + } + } + } + + for parentDn, children := range parentChildMap { + if parent, exists := resourceMap[parentDn]; exists { + attachChildren(parent, children) + } else { + // If parent doesn't exist, create placeholder item + missingParent := map[string]interface{}{ + "unknownParent": map[string]interface{}{ + "attributes": map[string]interface{}{ + "dn": parentDn, + }, + "children": children, + }, + } + resourceMap[parentDn] = missingParent + } + } + + var tree []map[string]interface{} + for _, resource := range resourceMap { + for key, obj := range resource { + if key == "unknownParent" { + children := obj.(map[string]interface{})["children"].([]map[string]interface{}) + tree = append(tree, children...) + } else { + if attributes, ok := obj.(map[string]interface{})["attributes"].(map[string]interface{}); ok { + if parentDn, ok := attributes["parent_dn"].(string); !ok || parentDn == "" { + tree = append(tree, resource) + } + } + } + } + } + + return tree +} + +func attachChildren(parent map[string]interface{}, children []map[string]interface{}) { + for _, value := range parent { + if obj, ok := value.(map[string]interface{}); ok { + if objChildren, ok := obj["children"].([]map[string]interface{}); ok { + obj["children"] = append(objChildren, children...) + } else { + obj["children"] = children + } + } + } +} + +func removeAttributes(obj map[string]interface{}) { + if attributes, ok := obj["attributes"].(map[string]interface{}); ok { + delete(attributes, "dn") + delete(attributes, "parent_dn") + } + if children, ok := obj["children"].([]map[string]interface{}); ok { + for _, child := range children { + for _, childObj := range child { + removeAttributes(childObj.(map[string]interface{})) + } + } + } +} + +func traverseAndRemoveAttributes(data []map[string]interface{}) { + for _, item := range data { + for _, value := range item { + removeAttributes(value.(map[string]interface{})) + } + } +} + +func removeArrayBrackets(jsonData []byte) ([]byte, error) { + var temp interface{} + if err := json.Unmarshal(jsonData, &temp); err != nil { + return nil, err + } + + jsonMap, ok := temp.([]interface{}) + if !ok || len(jsonMap) == 0 { + return nil, fmt.Errorf("invalid JSON structure") + } + + var finalJSON []byte + for _, element := range jsonMap { + elementJSON, err := json.MarshalIndent(element, "", " ") + if err != nil { + return nil, err + } + finalJSON = append(finalJSON, elementJSON...) + finalJSON = append(finalJSON, '\n') + } + + return finalJSON, nil +} + +func parseBinToMap(jsonPayload []byte) (map[string]interface{}, error) { + var customData map[string]interface{} + err := json.Unmarshal(jsonPayload, &customData) + if err != nil { + return nil, err + } + return customData, nil +} + +func createEndpointTagIP(attributes map[string]interface{}) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvEpIpTagResourceModel{} + + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["vrf_name"].(string); ok && v != "" { + data.CtxName = types.StringValue(v) + } + if v, ok := attributes["id_attribute"].(string); ok && v != "" { + data.FvEpIpTagId = types.StringValue(v) + } + if v, ok := attributes["ip"].(string); ok && v != "" { + data.Ip = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + + planAnnotations := convertToEpIpTagAnnotations(attributes["annotations"]) + planTags := convertToEpIpTagTags(attributes["tags"]) + + stateAnnotations := planAnnotations + stateTags := planTags + + newEndpointTag := provider.GetFvEpIpTagCreateJsonPayload(ctx, &diags, data, planAnnotations, stateAnnotations, planTags, stateTags) + + payload_bin := newEndpointTag.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(payload_bin) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvEpIpTagId(ctx, data) + attrs := payload["fvEpIpTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if v, ok := attributes["status"].(string); ok && v != "" { + attrs["status"] = v + } + + return payload +} + +func createVrfFallbackRouteGroup(attributes map[string]interface{}) 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["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["description"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + + planMembers := convertToFBRMembers(attributes["vrf_fallback_route_group_members"]) + planAnnotations := convertToFvFBRGroupAnnotations(attributes["annotations"]) + planTags := convertToFvFBRGroupTags(attributes["tags"]) + + newAciVrf := provider.GetFvFBRGroupCreateJsonPayload(ctx, &diags, data, planMembers, planMembers, planAnnotations, planAnnotations, planTags, planTags) + + jsonPayload := newAciVrf.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvFBRGroupId(ctx, data) + attrs := payload["fvFBRGroup"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if v, ok := attributes["status"].(string); ok && v != "" { + attrs["status"] = v + } + + return payload +} + +func convertToFvFBRGroupAnnotations(annotations interface{}) []provider.TagAnnotationFvFBRGroupResourceModel { + var planAnnotations []provider.TagAnnotationFvFBRGroupResourceModel + if annotations, ok := annotations.([]interface{}); ok { + for _, annotation := range annotations { + annotationMap := annotation.(map[string]interface{}) + planAnnotations = append(planAnnotations, provider.TagAnnotationFvFBRGroupResourceModel{ + Key: types.StringValue(annotationMap["key"].(string)), + Value: types.StringValue(annotationMap["value"].(string)), + }) + } + } + return planAnnotations +} + +func convertToFvFBRGroupTags(tags interface{}) []provider.TagTagFvFBRGroupResourceModel { + var planTags []provider.TagTagFvFBRGroupResourceModel + if tags, ok := tags.([]interface{}); ok { + for _, tag := range tags { + tagMap := tag.(map[string]interface{}) + planTags = append(planTags, provider.TagTagFvFBRGroupResourceModel{ + Key: types.StringValue(tagMap["key"].(string)), + Value: types.StringValue(tagMap["value"].(string)), + }) + } + } + return planTags +} + +func convertToFBRMembers(members interface{}) []provider.FvFBRMemberFvFBRGroupResourceModel { + var planMembers []provider.FvFBRMemberFvFBRGroupResourceModel + if members, ok := members.([]interface{}); ok { + for _, member := range members { + memberMap := member.(map[string]interface{}) + planMembers = append(planMembers, provider.FvFBRMemberFvFBRGroupResourceModel{ + Annotation: types.StringValue(memberMap["annotation"].(string)), + Descr: types.StringValue(memberMap["description"].(string)), + Name: types.StringValue(memberMap["name"].(string)), + NameAlias: types.StringValue(memberMap["name_alias"].(string)), + RnhAddr: types.StringValue(memberMap["fallback_member"].(string)), + }) + } + } + return planMembers +} + +func convertToEpIpTagAnnotations(annotations interface{}) []provider.TagAnnotationFvEpIpTagResourceModel { + var planAnnotations []provider.TagAnnotationFvEpIpTagResourceModel + if annotations, ok := annotations.([]interface{}); ok { + for _, annotation := range annotations { + annotationMap := annotation.(map[string]interface{}) + planAnnotations = append(planAnnotations, provider.TagAnnotationFvEpIpTagResourceModel{ + Key: types.StringValue(annotationMap["key"].(string)), + Value: types.StringValue(annotationMap["value"].(string)), + }) + } + } + return planAnnotations +} + +func convertToEpIpTagTags(tags interface{}) []provider.TagTagFvEpIpTagResourceModel { + var planTags []provider.TagTagFvEpIpTagResourceModel + if tags, ok := tags.([]interface{}); ok { + for _, tag := range tags { + tagMap := tag.(map[string]interface{}) + planTags = append(planTags, provider.TagTagFvEpIpTagResourceModel{ + Key: types.StringValue(tagMap["key"].(string)), + Value: types.StringValue(tagMap["value"].(string)), + }) + } + } + return planTags +} + +func convertToMgmtInstPAnnotations(annotations interface{}) []provider.TagAnnotationMgmtInstPResourceModel { + var planAnnotations []provider.TagAnnotationMgmtInstPResourceModel + if annotations, ok := annotations.([]interface{}); ok { + for _, annotation := range annotations { + annotationMap := annotation.(map[string]interface{}) + planAnnotations = append(planAnnotations, provider.TagAnnotationMgmtInstPResourceModel{ + Key: types.StringValue(annotationMap["key"].(string)), + Value: types.StringValue(annotationMap["value"].(string)), + }) + } + } + return planAnnotations +} + +func convertToMgmtInstPTags(tags interface{}) []provider.TagTagMgmtInstPResourceModel { + var planTags []provider.TagTagMgmtInstPResourceModel + if tags, ok := tags.([]interface{}); ok { + for _, tag := range tags { + tagMap := tag.(map[string]interface{}) + planTags = append(planTags, provider.TagTagMgmtInstPResourceModel{ + Key: types.StringValue(tagMap["key"].(string)), + Value: types.StringValue(tagMap["value"].(string)), + }) + } + } + return planTags +} + +func createTagAnnotation(attributes map[string]interface{}) 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) + } + + newAciTagAnnotation := provider.GetTagAnnotationCreateJsonPayload(ctx, &diags, data) + + jsonPayload := newAciTagAnnotation.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetTagAnnotationId(ctx, data) + attrs := payload["tagAnnotation"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + return payload +} + +func createFvEpIpTag(attributes map[string]interface{}) 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["ctx_name"].(string); ok && v != "" { + data.CtxName = types.StringValue(v) + } + if v, ok := attributes["id"].(string); ok && v != "" { + data.FvEpIpTagId = types.StringValue(v) + } + if v, ok := attributes["ip"].(string); ok && v != "" { + data.Ip = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvEpIpTag(attributes["annotations"]) + planTagTag := convertToTagTagFvEpIpTag(attributes["tags"]) + + newAciFvEpIpTag := provider.GetFvEpIpTagCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvEpIpTag.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvEpIpTagId(ctx, data) + attrs := payload["fvEpIpTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createFvEpMacTag(attributes map[string]interface{}) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvEpMacTagResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["bd_name"].(string); ok && v != "" { + data.BdName = types.StringValue(v) + } + if v, ok := attributes["id"].(string); ok && v != "" { + data.FvEpMacTagId = types.StringValue(v) + } + if v, ok := attributes["mac"].(string); ok && v != "" { + data.Mac = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvEpMacTag(attributes["annotations"]) + planTagTag := convertToTagTagFvEpMacTag(attributes["tags"]) + + newAciFvEpMacTag := provider.GetFvEpMacTagCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvEpMacTag.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvEpMacTagId(ctx, data) + attrs := payload["fvEpMacTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + 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 +} + +func createMgmtInstP(attributes map[string]interface{}) 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["descr"].(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["prio"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + planMgmtRsOoBCons := convertToMgmtRsOoBConsMgmtInstP(attributes["out_of_band_contract_name"]) + planTagAnnotation := convertToTagAnnotationMgmtInstP(attributes["annotations"]) + planTagTag := convertToTagTagMgmtInstP(attributes["tags"]) + + newAciMgmtInstP := provider.GetMgmtInstPCreateJsonPayload(ctx, &diags, data, planMgmtRsOoBCons, planMgmtRsOoBCons, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtInstP.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetMgmtInstPId(ctx, data) + attrs := payload["mgmtInstP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + 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["prio"].(string)), + TnVzOOBBrCPName: types.StringValue(resourceMap["tn_vz_oob_br_cp_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 +} + +func createMgmtSubnet(attributes map[string]interface{}) 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["descr"].(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"]) + + newAciMgmtSubnet := provider.GetMgmtSubnetCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtSubnet.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetMgmtSubnetId(ctx, data) + attrs := payload["mgmtSubnet"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + 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 +} + +func createL3extConsLbl(attributes map[string]interface{}) 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["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner"].(string); ok && v != "" { + data.Owner = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["tag"].(string); ok && v != "" { + data.Tag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extConsLbl(attributes["annotations"]) + planTagTag := convertToTagTagL3extConsLbl(attributes["tags"]) + + newAciL3extConsLbl := provider.GetL3extConsLblCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extConsLbl.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetL3extConsLblId(ctx, data) + attrs := payload["l3extConsLbl"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createMplsNodeSidP(attributes map[string]interface{}) 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["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["loopback_addr"].(string); ok && v != "" { + data.LoopbackAddr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["sidoffset"].(string); ok && v != "" { + data.Sidoffset = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationMplsNodeSidP(attributes["annotations"]) + planTagTag := convertToTagTagMplsNodeSidP(attributes["tags"]) + + newAciMplsNodeSidP := provider.GetMplsNodeSidPCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMplsNodeSidP.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetMplsNodeSidPId(ctx, data) + attrs := payload["mplsNodeSidP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + 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 +} + +func createL3extProvLbl(attributes map[string]interface{}) 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["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["tag"].(string); ok && v != "" { + data.Tag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extProvLbl(attributes["annotations"]) + planTagTag := convertToTagTagL3extProvLbl(attributes["tags"]) + + newAciL3extProvLbl := provider.GetL3extProvLblCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extProvLbl.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetL3extProvLblId(ctx, data) + attrs := payload["l3extProvLbl"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + 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 +} + +func createL3extRsRedistributePol(attributes map[string]interface{}) 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["src"].(string); ok && v != "" { + data.Src = types.StringValue(v) + } + if v, ok := attributes["tn_rtctrl_profile_name"].(string); ok && v != "" { + data.TnRtctrlProfileName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extRsRedistributePol(attributes["annotations"]) + planTagTag := convertToTagTagL3extRsRedistributePol(attributes["tags"]) + + newAciL3extRsRedistributePol := provider.GetL3extRsRedistributePolCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extRsRedistributePol.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetL3extRsRedistributePolId(ctx, data) + attrs := payload["l3extRsRedistributePol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createNetflowMonitorPol(attributes map[string]interface{}) 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["descr"].(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"]) + + newAciNetflowMonitorPol := provider.GetNetflowMonitorPolCreateJsonPayload(ctx, &diags, data, planNetflowRsMonitorToExporter, planNetflowRsMonitorToExporter, planNetflowRsMonitorToRecord, planNetflowRsMonitorToRecord, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciNetflowMonitorPol.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetNetflowMonitorPolId(ctx, data) + attrs := payload["netflowMonitorPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if status, ok := attributes["parent_dn"].(string); ok && status != "" { + attrs["parent_dn"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createVzOOBBrCP(attributes map[string]interface{}) 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["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["intent"].(string); ok && v != "" { + data.Intent = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["prio"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["scope"].(string); ok && v != "" { + data.Scope = types.StringValue(v) + } + if v, ok := attributes["target_dscp"].(string); ok && v != "" { + data.TargetDscp = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationVzOOBBrCP(attributes["annotations"]) + planTagTag := convertToTagTagVzOOBBrCP(attributes["tags"]) + + newAciVzOOBBrCP := provider.GetVzOOBBrCPCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciVzOOBBrCP.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetVzOOBBrCPId(ctx, data) + attrs := payload["vzOOBBrCP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if status, ok := attributes["parent_dn"].(string); ok && status != "" { + attrs["parent_dn"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createPimRouteMapEntry(attributes map[string]interface{}) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.PimRouteMapEntryResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["action"].(string); ok && v != "" { + data.Action = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["grp"].(string); ok && v != "" { + data.Grp = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["order"].(string); ok && v != "" { + data.Order = types.StringValue(v) + } + if v, ok := attributes["rp"].(string); ok && v != "" { + data.Rp = types.StringValue(v) + } + if v, ok := attributes["src"].(string); ok && v != "" { + data.Src = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationPimRouteMapEntry(attributes["annotations"]) + planTagTag := convertToTagTagPimRouteMapEntry(attributes["tags"]) + + newAciPimRouteMapEntry := provider.GetPimRouteMapEntryCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciPimRouteMapEntry.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetPimRouteMapEntryId(ctx, data) + attrs := payload["pimRouteMapEntry"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + 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 +} + +func createPimRouteMapPol(attributes map[string]interface{}) 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["descr"].(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"]) + + newAciPimRouteMapPol := provider.GetPimRouteMapPolCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciPimRouteMapPol.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetPimRouteMapPolId(ctx, data) + attrs := payload["pimRouteMapPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createMgmtRsOoBCons(attributes map[string]interface{}) 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["prio"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["tn_vz_oob_br_cp_name"].(string); ok && v != "" { + data.TnVzOOBBrCPName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationMgmtRsOoBCons(attributes["annotations"]) + planTagTag := convertToTagTagMgmtRsOoBCons(attributes["tags"]) + + newAciMgmtRsOoBCons := provider.GetMgmtRsOoBConsCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtRsOoBCons.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetMgmtRsOoBConsId(ctx, data) + attrs := payload["mgmtRsOoBCons"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createL3extRsOutToFBRGroup(attributes map[string]interface{}) 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["t_dn"].(string); ok && v != "" { + data.TDn = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extRsOutToFBRGroup(attributes["annotations"]) + planTagTag := convertToTagTagL3extRsOutToFBRGroup(attributes["tags"]) + + newAciL3extRsOutToFBRGroup := provider.GetL3extRsOutToFBRGroupCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extRsOutToFBRGroup.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetL3extRsOutToFBRGroupId(ctx, data) + attrs := payload["l3extRsOutToFBRGroup"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createNetflowRsMonitorToExporter(attributes map[string]interface{}) 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["tn_netflow_exporter_pol_name"].(string); ok && v != "" { + data.TnNetflowExporterPolName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationNetflowRsMonitorToExporter(attributes["annotations"]) + planTagTag := convertToTagTagNetflowRsMonitorToExporter(attributes["tags"]) + + newAciNetflowRsMonitorToExporter := provider.GetNetflowRsMonitorToExporterCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciNetflowRsMonitorToExporter.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetNetflowRsMonitorToExporterId(ctx, data) + attrs := payload["netflowRsMonitorToExporter"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + + 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 +} + +func createTagTag(attributes map[string]interface{}) 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) + } + + newAciTagTag := provider.GetTagTagCreateJsonPayload(ctx, &diags, data) + + jsonPayload := newAciTagTag.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetTagTagId(ctx, data) + attrs := payload["tagTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + return payload +} + +func createFvFBRMember(attributes map[string]interface{}) 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["descr"].(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["rnh_addr"].(string); ok && v != "" { + data.RnhAddr = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvFBRMember(attributes["annotations"]) + planTagTag := convertToTagTagFvFBRMember(attributes["tags"]) + + newAciFvFBRMember := provider.GetFvFBRMemberCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvFBRMember.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvFBRMemberId(ctx, data) + attrs := payload["fvFBRMember"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + 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 +} + +func createFvFBRGroup(attributes map[string]interface{}) 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["descr"].(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"]) + planTagAnnotation := convertToTagAnnotationFvFBRGroup(attributes["annotations"]) + planTagTag := convertToTagTagFvFBRGroup(attributes["tags"]) + + newAciFvFBRGroup := provider.GetFvFBRGroupCreateJsonPayload(ctx, &diags, data, planFvFBRMember, planFvFBRMember, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvFBRGroup.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseBinToMap(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvFBRGroupId(ctx, data) + attrs := payload["fvFBRGroup"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + if parent, ok := attributes["parent_dn"].(string); ok && parent != "" { + attrs["parent_dn"] = parent + } + 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["descr"].(string)), + Name: types.StringValue(resourceMap["name"].(string)), + NameAlias: types.StringValue(resourceMap["name_alias"].(string)), + RnhAddr: types.StringValue(resourceMap["rnh_addr"].(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 +} + +func main() { + if len(os.Args) != 1 { + fmt.Println("Usage: go run aci_converter.go") + os.Exit(1) + } + + outputFile := "payload.json" + + planJSON, err := runTerraform() + if err != nil { + log.Fatalf("Error running Terraform: %v", err) + } + + plan, err := readPlan(planJSON) + if err != nil { + log.Fatalf("Error reading plan: %v", err) + } + + jsonDump := createItemList(plan) + + aciPayload := constructTree(jsonDump) + + aciPayloadMap := make(map[string]interface{}) + for _, item := range aciPayload { + for key, value := range item { + aciPayloadMap[key] = value + } + } + + err = writeToFile(outputFile, aciPayloadMap) + if err != nil { + log.Fatalf("Error writing output file: %v", err) + } + + fmt.Printf("ACI Payload written to %s\n", outputFile) +} diff --git a/conversion/main.tf b/conversion/main.tf new file mode 100644 index 000000000..a3e785e2e --- /dev/null +++ b/conversion/main.tf @@ -0,0 +1,334 @@ +terraform { + required_providers { + aci = { + source = "CiscoDevNet/aci" + } + } +} + +# Configure the provider with your Cisco APIC credentials. +provider "aci" { + # APIC Username + username = "admin" + # APIC Password + password = "ins3965!" + # APIC URL + url = "https://173.36.219.79" + insecure = true +} + +# Define an ACI Tenant Resource. + +/* SUCCESS +resource "aci_endpoint_tag_ip" "full_example_tenant" { + parent_dn = "uni/tn-demo_tenant" + annotation = "annotation" + vrf_name = "test_ctx_name" + id_attribute = "1" + ip = "10.0.0.2" + name = "WOW" + name_alias = "name_alias" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +*/ +//SUCCESS +/* +resource "aci_vrf_fallback_route_group" "full_example_vrf" { + parent_dn = "uni/tn-mgmt/extmgmt-default/instp-test_name" + annotation = "annotation" + description = "description" + name = "fallback_route_group" + name_alias = "name_alias" + vrf_fallback_route_group_members = [ + { + annotation = "annotation_1" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + fallback_member = "2.2.2.2" + } + ] + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} +*/ + +resource "aci_external_management_network_instance_profile" "full_example" { + annotation = "woidid" + description = "description" + name = "test_name" + name_alias = "name_alias" + priority = "level1" + relation_to_consumed_out_of_band_contracts = [ + { + annotation = "annotation_1" + priority = "level1" + out_of_band_contract_name = "aci_out_of_band_contract.example.name" + } + ] + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +/* SUCCESS + +resource "aci_external_management_network_instance_profile" "full_example333" { + annotation = "annotation" + description = "description" + name = "test_name" + name_alias = "name_alias" + priority = "level1" + relation_to_consumed_out_of_band_contracts = [ + { + annotation = "annotation_1" + priority = "level1" + out_of_band_contract_name = "aci_out_of_band_contract.example.name" + } + ] + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +*/ + + +resource "aci_netflow_monitor_policy" "full_example_tenant" { + parent_dn = "uni/tn-mgmt/extmgmt-default/instp-test_name" + annotation = "annotation" + description = "description" + name = "netfow_monitor" + name_alias = "name_alias" + owner_key = "owner_key" + owner_tag = "owner_tag" + relation_to_netflow_exporters = [ + { + annotation = "annotation_1" + netflow_exporter_policy_name = "aci_netflow_exporter_policy.example.name" + } + ] + relation_to_netflow_record = [ + { + annotation = "annotation_1" + netflow_record_policy_name = "aci_netflow_record_policy.example.name" + } + ] + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + + + +/* +resource "aci_tag" "example_tenant" { + parent_dn = "uni/tn-example_tenant" + key = "test_key" + value = "test_value" +} +*/ + + +/* + + + +*/ + +//DEFINES AN ACI ANNOTATION ------- TEST + +/* +resource "aci_annotation" "terraform_annotation" { + parent_dn = "uni/tn-example_tenant" + key = "test_key" + value = "test_value" +} + +*/ + +resource "aci_l3out_consumer_label" "full_example_l3_outside" { + parent_dn = "uni/tn-mgmt/extmgmt-default/instp-test_name" + annotation = "annotation" + description = "description" + name = "test_name" + name_alias = "name_alias" + owner = "infra" + owner_key = "owner_key" + owner_tag = "owner_tag" + tag = "lemon-chiffon" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + + +/* +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" +# } + +# # Define an ACI Application EPG Resource. +# resource "aci_application_epg" "terraform_epg" { +# for_each = var.epgs +# application_profile_dn = aci_application_profile.terraform_ap.id +# name = each.value.epg +# relation_fv_rs_bd = aci_bridge_domain.terraform_bd.id +# description = "EPG 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/conversion/payload.json b/conversion/payload.json new file mode 100644 index 000000000..16bd2284a --- /dev/null +++ b/conversion/payload.json @@ -0,0 +1,87 @@ +{ + "mgmtInstP": { + "attributes": { + "annotation": "woidid", + "name": "test_name", + "nameAlias": "name_alias" + }, + "children": [ + { + "l3extConsLbl": { + "attributes": { + "annotation": "annotation", + "name": "test_name", + "nameAlias": "name_alias", + "owner": "infra", + "ownerKey": "owner_key", + "ownerTag": "owner_tag", + "tag": "lemon-chiffon" + }, + "children": [ + { + "tagAnnotation": { + "attributes": { + "key": "key_0", + "value": "value_1" + } + } + }, + { + "tagTag": { + "attributes": { + "key": "key_0", + "value": "value_1" + } + } + } + ] + } + }, + { + "netflowMonitorPol": { + "attributes": { + "annotation": "annotation", + "name": "netfow_monitor", + "nameAlias": "name_alias", + "ownerKey": "owner_key", + "ownerTag": "owner_tag" + }, + "children": [ + { + "netflowRsMonitorToExporter": { + "attributes": { + "annotation": "annotation_1", + "tnNetflowExporterPolName": "aci_netflow_exporter_policy.example.name" + } + } + }, + { + "netflowRsMonitorToRecord": { + "attributes": { + "annotation": "annotation_1", + "tnNetflowRecordPolName": "aci_netflow_record_policy.example.name" + } + } + }, + { + "tagAnnotation": { + "attributes": { + "key": "key_0", + "value": "value_1" + } + } + }, + { + "tagTag": { + "attributes": { + "key": "key_0", + "value": "value_1" + } + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/conversion/plan.bin b/conversion/plan.bin new file mode 100644 index 000000000..35f7e58aa Binary files /dev/null and b/conversion/plan.bin differ diff --git a/conversion/plan.json b/conversion/plan.json new file mode 100644 index 000000000..a71527ac8 --- /dev/null +++ b/conversion/plan.json @@ -0,0 +1 @@ +{"format_version":"1.2","terraform_version":"1.8.5","planned_values":{"root_module":{"resources":[{"address":"aci_external_management_network_instance_profile.full_example","mode":"managed","type":"aci_external_management_network_instance_profile","name":"full_example","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"annotation":"woidid","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","name":"test_name","name_alias":"name_alias","priority":"level1","relation_to_consumed_out_of_band_contracts":[{"annotation":"annotation_1","out_of_band_contract_name":"aci_out_of_band_contract.example.name","priority":"level1"}],"tags":[{"key":"key_0","value":"value_1"}]},"sensitive_values":{"annotations":[{}],"relation_to_consumed_out_of_band_contracts":[{}],"tags":[{}]}},{"address":"aci_l3out_consumer_label.full_example_l3_outside","mode":"managed","type":"aci_l3out_consumer_label","name":"full_example_l3_outside","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"annotation":"annotation","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","name":"test_name","name_alias":"name_alias","owner":"infra","owner_key":"owner_key","owner_tag":"owner_tag","parent_dn":"uni/tn-mgmt/extmgmt-default/instp-test_name","tag":"lemon-chiffon","tags":[{"key":"key_0","value":"value_1"}]},"sensitive_values":{"annotations":[{}],"tags":[{}]}},{"address":"aci_netflow_monitor_policy.full_example_tenant","mode":"managed","type":"aci_netflow_monitor_policy","name":"full_example_tenant","provider_name":"registry.terraform.io/ciscodevnet/aci","schema_version":0,"values":{"annotation":"annotation","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","name":"netfow_monitor","name_alias":"name_alias","owner_key":"owner_key","owner_tag":"owner_tag","parent_dn":"uni/tn-mgmt/extmgmt-default/instp-test_name","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"}],"tags":[{"key":"key_0","value":"value_1"}]},"sensitive_values":{"annotations":[{}],"relation_to_netflow_exporters":[{}],"relation_to_netflow_record":[{}],"tags":[{}]}}]}},"resource_changes":[{"address":"aci_external_management_network_instance_profile.full_example","mode":"managed","type":"aci_external_management_network_instance_profile","name":"full_example","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"woidid","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","name":"test_name","name_alias":"name_alias","priority":"level1","relation_to_consumed_out_of_band_contracts":[{"annotation":"annotation_1","out_of_band_contract_name":"aci_out_of_band_contract.example.name","priority":"level1"}],"tags":[{"key":"key_0","value":"value_1"}]},"after_unknown":{"annotations":[{}],"id":true,"relation_to_consumed_out_of_band_contracts":[{}],"tags":[{}]},"before_sensitive":false,"after_sensitive":{"annotations":[{}],"relation_to_consumed_out_of_band_contracts":[{}],"tags":[{}]}}},{"address":"aci_l3out_consumer_label.full_example_l3_outside","mode":"managed","type":"aci_l3out_consumer_label","name":"full_example_l3_outside","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"annotation","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","name":"test_name","name_alias":"name_alias","owner":"infra","owner_key":"owner_key","owner_tag":"owner_tag","parent_dn":"uni/tn-mgmt/extmgmt-default/instp-test_name","tag":"lemon-chiffon","tags":[{"key":"key_0","value":"value_1"}]},"after_unknown":{"annotations":[{}],"id":true,"tags":[{}]},"before_sensitive":false,"after_sensitive":{"annotations":[{}],"tags":[{}]}}},{"address":"aci_netflow_monitor_policy.full_example_tenant","mode":"managed","type":"aci_netflow_monitor_policy","name":"full_example_tenant","provider_name":"registry.terraform.io/ciscodevnet/aci","change":{"actions":["create"],"before":null,"after":{"annotation":"annotation","annotations":[{"key":"key_0","value":"value_1"}],"description":"description","name":"netfow_monitor","name_alias":"name_alias","owner_key":"owner_key","owner_tag":"owner_tag","parent_dn":"uni/tn-mgmt/extmgmt-default/instp-test_name","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"}],"tags":[{"key":"key_0","value":"value_1"}]},"after_unknown":{"annotations":[{}],"id":true,"relation_to_netflow_exporters":[{}],"relation_to_netflow_record":[{}],"tags":[{}]},"before_sensitive":false,"after_sensitive":{"annotations":[{}],"relation_to_netflow_exporters":[{}],"relation_to_netflow_record":[{}],"tags":[{}]}}}],"configuration":{"provider_config":{"aci":{"name":"aci","full_name":"registry.terraform.io/ciscodevnet/aci","expressions":{"insecure":{"constant_value":true},"password":{"constant_value":"ins3965!"},"url":{"constant_value":"https://173.36.219.79"},"username":{"constant_value":"admin"}}}},"root_module":{"resources":[{"address":"aci_external_management_network_instance_profile.full_example","mode":"managed","type":"aci_external_management_network_instance_profile","name":"full_example","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"woidid"},"annotations":{"constant_value":[{"key":"key_0","value":"value_1"}]},"description":{"constant_value":"description"},"name":{"constant_value":"test_name"},"name_alias":{"constant_value":"name_alias"},"priority":{"constant_value":"level1"},"relation_to_consumed_out_of_band_contracts":{"constant_value":[{"annotation":"annotation_1","out_of_band_contract_name":"aci_out_of_band_contract.example.name","priority":"level1"}]},"tags":{"constant_value":[{"key":"key_0","value":"value_1"}]}},"schema_version":0},{"address":"aci_l3out_consumer_label.full_example_l3_outside","mode":"managed","type":"aci_l3out_consumer_label","name":"full_example_l3_outside","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"annotation"},"annotations":{"constant_value":[{"key":"key_0","value":"value_1"}]},"description":{"constant_value":"description"},"name":{"constant_value":"test_name"},"name_alias":{"constant_value":"name_alias"},"owner":{"constant_value":"infra"},"owner_key":{"constant_value":"owner_key"},"owner_tag":{"constant_value":"owner_tag"},"parent_dn":{"constant_value":"uni/tn-mgmt/extmgmt-default/instp-test_name"},"tag":{"constant_value":"lemon-chiffon"},"tags":{"constant_value":[{"key":"key_0","value":"value_1"}]}},"schema_version":0},{"address":"aci_netflow_monitor_policy.full_example_tenant","mode":"managed","type":"aci_netflow_monitor_policy","name":"full_example_tenant","provider_config_key":"aci","expressions":{"annotation":{"constant_value":"annotation"},"annotations":{"constant_value":[{"key":"key_0","value":"value_1"}]},"description":{"constant_value":"description"},"name":{"constant_value":"netfow_monitor"},"name_alias":{"constant_value":"name_alias"},"owner_key":{"constant_value":"owner_key"},"owner_tag":{"constant_value":"owner_tag"},"parent_dn":{"constant_value":"uni/tn-mgmt/extmgmt-default/instp-test_name"},"relation_to_netflow_exporters":{"constant_value":[{"annotation":"annotation_1","netflow_exporter_policy_name":"aci_netflow_exporter_policy.example.name"}]},"relation_to_netflow_record":{"constant_value":[{"annotation":"annotation_1","netflow_record_policy_name":"aci_netflow_record_policy.example.name"}]},"tags":{"constant_value":[{"key":"key_0","value":"value_1"}]}},"schema_version":0}]}},"timestamp":"2024-08-08T04:59:10Z","applyable":true,"complete":true,"errored":false} diff --git a/convert_funcs/conversion_annotation.go b/convert_funcs/conversion_annotation.go new file mode 100644 index 000000000..c00945c5d --- /dev/null +++ b/convert_funcs/conversion_annotation.go @@ -0,0 +1,34 @@ + + +func createTagAnnotation(attributes map[string]interface{}) 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) + } + + newAciTagAnnotation := provider.GetTagAnnotationCreateJsonPayload(ctx, &diags, data) + + jsonPayload := newAciTagAnnotation.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetTagAnnotationId(ctx, data) + attrs := payload["tagAnnotation"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} diff --git a/convert_funcs/conversion_endpoint_tag_ip.go b/convert_funcs/conversion_endpoint_tag_ip.go new file mode 100644 index 000000000..8e5cac604 --- /dev/null +++ b/convert_funcs/conversion_endpoint_tag_ip.go @@ -0,0 +1,74 @@ + + +func createFvEpIpTag(attributes map[string]interface{}) 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["ctx_name"].(string); ok && v != "" { + data.CtxName = types.StringValue(v) + } + if v, ok := attributes["id"].(string); ok && v != "" { + data.FvEpIpTagId = types.StringValue(v) + } + if v, ok := attributes["ip"].(string); ok && v != "" { + data.Ip = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvEpIpTag(attributes["annotations"]) + planTagTag := convertToTagTagFvEpIpTag(attributes["tags"]) + + newAciFvEpIpTag := provider.GetFvEpIpTagCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvEpIpTag.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvEpIpTagId(ctx, data) + attrs := payload["fvEpIpTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationFvEpIpTag(resources interface{}) []provider.TagAnnotationFvEpIpTagResourceModel { + var planResources []provider.TagAnnotationFvEpIpTagResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvEpIpTagResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvEpIpTag(resources interface{}) []provider.TagTagFvEpIpTagResourceModel { + var planResources []provider.TagTagFvEpIpTagResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvEpIpTagResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_endpoint_tag_mac.go b/convert_funcs/conversion_endpoint_tag_mac.go new file mode 100644 index 000000000..f63368495 --- /dev/null +++ b/convert_funcs/conversion_endpoint_tag_mac.go @@ -0,0 +1,74 @@ + + +func createFvEpMacTag(attributes map[string]interface{}) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.FvEpMacTagResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["bd_name"].(string); ok && v != "" { + data.BdName = types.StringValue(v) + } + if v, ok := attributes["id"].(string); ok && v != "" { + data.FvEpMacTagId = types.StringValue(v) + } + if v, ok := attributes["mac"].(string); ok && v != "" { + data.Mac = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvEpMacTag(attributes["annotations"]) + planTagTag := convertToTagTagFvEpMacTag(attributes["tags"]) + + newAciFvEpMacTag := provider.GetFvEpMacTagCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvEpMacTag.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvEpMacTagId(ctx, data) + attrs := payload["fvEpMacTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationFvEpMacTag(resources interface{}) []provider.TagAnnotationFvEpMacTagResourceModel { + var planResources []provider.TagAnnotationFvEpMacTagResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvEpMacTagResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvEpMacTag(resources interface{}) []provider.TagTagFvEpMacTagResourceModel { + var planResources []provider.TagTagFvEpMacTagResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvEpMacTagResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_external_management_network_instance_profile.go b/convert_funcs/conversion_external_management_network_instance_profile.go new file mode 100644 index 000000000..9bfb9e683 --- /dev/null +++ b/convert_funcs/conversion_external_management_network_instance_profile.go @@ -0,0 +1,83 @@ + + +func createMgmtInstP(attributes map[string]interface{}) 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["descr"].(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["prio"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + planMgmtRsOoBCons := convertToMgmtRsOoBConsMgmtInstP(attributes["relation_to_consumed_out_of_band_contracts"]) + planTagAnnotation := convertToTagAnnotationMgmtInstP(attributes["annotations"]) + planTagTag := convertToTagTagMgmtInstP(attributes["tags"]) + + newAciMgmtInstP := provider.GetMgmtInstPCreateJsonPayload(ctx, &diags, data, planMgmtRsOoBCons, planMgmtRsOoBCons, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtInstP.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetMgmtInstPId(ctx, data) + attrs := payload["mgmtInstP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + 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["prio"].(string)), + TnVzOOBBrCPName: types.StringValue(resourceMap["tn_vz_oob_br_cp_name"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationMgmtInstP(resources interface{}) []provider.TagAnnotationMgmtInstPResourceModel { + var planResources []provider.TagAnnotationMgmtInstPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationMgmtInstPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagMgmtInstP(resources interface{}) []provider.TagTagMgmtInstPResourceModel { + var planResources []provider.TagTagMgmtInstPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagMgmtInstPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_external_management_network_subnet.go b/convert_funcs/conversion_external_management_network_subnet.go new file mode 100644 index 000000000..834948191 --- /dev/null +++ b/convert_funcs/conversion_external_management_network_subnet.go @@ -0,0 +1,71 @@ + + +func createMgmtSubnet(attributes map[string]interface{}) 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["descr"].(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"]) + + newAciMgmtSubnet := provider.GetMgmtSubnetCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtSubnet.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetMgmtSubnetId(ctx, data) + attrs := payload["mgmtSubnet"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationMgmtSubnet(resources interface{}) []provider.TagAnnotationMgmtSubnetResourceModel { + var planResources []provider.TagAnnotationMgmtSubnetResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationMgmtSubnetResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagMgmtSubnet(resources interface{}) []provider.TagTagMgmtSubnetResourceModel { + var planResources []provider.TagTagMgmtSubnetResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagMgmtSubnetResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_l3out_consumer_label.go b/convert_funcs/conversion_l3out_consumer_label.go new file mode 100644 index 000000000..5cb724071 --- /dev/null +++ b/convert_funcs/conversion_l3out_consumer_label.go @@ -0,0 +1,80 @@ + + +func createL3extConsLbl(attributes map[string]interface{}) 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["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner"].(string); ok && v != "" { + data.Owner = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["tag"].(string); ok && v != "" { + data.Tag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extConsLbl(attributes["annotations"]) + planTagTag := convertToTagTagL3extConsLbl(attributes["tags"]) + + newAciL3extConsLbl := provider.GetL3extConsLblCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extConsLbl.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetL3extConsLblId(ctx, data) + attrs := payload["l3extConsLbl"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationL3extConsLbl(resources interface{}) []provider.TagAnnotationL3extConsLblResourceModel { + var planResources []provider.TagAnnotationL3extConsLblResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationL3extConsLblResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagL3extConsLbl(resources interface{}) []provider.TagTagL3extConsLblResourceModel { + var planResources []provider.TagTagL3extConsLblResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagL3extConsLblResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_l3out_node_sid_profile.go b/convert_funcs/conversion_l3out_node_sid_profile.go new file mode 100644 index 000000000..2bb70c1da --- /dev/null +++ b/convert_funcs/conversion_l3out_node_sid_profile.go @@ -0,0 +1,74 @@ + + +func createMplsNodeSidP(attributes map[string]interface{}) 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["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["loopback_addr"].(string); ok && v != "" { + data.LoopbackAddr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["sidoffset"].(string); ok && v != "" { + data.Sidoffset = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationMplsNodeSidP(attributes["annotations"]) + planTagTag := convertToTagTagMplsNodeSidP(attributes["tags"]) + + newAciMplsNodeSidP := provider.GetMplsNodeSidPCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMplsNodeSidP.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetMplsNodeSidPId(ctx, data) + attrs := payload["mplsNodeSidP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationMplsNodeSidP(resources interface{}) []provider.TagAnnotationMplsNodeSidPResourceModel { + var planResources []provider.TagAnnotationMplsNodeSidPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationMplsNodeSidPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagMplsNodeSidP(resources interface{}) []provider.TagTagMplsNodeSidPResourceModel { + var planResources []provider.TagTagMplsNodeSidPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagMplsNodeSidPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_l3out_provider_label.go b/convert_funcs/conversion_l3out_provider_label.go new file mode 100644 index 000000000..5d201d468 --- /dev/null +++ b/convert_funcs/conversion_l3out_provider_label.go @@ -0,0 +1,77 @@ + + +func createL3extProvLbl(attributes map[string]interface{}) 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["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["tag"].(string); ok && v != "" { + data.Tag = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extProvLbl(attributes["annotations"]) + planTagTag := convertToTagTagL3extProvLbl(attributes["tags"]) + + newAciL3extProvLbl := provider.GetL3extProvLblCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extProvLbl.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetL3extProvLblId(ctx, data) + attrs := payload["l3extProvLbl"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationL3extProvLbl(resources interface{}) []provider.TagAnnotationL3extProvLblResourceModel { + var planResources []provider.TagAnnotationL3extProvLblResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationL3extProvLblResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagL3extProvLbl(resources interface{}) []provider.TagTagL3extProvLblResourceModel { + var planResources []provider.TagTagL3extProvLblResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagL3extProvLblResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_l3out_redistribute_policy.go b/convert_funcs/conversion_l3out_redistribute_policy.go new file mode 100644 index 000000000..8568743a2 --- /dev/null +++ b/convert_funcs/conversion_l3out_redistribute_policy.go @@ -0,0 +1,65 @@ + + +func createL3extRsRedistributePol(attributes map[string]interface{}) 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["src"].(string); ok && v != "" { + data.Src = types.StringValue(v) + } + if v, ok := attributes["tn_rtctrl_profile_name"].(string); ok && v != "" { + data.TnRtctrlProfileName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extRsRedistributePol(attributes["annotations"]) + planTagTag := convertToTagTagL3extRsRedistributePol(attributes["tags"]) + + newAciL3extRsRedistributePol := provider.GetL3extRsRedistributePolCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extRsRedistributePol.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetL3extRsRedistributePolId(ctx, data) + attrs := payload["l3extRsRedistributePol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationL3extRsRedistributePol(resources interface{}) []provider.TagAnnotationL3extRsRedistributePolResourceModel { + var planResources []provider.TagAnnotationL3extRsRedistributePolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationL3extRsRedistributePolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagL3extRsRedistributePol(resources interface{}) []provider.TagTagL3extRsRedistributePolResourceModel { + var planResources []provider.TagTagL3extRsRedistributePolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagL3extRsRedistributePolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_netflow_monitor_policy.go b/convert_funcs/conversion_netflow_monitor_policy.go new file mode 100644 index 000000000..9b3e44e17 --- /dev/null +++ b/convert_funcs/conversion_netflow_monitor_policy.go @@ -0,0 +1,102 @@ + + +func createNetflowMonitorPol(attributes map[string]interface{}) 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["descr"].(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"]) + + newAciNetflowMonitorPol := provider.GetNetflowMonitorPolCreateJsonPayload(ctx, &diags, data, planNetflowRsMonitorToExporter, planNetflowRsMonitorToExporter, planNetflowRsMonitorToRecord, planNetflowRsMonitorToRecord, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciNetflowMonitorPol.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetNetflowMonitorPolId(ctx, data) + attrs := payload["netflowMonitorPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + 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["tn_netflow_exporter_pol_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["tn_netflow_record_pol_name"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationNetflowMonitorPol(resources interface{}) []provider.TagAnnotationNetflowMonitorPolResourceModel { + var planResources []provider.TagAnnotationNetflowMonitorPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationNetflowMonitorPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagNetflowMonitorPol(resources interface{}) []provider.TagTagNetflowMonitorPolResourceModel { + var planResources []provider.TagTagNetflowMonitorPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagNetflowMonitorPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_out_of_band_contract.go b/convert_funcs/conversion_out_of_band_contract.go new file mode 100644 index 000000000..d77bd0a71 --- /dev/null +++ b/convert_funcs/conversion_out_of_band_contract.go @@ -0,0 +1,83 @@ + + +func createVzOOBBrCP(attributes map[string]interface{}) 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["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["intent"].(string); ok && v != "" { + data.Intent = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["owner_key"].(string); ok && v != "" { + data.OwnerKey = types.StringValue(v) + } + if v, ok := attributes["owner_tag"].(string); ok && v != "" { + data.OwnerTag = types.StringValue(v) + } + if v, ok := attributes["prio"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["scope"].(string); ok && v != "" { + data.Scope = types.StringValue(v) + } + if v, ok := attributes["target_dscp"].(string); ok && v != "" { + data.TargetDscp = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationVzOOBBrCP(attributes["annotations"]) + planTagTag := convertToTagTagVzOOBBrCP(attributes["tags"]) + + newAciVzOOBBrCP := provider.GetVzOOBBrCPCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciVzOOBBrCP.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetVzOOBBrCPId(ctx, data) + attrs := payload["vzOOBBrCP"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationVzOOBBrCP(resources interface{}) []provider.TagAnnotationVzOOBBrCPResourceModel { + var planResources []provider.TagAnnotationVzOOBBrCPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationVzOOBBrCPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagVzOOBBrCP(resources interface{}) []provider.TagTagVzOOBBrCPResourceModel { + var planResources []provider.TagTagVzOOBBrCPResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagVzOOBBrCPResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_pim_route_map_entry.go b/convert_funcs/conversion_pim_route_map_entry.go new file mode 100644 index 000000000..8523602a2 --- /dev/null +++ b/convert_funcs/conversion_pim_route_map_entry.go @@ -0,0 +1,83 @@ + + +func createPimRouteMapEntry(attributes map[string]interface{}) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.PimRouteMapEntryResourceModel{} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + if v, ok := attributes["action"].(string); ok && v != "" { + data.Action = types.StringValue(v) + } + if v, ok := attributes["annotation"].(string); ok && v != "" { + data.Annotation = types.StringValue(v) + } + if v, ok := attributes["descr"].(string); ok && v != "" { + data.Descr = types.StringValue(v) + } + if v, ok := attributes["grp"].(string); ok && v != "" { + data.Grp = types.StringValue(v) + } + if v, ok := attributes["name"].(string); ok && v != "" { + data.Name = types.StringValue(v) + } + if v, ok := attributes["name_alias"].(string); ok && v != "" { + data.NameAlias = types.StringValue(v) + } + if v, ok := attributes["order"].(string); ok && v != "" { + data.Order = types.StringValue(v) + } + if v, ok := attributes["rp"].(string); ok && v != "" { + data.Rp = types.StringValue(v) + } + if v, ok := attributes["src"].(string); ok && v != "" { + data.Src = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationPimRouteMapEntry(attributes["annotations"]) + planTagTag := convertToTagTagPimRouteMapEntry(attributes["tags"]) + + newAciPimRouteMapEntry := provider.GetPimRouteMapEntryCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciPimRouteMapEntry.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetPimRouteMapEntryId(ctx, data) + attrs := payload["pimRouteMapEntry"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationPimRouteMapEntry(resources interface{}) []provider.TagAnnotationPimRouteMapEntryResourceModel { + var planResources []provider.TagAnnotationPimRouteMapEntryResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationPimRouteMapEntryResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagPimRouteMapEntry(resources interface{}) []provider.TagTagPimRouteMapEntryResourceModel { + var planResources []provider.TagTagPimRouteMapEntryResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagPimRouteMapEntryResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_pim_route_map_policy.go b/convert_funcs/conversion_pim_route_map_policy.go new file mode 100644 index 000000000..a07fe2f90 --- /dev/null +++ b/convert_funcs/conversion_pim_route_map_policy.go @@ -0,0 +1,74 @@ + + +func createPimRouteMapPol(attributes map[string]interface{}) 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["descr"].(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"]) + + newAciPimRouteMapPol := provider.GetPimRouteMapPolCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciPimRouteMapPol.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetPimRouteMapPolId(ctx, data) + attrs := payload["pimRouteMapPol"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationPimRouteMapPol(resources interface{}) []provider.TagAnnotationPimRouteMapPolResourceModel { + var planResources []provider.TagAnnotationPimRouteMapPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationPimRouteMapPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagPimRouteMapPol(resources interface{}) []provider.TagTagPimRouteMapPolResourceModel { + var planResources []provider.TagTagPimRouteMapPolResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagPimRouteMapPolResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go b/convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go new file mode 100644 index 000000000..905184d2b --- /dev/null +++ b/convert_funcs/conversion_relation_to_consumed_out_of_band_contract.go @@ -0,0 +1,65 @@ + + +func createMgmtRsOoBCons(attributes map[string]interface{}) 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["prio"].(string); ok && v != "" { + data.Prio = types.StringValue(v) + } + if v, ok := attributes["tn_vz_oob_br_cp_name"].(string); ok && v != "" { + data.TnVzOOBBrCPName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationMgmtRsOoBCons(attributes["annotations"]) + planTagTag := convertToTagTagMgmtRsOoBCons(attributes["tags"]) + + newAciMgmtRsOoBCons := provider.GetMgmtRsOoBConsCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciMgmtRsOoBCons.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetMgmtRsOoBConsId(ctx, data) + attrs := payload["mgmtRsOoBCons"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationMgmtRsOoBCons(resources interface{}) []provider.TagAnnotationMgmtRsOoBConsResourceModel { + var planResources []provider.TagAnnotationMgmtRsOoBConsResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationMgmtRsOoBConsResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagMgmtRsOoBCons(resources interface{}) []provider.TagTagMgmtRsOoBConsResourceModel { + var planResources []provider.TagTagMgmtRsOoBConsResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagMgmtRsOoBConsResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_fallback_route_group.go b/convert_funcs/conversion_relation_to_fallback_route_group.go new file mode 100644 index 000000000..6af8f5a28 --- /dev/null +++ b/convert_funcs/conversion_relation_to_fallback_route_group.go @@ -0,0 +1,62 @@ + + +func createL3extRsOutToFBRGroup(attributes map[string]interface{}) 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["t_dn"].(string); ok && v != "" { + data.TDn = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationL3extRsOutToFBRGroup(attributes["annotations"]) + planTagTag := convertToTagTagL3extRsOutToFBRGroup(attributes["tags"]) + + newAciL3extRsOutToFBRGroup := provider.GetL3extRsOutToFBRGroupCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciL3extRsOutToFBRGroup.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetL3extRsOutToFBRGroupId(ctx, data) + attrs := payload["l3extRsOutToFBRGroup"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationL3extRsOutToFBRGroup(resources interface{}) []provider.TagAnnotationL3extRsOutToFBRGroupResourceModel { + var planResources []provider.TagAnnotationL3extRsOutToFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationL3extRsOutToFBRGroupResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagL3extRsOutToFBRGroup(resources interface{}) []provider.TagTagL3extRsOutToFBRGroupResourceModel { + var planResources []provider.TagTagL3extRsOutToFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagL3extRsOutToFBRGroupResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_relation_to_netflow_exporter.go b/convert_funcs/conversion_relation_to_netflow_exporter.go new file mode 100644 index 000000000..4a0ecbe7e --- /dev/null +++ b/convert_funcs/conversion_relation_to_netflow_exporter.go @@ -0,0 +1,62 @@ + + +func createNetflowRsMonitorToExporter(attributes map[string]interface{}) 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["tn_netflow_exporter_pol_name"].(string); ok && v != "" { + data.TnNetflowExporterPolName = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationNetflowRsMonitorToExporter(attributes["annotations"]) + planTagTag := convertToTagTagNetflowRsMonitorToExporter(attributes["tags"]) + + newAciNetflowRsMonitorToExporter := provider.GetNetflowRsMonitorToExporterCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciNetflowRsMonitorToExporter.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetNetflowRsMonitorToExporterId(ctx, data) + attrs := payload["netflowRsMonitorToExporter"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} +func convertToTagAnnotationNetflowRsMonitorToExporter(resources interface{}) []provider.TagAnnotationNetflowRsMonitorToExporterResourceModel { + var planResources []provider.TagAnnotationNetflowRsMonitorToExporterResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationNetflowRsMonitorToExporterResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagNetflowRsMonitorToExporter(resources interface{}) []provider.TagTagNetflowRsMonitorToExporterResourceModel { + var planResources []provider.TagTagNetflowRsMonitorToExporterResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagNetflowRsMonitorToExporterResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_tag.go b/convert_funcs/conversion_tag.go new file mode 100644 index 000000000..033159a0d --- /dev/null +++ b/convert_funcs/conversion_tag.go @@ -0,0 +1,34 @@ + + +func createTagTag(attributes map[string]interface{}) 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) + } + + newAciTagTag := provider.GetTagTagCreateJsonPayload(ctx, &diags, data) + + jsonPayload := newAciTagTag.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetTagTagId(ctx, data) + attrs := payload["tagTag"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + return payload +} diff --git a/convert_funcs/conversion_vrf_fallback_route_group.go b/convert_funcs/conversion_vrf_fallback_route_group.go new file mode 100644 index 000000000..325617402 --- /dev/null +++ b/convert_funcs/conversion_vrf_fallback_route_group.go @@ -0,0 +1,85 @@ + + +func createFvFBRGroup(attributes map[string]interface{}) 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["descr"].(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"]) + planTagAnnotation := convertToTagAnnotationFvFBRGroup(attributes["annotations"]) + planTagTag := convertToTagTagFvFBRGroup(attributes["tags"]) + + newAciFvFBRGroup := provider.GetFvFBRGroupCreateJsonPayload(ctx, &diags, data, planFvFBRMember, planFvFBRMember, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvFBRGroup.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvFBRGroupId(ctx, data) + attrs := payload["fvFBRGroup"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + 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["descr"].(string)), + Name: types.StringValue(resourceMap["name"].(string)), + NameAlias: types.StringValue(resourceMap["name_alias"].(string)), + RnhAddr: types.StringValue(resourceMap["rnh_addr"].(string)), + }) + } + } + return planResources +} +func convertToTagAnnotationFvFBRGroup(resources interface{}) []provider.TagAnnotationFvFBRGroupResourceModel { + var planResources []provider.TagAnnotationFvFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagAnnotationFvFBRGroupResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} +func convertToTagTagFvFBRGroup(resources interface{}) []provider.TagTagFvFBRGroupResourceModel { + var planResources []provider.TagTagFvFBRGroupResourceModel + if resources, ok := resources.([]interface{}); ok { + for _, resource := range resources { + resourceMap := resource.(map[string]interface{}) + planResources = append(planResources, provider.TagTagFvFBRGroupResourceModel{ + Key: types.StringValue(resourceMap["key"].(string)), + Value: types.StringValue(resourceMap["value"].(string)), + }) + } + } + return planResources +} diff --git a/convert_funcs/conversion_vrf_fallback_route_group_member.go b/convert_funcs/conversion_vrf_fallback_route_group_member.go new file mode 100644 index 000000000..a35aedd4a --- /dev/null +++ b/convert_funcs/conversion_vrf_fallback_route_group_member.go @@ -0,0 +1,71 @@ + + +func createFvFBRMember(attributes map[string]interface{}) 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["descr"].(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["rnh_addr"].(string); ok && v != "" { + data.RnhAddr = types.StringValue(v) + } + planTagAnnotation := convertToTagAnnotationFvFBRMember(attributes["annotations"]) + planTagTag := convertToTagTagFvFBRMember(attributes["tags"]) + + newAciFvFBRMember := provider.GetFvFBRMemberCreateJsonPayload(ctx, &diags, data, planTagAnnotation, planTagAnnotation, planTagTag, planTagTag) + + jsonPayload := newAciFvFBRMember.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.SetFvFBRMemberId(ctx, data) + attrs := payload["fvFBRMember"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + 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/gen/generator.go b/gen/generator.go index ba1228518..ad4861a13 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -70,6 +70,7 @@ const ( resourcesDocsPath = "./docs/resources" datasourcesDocsPath = "./docs/data-sources" providerPath = "./internal/provider/" + conversionPath = "./convert_funcs/" ) const providerName = "aci" @@ -79,6 +80,7 @@ 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{ + "lowercaseFirst": LowercaseFirst, "snakeCase": Underscore, "validatorString": ValidatorString, "containsString": ContainsString, @@ -328,6 +330,13 @@ func getTestVars(model Model) (map[string]interface{}, error) { return testVarsMap, nil } +func LowercaseFirst(s string) string { + if len(s) == 0 { + return s + } + return strings.ToLower(s[:1]) + s[1:] +} + // Retrieves the property and classs overwrite definitions from the definitions YAML files func getDefinitions() Definitions { definitions := Definitions{} @@ -606,6 +615,7 @@ func main() { renderTemplate("datasource.md.tmpl", fmt.Sprintf("%s.md", model.ResourceName), datasourcesDocsPath, model) renderTemplate("resource_test.go.tmpl", fmt.Sprintf("resource_%s_%s_test.go", providerName, model.ResourceName), providerPath, model) renderTemplate("datasource_test.go.tmpl", fmt.Sprintf("data_source_%s_%s_test.go", providerName, model.ResourceName), providerPath, model) + renderTemplate("conversion.go.tmpl", fmt.Sprintf("conversion_%s.go", model.ResourceName), conversionPath, model) } } diff --git a/gen/templates/conversion.go.tmpl b/gen/templates/conversion.go.tmpl new file mode 100644 index 000000000..a04028389 --- /dev/null +++ b/gen/templates/conversion.go.tmpl @@ -0,0 +1,62 @@ +{{- $resourceClassName := .ResourceClassName }} +{{- $resourceName := .ResourceName }} +{{- $properties := .Properties }} +{{- $children := .Children }} + +func create{{ $resourceClassName }}(attributes map[string]interface{}) map[string]interface{} { + ctx := context.Background() + var diags diag.Diagnostics + data := &provider.{{ $resourceClassName }}ResourceModel{} + + {{- if .HasParent }} + if v, ok := attributes["parent_dn"].(string); ok && v != "" { + data.ParentDn = types.StringValue(v) + } + {{- end }} + + {{- range $properties }} + if v, ok := attributes["{{ .SnakeCaseName }}"].(string); ok && v != "" { + data.{{- if eq .Name "Id" }}{{ $resourceClassName }}{{ .Name }}{{- else }}{{ .Name }}{{- end }} = types.StringValue(v) + } + {{- end }} + + {{- range $children }} + plan{{ .ResourceClassName }} := convertTo{{ .ResourceClassName }}{{ $resourceClassName }}(attributes["{{ .ResourceName }}"]) + {{- end }} + + newAci{{ $resourceClassName }} := provider.Get{{ $resourceClassName }}CreateJsonPayload(ctx, &diags, data + {{- range $children }}, plan{{ .ResourceClassName }}, plan{{ .ResourceClassName }}{{- end }}) + + jsonPayload := newAci{{ $resourceClassName }}.EncodeJSON(container.EncodeOptIndent("", " ")) + payload, err := parseCustomJSON(jsonPayload) + if err != nil { + log.Fatalf("Error unmarshalling JSON: %v\n", err) + } + + provider.Set{{ $resourceClassName }}Id(ctx, data) + attrs := payload["{{lowercaseFirst $resourceClassName }}"].(map[string]interface{})["attributes"].(map[string]interface{}) + attrs["dn"] = data.Id.ValueString() + + if status, ok := attributes["status"].(string); ok && status != "" { + attrs["status"] = status + } + + 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["{{ .SnakeCaseName }}"].(string)), + {{- end }} + }) + } + } + return planResources +} +{{- end }} diff --git a/gen/templates/datasource.go.tmpl b/gen/templates/datasource.go.tmpl index 22e399311..fc3935b1e 100644 --- a/gen/templates/datasource.go.tmpl +++ b/gen/templates/datasource.go.tmpl @@ -142,7 +142,7 @@ func (d *{{.ResourceClassName}}DataSource) Read(ctx context.Context, req datasou } {{- end}} - set{{.ResourceClassName}}Id(ctx, data) + Set{{.ResourceClassName}}Id(ctx, data) // Create a copy of the Id for when not found during getAndSet{{.ResourceClassName}}Attributes cachedId := data.Id.ValueString() diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index e91b2fd43..02d738341 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -272,7 +272,7 @@ func (r *{{.ResourceClassName}}Resource) Create(ctx context.Context, req resourc // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *{{.ResourceClassName}}ResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - set{{.ResourceClassName}}Id(ctx, stateData) + Set{{.ResourceClassName}}Id(ctx, stateData) getAndSet{{.ResourceClassName}}Attributes(ctx, &resp.Diagnostics, r.client, stateData) {{- end}} @@ -285,7 +285,7 @@ func (r *{{.ResourceClassName}}Resource) Create(ctx context.Context, req resourc return } - 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())) @@ -295,9 +295,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, data{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State{{- end}}) + jsonPayload := Get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, data{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State{{- end}}) {{- else}} - jsonPayload := get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, data) + jsonPayload := Get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, data) {{- end}} if resp.Diagnostics.HasError() { @@ -367,9 +367,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, data{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State{{- end}}) + jsonPayload := Get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, data{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State{{- end}}) {{- else}} - jsonPayload := get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, data) + jsonPayload := Get{{.ResourceClassName}}CreateJsonPayload(ctx, &resp.Diagnostics, data) {{- end}} if resp.Diagnostics.HasError() { @@ -607,7 +607,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)) @@ -700,7 +700,7 @@ func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context } {{- end}} -func get{{.ResourceClassName}}CreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, 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, data *{{.ResourceClassName}}ResourceModel{{- range .Children}}, {{.PkgName}}Plan, {{.PkgName}}State []{{.ResourceClassName}}{{$.ResourceClassName}}ResourceModel{{- end}}) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} {{- if .HasChild}} 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_endpoint_tag_ip.go b/internal/provider/data_source_aci_endpoint_tag_ip.go index 7c1bf4a91..7f0d2e21e 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 20681e3c3..4a3cad462 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_external_management_network_instance_profile.go b/internal/provider/data_source_aci_external_management_network_instance_profile.go index 4c1859580..7542b650d 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_out_of_band_contract.go b/internal/provider/data_source_aci_out_of_band_contract.go index 28c567b69..00b30e37d 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_out_of_band_contract.go b/internal/provider/data_source_aci_relation_to_consumed_out_of_band_contract.go index 3a1f25c2e..519fad7ab 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_fallback_route_group.go b/internal/provider/data_source_aci_relation_to_fallback_route_group.go index 43ff1992b..91fa3468d 100644 --- a/internal/provider/data_source_aci_relation_to_fallback_route_group.go +++ b/internal/provider/data_source_aci_relation_to_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_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_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_vrf_fallback_route_group.go b/internal/provider/data_source_aci_vrf_fallback_route_group.go index 25948dd50..0a40be3ff 100644 --- a/internal/provider/data_source_aci_vrf_fallback_route_group.go +++ b/internal/provider/data_source_aci_vrf_fallback_route_group.go @@ -162,7 +162,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_annotation.go b/internal/provider/resource_aci_annotation.go index 72b1f1605..f6bf026dd 100644 --- a/internal/provider/resource_aci_annotation.go +++ b/internal/provider/resource_aci_annotation.go @@ -131,11 +131,11 @@ func (r *TagAnnotationResource) Create(ctx context.Context, req resource.CreateR return } - 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, data) + jsonPayload := GetTagAnnotationCreateJsonPayload(ctx, &resp.Diagnostics, data) if resp.Diagnostics.HasError() { return @@ -192,7 +192,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, data) + jsonPayload := GetTagAnnotationCreateJsonPayload(ctx, &resp.Diagnostics, data) if resp.Diagnostics.HasError() { return @@ -304,12 +304,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, data *TagAnnotationResourceModel) *container.Container { +func GetTagAnnotationCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *TagAnnotationResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} if !data.Key.IsNull() && !data.Key.IsUnknown() { diff --git a/internal/provider/resource_aci_endpoint_tag_ip.go b/internal/provider/resource_aci_endpoint_tag_ip.go index 2e711138e..bde9f3b70 100644 --- a/internal/provider/resource_aci_endpoint_tag_ip.go +++ b/internal/provider/resource_aci_endpoint_tag_ip.go @@ -231,7 +231,7 @@ func (r *FvEpIpTagResource) Create(ctx context.Context, req resource.CreateReque // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *FvEpIpTagResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setFvEpIpTagId(ctx, stateData) + SetFvEpIpTagId(ctx, stateData) getAndSetFvEpIpTagAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *FvEpIpTagResourceModel @@ -243,7 +243,7 @@ func (r *FvEpIpTagResource) Create(ctx context.Context, req resource.CreateReque return } - setFvEpIpTagId(ctx, data) + SetFvEpIpTagId(ctx, data) tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_endpoint_tag_ip with id '%s'", data.Id.ValueString())) @@ -253,7 +253,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvEpIpTagCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -318,7 +318,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvEpIpTagCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -483,7 +483,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)) } @@ -567,7 +567,7 @@ func getFvEpIpTagTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getFvEpIpTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvEpIpTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpIpTagResourceModel, tagTagPlan, tagTagState []TagTagFvEpIpTagResourceModel) *container.Container { +func GetFvEpIpTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvEpIpTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpIpTagResourceModel, tagTagPlan, tagTagState []TagTagFvEpIpTagResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_endpoint_tag_mac.go b/internal/provider/resource_aci_endpoint_tag_mac.go index a405e067d..a2bdc6b97 100644 --- a/internal/provider/resource_aci_endpoint_tag_mac.go +++ b/internal/provider/resource_aci_endpoint_tag_mac.go @@ -231,7 +231,7 @@ func (r *FvEpMacTagResource) Create(ctx context.Context, req resource.CreateRequ // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *FvEpMacTagResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setFvEpMacTagId(ctx, stateData) + SetFvEpMacTagId(ctx, stateData) getAndSetFvEpMacTagAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *FvEpMacTagResourceModel @@ -243,7 +243,7 @@ func (r *FvEpMacTagResource) Create(ctx context.Context, req resource.CreateRequ return } - setFvEpMacTagId(ctx, data) + SetFvEpMacTagId(ctx, data) tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_endpoint_tag_mac with id '%s'", data.Id.ValueString())) @@ -253,7 +253,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvEpMacTagCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -318,7 +318,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvEpMacTagCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -483,7 +483,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)) } @@ -567,7 +567,7 @@ func getFvEpMacTagTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getFvEpMacTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvEpMacTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpMacTagResourceModel, tagTagPlan, tagTagState []TagTagFvEpMacTagResourceModel) *container.Container { +func GetFvEpMacTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvEpMacTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpMacTagResourceModel, tagTagPlan, tagTagState []TagTagFvEpMacTagResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} 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 5b4b737e2..4ef9ae1c6 100644 --- a/internal/provider/resource_aci_external_management_network_instance_profile.go +++ b/internal/provider/resource_aci_external_management_network_instance_profile.go @@ -263,7 +263,7 @@ func (r *MgmtInstPResource) Create(ctx context.Context, req resource.CreateReque // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *MgmtInstPResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setMgmtInstPId(ctx, stateData) + SetMgmtInstPId(ctx, stateData) getAndSetMgmtInstPAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *MgmtInstPResourceModel @@ -275,7 +275,7 @@ func (r *MgmtInstPResource) Create(ctx context.Context, req resource.CreateReque return } - 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())) @@ -288,7 +288,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, data, mgmtRsOoBConsPlan, mgmtRsOoBConsState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtInstPCreateJsonPayload(ctx, &resp.Diagnostics, data, mgmtRsOoBConsPlan, mgmtRsOoBConsState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -356,7 +356,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, data, mgmtRsOoBConsPlan, mgmtRsOoBConsState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtInstPCreateJsonPayload(ctx, &resp.Diagnostics, data, mgmtRsOoBConsPlan, mgmtRsOoBConsState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -517,7 +517,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)) } @@ -645,7 +645,7 @@ func getMgmtInstPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getMgmtInstPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MgmtInstPResourceModel, mgmtRsOoBConsPlan, mgmtRsOoBConsState []MgmtRsOoBConsMgmtInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtInstPResourceModel, tagTagPlan, tagTagState []TagTagMgmtInstPResourceModel) *container.Container { +func GetMgmtInstPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MgmtInstPResourceModel, mgmtRsOoBConsPlan, mgmtRsOoBConsState []MgmtRsOoBConsMgmtInstPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtInstPResourceModel, tagTagPlan, tagTagState []TagTagMgmtInstPResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_external_management_network_subnet.go b/internal/provider/resource_aci_external_management_network_subnet.go index 846fbe0de..07733c47b 100644 --- a/internal/provider/resource_aci_external_management_network_subnet.go +++ b/internal/provider/resource_aci_external_management_network_subnet.go @@ -221,7 +221,7 @@ func (r *MgmtSubnetResource) Create(ctx context.Context, req resource.CreateRequ // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *MgmtSubnetResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setMgmtSubnetId(ctx, stateData) + SetMgmtSubnetId(ctx, stateData) getAndSetMgmtSubnetAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *MgmtSubnetResourceModel @@ -233,7 +233,7 @@ func (r *MgmtSubnetResource) Create(ctx context.Context, req resource.CreateRequ return } - 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())) @@ -243,7 +243,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtSubnetCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -308,7 +308,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtSubnetCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -468,7 +468,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)) } @@ -552,7 +552,7 @@ func getMgmtSubnetTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getMgmtSubnetCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MgmtSubnetResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtSubnetResourceModel, tagTagPlan, tagTagState []TagTagMgmtSubnetResourceModel) *container.Container { +func GetMgmtSubnetCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MgmtSubnetResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtSubnetResourceModel, tagTagPlan, tagTagState []TagTagMgmtSubnetResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_l3out_consumer_label.go b/internal/provider/resource_aci_l3out_consumer_label.go index b3c602508..991915754 100644 --- a/internal/provider/resource_aci_l3out_consumer_label.go +++ b/internal/provider/resource_aci_l3out_consumer_label.go @@ -256,7 +256,7 @@ func (r *L3extConsLblResource) Create(ctx context.Context, req resource.CreateRe // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *L3extConsLblResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setL3extConsLblId(ctx, stateData) + SetL3extConsLblId(ctx, stateData) getAndSetL3extConsLblAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *L3extConsLblResourceModel @@ -268,7 +268,7 @@ func (r *L3extConsLblResource) Create(ctx context.Context, req resource.CreateRe return } - setL3extConsLblId(ctx, data) + SetL3extConsLblId(ctx, data) tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_consumer_label with id '%s'", data.Id.ValueString())) @@ -278,7 +278,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -343,7 +343,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extConsLblCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -512,7 +512,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)) } @@ -596,7 +596,7 @@ func getL3extConsLblTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { +func GetL3extConsLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extConsLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extConsLblResourceModel, tagTagPlan, tagTagState []TagTagL3extConsLblResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_l3out_node_sid_profile.go b/internal/provider/resource_aci_l3out_node_sid_profile.go index b64363c56..2f65bcd50 100644 --- a/internal/provider/resource_aci_l3out_node_sid_profile.go +++ b/internal/provider/resource_aci_l3out_node_sid_profile.go @@ -230,7 +230,7 @@ func (r *MplsNodeSidPResource) Create(ctx context.Context, req resource.CreateRe // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *MplsNodeSidPResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setMplsNodeSidPId(ctx, stateData) + SetMplsNodeSidPId(ctx, stateData) getAndSetMplsNodeSidPAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *MplsNodeSidPResourceModel @@ -242,7 +242,7 @@ func (r *MplsNodeSidPResource) Create(ctx context.Context, req resource.CreateRe return } - 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())) @@ -252,7 +252,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMplsNodeSidPCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -317,7 +317,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMplsNodeSidPCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -480,7 +480,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)) } @@ -564,7 +564,7 @@ func getMplsNodeSidPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getMplsNodeSidPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MplsNodeSidPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMplsNodeSidPResourceModel, tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel) *container.Container { +func GetMplsNodeSidPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MplsNodeSidPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMplsNodeSidPResourceModel, tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_l3out_provider_label.go b/internal/provider/resource_aci_l3out_provider_label.go index fba072364..64a076939 100644 --- a/internal/provider/resource_aci_l3out_provider_label.go +++ b/internal/provider/resource_aci_l3out_provider_label.go @@ -244,7 +244,7 @@ func (r *L3extProvLblResource) Create(ctx context.Context, req resource.CreateRe // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *L3extProvLblResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setL3extProvLblId(ctx, stateData) + SetL3extProvLblId(ctx, stateData) getAndSetL3extProvLblAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *L3extProvLblResourceModel @@ -256,7 +256,7 @@ func (r *L3extProvLblResource) Create(ctx context.Context, req resource.CreateRe return } - setL3extProvLblId(ctx, data) + SetL3extProvLblId(ctx, data) tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_provider_label with id '%s'", data.Id.ValueString())) @@ -266,7 +266,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extProvLblCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -331,7 +331,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extProvLblCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -497,7 +497,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)) } @@ -581,7 +581,7 @@ func getL3extProvLblTagTagChildPayloads(ctx context.Context, diags *diag.Diagnos return childPayloads } -func getL3extProvLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extProvLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extProvLblResourceModel, tagTagPlan, tagTagState []TagTagL3extProvLblResourceModel) *container.Container { +func GetL3extProvLblCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extProvLblResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extProvLblResourceModel, tagTagPlan, tagTagState []TagTagL3extProvLblResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_l3out_redistribute_policy.go b/internal/provider/resource_aci_l3out_redistribute_policy.go index 09116d7bc..39b61ec3f 100644 --- a/internal/provider/resource_aci_l3out_redistribute_policy.go +++ b/internal/provider/resource_aci_l3out_redistribute_policy.go @@ -209,7 +209,7 @@ func (r *L3extRsRedistributePolResource) Create(ctx context.Context, req resourc // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *L3extRsRedistributePolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setL3extRsRedistributePolId(ctx, stateData) + SetL3extRsRedistributePolId(ctx, stateData) getAndSetL3extRsRedistributePolAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *L3extRsRedistributePolResourceModel @@ -221,7 +221,7 @@ func (r *L3extRsRedistributePolResource) Create(ctx context.Context, req resourc return } - setL3extRsRedistributePolId(ctx, data) + SetL3extRsRedistributePolId(ctx, data) tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_redistribute_policy with id '%s'", data.Id.ValueString())) @@ -231,7 +231,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extRsRedistributePolCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -296,7 +296,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extRsRedistributePolCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -450,7 +450,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)) } @@ -534,7 +534,7 @@ func getL3extRsRedistributePolTagTagChildPayloads(ctx context.Context, diags *di return childPayloads } -func getL3extRsRedistributePolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extRsRedistributePolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsRedistributePolResourceModel, tagTagPlan, tagTagState []TagTagL3extRsRedistributePolResourceModel) *container.Container { +func GetL3extRsRedistributePolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extRsRedistributePolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsRedistributePolResourceModel, tagTagPlan, tagTagState []TagTagL3extRsRedistributePolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_netflow_monitor_policy.go b/internal/provider/resource_aci_netflow_monitor_policy.go index e3f1251a8..a1dc99023 100644 --- a/internal/provider/resource_aci_netflow_monitor_policy.go +++ b/internal/provider/resource_aci_netflow_monitor_policy.go @@ -306,7 +306,7 @@ func (r *NetflowMonitorPolResource) Create(ctx context.Context, req resource.Cre // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *NetflowMonitorPolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setNetflowMonitorPolId(ctx, stateData) + SetNetflowMonitorPolId(ctx, stateData) getAndSetNetflowMonitorPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *NetflowMonitorPolResourceModel @@ -318,7 +318,7 @@ func (r *NetflowMonitorPolResource) Create(ctx context.Context, req resource.Cre return } - setNetflowMonitorPolId(ctx, data) + SetNetflowMonitorPolId(ctx, data) tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_netflow_monitor_policy with id '%s'", data.Id.ValueString())) @@ -334,7 +334,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, data, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowMonitorPolCreateJsonPayload(ctx, &resp.Diagnostics, data, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -405,7 +405,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, data, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowMonitorPolCreateJsonPayload(ctx, &resp.Diagnostics, data, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -598,7 +598,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)) } @@ -752,7 +752,7 @@ func getNetflowMonitorPolTagTagChildPayloads(ctx context.Context, diags *diag.Di return childPayloads } -func getNetflowMonitorPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *NetflowMonitorPolResourceModel, netflowRsMonitorToExporterPlan, netflowRsMonitorToExporterState []NetflowRsMonitorToExporterNetflowMonitorPolResourceModel, netflowRsMonitorToRecordPlan, netflowRsMonitorToRecordState []NetflowRsMonitorToRecordNetflowMonitorPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowMonitorPolResourceModel, tagTagPlan, tagTagState []TagTagNetflowMonitorPolResourceModel) *container.Container { +func GetNetflowMonitorPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, 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{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_out_of_band_contract.go b/internal/provider/resource_aci_out_of_band_contract.go index c0bb85548..7e21c5125 100644 --- a/internal/provider/resource_aci_out_of_band_contract.go +++ b/internal/provider/resource_aci_out_of_band_contract.go @@ -271,7 +271,7 @@ func (r *VzOOBBrCPResource) Create(ctx context.Context, req resource.CreateReque // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *VzOOBBrCPResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setVzOOBBrCPId(ctx, stateData) + SetVzOOBBrCPId(ctx, stateData) getAndSetVzOOBBrCPAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *VzOOBBrCPResourceModel @@ -283,7 +283,7 @@ func (r *VzOOBBrCPResource) Create(ctx context.Context, req resource.CreateReque return } - 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())) @@ -293,7 +293,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetVzOOBBrCPCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -358,7 +358,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetVzOOBBrCPCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -516,7 +516,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)) } @@ -600,7 +600,7 @@ func getVzOOBBrCPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostic return childPayloads } -func getVzOOBBrCPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *VzOOBBrCPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationVzOOBBrCPResourceModel, tagTagPlan, tagTagState []TagTagVzOOBBrCPResourceModel) *container.Container { +func GetVzOOBBrCPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *VzOOBBrCPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationVzOOBBrCPResourceModel, tagTagPlan, tagTagState []TagTagVzOOBBrCPResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_pim_route_map_entry.go b/internal/provider/resource_aci_pim_route_map_entry.go index 1a05ea464..9f9664bc3 100644 --- a/internal/provider/resource_aci_pim_route_map_entry.go +++ b/internal/provider/resource_aci_pim_route_map_entry.go @@ -262,7 +262,7 @@ func (r *PimRouteMapEntryResource) Create(ctx context.Context, req resource.Crea // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *PimRouteMapEntryResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setPimRouteMapEntryId(ctx, stateData) + SetPimRouteMapEntryId(ctx, stateData) getAndSetPimRouteMapEntryAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *PimRouteMapEntryResourceModel @@ -274,7 +274,7 @@ func (r *PimRouteMapEntryResource) Create(ctx context.Context, req resource.Crea return } - 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())) @@ -284,7 +284,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetPimRouteMapEntryCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -349,7 +349,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetPimRouteMapEntryCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -521,7 +521,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)) } @@ -605,7 +605,7 @@ func getPimRouteMapEntryTagTagChildPayloads(ctx context.Context, diags *diag.Dia return childPayloads } -func getPimRouteMapEntryCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *PimRouteMapEntryResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPimRouteMapEntryResourceModel, tagTagPlan, tagTagState []TagTagPimRouteMapEntryResourceModel) *container.Container { +func GetPimRouteMapEntryCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *PimRouteMapEntryResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPimRouteMapEntryResourceModel, tagTagPlan, tagTagState []TagTagPimRouteMapEntryResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_pim_route_map_policy.go b/internal/provider/resource_aci_pim_route_map_policy.go index c63bb3e79..7ad4800e8 100644 --- a/internal/provider/resource_aci_pim_route_map_policy.go +++ b/internal/provider/resource_aci_pim_route_map_policy.go @@ -230,7 +230,7 @@ func (r *PimRouteMapPolResource) Create(ctx context.Context, req resource.Create // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *PimRouteMapPolResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setPimRouteMapPolId(ctx, stateData) + SetPimRouteMapPolId(ctx, stateData) getAndSetPimRouteMapPolAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *PimRouteMapPolResourceModel @@ -242,7 +242,7 @@ func (r *PimRouteMapPolResource) Create(ctx context.Context, req resource.Create return } - 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())) @@ -252,7 +252,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetPimRouteMapPolCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -317,7 +317,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetPimRouteMapPolCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -480,7 +480,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)) } @@ -564,7 +564,7 @@ func getPimRouteMapPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagn return childPayloads } -func getPimRouteMapPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *PimRouteMapPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPimRouteMapPolResourceModel, tagTagPlan, tagTagState []TagTagPimRouteMapPolResourceModel) *container.Container { +func GetPimRouteMapPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *PimRouteMapPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPimRouteMapPolResourceModel, tagTagPlan, tagTagState []TagTagPimRouteMapPolResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} 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 8458e5ebb..79db6173c 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 @@ -208,7 +208,7 @@ func (r *MgmtRsOoBConsResource) Create(ctx context.Context, req resource.CreateR // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *MgmtRsOoBConsResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setMgmtRsOoBConsId(ctx, stateData) + SetMgmtRsOoBConsId(ctx, stateData) getAndSetMgmtRsOoBConsAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *MgmtRsOoBConsResourceModel @@ -220,7 +220,7 @@ func (r *MgmtRsOoBConsResource) Create(ctx context.Context, req resource.CreateR return } - 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())) @@ -230,7 +230,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtRsOoBConsCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -295,7 +295,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetMgmtRsOoBConsCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -449,7 +449,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)) } @@ -533,7 +533,7 @@ func getMgmtRsOoBConsTagTagChildPayloads(ctx context.Context, diags *diag.Diagno return childPayloads } -func getMgmtRsOoBConsCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MgmtRsOoBConsResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtRsOoBConsResourceModel, tagTagPlan, tagTagState []TagTagMgmtRsOoBConsResourceModel) *container.Container { +func GetMgmtRsOoBConsCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MgmtRsOoBConsResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMgmtRsOoBConsResourceModel, tagTagPlan, tagTagState []TagTagMgmtRsOoBConsResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_relation_to_fallback_route_group.go b/internal/provider/resource_aci_relation_to_fallback_route_group.go index 008b9e309..1f6a29d92 100644 --- a/internal/provider/resource_aci_relation_to_fallback_route_group.go +++ b/internal/provider/resource_aci_relation_to_fallback_route_group.go @@ -194,7 +194,7 @@ func (r *L3extRsOutToFBRGroupResource) Create(ctx context.Context, req resource. // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *L3extRsOutToFBRGroupResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setL3extRsOutToFBRGroupId(ctx, stateData) + SetL3extRsOutToFBRGroupId(ctx, stateData) getAndSetL3extRsOutToFBRGroupAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *L3extRsOutToFBRGroupResourceModel @@ -206,7 +206,7 @@ func (r *L3extRsOutToFBRGroupResource) Create(ctx context.Context, req resource. return } - setL3extRsOutToFBRGroupId(ctx, data) + SetL3extRsOutToFBRGroupId(ctx, data) tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) @@ -216,7 +216,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extRsOutToFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -281,7 +281,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetL3extRsOutToFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -432,7 +432,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)) } @@ -516,7 +516,7 @@ func getL3extRsOutToFBRGroupTagTagChildPayloads(ctx context.Context, diags *diag return childPayloads } -func getL3extRsOutToFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extRsOutToFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsOutToFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagL3extRsOutToFBRGroupResourceModel) *container.Container { +func GetL3extRsOutToFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *L3extRsOutToFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsOutToFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagL3extRsOutToFBRGroupResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_relation_to_netflow_exporter.go b/internal/provider/resource_aci_relation_to_netflow_exporter.go index 858087501..174e3b00d 100644 --- a/internal/provider/resource_aci_relation_to_netflow_exporter.go +++ b/internal/provider/resource_aci_relation_to_netflow_exporter.go @@ -194,7 +194,7 @@ func (r *NetflowRsMonitorToExporterResource) Create(ctx context.Context, req res // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *NetflowRsMonitorToExporterResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setNetflowRsMonitorToExporterId(ctx, stateData) + SetNetflowRsMonitorToExporterId(ctx, stateData) getAndSetNetflowRsMonitorToExporterAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *NetflowRsMonitorToExporterResourceModel @@ -206,7 +206,7 @@ func (r *NetflowRsMonitorToExporterResource) Create(ctx context.Context, req res return } - 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())) @@ -216,7 +216,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowRsMonitorToExporterCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -281,7 +281,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetNetflowRsMonitorToExporterCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -432,7 +432,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)) } @@ -516,7 +516,7 @@ func getNetflowRsMonitorToExporterTagTagChildPayloads(ctx context.Context, diags return childPayloads } -func getNetflowRsMonitorToExporterCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *NetflowRsMonitorToExporterResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowRsMonitorToExporterResourceModel, tagTagPlan, tagTagState []TagTagNetflowRsMonitorToExporterResourceModel) *container.Container { +func GetNetflowRsMonitorToExporterCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *NetflowRsMonitorToExporterResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationNetflowRsMonitorToExporterResourceModel, tagTagPlan, tagTagState []TagTagNetflowRsMonitorToExporterResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/internal/provider/resource_aci_tag.go b/internal/provider/resource_aci_tag.go index 839aa221e..d821d0f5f 100644 --- a/internal/provider/resource_aci_tag.go +++ b/internal/provider/resource_aci_tag.go @@ -131,11 +131,11 @@ func (r *TagTagResource) Create(ctx context.Context, req resource.CreateRequest, return } - 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, data) + jsonPayload := GetTagTagCreateJsonPayload(ctx, &resp.Diagnostics, data) if resp.Diagnostics.HasError() { return @@ -192,7 +192,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, data) + jsonPayload := GetTagTagCreateJsonPayload(ctx, &resp.Diagnostics, data) if resp.Diagnostics.HasError() { return @@ -304,12 +304,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, data *TagTagResourceModel) *container.Container { +func GetTagTagCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *TagTagResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} if !data.Key.IsNull() && !data.Key.IsUnknown() { diff --git a/internal/provider/resource_aci_vrf_fallback_route_group.go b/internal/provider/resource_aci_vrf_fallback_route_group.go index a1f9c231b..f6735b2bf 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group.go @@ -273,7 +273,7 @@ func (r *FvFBRGroupResource) Create(ctx context.Context, req resource.CreateRequ // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *FvFBRGroupResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setFvFBRGroupId(ctx, stateData) + SetFvFBRGroupId(ctx, stateData) getAndSetFvFBRGroupAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *FvFBRGroupResourceModel @@ -285,7 +285,7 @@ func (r *FvFBRGroupResource) Create(ctx context.Context, req resource.CreateRequ return } - 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())) @@ -298,7 +298,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, data, fvFBRMemberPlan, fvFBRMemberState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, data, fvFBRMemberPlan, fvFBRMemberState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -366,7 +366,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, data, fvFBRMemberPlan, fvFBRMemberState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, data, fvFBRMemberPlan, fvFBRMemberState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -547,7 +547,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)) } @@ -681,7 +681,7 @@ func getFvFBRGroupTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getFvFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvFBRGroupResourceModel, fvFBRMemberPlan, fvFBRMemberState []FvFBRMemberFvFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel) *container.Container { +func GetFvFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvFBRGroupResourceModel, fvFBRMemberPlan, fvFBRMemberState []FvFBRMemberFvFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} 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 c78c3486b..701d76ba8 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group_member.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group_member.go @@ -221,7 +221,7 @@ func (r *FvFBRMemberResource) Create(ctx context.Context, req resource.CreateReq // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *FvFBRMemberResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) - setFvFBRMemberId(ctx, stateData) + SetFvFBRMemberId(ctx, stateData) getAndSetFvFBRMemberAttributes(ctx, &resp.Diagnostics, r.client, stateData) var data *FvFBRMemberResourceModel @@ -233,7 +233,7 @@ func (r *FvFBRMemberResource) Create(ctx context.Context, req resource.CreateReq return } - 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())) @@ -243,7 +243,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRMemberCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -308,7 +308,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, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := GetFvFBRMemberCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -468,7 +468,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)) } @@ -552,7 +552,7 @@ func getFvFBRMemberTagTagChildPayloads(ctx context.Context, diags *diag.Diagnost return childPayloads } -func getFvFBRMemberCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvFBRMemberResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRMemberResourceModel, tagTagPlan, tagTagState []TagTagFvFBRMemberResourceModel) *container.Container { +func GetFvFBRMemberCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvFBRMemberResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRMemberResourceModel, tagTagPlan, tagTagState []TagTagFvFBRMemberResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} diff --git a/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/2.15.0.json b/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/2.15.0.json new file mode 100644 index 000000000..87db87b05 --- /dev/null +++ b/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/2.15.0.json @@ -0,0 +1,10 @@ +{ + "archives": { + "darwin_arm64": { + "hashes": [ + "h1:1KNQy+3Y7h7dI3ORPK/M/iC/cOTlOerMilyJ/t/bYcY=" + ], + "url": "terraform-provider-aci_2.15.0_darwin_arm64.zip" + } + } +} \ No newline at end of file diff --git a/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/index.json b/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/index.json new file mode 100644 index 000000000..6e74d92ea --- /dev/null +++ b/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/index.json @@ -0,0 +1,5 @@ +{ + "versions": { + "2.15.0": {} + } +} \ No newline at end of file diff --git a/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/terraform-provider-aci_2.15.0_darwin_arm64.zip b/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/terraform-provider-aci_2.15.0_darwin_arm64.zip new file mode 100644 index 000000000..1ec22c269 Binary files /dev/null and b/terraform-provider-aci/registry.terraform.io/ciscodevnet/aci/terraform-provider-aci_2.15.0_darwin_arm64.zip differ