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

// Statistics struct for Statistics
type Statistics struct {
	// Number of successful deployments.
	Success int32 `json:"success"`
	// Number of pending deployments.
	Pending int32 `json:"pending"`
	// Number of deployments being downloaded.
	Downloading int32 `json:"downloading"`
	// Number of deployments devices are rebooting into.
	Rebooting int32 `json:"rebooting"`
	// Number of deployments devices being installed.
	Installing int32 `json:"installing"`
	// Number of failed deployments.
	Failure int32 `json:"failure"`
	// Do not have appropriate artifact for device type.
	Noartifact int32 `json:"noartifact"`
	// Number of devices unaffected by upgrade, since they are already running the specified software version.
	AlreadyInstalled int32 `json:"already-installed"`
	// Number of deployments aborted by user.
	Aborted int32 `json:"aborted"`
	// Number of deployments paused before install state.
	PauseBeforeInstalling int32 `json:"pause_before_installing"`
	// Number of deployments paused before reboot phase.
	PauseBeforeRebooting int32 `json:"pause_before_rebooting"`
	// Number of deployments paused before commit phase.
	PauseBeforeCommitting int32 `json:"pause_before_committing"`
	AdditionalProperties map[string]interface{}
}

type _Statistics Statistics

// NewStatistics instantiates a new Statistics 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 NewStatistics(success int32, pending int32, downloading int32, rebooting int32, installing int32, failure int32, noartifact int32, alreadyInstalled int32, aborted int32, pauseBeforeInstalling int32, pauseBeforeRebooting int32, pauseBeforeCommitting int32) *Statistics {
	this := Statistics{}
	this.Success = success
	this.Pending = pending
	this.Downloading = downloading
	this.Rebooting = rebooting
	this.Installing = installing
	this.Failure = failure
	this.Noartifact = noartifact
	this.AlreadyInstalled = alreadyInstalled
	this.Aborted = aborted
	this.PauseBeforeInstalling = pauseBeforeInstalling
	this.PauseBeforeRebooting = pauseBeforeRebooting
	this.PauseBeforeCommitting = pauseBeforeCommitting
	return &this
}

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

// GetSuccess returns the Success field value
func (o *Statistics) GetSuccess() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Success
}

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

// SetSuccess sets field value
func (o *Statistics) SetSuccess(v int32) {
	o.Success = v
}

// GetPending returns the Pending field value
func (o *Statistics) GetPending() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Pending
}

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

// SetPending sets field value
func (o *Statistics) SetPending(v int32) {
	o.Pending = v
}

// GetDownloading returns the Downloading field value
func (o *Statistics) GetDownloading() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Downloading
}

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

// SetDownloading sets field value
func (o *Statistics) SetDownloading(v int32) {
	o.Downloading = v
}

// GetRebooting returns the Rebooting field value
func (o *Statistics) GetRebooting() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Rebooting
}

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

// SetRebooting sets field value
func (o *Statistics) SetRebooting(v int32) {
	o.Rebooting = v
}

// GetInstalling returns the Installing field value
func (o *Statistics) GetInstalling() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Installing
}

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

// SetInstalling sets field value
func (o *Statistics) SetInstalling(v int32) {
	o.Installing = v
}

// GetFailure returns the Failure field value
func (o *Statistics) GetFailure() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Failure
}

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

// SetFailure sets field value
func (o *Statistics) SetFailure(v int32) {
	o.Failure = v
}

// GetNoartifact returns the Noartifact field value
func (o *Statistics) GetNoartifact() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Noartifact
}

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

// SetNoartifact sets field value
func (o *Statistics) SetNoartifact(v int32) {
	o.Noartifact = v
}

// GetAlreadyInstalled returns the AlreadyInstalled field value
func (o *Statistics) GetAlreadyInstalled() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.AlreadyInstalled
}

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

// SetAlreadyInstalled sets field value
func (o *Statistics) SetAlreadyInstalled(v int32) {
	o.AlreadyInstalled = v
}

// GetAborted returns the Aborted field value
func (o *Statistics) GetAborted() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Aborted
}

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

// SetAborted sets field value
func (o *Statistics) SetAborted(v int32) {
	o.Aborted = v
}

// GetPauseBeforeInstalling returns the PauseBeforeInstalling field value
func (o *Statistics) GetPauseBeforeInstalling() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.PauseBeforeInstalling
}

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

// SetPauseBeforeInstalling sets field value
func (o *Statistics) SetPauseBeforeInstalling(v int32) {
	o.PauseBeforeInstalling = v
}

// GetPauseBeforeRebooting returns the PauseBeforeRebooting field value
func (o *Statistics) GetPauseBeforeRebooting() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.PauseBeforeRebooting
}

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

// SetPauseBeforeRebooting sets field value
func (o *Statistics) SetPauseBeforeRebooting(v int32) {
	o.PauseBeforeRebooting = v
}

// GetPauseBeforeCommitting returns the PauseBeforeCommitting field value
func (o *Statistics) GetPauseBeforeCommitting() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.PauseBeforeCommitting
}

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

// SetPauseBeforeCommitting sets field value
func (o *Statistics) SetPauseBeforeCommitting(v int32) {
	o.PauseBeforeCommitting = v
}

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

func (o Statistics) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["success"] = o.Success
	toSerialize["pending"] = o.Pending
	toSerialize["downloading"] = o.Downloading
	toSerialize["rebooting"] = o.Rebooting
	toSerialize["installing"] = o.Installing
	toSerialize["failure"] = o.Failure
	toSerialize["noartifact"] = o.Noartifact
	toSerialize["already-installed"] = o.AlreadyInstalled
	toSerialize["aborted"] = o.Aborted
	toSerialize["pause_before_installing"] = o.PauseBeforeInstalling
	toSerialize["pause_before_rebooting"] = o.PauseBeforeRebooting
	toSerialize["pause_before_committing"] = o.PauseBeforeCommitting

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

	return toSerialize, nil
}

func (o *Statistics) 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{
		"success",
		"pending",
		"downloading",
		"rebooting",
		"installing",
		"failure",
		"noartifact",
		"already-installed",
		"aborted",
		"pause_before_installing",
		"pause_before_rebooting",
		"pause_before_committing",
	}

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

	varStatistics := _Statistics{}

	err = json.Unmarshal(data, &varStatistics)

	if err != nil {
		return err
	}

	*o = Statistics(varStatistics)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "success")
		delete(additionalProperties, "pending")
		delete(additionalProperties, "downloading")
		delete(additionalProperties, "rebooting")
		delete(additionalProperties, "installing")
		delete(additionalProperties, "failure")
		delete(additionalProperties, "noartifact")
		delete(additionalProperties, "already-installed")
		delete(additionalProperties, "aborted")
		delete(additionalProperties, "pause_before_installing")
		delete(additionalProperties, "pause_before_rebooting")
		delete(additionalProperties, "pause_before_committing")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableStatistics struct {
	value *Statistics
	isSet bool
}

func (v NullableStatistics) Get() *Statistics {
	return v.value
}

func (v *NullableStatistics) Set(val *Statistics) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableStatistics(val *Statistics) *NullableStatistics {
	return &NullableStatistics{value: val, isSet: true}
}

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

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


