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

// Workflow struct for Workflow
type Workflow struct {
	Name string `json:"name"`
	Description *string `json:"description,omitempty"`
	Version int32 `json:"version"`
	Schemaversion *int32 `json:"schemaversion,omitempty"`
	Tasks []Task `json:"tasks"`
	InputParameters []string `json:"inputParameters,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _Workflow Workflow

// NewWorkflow instantiates a new Workflow 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 NewWorkflow(name string, version int32, tasks []Task) *Workflow {
	this := Workflow{}
	this.Name = name
	this.Version = version
	this.Tasks = tasks
	return &this
}

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

// GetName returns the Name field value
func (o *Workflow) 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 *Workflow) GetNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Name, true
}

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

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

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

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

	return false
}

// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *Workflow) SetDescription(v string) {
	o.Description = &v
}

// GetVersion returns the Version field value
func (o *Workflow) GetVersion() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Version
}

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

// SetVersion sets field value
func (o *Workflow) SetVersion(v int32) {
	o.Version = v
}

// GetSchemaversion returns the Schemaversion field value if set, zero value otherwise.
func (o *Workflow) GetSchemaversion() int32 {
	if o == nil || IsNil(o.Schemaversion) {
		var ret int32
		return ret
	}
	return *o.Schemaversion
}

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

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

	return false
}

// SetSchemaversion gets a reference to the given int32 and assigns it to the Schemaversion field.
func (o *Workflow) SetSchemaversion(v int32) {
	o.Schemaversion = &v
}

// GetTasks returns the Tasks field value
func (o *Workflow) GetTasks() []Task {
	if o == nil {
		var ret []Task
		return ret
	}

	return o.Tasks
}

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

// SetTasks sets field value
func (o *Workflow) SetTasks(v []Task) {
	o.Tasks = v
}

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

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

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

	return false
}

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

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

func (o Workflow) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["name"] = o.Name
	if !IsNil(o.Description) {
		toSerialize["description"] = o.Description
	}
	toSerialize["version"] = o.Version
	if !IsNil(o.Schemaversion) {
		toSerialize["schemaversion"] = o.Schemaversion
	}
	toSerialize["tasks"] = o.Tasks
	if !IsNil(o.InputParameters) {
		toSerialize["inputParameters"] = o.InputParameters
	}

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

	return toSerialize, nil
}

func (o *Workflow) 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{
		"name",
		"version",
		"tasks",
	}

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

	varWorkflow := _Workflow{}

	err = json.Unmarshal(data, &varWorkflow)

	if err != nil {
		return err
	}

	*o = Workflow(varWorkflow)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "name")
		delete(additionalProperties, "description")
		delete(additionalProperties, "version")
		delete(additionalProperties, "schemaversion")
		delete(additionalProperties, "tasks")
		delete(additionalProperties, "inputParameters")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableWorkflow struct {
	value *Workflow
	isSet bool
}

func (v NullableWorkflow) Get() *Workflow {
	return v.value
}

func (v *NullableWorkflow) Set(val *Workflow) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableWorkflow(val *Workflow) *NullableWorkflow {
	return &NullableWorkflow{value: val, isSet: true}
}

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

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


