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

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

// DeviceUpdate Object containing device id and device revision of the device to update.
type DeviceUpdate struct {
	// Device identifier.
	Id string `json:"id"`
	// Device object revision.
	Revision int32 `json:"revision"`
	AdditionalProperties map[string]interface{}
}

type _DeviceUpdate DeviceUpdate

// NewDeviceUpdate instantiates a new DeviceUpdate 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 NewDeviceUpdate(id string, revision int32) *DeviceUpdate {
	this := DeviceUpdate{}
	this.Id = id
	this.Revision = revision
	return &this
}

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

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

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

// GetRevision returns the Revision field value
func (o *DeviceUpdate) GetRevision() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Revision
}

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

// SetRevision sets field value
func (o *DeviceUpdate) SetRevision(v int32) {
	o.Revision = v
}

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

func (o DeviceUpdate) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id"] = o.Id
	toSerialize["revision"] = o.Revision

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

	return toSerialize, nil
}

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

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

	varDeviceUpdate := _DeviceUpdate{}

	err = json.Unmarshal(data, &varDeviceUpdate)

	if err != nil {
		return err
	}

	*o = DeviceUpdate(varDeviceUpdate)

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

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

	return err
}

type NullableDeviceUpdate struct {
	value *DeviceUpdate
	isSet bool
}

func (v NullableDeviceUpdate) Get() *DeviceUpdate {
	return v.value
}

func (v *NullableDeviceUpdate) Set(val *DeviceUpdate) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeviceUpdate(val *DeviceUpdate) *NullableDeviceUpdate {
	return &NullableDeviceUpdate{value: val, isSet: true}
}

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

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


