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

// DeploymentInstructionsArtifact struct for DeploymentInstructionsArtifact
type DeploymentInstructionsArtifact struct {
	Id *string `json:"id,omitempty"`
	Source DeploymentInstructionsArtifactSource `json:"source"`
	// Compatible device types
	DeviceTypesCompatible []string `json:"device_types_compatible"`
	ArtifactName string `json:"artifact_name"`
	AdditionalProperties map[string]interface{}
}

type _DeploymentInstructionsArtifact DeploymentInstructionsArtifact

// NewDeploymentInstructionsArtifact instantiates a new DeploymentInstructionsArtifact 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 NewDeploymentInstructionsArtifact(source DeploymentInstructionsArtifactSource, deviceTypesCompatible []string, artifactName string) *DeploymentInstructionsArtifact {
	this := DeploymentInstructionsArtifact{}
	this.Source = source
	this.DeviceTypesCompatible = deviceTypesCompatible
	this.ArtifactName = artifactName
	return &this
}

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

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

// GetSource returns the Source field value
func (o *DeploymentInstructionsArtifact) GetSource() DeploymentInstructionsArtifactSource {
	if o == nil {
		var ret DeploymentInstructionsArtifactSource
		return ret
	}

	return o.Source
}

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

// SetSource sets field value
func (o *DeploymentInstructionsArtifact) SetSource(v DeploymentInstructionsArtifactSource) {
	o.Source = v
}

// GetDeviceTypesCompatible returns the DeviceTypesCompatible field value
func (o *DeploymentInstructionsArtifact) GetDeviceTypesCompatible() []string {
	if o == nil {
		var ret []string
		return ret
	}

	return o.DeviceTypesCompatible
}

// GetDeviceTypesCompatibleOk returns a tuple with the DeviceTypesCompatible field value
// and a boolean to check if the value has been set.
func (o *DeploymentInstructionsArtifact) GetDeviceTypesCompatibleOk() ([]string, bool) {
	if o == nil {
		return nil, false
	}
	return o.DeviceTypesCompatible, true
}

// SetDeviceTypesCompatible sets field value
func (o *DeploymentInstructionsArtifact) SetDeviceTypesCompatible(v []string) {
	o.DeviceTypesCompatible = v
}

// GetArtifactName returns the ArtifactName field value
func (o *DeploymentInstructionsArtifact) GetArtifactName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.ArtifactName
}

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

// SetArtifactName sets field value
func (o *DeploymentInstructionsArtifact) SetArtifactName(v string) {
	o.ArtifactName = v
}

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

func (o DeploymentInstructionsArtifact) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Id) {
		toSerialize["id"] = o.Id
	}
	toSerialize["source"] = o.Source
	toSerialize["device_types_compatible"] = o.DeviceTypesCompatible
	toSerialize["artifact_name"] = o.ArtifactName

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

	return toSerialize, nil
}

func (o *DeploymentInstructionsArtifact) 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{
		"source",
		"device_types_compatible",
		"artifact_name",
	}

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

	varDeploymentInstructionsArtifact := _DeploymentInstructionsArtifact{}

	err = json.Unmarshal(data, &varDeploymentInstructionsArtifact)

	if err != nil {
		return err
	}

	*o = DeploymentInstructionsArtifact(varDeploymentInstructionsArtifact)

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

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

	return err
}

type NullableDeploymentInstructionsArtifact struct {
	value *DeploymentInstructionsArtifact
	isSet bool
}

func (v NullableDeploymentInstructionsArtifact) Get() *DeploymentInstructionsArtifact {
	return v.value
}

func (v *NullableDeploymentInstructionsArtifact) Set(val *DeploymentInstructionsArtifact) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeploymentInstructionsArtifact(val *DeploymentInstructionsArtifact) *NullableDeploymentInstructionsArtifact {
	return &NullableDeploymentInstructionsArtifact{value: val, isSet: true}
}

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

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


