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

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

// FilterPredicate Attribute filter predicate
type FilterPredicate 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.  The $exists operator expects a boolean value: true means the specified attribute exists, false means the specified attribute doesn't exist.  The $regex operator expects a string as a Perl compatible regular expression (PCRE), automatically anchored by ^. If the regular expression is not valid, the filter will produce no results. If you need to specify options and flags, you can provide the full regex in the format of /regex/flags, for example `/[a-z]+/i`. 
	Value string `json:"value"`
}

type _FilterPredicate FilterPredicate

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

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

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

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

// GetAttribute returns the Attribute field value
func (o *FilterPredicate) 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 *FilterPredicate) GetAttributeOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Attribute, true
}

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

// GetType returns the Type field value
func (o *FilterPredicate) 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 *FilterPredicate) GetTypeOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Type, true
}

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

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

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

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

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

func (o *FilterPredicate) 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)
		}
	}

	varFilterPredicate := _FilterPredicate{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varFilterPredicate)

	if err != nil {
		return err
	}

	*o = FilterPredicate(varFilterPredicate)

	return err
}

type NullableFilterPredicate struct {
	value *FilterPredicate
	isSet bool
}

func (v NullableFilterPredicate) Get() *FilterPredicate {
	return v.value
}

func (v *NullableFilterPredicate) Set(val *FilterPredicate) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableFilterPredicate(val *FilterPredicate) *NullableFilterPredicate {
	return &NullableFilterPredicate{value: val, isSet: true}
}

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

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


