// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

// Code generated by "gen/generator.go"; DO NOT EDIT.

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
	"context"
	"fmt"
	"net/url"
	"reflect"
	"regexp"
	"strconv"
	"strings"

	"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
	"github.com/hashicorp/terraform-plugin-framework/types"
	"github.com/tidwall/gjson"
	"github.com/tidwall/sjson"
)

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin types
type VRF struct {
	Device                         types.String                        `tfsdk:"device"`
	Id                             types.String                        `tfsdk:"id"`
	DeleteMode                     types.String                        `tfsdk:"delete_mode"`
	Name                           types.String                        `tfsdk:"name"`
	Description                    types.String                        `tfsdk:"description"`
	Rd                             types.String                        `tfsdk:"rd"`
	AddressFamilyIpv4              types.Bool                          `tfsdk:"address_family_ipv4"`
	AddressFamilyIpv6              types.Bool                          `tfsdk:"address_family_ipv6"`
	VpnId                          types.String                        `tfsdk:"vpn_id"`
	RouteTargetImport              []VRFRouteTargetImport              `tfsdk:"route_target_import"`
	RouteTargetExport              []VRFRouteTargetExport              `tfsdk:"route_target_export"`
	Ipv4RouteTargetImport          []VRFIpv4RouteTargetImport          `tfsdk:"ipv4_route_target_import"`
	Ipv4RouteTargetImportStitching []VRFIpv4RouteTargetImportStitching `tfsdk:"ipv4_route_target_import_stitching"`
	Ipv4RouteTargetExport          []VRFIpv4RouteTargetExport          `tfsdk:"ipv4_route_target_export"`
	Ipv4RouteTargetExportStitching []VRFIpv4RouteTargetExportStitching `tfsdk:"ipv4_route_target_export_stitching"`
	Ipv6RouteTargetImport          []VRFIpv6RouteTargetImport          `tfsdk:"ipv6_route_target_import"`
	Ipv6RouteTargetImportStitching []VRFIpv6RouteTargetImportStitching `tfsdk:"ipv6_route_target_import_stitching"`
	Ipv6RouteTargetExport          []VRFIpv6RouteTargetExport          `tfsdk:"ipv6_route_target_export"`
	Ipv6RouteTargetExportStitching []VRFIpv6RouteTargetExportStitching `tfsdk:"ipv6_route_target_export_stitching"`
}

type VRFData struct {
	Device                         types.String                        `tfsdk:"device"`
	Id                             types.String                        `tfsdk:"id"`
	Name                           types.String                        `tfsdk:"name"`
	Description                    types.String                        `tfsdk:"description"`
	Rd                             types.String                        `tfsdk:"rd"`
	AddressFamilyIpv4              types.Bool                          `tfsdk:"address_family_ipv4"`
	AddressFamilyIpv6              types.Bool                          `tfsdk:"address_family_ipv6"`
	VpnId                          types.String                        `tfsdk:"vpn_id"`
	RouteTargetImport              []VRFRouteTargetImport              `tfsdk:"route_target_import"`
	RouteTargetExport              []VRFRouteTargetExport              `tfsdk:"route_target_export"`
	Ipv4RouteTargetImport          []VRFIpv4RouteTargetImport          `tfsdk:"ipv4_route_target_import"`
	Ipv4RouteTargetImportStitching []VRFIpv4RouteTargetImportStitching `tfsdk:"ipv4_route_target_import_stitching"`
	Ipv4RouteTargetExport          []VRFIpv4RouteTargetExport          `tfsdk:"ipv4_route_target_export"`
	Ipv4RouteTargetExportStitching []VRFIpv4RouteTargetExportStitching `tfsdk:"ipv4_route_target_export_stitching"`
	Ipv6RouteTargetImport          []VRFIpv6RouteTargetImport          `tfsdk:"ipv6_route_target_import"`
	Ipv6RouteTargetImportStitching []VRFIpv6RouteTargetImportStitching `tfsdk:"ipv6_route_target_import_stitching"`
	Ipv6RouteTargetExport          []VRFIpv6RouteTargetExport          `tfsdk:"ipv6_route_target_export"`
	Ipv6RouteTargetExportStitching []VRFIpv6RouteTargetExportStitching `tfsdk:"ipv6_route_target_export_stitching"`
}
type VRFRouteTargetImport struct {
	Value     types.String `tfsdk:"value"`
	Stitching types.Bool   `tfsdk:"stitching"`
}
type VRFRouteTargetExport struct {
	Value     types.String `tfsdk:"value"`
	Stitching types.Bool   `tfsdk:"stitching"`
}
type VRFIpv4RouteTargetImport struct {
	Value types.String `tfsdk:"value"`
}
type VRFIpv4RouteTargetImportStitching struct {
	Value     types.String `tfsdk:"value"`
	Stitching types.Bool   `tfsdk:"stitching"`
}
type VRFIpv4RouteTargetExport struct {
	Value types.String `tfsdk:"value"`
}
type VRFIpv4RouteTargetExportStitching struct {
	Value     types.String `tfsdk:"value"`
	Stitching types.Bool   `tfsdk:"stitching"`
}
type VRFIpv6RouteTargetImport struct {
	Value types.String `tfsdk:"value"`
}
type VRFIpv6RouteTargetImportStitching struct {
	Value     types.String `tfsdk:"value"`
	Stitching types.Bool   `tfsdk:"stitching"`
}
type VRFIpv6RouteTargetExport struct {
	Value types.String `tfsdk:"value"`
}
type VRFIpv6RouteTargetExportStitching struct {
	Value     types.String `tfsdk:"value"`
	Stitching types.Bool   `tfsdk:"stitching"`
}

// End of section. //template:end types

// Section below is generated&owned by "gen/generator.go". //template:begin getPath

func (data VRF) getPath() string {
	return fmt.Sprintf("Cisco-IOS-XE-native:native/vrf/definition=%s", url.QueryEscape(fmt.Sprintf("%v", data.Name.ValueString())))
}

func (data VRFData) getPath() string {
	return fmt.Sprintf("Cisco-IOS-XE-native:native/vrf/definition=%s", url.QueryEscape(fmt.Sprintf("%v", data.Name.ValueString())))
}

// if last path element has a key -> remove it
func (data VRF) getPathShort() string {
	path := data.getPath()
	re := regexp.MustCompile(`(.*)=[^\/]*$`)
	matches := re.FindStringSubmatch(path)
	if len(matches) <= 1 {
		return path
	}
	return matches[1]
}

// End of section. //template:end getPath

// Section below is generated&owned by "gen/generator.go". //template:begin toBody

func (data VRF) toBody(ctx context.Context) string {
	body := `{"` + helpers.LastElement(data.getPath()) + `":{}}`
	if !data.Name.IsNull() && !data.Name.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"name", data.Name.ValueString())
	}
	if !data.Description.IsNull() && !data.Description.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"description", data.Description.ValueString())
	}
	if !data.Rd.IsNull() && !data.Rd.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"rd", data.Rd.ValueString())
	}
	if !data.AddressFamilyIpv4.IsNull() && !data.AddressFamilyIpv4.IsUnknown() {
		if data.AddressFamilyIpv4.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4", map[string]string{})
		}
	}
	if !data.AddressFamilyIpv6.IsNull() && !data.AddressFamilyIpv6.IsUnknown() {
		if data.AddressFamilyIpv6.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6", map[string]string{})
		}
	}
	if !data.VpnId.IsNull() && !data.VpnId.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vpn.id", data.VpnId.ValueString())
	}
	if len(data.RouteTargetImport) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"route-target.import", []interface{}{})
		for index, item := range data.RouteTargetImport {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"route-target.import"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
			if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
				if item.Stitching.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"route-target.import"+"."+strconv.Itoa(index)+"."+"stitching", map[string]string{})
				}
			}
		}
	}
	if len(data.RouteTargetExport) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"route-target.export", []interface{}{})
		for index, item := range data.RouteTargetExport {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"route-target.export"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
			if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
				if item.Stitching.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"route-target.export"+"."+strconv.Itoa(index)+"."+"stitching", map[string]string{})
				}
			}
		}
	}
	if len(data.Ipv4RouteTargetImport) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.import-route-target.without-stitching", []interface{}{})
		for index, item := range data.Ipv4RouteTargetImport {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.import-route-target.without-stitching"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
		}
	}
	if len(data.Ipv4RouteTargetImportStitching) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.import-route-target.with-stitching", []interface{}{})
		for index, item := range data.Ipv4RouteTargetImportStitching {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.import-route-target.with-stitching"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
			if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
				if item.Stitching.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.import-route-target.with-stitching"+"."+strconv.Itoa(index)+"."+"stitching", map[string]string{})
				}
			}
		}
	}
	if len(data.Ipv4RouteTargetExport) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.export-route-target.without-stitching", []interface{}{})
		for index, item := range data.Ipv4RouteTargetExport {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.export-route-target.without-stitching"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
		}
	}
	if len(data.Ipv4RouteTargetExportStitching) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.export-route-target.with-stitching", []interface{}{})
		for index, item := range data.Ipv4RouteTargetExportStitching {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.export-route-target.with-stitching"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
			if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
				if item.Stitching.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv4.route-target.export-route-target.with-stitching"+"."+strconv.Itoa(index)+"."+"stitching", map[string]string{})
				}
			}
		}
	}
	if len(data.Ipv6RouteTargetImport) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.import-route-target.without-stitching", []interface{}{})
		for index, item := range data.Ipv6RouteTargetImport {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.import-route-target.without-stitching"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
		}
	}
	if len(data.Ipv6RouteTargetImportStitching) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.import-route-target.with-stitching", []interface{}{})
		for index, item := range data.Ipv6RouteTargetImportStitching {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.import-route-target.with-stitching"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
			if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
				if item.Stitching.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.import-route-target.with-stitching"+"."+strconv.Itoa(index)+"."+"stitching", map[string]string{})
				}
			}
		}
	}
	if len(data.Ipv6RouteTargetExport) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.export-route-target.without-stitching", []interface{}{})
		for index, item := range data.Ipv6RouteTargetExport {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.export-route-target.without-stitching"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
		}
	}
	if len(data.Ipv6RouteTargetExportStitching) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.export-route-target.with-stitching", []interface{}{})
		for index, item := range data.Ipv6RouteTargetExportStitching {
			if !item.Value.IsNull() && !item.Value.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.export-route-target.with-stitching"+"."+strconv.Itoa(index)+"."+"asn-ip", item.Value.ValueString())
			}
			if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
				if item.Stitching.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"address-family.ipv6.route-target.export-route-target.with-stitching"+"."+strconv.Itoa(index)+"."+"stitching", map[string]string{})
				}
			}
		}
	}
	return body
}

// End of section. //template:end toBody

// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody

func (data *VRF) updateFromBody(ctx context.Context, res gjson.Result) {
	prefix := helpers.LastElement(data.getPath()) + "."
	if res.Get(helpers.LastElement(data.getPath())).IsArray() {
		prefix += "0."
	}
	if value := res.Get(prefix + "name"); value.Exists() && !data.Name.IsNull() {
		data.Name = types.StringValue(value.String())
	} else {
		data.Name = types.StringNull()
	}
	if value := res.Get(prefix + "description"); value.Exists() && !data.Description.IsNull() {
		data.Description = types.StringValue(value.String())
	} else {
		data.Description = types.StringNull()
	}
	if value := res.Get(prefix + "rd"); value.Exists() && !data.Rd.IsNull() {
		data.Rd = types.StringValue(value.String())
	} else {
		data.Rd = types.StringNull()
	}
	if value := res.Get(prefix + "address-family.ipv4"); !data.AddressFamilyIpv4.IsNull() {
		if value.Exists() {
			data.AddressFamilyIpv4 = types.BoolValue(true)
		} else {
			data.AddressFamilyIpv4 = types.BoolValue(false)
		}
	} else {
		data.AddressFamilyIpv4 = types.BoolNull()
	}
	if value := res.Get(prefix + "address-family.ipv6"); !data.AddressFamilyIpv6.IsNull() {
		if value.Exists() {
			data.AddressFamilyIpv6 = types.BoolValue(true)
		} else {
			data.AddressFamilyIpv6 = types.BoolValue(false)
		}
	} else {
		data.AddressFamilyIpv6 = types.BoolNull()
	}
	if value := res.Get(prefix + "vpn.id"); value.Exists() && !data.VpnId.IsNull() {
		data.VpnId = types.StringValue(value.String())
	} else {
		data.VpnId = types.StringNull()
	}
	for i := range data.RouteTargetImport {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.RouteTargetImport[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "route-target.import").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.RouteTargetImport[i].Value.IsNull() {
			data.RouteTargetImport[i].Value = types.StringValue(value.String())
		} else {
			data.RouteTargetImport[i].Value = types.StringNull()
		}
		if value := r.Get("stitching"); !data.RouteTargetImport[i].Stitching.IsNull() {
			if value.Exists() {
				data.RouteTargetImport[i].Stitching = types.BoolValue(true)
			} else {
				data.RouteTargetImport[i].Stitching = types.BoolValue(false)
			}
		} else {
			data.RouteTargetImport[i].Stitching = types.BoolNull()
		}
	}
	for i := range data.RouteTargetExport {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.RouteTargetExport[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "route-target.export").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.RouteTargetExport[i].Value.IsNull() {
			data.RouteTargetExport[i].Value = types.StringValue(value.String())
		} else {
			data.RouteTargetExport[i].Value = types.StringNull()
		}
		if value := r.Get("stitching"); !data.RouteTargetExport[i].Stitching.IsNull() {
			if value.Exists() {
				data.RouteTargetExport[i].Stitching = types.BoolValue(true)
			} else {
				data.RouteTargetExport[i].Stitching = types.BoolValue(false)
			}
		} else {
			data.RouteTargetExport[i].Stitching = types.BoolNull()
		}
	}
	for i := range data.Ipv4RouteTargetImport {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.Ipv4RouteTargetImport[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "address-family.ipv4.route-target.import-route-target.without-stitching").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.Ipv4RouteTargetImport[i].Value.IsNull() {
			data.Ipv4RouteTargetImport[i].Value = types.StringValue(value.String())
		} else {
			data.Ipv4RouteTargetImport[i].Value = types.StringNull()
		}
	}
	for i := range data.Ipv4RouteTargetImportStitching {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.Ipv4RouteTargetImportStitching[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "address-family.ipv4.route-target.import-route-target.with-stitching").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.Ipv4RouteTargetImportStitching[i].Value.IsNull() {
			data.Ipv4RouteTargetImportStitching[i].Value = types.StringValue(value.String())
		} else {
			data.Ipv4RouteTargetImportStitching[i].Value = types.StringNull()
		}
		if value := r.Get("stitching"); !data.Ipv4RouteTargetImportStitching[i].Stitching.IsNull() {
			if value.Exists() {
				data.Ipv4RouteTargetImportStitching[i].Stitching = types.BoolValue(true)
			} else {
				data.Ipv4RouteTargetImportStitching[i].Stitching = types.BoolValue(false)
			}
		} else {
			data.Ipv4RouteTargetImportStitching[i].Stitching = types.BoolNull()
		}
	}
	for i := range data.Ipv4RouteTargetExport {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.Ipv4RouteTargetExport[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "address-family.ipv4.route-target.export-route-target.without-stitching").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.Ipv4RouteTargetExport[i].Value.IsNull() {
			data.Ipv4RouteTargetExport[i].Value = types.StringValue(value.String())
		} else {
			data.Ipv4RouteTargetExport[i].Value = types.StringNull()
		}
	}
	for i := range data.Ipv4RouteTargetExportStitching {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.Ipv4RouteTargetExportStitching[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "address-family.ipv4.route-target.export-route-target.with-stitching").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.Ipv4RouteTargetExportStitching[i].Value.IsNull() {
			data.Ipv4RouteTargetExportStitching[i].Value = types.StringValue(value.String())
		} else {
			data.Ipv4RouteTargetExportStitching[i].Value = types.StringNull()
		}
		if value := r.Get("stitching"); !data.Ipv4RouteTargetExportStitching[i].Stitching.IsNull() {
			if value.Exists() {
				data.Ipv4RouteTargetExportStitching[i].Stitching = types.BoolValue(true)
			} else {
				data.Ipv4RouteTargetExportStitching[i].Stitching = types.BoolValue(false)
			}
		} else {
			data.Ipv4RouteTargetExportStitching[i].Stitching = types.BoolNull()
		}
	}
	for i := range data.Ipv6RouteTargetImport {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.Ipv6RouteTargetImport[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "address-family.ipv6.route-target.import-route-target.without-stitching").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.Ipv6RouteTargetImport[i].Value.IsNull() {
			data.Ipv6RouteTargetImport[i].Value = types.StringValue(value.String())
		} else {
			data.Ipv6RouteTargetImport[i].Value = types.StringNull()
		}
	}
	for i := range data.Ipv6RouteTargetImportStitching {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.Ipv6RouteTargetImportStitching[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "address-family.ipv6.route-target.import-route-target.with-stitching").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.Ipv6RouteTargetImportStitching[i].Value.IsNull() {
			data.Ipv6RouteTargetImportStitching[i].Value = types.StringValue(value.String())
		} else {
			data.Ipv6RouteTargetImportStitching[i].Value = types.StringNull()
		}
		if value := r.Get("stitching"); !data.Ipv6RouteTargetImportStitching[i].Stitching.IsNull() {
			if value.Exists() {
				data.Ipv6RouteTargetImportStitching[i].Stitching = types.BoolValue(true)
			} else {
				data.Ipv6RouteTargetImportStitching[i].Stitching = types.BoolValue(false)
			}
		} else {
			data.Ipv6RouteTargetImportStitching[i].Stitching = types.BoolNull()
		}
	}
	for i := range data.Ipv6RouteTargetExport {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.Ipv6RouteTargetExport[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "address-family.ipv6.route-target.export-route-target.without-stitching").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.Ipv6RouteTargetExport[i].Value.IsNull() {
			data.Ipv6RouteTargetExport[i].Value = types.StringValue(value.String())
		} else {
			data.Ipv6RouteTargetExport[i].Value = types.StringNull()
		}
	}
	for i := range data.Ipv6RouteTargetExportStitching {
		keys := [...]string{"asn-ip"}
		keyValues := [...]string{data.Ipv6RouteTargetExportStitching[i].Value.ValueString()}

		var r gjson.Result
		res.Get(prefix + "address-family.ipv6.route-target.export-route-target.with-stitching").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("asn-ip"); value.Exists() && !data.Ipv6RouteTargetExportStitching[i].Value.IsNull() {
			data.Ipv6RouteTargetExportStitching[i].Value = types.StringValue(value.String())
		} else {
			data.Ipv6RouteTargetExportStitching[i].Value = types.StringNull()
		}
		if value := r.Get("stitching"); !data.Ipv6RouteTargetExportStitching[i].Stitching.IsNull() {
			if value.Exists() {
				data.Ipv6RouteTargetExportStitching[i].Stitching = types.BoolValue(true)
			} else {
				data.Ipv6RouteTargetExportStitching[i].Stitching = types.BoolValue(false)
			}
		} else {
			data.Ipv6RouteTargetExportStitching[i].Stitching = types.BoolNull()
		}
	}
}

// End of section. //template:end updateFromBody

// Section below is generated&owned by "gen/generator.go". //template:begin fromBody

func (data *VRF) fromBody(ctx context.Context, res gjson.Result) {
	prefix := helpers.LastElement(data.getPath()) + "."
	if res.Get(helpers.LastElement(data.getPath())).IsArray() {
		prefix += "0."
	}
	if value := res.Get(prefix + "description"); value.Exists() {
		data.Description = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "rd"); value.Exists() {
		data.Rd = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "address-family.ipv4"); value.Exists() {
		data.AddressFamilyIpv4 = types.BoolValue(true)
	} else {
		data.AddressFamilyIpv4 = types.BoolValue(false)
	}
	if value := res.Get(prefix + "address-family.ipv6"); value.Exists() {
		data.AddressFamilyIpv6 = types.BoolValue(true)
	} else {
		data.AddressFamilyIpv6 = types.BoolValue(false)
	}
	if value := res.Get(prefix + "vpn.id"); value.Exists() {
		data.VpnId = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "route-target.import"); value.Exists() {
		data.RouteTargetImport = make([]VRFRouteTargetImport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFRouteTargetImport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.RouteTargetImport = append(data.RouteTargetImport, item)
			return true
		})
	}
	if value := res.Get(prefix + "route-target.export"); value.Exists() {
		data.RouteTargetExport = make([]VRFRouteTargetExport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFRouteTargetExport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.RouteTargetExport = append(data.RouteTargetExport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.without-stitching"); value.Exists() {
		data.Ipv4RouteTargetImport = make([]VRFIpv4RouteTargetImport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv4RouteTargetImport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			data.Ipv4RouteTargetImport = append(data.Ipv4RouteTargetImport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.with-stitching"); value.Exists() {
		data.Ipv4RouteTargetImportStitching = make([]VRFIpv4RouteTargetImportStitching, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv4RouteTargetImportStitching{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.Ipv4RouteTargetImportStitching = append(data.Ipv4RouteTargetImportStitching, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.without-stitching"); value.Exists() {
		data.Ipv4RouteTargetExport = make([]VRFIpv4RouteTargetExport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv4RouteTargetExport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			data.Ipv4RouteTargetExport = append(data.Ipv4RouteTargetExport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.with-stitching"); value.Exists() {
		data.Ipv4RouteTargetExportStitching = make([]VRFIpv4RouteTargetExportStitching, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv4RouteTargetExportStitching{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.Ipv4RouteTargetExportStitching = append(data.Ipv4RouteTargetExportStitching, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.without-stitching"); value.Exists() {
		data.Ipv6RouteTargetImport = make([]VRFIpv6RouteTargetImport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv6RouteTargetImport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			data.Ipv6RouteTargetImport = append(data.Ipv6RouteTargetImport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.with-stitching"); value.Exists() {
		data.Ipv6RouteTargetImportStitching = make([]VRFIpv6RouteTargetImportStitching, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv6RouteTargetImportStitching{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.Ipv6RouteTargetImportStitching = append(data.Ipv6RouteTargetImportStitching, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.without-stitching"); value.Exists() {
		data.Ipv6RouteTargetExport = make([]VRFIpv6RouteTargetExport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv6RouteTargetExport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			data.Ipv6RouteTargetExport = append(data.Ipv6RouteTargetExport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.with-stitching"); value.Exists() {
		data.Ipv6RouteTargetExportStitching = make([]VRFIpv6RouteTargetExportStitching, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv6RouteTargetExportStitching{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.Ipv6RouteTargetExportStitching = append(data.Ipv6RouteTargetExportStitching, item)
			return true
		})
	}
}

// End of section. //template:end fromBody

// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData

func (data *VRFData) fromBody(ctx context.Context, res gjson.Result) {
	prefix := helpers.LastElement(data.getPath()) + "."
	if res.Get(helpers.LastElement(data.getPath())).IsArray() {
		prefix += "0."
	}
	if value := res.Get(prefix + "description"); value.Exists() {
		data.Description = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "rd"); value.Exists() {
		data.Rd = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "address-family.ipv4"); value.Exists() {
		data.AddressFamilyIpv4 = types.BoolValue(true)
	} else {
		data.AddressFamilyIpv4 = types.BoolValue(false)
	}
	if value := res.Get(prefix + "address-family.ipv6"); value.Exists() {
		data.AddressFamilyIpv6 = types.BoolValue(true)
	} else {
		data.AddressFamilyIpv6 = types.BoolValue(false)
	}
	if value := res.Get(prefix + "vpn.id"); value.Exists() {
		data.VpnId = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "route-target.import"); value.Exists() {
		data.RouteTargetImport = make([]VRFRouteTargetImport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFRouteTargetImport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.RouteTargetImport = append(data.RouteTargetImport, item)
			return true
		})
	}
	if value := res.Get(prefix + "route-target.export"); value.Exists() {
		data.RouteTargetExport = make([]VRFRouteTargetExport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFRouteTargetExport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.RouteTargetExport = append(data.RouteTargetExport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.without-stitching"); value.Exists() {
		data.Ipv4RouteTargetImport = make([]VRFIpv4RouteTargetImport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv4RouteTargetImport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			data.Ipv4RouteTargetImport = append(data.Ipv4RouteTargetImport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.with-stitching"); value.Exists() {
		data.Ipv4RouteTargetImportStitching = make([]VRFIpv4RouteTargetImportStitching, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv4RouteTargetImportStitching{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.Ipv4RouteTargetImportStitching = append(data.Ipv4RouteTargetImportStitching, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.without-stitching"); value.Exists() {
		data.Ipv4RouteTargetExport = make([]VRFIpv4RouteTargetExport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv4RouteTargetExport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			data.Ipv4RouteTargetExport = append(data.Ipv4RouteTargetExport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.with-stitching"); value.Exists() {
		data.Ipv4RouteTargetExportStitching = make([]VRFIpv4RouteTargetExportStitching, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv4RouteTargetExportStitching{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.Ipv4RouteTargetExportStitching = append(data.Ipv4RouteTargetExportStitching, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.without-stitching"); value.Exists() {
		data.Ipv6RouteTargetImport = make([]VRFIpv6RouteTargetImport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv6RouteTargetImport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			data.Ipv6RouteTargetImport = append(data.Ipv6RouteTargetImport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.with-stitching"); value.Exists() {
		data.Ipv6RouteTargetImportStitching = make([]VRFIpv6RouteTargetImportStitching, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv6RouteTargetImportStitching{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.Ipv6RouteTargetImportStitching = append(data.Ipv6RouteTargetImportStitching, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.without-stitching"); value.Exists() {
		data.Ipv6RouteTargetExport = make([]VRFIpv6RouteTargetExport, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv6RouteTargetExport{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			data.Ipv6RouteTargetExport = append(data.Ipv6RouteTargetExport, item)
			return true
		})
	}
	if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.with-stitching"); value.Exists() {
		data.Ipv6RouteTargetExportStitching = make([]VRFIpv6RouteTargetExportStitching, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := VRFIpv6RouteTargetExportStitching{}
			if cValue := v.Get("asn-ip"); cValue.Exists() {
				item.Value = types.StringValue(cValue.String())
			}
			if cValue := v.Get("stitching"); cValue.Exists() {
				item.Stitching = types.BoolValue(true)
			} else {
				item.Stitching = types.BoolValue(false)
			}
			data.Ipv6RouteTargetExportStitching = append(data.Ipv6RouteTargetExportStitching, item)
			return true
		})
	}
}

// End of section. //template:end fromBodyData

// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems

func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
	deletedItems := make([]string, 0)
	for i := range state.Ipv6RouteTargetExportStitching {
		stateKeyValues := [...]string{state.Ipv6RouteTargetExportStitching[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.Ipv6RouteTargetExportStitching[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.Ipv6RouteTargetExportStitching {
			found = true
			if state.Ipv6RouteTargetExportStitching[i].Value.ValueString() != data.Ipv6RouteTargetExportStitching[j].Value.ValueString() {
				found = false
			}
			if found {
				if !state.Ipv6RouteTargetExportStitching[i].Stitching.IsNull() && data.Ipv6RouteTargetExportStitching[j].Stitching.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.Ipv6RouteTargetExport {
		stateKeyValues := [...]string{state.Ipv6RouteTargetExport[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.Ipv6RouteTargetExport[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.Ipv6RouteTargetExport {
			found = true
			if state.Ipv6RouteTargetExport[i].Value.ValueString() != data.Ipv6RouteTargetExport[j].Value.ValueString() {
				found = false
			}
			if found {
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.Ipv6RouteTargetImportStitching {
		stateKeyValues := [...]string{state.Ipv6RouteTargetImportStitching[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.Ipv6RouteTargetImportStitching[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.Ipv6RouteTargetImportStitching {
			found = true
			if state.Ipv6RouteTargetImportStitching[i].Value.ValueString() != data.Ipv6RouteTargetImportStitching[j].Value.ValueString() {
				found = false
			}
			if found {
				if !state.Ipv6RouteTargetImportStitching[i].Stitching.IsNull() && data.Ipv6RouteTargetImportStitching[j].Stitching.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.Ipv6RouteTargetImport {
		stateKeyValues := [...]string{state.Ipv6RouteTargetImport[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.Ipv6RouteTargetImport[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.Ipv6RouteTargetImport {
			found = true
			if state.Ipv6RouteTargetImport[i].Value.ValueString() != data.Ipv6RouteTargetImport[j].Value.ValueString() {
				found = false
			}
			if found {
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.Ipv4RouteTargetExportStitching {
		stateKeyValues := [...]string{state.Ipv4RouteTargetExportStitching[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.Ipv4RouteTargetExportStitching[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.Ipv4RouteTargetExportStitching {
			found = true
			if state.Ipv4RouteTargetExportStitching[i].Value.ValueString() != data.Ipv4RouteTargetExportStitching[j].Value.ValueString() {
				found = false
			}
			if found {
				if !state.Ipv4RouteTargetExportStitching[i].Stitching.IsNull() && data.Ipv4RouteTargetExportStitching[j].Stitching.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.Ipv4RouteTargetExport {
		stateKeyValues := [...]string{state.Ipv4RouteTargetExport[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.Ipv4RouteTargetExport[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.Ipv4RouteTargetExport {
			found = true
			if state.Ipv4RouteTargetExport[i].Value.ValueString() != data.Ipv4RouteTargetExport[j].Value.ValueString() {
				found = false
			}
			if found {
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.Ipv4RouteTargetImportStitching {
		stateKeyValues := [...]string{state.Ipv4RouteTargetImportStitching[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.Ipv4RouteTargetImportStitching[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.Ipv4RouteTargetImportStitching {
			found = true
			if state.Ipv4RouteTargetImportStitching[i].Value.ValueString() != data.Ipv4RouteTargetImportStitching[j].Value.ValueString() {
				found = false
			}
			if found {
				if !state.Ipv4RouteTargetImportStitching[i].Stitching.IsNull() && data.Ipv4RouteTargetImportStitching[j].Stitching.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.Ipv4RouteTargetImport {
		stateKeyValues := [...]string{state.Ipv4RouteTargetImport[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.Ipv4RouteTargetImport[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.Ipv4RouteTargetImport {
			found = true
			if state.Ipv4RouteTargetImport[i].Value.ValueString() != data.Ipv4RouteTargetImport[j].Value.ValueString() {
				found = false
			}
			if found {
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.RouteTargetExport {
		stateKeyValues := [...]string{state.RouteTargetExport[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.RouteTargetExport[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.RouteTargetExport {
			found = true
			if state.RouteTargetExport[i].Value.ValueString() != data.RouteTargetExport[j].Value.ValueString() {
				found = false
			}
			if found {
				if !state.RouteTargetExport[i].Stitching.IsNull() && data.RouteTargetExport[j].Stitching.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/export=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/export=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.RouteTargetImport {
		stateKeyValues := [...]string{state.RouteTargetImport[i].Value.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.RouteTargetImport[i].Value.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.RouteTargetImport {
			found = true
			if state.RouteTargetImport[i].Value.ValueString() != data.RouteTargetImport[j].Value.ValueString() {
				found = false
			}
			if found {
				if !state.RouteTargetImport[i].Stitching.IsNull() && data.RouteTargetImport[j].Stitching.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/import=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/import=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	if !state.VpnId.IsNull() && data.VpnId.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/vpn/id", state.getPath()))
	}
	if !state.AddressFamilyIpv6.IsNull() && data.AddressFamilyIpv6.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6", state.getPath()))
	}
	if !state.AddressFamilyIpv4.IsNull() && data.AddressFamilyIpv4.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4", state.getPath()))
	}
	if !state.Rd.IsNull() && data.Rd.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/rd", state.getPath()))
	}
	if !state.Description.IsNull() && data.Description.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
	}

	return deletedItems
}

// End of section. //template:end getDeletedItems

// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete

func (data *VRF) getEmptyLeafsDelete(ctx context.Context) []string {
	emptyLeafsDelete := make([]string, 0)

	for i := range data.Ipv6RouteTargetExportStitching {
		keyValues := [...]string{data.Ipv6RouteTargetExportStitching[i].Value.ValueString()}
		if !data.Ipv6RouteTargetExportStitching[i].Stitching.IsNull() && !data.Ipv6RouteTargetExportStitching[i].Stitching.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/with-stitching=%v/stitching", data.getPath(), strings.Join(keyValues[:], ",")))
		}
	}

	for i := range data.Ipv6RouteTargetImportStitching {
		keyValues := [...]string{data.Ipv6RouteTargetImportStitching[i].Value.ValueString()}
		if !data.Ipv6RouteTargetImportStitching[i].Stitching.IsNull() && !data.Ipv6RouteTargetImportStitching[i].Stitching.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/with-stitching=%v/stitching", data.getPath(), strings.Join(keyValues[:], ",")))
		}
	}

	for i := range data.Ipv4RouteTargetExportStitching {
		keyValues := [...]string{data.Ipv4RouteTargetExportStitching[i].Value.ValueString()}
		if !data.Ipv4RouteTargetExportStitching[i].Stitching.IsNull() && !data.Ipv4RouteTargetExportStitching[i].Stitching.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/with-stitching=%v/stitching", data.getPath(), strings.Join(keyValues[:], ",")))
		}
	}

	for i := range data.Ipv4RouteTargetImportStitching {
		keyValues := [...]string{data.Ipv4RouteTargetImportStitching[i].Value.ValueString()}
		if !data.Ipv4RouteTargetImportStitching[i].Stitching.IsNull() && !data.Ipv4RouteTargetImportStitching[i].Stitching.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/with-stitching=%v/stitching", data.getPath(), strings.Join(keyValues[:], ",")))
		}
	}

	for i := range data.RouteTargetExport {
		keyValues := [...]string{data.RouteTargetExport[i].Value.ValueString()}
		if !data.RouteTargetExport[i].Stitching.IsNull() && !data.RouteTargetExport[i].Stitching.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/route-target/export=%v/stitching", data.getPath(), strings.Join(keyValues[:], ",")))
		}
	}

	for i := range data.RouteTargetImport {
		keyValues := [...]string{data.RouteTargetImport[i].Value.ValueString()}
		if !data.RouteTargetImport[i].Stitching.IsNull() && !data.RouteTargetImport[i].Stitching.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/route-target/import=%v/stitching", data.getPath(), strings.Join(keyValues[:], ",")))
		}
	}
	if !data.AddressFamilyIpv6.IsNull() && !data.AddressFamilyIpv6.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-family/ipv6", data.getPath()))
	}
	if !data.AddressFamilyIpv4.IsNull() && !data.AddressFamilyIpv4.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-family/ipv4", data.getPath()))
	}

	return emptyLeafsDelete
}

// End of section. //template:end getEmptyLeafsDelete

// Section below is generated&owned by "gen/generator.go". //template:begin getDeletePaths

func (data *VRF) getDeletePaths(ctx context.Context) []string {
	var deletePaths []string
	for i := range data.Ipv6RouteTargetExportStitching {
		keyValues := [...]string{data.Ipv6RouteTargetExportStitching[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/with-stitching=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.Ipv6RouteTargetExport {
		keyValues := [...]string{data.Ipv6RouteTargetExport[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/without-stitching=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.Ipv6RouteTargetImportStitching {
		keyValues := [...]string{data.Ipv6RouteTargetImportStitching[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/with-stitching=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.Ipv6RouteTargetImport {
		keyValues := [...]string{data.Ipv6RouteTargetImport[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/without-stitching=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.Ipv4RouteTargetExportStitching {
		keyValues := [...]string{data.Ipv4RouteTargetExportStitching[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/with-stitching=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.Ipv4RouteTargetExport {
		keyValues := [...]string{data.Ipv4RouteTargetExport[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/without-stitching=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.Ipv4RouteTargetImportStitching {
		keyValues := [...]string{data.Ipv4RouteTargetImportStitching[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/with-stitching=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.Ipv4RouteTargetImport {
		keyValues := [...]string{data.Ipv4RouteTargetImport[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/without-stitching=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.RouteTargetExport {
		keyValues := [...]string{data.RouteTargetExport[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/route-target/export=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.RouteTargetImport {
		keyValues := [...]string{data.RouteTargetImport[i].Value.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/route-target/import=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	if !data.VpnId.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/vpn/id", data.getPath()))
	}
	if !data.AddressFamilyIpv6.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv6", data.getPath()))
	}
	if !data.AddressFamilyIpv4.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/address-family/ipv4", data.getPath()))
	}
	if !data.Rd.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/rd", data.getPath()))
	}
	if !data.Description.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/description", data.getPath()))
	}

	return deletePaths
}

// End of section. //template:end getDeletePaths
