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

// AttributeFilterPredicate Attribute filter predicate
type AttributeFilterPredicate struct {
	Scope Scope `json:"scope"`
	// Name of the attribute to be queried for filtering. 
	Attribute string `json:"attribute"`
	// Type or operator of the filter predicate.
	Type string `json:"type"`
	// The value of the attribute to be used in filtering. Attribute type is implicit, inferred from the JSON type. Supported types: number, string, array of numbers, array of strings. Mixed arrays are not allowed. 
	Value interface{} `json:"value"`
	AdditionalProperties map[string]interface{}
}

type _AttributeFilterPredicate AttributeFilterPredicate

// NewAttributeFilterPredicate instantiates a new AttributeFilterPredicate 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 NewAttributeFilterPredicate(scope Scope, attribute string, type_ string, value interface{}) *AttributeFilterPredicate {
	this := AttributeFilterPredicate{}
	this.Scope = scope
	this.Attribute = attribute
	this.Type = type_
	this.Value = value
	return &this
}

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

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

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

// GetAttribute returns the Attribute field value
func (o *AttributeFilterPredicate) GetAttribute() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Attribute
}

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

// SetAttribute sets field value
func (o *AttributeFilterPredicate) SetAttribute(v string) {
	o.Attribute = v
}

// GetType returns the Type field value
func (o *AttributeFilterPredicate) GetType() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Type
}

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

// SetType sets field value
func (o *AttributeFilterPredicate) SetType(v string) {
	o.Type = v
}

// GetValue returns the Value field value
// If the value is explicit nil, the zero value for interface{} will be returned
func (o *AttributeFilterPredicate) GetValue() interface{} {
	if o == nil {
		var ret interface{}
		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.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *AttributeFilterPredicate) GetValueOk() (*interface{}, bool) {
	if o == nil || IsNil(o.Value) {
		return nil, false
	}
	return &o.Value, true
}

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

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

func (o AttributeFilterPredicate) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["scope"] = o.Scope
	toSerialize["attribute"] = o.Attribute
	toSerialize["type"] = o.Type
	if o.Value != nil {
		toSerialize["value"] = o.Value
	}

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

	return toSerialize, nil
}

func (o *AttributeFilterPredicate) 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{
		"scope",
		"attribute",
		"type",
		"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)
		}
	}

	varAttributeFilterPredicate := _AttributeFilterPredicate{}

	err = json.Unmarshal(data, &varAttributeFilterPredicate)

	if err != nil {
		return err
	}

	*o = AttributeFilterPredicate(varAttributeFilterPredicate)

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

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

	return err
}

type NullableAttributeFilterPredicate struct {
	value *AttributeFilterPredicate
	isSet bool
}

func (v NullableAttributeFilterPredicate) Get() *AttributeFilterPredicate {
	return v.value
}

func (v *NullableAttributeFilterPredicate) Set(val *AttributeFilterPredicate) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableAttributeFilterPredicate(val *AttributeFilterPredicate) *NullableAttributeFilterPredicate {
	return &NullableAttributeFilterPredicate{value: val, isSet: true}
}

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

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


