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

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

// DeploymentV1 struct for DeploymentV1
type DeploymentV1 struct {
	// Deployment identifier
	Id string `json:"id"`
	// Name of the deployment
	Name string `json:"name"`
	// Name of the artifact to deploy
	ArtifactName string `json:"artifact_name"`
	// Deployment's creation date and time
	Created time.Time `json:"created"`
	// Deployment's completion date and time
	Finished *time.Time `json:"finished,omitempty"`
	// Status of the deployment
	Status string `json:"status"`
	// Number of devices the deployment acted upon
	DeviceCount int32 `json:"device_count"`
	// An array of artifact's identifiers.
	Artifacts []string `json:"artifacts,omitempty"`
	// An array of groups the devices targeted by the deployment belong to. Available only if the user created the deployment for a group or a single device (if the device was in a static group). 
	Groups []string `json:"groups,omitempty"`
	Type *string `json:"type,omitempty"`
	// A string containing a configuration object provided with the deployment constructor. 
	Configuration *string `json:"configuration,omitempty"`
	Statistics *DeploymentStatistics `json:"statistics,omitempty"`
	Filter *FilterV1 `json:"filter,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _DeploymentV1 DeploymentV1

// NewDeploymentV1 instantiates a new DeploymentV1 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 NewDeploymentV1(id string, name string, artifactName string, created time.Time, status string, deviceCount int32) *DeploymentV1 {
	this := DeploymentV1{}
	this.Id = id
	this.Name = name
	this.ArtifactName = artifactName
	this.Created = created
	this.Status = status
	this.DeviceCount = deviceCount
	return &this
}

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

// GetId returns the Id field value
func (o *DeploymentV1) GetId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Id
}

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

// SetId sets field value
func (o *DeploymentV1) SetId(v string) {
	o.Id = v
}

// GetName returns the Name field value
func (o *DeploymentV1) GetName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Name
}

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

// SetName sets field value
func (o *DeploymentV1) SetName(v string) {
	o.Name = v
}

// GetArtifactName returns the ArtifactName field value
func (o *DeploymentV1) 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 *DeploymentV1) GetArtifactNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.ArtifactName, true
}

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

// GetCreated returns the Created field value
func (o *DeploymentV1) GetCreated() time.Time {
	if o == nil {
		var ret time.Time
		return ret
	}

	return o.Created
}

// GetCreatedOk returns a tuple with the Created field value
// and a boolean to check if the value has been set.
func (o *DeploymentV1) GetCreatedOk() (*time.Time, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Created, true
}

// SetCreated sets field value
func (o *DeploymentV1) SetCreated(v time.Time) {
	o.Created = v
}

// GetFinished returns the Finished field value if set, zero value otherwise.
func (o *DeploymentV1) GetFinished() time.Time {
	if o == nil || IsNil(o.Finished) {
		var ret time.Time
		return ret
	}
	return *o.Finished
}

// GetFinishedOk returns a tuple with the Finished field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DeploymentV1) GetFinishedOk() (*time.Time, bool) {
	if o == nil || IsNil(o.Finished) {
		return nil, false
	}
	return o.Finished, true
}

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

	return false
}

// SetFinished gets a reference to the given time.Time and assigns it to the Finished field.
func (o *DeploymentV1) SetFinished(v time.Time) {
	o.Finished = &v
}

// GetStatus returns the Status field value
func (o *DeploymentV1) 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 *DeploymentV1) GetStatusOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Status, true
}

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

// GetDeviceCount returns the DeviceCount field value
func (o *DeploymentV1) GetDeviceCount() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.DeviceCount
}

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

// SetDeviceCount sets field value
func (o *DeploymentV1) SetDeviceCount(v int32) {
	o.DeviceCount = v
}

// GetArtifacts returns the Artifacts field value if set, zero value otherwise.
func (o *DeploymentV1) GetArtifacts() []string {
	if o == nil || IsNil(o.Artifacts) {
		var ret []string
		return ret
	}
	return o.Artifacts
}

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

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

	return false
}

// SetArtifacts gets a reference to the given []string and assigns it to the Artifacts field.
func (o *DeploymentV1) SetArtifacts(v []string) {
	o.Artifacts = v
}

// GetGroups returns the Groups field value if set, zero value otherwise.
func (o *DeploymentV1) GetGroups() []string {
	if o == nil || IsNil(o.Groups) {
		var ret []string
		return ret
	}
	return o.Groups
}

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

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

	return false
}

// SetGroups gets a reference to the given []string and assigns it to the Groups field.
func (o *DeploymentV1) SetGroups(v []string) {
	o.Groups = v
}

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

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

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

	return false
}

// SetType gets a reference to the given string and assigns it to the Type field.
func (o *DeploymentV1) SetType(v string) {
	o.Type = &v
}

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

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

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

	return false
}

// SetConfiguration gets a reference to the given string and assigns it to the Configuration field.
func (o *DeploymentV1) SetConfiguration(v string) {
	o.Configuration = &v
}

// GetStatistics returns the Statistics field value if set, zero value otherwise.
func (o *DeploymentV1) GetStatistics() DeploymentStatistics {
	if o == nil || IsNil(o.Statistics) {
		var ret DeploymentStatistics
		return ret
	}
	return *o.Statistics
}

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

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

	return false
}

// SetStatistics gets a reference to the given DeploymentStatistics and assigns it to the Statistics field.
func (o *DeploymentV1) SetStatistics(v DeploymentStatistics) {
	o.Statistics = &v
}

// GetFilter returns the Filter field value if set, zero value otherwise.
func (o *DeploymentV1) GetFilter() FilterV1 {
	if o == nil || IsNil(o.Filter) {
		var ret FilterV1
		return ret
	}
	return *o.Filter
}

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

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

	return false
}

// SetFilter gets a reference to the given FilterV1 and assigns it to the Filter field.
func (o *DeploymentV1) SetFilter(v FilterV1) {
	o.Filter = &v
}

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

func (o DeploymentV1) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id"] = o.Id
	toSerialize["name"] = o.Name
	toSerialize["artifact_name"] = o.ArtifactName
	toSerialize["created"] = o.Created
	if !IsNil(o.Finished) {
		toSerialize["finished"] = o.Finished
	}
	toSerialize["status"] = o.Status
	toSerialize["device_count"] = o.DeviceCount
	if !IsNil(o.Artifacts) {
		toSerialize["artifacts"] = o.Artifacts
	}
	if !IsNil(o.Groups) {
		toSerialize["groups"] = o.Groups
	}
	if !IsNil(o.Type) {
		toSerialize["type"] = o.Type
	}
	if !IsNil(o.Configuration) {
		toSerialize["configuration"] = o.Configuration
	}
	if !IsNil(o.Statistics) {
		toSerialize["statistics"] = o.Statistics
	}
	if !IsNil(o.Filter) {
		toSerialize["filter"] = o.Filter
	}

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

	return toSerialize, nil
}

func (o *DeploymentV1) 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{
		"id",
		"name",
		"artifact_name",
		"created",
		"status",
		"device_count",
	}

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

	varDeploymentV1 := _DeploymentV1{}

	err = json.Unmarshal(data, &varDeploymentV1)

	if err != nil {
		return err
	}

	*o = DeploymentV1(varDeploymentV1)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "id")
		delete(additionalProperties, "name")
		delete(additionalProperties, "artifact_name")
		delete(additionalProperties, "created")
		delete(additionalProperties, "finished")
		delete(additionalProperties, "status")
		delete(additionalProperties, "device_count")
		delete(additionalProperties, "artifacts")
		delete(additionalProperties, "groups")
		delete(additionalProperties, "type")
		delete(additionalProperties, "configuration")
		delete(additionalProperties, "statistics")
		delete(additionalProperties, "filter")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableDeploymentV1 struct {
	value *DeploymentV1
	isSet bool
}

func (v NullableDeploymentV1) Get() *DeploymentV1 {
	return v.value
}

func (v *NullableDeploymentV1) Set(val *DeploymentV1) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeploymentV1(val *DeploymentV1) *NullableDeploymentV1 {
	return &NullableDeploymentV1{value: val, isSet: true}
}

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

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


