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

// DeviceAuthEvent DeviceAuthEvent describes an event that relates to changes to a device's authentication data. The properties included depends on the event type: device provisioning includes the entire device with the accepted authentication set, status change events only includes the device id and the new status, and device decommissioning will only include the device id.
type DeviceAuthEvent struct {
	// Device unique ID.
	Id string `json:"id"`
	// The authentication status of the device.
	Status *string `json:"status,omitempty"`
	AuthSets []AuthSet `json:"auth_sets,omitempty"`
	// The time the device was initialized in Mender.
	CreatedTs *time.Time `json:"created_ts,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _DeviceAuthEvent DeviceAuthEvent

// NewDeviceAuthEvent instantiates a new DeviceAuthEvent 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 NewDeviceAuthEvent(id string) *DeviceAuthEvent {
	this := DeviceAuthEvent{}
	this.Id = id
	return &this
}

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

// GetId returns the Id field value
func (o *DeviceAuthEvent) 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 *DeviceAuthEvent) GetIdOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Id, true
}

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

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

// GetAuthSets returns the AuthSets field value if set, zero value otherwise.
func (o *DeviceAuthEvent) 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 *DeviceAuthEvent) 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 *DeviceAuthEvent) 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 *DeviceAuthEvent) SetAuthSets(v []AuthSet) {
	o.AuthSets = v
}

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

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

func (o DeviceAuthEvent) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id"] = o.Id
	if !IsNil(o.Status) {
		toSerialize["status"] = o.Status
	}
	if !IsNil(o.AuthSets) {
		toSerialize["auth_sets"] = o.AuthSets
	}
	if !IsNil(o.CreatedTs) {
		toSerialize["created_ts"] = o.CreatedTs
	}

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

	return toSerialize, nil
}

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

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

	varDeviceAuthEvent := _DeviceAuthEvent{}

	err = json.Unmarshal(data, &varDeviceAuthEvent)

	if err != nil {
		return err
	}

	*o = DeviceAuthEvent(varDeviceAuthEvent)

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

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

	return err
}

type NullableDeviceAuthEvent struct {
	value *DeviceAuthEvent
	isSet bool
}

func (v NullableDeviceAuthEvent) Get() *DeviceAuthEvent {
	return v.value
}

func (v *NullableDeviceAuthEvent) Set(val *DeviceAuthEvent) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeviceAuthEvent(val *DeviceAuthEvent) *NullableDeviceAuthEvent {
	return &NullableDeviceAuthEvent{value: val, isSet: true}
}

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

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


