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

// ProvisionDevice struct for ProvisionDevice
type ProvisionDevice struct {
	// ID of the new device.
	DeviceId string `json:"device_id"`
}

type _ProvisionDevice ProvisionDevice

// NewProvisionDevice instantiates a new ProvisionDevice 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 NewProvisionDevice(deviceId string) *ProvisionDevice {
	this := ProvisionDevice{}
	this.DeviceId = deviceId
	return &this
}

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

// GetDeviceId returns the DeviceId field value
func (o *ProvisionDevice) GetDeviceId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.DeviceId
}

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

// SetDeviceId sets field value
func (o *ProvisionDevice) SetDeviceId(v string) {
	o.DeviceId = v
}

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

func (o ProvisionDevice) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["device_id"] = o.DeviceId
	return toSerialize, nil
}

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

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

	varProvisionDevice := _ProvisionDevice{}

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

	if err != nil {
		return err
	}

	*o = ProvisionDevice(varProvisionDevice)

	return err
}

type NullableProvisionDevice struct {
	value *ProvisionDevice
	isSet bool
}

func (v NullableProvisionDevice) Get() *ProvisionDevice {
	return v.value
}

func (v *NullableProvisionDevice) Set(val *ProvisionDevice) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableProvisionDevice(val *ProvisionDevice) *NullableProvisionDevice {
	return &NullableProvisionDevice{value: val, isSet: true}
}

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

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


