// 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"
	"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 Dot1x struct {
	Device                        types.String       `tfsdk:"device"`
	Id                            types.String       `tfsdk:"id"`
	DeleteMode                    types.String       `tfsdk:"delete_mode"`
	AuthFailEapol                 types.Bool         `tfsdk:"auth_fail_eapol"`
	Credentials                   []Dot1xCredentials `tfsdk:"credentials"`
	CriticalEapolConfigBlock      types.Bool         `tfsdk:"critical_eapol_config_block"`
	CriticalRecoveryDelay         types.Int64        `tfsdk:"critical_recovery_delay"`
	TestTimeout                   types.Int64        `tfsdk:"test_timeout"`
	LoggingVerbose                types.Bool         `tfsdk:"logging_verbose"`
	SupplicantControlledTransient types.Bool         `tfsdk:"supplicant_controlled_transient"`
	SupplicantForceMulticast      types.Bool         `tfsdk:"supplicant_force_multicast"`
	SystemAuthControl             types.Bool         `tfsdk:"system_auth_control"`
	GuestVlanSupplicant           types.Bool         `tfsdk:"guest_vlan_supplicant"`
	CriticalEapol                 types.Bool         `tfsdk:"critical_eapol"`
	CriticalEapolBlock            types.Bool         `tfsdk:"critical_eapol_block"`
}

type Dot1xData struct {
	Device                        types.String       `tfsdk:"device"`
	Id                            types.String       `tfsdk:"id"`
	AuthFailEapol                 types.Bool         `tfsdk:"auth_fail_eapol"`
	Credentials                   []Dot1xCredentials `tfsdk:"credentials"`
	CriticalEapolConfigBlock      types.Bool         `tfsdk:"critical_eapol_config_block"`
	CriticalRecoveryDelay         types.Int64        `tfsdk:"critical_recovery_delay"`
	TestTimeout                   types.Int64        `tfsdk:"test_timeout"`
	LoggingVerbose                types.Bool         `tfsdk:"logging_verbose"`
	SupplicantControlledTransient types.Bool         `tfsdk:"supplicant_controlled_transient"`
	SupplicantForceMulticast      types.Bool         `tfsdk:"supplicant_force_multicast"`
	SystemAuthControl             types.Bool         `tfsdk:"system_auth_control"`
	GuestVlanSupplicant           types.Bool         `tfsdk:"guest_vlan_supplicant"`
	CriticalEapol                 types.Bool         `tfsdk:"critical_eapol"`
	CriticalEapolBlock            types.Bool         `tfsdk:"critical_eapol_block"`
}
type Dot1xCredentials struct {
	ProfileName   types.String `tfsdk:"profile_name"`
	Description   types.String `tfsdk:"description"`
	Username      types.String `tfsdk:"username"`
	PasswordType  types.String `tfsdk:"password_type"`
	Password      types.String `tfsdk:"password"`
	PkiTrustpoint types.String `tfsdk:"pki_trustpoint"`
	AnonymousId   types.String `tfsdk:"anonymous_id"`
}

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

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

func (data Dot1x) getPath() string {
	return "Cisco-IOS-XE-native:native/dot1x"
}

func (data Dot1xData) getPath() string {
	return "Cisco-IOS-XE-native:native/dot1x"
}

// if last path element has a key -> remove it
func (data Dot1x) 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 Dot1x) toBody(ctx context.Context) string {
	body := `{"` + helpers.LastElement(data.getPath()) + `":{}}`
	if !data.AuthFailEapol.IsNull() && !data.AuthFailEapol.IsUnknown() {
		if data.AuthFailEapol.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:auth-fail.eapol", map[string]string{})
		}
	}
	if !data.CriticalEapolConfigBlock.IsNull() && !data.CriticalEapolConfigBlock.IsUnknown() {
		if data.CriticalEapolConfigBlock.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:critical.eapol-config.block", map[string]string{})
		}
	}
	if !data.CriticalRecoveryDelay.IsNull() && !data.CriticalRecoveryDelay.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:critical.recovery.delay", strconv.FormatInt(data.CriticalRecoveryDelay.ValueInt64(), 10))
	}
	if !data.TestTimeout.IsNull() && !data.TestTimeout.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:test.timeout", strconv.FormatInt(data.TestTimeout.ValueInt64(), 10))
	}
	if !data.LoggingVerbose.IsNull() && !data.LoggingVerbose.IsUnknown() {
		if data.LoggingVerbose.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:logging.verbose", map[string]string{})
		}
	}
	if !data.SupplicantControlledTransient.IsNull() && !data.SupplicantControlledTransient.IsUnknown() {
		if data.SupplicantControlledTransient.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:supplicant.controlled.transient", map[string]string{})
		}
	}
	if !data.SupplicantForceMulticast.IsNull() && !data.SupplicantForceMulticast.IsUnknown() {
		if data.SupplicantForceMulticast.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:supplicant.force-multicast", map[string]string{})
		}
	}
	if !data.SystemAuthControl.IsNull() && !data.SystemAuthControl.IsUnknown() {
		if data.SystemAuthControl.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:system-auth-control", map[string]string{})
		}
	}
	if !data.GuestVlanSupplicant.IsNull() && !data.GuestVlanSupplicant.IsUnknown() {
		if data.GuestVlanSupplicant.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:guest-vlan.supplicant", map[string]string{})
		}
	}
	if !data.CriticalEapol.IsNull() && !data.CriticalEapol.IsUnknown() {
		if data.CriticalEapol.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:critical.eapol-config", map[string]string{})
		}
	}
	if !data.CriticalEapolBlock.IsNull() && !data.CriticalEapolBlock.IsUnknown() {
		if data.CriticalEapolBlock.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:critical.eapol-config.block", map[string]string{})
		}
	}
	if len(data.Credentials) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:credentials", []interface{}{})
		for index, item := range data.Credentials {
			if !item.ProfileName.IsNull() && !item.ProfileName.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:credentials"+"."+strconv.Itoa(index)+"."+"profile-name", item.ProfileName.ValueString())
			}
			if !item.Description.IsNull() && !item.Description.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:credentials"+"."+strconv.Itoa(index)+"."+"description", item.Description.ValueString())
			}
			if !item.Username.IsNull() && !item.Username.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:credentials"+"."+strconv.Itoa(index)+"."+"username", item.Username.ValueString())
			}
			if !item.PasswordType.IsNull() && !item.PasswordType.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:credentials"+"."+strconv.Itoa(index)+"."+"password.type", item.PasswordType.ValueString())
			}
			if !item.Password.IsNull() && !item.Password.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:credentials"+"."+strconv.Itoa(index)+"."+"password.secret", item.Password.ValueString())
			}
			if !item.PkiTrustpoint.IsNull() && !item.PkiTrustpoint.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:credentials"+"."+strconv.Itoa(index)+"."+"pki-trustpoint", item.PkiTrustpoint.ValueString())
			}
			if !item.AnonymousId.IsNull() && !item.AnonymousId.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dot1x:credentials"+"."+strconv.Itoa(index)+"."+"anonymous-id", item.AnonymousId.ValueString())
			}
		}
	}
	return body
}

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

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

func (data *Dot1x) 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 + "Cisco-IOS-XE-dot1x:auth-fail.eapol"); !data.AuthFailEapol.IsNull() {
		if value.Exists() {
			data.AuthFailEapol = types.BoolValue(true)
		} else {
			data.AuthFailEapol = types.BoolValue(false)
		}
	} else {
		data.AuthFailEapol = types.BoolNull()
	}
	for i := range data.Credentials {
		keys := [...]string{"profile-name"}
		keyValues := [...]string{data.Credentials[i].ProfileName.ValueString()}

		var r gjson.Result
		res.Get(prefix + "Cisco-IOS-XE-dot1x:credentials").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("profile-name"); value.Exists() && !data.Credentials[i].ProfileName.IsNull() {
			data.Credentials[i].ProfileName = types.StringValue(value.String())
		} else {
			data.Credentials[i].ProfileName = types.StringNull()
		}
		if value := r.Get("description"); value.Exists() && !data.Credentials[i].Description.IsNull() {
			data.Credentials[i].Description = types.StringValue(value.String())
		} else {
			data.Credentials[i].Description = types.StringNull()
		}
		if value := r.Get("username"); value.Exists() && !data.Credentials[i].Username.IsNull() {
			data.Credentials[i].Username = types.StringValue(value.String())
		} else {
			data.Credentials[i].Username = types.StringNull()
		}
		if value := r.Get("pki-trustpoint"); value.Exists() && !data.Credentials[i].PkiTrustpoint.IsNull() {
			data.Credentials[i].PkiTrustpoint = types.StringValue(value.String())
		} else {
			data.Credentials[i].PkiTrustpoint = types.StringNull()
		}
		if value := r.Get("anonymous-id"); value.Exists() && !data.Credentials[i].AnonymousId.IsNull() {
			data.Credentials[i].AnonymousId = types.StringValue(value.String())
		} else {
			data.Credentials[i].AnonymousId = types.StringNull()
		}
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config.block"); !data.CriticalEapolConfigBlock.IsNull() {
		if value.Exists() {
			data.CriticalEapolConfigBlock = types.BoolValue(true)
		} else {
			data.CriticalEapolConfigBlock = types.BoolValue(false)
		}
	} else {
		data.CriticalEapolConfigBlock = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.recovery.delay"); value.Exists() && !data.CriticalRecoveryDelay.IsNull() {
		data.CriticalRecoveryDelay = types.Int64Value(value.Int())
	} else {
		data.CriticalRecoveryDelay = types.Int64Null()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:test.timeout"); value.Exists() && !data.TestTimeout.IsNull() {
		data.TestTimeout = types.Int64Value(value.Int())
	} else {
		data.TestTimeout = types.Int64Null()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:logging.verbose"); !data.LoggingVerbose.IsNull() {
		if value.Exists() {
			data.LoggingVerbose = types.BoolValue(true)
		} else {
			data.LoggingVerbose = types.BoolValue(false)
		}
	} else {
		data.LoggingVerbose = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:supplicant.controlled.transient"); !data.SupplicantControlledTransient.IsNull() {
		if value.Exists() {
			data.SupplicantControlledTransient = types.BoolValue(true)
		} else {
			data.SupplicantControlledTransient = types.BoolValue(false)
		}
	} else {
		data.SupplicantControlledTransient = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:supplicant.force-multicast"); !data.SupplicantForceMulticast.IsNull() {
		if value.Exists() {
			data.SupplicantForceMulticast = types.BoolValue(true)
		} else {
			data.SupplicantForceMulticast = types.BoolValue(false)
		}
	} else {
		data.SupplicantForceMulticast = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:system-auth-control"); !data.SystemAuthControl.IsNull() {
		if value.Exists() {
			data.SystemAuthControl = types.BoolValue(true)
		} else {
			data.SystemAuthControl = types.BoolValue(false)
		}
	} else {
		data.SystemAuthControl = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:guest-vlan.supplicant"); !data.GuestVlanSupplicant.IsNull() {
		if value.Exists() {
			data.GuestVlanSupplicant = types.BoolValue(true)
		} else {
			data.GuestVlanSupplicant = types.BoolValue(false)
		}
	} else {
		data.GuestVlanSupplicant = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config"); !data.CriticalEapol.IsNull() {
		if value.Exists() {
			data.CriticalEapol = types.BoolValue(true)
		} else {
			data.CriticalEapol = types.BoolValue(false)
		}
	} else {
		data.CriticalEapol = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config.block"); !data.CriticalEapolBlock.IsNull() {
		if value.Exists() {
			data.CriticalEapolBlock = types.BoolValue(true)
		} else {
			data.CriticalEapolBlock = types.BoolValue(false)
		}
	} else {
		data.CriticalEapolBlock = types.BoolNull()
	}
}

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

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

func (data *Dot1x) 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 + "Cisco-IOS-XE-dot1x:auth-fail.eapol"); value.Exists() {
		data.AuthFailEapol = types.BoolValue(true)
	} else {
		data.AuthFailEapol = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:credentials"); value.Exists() {
		data.Credentials = make([]Dot1xCredentials, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := Dot1xCredentials{}
			if cValue := v.Get("profile-name"); cValue.Exists() {
				item.ProfileName = types.StringValue(cValue.String())
			}
			if cValue := v.Get("description"); cValue.Exists() {
				item.Description = types.StringValue(cValue.String())
			}
			if cValue := v.Get("username"); cValue.Exists() {
				item.Username = types.StringValue(cValue.String())
			}
			if cValue := v.Get("password.type"); cValue.Exists() {
				item.PasswordType = types.StringValue(cValue.String())
			}
			if cValue := v.Get("password.secret"); cValue.Exists() {
				item.Password = types.StringValue(cValue.String())
			}
			if cValue := v.Get("pki-trustpoint"); cValue.Exists() {
				item.PkiTrustpoint = types.StringValue(cValue.String())
			}
			if cValue := v.Get("anonymous-id"); cValue.Exists() {
				item.AnonymousId = types.StringValue(cValue.String())
			}
			data.Credentials = append(data.Credentials, item)
			return true
		})
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config.block"); value.Exists() {
		data.CriticalEapolConfigBlock = types.BoolValue(true)
	} else {
		data.CriticalEapolConfigBlock = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.recovery.delay"); value.Exists() {
		data.CriticalRecoveryDelay = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:test.timeout"); value.Exists() {
		data.TestTimeout = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:logging.verbose"); value.Exists() {
		data.LoggingVerbose = types.BoolValue(true)
	} else {
		data.LoggingVerbose = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:supplicant.controlled.transient"); value.Exists() {
		data.SupplicantControlledTransient = types.BoolValue(true)
	} else {
		data.SupplicantControlledTransient = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:supplicant.force-multicast"); value.Exists() {
		data.SupplicantForceMulticast = types.BoolValue(true)
	} else {
		data.SupplicantForceMulticast = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:system-auth-control"); value.Exists() {
		data.SystemAuthControl = types.BoolValue(true)
	} else {
		data.SystemAuthControl = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:guest-vlan.supplicant"); value.Exists() {
		data.GuestVlanSupplicant = types.BoolValue(true)
	} else {
		data.GuestVlanSupplicant = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config"); value.Exists() {
		data.CriticalEapol = types.BoolValue(true)
	} else {
		data.CriticalEapol = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config.block"); value.Exists() {
		data.CriticalEapolBlock = types.BoolValue(true)
	} else {
		data.CriticalEapolBlock = types.BoolValue(false)
	}
}

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

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

func (data *Dot1xData) 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 + "Cisco-IOS-XE-dot1x:auth-fail.eapol"); value.Exists() {
		data.AuthFailEapol = types.BoolValue(true)
	} else {
		data.AuthFailEapol = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:credentials"); value.Exists() {
		data.Credentials = make([]Dot1xCredentials, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := Dot1xCredentials{}
			if cValue := v.Get("profile-name"); cValue.Exists() {
				item.ProfileName = types.StringValue(cValue.String())
			}
			if cValue := v.Get("description"); cValue.Exists() {
				item.Description = types.StringValue(cValue.String())
			}
			if cValue := v.Get("username"); cValue.Exists() {
				item.Username = types.StringValue(cValue.String())
			}
			if cValue := v.Get("password.type"); cValue.Exists() {
				item.PasswordType = types.StringValue(cValue.String())
			}
			if cValue := v.Get("password.secret"); cValue.Exists() {
				item.Password = types.StringValue(cValue.String())
			}
			if cValue := v.Get("pki-trustpoint"); cValue.Exists() {
				item.PkiTrustpoint = types.StringValue(cValue.String())
			}
			if cValue := v.Get("anonymous-id"); cValue.Exists() {
				item.AnonymousId = types.StringValue(cValue.String())
			}
			data.Credentials = append(data.Credentials, item)
			return true
		})
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config.block"); value.Exists() {
		data.CriticalEapolConfigBlock = types.BoolValue(true)
	} else {
		data.CriticalEapolConfigBlock = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.recovery.delay"); value.Exists() {
		data.CriticalRecoveryDelay = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:test.timeout"); value.Exists() {
		data.TestTimeout = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:logging.verbose"); value.Exists() {
		data.LoggingVerbose = types.BoolValue(true)
	} else {
		data.LoggingVerbose = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:supplicant.controlled.transient"); value.Exists() {
		data.SupplicantControlledTransient = types.BoolValue(true)
	} else {
		data.SupplicantControlledTransient = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:supplicant.force-multicast"); value.Exists() {
		data.SupplicantForceMulticast = types.BoolValue(true)
	} else {
		data.SupplicantForceMulticast = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:system-auth-control"); value.Exists() {
		data.SystemAuthControl = types.BoolValue(true)
	} else {
		data.SystemAuthControl = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:guest-vlan.supplicant"); value.Exists() {
		data.GuestVlanSupplicant = types.BoolValue(true)
	} else {
		data.GuestVlanSupplicant = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config"); value.Exists() {
		data.CriticalEapol = types.BoolValue(true)
	} else {
		data.CriticalEapol = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:critical.eapol-config.block"); value.Exists() {
		data.CriticalEapolBlock = types.BoolValue(true)
	} else {
		data.CriticalEapolBlock = types.BoolValue(false)
	}
}

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

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

func (data *Dot1x) getDeletedItems(ctx context.Context, state Dot1x) []string {
	deletedItems := make([]string, 0)
	if !state.CriticalEapolBlock.IsNull() && data.CriticalEapolBlock.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config/block", state.getPath()))
	}
	if !state.CriticalEapol.IsNull() && data.CriticalEapol.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config", state.getPath()))
	}
	if !state.GuestVlanSupplicant.IsNull() && data.GuestVlanSupplicant.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:guest-vlan/supplicant", state.getPath()))
	}
	if !state.SystemAuthControl.IsNull() && data.SystemAuthControl.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:system-auth-control", state.getPath()))
	}
	if !state.SupplicantForceMulticast.IsNull() && data.SupplicantForceMulticast.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:supplicant/force-multicast", state.getPath()))
	}
	if !state.SupplicantControlledTransient.IsNull() && data.SupplicantControlledTransient.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:supplicant/controlled/transient", state.getPath()))
	}
	if !state.LoggingVerbose.IsNull() && data.LoggingVerbose.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:logging/verbose", state.getPath()))
	}
	if !state.TestTimeout.IsNull() && data.TestTimeout.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:test/timeout", state.getPath()))
	}
	if !state.CriticalRecoveryDelay.IsNull() && data.CriticalRecoveryDelay.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/recovery/delay", state.getPath()))
	}
	if !state.CriticalEapolConfigBlock.IsNull() && data.CriticalEapolConfigBlock.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config/block", state.getPath()))
	}
	for i := range state.Credentials {
		stateKeyValues := [...]string{state.Credentials[i].ProfileName.ValueString()}

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

		found := false
		for j := range data.Credentials {
			found = true
			if state.Credentials[i].ProfileName.ValueString() != data.Credentials[j].ProfileName.ValueString() {
				found = false
			}
			if found {
				if !state.Credentials[i].AnonymousId.IsNull() && data.Credentials[j].AnonymousId.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:credentials=%v/anonymous-id", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.Credentials[i].PkiTrustpoint.IsNull() && data.Credentials[j].PkiTrustpoint.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:credentials=%v/pki-trustpoint", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.Credentials[i].Password.IsNull() && data.Credentials[j].Password.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:credentials=%v/password/secret", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.Credentials[i].PasswordType.IsNull() && data.Credentials[j].PasswordType.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:credentials=%v/password/type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.Credentials[i].Username.IsNull() && data.Credentials[j].Username.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:credentials=%v/username", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.Credentials[i].Description.IsNull() && data.Credentials[j].Description.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:credentials=%v/description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:credentials=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	if !state.AuthFailEapol.IsNull() && data.AuthFailEapol.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:auth-fail/eapol", state.getPath()))
	}

	return deletedItems
}

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

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

func (data *Dot1x) getEmptyLeafsDelete(ctx context.Context) []string {
	emptyLeafsDelete := make([]string, 0)
	if !data.CriticalEapolBlock.IsNull() && !data.CriticalEapolBlock.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config/block", data.getPath()))
	}
	if !data.CriticalEapol.IsNull() && !data.CriticalEapol.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config", data.getPath()))
	}
	if !data.GuestVlanSupplicant.IsNull() && !data.GuestVlanSupplicant.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:guest-vlan/supplicant", data.getPath()))
	}
	if !data.SystemAuthControl.IsNull() && !data.SystemAuthControl.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:system-auth-control", data.getPath()))
	}
	if !data.SupplicantForceMulticast.IsNull() && !data.SupplicantForceMulticast.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:supplicant/force-multicast", data.getPath()))
	}
	if !data.SupplicantControlledTransient.IsNull() && !data.SupplicantControlledTransient.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:supplicant/controlled/transient", data.getPath()))
	}
	if !data.LoggingVerbose.IsNull() && !data.LoggingVerbose.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:logging/verbose", data.getPath()))
	}
	if !data.CriticalEapolConfigBlock.IsNull() && !data.CriticalEapolConfigBlock.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config/block", data.getPath()))
	}

	if !data.AuthFailEapol.IsNull() && !data.AuthFailEapol.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:auth-fail/eapol", data.getPath()))
	}

	return emptyLeafsDelete
}

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

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

func (data *Dot1x) getDeletePaths(ctx context.Context) []string {
	var deletePaths []string
	if !data.CriticalEapolBlock.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config/block", data.getPath()))
	}
	if !data.CriticalEapol.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config", data.getPath()))
	}
	if !data.GuestVlanSupplicant.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:guest-vlan/supplicant", data.getPath()))
	}
	if !data.SystemAuthControl.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:system-auth-control", data.getPath()))
	}
	if !data.SupplicantForceMulticast.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:supplicant/force-multicast", data.getPath()))
	}
	if !data.SupplicantControlledTransient.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:supplicant/controlled/transient", data.getPath()))
	}
	if !data.LoggingVerbose.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:logging/verbose", data.getPath()))
	}
	if !data.TestTimeout.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:test/timeout", data.getPath()))
	}
	if !data.CriticalRecoveryDelay.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/recovery/delay", data.getPath()))
	}
	if !data.CriticalEapolConfigBlock.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:critical/eapol-config/block", data.getPath()))
	}
	for i := range data.Credentials {
		keyValues := [...]string{data.Credentials[i].ProfileName.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:credentials=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	if !data.AuthFailEapol.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:auth-fail/eapol", data.getPath()))
	}

	return deletePaths
}

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