/*
Daytona

Daytona AI platform API Docs

API version: 1.0
Contact: support@daytona.com
*/

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

package apiclient

import (
	"encoding/json"
	"fmt"
)

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

// UpdateJobStatus struct for UpdateJobStatus
type UpdateJobStatus struct {
	// The new status of the job
	Status JobStatus `json:"status"`
	// Error message if the job failed
	ErrorMessage *string `json:"errorMessage,omitempty"`
	// Result metadata for the job
	ResultMetadata *string `json:"resultMetadata,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _UpdateJobStatus UpdateJobStatus

// NewUpdateJobStatus instantiates a new UpdateJobStatus 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 NewUpdateJobStatus(status JobStatus) *UpdateJobStatus {
	this := UpdateJobStatus{}
	this.Status = status
	return &this
}

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

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

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

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

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

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

	return false
}

// SetErrorMessage gets a reference to the given string and assigns it to the ErrorMessage field.
func (o *UpdateJobStatus) SetErrorMessage(v string) {
	o.ErrorMessage = &v
}

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

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

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

	return false
}

// SetResultMetadata gets a reference to the given string and assigns it to the ResultMetadata field.
func (o *UpdateJobStatus) SetResultMetadata(v string) {
	o.ResultMetadata = &v
}

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

func (o UpdateJobStatus) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["status"] = o.Status
	if !IsNil(o.ErrorMessage) {
		toSerialize["errorMessage"] = o.ErrorMessage
	}
	if !IsNil(o.ResultMetadata) {
		toSerialize["resultMetadata"] = o.ResultMetadata
	}

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

	return toSerialize, nil
}

func (o *UpdateJobStatus) 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{
		"status",
	}

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

	varUpdateJobStatus := _UpdateJobStatus{}

	err = json.Unmarshal(data, &varUpdateJobStatus)

	if err != nil {
		return err
	}

	*o = UpdateJobStatus(varUpdateJobStatus)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "status")
		delete(additionalProperties, "errorMessage")
		delete(additionalProperties, "resultMetadata")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableUpdateJobStatus struct {
	value *UpdateJobStatus
	isSet bool
}

func (v NullableUpdateJobStatus) Get() *UpdateJobStatus {
	return v.value
}

func (v *NullableUpdateJobStatus) Set(val *UpdateJobStatus) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUpdateJobStatus(val *UpdateJobStatus) *NullableUpdateJobStatus {
	return &NullableUpdateJobStatus{value: val, isSet: true}
}

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

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


