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

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

// DeviceWithImage struct for DeviceWithImage
type DeviceWithImage struct {
	// Device identifier.
	Id string `json:"id"`
	Status DeviceStatus `json:"status"`
	Created *time.Time `json:"created,omitempty"`
	Started *time.Time `json:"started,omitempty"`
	Finished *time.Time `json:"finished,omitempty"`
	Deleted *time.Time `json:"deleted,omitempty"`
	DeviceType *string `json:"device_type,omitempty"`
	// Availability of the device's deployment log.
	Log bool `json:"log"`
	// State reported by device
	State *string `json:"state,omitempty"`
	// Additional state information
	Substate *string `json:"substate,omitempty"`
	Image *DeviceWithImageImage `json:"image,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _DeviceWithImage DeviceWithImage

// NewDeviceWithImage instantiates a new DeviceWithImage 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 NewDeviceWithImage(id string, status DeviceStatus, log bool) *DeviceWithImage {
	this := DeviceWithImage{}
	this.Id = id
	this.Status = status
	this.Log = log
	return &this
}

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

// GetId returns the Id field value
func (o *DeviceWithImage) GetId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Id
}

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

// SetId sets field value
func (o *DeviceWithImage) SetId(v string) {
	o.Id = v
}

// GetStatus returns the Status field value
func (o *DeviceWithImage) GetStatus() DeviceStatus {
	if o == nil {
		var ret DeviceStatus
		return ret
	}

	return o.Status
}

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

// SetStatus sets field value
func (o *DeviceWithImage) SetStatus(v DeviceStatus) {
	o.Status = v
}

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

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

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

	return false
}

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

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

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

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

	return false
}

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

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

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

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

	return false
}

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

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

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

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

	return false
}

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

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

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

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

	return false
}

// SetDeviceType gets a reference to the given string and assigns it to the DeviceType field.
func (o *DeviceWithImage) SetDeviceType(v string) {
	o.DeviceType = &v
}

// GetLog returns the Log field value
func (o *DeviceWithImage) GetLog() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.Log
}

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

// SetLog sets field value
func (o *DeviceWithImage) SetLog(v bool) {
	o.Log = v
}

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

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

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

	return false
}

// SetState gets a reference to the given string and assigns it to the State field.
func (o *DeviceWithImage) SetState(v string) {
	o.State = &v
}

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

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

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

	return false
}

// SetSubstate gets a reference to the given string and assigns it to the Substate field.
func (o *DeviceWithImage) SetSubstate(v string) {
	o.Substate = &v
}

// GetImage returns the Image field value if set, zero value otherwise.
func (o *DeviceWithImage) GetImage() DeviceWithImageImage {
	if o == nil || IsNil(o.Image) {
		var ret DeviceWithImageImage
		return ret
	}
	return *o.Image
}

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

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

	return false
}

// SetImage gets a reference to the given DeviceWithImageImage and assigns it to the Image field.
func (o *DeviceWithImage) SetImage(v DeviceWithImageImage) {
	o.Image = &v
}

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

func (o DeviceWithImage) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id"] = o.Id
	toSerialize["status"] = o.Status
	if !IsNil(o.Created) {
		toSerialize["created"] = o.Created
	}
	if !IsNil(o.Started) {
		toSerialize["started"] = o.Started
	}
	if !IsNil(o.Finished) {
		toSerialize["finished"] = o.Finished
	}
	if !IsNil(o.Deleted) {
		toSerialize["deleted"] = o.Deleted
	}
	if !IsNil(o.DeviceType) {
		toSerialize["device_type"] = o.DeviceType
	}
	toSerialize["log"] = o.Log
	if !IsNil(o.State) {
		toSerialize["state"] = o.State
	}
	if !IsNil(o.Substate) {
		toSerialize["substate"] = o.Substate
	}
	if !IsNil(o.Image) {
		toSerialize["image"] = o.Image
	}

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

	return toSerialize, nil
}

func (o *DeviceWithImage) 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{
		"id",
		"status",
		"log",
	}

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

	varDeviceWithImage := _DeviceWithImage{}

	err = json.Unmarshal(data, &varDeviceWithImage)

	if err != nil {
		return err
	}

	*o = DeviceWithImage(varDeviceWithImage)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "id")
		delete(additionalProperties, "status")
		delete(additionalProperties, "created")
		delete(additionalProperties, "started")
		delete(additionalProperties, "finished")
		delete(additionalProperties, "deleted")
		delete(additionalProperties, "device_type")
		delete(additionalProperties, "log")
		delete(additionalProperties, "state")
		delete(additionalProperties, "substate")
		delete(additionalProperties, "image")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableDeviceWithImage struct {
	value *DeviceWithImage
	isSet bool
}

func (v NullableDeviceWithImage) Get() *DeviceWithImage {
	return v.value
}

func (v *NullableDeviceWithImage) Set(val *DeviceWithImage) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeviceWithImage(val *DeviceWithImage) *NullableDeviceWithImage {
	return &NullableDeviceWithImage{value: val, isSet: true}
}

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

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


