/*
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 SelectableStage type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &SelectableStage{}

// SelectableStage Serializer for stages which can be selected by users
type SelectableStage struct {
	Pk                   string `json:"pk"`
	Name                 string `json:"name"`
	VerboseName          string `json:"verbose_name"`
	MetaModelName        string `json:"meta_model_name"`
	AdditionalProperties map[string]interface{}
}

type _SelectableStage SelectableStage

// NewSelectableStage instantiates a new SelectableStage 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 NewSelectableStage(pk string, name string, verboseName string, metaModelName string) *SelectableStage {
	this := SelectableStage{}
	this.Pk = pk
	this.Name = name
	this.VerboseName = verboseName
	this.MetaModelName = metaModelName
	return &this
}

// NewSelectableStageWithDefaults instantiates a new SelectableStage 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 NewSelectableStageWithDefaults() *SelectableStage {
	this := SelectableStage{}
	return &this
}

// GetPk returns the Pk field value
func (o *SelectableStage) GetPk() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Pk
}

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

// SetPk sets field value
func (o *SelectableStage) SetPk(v string) {
	o.Pk = v
}

// GetName returns the Name field value
func (o *SelectableStage) GetName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Name
}

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

// SetName sets field value
func (o *SelectableStage) SetName(v string) {
	o.Name = v
}

// GetVerboseName returns the VerboseName field value
func (o *SelectableStage) GetVerboseName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.VerboseName
}

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

// SetVerboseName sets field value
func (o *SelectableStage) SetVerboseName(v string) {
	o.VerboseName = v
}

// GetMetaModelName returns the MetaModelName field value
func (o *SelectableStage) GetMetaModelName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.MetaModelName
}

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

// SetMetaModelName sets field value
func (o *SelectableStage) SetMetaModelName(v string) {
	o.MetaModelName = v
}

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

func (o SelectableStage) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["pk"] = o.Pk
	toSerialize["name"] = o.Name
	toSerialize["verbose_name"] = o.VerboseName
	toSerialize["meta_model_name"] = o.MetaModelName

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

	return toSerialize, nil
}

func (o *SelectableStage) 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{
		"pk",
		"name",
		"verbose_name",
		"meta_model_name",
	}

	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)
		}
	}

	varSelectableStage := _SelectableStage{}

	err = json.Unmarshal(data, &varSelectableStage)

	if err != nil {
		return err
	}

	*o = SelectableStage(varSelectableStage)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "pk")
		delete(additionalProperties, "name")
		delete(additionalProperties, "verbose_name")
		delete(additionalProperties, "meta_model_name")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableSelectableStage struct {
	value *SelectableStage
	isSet bool
}

func (v NullableSelectableStage) Get() *SelectableStage {
	return v.value
}

func (v *NullableSelectableStage) Set(val *SelectableStage) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSelectableStage(val *SelectableStage) *NullableSelectableStage {
	return &NullableSelectableStage{value: val, isSet: true}
}

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

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