/*
Mender API

Combined API specification for the features of the different Mender backend services, suitable for code generation applications 

API version: 1
Contact: support@mender.io
*/

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

package client

import (
	"encoding/json"
)

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

// DeviceState struct for DeviceState
type DeviceState struct {
	// The desired state for the device, as reported by the cloud/user.
	Desired map[string]interface{} `json:"desired,omitempty"`
	// State reported by the device, this cannot be changed from the cloud.
	Reported map[string]interface{} `json:"reported,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _DeviceState DeviceState

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

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

// GetDesired returns the Desired field value if set, zero value otherwise.
func (o *DeviceState) GetDesired() map[string]interface{} {
	if o == nil || IsNil(o.Desired) {
		var ret map[string]interface{}
		return ret
	}
	return o.Desired
}

// GetDesiredOk returns a tuple with the Desired field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DeviceState) GetDesiredOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.Desired) {
		return map[string]interface{}{}, false
	}
	return o.Desired, true
}

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

	return false
}

// SetDesired gets a reference to the given map[string]interface{} and assigns it to the Desired field.
func (o *DeviceState) SetDesired(v map[string]interface{}) {
	o.Desired = v
}

// GetReported returns the Reported field value if set, zero value otherwise.
func (o *DeviceState) GetReported() map[string]interface{} {
	if o == nil || IsNil(o.Reported) {
		var ret map[string]interface{}
		return ret
	}
	return o.Reported
}

// GetReportedOk returns a tuple with the Reported field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DeviceState) GetReportedOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.Reported) {
		return map[string]interface{}{}, false
	}
	return o.Reported, true
}

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

	return false
}

// SetReported gets a reference to the given map[string]interface{} and assigns it to the Reported field.
func (o *DeviceState) SetReported(v map[string]interface{}) {
	o.Reported = v
}

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

func (o DeviceState) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Desired) {
		toSerialize["desired"] = o.Desired
	}
	if !IsNil(o.Reported) {
		toSerialize["reported"] = o.Reported
	}

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

	return toSerialize, nil
}

func (o *DeviceState) UnmarshalJSON(data []byte) (err error) {
	varDeviceState := _DeviceState{}

	err = json.Unmarshal(data, &varDeviceState)

	if err != nil {
		return err
	}

	*o = DeviceState(varDeviceState)

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

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

	return err
}

type NullableDeviceState struct {
	value *DeviceState
	isSet bool
}

func (v NullableDeviceState) Get() *DeviceState {
	return v.value
}

func (v *NullableDeviceState) Set(val *DeviceState) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeviceState(val *DeviceState) *NullableDeviceState {
	return &NullableDeviceState{value: val, isSet: true}
}

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

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


