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

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

// DeviceDeployment struct for DeviceDeployment
type DeviceDeployment struct {
	Id *string `json:"id,omitempty"`
	Deployment DeploymentV1Internal `json:"deployment"`
	Device DeviceWithImage `json:"device"`
}

type _DeviceDeployment DeviceDeployment

// NewDeviceDeployment instantiates a new DeviceDeployment 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 NewDeviceDeployment(deployment DeploymentV1Internal, device DeviceWithImage) *DeviceDeployment {
	this := DeviceDeployment{}
	this.Deployment = deployment
	this.Device = device
	return &this
}

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

// GetId returns the Id field value if set, zero value otherwise.
func (o *DeviceDeployment) 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 *DeviceDeployment) 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 *DeviceDeployment) 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 *DeviceDeployment) SetId(v string) {
	o.Id = &v
}

// GetDeployment returns the Deployment field value
func (o *DeviceDeployment) GetDeployment() DeploymentV1Internal {
	if o == nil {
		var ret DeploymentV1Internal
		return ret
	}

	return o.Deployment
}

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

// SetDeployment sets field value
func (o *DeviceDeployment) SetDeployment(v DeploymentV1Internal) {
	o.Deployment = v
}

// GetDevice returns the Device field value
func (o *DeviceDeployment) GetDevice() DeviceWithImage {
	if o == nil {
		var ret DeviceWithImage
		return ret
	}

	return o.Device
}

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

// SetDevice sets field value
func (o *DeviceDeployment) SetDevice(v DeviceWithImage) {
	o.Device = v
}

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

func (o DeviceDeployment) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Id) {
		toSerialize["id"] = o.Id
	}
	toSerialize["deployment"] = o.Deployment
	toSerialize["device"] = o.Device
	return toSerialize, nil
}

func (o *DeviceDeployment) 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{
		"deployment",
		"device",
	}

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

	varDeviceDeployment := _DeviceDeployment{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varDeviceDeployment)

	if err != nil {
		return err
	}

	*o = DeviceDeployment(varDeviceDeployment)

	return err
}

type NullableDeviceDeployment struct {
	value *DeviceDeployment
	isSet bool
}

func (v NullableDeviceDeployment) Get() *DeviceDeployment {
	return v.value
}

func (v *NullableDeviceDeployment) Set(val *DeviceDeployment) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeviceDeployment(val *DeviceDeployment) *NullableDeviceDeployment {
	return &NullableDeviceDeployment{value: val, isSet: true}
}

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

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


