// Code generated by "gen/generator.go"; DO NOT EDIT.
// In order to regenerate this file execute `go generate` from the repository root.
// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md).

package provider

import (
	"context"
	"encoding/json"
	"fmt"

	customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types"
	"github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators"
	"github.com/ciscoecosystem/aci-go-client/v2/client"
	"github.com/ciscoecosystem/aci-go-client/v2/container"
	"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
	"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
	"github.com/hashicorp/terraform-plugin-framework/attr"
	"github.com/hashicorp/terraform-plugin-framework/diag"
	"github.com/hashicorp/terraform-plugin-framework/path"
	"github.com/hashicorp/terraform-plugin-framework/resource"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
	"github.com/hashicorp/terraform-plugin-framework/schema/validator"
	"github.com/hashicorp/terraform-plugin-framework/types"
	"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
	"github.com/hashicorp/terraform-plugin-log/tflog"
)

// Ensure provider defined types fully satisfy framework interfaces.
var _ resource.Resource = &FvESgResource{}
var _ resource.ResourceWithImportState = &FvESgResource{}

func NewFvESgResource() resource.Resource {
	return &FvESgResource{}
}

// FvESgResource defines the resource implementation.
type FvESgResource struct {
	client *client.Client
}

// FvESgResourceModel describes the resource data model.
type FvESgResourceModel struct {
	Id                                  types.String `tfsdk:"id"`
	ParentDn                            types.String `tfsdk:"parent_dn"`
	Annotation                          types.String `tfsdk:"annotation"`
	Descr                               types.String `tfsdk:"description"`
	ExceptionTag                        types.String `tfsdk:"exception_tag"`
	MatchT                              types.String `tfsdk:"match_criteria"`
	Name                                types.String `tfsdk:"name"`
	NameAlias                           types.String `tfsdk:"name_alias"`
	PcEnfPref                           types.String `tfsdk:"intra_esg_isolation"`
	PcTag                               types.String `tfsdk:"pc_tag"`
	PrefGrMemb                          types.String `tfsdk:"preferred_group_member"`
	Scope                               types.String `tfsdk:"scope"`
	Shutdown                            types.String `tfsdk:"admin_state"`
	FvRsCons                            types.Set    `tfsdk:"relation_to_consumed_contracts"`
	FvRsConsIf                          types.Set    `tfsdk:"relation_to_imported_contracts"`
	FvRsIntraEpg                        types.Set    `tfsdk:"relation_to_intra_epg_contracts"`
	FvRsProv                            types.Set    `tfsdk:"relation_to_provided_contracts"`
	FvRsScope                           types.Object `tfsdk:"relation_to_vrf"`
	FvRsSecInherited                    types.Set    `tfsdk:"relation_to_contract_masters"`
	TagAnnotation                       types.Set    `tfsdk:"annotations"`
	TagTag                              types.Set    `tfsdk:"tags"`
	DeprecatedMatchT                    types.String `tfsdk:"match_t"`
	DeprecatedParentDn                  types.String `tfsdk:"application_profile_dn"`
	DeprecatedPcEnfPref                 types.String `tfsdk:"pc_enf_pref"`
	DeprecatedPrefGrMemb                types.String `tfsdk:"pref_gr_memb"`
	Ignored_relation_fv_rs_cust_qos_pol types.String `tfsdk:"relation_fv_rs_cust_qos_pol"`
	Ignored_relation_fv_rs_prot_by      types.Set    `tfsdk:"relation_fv_rs_prot_by"`
	DeprecatedFvRsSecInherited          types.Set    `tfsdk:"relation_fv_rs_sec_inherited"`
	DeprecatedFvRsIntraEpg              types.Set    `tfsdk:"relation_fv_rs_intra_epg"`
	DeprecatedFvRsScope                 types.String `tfsdk:"relation_fv_rs_scope"`
	DeprecatedFvRsCons                  types.Set    `tfsdk:"relation_fv_rs_cons"`
	DeprecatedFvRsConsIf                types.Set    `tfsdk:"relation_fv_rs_cons_if"`
	DeprecatedFvRsProv                  types.Set    `tfsdk:"relation_fv_rs_prov"`
}

func getEmptyFvESgResourceModel() *FvESgResourceModel {
	return &FvESgResourceModel{
		Id:           basetypes.NewStringNull(),
		ParentDn:     basetypes.NewStringNull(),
		Annotation:   basetypes.NewStringNull(),
		Descr:        basetypes.NewStringNull(),
		ExceptionTag: basetypes.NewStringNull(),
		MatchT:       basetypes.NewStringNull(),
		Name:         basetypes.NewStringNull(),
		NameAlias:    basetypes.NewStringNull(),
		PcEnfPref:    basetypes.NewStringNull(),
		PcTag:        basetypes.NewStringNull(),
		PrefGrMemb:   basetypes.NewStringNull(),
		Scope:        basetypes.NewStringNull(),
		Shutdown:     basetypes.NewStringNull(),
		FvRsCons: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"annotation":    types.StringType,
				"priority":      types.StringType,
				"contract_name": types.StringType,
				"annotations":   types.SetType{ElemType: TagAnnotationFvRsConsFvESgType},
				"tags":          types.SetType{ElemType: TagTagFvRsConsFvESgType},
			},
		}),
		FvRsConsIf: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"annotation":             types.StringType,
				"priority":               types.StringType,
				"imported_contract_name": types.StringType,
				"annotations":            types.SetType{ElemType: TagAnnotationFvRsConsIfFvESgType},
				"tags":                   types.SetType{ElemType: TagTagFvRsConsIfFvESgType},
			},
		}),
		FvRsIntraEpg: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"annotation":    types.StringType,
				"contract_name": types.StringType,
				"annotations":   types.SetType{ElemType: TagAnnotationFvRsIntraEpgFvESgType},
				"tags":          types.SetType{ElemType: TagTagFvRsIntraEpgFvESgType},
			},
		}),
		FvRsProv: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"annotation":     types.StringType,
				"match_criteria": types.StringType,
				"priority":       types.StringType,
				"contract_name":  types.StringType,
				"annotations":    types.SetType{ElemType: TagAnnotationFvRsProvFvESgType},
				"tags":           types.SetType{ElemType: TagTagFvRsProvFvESgType},
			},
		}),
		FvRsScope: types.ObjectNull(map[string]attr.Type{
			"annotation":  types.StringType,
			"vrf_name":    types.StringType,
			"annotations": types.SetType{ElemType: TagAnnotationFvRsScopeFvESgType},
			"tags":        types.SetType{ElemType: TagTagFvRsScopeFvESgType},
		}),
		FvRsSecInherited: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"annotation":  types.StringType,
				"target_dn":   types.StringType,
				"annotations": types.SetType{ElemType: TagAnnotationFvRsSecInheritedFvESgType},
				"tags":        types.SetType{ElemType: TagTagFvRsSecInheritedFvESgType},
			},
		}),
		TagAnnotation: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
		TagTag: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
		DeprecatedMatchT:                    types.String{},
		DeprecatedParentDn:                  types.String{},
		DeprecatedPcEnfPref:                 types.String{},
		DeprecatedPrefGrMemb:                types.String{},
		Ignored_relation_fv_rs_cust_qos_pol: types.String{},
		Ignored_relation_fv_rs_prot_by:      types.SetNull(types.StringType),
		DeprecatedFvRsSecInherited:          types.SetNull(types.StringType),
		DeprecatedFvRsIntraEpg:              types.SetNull(types.StringType),
		DeprecatedFvRsScope:                 types.String{},
		DeprecatedFvRsCons:                  types.SetNull(deprecatedFvRsConsType),
		DeprecatedFvRsConsIf:                types.SetNull(deprecatedFvRsConsIfType),
		DeprecatedFvRsProv:                  types.SetNull(deprecatedFvRsProvType),
	}
}

// FvRsConsFvESgResourceModel describes the resource data model for the children without relation ships.
type FvRsConsFvESgResourceModel struct {
	Annotation    types.String                        `tfsdk:"annotation"`
	Prio          customTypes.FvRsConsPrioStringValue `tfsdk:"priority"`
	TnVzBrCPName  types.String                        `tfsdk:"contract_name"`
	TagAnnotation types.Set                           `tfsdk:"annotations"`
	TagTag        types.Set                           `tfsdk:"tags"`
}

func getEmptyFvRsConsFvESgResourceModel() FvRsConsFvESgResourceModel {
	return FvRsConsFvESgResourceModel{
		Annotation:   basetypes.NewStringNull(),
		Prio:         customTypes.NewFvRsConsPrioStringNull(),
		TnVzBrCPName: basetypes.NewStringNull(),
		TagAnnotation: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
		TagTag: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
	}
}

var FvRsConsFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"annotation":    types.StringType,
		"priority":      types.StringType,
		"contract_name": types.StringType,
		"annotations":   types.SetType{ElemType: TagAnnotationFvRsConsFvESgType},
		"tags":          types.SetType{ElemType: TagTagFvRsConsFvESgType},
	},
}

func FvRsConsFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue {
	//  Function is needed to handle the case that an attribute is not yet supported in a version and gets set to null during read
	var planSetValues, stateSetValues []FvRsConsFvESgResourceModel
	stateValue.ElementsAs(ctx, &stateSetValues, false)
	planValue.ElementsAs(ctx, &planSetValues, false)

	// If the length of the state and plan values are different a change is already detected the loop can be skipped
	if len(stateSetValues) == len(planSetValues) {
		for index, stateValue := range stateSetValues {
			nullInStateFound := false
			if stateValue.Annotation.IsNull() {
				nullInStateFound = true
				planSetValues[index].Annotation = basetypes.NewStringNull()
			}
			if stateValue.Prio.IsNull() {
				nullInStateFound = true
				planSetValues[index].Prio = customTypes.NewFvRsConsPrioStringNull()
			}
			if stateValue.TnVzBrCPName.IsNull() {
				nullInStateFound = true
				planSetValues[index].TnVzBrCPName = basetypes.NewStringNull()
			}
			if !nullInStateFound {
				// when there are no null fields we can conclude the version supports all attributes in set
				break
			}
		}
	}
	planSet, _ := types.SetValueFrom(ctx, FvRsConsFvESgType, planSetValues)
	return planSet

}

// TagAnnotationFvRsConsFvESgResourceModel describes the resource data model for the children without relation ships.
type TagAnnotationFvRsConsFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagAnnotationFvRsConsFvESgResourceModel() TagAnnotationFvRsConsFvESgResourceModel {
	return TagAnnotationFvRsConsFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagAnnotationFvRsConsFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// TagTagFvRsConsFvESgResourceModel describes the resource data model for the children without relation ships.
type TagTagFvRsConsFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagTagFvRsConsFvESgResourceModel() TagTagFvRsConsFvESgResourceModel {
	return TagTagFvRsConsFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagTagFvRsConsFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// FvRsConsIfFvESgResourceModel describes the resource data model for the children without relation ships.
type FvRsConsIfFvESgResourceModel struct {
	Annotation    types.String                          `tfsdk:"annotation"`
	Prio          customTypes.FvRsConsIfPrioStringValue `tfsdk:"priority"`
	TnVzCPIfName  types.String                          `tfsdk:"imported_contract_name"`
	TagAnnotation types.Set                             `tfsdk:"annotations"`
	TagTag        types.Set                             `tfsdk:"tags"`
}

func getEmptyFvRsConsIfFvESgResourceModel() FvRsConsIfFvESgResourceModel {
	return FvRsConsIfFvESgResourceModel{
		Annotation:   basetypes.NewStringNull(),
		Prio:         customTypes.NewFvRsConsIfPrioStringNull(),
		TnVzCPIfName: basetypes.NewStringNull(),
		TagAnnotation: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
		TagTag: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
	}
}

var FvRsConsIfFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"annotation":             types.StringType,
		"priority":               types.StringType,
		"imported_contract_name": types.StringType,
		"annotations":            types.SetType{ElemType: TagAnnotationFvRsConsIfFvESgType},
		"tags":                   types.SetType{ElemType: TagTagFvRsConsIfFvESgType},
	},
}

func FvRsConsIfFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue {
	//  Function is needed to handle the case that an attribute is not yet supported in a version and gets set to null during read
	var planSetValues, stateSetValues []FvRsConsIfFvESgResourceModel
	stateValue.ElementsAs(ctx, &stateSetValues, false)
	planValue.ElementsAs(ctx, &planSetValues, false)

	// If the length of the state and plan values are different a change is already detected the loop can be skipped
	if len(stateSetValues) == len(planSetValues) {
		for index, stateValue := range stateSetValues {
			nullInStateFound := false
			if stateValue.Annotation.IsNull() {
				nullInStateFound = true
				planSetValues[index].Annotation = basetypes.NewStringNull()
			}
			if stateValue.Prio.IsNull() {
				nullInStateFound = true
				planSetValues[index].Prio = customTypes.NewFvRsConsIfPrioStringNull()
			}
			if stateValue.TnVzCPIfName.IsNull() {
				nullInStateFound = true
				planSetValues[index].TnVzCPIfName = basetypes.NewStringNull()
			}
			if !nullInStateFound {
				// when there are no null fields we can conclude the version supports all attributes in set
				break
			}
		}
	}
	planSet, _ := types.SetValueFrom(ctx, FvRsConsIfFvESgType, planSetValues)
	return planSet

}

// TagAnnotationFvRsConsIfFvESgResourceModel describes the resource data model for the children without relation ships.
type TagAnnotationFvRsConsIfFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagAnnotationFvRsConsIfFvESgResourceModel() TagAnnotationFvRsConsIfFvESgResourceModel {
	return TagAnnotationFvRsConsIfFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagAnnotationFvRsConsIfFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// TagTagFvRsConsIfFvESgResourceModel describes the resource data model for the children without relation ships.
type TagTagFvRsConsIfFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagTagFvRsConsIfFvESgResourceModel() TagTagFvRsConsIfFvESgResourceModel {
	return TagTagFvRsConsIfFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagTagFvRsConsIfFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// FvRsIntraEpgFvESgResourceModel describes the resource data model for the children without relation ships.
type FvRsIntraEpgFvESgResourceModel struct {
	Annotation    types.String `tfsdk:"annotation"`
	TnVzBrCPName  types.String `tfsdk:"contract_name"`
	TagAnnotation types.Set    `tfsdk:"annotations"`
	TagTag        types.Set    `tfsdk:"tags"`
}

func getEmptyFvRsIntraEpgFvESgResourceModel() FvRsIntraEpgFvESgResourceModel {
	return FvRsIntraEpgFvESgResourceModel{
		Annotation:   basetypes.NewStringNull(),
		TnVzBrCPName: basetypes.NewStringNull(),
		TagAnnotation: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
		TagTag: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
	}
}

var FvRsIntraEpgFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"annotation":    types.StringType,
		"contract_name": types.StringType,
		"annotations":   types.SetType{ElemType: TagAnnotationFvRsIntraEpgFvESgType},
		"tags":          types.SetType{ElemType: TagTagFvRsIntraEpgFvESgType},
	},
}

func FvRsIntraEpgFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue {
	//  Function is needed to handle the case that an attribute is not yet supported in a version and gets set to null during read
	var planSetValues, stateSetValues []FvRsIntraEpgFvESgResourceModel
	stateValue.ElementsAs(ctx, &stateSetValues, false)
	planValue.ElementsAs(ctx, &planSetValues, false)

	// If the length of the state and plan values are different a change is already detected the loop can be skipped
	if len(stateSetValues) == len(planSetValues) {
		for index, stateValue := range stateSetValues {
			nullInStateFound := false
			if stateValue.Annotation.IsNull() {
				nullInStateFound = true
				planSetValues[index].Annotation = basetypes.NewStringNull()
			}
			if stateValue.TnVzBrCPName.IsNull() {
				nullInStateFound = true
				planSetValues[index].TnVzBrCPName = basetypes.NewStringNull()
			}
			if !nullInStateFound {
				// when there are no null fields we can conclude the version supports all attributes in set
				break
			}
		}
	}
	planSet, _ := types.SetValueFrom(ctx, FvRsIntraEpgFvESgType, planSetValues)
	return planSet

}

// TagAnnotationFvRsIntraEpgFvESgResourceModel describes the resource data model for the children without relation ships.
type TagAnnotationFvRsIntraEpgFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagAnnotationFvRsIntraEpgFvESgResourceModel() TagAnnotationFvRsIntraEpgFvESgResourceModel {
	return TagAnnotationFvRsIntraEpgFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagAnnotationFvRsIntraEpgFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// TagTagFvRsIntraEpgFvESgResourceModel describes the resource data model for the children without relation ships.
type TagTagFvRsIntraEpgFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagTagFvRsIntraEpgFvESgResourceModel() TagTagFvRsIntraEpgFvESgResourceModel {
	return TagTagFvRsIntraEpgFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagTagFvRsIntraEpgFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// FvRsProvFvESgResourceModel describes the resource data model for the children without relation ships.
type FvRsProvFvESgResourceModel struct {
	Annotation    types.String                        `tfsdk:"annotation"`
	MatchT        types.String                        `tfsdk:"match_criteria"`
	Prio          customTypes.FvRsProvPrioStringValue `tfsdk:"priority"`
	TnVzBrCPName  types.String                        `tfsdk:"contract_name"`
	TagAnnotation types.Set                           `tfsdk:"annotations"`
	TagTag        types.Set                           `tfsdk:"tags"`
}

func getEmptyFvRsProvFvESgResourceModel() FvRsProvFvESgResourceModel {
	return FvRsProvFvESgResourceModel{
		Annotation:   basetypes.NewStringNull(),
		MatchT:       basetypes.NewStringNull(),
		Prio:         customTypes.NewFvRsProvPrioStringNull(),
		TnVzBrCPName: basetypes.NewStringNull(),
		TagAnnotation: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
		TagTag: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
	}
}

var FvRsProvFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"annotation":     types.StringType,
		"match_criteria": types.StringType,
		"priority":       types.StringType,
		"contract_name":  types.StringType,
		"annotations":    types.SetType{ElemType: TagAnnotationFvRsProvFvESgType},
		"tags":           types.SetType{ElemType: TagTagFvRsProvFvESgType},
	},
}

func FvRsProvFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue {
	//  Function is needed to handle the case that an attribute is not yet supported in a version and gets set to null during read
	var planSetValues, stateSetValues []FvRsProvFvESgResourceModel
	stateValue.ElementsAs(ctx, &stateSetValues, false)
	planValue.ElementsAs(ctx, &planSetValues, false)

	// If the length of the state and plan values are different a change is already detected the loop can be skipped
	if len(stateSetValues) == len(planSetValues) {
		for index, stateValue := range stateSetValues {
			nullInStateFound := false
			if stateValue.Annotation.IsNull() {
				nullInStateFound = true
				planSetValues[index].Annotation = basetypes.NewStringNull()
			}
			if stateValue.MatchT.IsNull() {
				nullInStateFound = true
				planSetValues[index].MatchT = basetypes.NewStringNull()
			}
			if stateValue.Prio.IsNull() {
				nullInStateFound = true
				planSetValues[index].Prio = customTypes.NewFvRsProvPrioStringNull()
			}
			if stateValue.TnVzBrCPName.IsNull() {
				nullInStateFound = true
				planSetValues[index].TnVzBrCPName = basetypes.NewStringNull()
			}
			if !nullInStateFound {
				// when there are no null fields we can conclude the version supports all attributes in set
				break
			}
		}
	}
	planSet, _ := types.SetValueFrom(ctx, FvRsProvFvESgType, planSetValues)
	return planSet

}

// TagAnnotationFvRsProvFvESgResourceModel describes the resource data model for the children without relation ships.
type TagAnnotationFvRsProvFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagAnnotationFvRsProvFvESgResourceModel() TagAnnotationFvRsProvFvESgResourceModel {
	return TagAnnotationFvRsProvFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagAnnotationFvRsProvFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// TagTagFvRsProvFvESgResourceModel describes the resource data model for the children without relation ships.
type TagTagFvRsProvFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagTagFvRsProvFvESgResourceModel() TagTagFvRsProvFvESgResourceModel {
	return TagTagFvRsProvFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagTagFvRsProvFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// FvRsScopeFvESgResourceModel describes the resource data model for the children without relation ships.
type FvRsScopeFvESgResourceModel struct {
	Annotation    types.String `tfsdk:"annotation"`
	TnFvCtxName   types.String `tfsdk:"vrf_name"`
	TagAnnotation types.Set    `tfsdk:"annotations"`
	TagTag        types.Set    `tfsdk:"tags"`
}

func getEmptyFvRsScopeFvESgResourceModel() FvRsScopeFvESgResourceModel {
	return FvRsScopeFvESgResourceModel{
		Annotation:  basetypes.NewStringNull(),
		TnFvCtxName: basetypes.NewStringNull(),
		TagAnnotation: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
		TagTag: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
	}
}

var FvRsScopeFvESgType = map[string]attr.Type{
	"annotation":  types.StringType,
	"vrf_name":    types.StringType,
	"annotations": types.SetType{ElemType: TagAnnotationFvRsScopeFvESgType},
	"tags":        types.SetType{ElemType: TagTagFvRsScopeFvESgType},
}

// TagAnnotationFvRsScopeFvESgResourceModel describes the resource data model for the children without relation ships.
type TagAnnotationFvRsScopeFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagAnnotationFvRsScopeFvESgResourceModel() TagAnnotationFvRsScopeFvESgResourceModel {
	return TagAnnotationFvRsScopeFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagAnnotationFvRsScopeFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// TagTagFvRsScopeFvESgResourceModel describes the resource data model for the children without relation ships.
type TagTagFvRsScopeFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagTagFvRsScopeFvESgResourceModel() TagTagFvRsScopeFvESgResourceModel {
	return TagTagFvRsScopeFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagTagFvRsScopeFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// FvRsSecInheritedFvESgResourceModel describes the resource data model for the children without relation ships.
type FvRsSecInheritedFvESgResourceModel struct {
	Annotation    types.String `tfsdk:"annotation"`
	TDn           types.String `tfsdk:"target_dn"`
	TagAnnotation types.Set    `tfsdk:"annotations"`
	TagTag        types.Set    `tfsdk:"tags"`
}

func getEmptyFvRsSecInheritedFvESgResourceModel() FvRsSecInheritedFvESgResourceModel {
	return FvRsSecInheritedFvESgResourceModel{
		Annotation: basetypes.NewStringNull(),
		TDn:        basetypes.NewStringNull(),
		TagAnnotation: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
		TagTag: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"key":   types.StringType,
				"value": types.StringType,
			},
		}),
	}
}

var FvRsSecInheritedFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"annotation":  types.StringType,
		"target_dn":   types.StringType,
		"annotations": types.SetType{ElemType: TagAnnotationFvRsSecInheritedFvESgType},
		"tags":        types.SetType{ElemType: TagTagFvRsSecInheritedFvESgType},
	},
}

func FvRsSecInheritedFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue {
	//  Function is needed to handle the case that an attribute is not yet supported in a version and gets set to null during read
	var planSetValues, stateSetValues []FvRsSecInheritedFvESgResourceModel
	stateValue.ElementsAs(ctx, &stateSetValues, false)
	planValue.ElementsAs(ctx, &planSetValues, false)

	// If the length of the state and plan values are different a change is already detected the loop can be skipped
	if len(stateSetValues) == len(planSetValues) {
		for index, stateValue := range stateSetValues {
			nullInStateFound := false
			if stateValue.Annotation.IsNull() {
				nullInStateFound = true
				planSetValues[index].Annotation = basetypes.NewStringNull()
			}
			if stateValue.TDn.IsNull() {
				nullInStateFound = true
				planSetValues[index].TDn = basetypes.NewStringNull()
			}
			if !nullInStateFound {
				// when there are no null fields we can conclude the version supports all attributes in set
				break
			}
		}
	}
	planSet, _ := types.SetValueFrom(ctx, FvRsSecInheritedFvESgType, planSetValues)
	return planSet

}

// TagAnnotationFvRsSecInheritedFvESgResourceModel describes the resource data model for the children without relation ships.
type TagAnnotationFvRsSecInheritedFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagAnnotationFvRsSecInheritedFvESgResourceModel() TagAnnotationFvRsSecInheritedFvESgResourceModel {
	return TagAnnotationFvRsSecInheritedFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagAnnotationFvRsSecInheritedFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// TagTagFvRsSecInheritedFvESgResourceModel describes the resource data model for the children without relation ships.
type TagTagFvRsSecInheritedFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagTagFvRsSecInheritedFvESgResourceModel() TagTagFvRsSecInheritedFvESgResourceModel {
	return TagTagFvRsSecInheritedFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagTagFvRsSecInheritedFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// TagAnnotationFvESgResourceModel describes the resource data model for the children without relation ships.
type TagAnnotationFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagAnnotationFvESgResourceModel() TagAnnotationFvESgResourceModel {
	return TagAnnotationFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagAnnotationFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

// TagTagFvESgResourceModel describes the resource data model for the children without relation ships.
type TagTagFvESgResourceModel struct {
	Key   types.String `tfsdk:"key"`
	Value types.String `tfsdk:"value"`
}

func getEmptyTagTagFvESgResourceModel() TagTagFvESgResourceModel {
	return TagTagFvESgResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

var TagTagFvESgType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"key":   types.StringType,
		"value": types.StringType,
	},
}

type FvESgIdentifier struct {
	Name types.String
}

var deprecatedFvRsConsType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"target_dn": basetypes.StringType{},
		"prio":      basetypes.StringType{},
	},
}

var deprecatedFvRsConsIfType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"target_dn": basetypes.StringType{},
		"prio":      basetypes.StringType{},
	},
}

var deprecatedFvRsProvType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"target_dn": basetypes.StringType{},
		"match_t":   basetypes.StringType{},
		"prio":      basetypes.StringType{},
	},
}

type FvESgResourceModelV1 struct {
	Annotation                          types.String `tfsdk:"annotation"`
	Descr                               types.String `tfsdk:"description"`
	Id                                  types.String `tfsdk:"id"`
	MatchT                              types.String `tfsdk:"match_t"`
	Name                                types.String `tfsdk:"name"`
	NameAlias                           types.String `tfsdk:"name_alias"`
	ParentDn                            types.String `tfsdk:"application_profile_dn"`
	PcEnfPref                           types.String `tfsdk:"pc_enf_pref"`
	PrefGrMemb                          types.String `tfsdk:"pref_gr_memb"`
	Ignored_relation_fv_rs_cust_qos_pol types.String `tfsdk:"relation_fv_rs_cust_qos_pol"`
	Ignored_relation_fv_rs_prot_by      types.Set    `tfsdk:"relation_fv_rs_prot_by"`
	FvRsSecInherited                    types.Set    `tfsdk:"relation_fv_rs_sec_inherited"`
	FvRsIntraEpg                        types.Set    `tfsdk:"relation_fv_rs_intra_epg"`
	FvRsScope                           types.String `tfsdk:"relation_fv_rs_scope"`
	FvRsCons                            types.Set    `tfsdk:"relation_fv_rs_cons"`
	FvRsConsIf                          types.Set    `tfsdk:"relation_fv_rs_cons_if"`
	FvRsProv                            types.Set    `tfsdk:"relation_fv_rs_prov"`
}

type FvRsConsFvESgResourceModelV1 struct {
	TargetDn types.String `tfsdk:"target_dn"`
	Prio     types.String `tfsdk:"prio"`
}

func getEmptyFvRsConsFvESgResourceModelV1() FvRsConsFvESgResourceModelV1 {
	return FvRsConsFvESgResourceModelV1{
		TargetDn: basetypes.NewStringNull(),
		Prio:     basetypes.NewStringNull(),
	}
}

type FvRsConsIfFvESgResourceModelV1 struct {
	TargetDn types.String `tfsdk:"target_dn"`
	Prio     types.String `tfsdk:"prio"`
}

func getEmptyFvRsConsIfFvESgResourceModelV1() FvRsConsIfFvESgResourceModelV1 {
	return FvRsConsIfFvESgResourceModelV1{
		TargetDn: basetypes.NewStringNull(),
		Prio:     basetypes.NewStringNull(),
	}
}

type FvRsProvFvESgResourceModelV1 struct {
	TargetDn types.String `tfsdk:"target_dn"`
	MatchT   types.String `tfsdk:"match_t"`
	Prio     types.String `tfsdk:"prio"`
}

func getEmptyFvRsProvFvESgResourceModelV1() FvRsProvFvESgResourceModelV1 {
	return FvRsProvFvESgResourceModelV1{
		TargetDn: basetypes.NewStringNull(),
		MatchT:   basetypes.NewStringNull(),
		Prio:     basetypes.NewStringNull(),
	}
}

func (r *FvESgResource) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader {
	return map[int64]resource.StateUpgrader{
		1: {
			PriorSchema: &schema.Schema{
				Attributes: map[string]schema.Attribute{
					"annotation": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: true,
					},
					"description": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: true,
					},
					"id": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: true,
					},
					"match_t": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: true,
					},
					"name": schema.StringAttribute{
						Required: true,
						Optional: false,
						Computed: false,
					},
					"name_alias": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: true,
					},
					"application_profile_dn": schema.StringAttribute{
						Required: true,
						Optional: false,
						Computed: false,
					},
					"pc_enf_pref": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: true,
					},
					"pref_gr_memb": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: true,
					},
					"relation_fv_rs_cust_qos_pol": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: false,
					},
					"relation_fv_rs_prot_by": schema.SetAttribute{
						Required:    false,
						Optional:    true,
						Computed:    false,
						ElementType: types.StringType,
					},
					"relation_fv_rs_sec_inherited": schema.SetAttribute{
						Required:    false,
						Optional:    true,
						Computed:    false,
						ElementType: types.StringType,
					},
					"relation_fv_rs_intra_epg": schema.SetAttribute{
						Required:    false,
						Optional:    true,
						Computed:    false,
						ElementType: types.StringType,
					},
					"relation_fv_rs_scope": schema.StringAttribute{
						Required: false,
						Optional: true,
						Computed: false,
					},
				},
				Blocks: map[string]schema.Block{
					"relation_fv_rs_cons": schema.SetNestedBlock{
						NestedObject: schema.NestedBlockObject{
							Attributes: map[string]schema.Attribute{
								"target_dn": schema.StringAttribute{
									Required: true,
									Optional: false,
									Computed: false,
								},
								"prio": schema.StringAttribute{
									Required: false,
									Optional: true,
									Computed: false,
								},
							},
						},
					},
					"relation_fv_rs_cons_if": schema.SetNestedBlock{
						NestedObject: schema.NestedBlockObject{
							Attributes: map[string]schema.Attribute{
								"target_dn": schema.StringAttribute{
									Required: true,
									Optional: false,
									Computed: false,
								},
								"prio": schema.StringAttribute{
									Required: false,
									Optional: true,
									Computed: false,
								},
							},
						},
					},
					"relation_fv_rs_prov": schema.SetNestedBlock{
						NestedObject: schema.NestedBlockObject{
							Attributes: map[string]schema.Attribute{
								"target_dn": schema.StringAttribute{
									Required: true,
									Optional: false,
									Computed: false,
								},
								"match_t": schema.StringAttribute{
									Required: false,
									Optional: true,
									Computed: false,
								},
								"prio": schema.StringAttribute{
									Required: false,
									Optional: true,
									Computed: false,
								},
							},
						},
					},
				},
			},
			StateUpgrader: func(ctx context.Context, req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) {
				var priorStateData FvESgResourceModelV1

				resp.Diagnostics.Append(req.State.Get(ctx, &priorStateData)...)

				if resp.Diagnostics.HasError() {
					return
				}

				upgradedStateData := FvESgResourceModel{
					Id:                                  priorStateData.Id,
					ParentDn:                            priorStateData.ParentDn,
					Annotation:                          priorStateData.Annotation,
					Descr:                               priorStateData.Descr,
					ExceptionTag:                        basetypes.NewStringNull(),
					MatchT:                              priorStateData.MatchT,
					Name:                                priorStateData.Name,
					NameAlias:                           priorStateData.NameAlias,
					PcEnfPref:                           priorStateData.PcEnfPref,
					PcTag:                               basetypes.NewStringNull(),
					PrefGrMemb:                          priorStateData.PrefGrMemb,
					Scope:                               basetypes.NewStringNull(),
					Shutdown:                            basetypes.NewStringNull(),
					DeprecatedMatchT:                    priorStateData.MatchT,
					DeprecatedParentDn:                  priorStateData.ParentDn,
					DeprecatedPcEnfPref:                 priorStateData.PcEnfPref,
					DeprecatedPrefGrMemb:                priorStateData.PrefGrMemb,
					Ignored_relation_fv_rs_cust_qos_pol: priorStateData.Ignored_relation_fv_rs_cust_qos_pol,
					Ignored_relation_fv_rs_prot_by:      priorStateData.Ignored_relation_fv_rs_prot_by,
					DeprecatedFvRsScope:                 priorStateData.FvRsScope,
				}

				FvRsConsList := make([]FvRsConsFvESgResourceModel, 0)
				var priorStateDataFvRsConsList []FvRsConsFvESgResourceModelV1
				priorStateData.FvRsCons.ElementsAs(ctx, &priorStateDataFvRsConsList, false)
				for _, priorStateDataFvRsCons := range priorStateDataFvRsConsList {
					FvRsCons := FvRsConsFvESgResourceModel{
						Annotation:   basetypes.NewStringNull(),
						Prio:         customTypes.FvRsConsPrioStringValue{StringValue: priorStateDataFvRsCons.Prio},
						TnVzBrCPName: priorStateDataFvRsCons.TargetDn,
						TagAnnotation: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
						TagTag: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
					}
					FvRsConsList = append(FvRsConsList, FvRsCons)
				}
				FvRsConsSet, _ := types.SetValueFrom(ctx, FvRsConsFvESgType, FvRsConsList)
				upgradedStateData.FvRsCons = FvRsConsSet

				FvRsConsIfList := make([]FvRsConsIfFvESgResourceModel, 0)
				var priorStateDataFvRsConsIfList []FvRsConsIfFvESgResourceModelV1
				priorStateData.FvRsConsIf.ElementsAs(ctx, &priorStateDataFvRsConsIfList, false)
				for _, priorStateDataFvRsConsIf := range priorStateDataFvRsConsIfList {
					FvRsConsIf := FvRsConsIfFvESgResourceModel{
						Annotation:   basetypes.NewStringNull(),
						Prio:         customTypes.FvRsConsIfPrioStringValue{StringValue: priorStateDataFvRsConsIf.Prio},
						TnVzCPIfName: priorStateDataFvRsConsIf.TargetDn,
						TagAnnotation: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
						TagTag: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
					}
					FvRsConsIfList = append(FvRsConsIfList, FvRsConsIf)
				}
				FvRsConsIfSet, _ := types.SetValueFrom(ctx, FvRsConsIfFvESgType, FvRsConsIfList)
				upgradedStateData.FvRsConsIf = FvRsConsIfSet

				FvRsIntraEpgList := make([]FvRsIntraEpgFvESgResourceModel, 0)
				var priorStateDataFvRsIntraEpgList []string
				priorStateData.FvRsIntraEpg.ElementsAs(ctx, &priorStateDataFvRsIntraEpgList, false)
				for _, priorStateDataFvRsIntraEpg := range priorStateDataFvRsIntraEpgList {
					FvRsIntraEpg := FvRsIntraEpgFvESgResourceModel{
						Annotation:   basetypes.NewStringNull(),
						TnVzBrCPName: basetypes.NewStringValue(GetMOName(priorStateDataFvRsIntraEpg)),
						TagAnnotation: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
						TagTag: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
					}
					FvRsIntraEpgList = append(FvRsIntraEpgList, FvRsIntraEpg)
				}
				FvRsIntraEpgSet, _ := types.SetValueFrom(ctx, FvRsIntraEpgFvESgType, FvRsIntraEpgList)
				upgradedStateData.FvRsIntraEpg = FvRsIntraEpgSet

				FvRsProvList := make([]FvRsProvFvESgResourceModel, 0)
				var priorStateDataFvRsProvList []FvRsProvFvESgResourceModelV1
				priorStateData.FvRsProv.ElementsAs(ctx, &priorStateDataFvRsProvList, false)
				for _, priorStateDataFvRsProv := range priorStateDataFvRsProvList {
					FvRsProv := FvRsProvFvESgResourceModel{
						Annotation:   basetypes.NewStringNull(),
						MatchT:       priorStateDataFvRsProv.MatchT,
						Prio:         customTypes.FvRsProvPrioStringValue{StringValue: priorStateDataFvRsProv.Prio},
						TnVzBrCPName: priorStateDataFvRsProv.TargetDn,
						TagAnnotation: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
						TagTag: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
					}
					FvRsProvList = append(FvRsProvList, FvRsProv)
				}
				FvRsProvSet, _ := types.SetValueFrom(ctx, FvRsProvFvESgType, FvRsProvList)
				upgradedStateData.FvRsProv = FvRsProvSet

				FvRsScopeObject := FvRsScopeFvESgResourceModel{
					Annotation:  basetypes.NewStringNull(),
					TnFvCtxName: basetypes.NewStringValue(GetMOName(priorStateData.FvRsScope.ValueString())),
					TagAnnotation: basetypes.NewSetNull(types.ObjectType{
						AttrTypes: map[string]attr.Type{
							"key":   types.StringType,
							"value": types.StringType,
						},
					}),
					TagTag: basetypes.NewSetNull(types.ObjectType{
						AttrTypes: map[string]attr.Type{
							"key":   types.StringType,
							"value": types.StringType,
						},
					}),
				}
				fvRsScopeObject, _ := types.ObjectValueFrom(ctx, FvRsScopeFvESgType, FvRsScopeObject)
				upgradedStateData.FvRsScope = fvRsScopeObject

				FvRsSecInheritedList := make([]FvRsSecInheritedFvESgResourceModel, 0)
				var priorStateDataFvRsSecInheritedList []string
				priorStateData.FvRsSecInherited.ElementsAs(ctx, &priorStateDataFvRsSecInheritedList, false)
				for _, priorStateDataFvRsSecInherited := range priorStateDataFvRsSecInheritedList {
					FvRsSecInherited := FvRsSecInheritedFvESgResourceModel{
						Annotation: basetypes.NewStringNull(),
						TDn:        basetypes.NewStringValue(priorStateDataFvRsSecInherited),
						TagAnnotation: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
						TagTag: basetypes.NewSetNull(types.ObjectType{
							AttrTypes: map[string]attr.Type{
								"key":   types.StringType,
								"value": types.StringType,
							},
						}),
					}
					FvRsSecInheritedList = append(FvRsSecInheritedList, FvRsSecInherited)
				}
				FvRsSecInheritedSet, _ := types.SetValueFrom(ctx, FvRsSecInheritedFvESgType, FvRsSecInheritedList)
				upgradedStateData.FvRsSecInherited = FvRsSecInheritedSet

				upgradedStateData.TagAnnotation = types.SetNull(
					types.ObjectType{
						AttrTypes: map[string]attr.Type{
							"key":   basetypes.StringType{},
							"value": basetypes.StringType{},
						},
					},
				)

				upgradedStateData.TagTag = types.SetNull(
					types.ObjectType{
						AttrTypes: map[string]attr.Type{
							"key":   basetypes.StringType{},
							"value": basetypes.StringType{},
						},
					},
				)

				var deprecatedFvRsSecInheritedList []string
				priorStateData.FvRsSecInherited.ElementsAs(ctx, &deprecatedFvRsSecInheritedList, false)
				DeprecatedFvRsSecInheritedSet, _ := types.SetValueFrom(ctx, types.StringType, deprecatedFvRsSecInheritedList)
				upgradedStateData.DeprecatedFvRsSecInherited = DeprecatedFvRsSecInheritedSet

				var deprecatedFvRsIntraEpgList []string
				priorStateData.FvRsIntraEpg.ElementsAs(ctx, &deprecatedFvRsIntraEpgList, false)
				DeprecatedFvRsIntraEpgSet, _ := types.SetValueFrom(ctx, types.StringType, deprecatedFvRsIntraEpgList)
				upgradedStateData.DeprecatedFvRsIntraEpg = DeprecatedFvRsIntraEpgSet

				var FvRsConsV1List []FvRsConsFvESgResourceModelV1
				priorStateData.FvRsCons.ElementsAs(ctx, &FvRsConsV1List, false)
				FvRsConsV1Set, _ := types.SetValueFrom(ctx, deprecatedFvRsConsType, FvRsConsV1List)
				upgradedStateData.DeprecatedFvRsCons = FvRsConsV1Set

				var FvRsConsIfV1List []FvRsConsIfFvESgResourceModelV1
				priorStateData.FvRsConsIf.ElementsAs(ctx, &FvRsConsIfV1List, false)
				FvRsConsIfV1Set, _ := types.SetValueFrom(ctx, deprecatedFvRsConsIfType, FvRsConsIfV1List)
				upgradedStateData.DeprecatedFvRsConsIf = FvRsConsIfV1Set

				var FvRsProvV1List []FvRsProvFvESgResourceModelV1
				priorStateData.FvRsProv.ElementsAs(ctx, &FvRsProvV1List, false)
				FvRsProvV1Set, _ := types.SetValueFrom(ctx, deprecatedFvRsProvType, FvRsProvV1List)
				upgradedStateData.DeprecatedFvRsProv = FvRsProvV1Set

				resp.Diagnostics.Append(resp.State.Set(ctx, upgradedStateData)...)
			},
		},
	}
}

func setFvESgLegacyAttributes(ctx context.Context, diags *diag.Diagnostics, data, staticData *FvESgResourceModel, classReadInfo []interface{}) {
	data.DeprecatedParentDn = data.ParentDn
	if !staticData.Ignored_relation_fv_rs_cust_qos_pol.IsUnknown() {
		data.Ignored_relation_fv_rs_cust_qos_pol = staticData.Ignored_relation_fv_rs_cust_qos_pol
	}
	if !staticData.Ignored_relation_fv_rs_prot_by.IsUnknown() && !staticData.Ignored_relation_fv_rs_prot_by.IsNull() {
		data.Ignored_relation_fv_rs_prot_by = staticData.Ignored_relation_fv_rs_prot_by
	} else {
		Ignored_relation_fv_rs_prot_bySet, _ := types.SetValueFrom(ctx, types.StringType, []string{})
		data.Ignored_relation_fv_rs_prot_by = Ignored_relation_fv_rs_prot_bySet
	}
	attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{})
	for attributeName, attributeValue := range attributes {
		if attributeName == "matchT" {
			data.DeprecatedMatchT = basetypes.NewStringValue(attributeValue.(string))
		}
		if attributeName == "pcEnfPref" {
			data.DeprecatedPcEnfPref = basetypes.NewStringValue(attributeValue.(string))
		}
		if attributeName == "prefGrMemb" {
			data.DeprecatedPrefGrMemb = basetypes.NewStringValue(attributeValue.(string))
		}
	}
	DeprecatedFvRsConsFvESgList := make([]FvRsConsFvESgResourceModelV1, 0)
	DeprecatedFvRsConsIfFvESgList := make([]FvRsConsIfFvESgResourceModelV1, 0)
	DeprecatedFvRsIntraEpgFvESgList := make([]string, 0)
	DeprecatedFvRsProvFvESgList := make([]FvRsProvFvESgResourceModelV1, 0)
	data.DeprecatedFvRsScope = basetypes.NewStringNull()
	DeprecatedFvRsSecInheritedFvESgList := make([]string, 0)

	_, ok := classReadInfo[0].(map[string]interface{})["children"]
	if ok {
		children := classReadInfo[0].(map[string]interface{})["children"].([]interface{})
		for _, child := range children {
			for childClassName, childClassDetails := range child.(map[string]interface{}) {
				childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{})
				if childClassName == "fvRsCons" {
					DeprecatedFvRsConsFvESg := getEmptyFvRsConsFvESgResourceModelV1()
					for childAttributeName, childAttributeValue := range childAttributes {
						if childAttributeName == "prio" {
							DeprecatedFvRsConsFvESg.Prio = basetypes.NewStringValue(childAttributeValue.(string))
						}
						if childAttributeName == "tDn" {
							DeprecatedFvRsConsFvESg.TargetDn = basetypes.NewStringValue(childAttributeValue.(string))
						}
					}
					DeprecatedFvRsConsFvESgList = append(DeprecatedFvRsConsFvESgList, DeprecatedFvRsConsFvESg)
				}
				if childClassName == "fvRsConsIf" {
					DeprecatedFvRsConsIfFvESg := getEmptyFvRsConsIfFvESgResourceModelV1()
					for childAttributeName, childAttributeValue := range childAttributes {
						if childAttributeName == "prio" {
							DeprecatedFvRsConsIfFvESg.Prio = basetypes.NewStringValue(childAttributeValue.(string))
						}
						if childAttributeName == "tDn" {
							DeprecatedFvRsConsIfFvESg.TargetDn = basetypes.NewStringValue(childAttributeValue.(string))
						}
					}
					DeprecatedFvRsConsIfFvESgList = append(DeprecatedFvRsConsIfFvESgList, DeprecatedFvRsConsIfFvESg)
				}
				if childClassName == "fvRsIntraEpg" {
					for childAttributeName, childAttributeValue := range childAttributes {
						if childAttributeName == "tDn" && childAttributeValue != "" && !ContainsString(DeprecatedFvRsIntraEpgFvESgList, childAttributeValue.(string)) {
							DeprecatedFvRsIntraEpgFvESgList = append(DeprecatedFvRsIntraEpgFvESgList, childAttributeValue.(string))
						}
					}
				}
				if childClassName == "fvRsProv" {
					DeprecatedFvRsProvFvESg := getEmptyFvRsProvFvESgResourceModelV1()
					for childAttributeName, childAttributeValue := range childAttributes {
						if childAttributeName == "matchT" {
							DeprecatedFvRsProvFvESg.MatchT = basetypes.NewStringValue(childAttributeValue.(string))
						}
						if childAttributeName == "prio" {
							DeprecatedFvRsProvFvESg.Prio = basetypes.NewStringValue(childAttributeValue.(string))
						}
						if childAttributeName == "tDn" {
							DeprecatedFvRsProvFvESg.TargetDn = basetypes.NewStringValue(childAttributeValue.(string))
						}
					}
					DeprecatedFvRsProvFvESgList = append(DeprecatedFvRsProvFvESgList, DeprecatedFvRsProvFvESg)
				}
				if childClassName == "fvRsScope" {
					for childAttributeName, childAttributeValue := range childAttributes {
						if childAttributeName == "tDn" {
							data.DeprecatedFvRsScope = basetypes.NewStringValue(childAttributeValue.(string))
						}
					}
				}
				if childClassName == "fvRsSecInherited" {
					for childAttributeName, childAttributeValue := range childAttributes {
						if childAttributeName == "tDn" && childAttributeValue != "" && !ContainsString(DeprecatedFvRsSecInheritedFvESgList, childAttributeValue.(string)) {
							DeprecatedFvRsSecInheritedFvESgList = append(DeprecatedFvRsSecInheritedFvESgList, childAttributeValue.(string))
						}
					}
				}
			}
		}
		fvRsConsSet, _ := types.SetValueFrom(ctx, data.DeprecatedFvRsCons.ElementType(ctx), DeprecatedFvRsConsFvESgList)
		data.DeprecatedFvRsCons = fvRsConsSet
		fvRsConsIfSet, _ := types.SetValueFrom(ctx, data.DeprecatedFvRsConsIf.ElementType(ctx), DeprecatedFvRsConsIfFvESgList)
		data.DeprecatedFvRsConsIf = fvRsConsIfSet
		fvRsIntraEpgSet, _ := types.SetValueFrom(ctx, data.DeprecatedFvRsIntraEpg.ElementType(ctx), DeprecatedFvRsIntraEpgFvESgList)
		data.DeprecatedFvRsIntraEpg = fvRsIntraEpgSet
		fvRsProvSet, _ := types.SetValueFrom(ctx, data.DeprecatedFvRsProv.ElementType(ctx), DeprecatedFvRsProvFvESgList)
		data.DeprecatedFvRsProv = fvRsProvSet
		fvRsSecInheritedSet, _ := types.SetValueFrom(ctx, data.DeprecatedFvRsSecInherited.ElementType(ctx), DeprecatedFvRsSecInheritedFvESgList)
		data.DeprecatedFvRsSecInherited = fvRsSecInheritedSet
	}
}

func (r *FvESgResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
	if !req.Plan.Raw.IsNull() {
		var planData, stateData, configData *FvESgResourceModel
		resp.Diagnostics.Append(req.Plan.Get(ctx, &planData)...)
		resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...)
		resp.Diagnostics.Append(req.Config.Get(ctx, &configData)...)

		if resp.Diagnostics.HasError() {
			return
		}

		if (planData.Id.IsUnknown() || planData.Id.IsNull()) && !planData.ParentDn.IsUnknown() && !planData.Name.IsUnknown() {
			setFvESgId(ctx, planData)
		}

		if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() {
			CheckDn(ctx, &resp.Diagnostics, r.client, "fvESg", planData.Id.ValueString())
			if resp.Diagnostics.HasError() {
				return
			}
		}
		if !configData.FvRsScope.IsNull() && stateData != nil {
			if IsEmptySingleNestedAttribute(configData.FvRsScope.Attributes()) {
				FvRsScopeObject, _ := types.ObjectValueFrom(ctx, FvRsScopeFvESgType, getEmptyFvRsScopeFvESgResourceModel())
				planData.FvRsScope = FvRsScopeObject
			}
		}

		if !configData.DeprecatedMatchT.IsNull() {
			planData.MatchT = configData.DeprecatedMatchT
		}

		if !configData.DeprecatedParentDn.IsNull() {
			planData.ParentDn = configData.DeprecatedParentDn
		}

		if !configData.DeprecatedPcEnfPref.IsNull() {
			planData.PcEnfPref = configData.DeprecatedPcEnfPref
		}

		if !configData.DeprecatedPrefGrMemb.IsNull() {
			planData.PrefGrMemb = configData.DeprecatedPrefGrMemb
		}

		if !configData.DeprecatedFvRsSecInherited.IsNull() {
			FvRsSecInheritedList := make([]FvRsSecInheritedFvESgResourceModel, 0)
			var attributeValues []basetypes.StringValue
			var newAttributeValues []FvRsSecInheritedFvESgResourceModel
			planData.DeprecatedFvRsSecInherited.ElementsAs(ctx, &attributeValues, false)
			if stateData != nil {
				stateData.FvRsSecInherited.ElementsAs(ctx, &newAttributeValues, false)
			}
			for _, attributeValue := range attributeValues {
				FvRsSecInheritedValue := FvRsSecInheritedFvESgResourceModel{}
				foundAttributeValue := false
				for _, newAttributeValue := range newAttributeValues {
					if newAttributeValue.TDn.ValueString() == attributeValue.ValueString() {
						FvRsSecInheritedValue = newAttributeValue
						foundAttributeValue = true
						break
					}
				}
				tDnValue := basetypes.NewStringUnknown()
				if !attributeValue.IsUnknown() {
					tDnValue = basetypes.NewStringValue(attributeValue.ValueString())
				}
				FvRsSecInherited := FvRsSecInheritedFvESgResourceModel{
					TDn: tDnValue,
				}

				if foundAttributeValue {
					FvRsSecInherited.Annotation = FvRsSecInheritedValue.Annotation
				} else {
					FvRsSecInherited.Annotation = planData.Annotation
				}
				tagAnnotationFvRsSecInheritedFvESgValue, _ := types.SetValueFrom(ctx, TagAnnotationFvRsSecInheritedFvESgType, make([]TagAnnotationFvRsSecInheritedFvESgResourceModel, 0))
				FvRsSecInherited.TagAnnotation = tagAnnotationFvRsSecInheritedFvESgValue
				tagTagFvRsSecInheritedFvESgValue, _ := types.SetValueFrom(ctx, TagTagFvRsSecInheritedFvESgType, make([]TagTagFvRsSecInheritedFvESgResourceModel, 0))
				FvRsSecInherited.TagTag = tagTagFvRsSecInheritedFvESgValue
				FvRsSecInheritedList = append(FvRsSecInheritedList, FvRsSecInherited)
			}
			FvRsSecInheritedSet, _ := types.SetValueFrom(ctx, FvRsSecInheritedFvESgType, FvRsSecInheritedList)
			planData.FvRsSecInherited = FvRsSecInheritedSet
		}

		if !configData.DeprecatedFvRsIntraEpg.IsNull() {
			FvRsIntraEpgList := make([]FvRsIntraEpgFvESgResourceModel, 0)
			var attributeValues []basetypes.StringValue
			var newAttributeValues []FvRsIntraEpgFvESgResourceModel
			planData.DeprecatedFvRsIntraEpg.ElementsAs(ctx, &attributeValues, false)
			if stateData != nil {
				stateData.FvRsIntraEpg.ElementsAs(ctx, &newAttributeValues, false)
			}
			for _, attributeValue := range attributeValues {
				FvRsIntraEpgValue := FvRsIntraEpgFvESgResourceModel{}
				foundAttributeValue := false
				for _, newAttributeValue := range newAttributeValues {
					if newAttributeValue.TnVzBrCPName.ValueString() == GetMOName(attributeValue.ValueString()) {
						FvRsIntraEpgValue = newAttributeValue
						foundAttributeValue = true
						break
					}
				}
				tnVzBrCPNameValue := basetypes.NewStringUnknown()
				if !attributeValue.IsUnknown() {
					tnVzBrCPNameValue = basetypes.NewStringValue(GetMOName(attributeValue.ValueString()))
				}
				FvRsIntraEpg := FvRsIntraEpgFvESgResourceModel{
					TnVzBrCPName: tnVzBrCPNameValue,
				}

				if foundAttributeValue {
					FvRsIntraEpg.Annotation = FvRsIntraEpgValue.Annotation
				} else {
					FvRsIntraEpg.Annotation = planData.Annotation
				}
				tagAnnotationFvRsIntraEpgFvESgValue, _ := types.SetValueFrom(ctx, TagAnnotationFvRsIntraEpgFvESgType, make([]TagAnnotationFvRsIntraEpgFvESgResourceModel, 0))
				FvRsIntraEpg.TagAnnotation = tagAnnotationFvRsIntraEpgFvESgValue
				tagTagFvRsIntraEpgFvESgValue, _ := types.SetValueFrom(ctx, TagTagFvRsIntraEpgFvESgType, make([]TagTagFvRsIntraEpgFvESgResourceModel, 0))
				FvRsIntraEpg.TagTag = tagTagFvRsIntraEpgFvESgValue
				FvRsIntraEpgList = append(FvRsIntraEpgList, FvRsIntraEpg)
			}
			FvRsIntraEpgSet, _ := types.SetValueFrom(ctx, FvRsIntraEpgFvESgType, FvRsIntraEpgList)
			planData.FvRsIntraEpg = FvRsIntraEpgSet
		}

		if !configData.DeprecatedFvRsScope.IsNull() {
			var newAttributeValues FvRsScopeFvESgResourceModel
			tagAnnotationFvRsScopeFvESgValue, _ := types.SetValueFrom(ctx, TagAnnotationFvRsScopeFvESgType, make([]TagAnnotationFvRsScopeFvESgResourceModel, 0))
			tagTagFvRsScopeFvESgValue, _ := types.SetValueFrom(ctx, TagTagFvRsScopeFvESgType, make([]TagTagFvRsScopeFvESgResourceModel, 0))
			annotationValue := planData.Annotation
			if stateData != nil && !IsEmptySingleNestedAttribute(stateData.FvRsScope.Attributes()) {
				stateData.FvRsScope.As(ctx, &newAttributeValues, basetypes.ObjectAsOptions{})
				annotationValue = newAttributeValues.Annotation
				tagAnnotationFvRsScopeFvESgValue = newAttributeValues.TagAnnotation
				tagTagFvRsScopeFvESgValue = newAttributeValues.TagTag
			}
			tnFvCtxNameValue := basetypes.NewStringUnknown()
			if !configData.DeprecatedFvRsScope.IsUnknown() {
				tnFvCtxNameValue = basetypes.NewStringValue(GetMOName(configData.DeprecatedFvRsScope.ValueString()))
			}
			FvRsScope := FvRsScopeFvESgResourceModel{
				Annotation:    annotationValue,
				TnFvCtxName:   tnFvCtxNameValue,
				TagAnnotation: tagAnnotationFvRsScopeFvESgValue,
				TagTag:        tagTagFvRsScopeFvESgValue,
			}
			FvRsScopeObject, _ := types.ObjectValueFrom(ctx, FvRsScopeFvESgType, FvRsScope)
			planData.FvRsScope = FvRsScopeObject
		}

		if !configData.DeprecatedFvRsCons.IsNull() {
			FvRsConsList := make([]FvRsConsFvESgResourceModel, 0)
			var attributeValues []FvRsConsFvESgResourceModelV1
			var newAttributeValues []FvRsConsFvESgResourceModel
			if stateData != nil {
				stateData.FvRsCons.ElementsAs(ctx, &newAttributeValues, false)
			}
			planData.DeprecatedFvRsCons.ElementsAs(ctx, &attributeValues, false)
			for _, attributeValue := range attributeValues {
				plannedFvRsCons := FvRsConsFvESgResourceModel{}
				foundAttributeValue := false
				for _, newAttributeValue := range newAttributeValues {
					if newAttributeValue.TnVzBrCPName.ValueString() == GetMOName(attributeValue.TargetDn.ValueString()) {
						plannedFvRsCons = newAttributeValue
						foundAttributeValue = true
						break
					}
				}
				tnVzBrCPNameValue := basetypes.NewStringUnknown()
				if !attributeValue.TargetDn.IsUnknown() {
					tnVzBrCPNameValue = basetypes.NewStringValue(GetMOName(attributeValue.TargetDn.ValueString()))
				}
				FvRsCons := FvRsConsFvESgResourceModel{
					Annotation:   planData.Annotation,
					TnVzBrCPName: tnVzBrCPNameValue,
				}
				if !attributeValue.Prio.IsNull() {
					FvRsCons.Prio = customTypes.FvRsConsPrioStringValue{StringValue: attributeValue.Prio}
				} else {
					FvRsCons.Prio = customTypes.FvRsConsPrioStringValue{StringValue: basetypes.NewStringUnknown()}
				}
				if foundAttributeValue {
					FvRsCons.TnVzBrCPName = plannedFvRsCons.TnVzBrCPName
					FvRsCons.Annotation = plannedFvRsCons.Annotation
				}
				tagAnnotationFvRsConsFvESgValue, _ := types.SetValueFrom(ctx, TagAnnotationFvRsConsFvESgType, make([]TagAnnotationFvRsConsFvESgResourceModel, 0))
				FvRsCons.TagAnnotation = tagAnnotationFvRsConsFvESgValue
				tagTagFvRsConsFvESgValue, _ := types.SetValueFrom(ctx, TagTagFvRsConsFvESgType, make([]TagTagFvRsConsFvESgResourceModel, 0))
				FvRsCons.TagTag = tagTagFvRsConsFvESgValue
				FvRsConsList = append(FvRsConsList, FvRsCons)
			}
			FvRsConsSet, _ := types.SetValueFrom(ctx, FvRsConsFvESgType, FvRsConsList)
			planData.FvRsCons = FvRsConsSet
		} else if !configData.FvRsCons.IsNull() && stateData == nil {
			setUnknownDeprecatedFvRsConsFvESgResourceModelToPlan(ctx, planData)
		}

		if !configData.DeprecatedFvRsConsIf.IsNull() {
			FvRsConsIfList := make([]FvRsConsIfFvESgResourceModel, 0)
			var attributeValues []FvRsConsIfFvESgResourceModelV1
			var newAttributeValues []FvRsConsIfFvESgResourceModel
			if stateData != nil {
				stateData.FvRsConsIf.ElementsAs(ctx, &newAttributeValues, false)
			}
			planData.DeprecatedFvRsConsIf.ElementsAs(ctx, &attributeValues, false)
			for _, attributeValue := range attributeValues {
				plannedFvRsConsIf := FvRsConsIfFvESgResourceModel{}
				foundAttributeValue := false
				for _, newAttributeValue := range newAttributeValues {
					if newAttributeValue.TnVzCPIfName.ValueString() == GetMOName(attributeValue.TargetDn.ValueString()) {
						plannedFvRsConsIf = newAttributeValue
						foundAttributeValue = true
						break
					}
				}
				tnVzCPIfNameValue := basetypes.NewStringUnknown()
				if !attributeValue.TargetDn.IsUnknown() {
					tnVzCPIfNameValue = basetypes.NewStringValue(GetMOName(attributeValue.TargetDn.ValueString()))
				}
				FvRsConsIf := FvRsConsIfFvESgResourceModel{
					Annotation:   planData.Annotation,
					TnVzCPIfName: tnVzCPIfNameValue,
				}
				if !attributeValue.Prio.IsNull() {
					FvRsConsIf.Prio = customTypes.FvRsConsIfPrioStringValue{StringValue: attributeValue.Prio}
				} else {
					FvRsConsIf.Prio = customTypes.FvRsConsIfPrioStringValue{StringValue: basetypes.NewStringUnknown()}
				}
				if foundAttributeValue {
					FvRsConsIf.TnVzCPIfName = plannedFvRsConsIf.TnVzCPIfName
					FvRsConsIf.Annotation = plannedFvRsConsIf.Annotation
				}
				tagAnnotationFvRsConsIfFvESgValue, _ := types.SetValueFrom(ctx, TagAnnotationFvRsConsIfFvESgType, make([]TagAnnotationFvRsConsIfFvESgResourceModel, 0))
				FvRsConsIf.TagAnnotation = tagAnnotationFvRsConsIfFvESgValue
				tagTagFvRsConsIfFvESgValue, _ := types.SetValueFrom(ctx, TagTagFvRsConsIfFvESgType, make([]TagTagFvRsConsIfFvESgResourceModel, 0))
				FvRsConsIf.TagTag = tagTagFvRsConsIfFvESgValue
				FvRsConsIfList = append(FvRsConsIfList, FvRsConsIf)
			}
			FvRsConsIfSet, _ := types.SetValueFrom(ctx, FvRsConsIfFvESgType, FvRsConsIfList)
			planData.FvRsConsIf = FvRsConsIfSet
		} else if !configData.FvRsConsIf.IsNull() && stateData == nil {
			setUnknownDeprecatedFvRsConsIfFvESgResourceModelToPlan(ctx, planData)
		}

		if !configData.DeprecatedFvRsProv.IsNull() {
			FvRsProvList := make([]FvRsProvFvESgResourceModel, 0)
			var attributeValues []FvRsProvFvESgResourceModelV1
			var newAttributeValues []FvRsProvFvESgResourceModel
			if stateData != nil {
				stateData.FvRsProv.ElementsAs(ctx, &newAttributeValues, false)
			}
			planData.DeprecatedFvRsProv.ElementsAs(ctx, &attributeValues, false)
			for _, attributeValue := range attributeValues {
				plannedFvRsProv := FvRsProvFvESgResourceModel{}
				foundAttributeValue := false
				for _, newAttributeValue := range newAttributeValues {
					if newAttributeValue.TnVzBrCPName.ValueString() == GetMOName(attributeValue.TargetDn.ValueString()) {
						plannedFvRsProv = newAttributeValue
						foundAttributeValue = true
						break
					}
				}
				tnVzBrCPNameValue := basetypes.NewStringUnknown()
				if !attributeValue.TargetDn.IsUnknown() {
					tnVzBrCPNameValue = basetypes.NewStringValue(GetMOName(attributeValue.TargetDn.ValueString()))
				}
				FvRsProv := FvRsProvFvESgResourceModel{
					Annotation:   planData.Annotation,
					TnVzBrCPName: tnVzBrCPNameValue,
				}
				if !attributeValue.MatchT.IsNull() {
					FvRsProv.MatchT = attributeValue.MatchT
				} else {
					FvRsProv.MatchT = basetypes.NewStringUnknown()
				}
				if !attributeValue.Prio.IsNull() {
					FvRsProv.Prio = customTypes.FvRsProvPrioStringValue{StringValue: attributeValue.Prio}
				} else {
					FvRsProv.Prio = customTypes.FvRsProvPrioStringValue{StringValue: basetypes.NewStringUnknown()}
				}
				if foundAttributeValue {
					FvRsProv.TnVzBrCPName = plannedFvRsProv.TnVzBrCPName
					FvRsProv.Annotation = plannedFvRsProv.Annotation
				}
				tagAnnotationFvRsProvFvESgValue, _ := types.SetValueFrom(ctx, TagAnnotationFvRsProvFvESgType, make([]TagAnnotationFvRsProvFvESgResourceModel, 0))
				FvRsProv.TagAnnotation = tagAnnotationFvRsProvFvESgValue
				tagTagFvRsProvFvESgValue, _ := types.SetValueFrom(ctx, TagTagFvRsProvFvESgType, make([]TagTagFvRsProvFvESgResourceModel, 0))
				FvRsProv.TagTag = tagTagFvRsProvFvESgValue
				FvRsProvList = append(FvRsProvList, FvRsProv)
			}
			FvRsProvSet, _ := types.SetValueFrom(ctx, FvRsProvFvESgType, FvRsProvList)
			planData.FvRsProv = FvRsProvSet
		} else if !configData.FvRsProv.IsNull() && stateData == nil {
			setUnknownDeprecatedFvRsProvFvESgResourceModelToPlan(ctx, planData)
		}

		// Workaround to compare the state with plan to avoid plan changes with only known after apply
		if stateData != nil {
			avoidFvESgPlanChangeForKnownAfterApplyOnly(ctx, planData, stateData, configData)
		}

		resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...)
	}
}
func setUnknownDeprecatedFvRsConsFvESgResourceModelToPlan(ctx context.Context, planData *FvESgResourceModel) {
	var attributeValues []FvRsConsFvESgResourceModel
	var legacyAttributeValues []FvRsConsFvESgResourceModelV1
	planData.FvRsCons.ElementsAs(ctx, &attributeValues, false)
	for i := 0; i < len(attributeValues); i++ {
		legacyAttributeValues = append(legacyAttributeValues, FvRsConsFvESgResourceModelV1{
			TargetDn: basetypes.NewStringUnknown(),
			Prio:     basetypes.NewStringUnknown(),
		})
	}
	DeprecatedFvRsConsSet, _ := types.SetValueFrom(ctx, deprecatedFvRsConsType, legacyAttributeValues)
	planData.DeprecatedFvRsCons = DeprecatedFvRsConsSet
}
func setUnknownDeprecatedFvRsConsIfFvESgResourceModelToPlan(ctx context.Context, planData *FvESgResourceModel) {
	var attributeValues []FvRsConsIfFvESgResourceModel
	var legacyAttributeValues []FvRsConsIfFvESgResourceModelV1
	planData.FvRsConsIf.ElementsAs(ctx, &attributeValues, false)
	for i := 0; i < len(attributeValues); i++ {
		legacyAttributeValues = append(legacyAttributeValues, FvRsConsIfFvESgResourceModelV1{
			TargetDn: basetypes.NewStringUnknown(),
			Prio:     basetypes.NewStringUnknown(),
		})
	}
	DeprecatedFvRsConsIfSet, _ := types.SetValueFrom(ctx, deprecatedFvRsConsIfType, legacyAttributeValues)
	planData.DeprecatedFvRsConsIf = DeprecatedFvRsConsIfSet
}
func setUnknownDeprecatedFvRsProvFvESgResourceModelToPlan(ctx context.Context, planData *FvESgResourceModel) {
	var attributeValues []FvRsProvFvESgResourceModel
	var legacyAttributeValues []FvRsProvFvESgResourceModelV1
	planData.FvRsProv.ElementsAs(ctx, &attributeValues, false)
	for i := 0; i < len(attributeValues); i++ {
		legacyAttributeValues = append(legacyAttributeValues, FvRsProvFvESgResourceModelV1{
			TargetDn: basetypes.NewStringUnknown(),
			MatchT:   basetypes.NewStringUnknown(),
			Prio:     basetypes.NewStringUnknown(),
		})
	}
	DeprecatedFvRsProvSet, _ := types.SetValueFrom(ctx, deprecatedFvRsProvType, legacyAttributeValues)
	planData.DeprecatedFvRsProv = DeprecatedFvRsProvSet
}

func avoidFvESgPlanChangeForKnownAfterApplyOnly(ctx context.Context, planData, stateData, configData *FvESgResourceModel) {
	// Set read-only and deprecated attributes in planData from stateData
	planData.PcTag = stateData.PcTag
	planData.Scope = stateData.Scope
	if configData.DeprecatedMatchT.IsNull() {
		planData.DeprecatedMatchT = stateData.DeprecatedMatchT
	}
	if configData.DeprecatedParentDn.IsNull() {
		planData.DeprecatedParentDn = stateData.DeprecatedParentDn
	}
	if configData.DeprecatedPcEnfPref.IsNull() {
		planData.DeprecatedPcEnfPref = stateData.DeprecatedPcEnfPref
	}
	if configData.DeprecatedPrefGrMemb.IsNull() {
		planData.DeprecatedPrefGrMemb = stateData.DeprecatedPrefGrMemb
	}
	if configData.DeprecatedFvRsSecInherited.IsNull() {
		planData.DeprecatedFvRsSecInherited = stateData.DeprecatedFvRsSecInherited
	}
	if configData.DeprecatedFvRsIntraEpg.IsNull() {
		planData.DeprecatedFvRsIntraEpg = stateData.DeprecatedFvRsIntraEpg
	}
	if configData.DeprecatedFvRsScope.IsNull() {
		planData.DeprecatedFvRsScope = stateData.DeprecatedFvRsScope
	}
	if configData.DeprecatedFvRsCons.IsNull() {
		planData.DeprecatedFvRsCons = stateData.DeprecatedFvRsCons
	}
	if configData.DeprecatedFvRsConsIf.IsNull() {
		planData.DeprecatedFvRsConsIf = stateData.DeprecatedFvRsConsIf
	}
	if configData.DeprecatedFvRsProv.IsNull() {
		planData.DeprecatedFvRsProv = stateData.DeprecatedFvRsProv
	}

	// Compare the string representation of the planData and stateData because structs cannot be compared directly
	if fmt.Sprintf("%s", planData) != fmt.Sprintf("%s", stateData) {
		planData.PcTag = basetypes.NewStringUnknown()
		planData.Scope = basetypes.NewStringUnknown()
		if configData.DeprecatedMatchT.IsNull() {
			planData.DeprecatedMatchT = basetypes.NewStringUnknown()
		}
		if configData.DeprecatedParentDn.IsNull() {
			planData.DeprecatedParentDn = basetypes.NewStringUnknown()
		}
		if configData.DeprecatedPcEnfPref.IsNull() {
			planData.DeprecatedPcEnfPref = basetypes.NewStringUnknown()
		}
		if configData.DeprecatedPrefGrMemb.IsNull() {
			planData.DeprecatedPrefGrMemb = basetypes.NewStringUnknown()
		}
		if configData.DeprecatedFvRsSecInherited.IsNull() {
			planData.DeprecatedFvRsSecInherited = basetypes.NewSetUnknown(basetypes.StringType{})
		}
		if configData.DeprecatedFvRsIntraEpg.IsNull() {
			planData.DeprecatedFvRsIntraEpg = basetypes.NewSetUnknown(basetypes.StringType{})
		}
		if configData.DeprecatedFvRsScope.IsNull() {
			planData.DeprecatedFvRsScope = basetypes.NewStringUnknown()
		}
		if configData.DeprecatedFvRsCons.IsNull() {
			setUnknownDeprecatedFvRsConsFvESgResourceModelToPlan(ctx, planData)
		}
		if configData.DeprecatedFvRsConsIf.IsNull() {
			setUnknownDeprecatedFvRsConsIfFvESgResourceModelToPlan(ctx, planData)
		}
		if configData.DeprecatedFvRsProv.IsNull() {
			setUnknownDeprecatedFvRsProvFvESgResourceModelToPlan(ctx, planData)
		}
	}
}

func (r *FvESgResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
	tflog.Debug(ctx, "Start metadata of resource: aci_endpoint_security_group")
	resp.TypeName = req.ProviderTypeName + "_endpoint_security_group"
	tflog.Debug(ctx, "End metadata of resource: aci_endpoint_security_group")
}

func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
	tflog.Debug(ctx, "Start schema of resource: aci_endpoint_security_group")
	resp.Schema = schema.Schema{
		// This description is used by the documentation generator and the language server.
		MarkdownDescription: "The endpoint_security_group resource for the 'fvESg' class",
		Version:             2,

		Attributes: map[string]schema.Attribute{
			// Deprecated attributes
			"match_t": schema.StringAttribute{
				Optional:           true,
				Computed:           true,
				DeprecationMessage: "Attribute 'match_t' is deprecated, please refer to 'match_criteria' instead. The attribute will be removed in the next major version of the provider.",
				Validators: []validator.String{
					stringvalidator.ConflictsWith(path.Expressions{
						path.MatchRoot("match_criteria"),
					}...),
				},
			},
			"application_profile_dn": schema.StringAttribute{
				Optional:           true,
				Computed:           true,
				DeprecationMessage: "Attribute 'application_profile_dn' is deprecated, please refer to 'parent_dn' instead. The attribute will be removed in the next major version of the provider.",
				Validators: []validator.String{
					stringvalidator.ConflictsWith(path.Expressions{
						path.MatchRoot("parent_dn"),
					}...),
				},
			},
			"pc_enf_pref": schema.StringAttribute{
				Optional:           true,
				Computed:           true,
				DeprecationMessage: "Attribute 'pc_enf_pref' is deprecated, please refer to 'intra_esg_isolation' instead. The attribute will be removed in the next major version of the provider.",
				Validators: []validator.String{
					stringvalidator.ConflictsWith(path.Expressions{
						path.MatchRoot("intra_esg_isolation"),
					}...),
				},
			},
			"pref_gr_memb": schema.StringAttribute{
				Optional:           true,
				Computed:           true,
				DeprecationMessage: "Attribute 'pref_gr_memb' is deprecated, please refer to 'preferred_group_member' instead. The attribute will be removed in the next major version of the provider.",
				Validators: []validator.String{
					stringvalidator.ConflictsWith(path.Expressions{
						path.MatchRoot("preferred_group_member"),
					}...),
				},
			},
			"relation_fv_rs_cust_qos_pol": schema.StringAttribute{
				Optional:           true,
				Computed:           true,
				DeprecationMessage: "Attribute `relation_fv_rs_cust_qos_pol` is deprecated. The configuration was not functioning as intended because the Managed Object (MO) created by the pre-migrated resource was either configured incorrectly or exposed without any implemented functionality on the APIC. The MO for this attribute is no longer created on the APIC, but the existing MO will remain present until the resource is destroyed. This attribute will be removed in the next major version of the provider.",
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
			},
			"relation_fv_rs_prot_by": schema.SetAttribute{
				Optional:           true,
				Computed:           true,
				ElementType:        types.StringType,
				DeprecationMessage: "Attribute `relation_fv_rs_prot_by` is deprecated. The configuration was not functioning as intended because the Managed Object (MO) created by the pre-migrated resource was either configured incorrectly or exposed without any implemented functionality on the APIC. The MO for this attribute is no longer created on the APIC, but the existing MO will remain present until the resource is destroyed. This attribute will be removed in the next major version of the provider.",
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
				},
			},
			"relation_fv_rs_sec_inherited": schema.SetAttribute{
				Optional:           true,
				Computed:           true,
				ElementType:        types.StringType,
				DeprecationMessage: "Attribute 'relation_fv_rs_sec_inherited' is deprecated, please refer to 'relation_to_contract_masters' instead. The attribute will be removed in the next major version of the provider.",
				Validators: []validator.Set{
					setvalidator.ConflictsWith(path.Expressions{
						path.MatchRoot("relation_to_contract_masters"),
					}...),
				},
			},
			"relation_fv_rs_intra_epg": schema.SetAttribute{
				Optional:           true,
				Computed:           true,
				ElementType:        types.StringType,
				DeprecationMessage: "Attribute 'relation_fv_rs_intra_epg' is deprecated, please refer to 'relation_to_intra_epg_contracts' instead. The attribute will be removed in the next major version of the provider.",
				Validators: []validator.Set{
					setvalidator.ConflictsWith(path.Expressions{
						path.MatchRoot("relation_to_intra_epg_contracts"),
					}...),
				},
			},
			"relation_fv_rs_scope": schema.StringAttribute{
				Optional:           true,
				Computed:           true,
				DeprecationMessage: "Attribute 'relation_fv_rs_scope' is deprecated, please refer to 'relation_to_vrf' instead. The attribute will be removed in the next major version of the provider.",
				Validators: []validator.String{
					stringvalidator.ConflictsWith(path.Expressions{
						path.MatchRoot("relation_to_vrf"),
					}...),
				},
			},
			// End of deprecated attributes
			"id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "The distinguished name (DN) of the Endpoint Security Group object.",
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
				},
			},
			"parent_dn": schema.StringAttribute{
				Optional:            true,
				Computed:            true,
				MarkdownDescription: "The distinguished name (DN) of the parent object.",
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					stringplanmodifier.RequiresReplace(),
				},
				Validators: []validator.String{
					stringvalidator.AtLeastOneOf(path.Expressions{
						path.MatchRoot("application_profile_dn"),
					}...),
				},
			},
			"annotation": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Default:             stringdefault.StaticString(globalAnnotation),
				MarkdownDescription: `The annotation of the Endpoint Security Group object.`,
			},
			"description": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The description of the Endpoint Security Group object.`,
			},
			"exception_tag": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `Contract Exception Tag.`,
			},
			"match_criteria": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("All", "AtleastOne", "AtmostOne", "None"),
				},
				MarkdownDescription: `The provider label match criteria.`,
			},
			"name": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
					stringplanmodifier.RequiresReplace(),
				},
				Validators: []validator.String{
					MakeStringRequired(),
				},
				MarkdownDescription: `The name of the Endpoint Security Group object.`,
			},
			"name_alias": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The name alias of the Endpoint Security Group object.`,
			},
			"intra_esg_isolation": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("enforced", "unenforced"),
				},
				MarkdownDescription: `Parameter used to determine whether communication between endpoints within the ESG is blocked.`,
			},
			"pc_tag": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: `The classification tag used for policy enforcement and zoning.`,
			},
			"preferred_group_member": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("exclude", "include"),
				},
				MarkdownDescription: `Parameter used to determine whether the ESG is part of the preferred group. Members of this group are allowed to communicate without contracts.`,
			},
			"scope": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: `The scope ID (L3-VNI) of the Endpoint Security Group object.`,
			},
			"admin_state": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("no", "yes"),
				},
				MarkdownDescription: `Withdraw the ESG configuration from all nodes in the fabric.`,
			},
			"relation_to_consumed_contracts": schema.SetNestedAttribute{
				MarkdownDescription: `The Consumer contract profile information.`,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
					SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsConsFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"annotation": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators:          []validator.String{},
							MarkdownDescription: `The annotation of the Relation To Consumed Contract object.`,
						},
						"priority": schema.StringAttribute{
							CustomType: customTypes.FvRsConsPrioStringType{},
							Optional:   true,
							Computed:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("level1", "level2", "level3", "level4", "level5", "level6", "unspecified"),
									validators.InBetweenFromString(0, 9),
								),
							},
							MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`,
						},
						"contract_name": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The consumer contract name.`,
						},
						"annotations": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
						"tags": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
					},
				},
			},
			"relation_to_imported_contracts": schema.SetNestedAttribute{
				MarkdownDescription: `A contract for which the EPG will be a consumer.`,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
					SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsConsIfFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"annotation": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators:          []validator.String{},
							MarkdownDescription: `The annotation of the Relation To Imported Contract object.`,
						},
						"priority": schema.StringAttribute{
							CustomType: customTypes.FvRsConsIfPrioStringType{},
							Optional:   true,
							Computed:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("level1", "level2", "level3", "level4", "level5", "level6", "unspecified"),
									validators.InBetweenFromString(0, 9),
								),
							},
							MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`,
						},
						"imported_contract_name": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The contract interface name.`,
						},
						"annotations": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
						"tags": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
					},
				},
			},
			"relation_to_intra_epg_contracts": schema.SetNestedAttribute{
				MarkdownDescription: `Intra EPg contract:
                      Represents that the EPg is moving from "allow all within epg" mode
                      to a "deny all within epg" mode.
                      The only type of traffic allowed between EPs in this EPg is the one
                      specified by contracts EPg associates to with this relation.`,
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
					SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsIntraEpgFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"annotation": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators:          []validator.String{},
							MarkdownDescription: `The annotation of the Relation To Intra EPG Contract object.`,
						},
						"contract_name": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The contract name.`,
						},
						"annotations": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
						"tags": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
					},
				},
			},
			"relation_to_provided_contracts": schema.SetNestedAttribute{
				MarkdownDescription: `A contract for which the EPG will be a provider.`,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
					SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsProvFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"annotation": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators:          []validator.String{},
							MarkdownDescription: `The annotation of the Relation To Provided Contract object.`,
						},
						"match_criteria": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.OneOf("All", "AtleastOne", "AtmostOne", "None"),
							},
							MarkdownDescription: `The provider label match criteria.`,
						},
						"priority": schema.StringAttribute{
							CustomType: customTypes.FvRsProvPrioStringType{},
							Optional:   true,
							Computed:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("level1", "level2", "level3", "level4", "level5", "level6", "unspecified"),
									validators.InBetweenFromString(0, 9),
								),
							},
							MarkdownDescription: `The Quality of Service (QoS) priority class ID. QoS refers to the capability of a network to provide better service to selected network traffic over various technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic), and improved loss characteristics. You can configure the bandwidth of each QoS level using QoS profiles.`,
						},
						"contract_name": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The provider contract name.`,
						},
						"annotations": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
						"tags": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
					},
				},
			},
			"relation_to_vrf": schema.SingleNestedAttribute{
				MarkdownDescription: ``,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Object{
					objectplanmodifier.UseStateForUnknown(),
				},
				Attributes: map[string]schema.Attribute{
					"annotation": schema.StringAttribute{
						Optional: true,
						Computed: true,
						PlanModifiers: []planmodifier.String{
							stringplanmodifier.UseStateForUnknown(),
						},
						MarkdownDescription: `The annotation of the Relation To VRF object.`,
					},
					"vrf_name": schema.StringAttribute{
						Optional: true,
						Computed: true,
						PlanModifiers: []planmodifier.String{
							stringplanmodifier.UseStateForUnknown(),
						},
						MarkdownDescription: `The name of the VRF object.`,
					},
					"annotations": schema.SetNestedAttribute{
						MarkdownDescription: ``,
						Optional:            true,
						Computed:            true,
						PlanModifiers: []planmodifier.Set{
							setplanmodifier.UseStateForUnknown(),
						},
						NestedObject: schema.NestedAttributeObject{
							Attributes: map[string]schema.Attribute{
								"key": schema.StringAttribute{
									Optional: true,
									Computed: true,
									PlanModifiers: []planmodifier.String{
										stringplanmodifier.UseStateForUnknown(),
									},
									Validators: []validator.String{
										MakeStringRequired(),
									},
									MarkdownDescription: `The key used to uniquely identify this configuration object.`,
								},
								"value": schema.StringAttribute{
									Optional: true,
									Computed: true,
									PlanModifiers: []planmodifier.String{
										stringplanmodifier.UseStateForUnknown(),
									},
									Validators: []validator.String{
										MakeStringRequired(),
									},
									MarkdownDescription: `The value of the property.`,
								},
							},
						},
					},
					"tags": schema.SetNestedAttribute{
						MarkdownDescription: ``,
						Optional:            true,
						Computed:            true,
						PlanModifiers: []planmodifier.Set{
							setplanmodifier.UseStateForUnknown(),
						},
						NestedObject: schema.NestedAttributeObject{
							Attributes: map[string]schema.Attribute{
								"key": schema.StringAttribute{
									Optional: true,
									Computed: true,
									PlanModifiers: []planmodifier.String{
										stringplanmodifier.UseStateForUnknown(),
									},
									Validators: []validator.String{
										MakeStringRequired(),
									},
									MarkdownDescription: `The key used to uniquely identify this configuration object.`,
								},
								"value": schema.StringAttribute{
									Optional: true,
									Computed: true,
									PlanModifiers: []planmodifier.String{
										stringplanmodifier.UseStateForUnknown(),
									},
									Validators: []validator.String{
										MakeStringRequired(),
									},
									MarkdownDescription: `The value of the property.`,
								},
							},
						},
					},
				},
			},
			"relation_to_contract_masters": schema.SetNestedAttribute{
				MarkdownDescription: `Represents that the EPg is inheriting security configuration from another EPg`,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
					SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsSecInheritedFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"annotation": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators:          []validator.String{},
							MarkdownDescription: `The annotation of the Relation To Contract Master object.`,
						},
						"target_dn": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The distinguished name of the target.`,
						},
						"annotations": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
						"tags": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Optional: true,
										Computed: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										Validators: []validator.String{
											MakeStringRequired(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
					},
				},
			},
			"annotations": schema.SetNestedAttribute{
				MarkdownDescription: ``,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"key": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The key used to uniquely identify this configuration object.`,
						},
						"value": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The value of the property.`,
						},
					},
				},
			},
			"tags": schema.SetNestedAttribute{
				MarkdownDescription: ``,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"key": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The key used to uniquely identify this configuration object.`,
						},
						"value": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								MakeStringRequired(),
							},
							MarkdownDescription: `The value of the property.`,
						},
					},
				},
			},
		},
		Blocks: map[string]schema.Block{
			"relation_fv_rs_cons": schema.SetNestedBlock{
				NestedObject: schema.NestedBlockObject{
					Attributes: map[string]schema.Attribute{
						"target_dn": schema.StringAttribute{
							Optional:           true,
							Computed:           true,
							DeprecationMessage: "Attribute 'target_dn' will be deprecated soon, please use 'relation_to_consumed_contracts.contract_name' instead",
							Validators: []validator.String{
								stringvalidator.ConflictsWith(path.Expressions{
									path.MatchRoot("relation_to_consumed_contracts"),
								}...),
								MakeStringRequired(),
							},
						},
						"prio": schema.StringAttribute{
							Optional:           true,
							Computed:           true,
							DeprecationMessage: "Attribute 'prio' will be deprecated soon, please use 'relation_to_consumed_contracts.priority' instead",
							Validators: []validator.String{
								stringvalidator.ConflictsWith(path.Expressions{
									path.MatchRoot("relation_to_consumed_contracts"),
								}...),
							},
						},
					},
				},
			},
			"relation_fv_rs_cons_if": schema.SetNestedBlock{
				NestedObject: schema.NestedBlockObject{
					Attributes: map[string]schema.Attribute{
						"target_dn": schema.StringAttribute{
							Optional:           true,
							Computed:           true,
							DeprecationMessage: "Attribute 'target_dn' will be deprecated soon, please use 'relation_to_imported_contracts.imported_contract_name' instead",
							Validators: []validator.String{
								stringvalidator.ConflictsWith(path.Expressions{
									path.MatchRoot("relation_to_imported_contracts"),
								}...),
								MakeStringRequired(),
							},
						},
						"prio": schema.StringAttribute{
							Optional:           true,
							Computed:           true,
							DeprecationMessage: "Attribute 'prio' will be deprecated soon, please use 'relation_to_imported_contracts.priority' instead",
							Validators: []validator.String{
								stringvalidator.ConflictsWith(path.Expressions{
									path.MatchRoot("relation_to_imported_contracts"),
								}...),
							},
						},
					},
				},
			},
			"relation_fv_rs_prov": schema.SetNestedBlock{
				NestedObject: schema.NestedBlockObject{
					Attributes: map[string]schema.Attribute{
						"target_dn": schema.StringAttribute{
							Optional:           true,
							Computed:           true,
							DeprecationMessage: "Attribute 'target_dn' will be deprecated soon, please use 'relation_to_provided_contracts.contract_name' instead",
							Validators: []validator.String{
								stringvalidator.ConflictsWith(path.Expressions{
									path.MatchRoot("relation_to_provided_contracts"),
								}...),
								MakeStringRequired(),
							},
						},
						"match_t": schema.StringAttribute{
							Optional:           true,
							Computed:           true,
							DeprecationMessage: "Attribute 'match_t' will be deprecated soon, please use 'relation_to_provided_contracts.match_criteria' instead",
							Validators: []validator.String{
								stringvalidator.ConflictsWith(path.Expressions{
									path.MatchRoot("relation_to_provided_contracts"),
								}...),
							},
						},
						"prio": schema.StringAttribute{
							Optional:           true,
							Computed:           true,
							DeprecationMessage: "Attribute 'prio' will be deprecated soon, please use 'relation_to_provided_contracts.priority' instead",
							Validators: []validator.String{
								stringvalidator.ConflictsWith(path.Expressions{
									path.MatchRoot("relation_to_provided_contracts"),
								}...),
							},
						},
					},
				},
			},
		},
	}
	tflog.Debug(ctx, "End schema of resource: aci_endpoint_security_group")
}

func (r *FvESgResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
	tflog.Debug(ctx, "Start configure of resource: aci_endpoint_security_group")
	// Prevent panic if the provider has not been configured.
	if req.ProviderData == nil {
		return
	}

	client, ok := req.ProviderData.(*client.Client)

	if !ok {
		resp.Diagnostics.AddError(
			"Unexpected Resource Configure Type",
			fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
		)

		return
	}

	r.client = client
	tflog.Debug(ctx, "End configure of resource: aci_endpoint_security_group")
}

func (r *FvESgResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
	tflog.Debug(ctx, "Start create of resource: aci_endpoint_security_group")
	// On create retrieve information on current state prior to making any changes in order to determine child delete operations
	var stateData *FvESgResourceModel
	resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...)
	if stateData.Id.IsUnknown() || stateData.Id.IsNull() {
		setFvESgId(ctx, stateData)
	}
	getAndSetFvESgAttributes(ctx, &resp.Diagnostics, r.client, stateData)
	if !globalAllowExistingOnCreate && !stateData.Id.IsNull() {
		resp.Diagnostics.AddError(
			"Object Already Exists",
			fmt.Sprintf("The fvESg object with DN '%s' already exists.", stateData.Id.ValueString()),
		)
		return
	}

	var data *FvESgResourceModel

	// Read Terraform plan data into the model
	resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)

	if resp.Diagnostics.HasError() {
		return
	}

	if data.Id.IsUnknown() || data.Id.IsNull() {
		setFvESgId(ctx, data)
	}

	tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString()))

	var fvRsConsPlan, fvRsConsState []FvRsConsFvESgResourceModel
	data.FvRsCons.ElementsAs(ctx, &fvRsConsPlan, false)
	stateData.FvRsCons.ElementsAs(ctx, &fvRsConsState, false)
	var fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvESgResourceModel
	data.FvRsConsIf.ElementsAs(ctx, &fvRsConsIfPlan, false)
	stateData.FvRsConsIf.ElementsAs(ctx, &fvRsConsIfState, false)
	var fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvESgResourceModel
	data.FvRsIntraEpg.ElementsAs(ctx, &fvRsIntraEpgPlan, false)
	stateData.FvRsIntraEpg.ElementsAs(ctx, &fvRsIntraEpgState, false)
	var fvRsProvPlan, fvRsProvState []FvRsProvFvESgResourceModel
	data.FvRsProv.ElementsAs(ctx, &fvRsProvPlan, false)
	stateData.FvRsProv.ElementsAs(ctx, &fvRsProvState, false)
	var fvRsScopePlan, fvRsScopeState FvRsScopeFvESgResourceModel
	data.FvRsScope.As(ctx, &fvRsScopePlan, basetypes.ObjectAsOptions{})
	stateData.FvRsScope.As(ctx, &fvRsScopeState, basetypes.ObjectAsOptions{})
	var fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvESgResourceModel
	data.FvRsSecInherited.ElementsAs(ctx, &fvRsSecInheritedPlan, false)
	stateData.FvRsSecInherited.ElementsAs(ctx, &fvRsSecInheritedState, false)
	var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvESgResourceModel
	data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false)
	stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false)
	var tagTagPlan, tagTagState []TagTagFvESgResourceModel
	data.TagTag.ElementsAs(ctx, &tagTagPlan, false)
	stateData.TagTag.ElementsAs(ctx, &tagTagState, false)
	jsonPayload := getFvESgCreateJsonPayload(ctx, &resp.Diagnostics, true, data, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsProvPlan, fvRsProvState, fvRsScopePlan, fvRsScopeState, fvRsSecInheritedPlan, fvRsSecInheritedState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState)

	if resp.Diagnostics.HasError() {
		return
	}

	DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload)

	if resp.Diagnostics.HasError() {
		return
	}

	getAndSetFvESgAttributes(ctx, &resp.Diagnostics, r.client, data)

	// Save data into Terraform state
	resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
	tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString()))
}

func (r *FvESgResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
	tflog.Debug(ctx, "Start read of resource: aci_endpoint_security_group")
	var data *FvESgResourceModel

	// Read Terraform prior state data into the model
	resp.Diagnostics.Append(req.State.Get(ctx, &data)...)

	if resp.Diagnostics.HasError() {
		return
	}

	tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString()))

	getAndSetFvESgAttributes(ctx, &resp.Diagnostics, r.client, data)

	// Save updated data into Terraform state
	if data.Id.IsNull() {
		var emptyData *FvESgResourceModel
		resp.Diagnostics.Append(resp.State.Set(ctx, &emptyData)...)
	} else {
		resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
	}

	tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString()))
}

func (r *FvESgResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
	tflog.Debug(ctx, "Start update of resource: aci_endpoint_security_group")
	var data *FvESgResourceModel
	var stateData *FvESgResourceModel

	// Read Terraform plan data into the model
	resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
	resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...)
	// Error out when child object fvRsScope is being deleted
	if IsEmptySingleNestedAttribute(data.FvRsScope.Attributes()) && !IsEmptySingleNestedAttribute(stateData.FvRsScope.Attributes()) {
		resp.Diagnostics.AddError(
			"FvRsScope object cannot be deleted",
			"deletion of child is only possible upon deletion of the parent",
		)
	}

	if resp.Diagnostics.HasError() {
		return
	}

	tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString()))

	var fvRsConsPlan, fvRsConsState []FvRsConsFvESgResourceModel
	data.FvRsCons.ElementsAs(ctx, &fvRsConsPlan, false)
	stateData.FvRsCons.ElementsAs(ctx, &fvRsConsState, false)
	var fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvESgResourceModel
	data.FvRsConsIf.ElementsAs(ctx, &fvRsConsIfPlan, false)
	stateData.FvRsConsIf.ElementsAs(ctx, &fvRsConsIfState, false)
	var fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvESgResourceModel
	data.FvRsIntraEpg.ElementsAs(ctx, &fvRsIntraEpgPlan, false)
	stateData.FvRsIntraEpg.ElementsAs(ctx, &fvRsIntraEpgState, false)
	var fvRsProvPlan, fvRsProvState []FvRsProvFvESgResourceModel
	data.FvRsProv.ElementsAs(ctx, &fvRsProvPlan, false)
	stateData.FvRsProv.ElementsAs(ctx, &fvRsProvState, false)
	var fvRsScopePlan, fvRsScopeState FvRsScopeFvESgResourceModel
	data.FvRsScope.As(ctx, &fvRsScopePlan, basetypes.ObjectAsOptions{})
	stateData.FvRsScope.As(ctx, &fvRsScopeState, basetypes.ObjectAsOptions{})
	var fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvESgResourceModel
	data.FvRsSecInherited.ElementsAs(ctx, &fvRsSecInheritedPlan, false)
	stateData.FvRsSecInherited.ElementsAs(ctx, &fvRsSecInheritedState, false)
	var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvESgResourceModel
	data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false)
	stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false)
	var tagTagPlan, tagTagState []TagTagFvESgResourceModel
	data.TagTag.ElementsAs(ctx, &tagTagPlan, false)
	stateData.TagTag.ElementsAs(ctx, &tagTagState, false)
	jsonPayload := getFvESgCreateJsonPayload(ctx, &resp.Diagnostics, false, data, fvRsConsPlan, fvRsConsState, fvRsConsIfPlan, fvRsConsIfState, fvRsIntraEpgPlan, fvRsIntraEpgState, fvRsProvPlan, fvRsProvState, fvRsScopePlan, fvRsScopeState, fvRsSecInheritedPlan, fvRsSecInheritedState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState)

	if resp.Diagnostics.HasError() {
		return
	}

	DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload)

	if resp.Diagnostics.HasError() {
		return
	}

	getAndSetFvESgAttributes(ctx, &resp.Diagnostics, r.client, data)

	// Save updated data into Terraform state
	resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
	tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString()))
}

func (r *FvESgResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
	tflog.Debug(ctx, "Start delete of resource: aci_endpoint_security_group")
	var data *FvESgResourceModel

	// Read Terraform prior state data into the model
	resp.Diagnostics.Append(req.State.Get(ctx, &data)...)

	if resp.Diagnostics.HasError() {
		return
	}

	tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString()))
	jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "fvESg", data.Id.ValueString())
	if resp.Diagnostics.HasError() {
		return
	}
	DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload)
	if resp.Diagnostics.HasError() {
		return
	}
	tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_endpoint_security_group with id '%s'", data.Id.ValueString()))
}

func (r *FvESgResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
	tflog.Debug(ctx, "Start import state of resource: aci_endpoint_security_group")
	resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)

	var stateData *FvESgResourceModel
	resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...)
	tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_endpoint_security_group with id '%s'", stateData.Id.ValueString()))

	tflog.Debug(ctx, "End import of state resource: aci_endpoint_security_group")
}

func getAndSetFvESgAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *FvESgResourceModel) {
	requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "fvESg,fvRsCons,fvRsConsIf,fvRsIntraEpg,fvRsProv,fvRsScope,fvRsSecInherited,tagAnnotation,tagTag,tagAnnotation,tagTag,tagAnnotation,tagTag,tagAnnotation,tagTag,tagAnnotation,tagTag,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil)

	readData := getEmptyFvESgResourceModel()

	if diags.HasError() {
		return
	}
	if requestData.Search("imdata").Search("fvESg").Data() != nil {
		classReadInfo := requestData.Search("imdata").Search("fvESg").Data().([]interface{})
		if len(classReadInfo) == 1 {
			attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{})
			for attributeName, attributeValue := range attributes {
				if attributeName == "dn" {
					readData.Id = basetypes.NewStringValue(attributeValue.(string))
					setFvESgParentDn(ctx, attributeValue.(string), readData)
				}
				if attributeName == "annotation" {
					readData.Annotation = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "descr" {
					readData.Descr = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "exceptionTag" {
					readData.ExceptionTag = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "matchT" {
					readData.MatchT = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "name" {
					readData.Name = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "nameAlias" {
					readData.NameAlias = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "pcEnfPref" {
					readData.PcEnfPref = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "pcTag" {
					readData.PcTag = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "prefGrMemb" {
					readData.PrefGrMemb = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "scope" {
					readData.Scope = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "shutdown" {
					readData.Shutdown = basetypes.NewStringValue(attributeValue.(string))
				}
			}
			FvRsConsFvESgList := make([]FvRsConsFvESgResourceModel, 0)
			FvRsConsIfFvESgList := make([]FvRsConsIfFvESgResourceModel, 0)
			FvRsIntraEpgFvESgList := make([]FvRsIntraEpgFvESgResourceModel, 0)
			FvRsProvFvESgList := make([]FvRsProvFvESgResourceModel, 0)
			FvRsScopeFvESgList := make([]FvRsScopeFvESgResourceModel, 0)
			FvRsSecInheritedFvESgList := make([]FvRsSecInheritedFvESgResourceModel, 0)
			TagAnnotationFvESgList := make([]TagAnnotationFvESgResourceModel, 0)
			TagTagFvESgList := make([]TagTagFvESgResourceModel, 0)
			_, ok := classReadInfo[0].(map[string]interface{})["children"]
			if ok {
				children := classReadInfo[0].(map[string]interface{})["children"].([]interface{})
				for _, child := range children {
					for childClassName, childClassDetails := range child.(map[string]interface{}) {
						childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{})
						if childClassName == "fvRsCons" {
							FvRsConsFvESg := getEmptyFvRsConsFvESgResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "annotation" {
									FvRsConsFvESg.Annotation = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "prio" {
									FvRsConsFvESg.Prio = customTypes.NewFvRsConsPrioStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "tnVzBrCPName" {
									FvRsConsFvESg.TnVzBrCPName = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationFvRsConsFvESgList := make([]TagAnnotationFvRsConsFvESgResourceModel, 0)
							TagTagFvRsConsFvESgList := make([]TagTagFvRsConsFvESgResourceModel, 0)
							childrenOfFvRsConsFvESg, childrenOfFvRsConsFvESgExist := childClassDetails.(map[string]interface{})["children"]
							if childrenOfFvRsConsFvESgExist {
								for _, childFvRsConsFvESg := range childrenOfFvRsConsFvESg.([]interface{}) {
									for childClassNameFvRsConsFvESg, childClassDetailsFvRsConsFvESg := range childFvRsConsFvESg.(map[string]interface{}) {
										if childClassNameFvRsConsFvESg == "tagAnnotation" {
											TagAnnotationFvRsConsFvESg := getEmptyTagAnnotationFvRsConsFvESgResourceModel()
											tagAnnotationchildAttributeValue := childClassDetailsFvRsConsFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue {
												if childAttributeName == "key" {
													TagAnnotationFvRsConsFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagAnnotationFvRsConsFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagAnnotationFvRsConsFvESgList = append(TagAnnotationFvRsConsFvESgList, TagAnnotationFvRsConsFvESg)
										}
										if childClassNameFvRsConsFvESg == "tagTag" {
											TagTagFvRsConsFvESg := getEmptyTagTagFvRsConsFvESgResourceModel()
											tagTagchildAttributeValue := childClassDetailsFvRsConsFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagTagchildAttributeValue {
												if childAttributeName == "key" {
													TagTagFvRsConsFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagTagFvRsConsFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagTagFvRsConsFvESgList = append(TagTagFvRsConsFvESgList, TagTagFvRsConsFvESg)
										}
									}
								}
							}
							TagAnnotationFvRsConsFvESgSet, _ := types.SetValueFrom(ctx, TagAnnotationFvRsConsFvESgType, TagAnnotationFvRsConsFvESgList)
							FvRsConsFvESg.TagAnnotation = TagAnnotationFvRsConsFvESgSet
							TagTagFvRsConsFvESgSet, _ := types.SetValueFrom(ctx, TagTagFvRsConsFvESgType, TagTagFvRsConsFvESgList)
							FvRsConsFvESg.TagTag = TagTagFvRsConsFvESgSet
							FvRsConsFvESgList = append(FvRsConsFvESgList, FvRsConsFvESg)
						}
						if childClassName == "fvRsConsIf" {
							FvRsConsIfFvESg := getEmptyFvRsConsIfFvESgResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "annotation" {
									FvRsConsIfFvESg.Annotation = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "prio" {
									FvRsConsIfFvESg.Prio = customTypes.NewFvRsConsIfPrioStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "tnVzCPIfName" {
									FvRsConsIfFvESg.TnVzCPIfName = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationFvRsConsIfFvESgList := make([]TagAnnotationFvRsConsIfFvESgResourceModel, 0)
							TagTagFvRsConsIfFvESgList := make([]TagTagFvRsConsIfFvESgResourceModel, 0)
							childrenOfFvRsConsIfFvESg, childrenOfFvRsConsIfFvESgExist := childClassDetails.(map[string]interface{})["children"]
							if childrenOfFvRsConsIfFvESgExist {
								for _, childFvRsConsIfFvESg := range childrenOfFvRsConsIfFvESg.([]interface{}) {
									for childClassNameFvRsConsIfFvESg, childClassDetailsFvRsConsIfFvESg := range childFvRsConsIfFvESg.(map[string]interface{}) {
										if childClassNameFvRsConsIfFvESg == "tagAnnotation" {
											TagAnnotationFvRsConsIfFvESg := getEmptyTagAnnotationFvRsConsIfFvESgResourceModel()
											tagAnnotationchildAttributeValue := childClassDetailsFvRsConsIfFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue {
												if childAttributeName == "key" {
													TagAnnotationFvRsConsIfFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagAnnotationFvRsConsIfFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagAnnotationFvRsConsIfFvESgList = append(TagAnnotationFvRsConsIfFvESgList, TagAnnotationFvRsConsIfFvESg)
										}
										if childClassNameFvRsConsIfFvESg == "tagTag" {
											TagTagFvRsConsIfFvESg := getEmptyTagTagFvRsConsIfFvESgResourceModel()
											tagTagchildAttributeValue := childClassDetailsFvRsConsIfFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagTagchildAttributeValue {
												if childAttributeName == "key" {
													TagTagFvRsConsIfFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagTagFvRsConsIfFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagTagFvRsConsIfFvESgList = append(TagTagFvRsConsIfFvESgList, TagTagFvRsConsIfFvESg)
										}
									}
								}
							}
							TagAnnotationFvRsConsIfFvESgSet, _ := types.SetValueFrom(ctx, TagAnnotationFvRsConsIfFvESgType, TagAnnotationFvRsConsIfFvESgList)
							FvRsConsIfFvESg.TagAnnotation = TagAnnotationFvRsConsIfFvESgSet
							TagTagFvRsConsIfFvESgSet, _ := types.SetValueFrom(ctx, TagTagFvRsConsIfFvESgType, TagTagFvRsConsIfFvESgList)
							FvRsConsIfFvESg.TagTag = TagTagFvRsConsIfFvESgSet
							FvRsConsIfFvESgList = append(FvRsConsIfFvESgList, FvRsConsIfFvESg)
						}
						if childClassName == "fvRsIntraEpg" {
							FvRsIntraEpgFvESg := getEmptyFvRsIntraEpgFvESgResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "annotation" {
									FvRsIntraEpgFvESg.Annotation = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "tnVzBrCPName" {
									FvRsIntraEpgFvESg.TnVzBrCPName = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationFvRsIntraEpgFvESgList := make([]TagAnnotationFvRsIntraEpgFvESgResourceModel, 0)
							TagTagFvRsIntraEpgFvESgList := make([]TagTagFvRsIntraEpgFvESgResourceModel, 0)
							childrenOfFvRsIntraEpgFvESg, childrenOfFvRsIntraEpgFvESgExist := childClassDetails.(map[string]interface{})["children"]
							if childrenOfFvRsIntraEpgFvESgExist {
								for _, childFvRsIntraEpgFvESg := range childrenOfFvRsIntraEpgFvESg.([]interface{}) {
									for childClassNameFvRsIntraEpgFvESg, childClassDetailsFvRsIntraEpgFvESg := range childFvRsIntraEpgFvESg.(map[string]interface{}) {
										if childClassNameFvRsIntraEpgFvESg == "tagAnnotation" {
											TagAnnotationFvRsIntraEpgFvESg := getEmptyTagAnnotationFvRsIntraEpgFvESgResourceModel()
											tagAnnotationchildAttributeValue := childClassDetailsFvRsIntraEpgFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue {
												if childAttributeName == "key" {
													TagAnnotationFvRsIntraEpgFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagAnnotationFvRsIntraEpgFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagAnnotationFvRsIntraEpgFvESgList = append(TagAnnotationFvRsIntraEpgFvESgList, TagAnnotationFvRsIntraEpgFvESg)
										}
										if childClassNameFvRsIntraEpgFvESg == "tagTag" {
											TagTagFvRsIntraEpgFvESg := getEmptyTagTagFvRsIntraEpgFvESgResourceModel()
											tagTagchildAttributeValue := childClassDetailsFvRsIntraEpgFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagTagchildAttributeValue {
												if childAttributeName == "key" {
													TagTagFvRsIntraEpgFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagTagFvRsIntraEpgFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagTagFvRsIntraEpgFvESgList = append(TagTagFvRsIntraEpgFvESgList, TagTagFvRsIntraEpgFvESg)
										}
									}
								}
							}
							TagAnnotationFvRsIntraEpgFvESgSet, _ := types.SetValueFrom(ctx, TagAnnotationFvRsIntraEpgFvESgType, TagAnnotationFvRsIntraEpgFvESgList)
							FvRsIntraEpgFvESg.TagAnnotation = TagAnnotationFvRsIntraEpgFvESgSet
							TagTagFvRsIntraEpgFvESgSet, _ := types.SetValueFrom(ctx, TagTagFvRsIntraEpgFvESgType, TagTagFvRsIntraEpgFvESgList)
							FvRsIntraEpgFvESg.TagTag = TagTagFvRsIntraEpgFvESgSet
							FvRsIntraEpgFvESgList = append(FvRsIntraEpgFvESgList, FvRsIntraEpgFvESg)
						}
						if childClassName == "fvRsProv" {
							FvRsProvFvESg := getEmptyFvRsProvFvESgResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "annotation" {
									FvRsProvFvESg.Annotation = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "matchT" {
									FvRsProvFvESg.MatchT = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "prio" {
									FvRsProvFvESg.Prio = customTypes.NewFvRsProvPrioStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "tnVzBrCPName" {
									FvRsProvFvESg.TnVzBrCPName = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationFvRsProvFvESgList := make([]TagAnnotationFvRsProvFvESgResourceModel, 0)
							TagTagFvRsProvFvESgList := make([]TagTagFvRsProvFvESgResourceModel, 0)
							childrenOfFvRsProvFvESg, childrenOfFvRsProvFvESgExist := childClassDetails.(map[string]interface{})["children"]
							if childrenOfFvRsProvFvESgExist {
								for _, childFvRsProvFvESg := range childrenOfFvRsProvFvESg.([]interface{}) {
									for childClassNameFvRsProvFvESg, childClassDetailsFvRsProvFvESg := range childFvRsProvFvESg.(map[string]interface{}) {
										if childClassNameFvRsProvFvESg == "tagAnnotation" {
											TagAnnotationFvRsProvFvESg := getEmptyTagAnnotationFvRsProvFvESgResourceModel()
											tagAnnotationchildAttributeValue := childClassDetailsFvRsProvFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue {
												if childAttributeName == "key" {
													TagAnnotationFvRsProvFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagAnnotationFvRsProvFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagAnnotationFvRsProvFvESgList = append(TagAnnotationFvRsProvFvESgList, TagAnnotationFvRsProvFvESg)
										}
										if childClassNameFvRsProvFvESg == "tagTag" {
											TagTagFvRsProvFvESg := getEmptyTagTagFvRsProvFvESgResourceModel()
											tagTagchildAttributeValue := childClassDetailsFvRsProvFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagTagchildAttributeValue {
												if childAttributeName == "key" {
													TagTagFvRsProvFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagTagFvRsProvFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagTagFvRsProvFvESgList = append(TagTagFvRsProvFvESgList, TagTagFvRsProvFvESg)
										}
									}
								}
							}
							TagAnnotationFvRsProvFvESgSet, _ := types.SetValueFrom(ctx, TagAnnotationFvRsProvFvESgType, TagAnnotationFvRsProvFvESgList)
							FvRsProvFvESg.TagAnnotation = TagAnnotationFvRsProvFvESgSet
							TagTagFvRsProvFvESgSet, _ := types.SetValueFrom(ctx, TagTagFvRsProvFvESgType, TagTagFvRsProvFvESgList)
							FvRsProvFvESg.TagTag = TagTagFvRsProvFvESgSet
							FvRsProvFvESgList = append(FvRsProvFvESgList, FvRsProvFvESg)
						}
						if childClassName == "fvRsScope" {
							FvRsScopeFvESg := getEmptyFvRsScopeFvESgResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "annotation" {
									FvRsScopeFvESg.Annotation = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "tnFvCtxName" {
									FvRsScopeFvESg.TnFvCtxName = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationFvRsScopeFvESgList := make([]TagAnnotationFvRsScopeFvESgResourceModel, 0)
							TagTagFvRsScopeFvESgList := make([]TagTagFvRsScopeFvESgResourceModel, 0)
							childrenOfFvRsScopeFvESg, childrenOfFvRsScopeFvESgExist := childClassDetails.(map[string]interface{})["children"]
							if childrenOfFvRsScopeFvESgExist {
								for _, childFvRsScopeFvESg := range childrenOfFvRsScopeFvESg.([]interface{}) {
									for childClassNameFvRsScopeFvESg, childClassDetailsFvRsScopeFvESg := range childFvRsScopeFvESg.(map[string]interface{}) {
										if childClassNameFvRsScopeFvESg == "tagAnnotation" {
											TagAnnotationFvRsScopeFvESg := getEmptyTagAnnotationFvRsScopeFvESgResourceModel()
											tagAnnotationchildAttributeValue := childClassDetailsFvRsScopeFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue {
												if childAttributeName == "key" {
													TagAnnotationFvRsScopeFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagAnnotationFvRsScopeFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagAnnotationFvRsScopeFvESgList = append(TagAnnotationFvRsScopeFvESgList, TagAnnotationFvRsScopeFvESg)
										}
										if childClassNameFvRsScopeFvESg == "tagTag" {
											TagTagFvRsScopeFvESg := getEmptyTagTagFvRsScopeFvESgResourceModel()
											tagTagchildAttributeValue := childClassDetailsFvRsScopeFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagTagchildAttributeValue {
												if childAttributeName == "key" {
													TagTagFvRsScopeFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagTagFvRsScopeFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagTagFvRsScopeFvESgList = append(TagTagFvRsScopeFvESgList, TagTagFvRsScopeFvESg)
										}
									}
								}
							}
							TagAnnotationFvRsScopeFvESgSet, _ := types.SetValueFrom(ctx, TagAnnotationFvRsScopeFvESgType, TagAnnotationFvRsScopeFvESgList)
							FvRsScopeFvESg.TagAnnotation = TagAnnotationFvRsScopeFvESgSet
							TagTagFvRsScopeFvESgSet, _ := types.SetValueFrom(ctx, TagTagFvRsScopeFvESgType, TagTagFvRsScopeFvESgList)
							FvRsScopeFvESg.TagTag = TagTagFvRsScopeFvESgSet
							FvRsScopeFvESgList = append(FvRsScopeFvESgList, FvRsScopeFvESg)
						}
						if childClassName == "fvRsSecInherited" {
							FvRsSecInheritedFvESg := getEmptyFvRsSecInheritedFvESgResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "annotation" {
									FvRsSecInheritedFvESg.Annotation = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "tDn" {
									FvRsSecInheritedFvESg.TDn = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationFvRsSecInheritedFvESgList := make([]TagAnnotationFvRsSecInheritedFvESgResourceModel, 0)
							TagTagFvRsSecInheritedFvESgList := make([]TagTagFvRsSecInheritedFvESgResourceModel, 0)
							childrenOfFvRsSecInheritedFvESg, childrenOfFvRsSecInheritedFvESgExist := childClassDetails.(map[string]interface{})["children"]
							if childrenOfFvRsSecInheritedFvESgExist {
								for _, childFvRsSecInheritedFvESg := range childrenOfFvRsSecInheritedFvESg.([]interface{}) {
									for childClassNameFvRsSecInheritedFvESg, childClassDetailsFvRsSecInheritedFvESg := range childFvRsSecInheritedFvESg.(map[string]interface{}) {
										if childClassNameFvRsSecInheritedFvESg == "tagAnnotation" {
											TagAnnotationFvRsSecInheritedFvESg := getEmptyTagAnnotationFvRsSecInheritedFvESgResourceModel()
											tagAnnotationchildAttributeValue := childClassDetailsFvRsSecInheritedFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue {
												if childAttributeName == "key" {
													TagAnnotationFvRsSecInheritedFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagAnnotationFvRsSecInheritedFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagAnnotationFvRsSecInheritedFvESgList = append(TagAnnotationFvRsSecInheritedFvESgList, TagAnnotationFvRsSecInheritedFvESg)
										}
										if childClassNameFvRsSecInheritedFvESg == "tagTag" {
											TagTagFvRsSecInheritedFvESg := getEmptyTagTagFvRsSecInheritedFvESgResourceModel()
											tagTagchildAttributeValue := childClassDetailsFvRsSecInheritedFvESg.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagTagchildAttributeValue {
												if childAttributeName == "key" {
													TagTagFvRsSecInheritedFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagTagFvRsSecInheritedFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagTagFvRsSecInheritedFvESgList = append(TagTagFvRsSecInheritedFvESgList, TagTagFvRsSecInheritedFvESg)
										}
									}
								}
							}
							TagAnnotationFvRsSecInheritedFvESgSet, _ := types.SetValueFrom(ctx, TagAnnotationFvRsSecInheritedFvESgType, TagAnnotationFvRsSecInheritedFvESgList)
							FvRsSecInheritedFvESg.TagAnnotation = TagAnnotationFvRsSecInheritedFvESgSet
							TagTagFvRsSecInheritedFvESgSet, _ := types.SetValueFrom(ctx, TagTagFvRsSecInheritedFvESgType, TagTagFvRsSecInheritedFvESgList)
							FvRsSecInheritedFvESg.TagTag = TagTagFvRsSecInheritedFvESgSet
							FvRsSecInheritedFvESgList = append(FvRsSecInheritedFvESgList, FvRsSecInheritedFvESg)
						}
						if childClassName == "tagAnnotation" {
							TagAnnotationFvESg := getEmptyTagAnnotationFvESgResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "key" {
									TagAnnotationFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "value" {
									TagAnnotationFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationFvESgList = append(TagAnnotationFvESgList, TagAnnotationFvESg)
						}
						if childClassName == "tagTag" {
							TagTagFvESg := getEmptyTagTagFvESgResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "key" {
									TagTagFvESg.Key = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "value" {
									TagTagFvESg.Value = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagTagFvESgList = append(TagTagFvESgList, TagTagFvESg)
						}
					}
				}
			}
			fvRsConsSet, _ := types.SetValueFrom(ctx, readData.FvRsCons.ElementType(ctx), FvRsConsFvESgList)
			readData.FvRsCons = fvRsConsSet
			fvRsConsIfSet, _ := types.SetValueFrom(ctx, readData.FvRsConsIf.ElementType(ctx), FvRsConsIfFvESgList)
			readData.FvRsConsIf = fvRsConsIfSet
			fvRsIntraEpgSet, _ := types.SetValueFrom(ctx, readData.FvRsIntraEpg.ElementType(ctx), FvRsIntraEpgFvESgList)
			readData.FvRsIntraEpg = fvRsIntraEpgSet
			fvRsProvSet, _ := types.SetValueFrom(ctx, readData.FvRsProv.ElementType(ctx), FvRsProvFvESgList)
			readData.FvRsProv = fvRsProvSet
			if len(FvRsScopeFvESgList) == 1 {
				fvRsScopeObject, _ := types.ObjectValueFrom(ctx, FvRsScopeFvESgType, FvRsScopeFvESgList[0])
				readData.FvRsScope = fvRsScopeObject
			} else {
				fvRsScopeObject, _ := types.ObjectValueFrom(ctx, FvRsScopeFvESgType, getEmptyFvRsScopeFvESgResourceModel())
				readData.FvRsScope = fvRsScopeObject
			}
			fvRsSecInheritedSet, _ := types.SetValueFrom(ctx, readData.FvRsSecInherited.ElementType(ctx), FvRsSecInheritedFvESgList)
			readData.FvRsSecInherited = fvRsSecInheritedSet
			tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationFvESgList)
			readData.TagAnnotation = tagAnnotationSet
			tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagFvESgList)
			readData.TagTag = tagTagSet
			setFvESgLegacyAttributes(ctx, diags, readData, data, classReadInfo)
		} else {
			diags.AddError(
				"too many results in response",
				fmt.Sprintf("%v matches returned for class 'fvESg'. Please report this issue to the provider developers.", len(classReadInfo)),
			)
		}
	} else {
		readData.Id = basetypes.NewStringNull()
	}
	*data = *readData
}

func getFvESgRn(ctx context.Context, data *FvESgResourceModel) string {
	return fmt.Sprintf("esg-%s", data.Name.ValueString())
}

func setFvESgParentDn(ctx context.Context, dn string, data *FvESgResourceModel) {
	bracketIndex := 0
	rnIndex := 0
	for i := len(dn) - 1; i >= 0; i-- {
		if string(dn[i]) == "]" {
			bracketIndex = bracketIndex + 1
		} else if string(dn[i]) == "[" {
			bracketIndex = bracketIndex - 1
		} else if string(dn[i]) == "/" && bracketIndex == 0 {
			rnIndex = i
			break
		}
	}
	data.ParentDn = basetypes.NewStringValue(dn[:rnIndex])
}

func setFvESgId(ctx context.Context, data *FvESgResourceModel) {
	rn := getFvESgRn(ctx, data)
	data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn))
}

func getFvESgFvRsConsChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvESgResourceModel, fvRsConsFvESgPlan, fvRsConsFvESgState []FvRsConsFvESgResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.FvRsCons.IsNull() && !data.FvRsCons.IsUnknown() {
		fvRsConsIdentifiers := []FvRsConsIdentifier{}
		for _, fvRsConsFvESg := range fvRsConsFvESgPlan {
			FvRsConsFvESgChildren := make([]map[string]interface{}, 0)
			childMap := NewAciObject()
			if !fvRsConsFvESg.Annotation.IsNull() && !fvRsConsFvESg.Annotation.IsUnknown() {
				childMap.Attributes["annotation"] = fvRsConsFvESg.Annotation.ValueString()
			} else {
				childMap.Attributes["annotation"] = globalAnnotation
			}
			if !fvRsConsFvESg.Prio.IsNull() && !fvRsConsFvESg.Prio.IsUnknown() {
				childMap.Attributes["prio"] = fvRsConsFvESg.Prio.ValueString()
			}
			if !fvRsConsFvESg.TnVzBrCPName.IsNull() && !fvRsConsFvESg.TnVzBrCPName.IsUnknown() {
				childMap.Attributes["tnVzBrCPName"] = fvRsConsFvESg.TnVzBrCPName.ValueString()
			}

			var tagAnnotationFvRsConsFvESgPlan, tagAnnotationFvRsConsFvESgState []TagAnnotationFvRsConsFvESgResourceModel
			fvRsConsFvESg.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsConsFvESgPlan, false)
			for _, tagAnnotationFvRsConsFvESgstate := range fvRsConsFvESgState {
				tagAnnotationFvRsConsFvESgstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsConsFvESgState, false)
			}
			if !fvRsConsFvESg.TagAnnotation.IsNull() && !fvRsConsFvESg.TagAnnotation.IsUnknown() {
				tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
				for _, tagAnnotationFvRsConsFvESg := range tagAnnotationFvRsConsFvESgPlan {
					tagAnnotationFvRsConsFvESgChildMap := NewAciObject()
					if !tagAnnotationFvRsConsFvESg.Key.IsNull() && !tagAnnotationFvRsConsFvESg.Key.IsUnknown() {
						tagAnnotationFvRsConsFvESgChildMap.Attributes["key"] = tagAnnotationFvRsConsFvESg.Key.ValueString()
					}
					if !tagAnnotationFvRsConsFvESg.Value.IsNull() && !tagAnnotationFvRsConsFvESg.Value.IsUnknown() {
						tagAnnotationFvRsConsFvESgChildMap.Attributes["value"] = tagAnnotationFvRsConsFvESg.Value.ValueString()
					}
					FvRsConsFvESgChildren = append(FvRsConsFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsConsFvESgChildMap})
					tagAnnotationIdentifier := TagAnnotationIdentifier{}
					tagAnnotationIdentifier.Key = tagAnnotationFvRsConsFvESg.Key
					tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
				}
				for _, tagAnnotationFvRsConsFvESg := range tagAnnotationFvRsConsFvESgState {
					delete := true
					for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
						if tagAnnotationIdentifier.Key == tagAnnotationFvRsConsFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagAnnotationFvRsConsFvESgChildMapForDelete := NewAciObject()
						tagAnnotationFvRsConsFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagAnnotationFvRsConsFvESgChildMapForDelete.Attributes["key"] = tagAnnotationFvRsConsFvESg.Key.ValueString()
						FvRsConsFvESgChildren = append(FvRsConsFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsConsFvESgChildMapForDelete})
					}
				}
			}

			var tagTagFvRsConsFvESgPlan, tagTagFvRsConsFvESgState []TagTagFvRsConsFvESgResourceModel
			fvRsConsFvESg.TagTag.ElementsAs(ctx, &tagTagFvRsConsFvESgPlan, false)
			for _, tagTagFvRsConsFvESgstate := range fvRsConsFvESgState {
				tagTagFvRsConsFvESgstate.TagTag.ElementsAs(ctx, &tagTagFvRsConsFvESgState, false)
			}
			if !fvRsConsFvESg.TagTag.IsNull() && !fvRsConsFvESg.TagTag.IsUnknown() {
				tagTagIdentifiers := []TagTagIdentifier{}
				for _, tagTagFvRsConsFvESg := range tagTagFvRsConsFvESgPlan {
					tagTagFvRsConsFvESgChildMap := NewAciObject()
					if !tagTagFvRsConsFvESg.Key.IsNull() && !tagTagFvRsConsFvESg.Key.IsUnknown() {
						tagTagFvRsConsFvESgChildMap.Attributes["key"] = tagTagFvRsConsFvESg.Key.ValueString()
					}
					if !tagTagFvRsConsFvESg.Value.IsNull() && !tagTagFvRsConsFvESg.Value.IsUnknown() {
						tagTagFvRsConsFvESgChildMap.Attributes["value"] = tagTagFvRsConsFvESg.Value.ValueString()
					}
					FvRsConsFvESgChildren = append(FvRsConsFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsConsFvESgChildMap})
					tagTagIdentifier := TagTagIdentifier{}
					tagTagIdentifier.Key = tagTagFvRsConsFvESg.Key
					tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
				}
				for _, tagTagFvRsConsFvESg := range tagTagFvRsConsFvESgState {
					delete := true
					for _, tagTagIdentifier := range tagTagIdentifiers {
						if tagTagIdentifier.Key == tagTagFvRsConsFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagTagFvRsConsFvESgChildMapForDelete := NewAciObject()
						tagTagFvRsConsFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagTagFvRsConsFvESgChildMapForDelete.Attributes["key"] = tagTagFvRsConsFvESg.Key.ValueString()
						FvRsConsFvESgChildren = append(FvRsConsFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsConsFvESgChildMapForDelete})
					}
				}
			}
			childMap.Children = FvRsConsFvESgChildren
			childPayloads = append(childPayloads, map[string]interface{}{"fvRsCons": childMap})
			fvRsConsIdentifier := FvRsConsIdentifier{}
			fvRsConsIdentifier.TnVzBrCPName = fvRsConsFvESg.TnVzBrCPName
			fvRsConsIdentifiers = append(fvRsConsIdentifiers, fvRsConsIdentifier)
		}
		for _, fvRsCons := range fvRsConsFvESgState {
			delete := true
			for _, fvRsConsIdentifier := range fvRsConsIdentifiers {
				if fvRsConsIdentifier.TnVzBrCPName == fvRsCons.TnVzBrCPName {
					delete = false
					break
				}
			}
			if delete {
				fvRsConsChildMapForDelete := NewAciObject()
				fvRsConsChildMapForDelete.Attributes["status"] = "deleted"
				fvRsConsChildMapForDelete.Attributes["tnVzBrCPName"] = fvRsCons.TnVzBrCPName.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"fvRsCons": fvRsConsChildMapForDelete})
			}
		}
	} else {
		data.FvRsCons = types.SetNull(data.FvRsCons.ElementType(ctx))
	}

	return childPayloads
}

func getFvESgFvRsConsIfChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvESgResourceModel, fvRsConsIfFvESgPlan, fvRsConsIfFvESgState []FvRsConsIfFvESgResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.FvRsConsIf.IsNull() && !data.FvRsConsIf.IsUnknown() {
		fvRsConsIfIdentifiers := []FvRsConsIfIdentifier{}
		for _, fvRsConsIfFvESg := range fvRsConsIfFvESgPlan {
			FvRsConsIfFvESgChildren := make([]map[string]interface{}, 0)
			childMap := NewAciObject()
			if !fvRsConsIfFvESg.Annotation.IsNull() && !fvRsConsIfFvESg.Annotation.IsUnknown() {
				childMap.Attributes["annotation"] = fvRsConsIfFvESg.Annotation.ValueString()
			} else {
				childMap.Attributes["annotation"] = globalAnnotation
			}
			if !fvRsConsIfFvESg.Prio.IsNull() && !fvRsConsIfFvESg.Prio.IsUnknown() {
				childMap.Attributes["prio"] = fvRsConsIfFvESg.Prio.ValueString()
			}
			if !fvRsConsIfFvESg.TnVzCPIfName.IsNull() && !fvRsConsIfFvESg.TnVzCPIfName.IsUnknown() {
				childMap.Attributes["tnVzCPIfName"] = fvRsConsIfFvESg.TnVzCPIfName.ValueString()
			}

			var tagAnnotationFvRsConsIfFvESgPlan, tagAnnotationFvRsConsIfFvESgState []TagAnnotationFvRsConsIfFvESgResourceModel
			fvRsConsIfFvESg.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsConsIfFvESgPlan, false)
			for _, tagAnnotationFvRsConsIfFvESgstate := range fvRsConsIfFvESgState {
				tagAnnotationFvRsConsIfFvESgstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsConsIfFvESgState, false)
			}
			if !fvRsConsIfFvESg.TagAnnotation.IsNull() && !fvRsConsIfFvESg.TagAnnotation.IsUnknown() {
				tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
				for _, tagAnnotationFvRsConsIfFvESg := range tagAnnotationFvRsConsIfFvESgPlan {
					tagAnnotationFvRsConsIfFvESgChildMap := NewAciObject()
					if !tagAnnotationFvRsConsIfFvESg.Key.IsNull() && !tagAnnotationFvRsConsIfFvESg.Key.IsUnknown() {
						tagAnnotationFvRsConsIfFvESgChildMap.Attributes["key"] = tagAnnotationFvRsConsIfFvESg.Key.ValueString()
					}
					if !tagAnnotationFvRsConsIfFvESg.Value.IsNull() && !tagAnnotationFvRsConsIfFvESg.Value.IsUnknown() {
						tagAnnotationFvRsConsIfFvESgChildMap.Attributes["value"] = tagAnnotationFvRsConsIfFvESg.Value.ValueString()
					}
					FvRsConsIfFvESgChildren = append(FvRsConsIfFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsConsIfFvESgChildMap})
					tagAnnotationIdentifier := TagAnnotationIdentifier{}
					tagAnnotationIdentifier.Key = tagAnnotationFvRsConsIfFvESg.Key
					tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
				}
				for _, tagAnnotationFvRsConsIfFvESg := range tagAnnotationFvRsConsIfFvESgState {
					delete := true
					for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
						if tagAnnotationIdentifier.Key == tagAnnotationFvRsConsIfFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagAnnotationFvRsConsIfFvESgChildMapForDelete := NewAciObject()
						tagAnnotationFvRsConsIfFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagAnnotationFvRsConsIfFvESgChildMapForDelete.Attributes["key"] = tagAnnotationFvRsConsIfFvESg.Key.ValueString()
						FvRsConsIfFvESgChildren = append(FvRsConsIfFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsConsIfFvESgChildMapForDelete})
					}
				}
			}

			var tagTagFvRsConsIfFvESgPlan, tagTagFvRsConsIfFvESgState []TagTagFvRsConsIfFvESgResourceModel
			fvRsConsIfFvESg.TagTag.ElementsAs(ctx, &tagTagFvRsConsIfFvESgPlan, false)
			for _, tagTagFvRsConsIfFvESgstate := range fvRsConsIfFvESgState {
				tagTagFvRsConsIfFvESgstate.TagTag.ElementsAs(ctx, &tagTagFvRsConsIfFvESgState, false)
			}
			if !fvRsConsIfFvESg.TagTag.IsNull() && !fvRsConsIfFvESg.TagTag.IsUnknown() {
				tagTagIdentifiers := []TagTagIdentifier{}
				for _, tagTagFvRsConsIfFvESg := range tagTagFvRsConsIfFvESgPlan {
					tagTagFvRsConsIfFvESgChildMap := NewAciObject()
					if !tagTagFvRsConsIfFvESg.Key.IsNull() && !tagTagFvRsConsIfFvESg.Key.IsUnknown() {
						tagTagFvRsConsIfFvESgChildMap.Attributes["key"] = tagTagFvRsConsIfFvESg.Key.ValueString()
					}
					if !tagTagFvRsConsIfFvESg.Value.IsNull() && !tagTagFvRsConsIfFvESg.Value.IsUnknown() {
						tagTagFvRsConsIfFvESgChildMap.Attributes["value"] = tagTagFvRsConsIfFvESg.Value.ValueString()
					}
					FvRsConsIfFvESgChildren = append(FvRsConsIfFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsConsIfFvESgChildMap})
					tagTagIdentifier := TagTagIdentifier{}
					tagTagIdentifier.Key = tagTagFvRsConsIfFvESg.Key
					tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
				}
				for _, tagTagFvRsConsIfFvESg := range tagTagFvRsConsIfFvESgState {
					delete := true
					for _, tagTagIdentifier := range tagTagIdentifiers {
						if tagTagIdentifier.Key == tagTagFvRsConsIfFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagTagFvRsConsIfFvESgChildMapForDelete := NewAciObject()
						tagTagFvRsConsIfFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagTagFvRsConsIfFvESgChildMapForDelete.Attributes["key"] = tagTagFvRsConsIfFvESg.Key.ValueString()
						FvRsConsIfFvESgChildren = append(FvRsConsIfFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsConsIfFvESgChildMapForDelete})
					}
				}
			}
			childMap.Children = FvRsConsIfFvESgChildren
			childPayloads = append(childPayloads, map[string]interface{}{"fvRsConsIf": childMap})
			fvRsConsIfIdentifier := FvRsConsIfIdentifier{}
			fvRsConsIfIdentifier.TnVzCPIfName = fvRsConsIfFvESg.TnVzCPIfName
			fvRsConsIfIdentifiers = append(fvRsConsIfIdentifiers, fvRsConsIfIdentifier)
		}
		for _, fvRsConsIf := range fvRsConsIfFvESgState {
			delete := true
			for _, fvRsConsIfIdentifier := range fvRsConsIfIdentifiers {
				if fvRsConsIfIdentifier.TnVzCPIfName == fvRsConsIf.TnVzCPIfName {
					delete = false
					break
				}
			}
			if delete {
				fvRsConsIfChildMapForDelete := NewAciObject()
				fvRsConsIfChildMapForDelete.Attributes["status"] = "deleted"
				fvRsConsIfChildMapForDelete.Attributes["tnVzCPIfName"] = fvRsConsIf.TnVzCPIfName.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"fvRsConsIf": fvRsConsIfChildMapForDelete})
			}
		}
	} else {
		data.FvRsConsIf = types.SetNull(data.FvRsConsIf.ElementType(ctx))
	}

	return childPayloads
}

func getFvESgFvRsIntraEpgChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvESgResourceModel, fvRsIntraEpgFvESgPlan, fvRsIntraEpgFvESgState []FvRsIntraEpgFvESgResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.FvRsIntraEpg.IsNull() && !data.FvRsIntraEpg.IsUnknown() {
		fvRsIntraEpgIdentifiers := []FvRsIntraEpgIdentifier{}
		for _, fvRsIntraEpgFvESg := range fvRsIntraEpgFvESgPlan {
			FvRsIntraEpgFvESgChildren := make([]map[string]interface{}, 0)
			childMap := NewAciObject()
			if !fvRsIntraEpgFvESg.Annotation.IsNull() && !fvRsIntraEpgFvESg.Annotation.IsUnknown() {
				childMap.Attributes["annotation"] = fvRsIntraEpgFvESg.Annotation.ValueString()
			} else {
				childMap.Attributes["annotation"] = globalAnnotation
			}
			if !fvRsIntraEpgFvESg.TnVzBrCPName.IsNull() && !fvRsIntraEpgFvESg.TnVzBrCPName.IsUnknown() {
				childMap.Attributes["tnVzBrCPName"] = fvRsIntraEpgFvESg.TnVzBrCPName.ValueString()
			}

			var tagAnnotationFvRsIntraEpgFvESgPlan, tagAnnotationFvRsIntraEpgFvESgState []TagAnnotationFvRsIntraEpgFvESgResourceModel
			fvRsIntraEpgFvESg.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsIntraEpgFvESgPlan, false)
			for _, tagAnnotationFvRsIntraEpgFvESgstate := range fvRsIntraEpgFvESgState {
				tagAnnotationFvRsIntraEpgFvESgstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsIntraEpgFvESgState, false)
			}
			if !fvRsIntraEpgFvESg.TagAnnotation.IsNull() && !fvRsIntraEpgFvESg.TagAnnotation.IsUnknown() {
				tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
				for _, tagAnnotationFvRsIntraEpgFvESg := range tagAnnotationFvRsIntraEpgFvESgPlan {
					tagAnnotationFvRsIntraEpgFvESgChildMap := NewAciObject()
					if !tagAnnotationFvRsIntraEpgFvESg.Key.IsNull() && !tagAnnotationFvRsIntraEpgFvESg.Key.IsUnknown() {
						tagAnnotationFvRsIntraEpgFvESgChildMap.Attributes["key"] = tagAnnotationFvRsIntraEpgFvESg.Key.ValueString()
					}
					if !tagAnnotationFvRsIntraEpgFvESg.Value.IsNull() && !tagAnnotationFvRsIntraEpgFvESg.Value.IsUnknown() {
						tagAnnotationFvRsIntraEpgFvESgChildMap.Attributes["value"] = tagAnnotationFvRsIntraEpgFvESg.Value.ValueString()
					}
					FvRsIntraEpgFvESgChildren = append(FvRsIntraEpgFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsIntraEpgFvESgChildMap})
					tagAnnotationIdentifier := TagAnnotationIdentifier{}
					tagAnnotationIdentifier.Key = tagAnnotationFvRsIntraEpgFvESg.Key
					tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
				}
				for _, tagAnnotationFvRsIntraEpgFvESg := range tagAnnotationFvRsIntraEpgFvESgState {
					delete := true
					for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
						if tagAnnotationIdentifier.Key == tagAnnotationFvRsIntraEpgFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagAnnotationFvRsIntraEpgFvESgChildMapForDelete := NewAciObject()
						tagAnnotationFvRsIntraEpgFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagAnnotationFvRsIntraEpgFvESgChildMapForDelete.Attributes["key"] = tagAnnotationFvRsIntraEpgFvESg.Key.ValueString()
						FvRsIntraEpgFvESgChildren = append(FvRsIntraEpgFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsIntraEpgFvESgChildMapForDelete})
					}
				}
			}

			var tagTagFvRsIntraEpgFvESgPlan, tagTagFvRsIntraEpgFvESgState []TagTagFvRsIntraEpgFvESgResourceModel
			fvRsIntraEpgFvESg.TagTag.ElementsAs(ctx, &tagTagFvRsIntraEpgFvESgPlan, false)
			for _, tagTagFvRsIntraEpgFvESgstate := range fvRsIntraEpgFvESgState {
				tagTagFvRsIntraEpgFvESgstate.TagTag.ElementsAs(ctx, &tagTagFvRsIntraEpgFvESgState, false)
			}
			if !fvRsIntraEpgFvESg.TagTag.IsNull() && !fvRsIntraEpgFvESg.TagTag.IsUnknown() {
				tagTagIdentifiers := []TagTagIdentifier{}
				for _, tagTagFvRsIntraEpgFvESg := range tagTagFvRsIntraEpgFvESgPlan {
					tagTagFvRsIntraEpgFvESgChildMap := NewAciObject()
					if !tagTagFvRsIntraEpgFvESg.Key.IsNull() && !tagTagFvRsIntraEpgFvESg.Key.IsUnknown() {
						tagTagFvRsIntraEpgFvESgChildMap.Attributes["key"] = tagTagFvRsIntraEpgFvESg.Key.ValueString()
					}
					if !tagTagFvRsIntraEpgFvESg.Value.IsNull() && !tagTagFvRsIntraEpgFvESg.Value.IsUnknown() {
						tagTagFvRsIntraEpgFvESgChildMap.Attributes["value"] = tagTagFvRsIntraEpgFvESg.Value.ValueString()
					}
					FvRsIntraEpgFvESgChildren = append(FvRsIntraEpgFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsIntraEpgFvESgChildMap})
					tagTagIdentifier := TagTagIdentifier{}
					tagTagIdentifier.Key = tagTagFvRsIntraEpgFvESg.Key
					tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
				}
				for _, tagTagFvRsIntraEpgFvESg := range tagTagFvRsIntraEpgFvESgState {
					delete := true
					for _, tagTagIdentifier := range tagTagIdentifiers {
						if tagTagIdentifier.Key == tagTagFvRsIntraEpgFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagTagFvRsIntraEpgFvESgChildMapForDelete := NewAciObject()
						tagTagFvRsIntraEpgFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagTagFvRsIntraEpgFvESgChildMapForDelete.Attributes["key"] = tagTagFvRsIntraEpgFvESg.Key.ValueString()
						FvRsIntraEpgFvESgChildren = append(FvRsIntraEpgFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsIntraEpgFvESgChildMapForDelete})
					}
				}
			}
			childMap.Children = FvRsIntraEpgFvESgChildren
			childPayloads = append(childPayloads, map[string]interface{}{"fvRsIntraEpg": childMap})
			fvRsIntraEpgIdentifier := FvRsIntraEpgIdentifier{}
			fvRsIntraEpgIdentifier.TnVzBrCPName = fvRsIntraEpgFvESg.TnVzBrCPName
			fvRsIntraEpgIdentifiers = append(fvRsIntraEpgIdentifiers, fvRsIntraEpgIdentifier)
		}
		for _, fvRsIntraEpg := range fvRsIntraEpgFvESgState {
			delete := true
			for _, fvRsIntraEpgIdentifier := range fvRsIntraEpgIdentifiers {
				if fvRsIntraEpgIdentifier.TnVzBrCPName == fvRsIntraEpg.TnVzBrCPName {
					delete = false
					break
				}
			}
			if delete {
				fvRsIntraEpgChildMapForDelete := NewAciObject()
				fvRsIntraEpgChildMapForDelete.Attributes["status"] = "deleted"
				fvRsIntraEpgChildMapForDelete.Attributes["tnVzBrCPName"] = fvRsIntraEpg.TnVzBrCPName.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"fvRsIntraEpg": fvRsIntraEpgChildMapForDelete})
			}
		}
	} else {
		data.FvRsIntraEpg = types.SetNull(data.FvRsIntraEpg.ElementType(ctx))
	}

	return childPayloads
}

func getFvESgFvRsProvChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvESgResourceModel, fvRsProvFvESgPlan, fvRsProvFvESgState []FvRsProvFvESgResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.FvRsProv.IsNull() && !data.FvRsProv.IsUnknown() {
		fvRsProvIdentifiers := []FvRsProvIdentifier{}
		for _, fvRsProvFvESg := range fvRsProvFvESgPlan {
			FvRsProvFvESgChildren := make([]map[string]interface{}, 0)
			childMap := NewAciObject()
			if !fvRsProvFvESg.Annotation.IsNull() && !fvRsProvFvESg.Annotation.IsUnknown() {
				childMap.Attributes["annotation"] = fvRsProvFvESg.Annotation.ValueString()
			} else {
				childMap.Attributes["annotation"] = globalAnnotation
			}
			if !fvRsProvFvESg.MatchT.IsNull() && !fvRsProvFvESg.MatchT.IsUnknown() {
				childMap.Attributes["matchT"] = fvRsProvFvESg.MatchT.ValueString()
			}
			if !fvRsProvFvESg.Prio.IsNull() && !fvRsProvFvESg.Prio.IsUnknown() {
				childMap.Attributes["prio"] = fvRsProvFvESg.Prio.ValueString()
			}
			if !fvRsProvFvESg.TnVzBrCPName.IsNull() && !fvRsProvFvESg.TnVzBrCPName.IsUnknown() {
				childMap.Attributes["tnVzBrCPName"] = fvRsProvFvESg.TnVzBrCPName.ValueString()
			}

			var tagAnnotationFvRsProvFvESgPlan, tagAnnotationFvRsProvFvESgState []TagAnnotationFvRsProvFvESgResourceModel
			fvRsProvFvESg.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsProvFvESgPlan, false)
			for _, tagAnnotationFvRsProvFvESgstate := range fvRsProvFvESgState {
				tagAnnotationFvRsProvFvESgstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsProvFvESgState, false)
			}
			if !fvRsProvFvESg.TagAnnotation.IsNull() && !fvRsProvFvESg.TagAnnotation.IsUnknown() {
				tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
				for _, tagAnnotationFvRsProvFvESg := range tagAnnotationFvRsProvFvESgPlan {
					tagAnnotationFvRsProvFvESgChildMap := NewAciObject()
					if !tagAnnotationFvRsProvFvESg.Key.IsNull() && !tagAnnotationFvRsProvFvESg.Key.IsUnknown() {
						tagAnnotationFvRsProvFvESgChildMap.Attributes["key"] = tagAnnotationFvRsProvFvESg.Key.ValueString()
					}
					if !tagAnnotationFvRsProvFvESg.Value.IsNull() && !tagAnnotationFvRsProvFvESg.Value.IsUnknown() {
						tagAnnotationFvRsProvFvESgChildMap.Attributes["value"] = tagAnnotationFvRsProvFvESg.Value.ValueString()
					}
					FvRsProvFvESgChildren = append(FvRsProvFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsProvFvESgChildMap})
					tagAnnotationIdentifier := TagAnnotationIdentifier{}
					tagAnnotationIdentifier.Key = tagAnnotationFvRsProvFvESg.Key
					tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
				}
				for _, tagAnnotationFvRsProvFvESg := range tagAnnotationFvRsProvFvESgState {
					delete := true
					for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
						if tagAnnotationIdentifier.Key == tagAnnotationFvRsProvFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagAnnotationFvRsProvFvESgChildMapForDelete := NewAciObject()
						tagAnnotationFvRsProvFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagAnnotationFvRsProvFvESgChildMapForDelete.Attributes["key"] = tagAnnotationFvRsProvFvESg.Key.ValueString()
						FvRsProvFvESgChildren = append(FvRsProvFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsProvFvESgChildMapForDelete})
					}
				}
			}

			var tagTagFvRsProvFvESgPlan, tagTagFvRsProvFvESgState []TagTagFvRsProvFvESgResourceModel
			fvRsProvFvESg.TagTag.ElementsAs(ctx, &tagTagFvRsProvFvESgPlan, false)
			for _, tagTagFvRsProvFvESgstate := range fvRsProvFvESgState {
				tagTagFvRsProvFvESgstate.TagTag.ElementsAs(ctx, &tagTagFvRsProvFvESgState, false)
			}
			if !fvRsProvFvESg.TagTag.IsNull() && !fvRsProvFvESg.TagTag.IsUnknown() {
				tagTagIdentifiers := []TagTagIdentifier{}
				for _, tagTagFvRsProvFvESg := range tagTagFvRsProvFvESgPlan {
					tagTagFvRsProvFvESgChildMap := NewAciObject()
					if !tagTagFvRsProvFvESg.Key.IsNull() && !tagTagFvRsProvFvESg.Key.IsUnknown() {
						tagTagFvRsProvFvESgChildMap.Attributes["key"] = tagTagFvRsProvFvESg.Key.ValueString()
					}
					if !tagTagFvRsProvFvESg.Value.IsNull() && !tagTagFvRsProvFvESg.Value.IsUnknown() {
						tagTagFvRsProvFvESgChildMap.Attributes["value"] = tagTagFvRsProvFvESg.Value.ValueString()
					}
					FvRsProvFvESgChildren = append(FvRsProvFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsProvFvESgChildMap})
					tagTagIdentifier := TagTagIdentifier{}
					tagTagIdentifier.Key = tagTagFvRsProvFvESg.Key
					tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
				}
				for _, tagTagFvRsProvFvESg := range tagTagFvRsProvFvESgState {
					delete := true
					for _, tagTagIdentifier := range tagTagIdentifiers {
						if tagTagIdentifier.Key == tagTagFvRsProvFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagTagFvRsProvFvESgChildMapForDelete := NewAciObject()
						tagTagFvRsProvFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagTagFvRsProvFvESgChildMapForDelete.Attributes["key"] = tagTagFvRsProvFvESg.Key.ValueString()
						FvRsProvFvESgChildren = append(FvRsProvFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsProvFvESgChildMapForDelete})
					}
				}
			}
			childMap.Children = FvRsProvFvESgChildren
			childPayloads = append(childPayloads, map[string]interface{}{"fvRsProv": childMap})
			fvRsProvIdentifier := FvRsProvIdentifier{}
			fvRsProvIdentifier.TnVzBrCPName = fvRsProvFvESg.TnVzBrCPName
			fvRsProvIdentifiers = append(fvRsProvIdentifiers, fvRsProvIdentifier)
		}
		for _, fvRsProv := range fvRsProvFvESgState {
			delete := true
			for _, fvRsProvIdentifier := range fvRsProvIdentifiers {
				if fvRsProvIdentifier.TnVzBrCPName == fvRsProv.TnVzBrCPName {
					delete = false
					break
				}
			}
			if delete {
				fvRsProvChildMapForDelete := NewAciObject()
				fvRsProvChildMapForDelete.Attributes["status"] = "deleted"
				fvRsProvChildMapForDelete.Attributes["tnVzBrCPName"] = fvRsProv.TnVzBrCPName.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"fvRsProv": fvRsProvChildMapForDelete})
			}
		}
	} else {
		data.FvRsProv = types.SetNull(data.FvRsProv.ElementType(ctx))
	}

	return childPayloads
}

func getFvESgFvRsScopeChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvESgResourceModel, fvRsScopeFvESgPlan, fvRsScopeFvESgState FvRsScopeFvESgResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.FvRsScope.IsNull() && !data.FvRsScope.IsUnknown() {
		FvRsScopeFvESgChildren := make([]map[string]interface{}, 0)
		childMap := NewAciObject()
		if !IsEmptySingleNestedAttribute(data.FvRsScope.Attributes()) {
			if !fvRsScopeFvESgPlan.Annotation.IsUnknown() && !fvRsScopeFvESgPlan.Annotation.IsNull() {
				childMap.Attributes["annotation"] = fvRsScopeFvESgPlan.Annotation.ValueString()
			} else {
				childMap.Attributes["annotation"] = globalAnnotation
			}
			if !fvRsScopeFvESgPlan.TnFvCtxName.IsUnknown() && !fvRsScopeFvESgPlan.TnFvCtxName.IsNull() {
				childMap.Attributes["tnFvCtxName"] = fvRsScopeFvESgPlan.TnFvCtxName.ValueString()
			}

			var tagAnnotationFvRsScopeFvESgPlan, tagAnnotationFvRsScopeFvESgState []TagAnnotationFvRsScopeFvESgResourceModel
			fvRsScopeFvESgPlan.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsScopeFvESgPlan, false)
			if !fvRsScopeFvESgState.TagAnnotation.IsNull() {
				fvRsScopeFvESgState.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsScopeFvESgState, false)
			}
			if !fvRsScopeFvESgPlan.TagAnnotation.IsNull() && !fvRsScopeFvESgPlan.TagAnnotation.IsUnknown() {
				tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
				for _, tagAnnotationFvRsScopeFvESg := range tagAnnotationFvRsScopeFvESgPlan {
					tagAnnotationFvRsScopeFvESgChildMap := NewAciObject()
					if !tagAnnotationFvRsScopeFvESg.Key.IsNull() && !tagAnnotationFvRsScopeFvESg.Key.IsUnknown() {
						tagAnnotationFvRsScopeFvESgChildMap.Attributes["key"] = tagAnnotationFvRsScopeFvESg.Key.ValueString()
					}
					if !tagAnnotationFvRsScopeFvESg.Value.IsNull() && !tagAnnotationFvRsScopeFvESg.Value.IsUnknown() {
						tagAnnotationFvRsScopeFvESgChildMap.Attributes["value"] = tagAnnotationFvRsScopeFvESg.Value.ValueString()
					}
					FvRsScopeFvESgChildren = append(FvRsScopeFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsScopeFvESgChildMap})
					tagAnnotationIdentifier := TagAnnotationIdentifier{}
					tagAnnotationIdentifier.Key = tagAnnotationFvRsScopeFvESg.Key
					tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
				}
				for _, tagAnnotationFvRsScopeFvESg := range tagAnnotationFvRsScopeFvESgState {
					delete := true
					for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
						if tagAnnotationIdentifier.Key == tagAnnotationFvRsScopeFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagAnnotationFvRsScopeFvESgChildMapForDelete := NewAciObject()
						tagAnnotationFvRsScopeFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagAnnotationFvRsScopeFvESgChildMapForDelete.Attributes["key"] = tagAnnotationFvRsScopeFvESg.Key.ValueString()
						FvRsScopeFvESgChildren = append(FvRsScopeFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsScopeFvESgChildMapForDelete})
					}
				}
			}

			var tagTagFvRsScopeFvESgPlan, tagTagFvRsScopeFvESgState []TagTagFvRsScopeFvESgResourceModel
			fvRsScopeFvESgPlan.TagTag.ElementsAs(ctx, &tagTagFvRsScopeFvESgPlan, false)
			if !fvRsScopeFvESgState.TagTag.IsNull() {
				fvRsScopeFvESgState.TagTag.ElementsAs(ctx, &tagTagFvRsScopeFvESgState, false)
			}
			if !fvRsScopeFvESgPlan.TagTag.IsNull() && !fvRsScopeFvESgPlan.TagTag.IsUnknown() {
				tagTagIdentifiers := []TagTagIdentifier{}
				for _, tagTagFvRsScopeFvESg := range tagTagFvRsScopeFvESgPlan {
					tagTagFvRsScopeFvESgChildMap := NewAciObject()
					if !tagTagFvRsScopeFvESg.Key.IsNull() && !tagTagFvRsScopeFvESg.Key.IsUnknown() {
						tagTagFvRsScopeFvESgChildMap.Attributes["key"] = tagTagFvRsScopeFvESg.Key.ValueString()
					}
					if !tagTagFvRsScopeFvESg.Value.IsNull() && !tagTagFvRsScopeFvESg.Value.IsUnknown() {
						tagTagFvRsScopeFvESgChildMap.Attributes["value"] = tagTagFvRsScopeFvESg.Value.ValueString()
					}
					FvRsScopeFvESgChildren = append(FvRsScopeFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsScopeFvESgChildMap})
					tagTagIdentifier := TagTagIdentifier{}
					tagTagIdentifier.Key = tagTagFvRsScopeFvESg.Key
					tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
				}
				for _, tagTagFvRsScopeFvESg := range tagTagFvRsScopeFvESgState {
					delete := true
					for _, tagTagIdentifier := range tagTagIdentifiers {
						if tagTagIdentifier.Key == tagTagFvRsScopeFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagTagFvRsScopeFvESgChildMapForDelete := NewAciObject()
						tagTagFvRsScopeFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagTagFvRsScopeFvESgChildMapForDelete.Attributes["key"] = tagTagFvRsScopeFvESg.Key.ValueString()
						FvRsScopeFvESgChildren = append(FvRsScopeFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsScopeFvESgChildMapForDelete})
					}
				}
			}
			childMap.Children = FvRsScopeFvESgChildren
			childPayloads = append(childPayloads, map[string]interface{}{"fvRsScope": childMap})
		}
	} else {
		FvRsScopeObject, _ := types.ObjectValueFrom(ctx, FvRsScopeFvESgType, getEmptyFvRsScopeFvESgResourceModel())
		data.FvRsScope = FvRsScopeObject
	}

	return childPayloads
}

func getFvESgFvRsSecInheritedChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvESgResourceModel, fvRsSecInheritedFvESgPlan, fvRsSecInheritedFvESgState []FvRsSecInheritedFvESgResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.FvRsSecInherited.IsNull() && !data.FvRsSecInherited.IsUnknown() {
		fvRsSecInheritedIdentifiers := []FvRsSecInheritedIdentifier{}
		for _, fvRsSecInheritedFvESg := range fvRsSecInheritedFvESgPlan {
			FvRsSecInheritedFvESgChildren := make([]map[string]interface{}, 0)
			childMap := NewAciObject()
			if !fvRsSecInheritedFvESg.Annotation.IsNull() && !fvRsSecInheritedFvESg.Annotation.IsUnknown() {
				childMap.Attributes["annotation"] = fvRsSecInheritedFvESg.Annotation.ValueString()
			} else {
				childMap.Attributes["annotation"] = globalAnnotation
			}
			if !fvRsSecInheritedFvESg.TDn.IsNull() && !fvRsSecInheritedFvESg.TDn.IsUnknown() {
				childMap.Attributes["tDn"] = fvRsSecInheritedFvESg.TDn.ValueString()
			}

			var tagAnnotationFvRsSecInheritedFvESgPlan, tagAnnotationFvRsSecInheritedFvESgState []TagAnnotationFvRsSecInheritedFvESgResourceModel
			fvRsSecInheritedFvESg.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsSecInheritedFvESgPlan, false)
			for _, tagAnnotationFvRsSecInheritedFvESgstate := range fvRsSecInheritedFvESgState {
				tagAnnotationFvRsSecInheritedFvESgstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationFvRsSecInheritedFvESgState, false)
			}
			if !fvRsSecInheritedFvESg.TagAnnotation.IsNull() && !fvRsSecInheritedFvESg.TagAnnotation.IsUnknown() {
				tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
				for _, tagAnnotationFvRsSecInheritedFvESg := range tagAnnotationFvRsSecInheritedFvESgPlan {
					tagAnnotationFvRsSecInheritedFvESgChildMap := NewAciObject()
					if !tagAnnotationFvRsSecInheritedFvESg.Key.IsNull() && !tagAnnotationFvRsSecInheritedFvESg.Key.IsUnknown() {
						tagAnnotationFvRsSecInheritedFvESgChildMap.Attributes["key"] = tagAnnotationFvRsSecInheritedFvESg.Key.ValueString()
					}
					if !tagAnnotationFvRsSecInheritedFvESg.Value.IsNull() && !tagAnnotationFvRsSecInheritedFvESg.Value.IsUnknown() {
						tagAnnotationFvRsSecInheritedFvESgChildMap.Attributes["value"] = tagAnnotationFvRsSecInheritedFvESg.Value.ValueString()
					}
					FvRsSecInheritedFvESgChildren = append(FvRsSecInheritedFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsSecInheritedFvESgChildMap})
					tagAnnotationIdentifier := TagAnnotationIdentifier{}
					tagAnnotationIdentifier.Key = tagAnnotationFvRsSecInheritedFvESg.Key
					tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
				}
				for _, tagAnnotationFvRsSecInheritedFvESg := range tagAnnotationFvRsSecInheritedFvESgState {
					delete := true
					for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
						if tagAnnotationIdentifier.Key == tagAnnotationFvRsSecInheritedFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagAnnotationFvRsSecInheritedFvESgChildMapForDelete := NewAciObject()
						tagAnnotationFvRsSecInheritedFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagAnnotationFvRsSecInheritedFvESgChildMapForDelete.Attributes["key"] = tagAnnotationFvRsSecInheritedFvESg.Key.ValueString()
						FvRsSecInheritedFvESgChildren = append(FvRsSecInheritedFvESgChildren, map[string]interface{}{"tagAnnotation": tagAnnotationFvRsSecInheritedFvESgChildMapForDelete})
					}
				}
			}

			var tagTagFvRsSecInheritedFvESgPlan, tagTagFvRsSecInheritedFvESgState []TagTagFvRsSecInheritedFvESgResourceModel
			fvRsSecInheritedFvESg.TagTag.ElementsAs(ctx, &tagTagFvRsSecInheritedFvESgPlan, false)
			for _, tagTagFvRsSecInheritedFvESgstate := range fvRsSecInheritedFvESgState {
				tagTagFvRsSecInheritedFvESgstate.TagTag.ElementsAs(ctx, &tagTagFvRsSecInheritedFvESgState, false)
			}
			if !fvRsSecInheritedFvESg.TagTag.IsNull() && !fvRsSecInheritedFvESg.TagTag.IsUnknown() {
				tagTagIdentifiers := []TagTagIdentifier{}
				for _, tagTagFvRsSecInheritedFvESg := range tagTagFvRsSecInheritedFvESgPlan {
					tagTagFvRsSecInheritedFvESgChildMap := NewAciObject()
					if !tagTagFvRsSecInheritedFvESg.Key.IsNull() && !tagTagFvRsSecInheritedFvESg.Key.IsUnknown() {
						tagTagFvRsSecInheritedFvESgChildMap.Attributes["key"] = tagTagFvRsSecInheritedFvESg.Key.ValueString()
					}
					if !tagTagFvRsSecInheritedFvESg.Value.IsNull() && !tagTagFvRsSecInheritedFvESg.Value.IsUnknown() {
						tagTagFvRsSecInheritedFvESgChildMap.Attributes["value"] = tagTagFvRsSecInheritedFvESg.Value.ValueString()
					}
					FvRsSecInheritedFvESgChildren = append(FvRsSecInheritedFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsSecInheritedFvESgChildMap})
					tagTagIdentifier := TagTagIdentifier{}
					tagTagIdentifier.Key = tagTagFvRsSecInheritedFvESg.Key
					tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
				}
				for _, tagTagFvRsSecInheritedFvESg := range tagTagFvRsSecInheritedFvESgState {
					delete := true
					for _, tagTagIdentifier := range tagTagIdentifiers {
						if tagTagIdentifier.Key == tagTagFvRsSecInheritedFvESg.Key {
							delete = false
							break
						}
					}
					if delete {
						tagTagFvRsSecInheritedFvESgChildMapForDelete := NewAciObject()
						tagTagFvRsSecInheritedFvESgChildMapForDelete.Attributes["status"] = "deleted"
						tagTagFvRsSecInheritedFvESgChildMapForDelete.Attributes["key"] = tagTagFvRsSecInheritedFvESg.Key.ValueString()
						FvRsSecInheritedFvESgChildren = append(FvRsSecInheritedFvESgChildren, map[string]interface{}{"tagTag": tagTagFvRsSecInheritedFvESgChildMapForDelete})
					}
				}
			}
			childMap.Children = FvRsSecInheritedFvESgChildren
			childPayloads = append(childPayloads, map[string]interface{}{"fvRsSecInherited": childMap})
			fvRsSecInheritedIdentifier := FvRsSecInheritedIdentifier{}
			fvRsSecInheritedIdentifier.TDn = fvRsSecInheritedFvESg.TDn
			fvRsSecInheritedIdentifiers = append(fvRsSecInheritedIdentifiers, fvRsSecInheritedIdentifier)
		}
		for _, fvRsSecInherited := range fvRsSecInheritedFvESgState {
			delete := true
			for _, fvRsSecInheritedIdentifier := range fvRsSecInheritedIdentifiers {
				if fvRsSecInheritedIdentifier.TDn == fvRsSecInherited.TDn {
					delete = false
					break
				}
			}
			if delete {
				fvRsSecInheritedChildMapForDelete := NewAciObject()
				fvRsSecInheritedChildMapForDelete.Attributes["status"] = "deleted"
				fvRsSecInheritedChildMapForDelete.Attributes["tDn"] = fvRsSecInherited.TDn.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"fvRsSecInherited": fvRsSecInheritedChildMapForDelete})
			}
		}
	} else {
		data.FvRsSecInherited = types.SetNull(data.FvRsSecInherited.ElementType(ctx))
	}

	return childPayloads
}

func getFvESgTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvESgResourceModel, tagAnnotationFvESgPlan, tagAnnotationFvESgState []TagAnnotationFvESgResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() {
		tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
		for _, tagAnnotationFvESg := range tagAnnotationFvESgPlan {
			childMap := NewAciObject()
			if !tagAnnotationFvESg.Key.IsNull() && !tagAnnotationFvESg.Key.IsUnknown() {
				childMap.Attributes["key"] = tagAnnotationFvESg.Key.ValueString()
			}
			if !tagAnnotationFvESg.Value.IsNull() && !tagAnnotationFvESg.Value.IsUnknown() {
				childMap.Attributes["value"] = tagAnnotationFvESg.Value.ValueString()
			}
			childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap})
			tagAnnotationIdentifier := TagAnnotationIdentifier{}
			tagAnnotationIdentifier.Key = tagAnnotationFvESg.Key
			tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
		}
		for _, tagAnnotation := range tagAnnotationFvESgState {
			delete := true
			for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
				if tagAnnotationIdentifier.Key == tagAnnotation.Key {
					delete = false
					break
				}
			}
			if delete {
				tagAnnotationChildMapForDelete := NewAciObject()
				tagAnnotationChildMapForDelete.Attributes["status"] = "deleted"
				tagAnnotationChildMapForDelete.Attributes["key"] = tagAnnotation.Key.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": tagAnnotationChildMapForDelete})
			}
		}
	} else {
		data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx))
	}

	return childPayloads
}

func getFvESgTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvESgResourceModel, tagTagFvESgPlan, tagTagFvESgState []TagTagFvESgResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() {
		tagTagIdentifiers := []TagTagIdentifier{}
		for _, tagTagFvESg := range tagTagFvESgPlan {
			childMap := NewAciObject()
			if !tagTagFvESg.Key.IsNull() && !tagTagFvESg.Key.IsUnknown() {
				childMap.Attributes["key"] = tagTagFvESg.Key.ValueString()
			}
			if !tagTagFvESg.Value.IsNull() && !tagTagFvESg.Value.IsUnknown() {
				childMap.Attributes["value"] = tagTagFvESg.Value.ValueString()
			}
			childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap})
			tagTagIdentifier := TagTagIdentifier{}
			tagTagIdentifier.Key = tagTagFvESg.Key
			tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
		}
		for _, tagTag := range tagTagFvESgState {
			delete := true
			for _, tagTagIdentifier := range tagTagIdentifiers {
				if tagTagIdentifier.Key == tagTag.Key {
					delete = false
					break
				}
			}
			if delete {
				tagTagChildMapForDelete := NewAciObject()
				tagTagChildMapForDelete.Attributes["status"] = "deleted"
				tagTagChildMapForDelete.Attributes["key"] = tagTag.Key.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"tagTag": tagTagChildMapForDelete})
			}
		}
	} else {
		data.TagTag = types.SetNull(data.TagTag.ElementType(ctx))
	}

	return childPayloads
}

func getFvESgCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *FvESgResourceModel, fvRsConsPlan, fvRsConsState []FvRsConsFvESgResourceModel, fvRsConsIfPlan, fvRsConsIfState []FvRsConsIfFvESgResourceModel, fvRsIntraEpgPlan, fvRsIntraEpgState []FvRsIntraEpgFvESgResourceModel, fvRsProvPlan, fvRsProvState []FvRsProvFvESgResourceModel, fvRsScopePlan, fvRsScopeState FvRsScopeFvESgResourceModel, fvRsSecInheritedPlan, fvRsSecInheritedState []FvRsSecInheritedFvESgResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvESgResourceModel, tagTagPlan, tagTagState []TagTagFvESgResourceModel) *container.Container {
	payloadMap := map[string]interface{}{}
	payloadMap["attributes"] = map[string]string{}

	if createType && !globalAllowExistingOnCreate {
		payloadMap["attributes"].(map[string]string)["status"] = "created"
	}
	childPayloads := []map[string]interface{}{}

	FvRsConschildPayloads := getFvESgFvRsConsChildPayloads(ctx, diags, data, fvRsConsPlan, fvRsConsState)
	if FvRsConschildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, FvRsConschildPayloads...)

	FvRsConsIfchildPayloads := getFvESgFvRsConsIfChildPayloads(ctx, diags, data, fvRsConsIfPlan, fvRsConsIfState)
	if FvRsConsIfchildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, FvRsConsIfchildPayloads...)

	FvRsIntraEpgchildPayloads := getFvESgFvRsIntraEpgChildPayloads(ctx, diags, data, fvRsIntraEpgPlan, fvRsIntraEpgState)
	if FvRsIntraEpgchildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, FvRsIntraEpgchildPayloads...)

	FvRsProvchildPayloads := getFvESgFvRsProvChildPayloads(ctx, diags, data, fvRsProvPlan, fvRsProvState)
	if FvRsProvchildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, FvRsProvchildPayloads...)

	FvRsScopechildPayloads := getFvESgFvRsScopeChildPayloads(ctx, diags, data, fvRsScopePlan, fvRsScopeState)
	if FvRsScopechildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, FvRsScopechildPayloads...)

	FvRsSecInheritedchildPayloads := getFvESgFvRsSecInheritedChildPayloads(ctx, diags, data, fvRsSecInheritedPlan, fvRsSecInheritedState)
	if FvRsSecInheritedchildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, FvRsSecInheritedchildPayloads...)

	TagAnnotationchildPayloads := getFvESgTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState)
	if TagAnnotationchildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, TagAnnotationchildPayloads...)

	TagTagchildPayloads := getFvESgTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState)
	if TagTagchildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, TagTagchildPayloads...)

	payloadMap["children"] = childPayloads
	if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString()
	}
	if !data.Descr.IsNull() && !data.Descr.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString()
	}
	if !data.ExceptionTag.IsNull() && !data.ExceptionTag.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["exceptionTag"] = data.ExceptionTag.ValueString()
	}
	if !data.MatchT.IsNull() && !data.MatchT.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["matchT"] = data.MatchT.ValueString()
	}
	if !data.Name.IsNull() && !data.Name.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString()
	}
	if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString()
	}
	if !data.PcEnfPref.IsNull() && !data.PcEnfPref.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["pcEnfPref"] = data.PcEnfPref.ValueString()
	}
	if !data.PrefGrMemb.IsNull() && !data.PrefGrMemb.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["prefGrMemb"] = data.PrefGrMemb.ValueString()
	}
	if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["shutdown"] = data.Shutdown.ValueString()
	}
	payload, err := json.Marshal(map[string]interface{}{"fvESg": payloadMap})
	if err != nil {
		diags.AddError(
			"Marshalling of json payload failed",
			fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err),
		)
		return nil
	}

	jsonPayload, err := container.ParseJSON(payload)

	if err != nil {
		diags.AddError(
			"Construction of json payload failed",
			fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err),
		)
		return nil
	}
	return jsonPayload
}
