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 CHANGED
@@ -1,6 +1,10 @@
1
1
  # CHANGELOG.md
2
2
 
3
3
  ## Next
4
+ - Your info here
5
+
6
+ ## 1.5.25
7
+ - \#85 Fix bug causing useless and malformed login if client is passed an access token with no expiry timestamp
4
8
 
5
9
  ## 1.5.24
6
10
  - \#81 Pass ssl_version option of TLSv1 to rest-client
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.24
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() unless @cookies || @access_token
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 needs a fresh round of authentication based on state of
503
- # cookies/tokens and their expiration timestamps.
502
+ # Determine whether the client should login based on known state of cookies/tokens and their
503
+ # expiration timestamps.
504
504
  #
505
- # @return [Boolean] true if re-login is suggested
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
- (@refresh_token && @refresh_token_expires_at && @refresh_token_expires_at - Time.now < 900) ||
508
- (@cookies.respond_to?(:empty?) && @cookies.empty?)
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(.*Session cookie is expired or invalid)) ||
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
- version: 1.5.24
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
- date: 2014-10-17 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
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
- requirement: !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
25
+ requirements:
19
26
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.0'
22
- type: :runtime
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 1
31
+ - 0
32
+ version: "1.0"
23
33
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
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
- requirement: !ruby/object:Gem::Requirement
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
33
39
  none: false
34
- requirements:
40
+ requirements:
35
41
  - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '1.0'
38
- type: :runtime
42
+ - !ruby/object:Gem::Version
43
+ hash: 15
44
+ segments:
45
+ - 1
46
+ - 0
47
+ version: "1.0"
39
48
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
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
- requirement: !ruby/object:Gem::Requirement
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
49
54
  none: false
50
- requirements:
55
+ requirements:
51
56
  - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '1.6'
54
- type: :runtime
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 1
61
+ - 6
62
+ version: "1.6"
55
63
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
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
- requirement: !ruby/object:Gem::Requirement
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
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
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
- requirement: !ruby/object:Gem::Requirement
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
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
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
- requirement: !ruby/object:Gem::Requirement
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
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
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
- requirement: !ruby/object:Gem::Requirement
116
+ version_requirements: &id007 !ruby/object:Gem::Requirement
113
117
  none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
119
125
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
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
- extra_rdoc_files:
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
- require_paths:
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
- version: '0'
175
- segments:
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ hash: 3
176
+ segments:
176
177
  - 0
177
- hash: -2833104221795664035
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
- version: '0'
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.23
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
+