/*
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"
	"time"
)

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

// Device struct for Device
type Device struct {
	// Mender assigned Device ID.
	Id *string `json:"id,omitempty"`
	IdentityData *IdentityData `json:"identity_data,omitempty"`
	Status *string `json:"status,omitempty"`
	// Created timestamp
	CreatedTs *time.Time `json:"created_ts,omitempty"`
	// Updated timestamp
	UpdatedTs *time.Time `json:"updated_ts,omitempty"`
	// Time when accepted device contacted server for the last time.
	CheckInTime *time.Time `json:"check_in_time,omitempty"`
	AuthSets []AuthSet `json:"auth_sets,omitempty"`
	// Devices that are part of ongoing decomissioning process will return True
	Decommissioning *bool `json:"decommissioning,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _Device Device

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

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

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

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

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

	return false
}

// SetId gets a reference to the given string and assigns it to the Id field.
func (o *Device) SetId(v string) {
	o.Id = &v
}

// GetIdentityData returns the IdentityData field value if set, zero value otherwise.
func (o *Device) GetIdentityData() IdentityData {
	if o == nil || IsNil(o.IdentityData) {
		var ret IdentityData
		return ret
	}
	return *o.IdentityData
}

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

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

	return false
}

// SetIdentityData gets a reference to the given IdentityData and assigns it to the IdentityData field.
func (o *Device) SetIdentityData(v IdentityData) {
	o.IdentityData = &v
}

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

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

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

	return false
}

// SetStatus gets a reference to the given string and assigns it to the Status field.
func (o *Device) SetStatus(v string) {
	o.Status = &v
}

// GetCreatedTs returns the CreatedTs field value if set, zero value otherwise.
func (o *Device) GetCreatedTs() time.Time {
	if o == nil || IsNil(o.CreatedTs) {
		var ret time.Time
		return ret
	}
	return *o.CreatedTs
}

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

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

	return false
}

// SetCreatedTs gets a reference to the given time.Time and assigns it to the CreatedTs field.
func (o *Device) SetCreatedTs(v time.Time) {
	o.CreatedTs = &v
}

// GetUpdatedTs returns the UpdatedTs field value if set, zero value otherwise.
func (o *Device) GetUpdatedTs() time.Time {
	if o == nil || IsNil(o.UpdatedTs) {
		var ret time.Time
		return ret
	}
	return *o.UpdatedTs
}

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

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

	return false
}

// SetUpdatedTs gets a reference to the given time.Time and assigns it to the UpdatedTs field.
func (o *Device) SetUpdatedTs(v time.Time) {
	o.UpdatedTs = &v
}

// GetCheckInTime returns the CheckInTime field value if set, zero value otherwise.
func (o *Device) GetCheckInTime() time.Time {
	if o == nil || IsNil(o.CheckInTime) {
		var ret time.Time
		return ret
	}
	return *o.CheckInTime
}

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

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

	return false
}

// SetCheckInTime gets a reference to the given time.Time and assigns it to the CheckInTime field.
func (o *Device) SetCheckInTime(v time.Time) {
	o.CheckInTime = &v
}

// GetAuthSets returns the AuthSets field value if set, zero value otherwise.
func (o *Device) GetAuthSets() []AuthSet {
	if o == nil || IsNil(o.AuthSets) {
		var ret []AuthSet
		return ret
	}
	return o.AuthSets
}

// GetAuthSetsOk returns a tuple with the AuthSets field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Device) GetAuthSetsOk() ([]AuthSet, bool) {
	if o == nil || IsNil(o.AuthSets) {
		return nil, false
	}
	return o.AuthSets, true
}

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

	return false
}

// SetAuthSets gets a reference to the given []AuthSet and assigns it to the AuthSets field.
func (o *Device) SetAuthSets(v []AuthSet) {
	o.AuthSets = v
}

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

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

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

	return false
}

// SetDecommissioning gets a reference to the given bool and assigns it to the Decommissioning field.
func (o *Device) SetDecommissioning(v bool) {
	o.Decommissioning = &v
}

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

func (o Device) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Id) {
		toSerialize["id"] = o.Id
	}
	if !IsNil(o.IdentityData) {
		toSerialize["identity_data"] = o.IdentityData
	}
	if !IsNil(o.Status) {
		toSerialize["status"] = o.Status
	}
	if !IsNil(o.CreatedTs) {
		toSerialize["created_ts"] = o.CreatedTs
	}
	if !IsNil(o.UpdatedTs) {
		toSerialize["updated_ts"] = o.UpdatedTs
	}
	if !IsNil(o.CheckInTime) {
		toSerialize["check_in_time"] = o.CheckInTime
	}
	if !IsNil(o.AuthSets) {
		toSerialize["auth_sets"] = o.AuthSets
	}
	if !IsNil(o.Decommissioning) {
		toSerialize["decommissioning"] = o.Decommissioning
	}

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

	return toSerialize, nil
}

func (o *Device) UnmarshalJSON(data []byte) (err error) {
	varDevice := _Device{}

	err = json.Unmarshal(data, &varDevice)

	if err != nil {
		return err
	}

	*o = Device(varDevice)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "id")
		delete(additionalProperties, "identity_data")
		delete(additionalProperties, "status")
		delete(additionalProperties, "created_ts")
		delete(additionalProperties, "updated_ts")
		delete(additionalProperties, "check_in_time")
		delete(additionalProperties, "auth_sets")
		delete(additionalProperties, "decommissioning")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableDevice struct {
	value *Device
	isSet bool
}

func (v NullableDevice) Get() *Device {
	return v.value
}

func (v *NullableDevice) Set(val *Device) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDevice(val *Device) *NullableDevice {
	return &NullableDevice{value: val, isSet: true}
}

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

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


