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

// RunnerServiceHealth struct for RunnerServiceHealth
type RunnerServiceHealth struct {
	// Name of the service being checked
	ServiceName string `json:"serviceName"`
	// Whether the service is healthy
	Healthy bool `json:"healthy"`
	// Error reason if the service is unhealthy
	ErrorReason *string `json:"errorReason,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _RunnerServiceHealth RunnerServiceHealth

// NewRunnerServiceHealth instantiates a new RunnerServiceHealth 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 NewRunnerServiceHealth(serviceName string, healthy bool) *RunnerServiceHealth {
	this := RunnerServiceHealth{}
	this.ServiceName = serviceName
	this.Healthy = healthy
	return &this
}

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

// GetServiceName returns the ServiceName field value
func (o *RunnerServiceHealth) GetServiceName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.ServiceName
}

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

// SetServiceName sets field value
func (o *RunnerServiceHealth) SetServiceName(v string) {
	o.ServiceName = v
}

// GetHealthy returns the Healthy field value
func (o *RunnerServiceHealth) GetHealthy() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.Healthy
}

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

// SetHealthy sets field value
func (o *RunnerServiceHealth) SetHealthy(v bool) {
	o.Healthy = v
}

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

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

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

	return false
}

// SetErrorReason gets a reference to the given string and assigns it to the ErrorReason field.
func (o *RunnerServiceHealth) SetErrorReason(v string) {
	o.ErrorReason = &v
}

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

func (o RunnerServiceHealth) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["serviceName"] = o.ServiceName
	toSerialize["healthy"] = o.Healthy
	if !IsNil(o.ErrorReason) {
		toSerialize["errorReason"] = o.ErrorReason
	}

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

	return toSerialize, nil
}

func (o *RunnerServiceHealth) 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{
		"serviceName",
		"healthy",
	}

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

	varRunnerServiceHealth := _RunnerServiceHealth{}

	err = json.Unmarshal(data, &varRunnerServiceHealth)

	if err != nil {
		return err
	}

	*o = RunnerServiceHealth(varRunnerServiceHealth)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "serviceName")
		delete(additionalProperties, "healthy")
		delete(additionalProperties, "errorReason")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableRunnerServiceHealth struct {
	value *RunnerServiceHealth
	isSet bool
}

func (v NullableRunnerServiceHealth) Get() *RunnerServiceHealth {
	return v.value
}

func (v *NullableRunnerServiceHealth) Set(val *RunnerServiceHealth) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableRunnerServiceHealth(val *RunnerServiceHealth) *NullableRunnerServiceHealth {
	return &NullableRunnerServiceHealth{value: val, isSet: true}
}

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

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


