oso-cloud 1.3.0.dev.1 → 1.3.0.dev.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/oso/api.rb +16 -11
- data/lib/oso/version.rb +1 -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: 399088667fdeb8cf07cbaca88553b42c7af2eca560c09323425742d67eb59ccc
|
4
|
+
data.tar.gz: 22fdc6724778ebb443a8855451c05e7e1d21478e2a29837a6a11bcc05b791b45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b6f071e3f13cb4bc665706181467c88873a868751ac0a0727ce07f2dfd02cf27375d08baf938edd288d507c877f705da1985c3a8eaa96852f9215b25f9bf2b1
|
7
|
+
data.tar.gz: d45dfc511dd84c2fa3a7df6f4fc1792174878de7f4a07c32e62ba863fdbddcea5f8921137ba948a8fbc5c11f0810d8570fae385f9d3c2e69078494f5d59cd273
|
data/Gemfile.lock
CHANGED
data/lib/oso/api.rb
CHANGED
@@ -204,9 +204,8 @@ module OsoCloud
|
|
204
204
|
|
205
205
|
# @!visibility private
|
206
206
|
class Api
|
207
|
-
def
|
208
|
-
@url
|
209
|
-
@connection = Faraday.new(url: url) do |faraday|
|
207
|
+
def get_connection(options: nil)
|
208
|
+
Faraday.new(url: @url) do |faraday|
|
210
209
|
faraday.request :json
|
211
210
|
|
212
211
|
# responses are processed in reverse order; this stack implies the
|
@@ -255,6 +254,11 @@ module OsoCloud
|
|
255
254
|
faraday.adapter :typhoeus, forbid_reuse: true, maxredirs: 1
|
256
255
|
end
|
257
256
|
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def initialize(url: 'https://api.osohq.com', api_key: nil, options: nil)
|
260
|
+
@url = url
|
261
|
+
@connection = get_connection(options: options)
|
258
262
|
@api_key = api_key
|
259
263
|
@user_agent = "Oso Cloud (ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}; rv:#{VERSION})"
|
260
264
|
@last_offset = nil
|
@@ -392,9 +396,10 @@ module OsoCloud
|
|
392
396
|
end
|
393
397
|
|
394
398
|
def POST_BATCH(path, params, body_array, isMutation)
|
395
|
-
|
396
|
-
|
397
|
-
|
399
|
+
connection = get_connection(options: nil)
|
400
|
+
responses = connection.in_parallel do
|
401
|
+
body_array.map do |body|
|
402
|
+
connection.post("api#{path}") do |req|
|
398
403
|
req.params = params unless params.nil?
|
399
404
|
req.body = OsoCloud::Helpers.to_hash(body) unless body.nil?
|
400
405
|
req.headers = headers
|
@@ -402,19 +407,19 @@ module OsoCloud
|
|
402
407
|
end
|
403
408
|
end
|
404
409
|
|
405
|
-
connection_failed =
|
410
|
+
connection_failed = responses.find { |r| r.env.custom_members[:typhoeus_connection_failed] }
|
406
411
|
if connection_failed
|
407
412
|
raise Faraday::ConnectionFailed, connection_failed.env.custom_members[:typhoeus_return_message]
|
408
413
|
end
|
409
414
|
|
410
|
-
timed_out =
|
415
|
+
timed_out = responses.find { |r| r.env.custom_members[:typhoeus_timed_out] }
|
411
416
|
if timed_out
|
412
417
|
raise Faraday::TimeoutError, timed_out.env.custom_members[:typhoeus_return_message]
|
413
418
|
end
|
414
419
|
if isMutation
|
415
|
-
@last_offset =
|
420
|
+
@last_offset = responses[-1].headers[:OsoOffset]
|
416
421
|
end
|
417
|
-
|
422
|
+
responses
|
418
423
|
rescue Faraday::Error => e
|
419
424
|
handle_faraday_error e
|
420
425
|
end
|
@@ -427,7 +432,7 @@ module OsoCloud
|
|
427
432
|
end
|
428
433
|
|
429
434
|
if isMutation
|
430
|
-
@last_offset = response.headers[:OsoOffset]
|
435
|
+
@last_offset = @response.headers[:OsoOffset]
|
431
436
|
end
|
432
437
|
response.body
|
433
438
|
rescue Faraday::Error => e
|
data/lib/oso/version.rb
CHANGED