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

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

// TaskResult struct for TaskResult
type TaskResult struct {
	Success *bool `json:"success,omitempty"`
	Cli *TaskResultCLI `json:"cli,omitempty"`
	Request *TaskResultHTTPRequest `json:"request,omitempty"`
	Response *TaskResultHTTPResponse `json:"response,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _TaskResult TaskResult

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

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

// GetSuccess returns the Success field value if set, zero value otherwise.
func (o *TaskResult) GetSuccess() bool {
	if o == nil || IsNil(o.Success) {
		var ret bool
		return ret
	}
	return *o.Success
}

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

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

	return false
}

// SetSuccess gets a reference to the given bool and assigns it to the Success field.
func (o *TaskResult) SetSuccess(v bool) {
	o.Success = &v
}

// GetCli returns the Cli field value if set, zero value otherwise.
func (o *TaskResult) GetCli() TaskResultCLI {
	if o == nil || IsNil(o.Cli) {
		var ret TaskResultCLI
		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 *TaskResult) GetCliOk() (*TaskResultCLI, 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 *TaskResult) HasCli() bool {
	if o != nil && !IsNil(o.Cli) {
		return true
	}

	return false
}

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

// GetRequest returns the Request field value if set, zero value otherwise.
func (o *TaskResult) GetRequest() TaskResultHTTPRequest {
	if o == nil || IsNil(o.Request) {
		var ret TaskResultHTTPRequest
		return ret
	}
	return *o.Request
}

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

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

	return false
}

// SetRequest gets a reference to the given TaskResultHTTPRequest and assigns it to the Request field.
func (o *TaskResult) SetRequest(v TaskResultHTTPRequest) {
	o.Request = &v
}

// GetResponse returns the Response field value if set, zero value otherwise.
func (o *TaskResult) GetResponse() TaskResultHTTPResponse {
	if o == nil || IsNil(o.Response) {
		var ret TaskResultHTTPResponse
		return ret
	}
	return *o.Response
}

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

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

	return false
}

// SetResponse gets a reference to the given TaskResultHTTPResponse and assigns it to the Response field.
func (o *TaskResult) SetResponse(v TaskResultHTTPResponse) {
	o.Response = &v
}

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

func (o TaskResult) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Success) {
		toSerialize["success"] = o.Success
	}
	if !IsNil(o.Cli) {
		toSerialize["cli"] = o.Cli
	}
	if !IsNil(o.Request) {
		toSerialize["request"] = o.Request
	}
	if !IsNil(o.Response) {
		toSerialize["response"] = o.Response
	}

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

	return toSerialize, nil
}

func (o *TaskResult) UnmarshalJSON(data []byte) (err error) {
	varTaskResult := _TaskResult{}

	err = json.Unmarshal(data, &varTaskResult)

	if err != nil {
		return err
	}

	*o = TaskResult(varTaskResult)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "success")
		delete(additionalProperties, "cli")
		delete(additionalProperties, "request")
		delete(additionalProperties, "response")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableTaskResult struct {
	value *TaskResult
	isSet bool
}

func (v NullableTaskResult) Get() *TaskResult {
	return v.value
}

func (v *NullableTaskResult) Set(val *TaskResult) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTaskResult(val *TaskResult) *NullableTaskResult {
	return &NullableTaskResult{value: val, isSet: true}
}

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

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


