oso-cloud 1.3.0.dev.1 → 1.3.0.dev.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea1469d68034a213af21a5a0300d2b1b1c7df2d00a3a2518f0a5e48fc0b5756b
4
- data.tar.gz: 9491bc2e2bc622296b16a473c0996fdb89a67eb2242f046637ccba173a9e9fb4
3
+ metadata.gz: 75c0b57a46025c665c2098566134bbdc8e9e5a577706b6efc318b35a7a60ca57
4
+ data.tar.gz: c6482fd3885bb7736c95ec2cf744b6f9b8111da1f9daf62c9ff56fd5636d475e
5
5
  SHA512:
6
- metadata.gz: 4baf074d8e2a237287699be969ad02959f5ba1c626cc582c0542931c198cc3c7728b5aa2ec5fa1d323a1368a027d7734fea5c07490247df81f16153c4192cdc4
7
- data.tar.gz: '083f190963c58855ac7c5514a07f4547edb2d4b01cb01ac1ef2e11594375401d1b5481a23811134ac484242b8a257a1897e57c36da59241da4a2e95e6fc4d694'
6
+ metadata.gz: a0f41beb06adcdc1fdefeaefedb705d45b128c4a40533ba8356922e7903acddd566a481ac1a15910eb9aaeddc904b7091ef13e0023618cdca343c74b74ab7214
7
+ data.tar.gz: 027de9f7060481d03b7da46a837525d39391e130fb247dc140e7b0f7cf8db43e017da000ce6a02c4cb19032783e5888d5d36e92b90e1a618fe5324ffb955dab9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oso-cloud (1.3.0.dev.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,9 +396,10 @@ module OsoCloud
392
396
  end
393
397
 
394
398
  def POST_BATCH(path, params, body_array, isMutation)
395
- @connection.in_parallel do
396
- @responses = body_array.map do |body|
397
- @connection.post("api#{path}") do |req|
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 = @responses.find { |r| r.env.custom_members[:typhoeus_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 = @responses.find { |r| r.env.custom_members[:typhoeus_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 = @responses[-1].headers[:OsoOffset]
420
+ @last_offset = responses[-1].headers[:OsoOffset]
416
421
  end
417
- @responses
422
+ responses
418
423
  rescue Faraday::Error => e
419
424
  handle_faraday_error e
420
425
  end
data/lib/oso/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OsoCloud
2
- VERSION = '1.3.0.dev.1'.freeze
2
+ VERSION = '1.3.0.dev.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oso-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.dev.1
4
+ version: 1.3.0.dev.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oso Security, Inc.