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

// NewDeviceInternalProvision struct for NewDeviceInternalProvision
type NewDeviceInternalProvision struct {
	// ID of the new device.
	Id string `json:"id"`
	// Authorization status for the device.
	Status *string `json:"status,omitempty"`
	AuthSets []AuthSet `json:"auth_sets,omitempty"`
	// The creation timestamp of the device.
	CreatedTs *time.Time `json:"created_ts,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _NewDeviceInternalProvision NewDeviceInternalProvision

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

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

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

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

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

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

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

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

func (o NewDeviceInternalProvision) 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 *NewDeviceInternalProvision) 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)
		}
	}

	varNewDeviceInternalProvision := _NewDeviceInternalProvision{}

	err = json.Unmarshal(data, &varNewDeviceInternalProvision)

	if err != nil {
		return err
	}

	*o = NewDeviceInternalProvision(varNewDeviceInternalProvision)

	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 NullableNewDeviceInternalProvision struct {
	value *NewDeviceInternalProvision
	isSet bool
}

func (v NullableNewDeviceInternalProvision) Get() *NewDeviceInternalProvision {
	return v.value
}

func (v *NullableNewDeviceInternalProvision) Set(val *NewDeviceInternalProvision) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableNewDeviceInternalProvision(val *NewDeviceInternalProvision) *NullableNewDeviceInternalProvision {
	return &NullableNewDeviceInternalProvision{value: val, isSet: true}
}

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

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


