// 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/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/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 = &QosCustomPolResource{}
var _ resource.ResourceWithImportState = &QosCustomPolResource{}

func NewQosCustomPolResource() resource.Resource {
	return &QosCustomPolResource{}
}

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

// QosCustomPolResourceModel describes the resource data model.
type QosCustomPolResourceModel struct {
	Id            types.String `tfsdk:"id"`
	ParentDn      types.String `tfsdk:"parent_dn"`
	Annotation    types.String `tfsdk:"annotation"`
	Descr         types.String `tfsdk:"description"`
	Name          types.String `tfsdk:"name"`
	NameAlias     types.String `tfsdk:"name_alias"`
	OwnerKey      types.String `tfsdk:"owner_key"`
	OwnerTag      types.String `tfsdk:"owner_tag"`
	QosDot1PClass types.Set    `tfsdk:"dot1p_classifiers"`
	QosDscpClass  types.Set    `tfsdk:"dscp_to_priority_maps"`
	TagAnnotation types.Set    `tfsdk:"annotations"`
	TagTag        types.Set    `tfsdk:"tags"`
}

func getEmptyQosCustomPolResourceModel() *QosCustomPolResourceModel {
	return &QosCustomPolResourceModel{
		Id:         basetypes.NewStringNull(),
		ParentDn:   basetypes.NewStringNull(),
		Annotation: basetypes.NewStringNull(),
		Descr:      basetypes.NewStringNull(),
		Name:       basetypes.NewStringNull(),
		NameAlias:  basetypes.NewStringNull(),
		OwnerKey:   basetypes.NewStringNull(),
		OwnerTag:   basetypes.NewStringNull(),
		QosDot1PClass: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"annotation":  types.StringType,
				"description": types.StringType,
				"from":        types.StringType,
				"name":        types.StringType,
				"name_alias":  types.StringType,
				"priority":    types.StringType,
				"target":      types.StringType,
				"target_cos":  types.StringType,
				"to":          types.StringType,
				"annotations": types.SetType{ElemType: TagAnnotationQosDot1PClassQosCustomPolType},
				"tags":        types.SetType{ElemType: TagTagQosDot1PClassQosCustomPolType},
			},
		}),
		QosDscpClass: types.SetNull(types.ObjectType{
			AttrTypes: map[string]attr.Type{
				"annotation":  types.StringType,
				"description": types.StringType,
				"from":        types.StringType,
				"name":        types.StringType,
				"name_alias":  types.StringType,
				"priority":    types.StringType,
				"target":      types.StringType,
				"target_cos":  types.StringType,
				"to":          types.StringType,
				"annotations": types.SetType{ElemType: TagAnnotationQosDscpClassQosCustomPolType},
				"tags":        types.SetType{ElemType: TagTagQosDscpClassQosCustomPolType},
			},
		}),
		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,
			},
		}),
	}
}

// QosDot1PClassQosCustomPolResourceModel describes the resource data model for the children without relation ships.
type QosDot1PClassQosCustomPolResourceModel struct {
	Annotation    types.String                                  `tfsdk:"annotation"`
	Descr         types.String                                  `tfsdk:"description"`
	From          customTypes.QosDot1PClassFromStringValue      `tfsdk:"from"`
	Name          types.String                                  `tfsdk:"name"`
	NameAlias     types.String                                  `tfsdk:"name_alias"`
	Prio          customTypes.QosDot1PClassPrioStringValue      `tfsdk:"priority"`
	Target        customTypes.QosDot1PClassTargetStringValue    `tfsdk:"target"`
	TargetCos     customTypes.QosDot1PClassTargetCosStringValue `tfsdk:"target_cos"`
	To            customTypes.QosDot1PClassToStringValue        `tfsdk:"to"`
	TagAnnotation types.Set                                     `tfsdk:"annotations"`
	TagTag        types.Set                                     `tfsdk:"tags"`
}

func getEmptyQosDot1PClassQosCustomPolResourceModel() QosDot1PClassQosCustomPolResourceModel {
	return QosDot1PClassQosCustomPolResourceModel{
		Annotation: basetypes.NewStringNull(),
		Descr:      basetypes.NewStringNull(),
		From:       customTypes.NewQosDot1PClassFromStringNull(),
		Name:       basetypes.NewStringNull(),
		NameAlias:  basetypes.NewStringNull(),
		Prio:       customTypes.NewQosDot1PClassPrioStringNull(),
		Target:     customTypes.NewQosDot1PClassTargetStringNull(),
		TargetCos:  customTypes.NewQosDot1PClassTargetCosStringNull(),
		To:         customTypes.NewQosDot1PClassToStringNull(),
		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 QosDot1PClassQosCustomPolType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"annotation":  types.StringType,
		"description": types.StringType,
		"from":        types.StringType,
		"name":        types.StringType,
		"name_alias":  types.StringType,
		"priority":    types.StringType,
		"target":      types.StringType,
		"target_cos":  types.StringType,
		"to":          types.StringType,
		"annotations": types.SetType{ElemType: TagAnnotationQosDot1PClassQosCustomPolType},
		"tags":        types.SetType{ElemType: TagTagQosDot1PClassQosCustomPolType},
	},
}

func QosDot1PClassQosCustomPolSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(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 []QosDot1PClassQosCustomPolResourceModel
	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.Descr.IsNull() {
				nullInStateFound = true
				planSetValues[index].Descr = basetypes.NewStringNull()
			}
			if stateValue.From.IsNull() {
				nullInStateFound = true
				planSetValues[index].From = customTypes.NewQosDot1PClassFromStringNull()
			}
			if stateValue.Name.IsNull() {
				nullInStateFound = true
				planSetValues[index].Name = basetypes.NewStringNull()
			}
			if stateValue.NameAlias.IsNull() {
				nullInStateFound = true
				planSetValues[index].NameAlias = basetypes.NewStringNull()
			}
			if stateValue.Prio.IsNull() {
				nullInStateFound = true
				planSetValues[index].Prio = customTypes.NewQosDot1PClassPrioStringNull()
			}
			if stateValue.Target.IsNull() {
				nullInStateFound = true
				planSetValues[index].Target = customTypes.NewQosDot1PClassTargetStringNull()
			}
			if stateValue.TargetCos.IsNull() {
				nullInStateFound = true
				planSetValues[index].TargetCos = customTypes.NewQosDot1PClassTargetCosStringNull()
			}
			if stateValue.To.IsNull() {
				nullInStateFound = true
				planSetValues[index].To = customTypes.NewQosDot1PClassToStringNull()
			}
			if !nullInStateFound {
				// when there are no null fields we can conclude the version supports all attributes in set
				break
			}
		}
	}
	planSet, _ := types.SetValueFrom(ctx, QosDot1PClassQosCustomPolType, planSetValues)
	return planSet

}

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

func getEmptyTagAnnotationQosDot1PClassQosCustomPolResourceModel() TagAnnotationQosDot1PClassQosCustomPolResourceModel {
	return TagAnnotationQosDot1PClassQosCustomPolResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

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

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

func getEmptyTagTagQosDot1PClassQosCustomPolResourceModel() TagTagQosDot1PClassQosCustomPolResourceModel {
	return TagTagQosDot1PClassQosCustomPolResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

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

// QosDscpClassQosCustomPolResourceModel describes the resource data model for the children without relation ships.
type QosDscpClassQosCustomPolResourceModel struct {
	Annotation    types.String                                 `tfsdk:"annotation"`
	Descr         types.String                                 `tfsdk:"description"`
	From          customTypes.QosDscpClassFromStringValue      `tfsdk:"from"`
	Name          types.String                                 `tfsdk:"name"`
	NameAlias     types.String                                 `tfsdk:"name_alias"`
	Prio          customTypes.QosDscpClassPrioStringValue      `tfsdk:"priority"`
	Target        customTypes.QosDscpClassTargetStringValue    `tfsdk:"target"`
	TargetCos     customTypes.QosDscpClassTargetCosStringValue `tfsdk:"target_cos"`
	To            customTypes.QosDscpClassToStringValue        `tfsdk:"to"`
	TagAnnotation types.Set                                    `tfsdk:"annotations"`
	TagTag        types.Set                                    `tfsdk:"tags"`
}

func getEmptyQosDscpClassQosCustomPolResourceModel() QosDscpClassQosCustomPolResourceModel {
	return QosDscpClassQosCustomPolResourceModel{
		Annotation: basetypes.NewStringNull(),
		Descr:      basetypes.NewStringNull(),
		From:       customTypes.NewQosDscpClassFromStringNull(),
		Name:       basetypes.NewStringNull(),
		NameAlias:  basetypes.NewStringNull(),
		Prio:       customTypes.NewQosDscpClassPrioStringNull(),
		Target:     customTypes.NewQosDscpClassTargetStringNull(),
		TargetCos:  customTypes.NewQosDscpClassTargetCosStringNull(),
		To:         customTypes.NewQosDscpClassToStringNull(),
		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 QosDscpClassQosCustomPolType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"annotation":  types.StringType,
		"description": types.StringType,
		"from":        types.StringType,
		"name":        types.StringType,
		"name_alias":  types.StringType,
		"priority":    types.StringType,
		"target":      types.StringType,
		"target_cos":  types.StringType,
		"to":          types.StringType,
		"annotations": types.SetType{ElemType: TagAnnotationQosDscpClassQosCustomPolType},
		"tags":        types.SetType{ElemType: TagTagQosDscpClassQosCustomPolType},
	},
}

func QosDscpClassQosCustomPolSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(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 []QosDscpClassQosCustomPolResourceModel
	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.Descr.IsNull() {
				nullInStateFound = true
				planSetValues[index].Descr = basetypes.NewStringNull()
			}
			if stateValue.From.IsNull() {
				nullInStateFound = true
				planSetValues[index].From = customTypes.NewQosDscpClassFromStringNull()
			}
			if stateValue.Name.IsNull() {
				nullInStateFound = true
				planSetValues[index].Name = basetypes.NewStringNull()
			}
			if stateValue.NameAlias.IsNull() {
				nullInStateFound = true
				planSetValues[index].NameAlias = basetypes.NewStringNull()
			}
			if stateValue.Prio.IsNull() {
				nullInStateFound = true
				planSetValues[index].Prio = customTypes.NewQosDscpClassPrioStringNull()
			}
			if stateValue.Target.IsNull() {
				nullInStateFound = true
				planSetValues[index].Target = customTypes.NewQosDscpClassTargetStringNull()
			}
			if stateValue.TargetCos.IsNull() {
				nullInStateFound = true
				planSetValues[index].TargetCos = customTypes.NewQosDscpClassTargetCosStringNull()
			}
			if stateValue.To.IsNull() {
				nullInStateFound = true
				planSetValues[index].To = customTypes.NewQosDscpClassToStringNull()
			}
			if !nullInStateFound {
				// when there are no null fields we can conclude the version supports all attributes in set
				break
			}
		}
	}
	planSet, _ := types.SetValueFrom(ctx, QosDscpClassQosCustomPolType, planSetValues)
	return planSet

}

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

func getEmptyTagAnnotationQosDscpClassQosCustomPolResourceModel() TagAnnotationQosDscpClassQosCustomPolResourceModel {
	return TagAnnotationQosDscpClassQosCustomPolResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

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

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

func getEmptyTagTagQosDscpClassQosCustomPolResourceModel() TagTagQosDscpClassQosCustomPolResourceModel {
	return TagTagQosDscpClassQosCustomPolResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

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

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

func getEmptyTagAnnotationQosCustomPolResourceModel() TagAnnotationQosCustomPolResourceModel {
	return TagAnnotationQosCustomPolResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

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

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

func getEmptyTagTagQosCustomPolResourceModel() TagTagQosCustomPolResourceModel {
	return TagTagQosCustomPolResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

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

type QosCustomPolIdentifier struct {
	Name types.String
}

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

		if resp.Diagnostics.HasError() {
			return
		}

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

		if stateData == nil && !globalAllowExistingOnCreate && !planData.Id.IsUnknown() && !planData.Id.IsNull() {
			CheckDn(ctx, &resp.Diagnostics, r.client, "qosCustomPol", planData.Id.ValueString())
			if resp.Diagnostics.HasError() {
				return
			}
		}

		resp.Diagnostics.Append(resp.Plan.Set(ctx, &planData)...)
	}
}

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

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

		Attributes: map[string]schema.Attribute{
			"id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "The distinguished name (DN) of the Custom QoS Policy object.",
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
				},
			},
			"parent_dn": schema.StringAttribute{
				Required:            true,
				MarkdownDescription: "The distinguished name (DN) of the parent object.",
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					stringplanmodifier.RequiresReplace(),
				},
			},
			"annotation": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Default:             stringdefault.StaticString(globalAnnotation),
				MarkdownDescription: `The annotation of the Custom QoS Policy object.`,
			},
			"description": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The description of the Custom QoS Policy object.`,
			},
			"name": schema.StringAttribute{
				Required: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
					stringplanmodifier.RequiresReplace(),
				},
				MarkdownDescription: `The name of the Custom QoS Policy object.`,
			},
			"name_alias": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The name alias of the Custom QoS Policy object.`,
			},
			"owner_key": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The key for enabling clients to own their data for entity correlation.`,
			},
			"owner_tag": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `A tag for enabling clients to add their own data. For example, to indicate who created this object.`,
			},
			"dot1p_classifiers": schema.SetNestedAttribute{
				MarkdownDescription: `The class level for dot1P to prioritize the map.`,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
					SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(QosDot1PClassQosCustomPolSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"annotation": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The annotation of the Dot1p Classifier object.`,
						},
						"description": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The description of the Dot1p Classifier object.`,
						},
						"from": schema.StringAttribute{
							CustomType: customTypes.QosDot1PClassFromStringType{},
							Required:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"),
									validators.InBetweenFromString(0, 8),
								),
							},
							MarkdownDescription: `The Dot1p priority range starting value.`,
						},
						"name": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The name of the Dot1p Classifier object.`,
						},
						"name_alias": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The name alias of the Dot1p Classifier object.`,
						},
						"priority": schema.StringAttribute{
							CustomType: customTypes.QosDot1PClassPrioStringType{},
							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.`,
						},
						"target": schema.StringAttribute{
							CustomType: customTypes.QosDot1PClassTargetStringType{},
							Optional:   true,
							Computed:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA", "unspecified"),
									validators.InBetweenFromString(0, 64),
								),
							},
							MarkdownDescription: `The target of the Dot1p Classifier object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`,
						},
						"target_cos": schema.StringAttribute{
							CustomType: customTypes.QosDot1PClassTargetCosStringType{},
							Optional:   true,
							Computed:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"),
									validators.InBetweenFromString(0, 8),
								),
							},
							MarkdownDescription: `The target Class of Service (CoS) to be driven based on the range of DSCP input values coming into the fabric.`,
						},
						"to": schema.StringAttribute{
							CustomType: customTypes.QosDot1PClassToStringType{},
							Required:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"),
									validators.InBetweenFromString(0, 8),
								),
							},
							MarkdownDescription: `The Dot1p priority range ending value.`,
						},
						"annotations": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Required: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Required: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
						"tags": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Required: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Required: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
					},
				},
			},
			"dscp_to_priority_maps": schema.SetNestedAttribute{
				MarkdownDescription: `The class level for DSCP to prioritize the map.`,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
					SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(QosDscpClassQosCustomPolSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"annotation": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The annotation of the DSCP to Priority Map object.`,
						},
						"description": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The description of the DSCP to Priority Map object.`,
						},
						"from": schema.StringAttribute{
							CustomType: customTypes.QosDscpClassFromStringType{},
							Required:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA"),
									validators.InBetweenFromString(0, 63),
								),
							},
							MarkdownDescription: `The DSCP range starting value.`,
						},
						"name": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The name of the DSCP to Priority Map object.`,
						},
						"name_alias": schema.StringAttribute{
							Optional: true,
							Computed: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The name alias of the DSCP to Priority Map object.`,
						},
						"priority": schema.StringAttribute{
							CustomType: customTypes.QosDscpClassPrioStringType{},
							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.`,
						},
						"target": schema.StringAttribute{
							CustomType: customTypes.QosDscpClassTargetStringType{},
							Optional:   true,
							Computed:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA", "unspecified"),
									validators.InBetweenFromString(0, 64),
								),
							},
							MarkdownDescription: `The target of the DSCP to Priority Map object. This Fabric only supports DSCP mutation, Dot1P mutation is not supported.`,
						},
						"target_cos": schema.StringAttribute{
							CustomType: customTypes.QosDscpClassTargetCosStringType{},
							Optional:   true,
							Computed:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("0", "1", "2", "3", "4", "5", "6", "7", "unspecified"),
									validators.InBetweenFromString(0, 8),
								),
							},
							MarkdownDescription: `Target COS to be driven based on the range of input values of DSCP coming into the fabric.`,
						},
						"to": schema.StringAttribute{
							CustomType: customTypes.QosDscpClassToStringType{},
							Required:   true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							Validators: []validator.String{
								stringvalidator.Any(
									stringvalidator.OneOf("AF11", "AF12", "AF13", "AF21", "AF22", "AF23", "AF31", "AF32", "AF33", "AF41", "AF42", "AF43", "CS0", "CS1", "CS2", "CS3", "CS4", "CS5", "CS6", "CS7", "EF", "VA"),
									validators.InBetweenFromString(0, 63),
								),
							},
							MarkdownDescription: `The DSCP range ending value.`,
						},
						"annotations": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Required: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Required: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
						"tags": schema.SetNestedAttribute{
							MarkdownDescription: ``,
							Optional:            true,
							Computed:            true,
							PlanModifiers: []planmodifier.Set{
								setplanmodifier.UseStateForUnknown(),
							},
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"key": schema.StringAttribute{
										Required: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										MarkdownDescription: `The key used to uniquely identify this configuration object.`,
									},
									"value": schema.StringAttribute{
										Required: true,
										PlanModifiers: []planmodifier.String{
											stringplanmodifier.UseStateForUnknown(),
										},
										MarkdownDescription: `The value of the property.`,
									},
								},
							},
						},
					},
				},
			},
			"annotations": schema.SetNestedAttribute{
				MarkdownDescription: ``,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"key": schema.StringAttribute{
							Required: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The key used to uniquely identify this configuration object.`,
						},
						"value": schema.StringAttribute{
							Required: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The value of the property.`,
						},
					},
				},
			},
			"tags": schema.SetNestedAttribute{
				MarkdownDescription: ``,
				Optional:            true,
				Computed:            true,
				PlanModifiers: []planmodifier.Set{
					setplanmodifier.UseStateForUnknown(),
				},
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"key": schema.StringAttribute{
							Required: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The key used to uniquely identify this configuration object.`,
						},
						"value": schema.StringAttribute{
							Required: true,
							PlanModifiers: []planmodifier.String{
								stringplanmodifier.UseStateForUnknown(),
							},
							MarkdownDescription: `The value of the property.`,
						},
					},
				},
			},
		},
	}
	tflog.Debug(ctx, "End schema of resource: aci_custom_qos_policy")
}

func (r *QosCustomPolResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
	tflog.Debug(ctx, "Start configure of resource: aci_custom_qos_policy")
	// 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_custom_qos_policy")
}

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

	var data *QosCustomPolResourceModel

	// 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() {
		setQosCustomPolId(ctx, data)
	}

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

	var qosDot1PClassPlan, qosDot1PClassState []QosDot1PClassQosCustomPolResourceModel
	data.QosDot1PClass.ElementsAs(ctx, &qosDot1PClassPlan, false)
	stateData.QosDot1PClass.ElementsAs(ctx, &qosDot1PClassState, false)
	var qosDscpClassPlan, qosDscpClassState []QosDscpClassQosCustomPolResourceModel
	data.QosDscpClass.ElementsAs(ctx, &qosDscpClassPlan, false)
	stateData.QosDscpClass.ElementsAs(ctx, &qosDscpClassState, false)
	var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel
	data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false)
	stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false)
	var tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel
	data.TagTag.ElementsAs(ctx, &tagTagPlan, false)
	stateData.TagTag.ElementsAs(ctx, &tagTagState, false)
	jsonPayload := getQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, qosDot1PClassPlan, qosDot1PClassState, qosDscpClassPlan, qosDscpClassState, 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
	}

	getAndSetQosCustomPolAttributes(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_custom_qos_policy with id '%s'", data.Id.ValueString()))
}

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

	// 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_custom_qos_policy with id '%s'", data.Id.ValueString()))

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

	// Save updated data into Terraform state
	if data.Id.IsNull() {
		var emptyData *QosCustomPolResourceModel
		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_custom_qos_policy with id '%s'", data.Id.ValueString()))
}

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

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

	if resp.Diagnostics.HasError() {
		return
	}

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

	var qosDot1PClassPlan, qosDot1PClassState []QosDot1PClassQosCustomPolResourceModel
	data.QosDot1PClass.ElementsAs(ctx, &qosDot1PClassPlan, false)
	stateData.QosDot1PClass.ElementsAs(ctx, &qosDot1PClassState, false)
	var qosDscpClassPlan, qosDscpClassState []QosDscpClassQosCustomPolResourceModel
	data.QosDscpClass.ElementsAs(ctx, &qosDscpClassPlan, false)
	stateData.QosDscpClass.ElementsAs(ctx, &qosDscpClassState, false)
	var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel
	data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false)
	stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false)
	var tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel
	data.TagTag.ElementsAs(ctx, &tagTagPlan, false)
	stateData.TagTag.ElementsAs(ctx, &tagTagState, false)
	jsonPayload := getQosCustomPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, qosDot1PClassPlan, qosDot1PClassState, qosDscpClassPlan, qosDscpClassState, 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
	}

	getAndSetQosCustomPolAttributes(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_custom_qos_policy with id '%s'", data.Id.ValueString()))
}

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

	// 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_custom_qos_policy with id '%s'", data.Id.ValueString()))
	jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "qosCustomPol", 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_custom_qos_policy with id '%s'", data.Id.ValueString()))
}

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

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

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

func getAndSetQosCustomPolAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *QosCustomPolResourceModel) {
	requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "qosCustomPol,qosDot1PClass,qosDscpClass,tagAnnotation,tagTag,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil)

	readData := getEmptyQosCustomPolResourceModel()

	if diags.HasError() {
		return
	}
	if requestData.Search("imdata").Search("qosCustomPol").Data() != nil {
		classReadInfo := requestData.Search("imdata").Search("qosCustomPol").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))
					setQosCustomPolParentDn(ctx, attributeValue.(string), readData)
				}
				if attributeName == "annotation" {
					readData.Annotation = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "descr" {
					readData.Descr = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "name" {
					readData.Name = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "nameAlias" {
					readData.NameAlias = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "ownerKey" {
					readData.OwnerKey = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "ownerTag" {
					readData.OwnerTag = basetypes.NewStringValue(attributeValue.(string))
				}
			}
			QosDot1PClassQosCustomPolList := make([]QosDot1PClassQosCustomPolResourceModel, 0)
			QosDscpClassQosCustomPolList := make([]QosDscpClassQosCustomPolResourceModel, 0)
			TagAnnotationQosCustomPolList := make([]TagAnnotationQosCustomPolResourceModel, 0)
			TagTagQosCustomPolList := make([]TagTagQosCustomPolResourceModel, 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 == "qosDot1PClass" {
							QosDot1PClassQosCustomPol := getEmptyQosDot1PClassQosCustomPolResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "annotation" {
									QosDot1PClassQosCustomPol.Annotation = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "descr" {
									QosDot1PClassQosCustomPol.Descr = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "from" {
									QosDot1PClassQosCustomPol.From = customTypes.NewQosDot1PClassFromStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "name" {
									QosDot1PClassQosCustomPol.Name = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "nameAlias" {
									QosDot1PClassQosCustomPol.NameAlias = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "prio" {
									QosDot1PClassQosCustomPol.Prio = customTypes.NewQosDot1PClassPrioStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "target" {
									QosDot1PClassQosCustomPol.Target = customTypes.NewQosDot1PClassTargetStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "targetCos" {
									QosDot1PClassQosCustomPol.TargetCos = customTypes.NewQosDot1PClassTargetCosStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "to" {
									QosDot1PClassQosCustomPol.To = customTypes.NewQosDot1PClassToStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationQosDot1PClassQosCustomPolList := make([]TagAnnotationQosDot1PClassQosCustomPolResourceModel, 0)
							TagTagQosDot1PClassQosCustomPolList := make([]TagTagQosDot1PClassQosCustomPolResourceModel, 0)
							childrenOfQosDot1PClassQosCustomPol, childrenOfQosDot1PClassQosCustomPolExist := childClassDetails.(map[string]interface{})["children"]
							if childrenOfQosDot1PClassQosCustomPolExist {
								for _, childQosDot1PClassQosCustomPol := range childrenOfQosDot1PClassQosCustomPol.([]interface{}) {
									for childClassNameQosDot1PClassQosCustomPol, childClassDetailsQosDot1PClassQosCustomPol := range childQosDot1PClassQosCustomPol.(map[string]interface{}) {
										if childClassNameQosDot1PClassQosCustomPol == "tagAnnotation" {
											TagAnnotationQosDot1PClassQosCustomPol := getEmptyTagAnnotationQosDot1PClassQosCustomPolResourceModel()
											tagAnnotationchildAttributeValue := childClassDetailsQosDot1PClassQosCustomPol.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue {
												if childAttributeName == "key" {
													TagAnnotationQosDot1PClassQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagAnnotationQosDot1PClassQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagAnnotationQosDot1PClassQosCustomPolList = append(TagAnnotationQosDot1PClassQosCustomPolList, TagAnnotationQosDot1PClassQosCustomPol)
										}
										if childClassNameQosDot1PClassQosCustomPol == "tagTag" {
											TagTagQosDot1PClassQosCustomPol := getEmptyTagTagQosDot1PClassQosCustomPolResourceModel()
											tagTagchildAttributeValue := childClassDetailsQosDot1PClassQosCustomPol.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagTagchildAttributeValue {
												if childAttributeName == "key" {
													TagTagQosDot1PClassQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagTagQosDot1PClassQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagTagQosDot1PClassQosCustomPolList = append(TagTagQosDot1PClassQosCustomPolList, TagTagQosDot1PClassQosCustomPol)
										}
									}
								}
							}
							TagAnnotationQosDot1PClassQosCustomPolSet, _ := types.SetValueFrom(ctx, TagAnnotationQosDot1PClassQosCustomPolType, TagAnnotationQosDot1PClassQosCustomPolList)
							QosDot1PClassQosCustomPol.TagAnnotation = TagAnnotationQosDot1PClassQosCustomPolSet
							TagTagQosDot1PClassQosCustomPolSet, _ := types.SetValueFrom(ctx, TagTagQosDot1PClassQosCustomPolType, TagTagQosDot1PClassQosCustomPolList)
							QosDot1PClassQosCustomPol.TagTag = TagTagQosDot1PClassQosCustomPolSet
							QosDot1PClassQosCustomPolList = append(QosDot1PClassQosCustomPolList, QosDot1PClassQosCustomPol)
						}
						if childClassName == "qosDscpClass" {
							QosDscpClassQosCustomPol := getEmptyQosDscpClassQosCustomPolResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "annotation" {
									QosDscpClassQosCustomPol.Annotation = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "descr" {
									QosDscpClassQosCustomPol.Descr = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "from" {
									QosDscpClassQosCustomPol.From = customTypes.NewQosDscpClassFromStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "name" {
									QosDscpClassQosCustomPol.Name = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "nameAlias" {
									QosDscpClassQosCustomPol.NameAlias = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "prio" {
									QosDscpClassQosCustomPol.Prio = customTypes.NewQosDscpClassPrioStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "target" {
									QosDscpClassQosCustomPol.Target = customTypes.NewQosDscpClassTargetStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "targetCos" {
									QosDscpClassQosCustomPol.TargetCos = customTypes.NewQosDscpClassTargetCosStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "to" {
									QosDscpClassQosCustomPol.To = customTypes.NewQosDscpClassToStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationQosDscpClassQosCustomPolList := make([]TagAnnotationQosDscpClassQosCustomPolResourceModel, 0)
							TagTagQosDscpClassQosCustomPolList := make([]TagTagQosDscpClassQosCustomPolResourceModel, 0)
							childrenOfQosDscpClassQosCustomPol, childrenOfQosDscpClassQosCustomPolExist := childClassDetails.(map[string]interface{})["children"]
							if childrenOfQosDscpClassQosCustomPolExist {
								for _, childQosDscpClassQosCustomPol := range childrenOfQosDscpClassQosCustomPol.([]interface{}) {
									for childClassNameQosDscpClassQosCustomPol, childClassDetailsQosDscpClassQosCustomPol := range childQosDscpClassQosCustomPol.(map[string]interface{}) {
										if childClassNameQosDscpClassQosCustomPol == "tagAnnotation" {
											TagAnnotationQosDscpClassQosCustomPol := getEmptyTagAnnotationQosDscpClassQosCustomPolResourceModel()
											tagAnnotationchildAttributeValue := childClassDetailsQosDscpClassQosCustomPol.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagAnnotationchildAttributeValue {
												if childAttributeName == "key" {
													TagAnnotationQosDscpClassQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagAnnotationQosDscpClassQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagAnnotationQosDscpClassQosCustomPolList = append(TagAnnotationQosDscpClassQosCustomPolList, TagAnnotationQosDscpClassQosCustomPol)
										}
										if childClassNameQosDscpClassQosCustomPol == "tagTag" {
											TagTagQosDscpClassQosCustomPol := getEmptyTagTagQosDscpClassQosCustomPolResourceModel()
											tagTagchildAttributeValue := childClassDetailsQosDscpClassQosCustomPol.(map[string]interface{})["attributes"].(map[string]interface{})
											for childAttributeName, childAttributeValue := range tagTagchildAttributeValue {
												if childAttributeName == "key" {
													TagTagQosDscpClassQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string))
												}
												if childAttributeName == "value" {
													TagTagQosDscpClassQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string))
												}
											}
											TagTagQosDscpClassQosCustomPolList = append(TagTagQosDscpClassQosCustomPolList, TagTagQosDscpClassQosCustomPol)
										}
									}
								}
							}
							TagAnnotationQosDscpClassQosCustomPolSet, _ := types.SetValueFrom(ctx, TagAnnotationQosDscpClassQosCustomPolType, TagAnnotationQosDscpClassQosCustomPolList)
							QosDscpClassQosCustomPol.TagAnnotation = TagAnnotationQosDscpClassQosCustomPolSet
							TagTagQosDscpClassQosCustomPolSet, _ := types.SetValueFrom(ctx, TagTagQosDscpClassQosCustomPolType, TagTagQosDscpClassQosCustomPolList)
							QosDscpClassQosCustomPol.TagTag = TagTagQosDscpClassQosCustomPolSet
							QosDscpClassQosCustomPolList = append(QosDscpClassQosCustomPolList, QosDscpClassQosCustomPol)
						}
						if childClassName == "tagAnnotation" {
							TagAnnotationQosCustomPol := getEmptyTagAnnotationQosCustomPolResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "key" {
									TagAnnotationQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "value" {
									TagAnnotationQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationQosCustomPolList = append(TagAnnotationQosCustomPolList, TagAnnotationQosCustomPol)
						}
						if childClassName == "tagTag" {
							TagTagQosCustomPol := getEmptyTagTagQosCustomPolResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "key" {
									TagTagQosCustomPol.Key = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "value" {
									TagTagQosCustomPol.Value = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagTagQosCustomPolList = append(TagTagQosCustomPolList, TagTagQosCustomPol)
						}
					}
				}
			}
			qosDot1PClassSet, _ := types.SetValueFrom(ctx, readData.QosDot1PClass.ElementType(ctx), QosDot1PClassQosCustomPolList)
			readData.QosDot1PClass = qosDot1PClassSet
			qosDscpClassSet, _ := types.SetValueFrom(ctx, readData.QosDscpClass.ElementType(ctx), QosDscpClassQosCustomPolList)
			readData.QosDscpClass = qosDscpClassSet
			tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationQosCustomPolList)
			readData.TagAnnotation = tagAnnotationSet
			tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagQosCustomPolList)
			readData.TagTag = tagTagSet
		} else {
			diags.AddError(
				"too many results in response",
				fmt.Sprintf("%v matches returned for class 'qosCustomPol'. Please report this issue to the provider developers.", len(classReadInfo)),
			)
		}
	} else {
		readData.Id = basetypes.NewStringNull()
	}
	*data = *readData
}

func getQosCustomPolRn(ctx context.Context, data *QosCustomPolResourceModel) string {
	return fmt.Sprintf("qoscustom-%s", data.Name.ValueString())
}

func setQosCustomPolParentDn(ctx context.Context, dn string, data *QosCustomPolResourceModel) {
	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 setQosCustomPolId(ctx context.Context, data *QosCustomPolResourceModel) {
	rn := getQosCustomPolRn(ctx, data)
	data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn))
}

func getQosCustomPolQosDot1PClassChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosCustomPolResourceModel, qosDot1PClassQosCustomPolPlan, qosDot1PClassQosCustomPolState []QosDot1PClassQosCustomPolResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.QosDot1PClass.IsNull() && !data.QosDot1PClass.IsUnknown() {
		qosDot1PClassIdentifiers := []QosDot1PClassIdentifier{}
		for _, qosDot1PClassQosCustomPol := range qosDot1PClassQosCustomPolPlan {
			QosDot1PClassQosCustomPolChildren := make([]map[string]interface{}, 0)
			childMap := NewAciObject()
			if !qosDot1PClassQosCustomPol.Annotation.IsNull() && !qosDot1PClassQosCustomPol.Annotation.IsUnknown() {
				childMap.Attributes["annotation"] = qosDot1PClassQosCustomPol.Annotation.ValueString()
			} else {
				childMap.Attributes["annotation"] = globalAnnotation
			}
			if !qosDot1PClassQosCustomPol.Descr.IsNull() && !qosDot1PClassQosCustomPol.Descr.IsUnknown() {
				childMap.Attributes["descr"] = qosDot1PClassQosCustomPol.Descr.ValueString()
			}
			if !qosDot1PClassQosCustomPol.From.IsNull() && !qosDot1PClassQosCustomPol.From.IsUnknown() {
				childMap.Attributes["from"] = qosDot1PClassQosCustomPol.From.ValueString()
			}
			if !qosDot1PClassQosCustomPol.Name.IsNull() && !qosDot1PClassQosCustomPol.Name.IsUnknown() {
				childMap.Attributes["name"] = qosDot1PClassQosCustomPol.Name.ValueString()
			}
			if !qosDot1PClassQosCustomPol.NameAlias.IsNull() && !qosDot1PClassQosCustomPol.NameAlias.IsUnknown() {
				childMap.Attributes["nameAlias"] = qosDot1PClassQosCustomPol.NameAlias.ValueString()
			}
			if !qosDot1PClassQosCustomPol.Prio.IsNull() && !qosDot1PClassQosCustomPol.Prio.IsUnknown() {
				childMap.Attributes["prio"] = qosDot1PClassQosCustomPol.Prio.ValueString()
			}
			if !qosDot1PClassQosCustomPol.Target.IsNull() && !qosDot1PClassQosCustomPol.Target.IsUnknown() {
				childMap.Attributes["target"] = qosDot1PClassQosCustomPol.Target.ValueString()
			}
			if !qosDot1PClassQosCustomPol.TargetCos.IsNull() && !qosDot1PClassQosCustomPol.TargetCos.IsUnknown() {
				childMap.Attributes["targetCos"] = qosDot1PClassQosCustomPol.TargetCos.ValueString()
			}
			if !qosDot1PClassQosCustomPol.To.IsNull() && !qosDot1PClassQosCustomPol.To.IsUnknown() {
				childMap.Attributes["to"] = qosDot1PClassQosCustomPol.To.ValueString()
			}

			var tagAnnotationQosDot1PClassQosCustomPolPlan, tagAnnotationQosDot1PClassQosCustomPolState []TagAnnotationQosDot1PClassQosCustomPolResourceModel
			qosDot1PClassQosCustomPol.TagAnnotation.ElementsAs(ctx, &tagAnnotationQosDot1PClassQosCustomPolPlan, false)
			for _, tagAnnotationQosDot1PClassQosCustomPolstate := range qosDot1PClassQosCustomPolState {
				tagAnnotationQosDot1PClassQosCustomPolstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationQosDot1PClassQosCustomPolState, false)
			}
			if !qosDot1PClassQosCustomPol.TagAnnotation.IsNull() && !qosDot1PClassQosCustomPol.TagAnnotation.IsUnknown() {
				tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
				for _, tagAnnotationQosDot1PClassQosCustomPol := range tagAnnotationQosDot1PClassQosCustomPolPlan {
					tagAnnotationQosDot1PClassQosCustomPolChildMap := NewAciObject()
					if !tagAnnotationQosDot1PClassQosCustomPol.Key.IsNull() && !tagAnnotationQosDot1PClassQosCustomPol.Key.IsUnknown() {
						tagAnnotationQosDot1PClassQosCustomPolChildMap.Attributes["key"] = tagAnnotationQosDot1PClassQosCustomPol.Key.ValueString()
					}
					if !tagAnnotationQosDot1PClassQosCustomPol.Value.IsNull() && !tagAnnotationQosDot1PClassQosCustomPol.Value.IsUnknown() {
						tagAnnotationQosDot1PClassQosCustomPolChildMap.Attributes["value"] = tagAnnotationQosDot1PClassQosCustomPol.Value.ValueString()
					}
					QosDot1PClassQosCustomPolChildren = append(QosDot1PClassQosCustomPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationQosDot1PClassQosCustomPolChildMap})
					tagAnnotationIdentifier := TagAnnotationIdentifier{}
					tagAnnotationIdentifier.Key = tagAnnotationQosDot1PClassQosCustomPol.Key
					tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
				}
				for _, tagAnnotationQosDot1PClassQosCustomPol := range tagAnnotationQosDot1PClassQosCustomPolState {
					delete := true
					for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
						if tagAnnotationIdentifier.Key == tagAnnotationQosDot1PClassQosCustomPol.Key {
							delete = false
							break
						}
					}
					if delete {
						tagAnnotationQosDot1PClassQosCustomPolChildMapForDelete := NewAciObject()
						tagAnnotationQosDot1PClassQosCustomPolChildMapForDelete.Attributes["status"] = "deleted"
						tagAnnotationQosDot1PClassQosCustomPolChildMapForDelete.Attributes["key"] = tagAnnotationQosDot1PClassQosCustomPol.Key.ValueString()
						QosDot1PClassQosCustomPolChildren = append(QosDot1PClassQosCustomPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationQosDot1PClassQosCustomPolChildMapForDelete})
					}
				}
			}

			var tagTagQosDot1PClassQosCustomPolPlan, tagTagQosDot1PClassQosCustomPolState []TagTagQosDot1PClassQosCustomPolResourceModel
			qosDot1PClassQosCustomPol.TagTag.ElementsAs(ctx, &tagTagQosDot1PClassQosCustomPolPlan, false)
			for _, tagTagQosDot1PClassQosCustomPolstate := range qosDot1PClassQosCustomPolState {
				tagTagQosDot1PClassQosCustomPolstate.TagTag.ElementsAs(ctx, &tagTagQosDot1PClassQosCustomPolState, false)
			}
			if !qosDot1PClassQosCustomPol.TagTag.IsNull() && !qosDot1PClassQosCustomPol.TagTag.IsUnknown() {
				tagTagIdentifiers := []TagTagIdentifier{}
				for _, tagTagQosDot1PClassQosCustomPol := range tagTagQosDot1PClassQosCustomPolPlan {
					tagTagQosDot1PClassQosCustomPolChildMap := NewAciObject()
					if !tagTagQosDot1PClassQosCustomPol.Key.IsNull() && !tagTagQosDot1PClassQosCustomPol.Key.IsUnknown() {
						tagTagQosDot1PClassQosCustomPolChildMap.Attributes["key"] = tagTagQosDot1PClassQosCustomPol.Key.ValueString()
					}
					if !tagTagQosDot1PClassQosCustomPol.Value.IsNull() && !tagTagQosDot1PClassQosCustomPol.Value.IsUnknown() {
						tagTagQosDot1PClassQosCustomPolChildMap.Attributes["value"] = tagTagQosDot1PClassQosCustomPol.Value.ValueString()
					}
					QosDot1PClassQosCustomPolChildren = append(QosDot1PClassQosCustomPolChildren, map[string]interface{}{"tagTag": tagTagQosDot1PClassQosCustomPolChildMap})
					tagTagIdentifier := TagTagIdentifier{}
					tagTagIdentifier.Key = tagTagQosDot1PClassQosCustomPol.Key
					tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
				}
				for _, tagTagQosDot1PClassQosCustomPol := range tagTagQosDot1PClassQosCustomPolState {
					delete := true
					for _, tagTagIdentifier := range tagTagIdentifiers {
						if tagTagIdentifier.Key == tagTagQosDot1PClassQosCustomPol.Key {
							delete = false
							break
						}
					}
					if delete {
						tagTagQosDot1PClassQosCustomPolChildMapForDelete := NewAciObject()
						tagTagQosDot1PClassQosCustomPolChildMapForDelete.Attributes["status"] = "deleted"
						tagTagQosDot1PClassQosCustomPolChildMapForDelete.Attributes["key"] = tagTagQosDot1PClassQosCustomPol.Key.ValueString()
						QosDot1PClassQosCustomPolChildren = append(QosDot1PClassQosCustomPolChildren, map[string]interface{}{"tagTag": tagTagQosDot1PClassQosCustomPolChildMapForDelete})
					}
				}
			}
			childMap.Children = QosDot1PClassQosCustomPolChildren
			childPayloads = append(childPayloads, map[string]interface{}{"qosDot1PClass": childMap})
			qosDot1PClassIdentifier := QosDot1PClassIdentifier{}
			qosDot1PClassIdentifier.From = basetypes.NewStringValue(qosDot1PClassQosCustomPol.From.ValueString())
			qosDot1PClassIdentifier.To = basetypes.NewStringValue(qosDot1PClassQosCustomPol.To.ValueString())
			qosDot1PClassIdentifiers = append(qosDot1PClassIdentifiers, qosDot1PClassIdentifier)
		}
		for _, qosDot1PClass := range qosDot1PClassQosCustomPolState {
			delete := true
			for _, qosDot1PClassIdentifier := range qosDot1PClassIdentifiers {
				if qosDot1PClassIdentifier.From == basetypes.NewStringValue(qosDot1PClass.From.ValueString()) &&
					qosDot1PClassIdentifier.To == basetypes.NewStringValue(qosDot1PClass.To.ValueString()) {
					delete = false
					break
				}
			}
			if delete {
				qosDot1PClassChildMapForDelete := NewAciObject()
				qosDot1PClassChildMapForDelete.Attributes["status"] = "deleted"
				qosDot1PClassChildMapForDelete.Attributes["from"] = qosDot1PClass.From.ValueString()
				qosDot1PClassChildMapForDelete.Attributes["to"] = qosDot1PClass.To.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"qosDot1PClass": qosDot1PClassChildMapForDelete})
			}
		}
	} else {
		data.QosDot1PClass = types.SetNull(data.QosDot1PClass.ElementType(ctx))
	}

	return childPayloads
}

func getQosCustomPolQosDscpClassChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosCustomPolResourceModel, qosDscpClassQosCustomPolPlan, qosDscpClassQosCustomPolState []QosDscpClassQosCustomPolResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.QosDscpClass.IsNull() && !data.QosDscpClass.IsUnknown() {
		qosDscpClassIdentifiers := []QosDscpClassIdentifier{}
		for _, qosDscpClassQosCustomPol := range qosDscpClassQosCustomPolPlan {
			QosDscpClassQosCustomPolChildren := make([]map[string]interface{}, 0)
			childMap := NewAciObject()
			if !qosDscpClassQosCustomPol.Annotation.IsNull() && !qosDscpClassQosCustomPol.Annotation.IsUnknown() {
				childMap.Attributes["annotation"] = qosDscpClassQosCustomPol.Annotation.ValueString()
			} else {
				childMap.Attributes["annotation"] = globalAnnotation
			}
			if !qosDscpClassQosCustomPol.Descr.IsNull() && !qosDscpClassQosCustomPol.Descr.IsUnknown() {
				childMap.Attributes["descr"] = qosDscpClassQosCustomPol.Descr.ValueString()
			}
			if !qosDscpClassQosCustomPol.From.IsNull() && !qosDscpClassQosCustomPol.From.IsUnknown() {
				childMap.Attributes["from"] = qosDscpClassQosCustomPol.From.ValueString()
			}
			if !qosDscpClassQosCustomPol.Name.IsNull() && !qosDscpClassQosCustomPol.Name.IsUnknown() {
				childMap.Attributes["name"] = qosDscpClassQosCustomPol.Name.ValueString()
			}
			if !qosDscpClassQosCustomPol.NameAlias.IsNull() && !qosDscpClassQosCustomPol.NameAlias.IsUnknown() {
				childMap.Attributes["nameAlias"] = qosDscpClassQosCustomPol.NameAlias.ValueString()
			}
			if !qosDscpClassQosCustomPol.Prio.IsNull() && !qosDscpClassQosCustomPol.Prio.IsUnknown() {
				childMap.Attributes["prio"] = qosDscpClassQosCustomPol.Prio.ValueString()
			}
			if !qosDscpClassQosCustomPol.Target.IsNull() && !qosDscpClassQosCustomPol.Target.IsUnknown() {
				childMap.Attributes["target"] = qosDscpClassQosCustomPol.Target.ValueString()
			}
			if !qosDscpClassQosCustomPol.TargetCos.IsNull() && !qosDscpClassQosCustomPol.TargetCos.IsUnknown() {
				childMap.Attributes["targetCos"] = qosDscpClassQosCustomPol.TargetCos.ValueString()
			}
			if !qosDscpClassQosCustomPol.To.IsNull() && !qosDscpClassQosCustomPol.To.IsUnknown() {
				childMap.Attributes["to"] = qosDscpClassQosCustomPol.To.ValueString()
			}

			var tagAnnotationQosDscpClassQosCustomPolPlan, tagAnnotationQosDscpClassQosCustomPolState []TagAnnotationQosDscpClassQosCustomPolResourceModel
			qosDscpClassQosCustomPol.TagAnnotation.ElementsAs(ctx, &tagAnnotationQosDscpClassQosCustomPolPlan, false)
			for _, tagAnnotationQosDscpClassQosCustomPolstate := range qosDscpClassQosCustomPolState {
				tagAnnotationQosDscpClassQosCustomPolstate.TagAnnotation.ElementsAs(ctx, &tagAnnotationQosDscpClassQosCustomPolState, false)
			}
			if !qosDscpClassQosCustomPol.TagAnnotation.IsNull() && !qosDscpClassQosCustomPol.TagAnnotation.IsUnknown() {
				tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
				for _, tagAnnotationQosDscpClassQosCustomPol := range tagAnnotationQosDscpClassQosCustomPolPlan {
					tagAnnotationQosDscpClassQosCustomPolChildMap := NewAciObject()
					if !tagAnnotationQosDscpClassQosCustomPol.Key.IsNull() && !tagAnnotationQosDscpClassQosCustomPol.Key.IsUnknown() {
						tagAnnotationQosDscpClassQosCustomPolChildMap.Attributes["key"] = tagAnnotationQosDscpClassQosCustomPol.Key.ValueString()
					}
					if !tagAnnotationQosDscpClassQosCustomPol.Value.IsNull() && !tagAnnotationQosDscpClassQosCustomPol.Value.IsUnknown() {
						tagAnnotationQosDscpClassQosCustomPolChildMap.Attributes["value"] = tagAnnotationQosDscpClassQosCustomPol.Value.ValueString()
					}
					QosDscpClassQosCustomPolChildren = append(QosDscpClassQosCustomPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationQosDscpClassQosCustomPolChildMap})
					tagAnnotationIdentifier := TagAnnotationIdentifier{}
					tagAnnotationIdentifier.Key = tagAnnotationQosDscpClassQosCustomPol.Key
					tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
				}
				for _, tagAnnotationQosDscpClassQosCustomPol := range tagAnnotationQosDscpClassQosCustomPolState {
					delete := true
					for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers {
						if tagAnnotationIdentifier.Key == tagAnnotationQosDscpClassQosCustomPol.Key {
							delete = false
							break
						}
					}
					if delete {
						tagAnnotationQosDscpClassQosCustomPolChildMapForDelete := NewAciObject()
						tagAnnotationQosDscpClassQosCustomPolChildMapForDelete.Attributes["status"] = "deleted"
						tagAnnotationQosDscpClassQosCustomPolChildMapForDelete.Attributes["key"] = tagAnnotationQosDscpClassQosCustomPol.Key.ValueString()
						QosDscpClassQosCustomPolChildren = append(QosDscpClassQosCustomPolChildren, map[string]interface{}{"tagAnnotation": tagAnnotationQosDscpClassQosCustomPolChildMapForDelete})
					}
				}
			}

			var tagTagQosDscpClassQosCustomPolPlan, tagTagQosDscpClassQosCustomPolState []TagTagQosDscpClassQosCustomPolResourceModel
			qosDscpClassQosCustomPol.TagTag.ElementsAs(ctx, &tagTagQosDscpClassQosCustomPolPlan, false)
			for _, tagTagQosDscpClassQosCustomPolstate := range qosDscpClassQosCustomPolState {
				tagTagQosDscpClassQosCustomPolstate.TagTag.ElementsAs(ctx, &tagTagQosDscpClassQosCustomPolState, false)
			}
			if !qosDscpClassQosCustomPol.TagTag.IsNull() && !qosDscpClassQosCustomPol.TagTag.IsUnknown() {
				tagTagIdentifiers := []TagTagIdentifier{}
				for _, tagTagQosDscpClassQosCustomPol := range tagTagQosDscpClassQosCustomPolPlan {
					tagTagQosDscpClassQosCustomPolChildMap := NewAciObject()
					if !tagTagQosDscpClassQosCustomPol.Key.IsNull() && !tagTagQosDscpClassQosCustomPol.Key.IsUnknown() {
						tagTagQosDscpClassQosCustomPolChildMap.Attributes["key"] = tagTagQosDscpClassQosCustomPol.Key.ValueString()
					}
					if !tagTagQosDscpClassQosCustomPol.Value.IsNull() && !tagTagQosDscpClassQosCustomPol.Value.IsUnknown() {
						tagTagQosDscpClassQosCustomPolChildMap.Attributes["value"] = tagTagQosDscpClassQosCustomPol.Value.ValueString()
					}
					QosDscpClassQosCustomPolChildren = append(QosDscpClassQosCustomPolChildren, map[string]interface{}{"tagTag": tagTagQosDscpClassQosCustomPolChildMap})
					tagTagIdentifier := TagTagIdentifier{}
					tagTagIdentifier.Key = tagTagQosDscpClassQosCustomPol.Key
					tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
				}
				for _, tagTagQosDscpClassQosCustomPol := range tagTagQosDscpClassQosCustomPolState {
					delete := true
					for _, tagTagIdentifier := range tagTagIdentifiers {
						if tagTagIdentifier.Key == tagTagQosDscpClassQosCustomPol.Key {
							delete = false
							break
						}
					}
					if delete {
						tagTagQosDscpClassQosCustomPolChildMapForDelete := NewAciObject()
						tagTagQosDscpClassQosCustomPolChildMapForDelete.Attributes["status"] = "deleted"
						tagTagQosDscpClassQosCustomPolChildMapForDelete.Attributes["key"] = tagTagQosDscpClassQosCustomPol.Key.ValueString()
						QosDscpClassQosCustomPolChildren = append(QosDscpClassQosCustomPolChildren, map[string]interface{}{"tagTag": tagTagQosDscpClassQosCustomPolChildMapForDelete})
					}
				}
			}
			childMap.Children = QosDscpClassQosCustomPolChildren
			childPayloads = append(childPayloads, map[string]interface{}{"qosDscpClass": childMap})
			qosDscpClassIdentifier := QosDscpClassIdentifier{}
			qosDscpClassIdentifier.From = basetypes.NewStringValue(qosDscpClassQosCustomPol.From.ValueString())
			qosDscpClassIdentifier.To = basetypes.NewStringValue(qosDscpClassQosCustomPol.To.ValueString())
			qosDscpClassIdentifiers = append(qosDscpClassIdentifiers, qosDscpClassIdentifier)
		}
		for _, qosDscpClass := range qosDscpClassQosCustomPolState {
			delete := true
			for _, qosDscpClassIdentifier := range qosDscpClassIdentifiers {
				if qosDscpClassIdentifier.From == basetypes.NewStringValue(qosDscpClass.From.ValueString()) &&
					qosDscpClassIdentifier.To == basetypes.NewStringValue(qosDscpClass.To.ValueString()) {
					delete = false
					break
				}
			}
			if delete {
				qosDscpClassChildMapForDelete := NewAciObject()
				qosDscpClassChildMapForDelete.Attributes["status"] = "deleted"
				qosDscpClassChildMapForDelete.Attributes["from"] = qosDscpClass.From.ValueString()
				qosDscpClassChildMapForDelete.Attributes["to"] = qosDscpClass.To.ValueString()
				childPayloads = append(childPayloads, map[string]interface{}{"qosDscpClass": qosDscpClassChildMapForDelete})
			}
		}
	} else {
		data.QosDscpClass = types.SetNull(data.QosDscpClass.ElementType(ctx))
	}

	return childPayloads
}

func getQosCustomPolTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosCustomPolResourceModel, tagAnnotationQosCustomPolPlan, tagAnnotationQosCustomPolState []TagAnnotationQosCustomPolResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() {
		tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
		for _, tagAnnotationQosCustomPol := range tagAnnotationQosCustomPolPlan {
			childMap := NewAciObject()
			if !tagAnnotationQosCustomPol.Key.IsNull() && !tagAnnotationQosCustomPol.Key.IsUnknown() {
				childMap.Attributes["key"] = tagAnnotationQosCustomPol.Key.ValueString()
			}
			if !tagAnnotationQosCustomPol.Value.IsNull() && !tagAnnotationQosCustomPol.Value.IsUnknown() {
				childMap.Attributes["value"] = tagAnnotationQosCustomPol.Value.ValueString()
			}
			childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap})
			tagAnnotationIdentifier := TagAnnotationIdentifier{}
			tagAnnotationIdentifier.Key = tagAnnotationQosCustomPol.Key
			tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
		}
		for _, tagAnnotation := range tagAnnotationQosCustomPolState {
			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 getQosCustomPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosCustomPolResourceModel, tagTagQosCustomPolPlan, tagTagQosCustomPolState []TagTagQosCustomPolResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() {
		tagTagIdentifiers := []TagTagIdentifier{}
		for _, tagTagQosCustomPol := range tagTagQosCustomPolPlan {
			childMap := NewAciObject()
			if !tagTagQosCustomPol.Key.IsNull() && !tagTagQosCustomPol.Key.IsUnknown() {
				childMap.Attributes["key"] = tagTagQosCustomPol.Key.ValueString()
			}
			if !tagTagQosCustomPol.Value.IsNull() && !tagTagQosCustomPol.Value.IsUnknown() {
				childMap.Attributes["value"] = tagTagQosCustomPol.Value.ValueString()
			}
			childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap})
			tagTagIdentifier := TagTagIdentifier{}
			tagTagIdentifier.Key = tagTagQosCustomPol.Key
			tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
		}
		for _, tagTag := range tagTagQosCustomPolState {
			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 getQosCustomPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosCustomPolResourceModel, qosDot1PClassPlan, qosDot1PClassState []QosDot1PClassQosCustomPolResourceModel, qosDscpClassPlan, qosDscpClassState []QosDscpClassQosCustomPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosCustomPolResourceModel, tagTagPlan, tagTagState []TagTagQosCustomPolResourceModel) *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{}{}

	QosDot1PClasschildPayloads := getQosCustomPolQosDot1PClassChildPayloads(ctx, diags, data, qosDot1PClassPlan, qosDot1PClassState)
	if QosDot1PClasschildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, QosDot1PClasschildPayloads...)

	QosDscpClasschildPayloads := getQosCustomPolQosDscpClassChildPayloads(ctx, diags, data, qosDscpClassPlan, qosDscpClassState)
	if QosDscpClasschildPayloads == nil {
		return nil
	}
	childPayloads = append(childPayloads, QosDscpClasschildPayloads...)

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

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

	payloadMap["children"] = childPayloads
	if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString()
	}
	if !data.Descr.IsNull() && !data.Descr.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString()
	}
	if !data.Name.IsNull() && !data.Name.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString()
	}
	if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString()
	}
	if !data.OwnerKey.IsNull() && !data.OwnerKey.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["ownerKey"] = data.OwnerKey.ValueString()
	}
	if !data.OwnerTag.IsNull() && !data.OwnerTag.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["ownerTag"] = data.OwnerTag.ValueString()
	}
	payload, err := json.Marshal(map[string]interface{}{"qosCustomPol": 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
}
