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

func NewQosDppPolResource() resource.Resource {
	return &QosDppPolResource{}
}

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

// QosDppPolResourceModel describes the resource data model.
type QosDppPolResourceModel struct {
	Id              types.String                                    `tfsdk:"id"`
	ParentDn        types.String                                    `tfsdk:"parent_dn"`
	AdminSt         types.String                                    `tfsdk:"admin_state"`
	Annotation      types.String                                    `tfsdk:"annotation"`
	Be              customTypes.QosDppPolBeStringValue              `tfsdk:"excessive_burst"`
	BeUnit          types.String                                    `tfsdk:"excessive_burst_unit"`
	Burst           customTypes.QosDppPolBurstStringValue           `tfsdk:"burst"`
	BurstUnit       types.String                                    `tfsdk:"burst_unit"`
	ConformAction   types.String                                    `tfsdk:"conform_action"`
	ConformMarkCos  customTypes.QosDppPolConformMarkCosStringValue  `tfsdk:"conform_mark_cos"`
	ConformMarkDscp customTypes.QosDppPolConformMarkDscpStringValue `tfsdk:"conform_mark_dscp"`
	Descr           types.String                                    `tfsdk:"description"`
	ExceedAction    types.String                                    `tfsdk:"exceed_action"`
	ExceedMarkCos   customTypes.QosDppPolExceedMarkCosStringValue   `tfsdk:"exceed_mark_cos"`
	ExceedMarkDscp  customTypes.QosDppPolExceedMarkDscpStringValue  `tfsdk:"exceed_mark_dscp"`
	Mode            types.String                                    `tfsdk:"mode"`
	Name            types.String                                    `tfsdk:"name"`
	NameAlias       types.String                                    `tfsdk:"name_alias"`
	OwnerKey        types.String                                    `tfsdk:"owner_key"`
	OwnerTag        types.String                                    `tfsdk:"owner_tag"`
	Pir             types.String                                    `tfsdk:"peak_rate"`
	PirUnit         types.String                                    `tfsdk:"peak_rate_unit"`
	Rate            types.String                                    `tfsdk:"rate"`
	RateUnit        types.String                                    `tfsdk:"rate_unit"`
	SharingMode     types.String                                    `tfsdk:"sharing_mode"`
	Type            types.String                                    `tfsdk:"type"`
	ViolateAction   types.String                                    `tfsdk:"violate_action"`
	ViolateMarkCos  customTypes.QosDppPolViolateMarkCosStringValue  `tfsdk:"violate_mark_cos"`
	ViolateMarkDscp customTypes.QosDppPolViolateMarkDscpStringValue `tfsdk:"violate_mark_dscp"`
	TagAnnotation   types.Set                                       `tfsdk:"annotations"`
	TagTag          types.Set                                       `tfsdk:"tags"`
}

func getEmptyQosDppPolResourceModel() *QosDppPolResourceModel {
	return &QosDppPolResourceModel{
		Id:              basetypes.NewStringNull(),
		ParentDn:        basetypes.NewStringNull(),
		AdminSt:         basetypes.NewStringNull(),
		Annotation:      basetypes.NewStringNull(),
		Be:              customTypes.NewQosDppPolBeStringNull(),
		BeUnit:          basetypes.NewStringNull(),
		Burst:           customTypes.NewQosDppPolBurstStringNull(),
		BurstUnit:       basetypes.NewStringNull(),
		ConformAction:   basetypes.NewStringNull(),
		ConformMarkCos:  customTypes.NewQosDppPolConformMarkCosStringNull(),
		ConformMarkDscp: customTypes.NewQosDppPolConformMarkDscpStringNull(),
		Descr:           basetypes.NewStringNull(),
		ExceedAction:    basetypes.NewStringNull(),
		ExceedMarkCos:   customTypes.NewQosDppPolExceedMarkCosStringNull(),
		ExceedMarkDscp:  customTypes.NewQosDppPolExceedMarkDscpStringNull(),
		Mode:            basetypes.NewStringNull(),
		Name:            basetypes.NewStringNull(),
		NameAlias:       basetypes.NewStringNull(),
		OwnerKey:        basetypes.NewStringNull(),
		OwnerTag:        basetypes.NewStringNull(),
		Pir:             basetypes.NewStringNull(),
		PirUnit:         basetypes.NewStringNull(),
		Rate:            basetypes.NewStringNull(),
		RateUnit:        basetypes.NewStringNull(),
		SharingMode:     basetypes.NewStringNull(),
		Type:            basetypes.NewStringNull(),
		ViolateAction:   basetypes.NewStringNull(),
		ViolateMarkCos:  customTypes.NewQosDppPolViolateMarkCosStringNull(),
		ViolateMarkDscp: customTypes.NewQosDppPolViolateMarkDscpStringNull(),
		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,
			},
		}),
	}
}

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

func getEmptyTagAnnotationQosDppPolResourceModel() TagAnnotationQosDppPolResourceModel {
	return TagAnnotationQosDppPolResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

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

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

func getEmptyTagTagQosDppPolResourceModel() TagTagQosDppPolResourceModel {
	return TagTagQosDppPolResourceModel{
		Key:   basetypes.NewStringNull(),
		Value: basetypes.NewStringNull(),
	}
}

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

type QosDppPolIdentifier struct {
	Name types.String
}

func (r *QosDppPolResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
	if !req.Plan.Raw.IsNull() {
		var planData, stateData *QosDppPolResourceModel
		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() {
			setQosDppPolId(ctx, planData)
		}

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

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

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

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

		Attributes: map[string]schema.Attribute{
			"id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "The distinguished name (DN) of the Data Plane Policing Policy object.",
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
				},
			},
			"parent_dn": schema.StringAttribute{
				Optional:            true,
				Computed:            true,
				Default:             stringdefault.StaticString("uni/infra"),
				MarkdownDescription: "The distinguished name (DN) of the parent object.",
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					stringplanmodifier.RequiresReplace(),
				},
			},
			"admin_state": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("disabled", "enabled"),
				},
				MarkdownDescription: `The administrative state of the Data Plane Policing Policy object.`,
			},
			"annotation": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Default:             stringdefault.StaticString(globalAnnotation),
				MarkdownDescription: `The annotation of the Data Plane Policing Policy object.`,
			},
			"excessive_burst": schema.StringAttribute{
				CustomType: customTypes.QosDppPolBeStringType{},
				Optional:   true,
				Computed:   true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.Any(
						stringvalidator.OneOf("0xffffffffffffffff", "unspecified"),
						validators.InBetweenFromString(0, 5.4975581376e+11),
					),
				},
				MarkdownDescription: `The excessive burst size of the Data Plane Policing Policy object. Only applicable for 2R3C policer.`,
			},
			"excessive_burst_unit": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("giga", "kilo", "mega", "msec", "unspecified", "usec"),
				},
				MarkdownDescription: `The excessive burst size unit of the Data Plane Policing Policy object. Only applicable for 2R3C policer.`,
			},
			"burst": schema.StringAttribute{
				CustomType: customTypes.QosDppPolBurstStringType{},
				Optional:   true,
				Computed:   true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.Any(
						stringvalidator.OneOf("0xffffffffffffffff", "unspecified"),
						validators.InBetweenFromString(0, 5.4975581376e+11),
					),
				},
				MarkdownDescription: `The burst size of the Data Plane Policing Policy object.`,
			},
			"burst_unit": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("giga", "kilo", "mega", "msec", "unspecified", "usec"),
				},
				MarkdownDescription: `The burst size unit of the Data Plane Policing Policy object.`,
			},
			"conform_action": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("drop", "mark", "transmit"),
				},
				MarkdownDescription: `The conform action of the Data Plane Policing Policy object.`,
			},
			"conform_mark_cos": schema.StringAttribute{
				CustomType: customTypes.QosDppPolConformMarkCosStringType{},
				Optional:   true,
				Computed:   true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.Any(
						stringvalidator.OneOf("0xffff", "unspecified"),
						validators.InBetweenFromString(0, 7),
					),
				},
				MarkdownDescription: `The conform mark class of service (CoS) of the Data Plane Policing Policy object.`,
			},
			"conform_mark_dscp": schema.StringAttribute{
				CustomType: customTypes.QosDppPolConformMarkDscpStringType{},
				Optional:   true,
				Computed:   true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.Any(
						stringvalidator.OneOf("0xffff", "unspecified"),
						validators.InBetweenFromString(0, 63),
					),
				},
				MarkdownDescription: `The conform mark differentiated services code point (DSCP) of the Data Plane Policing Policy object.`,
			},
			"description": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The description of the Data Plane Policing Policy object.`,
			},
			"exceed_action": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("drop", "mark", "transmit"),
				},
				MarkdownDescription: `The exceed action of the Data Plane Policing Policy object.`,
			},
			"exceed_mark_cos": schema.StringAttribute{
				CustomType: customTypes.QosDppPolExceedMarkCosStringType{},
				Optional:   true,
				Computed:   true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.Any(
						stringvalidator.OneOf("0xffff", "unspecified"),
						validators.InBetweenFromString(0, 7),
					),
				},
				MarkdownDescription: `The exceed mark class of service (CoS) of the Data Plane Policing Policy object.`,
			},
			"exceed_mark_dscp": schema.StringAttribute{
				CustomType: customTypes.QosDppPolExceedMarkDscpStringType{},
				Optional:   true,
				Computed:   true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.Any(
						stringvalidator.OneOf("0xffff", "unspecified"),
						validators.InBetweenFromString(0, 63),
					),
				},
				MarkdownDescription: `The exceed mark differentiated services code point (DSCP) of the Data Plane Policing Policy object.`,
			},
			"mode": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("bit", "packet"),
				},
				MarkdownDescription: `Policer mode - bytes or packet policer.`,
			},
			"name": schema.StringAttribute{
				Required: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
					stringplanmodifier.RequiresReplace(),
				},
				MarkdownDescription: `The name of the Data Plane Policing Policy object.`,
			},
			"name_alias": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The name alias of the Data Plane Policing 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.`,
			},
			"peak_rate": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The peak information rate (PIR) of the Data Plane Policing Policy object. Only applicable for 2R3C policer.`,
			},
			"peak_rate_unit": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("giga", "kilo", "mega", "unspecified"),
				},
				MarkdownDescription: `The peak information rate (PIR) unit of the Data Plane Policing Policy object. Only applicable for 2R3C policer.`,
			},
			"rate": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				MarkdownDescription: `The rate of the Data Plane Policing Policy object.`,
			},
			"rate_unit": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("giga", "kilo", "mega", "unspecified"),
				},
				MarkdownDescription: `The rate unit of the Data Plane Policing Policy object.`,
			},
			"sharing_mode": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("dedicated", "shared"),
				},
				MarkdownDescription: `The sharing mode of the Data Plane Policing Policy object.`,
			},
			"type": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("1R2C", "2R3C"),
				},
				MarkdownDescription: `The type of the Data Plane Policing Policy object.`,
			},
			"violate_action": schema.StringAttribute{
				Optional: true,
				Computed: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.OneOf("drop", "mark", "transmit"),
				},
				MarkdownDescription: `The violate action of the Data Plane Policing Policy object.`,
			},
			"violate_mark_cos": schema.StringAttribute{
				CustomType: customTypes.QosDppPolViolateMarkCosStringType{},
				Optional:   true,
				Computed:   true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.Any(
						stringvalidator.OneOf("0xffff", "unspecified"),
						validators.InBetweenFromString(0, 7),
					),
				},
				MarkdownDescription: `The violate mark class of service (CoS) of the Data Plane Policing Policy object.`,
			},
			"violate_mark_dscp": schema.StringAttribute{
				CustomType: customTypes.QosDppPolViolateMarkDscpStringType{},
				Optional:   true,
				Computed:   true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
					SetToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate(),
				},
				Validators: []validator.String{
					stringvalidator.Any(
						stringvalidator.OneOf("0xffff", "unspecified"),
						validators.InBetweenFromString(0, 63),
					),
				},
				MarkdownDescription: `The violate mark differentiated services code point (DSCP) of the Data Plane Policing Policy 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{
							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_data_plane_policing_policy")
}

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

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

	var data *QosDppPolResourceModel

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

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

	var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDppPolResourceModel
	data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false)
	stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false)
	var tagTagPlan, tagTagState []TagTagQosDppPolResourceModel
	data.TagTag.ElementsAs(ctx, &tagTagPlan, false)
	stateData.TagTag.ElementsAs(ctx, &tagTagState, false)
	jsonPayload := getQosDppPolCreateJsonPayload(ctx, &resp.Diagnostics, true, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState)

	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
	}

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

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

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

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

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

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

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

	var tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDppPolResourceModel
	data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false)
	stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false)
	var tagTagPlan, tagTagState []TagTagQosDppPolResourceModel
	data.TagTag.ElementsAs(ctx, &tagTagPlan, false)
	stateData.TagTag.ElementsAs(ctx, &tagTagState, false)
	jsonPayload := getQosDppPolCreateJsonPayload(ctx, &resp.Diagnostics, false, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState)

	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
	}

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

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

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

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

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

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

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

	readData := getEmptyQosDppPolResourceModel()

	if diags.HasError() {
		return
	}
	if requestData.Search("imdata").Search("qosDppPol").Data() != nil {
		classReadInfo := requestData.Search("imdata").Search("qosDppPol").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))
					setQosDppPolParentDn(ctx, attributeValue.(string), readData)
				}
				if attributeName == "adminSt" {
					readData.AdminSt = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "annotation" {
					readData.Annotation = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "be" {
					readData.Be = customTypes.NewQosDppPolBeStringValue(attributeValue.(string))
				}
				if attributeName == "beUnit" {
					readData.BeUnit = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "burst" {
					readData.Burst = customTypes.NewQosDppPolBurstStringValue(attributeValue.(string))
				}
				if attributeName == "burstUnit" {
					readData.BurstUnit = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "conformAction" {
					readData.ConformAction = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "conformMarkCos" {
					readData.ConformMarkCos = customTypes.NewQosDppPolConformMarkCosStringValue(attributeValue.(string))
				}
				if attributeName == "conformMarkDscp" {
					readData.ConformMarkDscp = customTypes.NewQosDppPolConformMarkDscpStringValue(attributeValue.(string))
				}
				if attributeName == "descr" {
					readData.Descr = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "exceedAction" {
					readData.ExceedAction = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "exceedMarkCos" {
					readData.ExceedMarkCos = customTypes.NewQosDppPolExceedMarkCosStringValue(attributeValue.(string))
				}
				if attributeName == "exceedMarkDscp" {
					readData.ExceedMarkDscp = customTypes.NewQosDppPolExceedMarkDscpStringValue(attributeValue.(string))
				}
				if attributeName == "mode" {
					readData.Mode = 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))
				}
				if attributeName == "pir" {
					readData.Pir = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "pirUnit" {
					readData.PirUnit = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "rate" {
					readData.Rate = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "rateUnit" {
					readData.RateUnit = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "sharingMode" {
					readData.SharingMode = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "type" {
					readData.Type = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "violateAction" {
					readData.ViolateAction = basetypes.NewStringValue(attributeValue.(string))
				}
				if attributeName == "violateMarkCos" {
					readData.ViolateMarkCos = customTypes.NewQosDppPolViolateMarkCosStringValue(attributeValue.(string))
				}
				if attributeName == "violateMarkDscp" {
					readData.ViolateMarkDscp = customTypes.NewQosDppPolViolateMarkDscpStringValue(attributeValue.(string))
				}
			}
			TagAnnotationQosDppPolList := make([]TagAnnotationQosDppPolResourceModel, 0)
			TagTagQosDppPolList := make([]TagTagQosDppPolResourceModel, 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 == "tagAnnotation" {
							TagAnnotationQosDppPol := getEmptyTagAnnotationQosDppPolResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "key" {
									TagAnnotationQosDppPol.Key = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "value" {
									TagAnnotationQosDppPol.Value = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagAnnotationQosDppPolList = append(TagAnnotationQosDppPolList, TagAnnotationQosDppPol)
						}
						if childClassName == "tagTag" {
							TagTagQosDppPol := getEmptyTagTagQosDppPolResourceModel()
							for childAttributeName, childAttributeValue := range childAttributes {
								if childAttributeName == "key" {
									TagTagQosDppPol.Key = basetypes.NewStringValue(childAttributeValue.(string))
								}
								if childAttributeName == "value" {
									TagTagQosDppPol.Value = basetypes.NewStringValue(childAttributeValue.(string))
								}

							}
							TagTagQosDppPolList = append(TagTagQosDppPolList, TagTagQosDppPol)
						}
					}
				}
			}
			tagAnnotationSet, _ := types.SetValueFrom(ctx, readData.TagAnnotation.ElementType(ctx), TagAnnotationQosDppPolList)
			readData.TagAnnotation = tagAnnotationSet
			tagTagSet, _ := types.SetValueFrom(ctx, readData.TagTag.ElementType(ctx), TagTagQosDppPolList)
			readData.TagTag = tagTagSet
		} else {
			diags.AddError(
				"too many results in response",
				fmt.Sprintf("%v matches returned for class 'qosDppPol'. Please report this issue to the provider developers.", len(classReadInfo)),
			)
		}
	} else {
		readData.Id = basetypes.NewStringNull()
	}
	*data = *readData
}

func getQosDppPolRn(ctx context.Context, data *QosDppPolResourceModel) string {
	return fmt.Sprintf("qosdpppol-%s", data.Name.ValueString())
}

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

func getQosDppPolTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosDppPolResourceModel, tagAnnotationQosDppPolPlan, tagAnnotationQosDppPolState []TagAnnotationQosDppPolResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.TagAnnotation.IsNull() && !data.TagAnnotation.IsUnknown() {
		tagAnnotationIdentifiers := []TagAnnotationIdentifier{}
		for _, tagAnnotationQosDppPol := range tagAnnotationQosDppPolPlan {
			childMap := NewAciObject()
			if !tagAnnotationQosDppPol.Key.IsNull() && !tagAnnotationQosDppPol.Key.IsUnknown() {
				childMap.Attributes["key"] = tagAnnotationQosDppPol.Key.ValueString()
			}
			if !tagAnnotationQosDppPol.Value.IsNull() && !tagAnnotationQosDppPol.Value.IsUnknown() {
				childMap.Attributes["value"] = tagAnnotationQosDppPol.Value.ValueString()
			}
			childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap})
			tagAnnotationIdentifier := TagAnnotationIdentifier{}
			tagAnnotationIdentifier.Key = tagAnnotationQosDppPol.Key
			tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier)
		}
		for _, tagAnnotation := range tagAnnotationQosDppPolState {
			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 getQosDppPolTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *QosDppPolResourceModel, tagTagQosDppPolPlan, tagTagQosDppPolState []TagTagQosDppPolResourceModel) []map[string]interface{} {
	childPayloads := []map[string]interface{}{}
	if !data.TagTag.IsNull() && !data.TagTag.IsUnknown() {
		tagTagIdentifiers := []TagTagIdentifier{}
		for _, tagTagQosDppPol := range tagTagQosDppPolPlan {
			childMap := NewAciObject()
			if !tagTagQosDppPol.Key.IsNull() && !tagTagQosDppPol.Key.IsUnknown() {
				childMap.Attributes["key"] = tagTagQosDppPol.Key.ValueString()
			}
			if !tagTagQosDppPol.Value.IsNull() && !tagTagQosDppPol.Value.IsUnknown() {
				childMap.Attributes["value"] = tagTagQosDppPol.Value.ValueString()
			}
			childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap})
			tagTagIdentifier := TagTagIdentifier{}
			tagTagIdentifier.Key = tagTagQosDppPol.Key
			tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier)
		}
		for _, tagTag := range tagTagQosDppPolState {
			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 getQosDppPolCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, createType bool, data *QosDppPolResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationQosDppPolResourceModel, tagTagPlan, tagTagState []TagTagQosDppPolResourceModel) *container.Container {
	payloadMap := map[string]interface{}{}
	payloadMap["attributes"] = map[string]string{}

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

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

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

	payloadMap["children"] = childPayloads
	if !data.AdminSt.IsNull() && !data.AdminSt.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["adminSt"] = data.AdminSt.ValueString()
	}
	if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString()
	}
	if !data.Be.IsNull() && !data.Be.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["be"] = data.Be.ValueString()
	}
	if !data.BeUnit.IsNull() && !data.BeUnit.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["beUnit"] = data.BeUnit.ValueString()
	}
	if !data.Burst.IsNull() && !data.Burst.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["burst"] = data.Burst.ValueString()
	}
	if !data.BurstUnit.IsNull() && !data.BurstUnit.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["burstUnit"] = data.BurstUnit.ValueString()
	}
	if !data.ConformAction.IsNull() && !data.ConformAction.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["conformAction"] = data.ConformAction.ValueString()
	}
	if !data.ConformMarkCos.IsNull() && !data.ConformMarkCos.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["conformMarkCos"] = data.ConformMarkCos.ValueString()
	}
	if !data.ConformMarkDscp.IsNull() && !data.ConformMarkDscp.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["conformMarkDscp"] = data.ConformMarkDscp.ValueString()
	}
	if !data.Descr.IsNull() && !data.Descr.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString()
	}
	if !data.ExceedAction.IsNull() && !data.ExceedAction.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["exceedAction"] = data.ExceedAction.ValueString()
	}
	if !data.ExceedMarkCos.IsNull() && !data.ExceedMarkCos.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["exceedMarkCos"] = data.ExceedMarkCos.ValueString()
	}
	if !data.ExceedMarkDscp.IsNull() && !data.ExceedMarkDscp.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["exceedMarkDscp"] = data.ExceedMarkDscp.ValueString()
	}
	if !data.Mode.IsNull() && !data.Mode.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["mode"] = data.Mode.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()
	}
	if !data.Pir.IsNull() && !data.Pir.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["pir"] = data.Pir.ValueString()
	}
	if !data.PirUnit.IsNull() && !data.PirUnit.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["pirUnit"] = data.PirUnit.ValueString()
	}
	if !data.Rate.IsNull() && !data.Rate.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["rate"] = data.Rate.ValueString()
	}
	if !data.RateUnit.IsNull() && !data.RateUnit.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["rateUnit"] = data.RateUnit.ValueString()
	}
	if !data.SharingMode.IsNull() && !data.SharingMode.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["sharingMode"] = data.SharingMode.ValueString()
	}
	if !data.Type.IsNull() && !data.Type.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["type"] = data.Type.ValueString()
	}
	if !data.ViolateAction.IsNull() && !data.ViolateAction.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["violateAction"] = data.ViolateAction.ValueString()
	}
	if !data.ViolateMarkCos.IsNull() && !data.ViolateMarkCos.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["violateMarkCos"] = data.ViolateMarkCos.ValueString()
	}
	if !data.ViolateMarkDscp.IsNull() && !data.ViolateMarkDscp.IsUnknown() {
		payloadMap["attributes"].(map[string]string)["violateMarkDscp"] = data.ViolateMarkDscp.ValueString()
	}
	payload, err := json.Marshal(map[string]interface{}{"qosDppPol": 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
}
