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

// MetricDataPoint struct for MetricDataPoint
type MetricDataPoint struct {
	// Timestamp of the data point
	Timestamp string `json:"timestamp"`
	// Value at this timestamp
	Value float32 `json:"value"`
	AdditionalProperties map[string]interface{}
}

type _MetricDataPoint MetricDataPoint

// NewMetricDataPoint instantiates a new MetricDataPoint 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 NewMetricDataPoint(timestamp string, value float32) *MetricDataPoint {
	this := MetricDataPoint{}
	this.Timestamp = timestamp
	this.Value = value
	return &this
}

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

// GetTimestamp returns the Timestamp field value
func (o *MetricDataPoint) GetTimestamp() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Timestamp
}

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

// SetTimestamp sets field value
func (o *MetricDataPoint) SetTimestamp(v string) {
	o.Timestamp = v
}

// GetValue returns the Value field value
func (o *MetricDataPoint) GetValue() float32 {
	if o == nil {
		var ret float32
		return ret
	}

	return o.Value
}

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

// SetValue sets field value
func (o *MetricDataPoint) SetValue(v float32) {
	o.Value = v
}

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

func (o MetricDataPoint) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["timestamp"] = o.Timestamp
	toSerialize["value"] = o.Value

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

	return toSerialize, nil
}

func (o *MetricDataPoint) 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{
		"timestamp",
		"value",
	}

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

	varMetricDataPoint := _MetricDataPoint{}

	err = json.Unmarshal(data, &varMetricDataPoint)

	if err != nil {
		return err
	}

	*o = MetricDataPoint(varMetricDataPoint)

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

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

	return err
}

type NullableMetricDataPoint struct {
	value *MetricDataPoint
	isSet bool
}

func (v NullableMetricDataPoint) Get() *MetricDataPoint {
	return v.value
}

func (v *NullableMetricDataPoint) Set(val *MetricDataPoint) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableMetricDataPoint(val *MetricDataPoint) *NullableMetricDataPoint {
	return &NullableMetricDataPoint{value: val, isSet: true}
}

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

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


