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

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

// SearchParams struct for SearchParams
type SearchParams struct {
	// Starting page.
	Page *int32 `json:"page,omitempty"`
	// Number of results per page.
	PerPage *int32 `json:"per_page,omitempty"`
	// List of device IDs
	DeviceIds []string `json:"device_ids,omitempty"`
	// Free-text search query
	Text *string `json:"text,omitempty"`
	// List of filter predicates, chained with boolean AND operators to build the search condition definition.
	Filters []FilterPredicate `json:"filters,omitempty"`
	// List of ordered sort criterias
	Sort []SortCriteria `json:"sort,omitempty"`
	// List of attributes to select and return
	Attributes []SelectAttribute `json:"attributes,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _SearchParams SearchParams

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

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

// GetPage returns the Page field value if set, zero value otherwise.
func (o *SearchParams) GetPage() int32 {
	if o == nil || IsNil(o.Page) {
		var ret int32
		return ret
	}
	return *o.Page
}

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

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

	return false
}

// SetPage gets a reference to the given int32 and assigns it to the Page field.
func (o *SearchParams) SetPage(v int32) {
	o.Page = &v
}

// GetPerPage returns the PerPage field value if set, zero value otherwise.
func (o *SearchParams) GetPerPage() int32 {
	if o == nil || IsNil(o.PerPage) {
		var ret int32
		return ret
	}
	return *o.PerPage
}

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

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

	return false
}

// SetPerPage gets a reference to the given int32 and assigns it to the PerPage field.
func (o *SearchParams) SetPerPage(v int32) {
	o.PerPage = &v
}

// GetDeviceIds returns the DeviceIds field value if set, zero value otherwise.
func (o *SearchParams) GetDeviceIds() []string {
	if o == nil || IsNil(o.DeviceIds) {
		var ret []string
		return ret
	}
	return o.DeviceIds
}

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

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

	return false
}

// SetDeviceIds gets a reference to the given []string and assigns it to the DeviceIds field.
func (o *SearchParams) SetDeviceIds(v []string) {
	o.DeviceIds = v
}

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

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

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

	return false
}

// SetText gets a reference to the given string and assigns it to the Text field.
func (o *SearchParams) SetText(v string) {
	o.Text = &v
}

// GetFilters returns the Filters field value if set, zero value otherwise.
func (o *SearchParams) GetFilters() []FilterPredicate {
	if o == nil || IsNil(o.Filters) {
		var ret []FilterPredicate
		return ret
	}
	return o.Filters
}

// GetFiltersOk returns a tuple with the Filters field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SearchParams) GetFiltersOk() ([]FilterPredicate, bool) {
	if o == nil || IsNil(o.Filters) {
		return nil, false
	}
	return o.Filters, true
}

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

	return false
}

// SetFilters gets a reference to the given []FilterPredicate and assigns it to the Filters field.
func (o *SearchParams) SetFilters(v []FilterPredicate) {
	o.Filters = v
}

// GetSort returns the Sort field value if set, zero value otherwise.
func (o *SearchParams) GetSort() []SortCriteria {
	if o == nil || IsNil(o.Sort) {
		var ret []SortCriteria
		return ret
	}
	return o.Sort
}

// GetSortOk returns a tuple with the Sort field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SearchParams) GetSortOk() ([]SortCriteria, bool) {
	if o == nil || IsNil(o.Sort) {
		return nil, false
	}
	return o.Sort, true
}

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

	return false
}

// SetSort gets a reference to the given []SortCriteria and assigns it to the Sort field.
func (o *SearchParams) SetSort(v []SortCriteria) {
	o.Sort = v
}

// GetAttributes returns the Attributes field value if set, zero value otherwise.
func (o *SearchParams) GetAttributes() []SelectAttribute {
	if o == nil || IsNil(o.Attributes) {
		var ret []SelectAttribute
		return ret
	}
	return o.Attributes
}

// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SearchParams) GetAttributesOk() ([]SelectAttribute, bool) {
	if o == nil || IsNil(o.Attributes) {
		return nil, false
	}
	return o.Attributes, true
}

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

	return false
}

// SetAttributes gets a reference to the given []SelectAttribute and assigns it to the Attributes field.
func (o *SearchParams) SetAttributes(v []SelectAttribute) {
	o.Attributes = v
}

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

func (o SearchParams) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Page) {
		toSerialize["page"] = o.Page
	}
	if !IsNil(o.PerPage) {
		toSerialize["per_page"] = o.PerPage
	}
	if !IsNil(o.DeviceIds) {
		toSerialize["device_ids"] = o.DeviceIds
	}
	if !IsNil(o.Text) {
		toSerialize["text"] = o.Text
	}
	if !IsNil(o.Filters) {
		toSerialize["filters"] = o.Filters
	}
	if !IsNil(o.Sort) {
		toSerialize["sort"] = o.Sort
	}
	if !IsNil(o.Attributes) {
		toSerialize["attributes"] = o.Attributes
	}

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

	return toSerialize, nil
}

func (o *SearchParams) UnmarshalJSON(data []byte) (err error) {
	varSearchParams := _SearchParams{}

	err = json.Unmarshal(data, &varSearchParams)

	if err != nil {
		return err
	}

	*o = SearchParams(varSearchParams)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "page")
		delete(additionalProperties, "per_page")
		delete(additionalProperties, "device_ids")
		delete(additionalProperties, "text")
		delete(additionalProperties, "filters")
		delete(additionalProperties, "sort")
		delete(additionalProperties, "attributes")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableSearchParams struct {
	value *SearchParams
	isSet bool
}

func (v NullableSearchParams) Get() *SearchParams {
	return v.value
}

func (v *NullableSearchParams) Set(val *SearchParams) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSearchParams(val *SearchParams) *NullableSearchParams {
	return &NullableSearchParams{value: val, isSet: true}
}

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

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


