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

// AttributeResponse Attribute descriptor.
type AttributeResponse 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 AttributeValueResponse `json:"value"`
	Scope Scope `json:"scope"`
	// The date and time of last tag update in RFC3339 format.  Only applicable when scope is `tags`. 
	Timestamp *time.Time `json:"timestamp,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _AttributeResponse AttributeResponse

// NewAttributeResponse instantiates a new AttributeResponse 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 NewAttributeResponse(name string, value AttributeValueResponse, scope Scope) *AttributeResponse {
	this := AttributeResponse{}
	this.Name = name
	this.Value = value
	this.Scope = scope
	return &this
}

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

// GetName returns the Name field value
func (o *AttributeResponse) 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 *AttributeResponse) GetNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Name, true
}

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

// GetDescription returns the Description field value if set, zero value otherwise.
func (o *AttributeResponse) 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 *AttributeResponse) 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 *AttributeResponse) 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 *AttributeResponse) SetDescription(v string) {
	o.Description = &v
}

// GetValue returns the Value field value
func (o *AttributeResponse) GetValue() AttributeValueResponse {
	if o == nil {
		var ret AttributeValueResponse
		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 *AttributeResponse) GetValueOk() (*AttributeValueResponse, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Value, true
}

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

// GetScope returns the Scope field value
func (o *AttributeResponse) GetScope() Scope {
	if o == nil {
		var ret Scope
		return ret
	}

	return o.Scope
}

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

// SetScope sets field value
func (o *AttributeResponse) SetScope(v Scope) {
	o.Scope = v
}

// GetTimestamp returns the Timestamp field value if set, zero value otherwise.
func (o *AttributeResponse) GetTimestamp() time.Time {
	if o == nil || IsNil(o.Timestamp) {
		var ret time.Time
		return ret
	}
	return *o.Timestamp
}

// GetTimestampOk returns a tuple with the Timestamp field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *AttributeResponse) GetTimestampOk() (*time.Time, bool) {
	if o == nil || IsNil(o.Timestamp) {
		return nil, false
	}
	return o.Timestamp, true
}

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

	return false
}

// SetTimestamp gets a reference to the given time.Time and assigns it to the Timestamp field.
func (o *AttributeResponse) SetTimestamp(v time.Time) {
	o.Timestamp = &v
}

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

func (o AttributeResponse) 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
	toSerialize["scope"] = o.Scope
	if !IsNil(o.Timestamp) {
		toSerialize["timestamp"] = o.Timestamp
	}

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

	return toSerialize, nil
}

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

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

	varAttributeResponse := _AttributeResponse{}

	err = json.Unmarshal(data, &varAttributeResponse)

	if err != nil {
		return err
	}

	*o = AttributeResponse(varAttributeResponse)

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

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

	return err
}

type NullableAttributeResponse struct {
	value *AttributeResponse
	isSet bool
}

func (v NullableAttributeResponse) Get() *AttributeResponse {
	return v.value
}

func (v *NullableAttributeResponse) Set(val *AttributeResponse) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableAttributeResponse(val *AttributeResponse) *NullableAttributeResponse {
	return &NullableAttributeResponse{value: val, isSet: true}
}

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

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


