multiwoven-integrations 0.43.6 → 0.43.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/multiwoven/integrations/core/oauth_client_credentials.rb +15 -1
- data/lib/multiwoven/integrations/rollout.rb +1 -1
- data/lib/multiwoven/integrations/source/aws_athena/client.rb +4 -2
- data/lib/multiwoven/integrations/source/aws_athena/config/spec.json +1 -1
- data/lib/multiwoven/integrations/source/http/client.rb +8 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7a0d04eba9b5c342148c532ce0fcdf9c10e72305e74a1861464820b9974157b
|
|
4
|
+
data.tar.gz: 76d936e4811beaaff773fb5fb54bf77edc3c6f85b8fc61196b279784dfdd4641
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5cec8ef78b7eed1015bcec7613e614e94c33f09a4257e0478500975fb9efabb679a4fd41656e14c10c63ccb1a0105f357f5e00799d304f0e88b8cb4eec77304d
|
|
7
|
+
data.tar.gz: 0cc2a19d04daf5f52fc929e5a708011202ee032d5d98a5a52974d23d26422a96d69a4d2e955f7d3066424e4002aa34468f53f3f0c151d0e0f913eb0a098acd5c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
### [0.43.8]
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* AWS Athena source builds its client with the connector's own credentials and region instead of changing global `Aws.config` (INFRA-2785)
|
|
9
|
+
|
|
10
|
+
### [0.43.7]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* OAuth token requests rejected with a 4xx other than 408 or 429 raise `OauthTokenRequestError` instead of a bare `RuntimeError` (BE-2068)
|
|
16
|
+
|
|
3
17
|
### [0.43.3]
|
|
4
18
|
|
|
5
19
|
|
|
@@ -21,6 +21,8 @@ module Multiwoven
|
|
|
21
21
|
# should benefit from the cache. Without it, a fresh token is fetched every
|
|
22
22
|
# call — safe but wasteful.
|
|
23
23
|
module OauthClientCredentials
|
|
24
|
+
class OauthTokenRequestError < RuntimeError; end
|
|
25
|
+
|
|
24
26
|
AUTH_TYPE_OAUTH_CLIENT_CREDENTIALS = "oauth_client_credentials"
|
|
25
27
|
AUTH_TYPE_PRIVATE_KEY_JWT = "oauth_private_key_jwt"
|
|
26
28
|
OAUTH_AUTH_TYPES = [AUTH_TYPE_OAUTH_CLIENT_CREDENTIALS, AUTH_TYPE_PRIVATE_KEY_JWT].freeze
|
|
@@ -33,6 +35,7 @@ module Multiwoven
|
|
|
33
35
|
# Refresh access tokens this many seconds before their advertised expiry,
|
|
34
36
|
# so a token that expires mid-request doesn't leave the connector.
|
|
35
37
|
TOKEN_EXPIRY_BUFFER_SECONDS = 300
|
|
38
|
+
TRANSIENT_HTTP_STATUSES = %w[408 429].freeze
|
|
36
39
|
|
|
37
40
|
def build_headers(connection_config)
|
|
38
41
|
headers = (connection_config[:headers] || {}).to_h.dup
|
|
@@ -76,7 +79,7 @@ module Multiwoven
|
|
|
76
79
|
else
|
|
77
80
|
post_client_secret_token_request(connection_config)
|
|
78
81
|
end
|
|
79
|
-
|
|
82
|
+
raise_token_request_error(response) unless response.is_a?(Net::HTTPSuccess)
|
|
80
83
|
|
|
81
84
|
body = JSON.parse(response.body)
|
|
82
85
|
access_token = body["access_token"]
|
|
@@ -87,6 +90,17 @@ module Multiwoven
|
|
|
87
90
|
access_token
|
|
88
91
|
end
|
|
89
92
|
|
|
93
|
+
def raise_token_request_error(response)
|
|
94
|
+
message = "OAuth token request failed: #{response.code} #{response.body}"
|
|
95
|
+
raise OauthTokenRequestError, message if rejected_token_request?(response)
|
|
96
|
+
|
|
97
|
+
raise message
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def rejected_token_request?(response)
|
|
101
|
+
response.is_a?(Net::HTTPClientError) && !TRANSIENT_HTTP_STATUSES.include?(response.code)
|
|
102
|
+
end
|
|
103
|
+
|
|
90
104
|
def post_client_secret_token_request(connection_config)
|
|
91
105
|
token_url = connection_config[:token_url]
|
|
92
106
|
client_id = connection_config[:client_id]
|
|
@@ -46,10 +46,12 @@ module Multiwoven::Integrations::Source
|
|
|
46
46
|
private
|
|
47
47
|
|
|
48
48
|
def create_connection(connection_config)
|
|
49
|
-
Aws.config.update({ credentials: Aws::Credentials.new(connection_config[:access_key], connection_config[:secret_access_key]), region: connection_config[:region] })
|
|
50
49
|
@database = connection_config[:schema]
|
|
51
50
|
@output_location = connection_config[:output_location]
|
|
52
|
-
Aws::Athena::Client.new
|
|
51
|
+
Aws::Athena::Client.new(
|
|
52
|
+
region: connection_config[:region],
|
|
53
|
+
credentials: Aws::Credentials.new(connection_config[:access_key], connection_config[:secret_access_key])
|
|
54
|
+
)
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
def query_execution(db, query)
|
|
@@ -144,10 +144,17 @@ module Multiwoven::Integrations::Source
|
|
|
144
144
|
parse_response = get_parse_response(connection_config[:parse_response])
|
|
145
145
|
parse_response(response_body, parse_response)
|
|
146
146
|
else
|
|
147
|
-
handle_exception(
|
|
147
|
+
handle_exception(StandardError.new(query_failure_message(response)), { context: "HTTP:QUERY:EXCEPTION", type: "error" })
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
+
def query_failure_message(response)
|
|
152
|
+
code = response.respond_to?(:code) ? response.code.to_s : ""
|
|
153
|
+
return "Failed to fetch data" if code.empty?
|
|
154
|
+
|
|
155
|
+
"Failed to fetch data: HTTP #{code}"
|
|
156
|
+
end
|
|
157
|
+
|
|
151
158
|
def create_streams(response_body)
|
|
152
159
|
group_by_table(response_body).map do |r|
|
|
153
160
|
Multiwoven::Integrations::Protocol::Stream.new(name: r["name"], action: StreamAction["fetch"], json_schema: r["schema"])
|