/*
Merlin

API Guide for accessing Merlin's model management, deployment, and serving functionalities

API version: 0.14.0
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package client

import (
	"encoding/json"
	"fmt"
)

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

// Paging struct for Paging
type Paging struct {
	// Total number of results matching the query criteria
	Total int32 `json:"total"`
	// Number of the current page
	Page int32 `json:"page"`
	// Total number of pages
	Pages int32 `json:"pages"`
}

type _Paging Paging

// NewPaging instantiates a new Paging 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 NewPaging(total int32, page int32, pages int32) *Paging {
	this := Paging{}
	this.Total = total
	this.Page = page
	this.Pages = pages
	return &this
}

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

// GetTotal returns the Total field value
func (o *Paging) GetTotal() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Total
}

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

// SetTotal sets field value
func (o *Paging) SetTotal(v int32) {
	o.Total = v
}

// GetPage returns the Page field value
func (o *Paging) GetPage() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Page
}

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

// SetPage sets field value
func (o *Paging) SetPage(v int32) {
	o.Page = v
}

// GetPages returns the Pages field value
func (o *Paging) GetPages() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Pages
}

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

// SetPages sets field value
func (o *Paging) SetPages(v int32) {
	o.Pages = v
}

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

func (o Paging) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["total"] = o.Total
	toSerialize["page"] = o.Page
	toSerialize["pages"] = o.Pages
	return toSerialize, nil
}

func (o *Paging) UnmarshalJSON(bytes []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{
		"total",
		"page",
		"pages",
	}

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

	err = json.Unmarshal(bytes, &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)
		}
	}

	varPaging := _Paging{}

	err = json.Unmarshal(bytes, &varPaging)

	if err != nil {
		return err
	}

	*o = Paging(varPaging)

	return err
}

type NullablePaging struct {
	value *Paging
	isSet bool
}

func (v NullablePaging) Get() *Paging {
	return v.value
}

func (v *NullablePaging) Set(val *Paging) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullablePaging(val *Paging) *NullablePaging {
	return &NullablePaging{value: val, isSet: true}
}

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

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