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

// DeviceDeploymentV1 struct for DeviceDeploymentV1
type DeviceDeploymentV1 struct {
	Id *string `json:"id,omitempty"`
	Deployment DeploymentV1 `json:"deployment"`
	Device DeviceWithImage `json:"device"`
	AdditionalProperties map[string]interface{}
}

type _DeviceDeploymentV1 DeviceDeploymentV1

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

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

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

// GetDeployment returns the Deployment field value
func (o *DeviceDeploymentV1) GetDeployment() DeploymentV1 {
	if o == nil {
		var ret DeploymentV1
		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 *DeviceDeploymentV1) GetDeploymentOk() (*DeploymentV1, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Deployment, true
}

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

// GetDevice returns the Device field value
func (o *DeviceDeploymentV1) 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 *DeviceDeploymentV1) GetDeviceOk() (*DeviceWithImage, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Device, true
}

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

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

func (o DeviceDeploymentV1) 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

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

	return toSerialize, nil
}

func (o *DeviceDeploymentV1) 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)
		}
	}

	varDeviceDeploymentV1 := _DeviceDeploymentV1{}

	err = json.Unmarshal(data, &varDeviceDeploymentV1)

	if err != nil {
		return err
	}

	*o = DeviceDeploymentV1(varDeviceDeploymentV1)

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

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

	return err
}

type NullableDeviceDeploymentV1 struct {
	value *DeviceDeploymentV1
	isSet bool
}

func (v NullableDeviceDeploymentV1) Get() *DeviceDeploymentV1 {
	return v.value
}

func (v *NullableDeviceDeploymentV1) Set(val *DeviceDeploymentV1) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeviceDeploymentV1(val *DeviceDeploymentV1) *NullableDeviceDeploymentV1 {
	return &NullableDeviceDeploymentV1{value: val, isSet: true}
}

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

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


