idlc-sdk-core 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/idlc-sdk-core/restclient.rb +34 -10
- data/lib/idlc-sdk-core/version.rb +1 -1
- 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: 5f359eccf2136e9e844b00d631b71ba4d53bc27ea3b8867f2894278283802f06
|
4
|
+
data.tar.gz: 6b700d3b4184376a94fd512ee85b360bc6d0a5f184800f01a85b899adbe28e41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fcf3e008ac4ddcff58db39eadf4973e7bdb9e1534d7532e3113873de676b6e37ab103f910556fbea96567b0fc29e82a64401c1730590c9e647fa5daf143f114
|
7
|
+
data.tar.gz: 93d7c9a0373f20656f86fb9b8cbc6c5f0e0661db045e348779bea60b3070650afb30164759404adc7e6aef88a1de9cf163c90f3c416bb64d4a500bf163f8069c
|
@@ -48,6 +48,8 @@ module Idlc
|
|
48
48
|
end
|
49
49
|
|
50
50
|
class AWSRestClient
|
51
|
+
include Helpers
|
52
|
+
|
51
53
|
def initialize(credentials= {
|
52
54
|
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
53
55
|
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
|
@@ -68,17 +70,40 @@ module Idlc
|
|
68
70
|
body = ''
|
69
71
|
body = request['body'].to_json if request['body']
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
retries = 0
|
74
|
+
max_retries = 5
|
75
|
+
sleep_time = 5
|
76
|
+
exp_backoff = 2
|
77
|
+
result = nil
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
+
loop do
|
80
|
+
begin
|
81
|
+
resp = send_signed_request(
|
82
|
+
request['method'],
|
83
|
+
"#{endpoint.strip}#{request['path']}",
|
84
|
+
body
|
85
|
+
)
|
86
|
+
|
87
|
+
result = JSON.parse(resp.body)
|
88
|
+
message = "status: #{resp.code}, message: #{result['message']}"
|
89
|
+
raise message unless resp.code == '200'
|
90
|
+
break
|
91
|
+
rescue Exception => e
|
92
|
+
break if retries >= max_retries
|
93
|
+
retries += 1
|
94
|
+
msg("RequestFailed: #{e} - Waiting #{sleep_time}s then retrying... (#{retries} of #{max_retries})")
|
79
95
|
|
80
|
-
|
81
|
-
|
96
|
+
|
97
|
+
sleep sleep_time
|
98
|
+
sleep_time *= exp_backoff # use an exponential backoff when retrying requests
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# if request has 'outfile' param, write response body to file
|
103
|
+
to_file(result, request['outfile']) if request['outfile']
|
104
|
+
|
105
|
+
# return response body obj
|
106
|
+
result
|
82
107
|
end
|
83
108
|
|
84
109
|
def to_file(obj, filename)
|
@@ -99,7 +124,6 @@ module Idlc
|
|
99
124
|
request = http_request(method, path, signature, payload)
|
100
125
|
|
101
126
|
response = https.request(request)
|
102
|
-
JSON.parse(response.body)
|
103
127
|
end
|
104
128
|
|
105
129
|
def set_headers(request, signature)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idlc-sdk-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Cazell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|