=begin
#Daytona

#Daytona AI platform API Docs

The version of the OpenAPI document: 1.0
Contact: support@daytona.com
Generated by: https://openapi-generator.tech
Generator version: 7.21.0

=end

require 'date'
require 'time'

module DaytonaApiClient
  class TraceSummary < ApiModelBase
    # Unique trace identifier
    attr_accessor :trace_id

    # Name of the root span
    attr_accessor :root_span_name

    # Trace start time
    attr_accessor :start_time

    # Trace end time
    attr_accessor :end_time

    # Total duration in milliseconds
    attr_accessor :duration_ms

    # Number of spans in this trace
    attr_accessor :span_count

    # Status code of the trace
    attr_accessor :status_code

    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'trace_id' => :'traceId',
        :'root_span_name' => :'rootSpanName',
        :'start_time' => :'startTime',
        :'end_time' => :'endTime',
        :'duration_ms' => :'durationMs',
        :'span_count' => :'spanCount',
        :'status_code' => :'statusCode'
      }
    end

    # Returns attribute mapping this model knows about
    def self.acceptable_attribute_map
      attribute_map
    end

    # Returns all the JSON keys this model knows about
    def self.acceptable_attributes
      acceptable_attribute_map.values
    end

    # Attribute type mapping.
    def self.openapi_types
      {
        :'trace_id' => :'String',
        :'root_span_name' => :'String',
        :'start_time' => :'String',
        :'end_time' => :'String',
        :'duration_ms' => :'Float',
        :'span_count' => :'Float',
        :'status_code' => :'String'
      }
    end

    # List of attributes with nullable: true
    def self.openapi_nullable
      Set.new([
      ])
    end

    # Initializes the object
    # @param [Hash] attributes Model attributes in the form of hash
    def initialize(attributes = {})
      if (!attributes.is_a?(Hash))
        fail ArgumentError, "The input argument (attributes) must be a hash in `DaytonaApiClient::TraceSummary` initialize method"
      end

      # check to see if the attribute exists and convert string to symbol for hash key
      acceptable_attribute_map = self.class.acceptable_attribute_map
      attributes = attributes.each_with_object({}) { |(k, v), h|
        if (!acceptable_attribute_map.key?(k.to_sym))
          fail ArgumentError, "`#{k}` is not a valid attribute in `DaytonaApiClient::TraceSummary`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
        end
        h[k.to_sym] = v
      }

      if attributes.key?(:'trace_id')
        self.trace_id = attributes[:'trace_id']
      else
        self.trace_id = nil
      end

      if attributes.key?(:'root_span_name')
        self.root_span_name = attributes[:'root_span_name']
      else
        self.root_span_name = nil
      end

      if attributes.key?(:'start_time')
        self.start_time = attributes[:'start_time']
      else
        self.start_time = nil
      end

      if attributes.key?(:'end_time')
        self.end_time = attributes[:'end_time']
      else
        self.end_time = nil
      end

      if attributes.key?(:'duration_ms')
        self.duration_ms = attributes[:'duration_ms']
      else
        self.duration_ms = nil
      end

      if attributes.key?(:'span_count')
        self.span_count = attributes[:'span_count']
      else
        self.span_count = nil
      end

      if attributes.key?(:'status_code')
        self.status_code = attributes[:'status_code']
      end
    end

    # Show invalid properties with the reasons. Usually used together with valid?
    # @return Array for valid properties with the reasons
    def list_invalid_properties
      warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
      invalid_properties = Array.new
      if @trace_id.nil?
        invalid_properties.push('invalid value for "trace_id", trace_id cannot be nil.')
      end

      if @root_span_name.nil?
        invalid_properties.push('invalid value for "root_span_name", root_span_name cannot be nil.')
      end

      if @start_time.nil?
        invalid_properties.push('invalid value for "start_time", start_time cannot be nil.')
      end

      if @end_time.nil?
        invalid_properties.push('invalid value for "end_time", end_time cannot be nil.')
      end

      if @duration_ms.nil?
        invalid_properties.push('invalid value for "duration_ms", duration_ms cannot be nil.')
      end

      if @span_count.nil?
        invalid_properties.push('invalid value for "span_count", span_count cannot be nil.')
      end

      invalid_properties
    end

    # Check to see if the all the properties in the model are valid
    # @return true if the model is valid
    def valid?
      warn '[DEPRECATED] the `valid?` method is obsolete'
      return false if @trace_id.nil?
      return false if @root_span_name.nil?
      return false if @start_time.nil?
      return false if @end_time.nil?
      return false if @duration_ms.nil?
      return false if @span_count.nil?
      true
    end

    # Custom attribute writer method with validation
    # @param [Object] trace_id Value to be assigned
    def trace_id=(trace_id)
      if trace_id.nil?
        fail ArgumentError, 'trace_id cannot be nil'
      end

      @trace_id = trace_id
    end

    # Custom attribute writer method with validation
    # @param [Object] root_span_name Value to be assigned
    def root_span_name=(root_span_name)
      if root_span_name.nil?
        fail ArgumentError, 'root_span_name cannot be nil'
      end

      @root_span_name = root_span_name
    end

    # Custom attribute writer method with validation
    # @param [Object] start_time Value to be assigned
    def start_time=(start_time)
      if start_time.nil?
        fail ArgumentError, 'start_time cannot be nil'
      end

      @start_time = start_time
    end

    # Custom attribute writer method with validation
    # @param [Object] end_time Value to be assigned
    def end_time=(end_time)
      if end_time.nil?
        fail ArgumentError, 'end_time cannot be nil'
      end

      @end_time = end_time
    end

    # Custom attribute writer method with validation
    # @param [Object] duration_ms Value to be assigned
    def duration_ms=(duration_ms)
      if duration_ms.nil?
        fail ArgumentError, 'duration_ms cannot be nil'
      end

      @duration_ms = duration_ms
    end

    # Custom attribute writer method with validation
    # @param [Object] span_count Value to be assigned
    def span_count=(span_count)
      if span_count.nil?
        fail ArgumentError, 'span_count cannot be nil'
      end

      @span_count = span_count
    end

    # Checks equality by comparing each attribute.
    # @param [Object] Object to be compared
    def ==(o)
      return true if self.equal?(o)
      self.class == o.class &&
          trace_id == o.trace_id &&
          root_span_name == o.root_span_name &&
          start_time == o.start_time &&
          end_time == o.end_time &&
          duration_ms == o.duration_ms &&
          span_count == o.span_count &&
          status_code == o.status_code
    end

    # @see the `==` method
    # @param [Object] Object to be compared
    def eql?(o)
      self == o
    end

    # Calculates hash code according to all attributes.
    # @return [Integer] Hash code
    def hash
      [trace_id, root_span_name, start_time, end_time, duration_ms, span_count, status_code].hash
    end

    # Builds the object from hash
    # @param [Hash] attributes Model attributes in the form of hash
    # @return [Object] Returns the model itself
    def self.build_from_hash(attributes)
      return nil unless attributes.is_a?(Hash)
      attributes = attributes.transform_keys(&:to_sym)
      transformed_hash = {}
      openapi_types.each_pair do |key, type|
        if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
          transformed_hash["#{key}"] = nil
        elsif type =~ /\AArray<(.*)>/i
          # check to ensure the input is an array given that the attribute
          # is documented as an array but the input is not
          if attributes[attribute_map[key]].is_a?(Array)
            transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
          end
        elsif !attributes[attribute_map[key]].nil?
          transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
        end
      end
      new(transformed_hash)
    end

    # Returns the object in the form of hash
    # @return [Hash] Returns the object in the form of hash
    def to_hash
      hash = {}
      self.class.attribute_map.each_pair do |attr, param|
        value = self.send(attr)
        if value.nil?
          is_nullable = self.class.openapi_nullable.include?(attr)
          next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
        end

        hash[param] = _to_hash(value)
      end
      hash
    end

  end

end
