right_api_client 1.5.24 → 1.5.25
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +5 -0
- data/VERSION +1 -1
- data/lib/right_api_client/client.rb +23 -8
- metadata +120 -114
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -96,6 +96,11 @@ Log to STDOUT:
|
|
96
96
|
|
97
97
|
@client.log(STDOUT)
|
98
98
|
|
99
|
+
### Retrying HTTP Requests
|
100
|
+
HTTP calls can sometimes fail. To enable retrying idempotent requests automatically, enable the `:enable_retry` flag. By default, this value is `false`
|
101
|
+
|
102
|
+
@client = RightApi::Client.new(:email => 'my@email.com', :password => 'my_password', :account_id => 'my_account_id', :enable_retry => true)
|
103
|
+
|
99
104
|
### Managing multiple accounts
|
100
105
|
Multiple accounts can be managed by using the api\_url and account\_id attributes on the client.
|
101
106
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.25
|
@@ -112,7 +112,7 @@ module RightApi
|
|
112
112
|
# @return [Boolean] whether to retry idempotent requests that fail
|
113
113
|
attr_reader :enable_retry
|
114
114
|
|
115
|
-
# Instantiate a new Client.
|
115
|
+
# Instantiate a new Client, then login if necessary.
|
116
116
|
def initialize(args)
|
117
117
|
raise 'This API client is only compatible with Ruby 1.8.7 and upwards.' if (RUBY_VERSION < '1.8.7')
|
118
118
|
|
@@ -142,7 +142,7 @@ module RightApi
|
|
142
142
|
#
|
143
143
|
# The latter two options are not really login; they imply that the user logged in out of band.
|
144
144
|
# See config/login.yml.example for more info.
|
145
|
-
login()
|
145
|
+
login() if need_login?
|
146
146
|
|
147
147
|
timestamp_cookies
|
148
148
|
|
@@ -499,13 +499,28 @@ module RightApi
|
|
499
499
|
end
|
500
500
|
end
|
501
501
|
|
502
|
-
# Determine whether the client
|
503
|
-
#
|
502
|
+
# Determine whether the client should login based on known state of cookies/tokens and their
|
503
|
+
# expiration timestamps.
|
504
504
|
#
|
505
|
-
#
|
505
|
+
# If the method returns true, then the client MUST login based on known state.
|
506
|
+
#
|
507
|
+
# If the method returns false, login MAY still be required; we simply cannot determine with
|
508
|
+
# confidence that login is required. This can happen in the following cases:
|
509
|
+
# - cookie jar has cookies, but they are expired, corrupted or unrelated to auth
|
510
|
+
# - #initialize method received an access_token but no access_token_expires_at
|
511
|
+
#
|
512
|
+
# @return [Boolean] true if re-login is known to be required
|
506
513
|
def need_login?
|
507
|
-
|
508
|
-
|
514
|
+
if @access_token
|
515
|
+
# If our access token is expired and we know it...
|
516
|
+
@access_token_expires_at && @access_token_expires_at - Time.now < 900
|
517
|
+
elsif @cookies
|
518
|
+
# Or if we have a cookie jar and it's empty
|
519
|
+
@cookies.respond_to?(:empty?) && @cookies.empty?
|
520
|
+
else
|
521
|
+
# Or if we have neither cookies nor an access token (because how else can a man auth?)
|
522
|
+
true
|
523
|
+
end
|
509
524
|
end
|
510
525
|
|
511
526
|
# Determine whether an exception can be fixed by logging in again.
|
@@ -513,7 +528,7 @@ module RightApi
|
|
513
528
|
# @return [Boolean] true if re-login is appropriate
|
514
529
|
def re_login?(e)
|
515
530
|
auth_error =
|
516
|
-
(e.message.index('403') && e.message =~ %r(.*
|
531
|
+
(e.message.index('403') && e.message =~ %r(.*cookie is expired or invalid)) ||
|
517
532
|
e.message.index('401')
|
518
533
|
|
519
534
|
renewable_creds =
|
metadata
CHANGED
@@ -1,144 +1,144 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_api_client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 49
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 5
|
9
|
+
- 25
|
10
|
+
version: 1.5.25
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- RightScale, Inc.
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2014-12-17 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
type: :runtime
|
15
22
|
name: json
|
16
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
25
|
+
requirements:
|
19
26
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
22
|
-
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 15
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: "1.0"
|
23
33
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :runtime
|
31
37
|
name: mime-types
|
32
|
-
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
33
39
|
none: false
|
34
|
-
requirements:
|
40
|
+
requirements:
|
35
41
|
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
|
38
|
-
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 15
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
version: "1.0"
|
39
48
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '1.0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
49
|
+
requirement: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
type: :runtime
|
47
52
|
name: rest-client
|
48
|
-
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
49
54
|
none: false
|
50
|
-
requirements:
|
55
|
+
requirements:
|
51
56
|
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
54
|
-
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 1
|
61
|
+
- 6
|
62
|
+
version: "1.6"
|
55
63
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.6'
|
62
|
-
- !ruby/object:Gem::Dependency
|
64
|
+
requirement: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
type: :development
|
63
67
|
name: rake
|
64
|
-
|
68
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
65
69
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
70
|
+
requirements:
|
71
|
+
- - "="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 49
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
- 8
|
77
|
+
- 7
|
69
78
|
version: 0.8.7
|
70
|
-
type: :development
|
71
79
|
prerelease: false
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
- - '='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 0.8.7
|
78
|
-
- !ruby/object:Gem::Dependency
|
80
|
+
requirement: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
type: :development
|
79
83
|
name: rspec
|
80
|
-
|
84
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
81
85
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
86
|
+
requirements:
|
87
|
+
- - "="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 43
|
90
|
+
segments:
|
91
|
+
- 2
|
92
|
+
- 9
|
93
|
+
- 0
|
85
94
|
version: 2.9.0
|
86
|
-
type: :development
|
87
95
|
prerelease: false
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
- - '='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 2.9.0
|
94
|
-
- !ruby/object:Gem::Dependency
|
96
|
+
requirement: *id005
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
type: :development
|
95
99
|
name: flexmock
|
96
|
-
|
100
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
97
101
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
102
|
+
requirements:
|
103
|
+
- - "="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 49
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
- 8
|
109
|
+
- 7
|
101
110
|
version: 0.8.7
|
102
|
-
type: :development
|
103
111
|
prerelease: false
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
- - '='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 0.8.7
|
110
|
-
- !ruby/object:Gem::Dependency
|
112
|
+
requirement: *id006
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
type: :development
|
111
115
|
name: coveralls
|
112
|
-
|
116
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
113
117
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
hash: 3
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
119
125
|
prerelease: false
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
description: ! '
|
127
|
-
|
128
|
-
The right_api_client gem simplifies the use of RightScale''s MultiCloud API.
|
129
|
-
|
126
|
+
requirement: *id007
|
127
|
+
description: |
|
128
|
+
|
129
|
+
The right_api_client gem simplifies the use of RightScale's MultiCloud API.
|
130
130
|
It provides a simple object model of the API resources, and handles all of the
|
131
|
-
|
132
131
|
fine details involved in making HTTP calls and translating their responses.
|
133
132
|
|
134
|
-
'
|
135
133
|
email: rubygems@rightscale.com
|
136
134
|
executables: []
|
135
|
+
|
137
136
|
extensions: []
|
138
|
-
|
137
|
+
|
138
|
+
extra_rdoc_files:
|
139
139
|
- LICENSE.txt
|
140
140
|
- README.md
|
141
|
-
files:
|
141
|
+
files:
|
142
142
|
- .coveralls.yml
|
143
143
|
- .travis.yml
|
144
144
|
- CHANGELOG.md
|
@@ -160,31 +160,37 @@ files:
|
|
160
160
|
- login_to_client_irb.rb
|
161
161
|
- right_api_client.rconf
|
162
162
|
homepage: https://github.com/rightscale/right_api_client
|
163
|
-
licenses:
|
163
|
+
licenses:
|
164
164
|
- MIT
|
165
165
|
post_install_message:
|
166
166
|
rdoc_options: []
|
167
|
-
|
167
|
+
|
168
|
+
require_paths:
|
168
169
|
- lib
|
169
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
171
|
none: false
|
171
|
-
requirements:
|
172
|
-
- -
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
|
175
|
-
segments:
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
hash: 3
|
176
|
+
segments:
|
176
177
|
- 0
|
177
|
-
|
178
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
+
version: "0"
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
180
|
none: false
|
180
|
-
requirements:
|
181
|
-
- -
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
hash: 3
|
185
|
+
segments:
|
186
|
+
- 0
|
187
|
+
version: "0"
|
184
188
|
requirements: []
|
189
|
+
|
185
190
|
rubyforge_project:
|
186
|
-
rubygems_version: 1.8.
|
191
|
+
rubygems_version: 1.8.15
|
187
192
|
signing_key:
|
188
193
|
specification_version: 3
|
189
194
|
summary: RightScale MultiCloud API HTTP Client
|
190
195
|
test_files: []
|
196
|
+
|