=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 AuditLog < ApiModelBase
    attr_accessor :id

    attr_accessor :actor_id

    attr_accessor :actor_email

    attr_accessor :actor_api_key_prefix

    attr_accessor :actor_api_key_suffix

    attr_accessor :organization_id

    attr_accessor :action

    attr_accessor :target_type

    attr_accessor :target_id

    attr_accessor :status_code

    attr_accessor :error_message

    attr_accessor :ip_address

    attr_accessor :user_agent

    attr_accessor :source

    attr_accessor :metadata

    attr_accessor :created_at

    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'id' => :'id',
        :'actor_id' => :'actorId',
        :'actor_email' => :'actorEmail',
        :'actor_api_key_prefix' => :'actorApiKeyPrefix',
        :'actor_api_key_suffix' => :'actorApiKeySuffix',
        :'organization_id' => :'organizationId',
        :'action' => :'action',
        :'target_type' => :'targetType',
        :'target_id' => :'targetId',
        :'status_code' => :'statusCode',
        :'error_message' => :'errorMessage',
        :'ip_address' => :'ipAddress',
        :'user_agent' => :'userAgent',
        :'source' => :'source',
        :'metadata' => :'metadata',
        :'created_at' => :'createdAt'
      }
    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',
        :'actor_id' => :'String',
        :'actor_email' => :'String',
        :'actor_api_key_prefix' => :'String',
        :'actor_api_key_suffix' => :'String',
        :'organization_id' => :'String',
        :'action' => :'String',
        :'target_type' => :'String',
        :'target_id' => :'String',
        :'status_code' => :'Float',
        :'error_message' => :'String',
        :'ip_address' => :'String',
        :'user_agent' => :'String',
        :'source' => :'String',
        :'metadata' => :'Hash<String, Object>',
        :'created_at' => :'Time'
      }
    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::AuditLog` 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::AuditLog`. 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?(:'actor_id')
        self.actor_id = attributes[:'actor_id']
      else
        self.actor_id = nil
      end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if @created_at.nil?
        invalid_properties.push('invalid value for "created_at", created_at 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 @actor_id.nil?
      return false if @actor_email.nil?
      return false if @action.nil?
      return false if @created_at.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] actor_id Value to be assigned
    def actor_id=(actor_id)
      if actor_id.nil?
        fail ArgumentError, 'actor_id cannot be nil'
      end

      @actor_id = actor_id
    end

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

      @actor_email = actor_email
    end

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

      @action = action
    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

    # 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 &&
          actor_id == o.actor_id &&
          actor_email == o.actor_email &&
          actor_api_key_prefix == o.actor_api_key_prefix &&
          actor_api_key_suffix == o.actor_api_key_suffix &&
          organization_id == o.organization_id &&
          action == o.action &&
          target_type == o.target_type &&
          target_id == o.target_id &&
          status_code == o.status_code &&
          error_message == o.error_message &&
          ip_address == o.ip_address &&
          user_agent == o.user_agent &&
          source == o.source &&
          metadata == o.metadata &&
          created_at == o.created_at
    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, actor_id, actor_email, actor_api_key_prefix, actor_api_key_suffix, organization_id, action, target_type, target_id, status_code, error_message, ip_address, user_agent, source, metadata, created_at].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
