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

// DeviceCountByTier Number of devices per tier
type DeviceCountByTier struct {
	Standard int32 `json:"standard"`
	Micro int32 `json:"micro"`
	System int32 `json:"system"`
	AdditionalProperties map[string]interface{}
}

type _DeviceCountByTier DeviceCountByTier

// NewDeviceCountByTier instantiates a new DeviceCountByTier 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 NewDeviceCountByTier(standard int32, micro int32, system int32) *DeviceCountByTier {
	this := DeviceCountByTier{}
	this.Standard = standard
	this.Micro = micro
	this.System = system
	return &this
}

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

// GetStandard returns the Standard field value
func (o *DeviceCountByTier) GetStandard() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Standard
}

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

// SetStandard sets field value
func (o *DeviceCountByTier) SetStandard(v int32) {
	o.Standard = v
}

// GetMicro returns the Micro field value
func (o *DeviceCountByTier) GetMicro() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Micro
}

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

// SetMicro sets field value
func (o *DeviceCountByTier) SetMicro(v int32) {
	o.Micro = v
}

// GetSystem returns the System field value
func (o *DeviceCountByTier) GetSystem() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.System
}

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

// SetSystem sets field value
func (o *DeviceCountByTier) SetSystem(v int32) {
	o.System = v
}

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

func (o DeviceCountByTier) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["standard"] = o.Standard
	toSerialize["micro"] = o.Micro
	toSerialize["system"] = o.System

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

	return toSerialize, nil
}

func (o *DeviceCountByTier) 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{
		"standard",
		"micro",
		"system",
	}

	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)
		}
	}

	varDeviceCountByTier := _DeviceCountByTier{}

	err = json.Unmarshal(data, &varDeviceCountByTier)

	if err != nil {
		return err
	}

	*o = DeviceCountByTier(varDeviceCountByTier)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "standard")
		delete(additionalProperties, "micro")
		delete(additionalProperties, "system")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableDeviceCountByTier struct {
	value *DeviceCountByTier
	isSet bool
}

func (v NullableDeviceCountByTier) Get() *DeviceCountByTier {
	return v.value
}

func (v *NullableDeviceCountByTier) Set(val *DeviceCountByTier) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeviceCountByTier(val *DeviceCountByTier) *NullableDeviceCountByTier {
	return &NullableDeviceCountByTier{value: val, isSet: true}
}

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

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


