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

// Job struct for Job
type Job struct {
	// The ID of the job
	Id string `json:"id"`
	// The type of the job
	Type JobType `json:"type"`
	// The status of the job
	Status JobStatus `json:"status"`
	// The type of resource this job operates on
	ResourceType string `json:"resourceType"`
	// The ID of the resource this job operates on (sandboxId, snapshotRef, etc.)
	ResourceId string `json:"resourceId"`
	// Job-specific JSON-encoded payload data (operational metadata)
	Payload *string `json:"payload,omitempty"`
	// OpenTelemetry trace context for distributed tracing (W3C Trace Context format)
	TraceContext map[string]interface{} `json:"traceContext,omitempty"`
	// Error message if the job failed
	ErrorMessage *string `json:"errorMessage,omitempty"`
	// The creation timestamp of the job
	CreatedAt string `json:"createdAt"`
	// The last update timestamp of the job
	UpdatedAt *string `json:"updatedAt,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _Job Job

// NewJob instantiates a new Job 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 NewJob(id string, type_ JobType, status JobStatus, resourceType string, resourceId string, createdAt string) *Job {
	this := Job{}
	this.Id = id
	this.Type = type_
	this.Status = status
	this.ResourceType = resourceType
	this.ResourceId = resourceId
	this.CreatedAt = createdAt
	return &this
}

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

// GetId returns the Id field value
func (o *Job) GetId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Id
}

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

// SetId sets field value
func (o *Job) SetId(v string) {
	o.Id = v
}

// GetType returns the Type field value
func (o *Job) GetType() JobType {
	if o == nil {
		var ret JobType
		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 *Job) GetTypeOk() (*JobType, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Type, true
}

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

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

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

// GetResourceType returns the ResourceType field value
func (o *Job) GetResourceType() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.ResourceType
}

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

// SetResourceType sets field value
func (o *Job) SetResourceType(v string) {
	o.ResourceType = v
}

// GetResourceId returns the ResourceId field value
func (o *Job) GetResourceId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.ResourceId
}

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

// SetResourceId sets field value
func (o *Job) SetResourceId(v string) {
	o.ResourceId = v
}

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

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

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

	return false
}

// SetPayload gets a reference to the given string and assigns it to the Payload field.
func (o *Job) SetPayload(v string) {
	o.Payload = &v
}

// GetTraceContext returns the TraceContext field value if set, zero value otherwise.
func (o *Job) GetTraceContext() map[string]interface{} {
	if o == nil || IsNil(o.TraceContext) {
		var ret map[string]interface{}
		return ret
	}
	return o.TraceContext
}

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

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

	return false
}

// SetTraceContext gets a reference to the given map[string]interface{} and assigns it to the TraceContext field.
func (o *Job) SetTraceContext(v map[string]interface{}) {
	o.TraceContext = v
}

// GetErrorMessage returns the ErrorMessage field value if set, zero value otherwise.
func (o *Job) 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 *Job) 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 *Job) 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 *Job) SetErrorMessage(v string) {
	o.ErrorMessage = &v
}

// GetCreatedAt returns the CreatedAt field value
func (o *Job) GetCreatedAt() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.CreatedAt
}

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

// SetCreatedAt sets field value
func (o *Job) SetCreatedAt(v string) {
	o.CreatedAt = v
}

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

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

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

	return false
}

// SetUpdatedAt gets a reference to the given string and assigns it to the UpdatedAt field.
func (o *Job) SetUpdatedAt(v string) {
	o.UpdatedAt = &v
}

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

func (o Job) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id"] = o.Id
	toSerialize["type"] = o.Type
	toSerialize["status"] = o.Status
	toSerialize["resourceType"] = o.ResourceType
	toSerialize["resourceId"] = o.ResourceId
	if !IsNil(o.Payload) {
		toSerialize["payload"] = o.Payload
	}
	if !IsNil(o.TraceContext) {
		toSerialize["traceContext"] = o.TraceContext
	}
	if !IsNil(o.ErrorMessage) {
		toSerialize["errorMessage"] = o.ErrorMessage
	}
	toSerialize["createdAt"] = o.CreatedAt
	if !IsNil(o.UpdatedAt) {
		toSerialize["updatedAt"] = o.UpdatedAt
	}

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

	return toSerialize, nil
}

func (o *Job) 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{
		"id",
		"type",
		"status",
		"resourceType",
		"resourceId",
		"createdAt",
	}

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

	varJob := _Job{}

	err = json.Unmarshal(data, &varJob)

	if err != nil {
		return err
	}

	*o = Job(varJob)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "id")
		delete(additionalProperties, "type")
		delete(additionalProperties, "status")
		delete(additionalProperties, "resourceType")
		delete(additionalProperties, "resourceId")
		delete(additionalProperties, "payload")
		delete(additionalProperties, "traceContext")
		delete(additionalProperties, "errorMessage")
		delete(additionalProperties, "createdAt")
		delete(additionalProperties, "updatedAt")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableJob struct {
	value *Job
	isSet bool
}

func (v NullableJob) Get() *Job {
	return v.value
}

func (v *NullableJob) Set(val *Job) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableJob(val *Job) *NullableJob {
	return &NullableJob{value: val, isSet: true}
}

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

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


