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

// Task Task definition
type Task struct {
	Name string `json:"name"`
	Type string `json:"type"`
	Retries *int32 `json:"retries,omitempty"`
	RetryDelaySeconds *int32 `json:"retryDelaySeconds,omitempty"`
	Requires []string `json:"requires,omitempty"`
	Cli *CLIParams `json:"cli,omitempty"`
	Http *HTTPParams `json:"http,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _Task Task

// NewTask instantiates a new Task 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 NewTask(name string, type_ string) *Task {
	this := Task{}
	this.Name = name
	this.Type = type_
	return &this
}

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

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

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

// GetType returns the Type field value
func (o *Task) GetType() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Type
}

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

// SetType sets field value
func (o *Task) SetType(v string) {
	o.Type = v
}

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

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

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

	return false
}

// SetRetries gets a reference to the given int32 and assigns it to the Retries field.
func (o *Task) SetRetries(v int32) {
	o.Retries = &v
}

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

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

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

	return false
}

// SetRetryDelaySeconds gets a reference to the given int32 and assigns it to the RetryDelaySeconds field.
func (o *Task) SetRetryDelaySeconds(v int32) {
	o.RetryDelaySeconds = &v
}

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

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

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

	return false
}

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

// GetCli returns the Cli field value if set, zero value otherwise.
func (o *Task) GetCli() CLIParams {
	if o == nil || IsNil(o.Cli) {
		var ret CLIParams
		return ret
	}
	return *o.Cli
}

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

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

	return false
}

// SetCli gets a reference to the given CLIParams and assigns it to the Cli field.
func (o *Task) SetCli(v CLIParams) {
	o.Cli = &v
}

// GetHttp returns the Http field value if set, zero value otherwise.
func (o *Task) GetHttp() HTTPParams {
	if o == nil || IsNil(o.Http) {
		var ret HTTPParams
		return ret
	}
	return *o.Http
}

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

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

	return false
}

// SetHttp gets a reference to the given HTTPParams and assigns it to the Http field.
func (o *Task) SetHttp(v HTTPParams) {
	o.Http = &v
}

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

func (o Task) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["name"] = o.Name
	toSerialize["type"] = o.Type
	if !IsNil(o.Retries) {
		toSerialize["retries"] = o.Retries
	}
	if !IsNil(o.RetryDelaySeconds) {
		toSerialize["retryDelaySeconds"] = o.RetryDelaySeconds
	}
	if !IsNil(o.Requires) {
		toSerialize["requires"] = o.Requires
	}
	if !IsNil(o.Cli) {
		toSerialize["cli"] = o.Cli
	}
	if !IsNil(o.Http) {
		toSerialize["http"] = o.Http
	}

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

	return toSerialize, nil
}

func (o *Task) 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",
		"type",
	}

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

	varTask := _Task{}

	err = json.Unmarshal(data, &varTask)

	if err != nil {
		return err
	}

	*o = Task(varTask)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "name")
		delete(additionalProperties, "type")
		delete(additionalProperties, "retries")
		delete(additionalProperties, "retryDelaySeconds")
		delete(additionalProperties, "requires")
		delete(additionalProperties, "cli")
		delete(additionalProperties, "http")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableTask struct {
	value *Task
	isSet bool
}

func (v NullableTask) Get() *Task {
	return v.value
}

func (v *NullableTask) Set(val *Task) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTask(val *Task) *NullableTask {
	return &NullableTask{value: val, isSet: true}
}

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

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


