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

// TraceSummary struct for TraceSummary
type TraceSummary struct {
	// Unique trace identifier
	TraceId string `json:"traceId"`
	// Name of the root span
	RootSpanName string `json:"rootSpanName"`
	// Trace start time
	StartTime string `json:"startTime"`
	// Trace end time
	EndTime string `json:"endTime"`
	// Total duration in milliseconds
	DurationMs float32 `json:"durationMs"`
	// Number of spans in this trace
	SpanCount float32 `json:"spanCount"`
	// Status code of the trace
	StatusCode *string `json:"statusCode,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _TraceSummary TraceSummary

// NewTraceSummary instantiates a new TraceSummary 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 NewTraceSummary(traceId string, rootSpanName string, startTime string, endTime string, durationMs float32, spanCount float32) *TraceSummary {
	this := TraceSummary{}
	this.TraceId = traceId
	this.RootSpanName = rootSpanName
	this.StartTime = startTime
	this.EndTime = endTime
	this.DurationMs = durationMs
	this.SpanCount = spanCount
	return &this
}

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

// GetTraceId returns the TraceId field value
func (o *TraceSummary) GetTraceId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.TraceId
}

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

// SetTraceId sets field value
func (o *TraceSummary) SetTraceId(v string) {
	o.TraceId = v
}

// GetRootSpanName returns the RootSpanName field value
func (o *TraceSummary) GetRootSpanName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.RootSpanName
}

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

// SetRootSpanName sets field value
func (o *TraceSummary) SetRootSpanName(v string) {
	o.RootSpanName = v
}

// GetStartTime returns the StartTime field value
func (o *TraceSummary) GetStartTime() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.StartTime
}

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

// SetStartTime sets field value
func (o *TraceSummary) SetStartTime(v string) {
	o.StartTime = v
}

// GetEndTime returns the EndTime field value
func (o *TraceSummary) GetEndTime() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.EndTime
}

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

// SetEndTime sets field value
func (o *TraceSummary) SetEndTime(v string) {
	o.EndTime = v
}

// GetDurationMs returns the DurationMs field value
func (o *TraceSummary) GetDurationMs() float32 {
	if o == nil {
		var ret float32
		return ret
	}

	return o.DurationMs
}

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

// SetDurationMs sets field value
func (o *TraceSummary) SetDurationMs(v float32) {
	o.DurationMs = v
}

// GetSpanCount returns the SpanCount field value
func (o *TraceSummary) GetSpanCount() float32 {
	if o == nil {
		var ret float32
		return ret
	}

	return o.SpanCount
}

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

// SetSpanCount sets field value
func (o *TraceSummary) SetSpanCount(v float32) {
	o.SpanCount = v
}

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

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

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

	return false
}

// SetStatusCode gets a reference to the given string and assigns it to the StatusCode field.
func (o *TraceSummary) SetStatusCode(v string) {
	o.StatusCode = &v
}

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

func (o TraceSummary) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["traceId"] = o.TraceId
	toSerialize["rootSpanName"] = o.RootSpanName
	toSerialize["startTime"] = o.StartTime
	toSerialize["endTime"] = o.EndTime
	toSerialize["durationMs"] = o.DurationMs
	toSerialize["spanCount"] = o.SpanCount
	if !IsNil(o.StatusCode) {
		toSerialize["statusCode"] = o.StatusCode
	}

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

	return toSerialize, nil
}

func (o *TraceSummary) 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{
		"traceId",
		"rootSpanName",
		"startTime",
		"endTime",
		"durationMs",
		"spanCount",
	}

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

	varTraceSummary := _TraceSummary{}

	err = json.Unmarshal(data, &varTraceSummary)

	if err != nil {
		return err
	}

	*o = TraceSummary(varTraceSummary)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "traceId")
		delete(additionalProperties, "rootSpanName")
		delete(additionalProperties, "startTime")
		delete(additionalProperties, "endTime")
		delete(additionalProperties, "durationMs")
		delete(additionalProperties, "spanCount")
		delete(additionalProperties, "statusCode")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableTraceSummary struct {
	value *TraceSummary
	isSet bool
}

func (v NullableTraceSummary) Get() *TraceSummary {
	return v.value
}

func (v *NullableTraceSummary) Set(val *TraceSummary) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTraceSummary(val *TraceSummary) *NullableTraceSummary {
	return &NullableTraceSummary{value: val, isSet: true}
}

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

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


