class Multiwoven::Integrations::Source::AmazonS3::Client

def check_connection(connection_config)

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  @session_name = "connection-#{connection_config[:region]}-#{connection_config[:bucket]}"
  if unstructured_data?(connection_config)
    create_s3_connection(connection_config)
    @s3_resource.bucket(connection_config[:bucket]).objects.limit(1).first
  else
    conn = create_connection(connection_config)
    path = build_path(connection_config)
    get_results(conn, "DESCRIBE SELECT * FROM '#{path}';")
  end
  ConnectionStatus.new(status: ConnectionStatusType["succeeded"]).to_multiwoven_message
rescue StandardError => e
  ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.message).to_multiwoven_message
end