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

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

// Update Single updated to be applied. 
type Update struct {
	TypeInfo *ArtifactTypeInfo `json:"type_info,omitempty"`
	Files []UpdateFile `json:"files,omitempty"`
	// metadata is an object of unknown structure as this is dependent of update type (also custom defined by user)
	Metadata *map[string]string `json:"metadata,omitempty"`
	// Deprecated: Please use `metadata` instead. A list of objects of unknown structure as this is dependent of update type (also custom defined by user) 
	// Deprecated
	MetaData []map[string]interface{} `json:"meta_data,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _Update Update

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

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

// GetTypeInfo returns the TypeInfo field value if set, zero value otherwise.
func (o *Update) GetTypeInfo() ArtifactTypeInfo {
	if o == nil || IsNil(o.TypeInfo) {
		var ret ArtifactTypeInfo
		return ret
	}
	return *o.TypeInfo
}

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

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

	return false
}

// SetTypeInfo gets a reference to the given ArtifactTypeInfo and assigns it to the TypeInfo field.
func (o *Update) SetTypeInfo(v ArtifactTypeInfo) {
	o.TypeInfo = &v
}

// GetFiles returns the Files field value if set, zero value otherwise.
func (o *Update) GetFiles() []UpdateFile {
	if o == nil || IsNil(o.Files) {
		var ret []UpdateFile
		return ret
	}
	return o.Files
}

// GetFilesOk returns a tuple with the Files field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Update) GetFilesOk() ([]UpdateFile, bool) {
	if o == nil || IsNil(o.Files) {
		return nil, false
	}
	return o.Files, true
}

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

	return false
}

// SetFiles gets a reference to the given []UpdateFile and assigns it to the Files field.
func (o *Update) SetFiles(v []UpdateFile) {
	o.Files = v
}

// GetMetadata returns the Metadata field value if set, zero value otherwise.
func (o *Update) GetMetadata() map[string]string {
	if o == nil || IsNil(o.Metadata) {
		var ret map[string]string
		return ret
	}
	return *o.Metadata
}

// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Update) GetMetadataOk() (*map[string]string, bool) {
	if o == nil || IsNil(o.Metadata) {
		return nil, false
	}
	return o.Metadata, true
}

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

	return false
}

// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field.
func (o *Update) SetMetadata(v map[string]string) {
	o.Metadata = &v
}

// GetMetaData returns the MetaData field value if set, zero value otherwise.
// Deprecated
func (o *Update) GetMetaData() []map[string]interface{} {
	if o == nil || IsNil(o.MetaData) {
		var ret []map[string]interface{}
		return ret
	}
	return o.MetaData
}

// GetMetaDataOk returns a tuple with the MetaData field value if set, nil otherwise
// and a boolean to check if the value has been set.
// Deprecated
func (o *Update) GetMetaDataOk() ([]map[string]interface{}, bool) {
	if o == nil || IsNil(o.MetaData) {
		return nil, false
	}
	return o.MetaData, true
}

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

	return false
}

// SetMetaData gets a reference to the given []map[string]interface{} and assigns it to the MetaData field.
// Deprecated
func (o *Update) SetMetaData(v []map[string]interface{}) {
	o.MetaData = v
}

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

func (o Update) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.TypeInfo) {
		toSerialize["type_info"] = o.TypeInfo
	}
	if !IsNil(o.Files) {
		toSerialize["files"] = o.Files
	}
	if !IsNil(o.Metadata) {
		toSerialize["metadata"] = o.Metadata
	}
	if !IsNil(o.MetaData) {
		toSerialize["meta_data"] = o.MetaData
	}

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

	return toSerialize, nil
}

func (o *Update) UnmarshalJSON(data []byte) (err error) {
	varUpdate := _Update{}

	err = json.Unmarshal(data, &varUpdate)

	if err != nil {
		return err
	}

	*o = Update(varUpdate)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "type_info")
		delete(additionalProperties, "files")
		delete(additionalProperties, "metadata")
		delete(additionalProperties, "meta_data")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableUpdate struct {
	value *Update
	isSet bool
}

func (v NullableUpdate) Get() *Update {
	return v.value
}

func (v *NullableUpdate) Set(val *Update) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUpdate(val *Update) *NullableUpdate {
	return &NullableUpdate{value: val, isSet: true}
}

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

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


