multiwoven-integrations 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multiwoven/integrations/core/constants.rb +3 -0
- data/lib/multiwoven/integrations/core/destination_connector.rb +6 -0
- data/lib/multiwoven/integrations/core/utils.rb +8 -0
- data/lib/multiwoven/integrations/destination/postgresql/client.rb +5 -8
- data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/client.rb +9 -15
- data/lib/multiwoven/integrations/protocol/protocol.rb +1 -0
- data/lib/multiwoven/integrations/rollout.rb +1 -1
- data/lib/multiwoven/integrations/source/amazon_s3/client.rb +5 -3
- data/lib/multiwoven/integrations/source/amazon_s3/config/spec.json +13 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50ba719dc1cdacb377fe3caeadc0948944da43f2fce377d7db93f9ca3d5f1bea
|
4
|
+
data.tar.gz: 0f04916affd15488b2e5f7fe67b3031747d193b851dfa31e5085065bc8e6048e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1a4bb4360df030a2a8124579a1d95b84ee9ae3b2f64eb59a9e4502d481d1f5a8470216981c0303868cdca22dff9c8d8a14ca7bf01547277c4bf4bb6d72da78c
|
7
|
+
data.tar.gz: 6251c28f1bbbd38beeed2e1008715a146ad0d2fd7826c60c7508dc177e43bdf4f3bf7a792b7976c031fbfad9a0d77946ab301949cbaf9eb95acc5024596af3d8
|
@@ -34,6 +34,9 @@ module Multiwoven
|
|
34
34
|
AIRTABLE_BASES_ENDPOINT = "https://api.airtable.com/v0/meta/bases"
|
35
35
|
AIRTABLE_GET_BASE_SCHEMA_ENDPOINT = "https://api.airtable.com/v0/meta/bases/{baseId}/tables"
|
36
36
|
|
37
|
+
AWS_ACCESS_KEY_ID = ENV["AWS_ACCESS_KEY_ID"]
|
38
|
+
AWS_SECRET_ACCESS_KEY = ENV["AWS_SECRET_ACCESS_KEY"]
|
39
|
+
|
37
40
|
# HTTP
|
38
41
|
HTTP_GET = "GET"
|
39
42
|
HTTP_POST = "POST"
|
@@ -9,6 +9,12 @@ module Multiwoven
|
|
9
9
|
raise "Not implemented"
|
10
10
|
# return Protocol::TrackingMessage
|
11
11
|
end
|
12
|
+
|
13
|
+
def tracking_message(success, failure, log_message_array)
|
14
|
+
Multiwoven::Integrations::Protocol::TrackingMessage.new(
|
15
|
+
success: success, failed: failure, logs: log_message_array
|
16
|
+
).to_multiwoven_message
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -53,6 +53,14 @@ module Multiwoven
|
|
53
53
|
reporter&.report(exception, meta)
|
54
54
|
end
|
55
55
|
|
56
|
+
def log_request_response(level, request, response)
|
57
|
+
Integrations::Protocol::LogMessage.new(
|
58
|
+
name: self.class.name,
|
59
|
+
level: level,
|
60
|
+
message: { request: request.to_s, response: response.to_s, level: level }.to_json
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
56
64
|
def create_log_message(context, type, exception)
|
57
65
|
Integrations::Protocol::LogMessage.new(
|
58
66
|
name: context,
|
@@ -46,6 +46,7 @@ module Multiwoven::Integrations::Destination
|
|
46
46
|
connection_config = sync_config.destination.connection_specification.with_indifferent_access
|
47
47
|
table_name = sync_config.stream.name
|
48
48
|
primary_key = sync_config.model.primary_key
|
49
|
+
log_message_array = []
|
49
50
|
db = create_connection(connection_config)
|
50
51
|
|
51
52
|
write_success = 0
|
@@ -55,8 +56,9 @@ module Multiwoven::Integrations::Destination
|
|
55
56
|
query = Multiwoven::Integrations::Core::QueryBuilder.perform(action, table_name, record, primary_key)
|
56
57
|
logger.debug("POSTGRESQL:WRITE:QUERY query = #{query} sync_id = #{sync_config.sync_id} sync_run_id = #{sync_config.sync_run_id}")
|
57
58
|
begin
|
58
|
-
db.exec(query)
|
59
|
+
response = db.exec(query)
|
59
60
|
write_success += 1
|
61
|
+
log_message_array << log_request_response("info", query, response)
|
60
62
|
rescue StandardError => e
|
61
63
|
handle_exception(e, {
|
62
64
|
context: "POSTGRESQL:RECORD:WRITE:EXCEPTION",
|
@@ -65,9 +67,10 @@ module Multiwoven::Integrations::Destination
|
|
65
67
|
sync_run_id: sync_config.sync_run_id
|
66
68
|
})
|
67
69
|
write_failure += 1
|
70
|
+
log_message_array << log_request_response("error", query, e.message)
|
68
71
|
end
|
69
72
|
end
|
70
|
-
tracking_message(write_success, write_failure)
|
73
|
+
tracking_message(write_success, write_failure, log_message_array)
|
71
74
|
rescue StandardError => e
|
72
75
|
handle_exception(e, {
|
73
76
|
context: "POSTGRESQL:RECORD:WRITE:EXCEPTION",
|
@@ -119,12 +122,6 @@ module Multiwoven::Integrations::Destination
|
|
119
122
|
}
|
120
123
|
end
|
121
124
|
end
|
122
|
-
|
123
|
-
def tracking_message(success, failure)
|
124
|
-
Multiwoven::Integrations::Protocol::TrackingMessage.new(
|
125
|
-
success: success, failed: failure
|
126
|
-
).to_multiwoven_message
|
127
|
-
end
|
128
125
|
end
|
129
126
|
end
|
130
127
|
end
|
@@ -80,10 +80,14 @@ module Multiwoven
|
|
80
80
|
write_success = 0
|
81
81
|
write_failure = 0
|
82
82
|
properties = stream.json_schema[:properties]
|
83
|
+
log_message_array = []
|
84
|
+
|
83
85
|
records.each do |record_object|
|
84
86
|
record = extract_data(record_object, properties)
|
85
|
-
|
87
|
+
args = [stream.name, "Id", record]
|
88
|
+
response = send_data_to_salesforce(args)
|
86
89
|
write_success += 1
|
90
|
+
log_message_array << log_request_response("info", args, response)
|
87
91
|
rescue StandardError => e
|
88
92
|
# TODO: add sync_id and sync run id to the logs
|
89
93
|
handle_exception(e, {
|
@@ -93,18 +97,14 @@ module Multiwoven
|
|
93
97
|
sync_run_id: @sync_config.sync_run_id
|
94
98
|
})
|
95
99
|
write_failure += 1
|
100
|
+
log_message_array << log_request_response("error", args, e.message)
|
96
101
|
end
|
97
|
-
tracking_message(write_success, write_failure)
|
98
|
-
end
|
99
|
-
|
100
|
-
def process_record(stream, record)
|
101
|
-
send_data_to_salesforce(stream.name, record)
|
102
|
+
tracking_message(write_success, write_failure, log_message_array)
|
102
103
|
end
|
103
104
|
|
104
|
-
def send_data_to_salesforce(
|
105
|
+
def send_data_to_salesforce(args)
|
105
106
|
method_name = "upsert!"
|
106
|
-
|
107
|
-
@logger.debug("sync_id: #{@sync_config.sync_id}, sync_run_id: #{@sync_config.sync_run_id}, record: #{record}")
|
107
|
+
@logger.debug("sync_id: #{@sync_config.sync_id}, sync_run_id: #{@sync_config.sync_run_id}, args: #{args}")
|
108
108
|
@client.send(method_name, *args)
|
109
109
|
end
|
110
110
|
|
@@ -124,12 +124,6 @@ module Multiwoven
|
|
124
124
|
read_json(CATALOG_SPEC_PATH)
|
125
125
|
end
|
126
126
|
|
127
|
-
def tracking_message(success, failure)
|
128
|
-
Multiwoven::Integrations::Protocol::TrackingMessage.new(
|
129
|
-
success: success, failed: failure
|
130
|
-
).to_multiwoven_message
|
131
|
-
end
|
132
|
-
|
133
127
|
def log_debug(message)
|
134
128
|
Multiwoven::Integrations::Service.logger.debug(message)
|
135
129
|
end
|
@@ -197,6 +197,7 @@ module Multiwoven
|
|
197
197
|
attribute :success, Types::Integer.default(0)
|
198
198
|
attribute :failed, Types::Integer.default(0)
|
199
199
|
attribute? :meta, Types::Hash
|
200
|
+
attribute? :logs, Types::Array.of(LogMessage)
|
200
201
|
|
201
202
|
def to_multiwoven_message
|
202
203
|
MultiwovenMessage.new(
|
@@ -50,15 +50,17 @@ module Multiwoven::Integrations::Source
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def get_auth_data(connection_config)
|
53
|
-
session = @session_name
|
53
|
+
session = @session_name.gsub(/\s+/, "-")
|
54
54
|
@session_name = ""
|
55
55
|
if connection_config[:auth_type] == "user"
|
56
56
|
Aws::Credentials.new(connection_config[:access_id], connection_config[:secret_access])
|
57
57
|
elsif connection_config[:auth_type] == "role"
|
58
|
-
|
58
|
+
credentials = Aws::Credentials.new(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
|
59
|
+
sts_client = Aws::STS::Client.new(region: connection_config[:region], credentials: credentials)
|
59
60
|
resp = sts_client.assume_role({
|
60
61
|
role_arn: connection_config[:arn],
|
61
|
-
role_session_name: session
|
62
|
+
role_session_name: session,
|
63
|
+
external_id: connection_config[:external_id]
|
62
64
|
})
|
63
65
|
Aws::Credentials.new(
|
64
66
|
resp.credentials.access_key_id,
|
@@ -29,6 +29,7 @@
|
|
29
29
|
"region",
|
30
30
|
"bucket",
|
31
31
|
"arn",
|
32
|
+
"external_id",
|
32
33
|
"file_type"
|
33
34
|
]
|
34
35
|
},
|
@@ -53,16 +54,22 @@
|
|
53
54
|
"title": "IAM Role ARN",
|
54
55
|
"order": 1
|
55
56
|
},
|
57
|
+
"external_id": {
|
58
|
+
"type": "string",
|
59
|
+
"title": "External Id",
|
60
|
+
"description": "Unique ID that allows handshake between AWS accounts.",
|
61
|
+
"order": 2
|
62
|
+
},
|
56
63
|
"access_id": {
|
57
64
|
"type": "string",
|
58
65
|
"title": "Access Id",
|
59
|
-
"order":
|
66
|
+
"order": 3
|
60
67
|
},
|
61
68
|
"secret_access": {
|
62
69
|
"type": "string",
|
63
70
|
"title": "Secret Access",
|
64
71
|
"multiwoven_secret": true,
|
65
|
-
"order":
|
72
|
+
"order": 4
|
66
73
|
},
|
67
74
|
"region": {
|
68
75
|
"description": "AWS region",
|
@@ -71,13 +78,13 @@
|
|
71
78
|
],
|
72
79
|
"type": "string",
|
73
80
|
"title": "Region",
|
74
|
-
"order":
|
81
|
+
"order": 5
|
75
82
|
},
|
76
83
|
"bucket": {
|
77
84
|
"description": "Bucket Name",
|
78
85
|
"type": "string",
|
79
86
|
"title": "Bucket",
|
80
|
-
"order":
|
87
|
+
"order": 6
|
81
88
|
},
|
82
89
|
"path": {
|
83
90
|
"description": "Path to csv or parquet files",
|
@@ -86,7 +93,7 @@
|
|
86
93
|
],
|
87
94
|
"type": "string",
|
88
95
|
"title": "Path",
|
89
|
-
"order":
|
96
|
+
"order": 7
|
90
97
|
},
|
91
98
|
"file_type": {
|
92
99
|
"description": "The type of file to read",
|
@@ -96,7 +103,7 @@
|
|
96
103
|
"csv",
|
97
104
|
"parquet"
|
98
105
|
],
|
99
|
-
"order":
|
106
|
+
"order": 8
|
100
107
|
}
|
101
108
|
}
|
102
109
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multiwoven-integrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Subin T P
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|