strongdm 2.0.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/strongdm.rb CHANGED
@@ -18,6 +18,7 @@
18
18
  require_relative "./svc"
19
19
  require "base64"
20
20
  require "openssl"
21
+ require "time"
21
22
 
22
23
  module SDM #:nodoc:
23
24
 
@@ -27,11 +28,11 @@ module SDM #:nodoc:
27
28
  DEFAULT_BASE_RETRY_DELAY = 0.0030 # 30 ms
28
29
  DEFAULT_MAX_RETRY_DELAY = 300 # 300 seconds
29
30
  API_VERSION = "2021-08-23"
30
- USER_AGENT = "strongdm-sdk-ruby/2.0.0"
31
+ USER_AGENT = "strongdm-sdk-ruby/2.5.0"
31
32
  private_constant :DEFAULT_MAX_RETRIES, :DEFAULT_BASE_RETRY_DELAY, :DEFAULT_MAX_RETRY_DELAY, :API_VERSION, :USER_AGENT
32
33
 
33
34
  # Creates a new strongDM API client.
34
- def initialize(api_access_key, api_secret_key, host: "api.strongdm.com:443", insecure: false)
35
+ def initialize(api_access_key, api_secret_key, host: "api.strongdm.com:443", insecure: false, retry_rate_limit_errors: true)
35
36
  raise TypeError, "client access key must be a string" unless api_access_key.kind_of?(String)
36
37
  raise TypeError, "client secret key must be a string" unless api_secret_key.kind_of?(String)
37
38
  raise TypeError, "client host must be a string" unless host.kind_of?(String)
@@ -40,6 +41,7 @@ module SDM #:nodoc:
40
41
  @max_retries = DEFAULT_MAX_RETRIES
41
42
  @base_retry_delay = DEFAULT_BASE_RETRY_DELAY
42
43
  @max_retry_delay = DEFAULT_MAX_RETRY_DELAY
44
+ @expose_rate_limit_errors = (not retry_rate_limit_errors)
43
45
  @account_attachments = AccountAttachments.new(host, insecure, self)
44
46
  @account_grants = AccountGrants.new(host, insecure, self)
45
47
  @accounts = Accounts.new(host, insecure, self)
@@ -94,6 +96,17 @@ module SDM #:nodoc:
94
96
  if not err.is_a? GRPC::BadStatus
95
97
  return true
96
98
  end
99
+ porcelainErr = Plumbing::convert_error_to_porcelain(err)
100
+ if (not @expose_rate_limit_errors) and (porcelainErr.is_a? RateLimitError)
101
+ sleep_for = porcelainErr.rate_limit.reset_at - Time.now
102
+ # If timezones or clock drift causes this calculation to fail,
103
+ # wait at most one minute.
104
+ if sleep_for < 0 or sleep_for > 60
105
+ sleep_for = 60
106
+ end
107
+ sleep(sleep_for)
108
+ return true
109
+ end
97
110
  return err.code() == 13
98
111
  end
99
112
 
data/lib/svc.rb CHANGED
@@ -812,6 +812,7 @@ module SDM #:nodoc:
812
812
  # {MongoLegacyReplicaset}
813
813
  # {MongoReplicaSet}
814
814
  # {MongoShardedCluster}
815
+ # {MTLSMysql}
815
816
  # {MTLSPostgres}
816
817
  # {Mysql}
817
818
  # {Neptune}
data/lib/version CHANGED
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  module SDM
16
- VERSION = "2.0.0"
16
+ VERSION = "2.5.0"
17
17
  end
data/lib/version.rb CHANGED
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  module SDM
16
- VERSION = "2.0.0"
16
+ VERSION = "2.5.0"
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - strongDM Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-16 00:00:00.000000000 Z
11
+ date: 2022-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -79,8 +79,8 @@ files:
79
79
  - "./.git/logs/HEAD"
80
80
  - "./.git/logs/refs/heads/master"
81
81
  - "./.git/logs/refs/remotes/origin/HEAD"
82
- - "./.git/objects/pack/pack-799dc839a811c2fbe50b5281a9266fcc3a8f5154.idx"
83
- - "./.git/objects/pack/pack-799dc839a811c2fbe50b5281a9266fcc3a8f5154.pack"
82
+ - "./.git/objects/pack/pack-c180677ba60e518124a696667c7cc0c268db3b1a.idx"
83
+ - "./.git/objects/pack/pack-c180677ba60e518124a696667c7cc0c268db3b1a.pack"
84
84
  - "./.git/packed-refs"
85
85
  - "./.git/refs/heads/master"
86
86
  - "./.git/refs/remotes/origin/HEAD"