=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 Organization < ApiModelBase
    # Organization ID
    attr_accessor :id

    # Organization name
    attr_accessor :name

    # User ID of the organization creator
    attr_accessor :created_by

    # Personal organization flag
    attr_accessor :personal

    # Creation timestamp
    attr_accessor :created_at

    # Last update timestamp
    attr_accessor :updated_at

    # Suspended flag
    attr_accessor :suspended

    # Suspended at
    attr_accessor :suspended_at

    # Suspended reason
    attr_accessor :suspension_reason

    # Suspended until
    attr_accessor :suspended_until

    # Suspension cleanup grace period hours
    attr_accessor :suspension_cleanup_grace_period_hours

    # Max CPU per sandbox
    attr_accessor :max_cpu_per_sandbox

    # Max memory per sandbox
    attr_accessor :max_memory_per_sandbox

    # Max disk per sandbox
    attr_accessor :max_disk_per_sandbox

    # Time in minutes before an unused snapshot is deactivated
    attr_accessor :snapshot_deactivation_timeout_minutes

    # Sandbox default network block all
    attr_accessor :sandbox_limited_network_egress

    # Default region ID
    attr_accessor :default_region_id

    # Authenticated rate limit per minute
    attr_accessor :authenticated_rate_limit

    # Sandbox create rate limit per minute
    attr_accessor :sandbox_create_rate_limit

    # Sandbox lifecycle rate limit per minute
    attr_accessor :sandbox_lifecycle_rate_limit

    # Experimental configuration
    attr_accessor :experimental_config

    # OpenTelemetry collection configuration
    attr_accessor :otel_config

    # Authenticated rate limit TTL in seconds
    attr_accessor :authenticated_rate_limit_ttl_seconds

    # Sandbox create rate limit TTL in seconds
    attr_accessor :sandbox_create_rate_limit_ttl_seconds

    # Sandbox lifecycle rate limit TTL in seconds
    attr_accessor :sandbox_lifecycle_rate_limit_ttl_seconds

    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'id' => :'id',
        :'name' => :'name',
        :'created_by' => :'createdBy',
        :'personal' => :'personal',
        :'created_at' => :'createdAt',
        :'updated_at' => :'updatedAt',
        :'suspended' => :'suspended',
        :'suspended_at' => :'suspendedAt',
        :'suspension_reason' => :'suspensionReason',
        :'suspended_until' => :'suspendedUntil',
        :'suspension_cleanup_grace_period_hours' => :'suspensionCleanupGracePeriodHours',
        :'max_cpu_per_sandbox' => :'maxCpuPerSandbox',
        :'max_memory_per_sandbox' => :'maxMemoryPerSandbox',
        :'max_disk_per_sandbox' => :'maxDiskPerSandbox',
        :'snapshot_deactivation_timeout_minutes' => :'snapshotDeactivationTimeoutMinutes',
        :'sandbox_limited_network_egress' => :'sandboxLimitedNetworkEgress',
        :'default_region_id' => :'defaultRegionId',
        :'authenticated_rate_limit' => :'authenticatedRateLimit',
        :'sandbox_create_rate_limit' => :'sandboxCreateRateLimit',
        :'sandbox_lifecycle_rate_limit' => :'sandboxLifecycleRateLimit',
        :'experimental_config' => :'experimentalConfig',
        :'otel_config' => :'otelConfig',
        :'authenticated_rate_limit_ttl_seconds' => :'authenticatedRateLimitTtlSeconds',
        :'sandbox_create_rate_limit_ttl_seconds' => :'sandboxCreateRateLimitTtlSeconds',
        :'sandbox_lifecycle_rate_limit_ttl_seconds' => :'sandboxLifecycleRateLimitTtlSeconds'
      }
    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',
        :'name' => :'String',
        :'created_by' => :'String',
        :'personal' => :'Boolean',
        :'created_at' => :'Time',
        :'updated_at' => :'Time',
        :'suspended' => :'Boolean',
        :'suspended_at' => :'Time',
        :'suspension_reason' => :'String',
        :'suspended_until' => :'Time',
        :'suspension_cleanup_grace_period_hours' => :'Float',
        :'max_cpu_per_sandbox' => :'Float',
        :'max_memory_per_sandbox' => :'Float',
        :'max_disk_per_sandbox' => :'Float',
        :'snapshot_deactivation_timeout_minutes' => :'Float',
        :'sandbox_limited_network_egress' => :'Boolean',
        :'default_region_id' => :'String',
        :'authenticated_rate_limit' => :'Float',
        :'sandbox_create_rate_limit' => :'Float',
        :'sandbox_lifecycle_rate_limit' => :'Float',
        :'experimental_config' => :'Object',
        :'otel_config' => :'OtelConfig',
        :'authenticated_rate_limit_ttl_seconds' => :'Float',
        :'sandbox_create_rate_limit_ttl_seconds' => :'Float',
        :'sandbox_lifecycle_rate_limit_ttl_seconds' => :'Float'
      }
    end

    # List of attributes with nullable: true
    def self.openapi_nullable
      Set.new([
        :'authenticated_rate_limit',
        :'sandbox_create_rate_limit',
        :'sandbox_lifecycle_rate_limit',
        :'otel_config',
        :'authenticated_rate_limit_ttl_seconds',
        :'sandbox_create_rate_limit_ttl_seconds',
        :'sandbox_lifecycle_rate_limit_ttl_seconds'
      ])
    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::Organization` 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::Organization`. 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?(:'name')
        self.name = attributes[:'name']
      else
        self.name = nil
      end

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

      if attributes.key?(:'personal')
        self.personal = attributes[:'personal']
      else
        self.personal = 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?(:'suspended')
        self.suspended = attributes[:'suspended']
      else
        self.suspended = nil
      end

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

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

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

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

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

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

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

      if attributes.key?(:'snapshot_deactivation_timeout_minutes')
        self.snapshot_deactivation_timeout_minutes = attributes[:'snapshot_deactivation_timeout_minutes']
      else
        self.snapshot_deactivation_timeout_minutes = 20160
      end

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

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

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

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

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

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

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

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

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

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

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

      if @personal.nil?
        invalid_properties.push('invalid value for "personal", personal 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 @suspended.nil?
        invalid_properties.push('invalid value for "suspended", suspended cannot be nil.')
      end

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

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

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

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

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

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

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

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

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

      if @experimental_config.nil?
        invalid_properties.push('invalid value for "experimental_config", experimental_config 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 @name.nil?
      return false if @created_by.nil?
      return false if @personal.nil?
      return false if @created_at.nil?
      return false if @updated_at.nil?
      return false if @suspended.nil?
      return false if @suspended_at.nil?
      return false if @suspension_reason.nil?
      return false if @suspended_until.nil?
      return false if @suspension_cleanup_grace_period_hours.nil?
      return false if @max_cpu_per_sandbox.nil?
      return false if @max_memory_per_sandbox.nil?
      return false if @max_disk_per_sandbox.nil?
      return false if @snapshot_deactivation_timeout_minutes.nil?
      return false if @sandbox_limited_network_egress.nil?
      return false if @experimental_config.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] 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] created_by Value to be assigned
    def created_by=(created_by)
      if created_by.nil?
        fail ArgumentError, 'created_by cannot be nil'
      end

      @created_by = created_by
    end

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

      @personal = personal
    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] suspended Value to be assigned
    def suspended=(suspended)
      if suspended.nil?
        fail ArgumentError, 'suspended cannot be nil'
      end

      @suspended = suspended
    end

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

      @suspended_at = suspended_at
    end

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

      @suspension_reason = suspension_reason
    end

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

      @suspended_until = suspended_until
    end

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

      @suspension_cleanup_grace_period_hours = suspension_cleanup_grace_period_hours
    end

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

      @max_cpu_per_sandbox = max_cpu_per_sandbox
    end

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

      @max_memory_per_sandbox = max_memory_per_sandbox
    end

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

      @max_disk_per_sandbox = max_disk_per_sandbox
    end

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

      @snapshot_deactivation_timeout_minutes = snapshot_deactivation_timeout_minutes
    end

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

      @sandbox_limited_network_egress = sandbox_limited_network_egress
    end

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

      @experimental_config = experimental_config
    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 &&
          name == o.name &&
          created_by == o.created_by &&
          personal == o.personal &&
          created_at == o.created_at &&
          updated_at == o.updated_at &&
          suspended == o.suspended &&
          suspended_at == o.suspended_at &&
          suspension_reason == o.suspension_reason &&
          suspended_until == o.suspended_until &&
          suspension_cleanup_grace_period_hours == o.suspension_cleanup_grace_period_hours &&
          max_cpu_per_sandbox == o.max_cpu_per_sandbox &&
          max_memory_per_sandbox == o.max_memory_per_sandbox &&
          max_disk_per_sandbox == o.max_disk_per_sandbox &&
          snapshot_deactivation_timeout_minutes == o.snapshot_deactivation_timeout_minutes &&
          sandbox_limited_network_egress == o.sandbox_limited_network_egress &&
          default_region_id == o.default_region_id &&
          authenticated_rate_limit == o.authenticated_rate_limit &&
          sandbox_create_rate_limit == o.sandbox_create_rate_limit &&
          sandbox_lifecycle_rate_limit == o.sandbox_lifecycle_rate_limit &&
          experimental_config == o.experimental_config &&
          otel_config == o.otel_config &&
          authenticated_rate_limit_ttl_seconds == o.authenticated_rate_limit_ttl_seconds &&
          sandbox_create_rate_limit_ttl_seconds == o.sandbox_create_rate_limit_ttl_seconds &&
          sandbox_lifecycle_rate_limit_ttl_seconds == o.sandbox_lifecycle_rate_limit_ttl_seconds
    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, name, created_by, personal, created_at, updated_at, suspended, suspended_at, suspension_reason, suspended_until, suspension_cleanup_grace_period_hours, max_cpu_per_sandbox, max_memory_per_sandbox, max_disk_per_sandbox, snapshot_deactivation_timeout_minutes, sandbox_limited_network_egress, default_region_id, authenticated_rate_limit, sandbox_create_rate_limit, sandbox_lifecycle_rate_limit, experimental_config, otel_config, authenticated_rate_limit_ttl_seconds, sandbox_create_rate_limit_ttl_seconds, sandbox_lifecycle_rate_limit_ttl_seconds].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
