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

// FilterAttribute Filterable attribute
type FilterAttribute struct {
	// Name of the attribute.
	Name string `json:"name"`
	Scope Scope `json:"scope"`
	// Number of occurrences of the attribute in the database.
	Count int32 `json:"count"`
	AdditionalProperties map[string]interface{}
}

type _FilterAttribute FilterAttribute

// NewFilterAttribute instantiates a new FilterAttribute 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 NewFilterAttribute(name string, scope Scope, count int32) *FilterAttribute {
	this := FilterAttribute{}
	this.Name = name
	this.Scope = scope
	this.Count = count
	return &this
}

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

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

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

// GetScope returns the Scope field value
func (o *FilterAttribute) 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 *FilterAttribute) GetScopeOk() (*Scope, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Scope, true
}

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

// GetCount returns the Count field value
func (o *FilterAttribute) GetCount() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Count
}

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

// SetCount sets field value
func (o *FilterAttribute) SetCount(v int32) {
	o.Count = v
}

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

func (o FilterAttribute) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["name"] = o.Name
	toSerialize["scope"] = o.Scope
	toSerialize["count"] = o.Count

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

	return toSerialize, nil
}

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

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

	varFilterAttribute := _FilterAttribute{}

	err = json.Unmarshal(data, &varFilterAttribute)

	if err != nil {
		return err
	}

	*o = FilterAttribute(varFilterAttribute)

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

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

	return err
}

type NullableFilterAttribute struct {
	value *FilterAttribute
	isSet bool
}

func (v NullableFilterAttribute) Get() *FilterAttribute {
	return v.value
}

func (v *NullableFilterAttribute) Set(val *FilterAttribute) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableFilterAttribute(val *FilterAttribute) *NullableFilterAttribute {
	return &NullableFilterAttribute{value: val, isSet: true}
}

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

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


