/*
Daytona

Daytona AI platform API Docs

API version: 1.0
Contact: support@daytona.com
*/

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

package apiclient

import (
	"encoding/json"
	"fmt"
)

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

// UpdateSandboxStateDto struct for UpdateSandboxStateDto
type UpdateSandboxStateDto struct {
	// The new state for the sandbox
	State string `json:"state"`
	// Optional error message when reporting an error state
	ErrorReason *string `json:"errorReason,omitempty"`
	// Whether the sandbox is recoverable
	Recoverable *bool `json:"recoverable,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _UpdateSandboxStateDto UpdateSandboxStateDto

// NewUpdateSandboxStateDto instantiates a new UpdateSandboxStateDto 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 NewUpdateSandboxStateDto(state string) *UpdateSandboxStateDto {
	this := UpdateSandboxStateDto{}
	this.State = state
	return &this
}

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

// GetState returns the State field value
func (o *UpdateSandboxStateDto) GetState() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.State
}

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

// SetState sets field value
func (o *UpdateSandboxStateDto) SetState(v string) {
	o.State = v
}

// GetErrorReason returns the ErrorReason field value if set, zero value otherwise.
func (o *UpdateSandboxStateDto) GetErrorReason() string {
	if o == nil || IsNil(o.ErrorReason) {
		var ret string
		return ret
	}
	return *o.ErrorReason
}

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

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

	return false
}

// SetErrorReason gets a reference to the given string and assigns it to the ErrorReason field.
func (o *UpdateSandboxStateDto) SetErrorReason(v string) {
	o.ErrorReason = &v
}

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

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

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

	return false
}

// SetRecoverable gets a reference to the given bool and assigns it to the Recoverable field.
func (o *UpdateSandboxStateDto) SetRecoverable(v bool) {
	o.Recoverable = &v
}

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

func (o UpdateSandboxStateDto) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["state"] = o.State
	if !IsNil(o.ErrorReason) {
		toSerialize["errorReason"] = o.ErrorReason
	}
	if !IsNil(o.Recoverable) {
		toSerialize["recoverable"] = o.Recoverable
	}

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

	return toSerialize, nil
}

func (o *UpdateSandboxStateDto) 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{
		"state",
	}

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

	varUpdateSandboxStateDto := _UpdateSandboxStateDto{}

	err = json.Unmarshal(data, &varUpdateSandboxStateDto)

	if err != nil {
		return err
	}

	*o = UpdateSandboxStateDto(varUpdateSandboxStateDto)

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

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

	return err
}

type NullableUpdateSandboxStateDto struct {
	value *UpdateSandboxStateDto
	isSet bool
}

func (v NullableUpdateSandboxStateDto) Get() *UpdateSandboxStateDto {
	return v.value
}

func (v *NullableUpdateSandboxStateDto) Set(val *UpdateSandboxStateDto) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUpdateSandboxStateDto(val *UpdateSandboxStateDto) *NullableUpdateSandboxStateDto {
	return &NullableUpdateSandboxStateDto{value: val, isSet: true}
}

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

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


