/*
Merlin

API Guide for accessing Merlin's model management, deployment, and serving functionalities

API version: 0.14.0
*/

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

package client

import (
	"encoding/json"
	"fmt"
)

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

// ModelObservability struct for ModelObservability
type ModelObservability struct {
	Enabled                               bool                                   `json:"enabled"`
	GroundTruthSource                     *GroundTruthSource                     `json:"ground_truth_source,omitempty"`
	GroundTruthJob                        *GroundTruthJob                        `json:"ground_truth_job,omitempty"`
	PredictionLogIngestionResourceRequest *PredictionLogIngestionResourceRequest `json:"prediction_log_ingestion_resource_request,omitempty"`
}

type _ModelObservability ModelObservability

// NewModelObservability instantiates a new ModelObservability 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 NewModelObservability(enabled bool) *ModelObservability {
	this := ModelObservability{}
	this.Enabled = enabled
	return &this
}

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

// GetEnabled returns the Enabled field value
func (o *ModelObservability) GetEnabled() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.Enabled
}

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

// SetEnabled sets field value
func (o *ModelObservability) SetEnabled(v bool) {
	o.Enabled = v
}

// GetGroundTruthSource returns the GroundTruthSource field value if set, zero value otherwise.
func (o *ModelObservability) GetGroundTruthSource() GroundTruthSource {
	if o == nil || IsNil(o.GroundTruthSource) {
		var ret GroundTruthSource
		return ret
	}
	return *o.GroundTruthSource
}

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

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

	return false
}

// SetGroundTruthSource gets a reference to the given GroundTruthSource and assigns it to the GroundTruthSource field.
func (o *ModelObservability) SetGroundTruthSource(v GroundTruthSource) {
	o.GroundTruthSource = &v
}

// GetGroundTruthJob returns the GroundTruthJob field value if set, zero value otherwise.
func (o *ModelObservability) GetGroundTruthJob() GroundTruthJob {
	if o == nil || IsNil(o.GroundTruthJob) {
		var ret GroundTruthJob
		return ret
	}
	return *o.GroundTruthJob
}

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

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

	return false
}

// SetGroundTruthJob gets a reference to the given GroundTruthJob and assigns it to the GroundTruthJob field.
func (o *ModelObservability) SetGroundTruthJob(v GroundTruthJob) {
	o.GroundTruthJob = &v
}

// GetPredictionLogIngestionResourceRequest returns the PredictionLogIngestionResourceRequest field value if set, zero value otherwise.
func (o *ModelObservability) GetPredictionLogIngestionResourceRequest() PredictionLogIngestionResourceRequest {
	if o == nil || IsNil(o.PredictionLogIngestionResourceRequest) {
		var ret PredictionLogIngestionResourceRequest
		return ret
	}
	return *o.PredictionLogIngestionResourceRequest
}

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

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

	return false
}

// SetPredictionLogIngestionResourceRequest gets a reference to the given PredictionLogIngestionResourceRequest and assigns it to the PredictionLogIngestionResourceRequest field.
func (o *ModelObservability) SetPredictionLogIngestionResourceRequest(v PredictionLogIngestionResourceRequest) {
	o.PredictionLogIngestionResourceRequest = &v
}

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

func (o ModelObservability) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["enabled"] = o.Enabled
	if !IsNil(o.GroundTruthSource) {
		toSerialize["ground_truth_source"] = o.GroundTruthSource
	}
	if !IsNil(o.GroundTruthJob) {
		toSerialize["ground_truth_job"] = o.GroundTruthJob
	}
	if !IsNil(o.PredictionLogIngestionResourceRequest) {
		toSerialize["prediction_log_ingestion_resource_request"] = o.PredictionLogIngestionResourceRequest
	}
	return toSerialize, nil
}

func (o *ModelObservability) UnmarshalJSON(bytes []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{
		"enabled",
	}

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

	err = json.Unmarshal(bytes, &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)
		}
	}

	varModelObservability := _ModelObservability{}

	err = json.Unmarshal(bytes, &varModelObservability)

	if err != nil {
		return err
	}

	*o = ModelObservability(varModelObservability)

	return err
}

type NullableModelObservability struct {
	value *ModelObservability
	isSet bool
}

func (v NullableModelObservability) Get() *ModelObservability {
	return v.value
}

func (v *NullableModelObservability) Set(val *ModelObservability) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableModelObservability(val *ModelObservability) *NullableModelObservability {
	return &NullableModelObservability{value: val, isSet: true}
}

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

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