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

// PlanLimits Plan limits descriptor.
type PlanLimits struct {
	Devices *int32 `json:"devices,omitempty"`
	Users *int32 `json:"users,omitempty"`
	AuditLogsDays *int32 `json:"audit_logs_days,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _PlanLimits PlanLimits

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

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

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

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

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

	return false
}

// SetDevices gets a reference to the given int32 and assigns it to the Devices field.
func (o *PlanLimits) SetDevices(v int32) {
	o.Devices = &v
}

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

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

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

	return false
}

// SetUsers gets a reference to the given int32 and assigns it to the Users field.
func (o *PlanLimits) SetUsers(v int32) {
	o.Users = &v
}

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

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

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

	return false
}

// SetAuditLogsDays gets a reference to the given int32 and assigns it to the AuditLogsDays field.
func (o *PlanLimits) SetAuditLogsDays(v int32) {
	o.AuditLogsDays = &v
}

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

func (o PlanLimits) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Devices) {
		toSerialize["devices"] = o.Devices
	}
	if !IsNil(o.Users) {
		toSerialize["users"] = o.Users
	}
	if !IsNil(o.AuditLogsDays) {
		toSerialize["audit_logs_days"] = o.AuditLogsDays
	}

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

	return toSerialize, nil
}

func (o *PlanLimits) UnmarshalJSON(data []byte) (err error) {
	varPlanLimits := _PlanLimits{}

	err = json.Unmarshal(data, &varPlanLimits)

	if err != nil {
		return err
	}

	*o = PlanLimits(varPlanLimits)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "devices")
		delete(additionalProperties, "users")
		delete(additionalProperties, "audit_logs_days")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullablePlanLimits struct {
	value *PlanLimits
	isSet bool
}

func (v NullablePlanLimits) Get() *PlanLimits {
	return v.value
}

func (v *NullablePlanLimits) Set(val *PlanLimits) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullablePlanLimits(val *PlanLimits) *NullablePlanLimits {
	return &NullablePlanLimits{value: val, isSet: true}
}

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

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


