=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 Runner < ApiModelBase
    # The ID of the runner
    attr_accessor :id

    # The domain of the runner
    attr_accessor :domain

    # The API URL of the runner
    attr_accessor :api_url

    # The proxy URL of the runner
    attr_accessor :proxy_url

    # The CPU capacity of the runner
    attr_accessor :cpu

    # The memory capacity of the runner in GiB
    attr_accessor :memory

    # The disk capacity of the runner in GiB
    attr_accessor :disk

    # The GPU capacity of the runner
    attr_accessor :gpu

    # The type of GPU
    attr_accessor :gpu_type

    # The class of the runner
    attr_accessor :_class

    # Current CPU usage percentage
    attr_accessor :current_cpu_usage_percentage

    # Current RAM usage percentage
    attr_accessor :current_memory_usage_percentage

    # Current disk usage percentage
    attr_accessor :current_disk_usage_percentage

    # Current allocated CPU
    attr_accessor :current_allocated_cpu

    # Current allocated memory in GiB
    attr_accessor :current_allocated_memory_gi_b

    # Current allocated disk in GiB
    attr_accessor :current_allocated_disk_gi_b

    # Current snapshot count
    attr_accessor :current_snapshot_count

    # Current number of started sandboxes
    attr_accessor :current_started_sandboxes

    # Runner availability score
    attr_accessor :availability_score

    # The region of the runner
    attr_accessor :region

    # The name of the runner
    attr_accessor :name

    # The state of the runner
    attr_accessor :state

    # The last time the runner was checked
    attr_accessor :last_checked

    # Whether the runner is unschedulable
    attr_accessor :unschedulable

    # The creation timestamp of the runner
    attr_accessor :created_at

    # The last update timestamp of the runner
    attr_accessor :updated_at

    # The version of the runner (deprecated in favor of apiVersion)
    attr_accessor :version

    # The api version of the runner
    attr_accessor :api_version

    # The class of the runner
    attr_accessor :runner_class

    # The app version of the runner
    attr_accessor :app_version

    class EnumAttributeValidator
      attr_reader :datatype
      attr_reader :allowable_values

      def initialize(datatype, allowable_values)
        @allowable_values = allowable_values.map do |value|
          case datatype.to_s
          when /Integer/i
            value.to_i
          when /Float/i
            value.to_f
          else
            value
          end
        end
      end

      def valid?(value)
        !value || allowable_values.include?(value)
      end
    end

    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'id' => :'id',
        :'domain' => :'domain',
        :'api_url' => :'apiUrl',
        :'proxy_url' => :'proxyUrl',
        :'cpu' => :'cpu',
        :'memory' => :'memory',
        :'disk' => :'disk',
        :'gpu' => :'gpu',
        :'gpu_type' => :'gpuType',
        :'_class' => :'class',
        :'current_cpu_usage_percentage' => :'currentCpuUsagePercentage',
        :'current_memory_usage_percentage' => :'currentMemoryUsagePercentage',
        :'current_disk_usage_percentage' => :'currentDiskUsagePercentage',
        :'current_allocated_cpu' => :'currentAllocatedCpu',
        :'current_allocated_memory_gi_b' => :'currentAllocatedMemoryGiB',
        :'current_allocated_disk_gi_b' => :'currentAllocatedDiskGiB',
        :'current_snapshot_count' => :'currentSnapshotCount',
        :'current_started_sandboxes' => :'currentStartedSandboxes',
        :'availability_score' => :'availabilityScore',
        :'region' => :'region',
        :'name' => :'name',
        :'state' => :'state',
        :'last_checked' => :'lastChecked',
        :'unschedulable' => :'unschedulable',
        :'created_at' => :'createdAt',
        :'updated_at' => :'updatedAt',
        :'version' => :'version',
        :'api_version' => :'apiVersion',
        :'runner_class' => :'runnerClass',
        :'app_version' => :'appVersion'
      }
    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
      {
        :'id' => :'String',
        :'domain' => :'String',
        :'api_url' => :'String',
        :'proxy_url' => :'String',
        :'cpu' => :'Float',
        :'memory' => :'Float',
        :'disk' => :'Float',
        :'gpu' => :'Float',
        :'gpu_type' => :'String',
        :'_class' => :'SandboxClass',
        :'current_cpu_usage_percentage' => :'Float',
        :'current_memory_usage_percentage' => :'Float',
        :'current_disk_usage_percentage' => :'Float',
        :'current_allocated_cpu' => :'Float',
        :'current_allocated_memory_gi_b' => :'Float',
        :'current_allocated_disk_gi_b' => :'Float',
        :'current_snapshot_count' => :'Float',
        :'current_started_sandboxes' => :'Float',
        :'availability_score' => :'Float',
        :'region' => :'String',
        :'name' => :'String',
        :'state' => :'RunnerState',
        :'last_checked' => :'String',
        :'unschedulable' => :'Boolean',
        :'created_at' => :'String',
        :'updated_at' => :'String',
        :'version' => :'String',
        :'api_version' => :'String',
        :'runner_class' => :'RunnerClass',
        :'app_version' => :'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::Runner` 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::Runner`. 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?(:'id')
        self.id = attributes[:'id']
      else
        self.id = nil
      end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if attributes.key?(:'app_version')
        self.app_version = attributes[:'app_version']
      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 @id.nil?
        invalid_properties.push('invalid value for "id", id cannot be nil.')
      end

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

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

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

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

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

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

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

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

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

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

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

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

      if @runner_class.nil?
        invalid_properties.push('invalid value for "runner_class", runner_class 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 @id.nil?
      return false if @cpu.nil?
      return false if @memory.nil?
      return false if @disk.nil?
      return false if @_class.nil?
      return false if @region.nil?
      return false if @name.nil?
      return false if @state.nil?
      return false if @unschedulable.nil?
      return false if @created_at.nil?
      return false if @updated_at.nil?
      return false if @version.nil?
      return false if @api_version.nil?
      return false if @runner_class.nil?
      true
    end

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

      @id = id
    end

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

      @cpu = cpu
    end

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

      @memory = memory
    end

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

      @disk = disk
    end

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

      @_class = _class
    end

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

      @region = region
    end

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

      @name = name
    end

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

      @state = state
    end

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

      @unschedulable = unschedulable
    end

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

      @created_at = created_at
    end

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

      @updated_at = updated_at
    end

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

      @version = version
    end

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

      @api_version = api_version
    end

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

      @runner_class = runner_class
    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 &&
          id == o.id &&
          domain == o.domain &&
          api_url == o.api_url &&
          proxy_url == o.proxy_url &&
          cpu == o.cpu &&
          memory == o.memory &&
          disk == o.disk &&
          gpu == o.gpu &&
          gpu_type == o.gpu_type &&
          _class == o._class &&
          current_cpu_usage_percentage == o.current_cpu_usage_percentage &&
          current_memory_usage_percentage == o.current_memory_usage_percentage &&
          current_disk_usage_percentage == o.current_disk_usage_percentage &&
          current_allocated_cpu == o.current_allocated_cpu &&
          current_allocated_memory_gi_b == o.current_allocated_memory_gi_b &&
          current_allocated_disk_gi_b == o.current_allocated_disk_gi_b &&
          current_snapshot_count == o.current_snapshot_count &&
          current_started_sandboxes == o.current_started_sandboxes &&
          availability_score == o.availability_score &&
          region == o.region &&
          name == o.name &&
          state == o.state &&
          last_checked == o.last_checked &&
          unschedulable == o.unschedulable &&
          created_at == o.created_at &&
          updated_at == o.updated_at &&
          version == o.version &&
          api_version == o.api_version &&
          runner_class == o.runner_class &&
          app_version == o.app_version
    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
      [id, domain, api_url, proxy_url, cpu, memory, disk, gpu, gpu_type, _class, current_cpu_usage_percentage, current_memory_usage_percentage, current_disk_usage_percentage, current_allocated_cpu, current_allocated_memory_gi_b, current_allocated_disk_gi_b, current_snapshot_count, current_started_sandboxes, availability_score, region, name, state, last_checked, unschedulable, created_at, updated_at, version, api_version, runner_class, app_version].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
