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

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

// DeploymentPhase struct for DeploymentPhase
type DeploymentPhase struct {
	// Phase identifier.
	Id *string `json:"id,omitempty"`
	// Percentage of devices to update in the phase. 
	BatchSize *int32 `json:"batch_size,omitempty"`
	// Start date of a phase. May be undefined for the first phase of a deployment. 
	StartTs *time.Time `json:"start_ts,omitempty"`
	// Number of devices which already requested an update within this phase. 
	DeviceCount *int32 `json:"device_count,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _DeploymentPhase DeploymentPhase

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

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

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

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

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

	return false
}

// SetId gets a reference to the given string and assigns it to the Id field.
func (o *DeploymentPhase) SetId(v string) {
	o.Id = &v
}

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

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

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

	return false
}

// SetBatchSize gets a reference to the given int32 and assigns it to the BatchSize field.
func (o *DeploymentPhase) SetBatchSize(v int32) {
	o.BatchSize = &v
}

// GetStartTs returns the StartTs field value if set, zero value otherwise.
func (o *DeploymentPhase) GetStartTs() time.Time {
	if o == nil || IsNil(o.StartTs) {
		var ret time.Time
		return ret
	}
	return *o.StartTs
}

// GetStartTsOk returns a tuple with the StartTs field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DeploymentPhase) GetStartTsOk() (*time.Time, bool) {
	if o == nil || IsNil(o.StartTs) {
		return nil, false
	}
	return o.StartTs, true
}

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

	return false
}

// SetStartTs gets a reference to the given time.Time and assigns it to the StartTs field.
func (o *DeploymentPhase) SetStartTs(v time.Time) {
	o.StartTs = &v
}

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

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

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

	return false
}

// SetDeviceCount gets a reference to the given int32 and assigns it to the DeviceCount field.
func (o *DeploymentPhase) SetDeviceCount(v int32) {
	o.DeviceCount = &v
}

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

func (o DeploymentPhase) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Id) {
		toSerialize["id"] = o.Id
	}
	if !IsNil(o.BatchSize) {
		toSerialize["batch_size"] = o.BatchSize
	}
	if !IsNil(o.StartTs) {
		toSerialize["start_ts"] = o.StartTs
	}
	if !IsNil(o.DeviceCount) {
		toSerialize["device_count"] = o.DeviceCount
	}

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

	return toSerialize, nil
}

func (o *DeploymentPhase) UnmarshalJSON(data []byte) (err error) {
	varDeploymentPhase := _DeploymentPhase{}

	err = json.Unmarshal(data, &varDeploymentPhase)

	if err != nil {
		return err
	}

	*o = DeploymentPhase(varDeploymentPhase)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "id")
		delete(additionalProperties, "batch_size")
		delete(additionalProperties, "start_ts")
		delete(additionalProperties, "device_count")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableDeploymentPhase struct {
	value *DeploymentPhase
	isSet bool
}

func (v NullableDeploymentPhase) Get() *DeploymentPhase {
	return v.value
}

func (v *NullableDeploymentPhase) Set(val *DeploymentPhase) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeploymentPhase(val *DeploymentPhase) *NullableDeploymentPhase {
	return &NullableDeploymentPhase{value: val, isSet: true}
}

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

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


