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

// DeviceAttributeRequest Attribute descriptor.
type DeviceAttributeRequest struct {
	// A human readable, unique attribute ID, e.g. 'device_type', 'ip_addr', 'cpu_load', etc. 
	Name string `json:"name"`
	// Attribute description.
	Description *string `json:"description,omitempty"`
	Value AttributeValueRequest `json:"value"`
	AdditionalProperties map[string]interface{}
}

type _DeviceAttributeRequest DeviceAttributeRequest

// NewDeviceAttributeRequest instantiates a new DeviceAttributeRequest 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 NewDeviceAttributeRequest(name string, value AttributeValueRequest) *DeviceAttributeRequest {
	this := DeviceAttributeRequest{}
	this.Name = name
	this.Value = value
	return &this
}

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

// GetName returns the Name field value
func (o *DeviceAttributeRequest) GetName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Name
}

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

// SetName sets field value
func (o *DeviceAttributeRequest) SetName(v string) {
	o.Name = v
}

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

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

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

	return false
}

// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *DeviceAttributeRequest) SetDescription(v string) {
	o.Description = &v
}

// GetValue returns the Value field value
func (o *DeviceAttributeRequest) GetValue() AttributeValueRequest {
	if o == nil {
		var ret AttributeValueRequest
		return ret
	}

	return o.Value
}

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

// SetValue sets field value
func (o *DeviceAttributeRequest) SetValue(v AttributeValueRequest) {
	o.Value = v
}

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

func (o DeviceAttributeRequest) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["name"] = o.Name
	if !IsNil(o.Description) {
		toSerialize["description"] = o.Description
	}
	toSerialize["value"] = o.Value

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

	return toSerialize, nil
}

func (o *DeviceAttributeRequest) 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{
		"name",
		"value",
	}

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

	varDeviceAttributeRequest := _DeviceAttributeRequest{}

	err = json.Unmarshal(data, &varDeviceAttributeRequest)

	if err != nil {
		return err
	}

	*o = DeviceAttributeRequest(varDeviceAttributeRequest)

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

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

	return err
}

type NullableDeviceAttributeRequest struct {
	value *DeviceAttributeRequest
	isSet bool
}

func (v NullableDeviceAttributeRequest) Get() *DeviceAttributeRequest {
	return v.value
}

func (v *NullableDeviceAttributeRequest) Set(val *DeviceAttributeRequest) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeviceAttributeRequest(val *DeviceAttributeRequest) *NullableDeviceAttributeRequest {
	return &NullableDeviceAttributeRequest{value: val, isSet: true}
}

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

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


