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

// ConnectionState struct for ConnectionState
type ConnectionState struct {
	// Device ID.
	DeviceId *string `json:"device_id,omitempty"`
	// Device status.
	Status *string `json:"status,omitempty"`
	// Server-side timestamp of the last device information update.
	UpdatedTs *time.Time `json:"updated_ts,omitempty"`
	// Server-side timestamp of the device creation.
	CreatedTs *time.Time `json:"created_ts,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _ConnectionState ConnectionState

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

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

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

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

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

	return false
}

// SetDeviceId gets a reference to the given string and assigns it to the DeviceId field.
func (o *ConnectionState) SetDeviceId(v string) {
	o.DeviceId = &v
}

// GetStatus returns the Status field value if set, zero value otherwise.
func (o *ConnectionState) 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 *ConnectionState) 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 *ConnectionState) 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 *ConnectionState) SetStatus(v string) {
	o.Status = &v
}

// GetUpdatedTs returns the UpdatedTs field value if set, zero value otherwise.
func (o *ConnectionState) 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 *ConnectionState) 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 *ConnectionState) 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 *ConnectionState) SetUpdatedTs(v time.Time) {
	o.UpdatedTs = &v
}

// GetCreatedTs returns the CreatedTs field value if set, zero value otherwise.
func (o *ConnectionState) 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 *ConnectionState) 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 *ConnectionState) 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 *ConnectionState) SetCreatedTs(v time.Time) {
	o.CreatedTs = &v
}

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

func (o ConnectionState) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.DeviceId) {
		toSerialize["device_id"] = o.DeviceId
	}
	if !IsNil(o.Status) {
		toSerialize["status"] = o.Status
	}
	if !IsNil(o.UpdatedTs) {
		toSerialize["updated_ts"] = o.UpdatedTs
	}
	if !IsNil(o.CreatedTs) {
		toSerialize["created_ts"] = o.CreatedTs
	}

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

	return toSerialize, nil
}

func (o *ConnectionState) UnmarshalJSON(data []byte) (err error) {
	varConnectionState := _ConnectionState{}

	err = json.Unmarshal(data, &varConnectionState)

	if err != nil {
		return err
	}

	*o = ConnectionState(varConnectionState)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "device_id")
		delete(additionalProperties, "status")
		delete(additionalProperties, "updated_ts")
		delete(additionalProperties, "created_ts")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableConnectionState struct {
	value *ConnectionState
	isSet bool
}

func (v NullableConnectionState) Get() *ConnectionState {
	return v.value
}

func (v *NullableConnectionState) Set(val *ConnectionState) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableConnectionState(val *ConnectionState) *NullableConnectionState {
	return &NullableConnectionState{value: val, isSet: true}
}

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

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


