/*
authentik

Making authentication simple.

API version: 2026.5.0-rc1
Contact: hello@goauthentik.io
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package api

import (
	"encoding/json"
	"fmt"
)

// checks if the LDAPCheckAccess type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &LDAPCheckAccess{}

// LDAPCheckAccess Base serializer class which doesn't implement create/update methods
type LDAPCheckAccess struct {
	HasSearchPermission  *bool            `json:"has_search_permission,omitempty"`
	Access               PolicyTestResult `json:"access"`
	AdditionalProperties map[string]interface{}
}

type _LDAPCheckAccess LDAPCheckAccess

// NewLDAPCheckAccess instantiates a new LDAPCheckAccess object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewLDAPCheckAccess(access PolicyTestResult) *LDAPCheckAccess {
	this := LDAPCheckAccess{}
	this.Access = access
	return &this
}

// NewLDAPCheckAccessWithDefaults instantiates a new LDAPCheckAccess object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewLDAPCheckAccessWithDefaults() *LDAPCheckAccess {
	this := LDAPCheckAccess{}
	return &this
}

// GetHasSearchPermission returns the HasSearchPermission field value if set, zero value otherwise.
func (o *LDAPCheckAccess) GetHasSearchPermission() bool {
	if o == nil || IsNil(o.HasSearchPermission) {
		var ret bool
		return ret
	}
	return *o.HasSearchPermission
}

// GetHasSearchPermissionOk returns a tuple with the HasSearchPermission field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *LDAPCheckAccess) GetHasSearchPermissionOk() (*bool, bool) {
	if o == nil || IsNil(o.HasSearchPermission) {
		return nil, false
	}
	return o.HasSearchPermission, true
}

// HasHasSearchPermission returns a boolean if a field has been set.
func (o *LDAPCheckAccess) HasHasSearchPermission() bool {
	if o != nil && !IsNil(o.HasSearchPermission) {
		return true
	}

	return false
}

// SetHasSearchPermission gets a reference to the given bool and assigns it to the HasSearchPermission field.
func (o *LDAPCheckAccess) SetHasSearchPermission(v bool) {
	o.HasSearchPermission = &v
}

// GetAccess returns the Access field value
func (o *LDAPCheckAccess) GetAccess() PolicyTestResult {
	if o == nil {
		var ret PolicyTestResult
		return ret
	}

	return o.Access
}

// GetAccessOk returns a tuple with the Access field value
// and a boolean to check if the value has been set.
func (o *LDAPCheckAccess) GetAccessOk() (*PolicyTestResult, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Access, true
}

// SetAccess sets field value
func (o *LDAPCheckAccess) SetAccess(v PolicyTestResult) {
	o.Access = v
}

func (o LDAPCheckAccess) MarshalJSON() ([]byte, error) {
	toSerialize, err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o LDAPCheckAccess) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.HasSearchPermission) {
		toSerialize["has_search_permission"] = o.HasSearchPermission
	}
	toSerialize["access"] = o.Access

	for key, value := range o.AdditionalProperties {
		toSerialize[key] = value
	}

	return toSerialize, nil
}

func (o *LDAPCheckAccess) UnmarshalJSON(data []byte) (err error) {
	// This validates that all required properties are included in the JSON object
	// by unmarshalling the object into a generic map with string keys and checking
	// that every required field exists as a key in the generic map.
	requiredProperties := []string{
		"access",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(data, &allProperties)

	if err != nil {
		return err
	}

	for _, requiredProperty := range requiredProperties {
		if _, exists := allProperties[requiredProperty]; !exists {
			return fmt.Errorf("no value given for required property %v", requiredProperty)
		}
	}

	varLDAPCheckAccess := _LDAPCheckAccess{}

	err = json.Unmarshal(data, &varLDAPCheckAccess)

	if err != nil {
		return err
	}

	*o = LDAPCheckAccess(varLDAPCheckAccess)

	additionalProperties := make(map[string]interface{})

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "has_search_permission")
		delete(additionalProperties, "access")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableLDAPCheckAccess struct {
	value *LDAPCheckAccess
	isSet bool
}

func (v NullableLDAPCheckAccess) Get() *LDAPCheckAccess {
	return v.value
}

func (v *NullableLDAPCheckAccess) Set(val *LDAPCheckAccess) {
	v.value = val
	v.isSet = true
}

func (v NullableLDAPCheckAccess) IsSet() bool {
	return v.isSet
}

func (v *NullableLDAPCheckAccess) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableLDAPCheckAccess(val *LDAPCheckAccess) *NullableLDAPCheckAccess {
	return &NullableLDAPCheckAccess{value: val, isSet: true}
}

func (v NullableLDAPCheckAccess) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableLDAPCheckAccess) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}
