Class: Outhad::Integrations::Destination::AmazonS3::Client

Inherits:
DestinationConnector
  • Object
show all
Defined in:
lib/outhad/integrations/destination/amazon_s3/client.rb

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/outhad/integrations/destination/amazon_s3/client.rb', line 7

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  conn = create_connection(connection_config)
  conn.head_bucket(bucket: connection_config[:bucket_name])
  ConnectionStatus.new(status: ConnectionStatusType["succeeded"]).to_outhad_message
rescue StandardError => e
  ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.message).to_outhad_message
end

#discover(_connection_config = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/outhad/integrations/destination/amazon_s3/client.rb', line 16

def discover(_connection_config = nil)
  catalog_json = read_json(CATALOG_SPEC_PATH)
  catalog = build_catalog(catalog_json)
  catalog.to_outhad_message
rescue StandardError => e
  handle_exception(e, {
                     context: "AMAZONS3:DISCOVER:EXCEPTION",
                     type: "error"
                   })
end

#write(sync_config, records, _action = "destination_insert") ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/outhad/integrations/destination/amazon_s3/client.rb', line 27

def write(sync_config, records, _action = "destination_insert")
  records_size = records.size
  log_message_array = []
  write_success = upload_csv_content(sync_config, records)
  write_failure = records_size - write_success
  log_message_array << log_request_response("info", @args, @response)
  tracking_message(write_success, write_failure, log_message_array)
rescue StandardError => e
  handle_exception(e, {
                     context: "AMAZONS3:WRITE:EXCEPTION",
                     type: "error",
                     sync_id: sync_config.sync_id,
                     sync_run_id: sync_config.sync_run_id
                   })
end