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

// DeploymentStatus struct for DeploymentStatus
type DeploymentStatus struct {
	Status string `json:"status"`
	// Additional state information
	Substate *string `json:"substate,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _DeploymentStatus DeploymentStatus

// NewDeploymentStatus instantiates a new DeploymentStatus 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 NewDeploymentStatus(status string) *DeploymentStatus {
	this := DeploymentStatus{}
	this.Status = status
	return &this
}

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

// GetStatus returns the Status field value
func (o *DeploymentStatus) GetStatus() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Status
}

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

// SetStatus sets field value
func (o *DeploymentStatus) SetStatus(v string) {
	o.Status = v
}

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

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

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

	return false
}

// SetSubstate gets a reference to the given string and assigns it to the Substate field.
func (o *DeploymentStatus) SetSubstate(v string) {
	o.Substate = &v
}

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

func (o DeploymentStatus) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["status"] = o.Status
	if !IsNil(o.Substate) {
		toSerialize["substate"] = o.Substate
	}

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

	return toSerialize, nil
}

func (o *DeploymentStatus) 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{
		"status",
	}

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

	varDeploymentStatus := _DeploymentStatus{}

	err = json.Unmarshal(data, &varDeploymentStatus)

	if err != nil {
		return err
	}

	*o = DeploymentStatus(varDeploymentStatus)

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

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

	return err
}

type NullableDeploymentStatus struct {
	value *DeploymentStatus
	isSet bool
}

func (v NullableDeploymentStatus) Get() *DeploymentStatus {
	return v.value
}

func (v *NullableDeploymentStatus) Set(val *DeploymentStatus) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeploymentStatus(val *DeploymentStatus) *NullableDeploymentStatus {
	return &NullableDeploymentStatus{value: val, isSet: true}
}

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

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


