=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 CreateSandbox < ApiModelBase
    # The name of the sandbox. If not provided, the sandbox ID will be used as the name
    attr_accessor :name

    # The ID or name of the snapshot used for the sandbox
    attr_accessor :snapshot

    # The user associated with the project
    attr_accessor :user

    # Environment variables for the sandbox
    attr_accessor :env

    # Labels for the sandbox
    attr_accessor :labels

    # Whether the sandbox http preview is publicly accessible
    attr_accessor :public

    # Whether to block all network access for the sandbox
    attr_accessor :network_block_all

    # Comma-separated list of allowed CIDR network addresses for the sandbox
    attr_accessor :network_allow_list

    # The sandbox class type
    attr_accessor :_class

    # The target (region) where the sandbox will be created
    attr_accessor :target

    # CPU cores allocated to the sandbox
    attr_accessor :cpu

    # GPU units allocated to the sandbox
    attr_accessor :gpu

    # Memory allocated to the sandbox in GB
    attr_accessor :memory

    # Disk space allocated to the sandbox in GB
    attr_accessor :disk

    # Auto-stop interval in minutes (0 means disabled)
    attr_accessor :auto_stop_interval

    # Auto-archive interval in minutes (0 means the maximum interval will be used)
    attr_accessor :auto_archive_interval

    # Auto-delete interval in minutes (negative value means disabled, 0 means delete immediately upon stopping)
    attr_accessor :auto_delete_interval

    # Array of volumes to attach to the sandbox
    attr_accessor :volumes

    # Build information for the sandbox
    attr_accessor :build_info

    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
      {
        :'name' => :'name',
        :'snapshot' => :'snapshot',
        :'user' => :'user',
        :'env' => :'env',
        :'labels' => :'labels',
        :'public' => :'public',
        :'network_block_all' => :'networkBlockAll',
        :'network_allow_list' => :'networkAllowList',
        :'_class' => :'class',
        :'target' => :'target',
        :'cpu' => :'cpu',
        :'gpu' => :'gpu',
        :'memory' => :'memory',
        :'disk' => :'disk',
        :'auto_stop_interval' => :'autoStopInterval',
        :'auto_archive_interval' => :'autoArchiveInterval',
        :'auto_delete_interval' => :'autoDeleteInterval',
        :'volumes' => :'volumes',
        :'build_info' => :'buildInfo'
      }
    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
      {
        :'name' => :'String',
        :'snapshot' => :'String',
        :'user' => :'String',
        :'env' => :'Hash<String, String>',
        :'labels' => :'Hash<String, String>',
        :'public' => :'Boolean',
        :'network_block_all' => :'Boolean',
        :'network_allow_list' => :'String',
        :'_class' => :'String',
        :'target' => :'String',
        :'cpu' => :'Integer',
        :'gpu' => :'Integer',
        :'memory' => :'Integer',
        :'disk' => :'Integer',
        :'auto_stop_interval' => :'Integer',
        :'auto_archive_interval' => :'Integer',
        :'auto_delete_interval' => :'Integer',
        :'volumes' => :'Array<SandboxVolume>',
        :'build_info' => :'CreateBuildInfo'
      }
    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::CreateSandbox` 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::CreateSandbox`. 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?(:'name')
        self.name = attributes[:'name']
      end

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

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

      if attributes.key?(:'env')
        if (value = attributes[:'env']).is_a?(Hash)
          self.env = value
        end
      end

      if attributes.key?(:'labels')
        if (value = attributes[:'labels']).is_a?(Hash)
          self.labels = value
        end
      end

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

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

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

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

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

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

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

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

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

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

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

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

      if attributes.key?(:'volumes')
        if (value = attributes[:'volumes']).is_a?(Array)
          self.volumes = value
        end
      end

      if attributes.key?(:'build_info')
        self.build_info = attributes[:'build_info']
      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
      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'
      _class_validator = EnumAttributeValidator.new('String', ["small", "medium", "large", "unknown_default_open_api"])
      return false unless _class_validator.valid?(@_class)
      true
    end

    # Custom attribute writer method checking allowed values (enum).
    # @param [Object] _class Object to be assigned
    def _class=(_class)
      validator = EnumAttributeValidator.new('String', ["small", "medium", "large", "unknown_default_open_api"])
      unless validator.valid?(_class)
        fail ArgumentError, "invalid value for \"_class\", must be one of #{validator.allowable_values}."
      end
      @_class = _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 &&
          name == o.name &&
          snapshot == o.snapshot &&
          user == o.user &&
          env == o.env &&
          labels == o.labels &&
          public == o.public &&
          network_block_all == o.network_block_all &&
          network_allow_list == o.network_allow_list &&
          _class == o._class &&
          target == o.target &&
          cpu == o.cpu &&
          gpu == o.gpu &&
          memory == o.memory &&
          disk == o.disk &&
          auto_stop_interval == o.auto_stop_interval &&
          auto_archive_interval == o.auto_archive_interval &&
          auto_delete_interval == o.auto_delete_interval &&
          volumes == o.volumes &&
          build_info == o.build_info
    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
      [name, snapshot, user, env, labels, public, network_block_all, network_allow_list, _class, target, cpu, gpu, memory, disk, auto_stop_interval, auto_archive_interval, auto_delete_interval, volumes, build_info].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
