/*
DM OpenAPI DOC

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

API version: 6.0.0
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package dm

import (
	"bytes"
	"encoding/json"
	"fmt"
)

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

// OperateTaskResponse struct for OperateTaskResponse
type OperateTaskResponse struct {
	// pre-check result
	CheckResult string `json:"check_result"`
	Task        Task   `json:"task"`
}

type _OperateTaskResponse OperateTaskResponse

// NewOperateTaskResponse instantiates a new OperateTaskResponse 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 NewOperateTaskResponse(checkResult string, task Task) *OperateTaskResponse {
	this := OperateTaskResponse{}
	this.CheckResult = checkResult
	this.Task = task
	return &this
}

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

// GetCheckResult returns the CheckResult field value
func (o *OperateTaskResponse) GetCheckResult() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.CheckResult
}

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

// SetCheckResult sets field value
func (o *OperateTaskResponse) SetCheckResult(v string) {
	o.CheckResult = v
}

// GetTask returns the Task field value
func (o *OperateTaskResponse) GetTask() Task {
	if o == nil {
		var ret Task
		return ret
	}

	return o.Task
}

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

// SetTask sets field value
func (o *OperateTaskResponse) SetTask(v Task) {
	o.Task = v
}

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

func (o OperateTaskResponse) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["check_result"] = o.CheckResult
	toSerialize["task"] = o.Task
	return toSerialize, nil
}

func (o *OperateTaskResponse) 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{
		"check_result",
		"task",
	}

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

	varOperateTaskResponse := _OperateTaskResponse{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varOperateTaskResponse)

	if err != nil {
		return err
	}

	*o = OperateTaskResponse(varOperateTaskResponse)

	return err
}

type NullableOperateTaskResponse struct {
	value *OperateTaskResponse
	isSet bool
}

func (v NullableOperateTaskResponse) Get() *OperateTaskResponse {
	return v.value
}

func (v *NullableOperateTaskResponse) Set(val *OperateTaskResponse) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableOperateTaskResponse(val *OperateTaskResponse) *NullableOperateTaskResponse {
	return &NullableOperateTaskResponse{value: val, isSet: true}
}

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

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