/*
Daytona Toolbox API

Daytona Toolbox API

API version: v0.0.0-dev
*/

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

package toolbox

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

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

// CodeRunRequest struct for CodeRunRequest
type CodeRunRequest struct {
	Argv []string `json:"argv,omitempty"`
	Code string `json:"code"`
	Envs *map[string]string `json:"envs,omitempty"`
	// python, javascript, typescript
	Language string `json:"language"`
	Timeout *int32 `json:"timeout,omitempty"`
}

type _CodeRunRequest CodeRunRequest

// NewCodeRunRequest instantiates a new CodeRunRequest 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 NewCodeRunRequest(code string, language string) *CodeRunRequest {
	this := CodeRunRequest{}
	this.Code = code
	this.Language = language
	return &this
}

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

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

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

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

	return false
}

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

// GetCode returns the Code field value
func (o *CodeRunRequest) GetCode() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Code
}

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

// SetCode sets field value
func (o *CodeRunRequest) SetCode(v string) {
	o.Code = v
}

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

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

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

	return false
}

// SetEnvs gets a reference to the given map[string]string and assigns it to the Envs field.
func (o *CodeRunRequest) SetEnvs(v map[string]string) {
	o.Envs = &v
}

// GetLanguage returns the Language field value
func (o *CodeRunRequest) GetLanguage() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Language
}

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

// SetLanguage sets field value
func (o *CodeRunRequest) SetLanguage(v string) {
	o.Language = v
}

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

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

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

	return false
}

// SetTimeout gets a reference to the given int32 and assigns it to the Timeout field.
func (o *CodeRunRequest) SetTimeout(v int32) {
	o.Timeout = &v
}

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

func (o CodeRunRequest) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Argv) {
		toSerialize["argv"] = o.Argv
	}
	toSerialize["code"] = o.Code
	if !IsNil(o.Envs) {
		toSerialize["envs"] = o.Envs
	}
	toSerialize["language"] = o.Language
	if !IsNil(o.Timeout) {
		toSerialize["timeout"] = o.Timeout
	}
	return toSerialize, nil
}

func (o *CodeRunRequest) 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{
		"code",
		"language",
	}

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

	varCodeRunRequest := _CodeRunRequest{}

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

	if err != nil {
		return err
	}

	*o = CodeRunRequest(varCodeRunRequest)

	return err
}

type NullableCodeRunRequest struct {
	value *CodeRunRequest
	isSet bool
}

func (v NullableCodeRunRequest) Get() *CodeRunRequest {
	return v.value
}

func (v *NullableCodeRunRequest) Set(val *CodeRunRequest) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableCodeRunRequest(val *CodeRunRequest) *NullableCodeRunRequest {
	return &NullableCodeRunRequest{value: val, isSet: true}
}

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

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


