oso-cloud 1.3.0.dev.0 → 1.3.0.dev.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93c11d4552281f1cbf95ec309bbbcd5e8d1289a7f0ee2000724f8d6eb4386617
4
- data.tar.gz: 62fd22884497116c5db29b06a012b2b06ad82de78b96ed4823b0dbd22862ef37
3
+ metadata.gz: 399088667fdeb8cf07cbaca88553b42c7af2eca560c09323425742d67eb59ccc
4
+ data.tar.gz: 22fdc6724778ebb443a8855451c05e7e1d21478e2a29837a6a11bcc05b791b45
5
5
  SHA512:
6
- metadata.gz: 5139439b2e01ab083c0e73827ddb520a54dc0c2606d1ca20203bad6b56fc446f747a638cc603a83584da35ae65e500ecf4354fd53065c109fa044aef6ba2950f
7
- data.tar.gz: eac48b47137286b49a1e27197cfb7867bbcd982b6fe6523f9e50ed9d8659934ceaea9b548f3d543510e9983872c9a9859400d417f149af8ef82f9319ea7b9f3e
6
+ metadata.gz: 3b6f071e3f13cb4bc665706181467c88873a868751ac0a0727ce07f2dfd02cf27375d08baf938edd288d507c877f705da1985c3a8eaa96852f9215b25f9bf2b1
7
+ data.tar.gz: d45dfc511dd84c2fa3a7df6f4fc1792174878de7f4a07c32e62ba863fdbddcea5f8921137ba948a8fbc5c11f0810d8570fae385f9d3c2e69078494f5d59cd273
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oso-cloud (1.2.0)
4
+ oso-cloud (1.3.0.dev.2)
5
5
  faraday (~> 2.5.2)
6
6
  faraday-retry (~> 2.0.0)
7
7
  faraday-typhoeus (~> 1.0.0)
data/lib/oso/api.rb CHANGED
@@ -204,9 +204,8 @@ module OsoCloud
204
204
 
205
205
  # @!visibility private
206
206
  class Api
207
- def initialize(url: 'https://api.osohq.com', api_key: nil, options: nil)
208
- @url = 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,15 +396,25 @@ module OsoCloud
392
396
  end
393
397
 
394
398
  def POST_BATCH(path, params, body_array, isMutation)
395
- responses = []
396
- @connection.in_parallel do
397
- body_array.each do |body|
398
- responses << @connection.post("api#{path}") do |req|
399
- req.params = params unless params.nil?
400
- req.body = OsoCloud::Helpers.to_hash(body) unless body.nil?
401
- req.headers = headers
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|
403
+ req.params = params unless params.nil?
404
+ req.body = OsoCloud::Helpers.to_hash(body) unless body.nil?
405
+ req.headers = headers
406
+ end
402
407
  end
403
408
  end
409
+
410
+ connection_failed = responses.find { |r| r.env.custom_members[:typhoeus_connection_failed] }
411
+ if connection_failed
412
+ raise Faraday::ConnectionFailed, connection_failed.env.custom_members[:typhoeus_return_message]
413
+ end
414
+
415
+ timed_out = responses.find { |r| r.env.custom_members[:typhoeus_timed_out] }
416
+ if timed_out
417
+ raise Faraday::TimeoutError, timed_out.env.custom_members[:typhoeus_return_message]
404
418
  end
405
419
  if isMutation
406
420
  @last_offset = responses[-1].headers[:OsoOffset]
@@ -418,7 +432,7 @@ module OsoCloud
418
432
  end
419
433
 
420
434
  if isMutation
421
- @last_offset = response.headers[:OsoOffset]
435
+ @last_offset = @response.headers[:OsoOffset]
422
436
  end
423
437
  response.body
424
438
  rescue Faraday::Error => e
data/lib/oso/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OsoCloud
2
- VERSION = '1.3.0.dev.0'.freeze
2
+ VERSION = '1.3.0.dev.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oso-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.dev.0
4
+ version: 1.3.0.dev.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oso Security, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-22 00:00:00.000000000 Z
11
+ date: 2023-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday