right_api_client 1.5.16 → 1.5.17

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG.md
2
2
 
3
+ ## 1.5.17
4
+ - \#61 Fix for REST client timeouts changing on redirect.
5
+ - \#61 Also added rest_client_class initializer parameter so that activity_service can use a different REST client implementation with better logging.
6
+
3
7
  ## 1.5.16
4
8
  - \#57 Sapphire added optional support for querying a (detailed) resource with params, example: client.resource(href, :view => 'full')
5
9
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- right_api_client (1.5.16)
4
+ right_api_client (1.5.17)
5
5
  json (~> 1.0)
6
6
  mime-types (~> 1.0)
7
7
  rest-client (~> 1.6)
@@ -27,7 +27,8 @@ module RightApi
27
27
  # permitted parameters for initializing
28
28
  AUTH_PARAMS = %w[
29
29
  email password_base64 password account_id api_url api_version
30
- cookies instance_token access_token timeout open_timeout max_attempts enable_retry
30
+ cookies instance_token access_token timeout open_timeout max_attempts
31
+ enable_retry rest_client_class
31
32
  ]
32
33
 
33
34
  attr_reader :cookies, :instance_token, :access_token, :last_request, :timeout, :open_timeout, :max_attempts, :enable_retry
@@ -48,7 +49,9 @@ module RightApi
48
49
 
49
50
  raise 'This API client is only compatible with the RightScale API 1.5 and upwards.' if (Float(@api_version) < 1.5)
50
51
 
51
- @rest_client = RestClient::Resource.new(@api_url, :open_timeout => @open_timeout, :timeout => @timeout)
52
+ # allow a custom resource-style REST client (for special logging, etc.)
53
+ @rest_client_class ||= ::RestClient::Resource
54
+ @rest_client = @rest_client_class.new(@api_url, :open_timeout => @open_timeout, :timeout => @timeout)
52
55
  @last_request = {}
53
56
 
54
57
  # There are four options for login:
@@ -110,9 +113,12 @@ module RightApi
110
113
  # Given a path returns a RightApiClient::Resource instance.
111
114
  #
112
115
  def resource(path, params={})
116
+ r = Resource.process_detailed(self, *do_get(path, params))
113
117
 
114
- r = Resource.process(self, *do_get(path, params))
115
-
118
+ # note that process_detailed will make a best-effort to return an already
119
+ # detailed resource or array of detailed resources but there may still be
120
+ # legacy cases where #show is still needed. calling #show on an already
121
+ # detailed resource is a no-op.
116
122
  r.respond_to?(:show) ? r.show : r
117
123
  end
118
124
 
@@ -459,7 +465,12 @@ module RightApi
459
465
  # Update the rest client url if we are redirected to another endpoint
460
466
  uri = URI.parse(response.headers[:location])
461
467
  @api_url = "#{uri.scheme}://#{uri.host}"
462
- @rest_client = RestClient::Resource.new(@api_url, :timeout => -1)
468
+
469
+ # note that the legacy code did not use the proper timeout values upon
470
+ # redirect (i.e. always set :timeout => -1) but that seems like an
471
+ # oversight; always use configured timeout values regardless of redirect.
472
+ @rest_client = @rest_client_class.new(
473
+ @api_url, :open_timeout => @open_timeout, :timeout => @timeout)
463
474
  end
464
475
  end
465
476
  end
@@ -20,6 +20,27 @@ module RightApi
20
20
  end
21
21
  end
22
22
 
23
+ # Data may already be 'detailed' (i.e. has a self-href) so avoid returning
24
+ # an undetailed resource in that case. this is because calling #show on
25
+ # the undetailed resource would generate a redundant call to
26
+ # client#do_get(...)
27
+ #
28
+ # FIX: this logic should probably be the behavior of the Resource.process()
29
+ # method but we are not willing to change legacy behavior for RightAPI v1.5.
30
+ # the RightAPI v1.6+ client should only use this logic going forward.
31
+ def self.process_detailed(client, resource_type, path, data={})
32
+ if data.kind_of?(Array)
33
+ process(client, resource_type, path, data)
34
+ else
35
+ if obj_href = client.get_href_from_links(data["links"])
36
+ ResourceDetail.new(client, resource_type, obj_href, data)
37
+ else
38
+ # no self-href means make an undetailed resource (legacy behavior).
39
+ process(client, resource_type, path, data)
40
+ end
41
+ end
42
+ end
43
+
23
44
  def inspect
24
45
  "#<#{self.class.name} " +
25
46
  "resource_type=\"#{@resource_type}\"" +
@@ -51,7 +51,8 @@ module RightApi
51
51
  # Any other method other than standard actions (create, index)
52
52
  # is simply appended to the href and called with a POST.
53
53
  def method_missing(m, *args)
54
- client.send(:do_post, [ href, m.to_s ].join('/'), *args)
54
+ # note that 'href' method is not defined on this class; use 'path' instead.
55
+ client.send(:do_post, [ path, m.to_s ].join('/'), *args)
55
56
  end
56
57
  end
57
58
  end
@@ -2,7 +2,7 @@
2
2
  module RightApi
3
3
  class Client
4
4
  API_VERSION = '1.5'
5
- CLIENT_VERSION = '16'
5
+ CLIENT_VERSION = '17'
6
6
  VERSION = "#{API_VERSION}.#{CLIENT_VERSION}"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,139 +1,161 @@
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.16
3
+ version: !ruby/object:Gem::Version
4
+ hash: 33
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 5
9
+ - 17
10
+ version: 1.5.17
5
11
  platform: ruby
6
- authors:
12
+ authors:
7
13
  - RightScale, Inc.
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: json
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
17
+
18
+ date: 2014-05-20 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
20
21
  type: :runtime
22
+ name: json
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 1
31
+ - 0
32
+ version: "1.0"
21
33
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: mime-types
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.0'
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
34
36
  type: :runtime
37
+ name: mime-types
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 15
44
+ segments:
45
+ - 1
46
+ - 0
47
+ version: "1.0"
35
48
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rest-client
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.6'
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
48
51
  type: :runtime
52
+ name: rest-client
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 1
61
+ - 6
62
+ version: "1.6"
49
63
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.6'
55
- - !ruby/object:Gem::Dependency
64
+ requirement: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ type: :development
56
67
  name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - "="
72
+ - !ruby/object:Gem::Version
73
+ hash: 49
74
+ segments:
75
+ - 0
76
+ - 8
77
+ - 7
61
78
  version: 0.8.7
62
- type: :development
63
79
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
67
- - !ruby/object:Gem::Version
68
- version: 0.8.7
69
- - !ruby/object:Gem::Dependency
80
+ requirement: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ type: :development
70
83
  name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
84
+ version_requirements: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - "="
88
+ - !ruby/object:Gem::Version
89
+ hash: 43
90
+ segments:
91
+ - 2
92
+ - 9
93
+ - 0
75
94
  version: 2.9.0
76
- type: :development
77
95
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 2.9.0
83
- - !ruby/object:Gem::Dependency
96
+ requirement: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ type: :development
84
99
  name: flexmock
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
100
+ version_requirements: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - "="
104
+ - !ruby/object:Gem::Version
105
+ hash: 49
106
+ segments:
107
+ - 0
108
+ - 8
109
+ - 7
89
110
  version: 0.8.7
90
- type: :development
91
111
  prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 0.8.7
97
- - !ruby/object:Gem::Dependency
112
+ requirement: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ type: :development
98
115
  name: simplecov
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - '='
102
- - !ruby/object:Gem::Version
116
+ version_requirements: &id007 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - "="
120
+ - !ruby/object:Gem::Version
121
+ hash: 11
122
+ segments:
123
+ - 0
124
+ - 4
125
+ - 2
103
126
  version: 0.4.2
104
- type: :development
105
127
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '='
109
- - !ruby/object:Gem::Version
110
- version: 0.4.2
111
- - !ruby/object:Gem::Dependency
112
- name: bundler
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '1.0'
128
+ requirement: *id007
129
+ - !ruby/object:Gem::Dependency
118
130
  type: :development
131
+ name: bundler
132
+ version_requirements: &id008 !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ~>
136
+ - !ruby/object:Gem::Version
137
+ hash: 15
138
+ segments:
139
+ - 1
140
+ - 0
141
+ version: "1.0"
119
142
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '1.0'
125
- description: "\nThe right_api_client gem simplifies the use of RightScale's MultiCloud
126
- API.\nIt provides a simple object model of the API resources, and handles all of
127
- the\nfine details involved in making HTTP calls and translating their responses.\n
128
- \ "
129
- email:
143
+ requirement: *id008
144
+ description: "\n\
145
+ The right_api_client gem simplifies the use of RightScale's MultiCloud API.\n\
146
+ It provides a simple object model of the API resources, and handles all of the\n\
147
+ fine details involved in making HTTP calls and translating their responses.\n "
148
+ email:
130
149
  - rubygems@rightscale.com
131
150
  executables: []
151
+
132
152
  extensions: []
153
+
133
154
  extra_rdoc_files: []
134
- files:
135
- - ".gitignore"
136
- - ".rspec"
155
+
156
+ files:
157
+ - .gitignore
158
+ - .rspec
137
159
  - CHANGELOG.md
138
160
  - Gemfile
139
161
  - Gemfile.lock
@@ -163,30 +185,39 @@ files:
163
185
  - spec/unit/resource_spec.rb
164
186
  - spec/unit/resources_spec.rb
165
187
  homepage: https://github.com/rightscale/right_api_client
166
- licenses:
188
+ licenses:
167
189
  - MIT
168
- metadata: {}
169
190
  post_install_message:
170
191
  rdoc_options: []
171
- require_paths:
192
+
193
+ require_paths:
172
194
  - lib
173
- required_ruby_version: !ruby/object:Gem::Requirement
174
- requirements:
195
+ required_ruby_version: !ruby/object:Gem::Requirement
196
+ none: false
197
+ requirements:
175
198
  - - ">="
176
- - !ruby/object:Gem::Version
177
- version: '0'
178
- required_rubygems_version: !ruby/object:Gem::Requirement
179
- requirements:
199
+ - !ruby/object:Gem::Version
200
+ hash: 3
201
+ segments:
202
+ - 0
203
+ version: "0"
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ none: false
206
+ requirements:
180
207
  - - ">="
181
- - !ruby/object:Gem::Version
182
- version: '0'
208
+ - !ruby/object:Gem::Version
209
+ hash: 3
210
+ segments:
211
+ - 0
212
+ version: "0"
183
213
  requirements: []
214
+
184
215
  rubyforge_project:
185
- rubygems_version: 2.2.2
216
+ rubygems_version: 1.8.15
186
217
  signing_key:
187
- specification_version: 4
218
+ specification_version: 3
188
219
  summary: RightScale MultiCloud API HTTP Client
189
- test_files:
220
+ test_files:
190
221
  - config/login.yml.example
191
222
  - spec/functional/audit_entries_spec.rb
192
223
  - spec/functional/client_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 2af6588a889b4481d483cab397c80441d8604792
4
- data.tar.gz: 33d1712937a923cadcfbf6a5b92e112b85d273a0
5
- SHA512:
6
- metadata.gz: bf2fbd1a63a0a699a1e5a52522088ceb9d31b54eb3bc08a670ab1d89c5ffd4fbcadfc28214284b6ae339c125affb5df05f441e84f5114f9c731bfda5ba090534
7
- data.tar.gz: 1175def15b5720a226d0097f9a27517216e5fb597a169e15bfc2e41d56869caef16aeafded911017b38704363607b6379a627dddca5fe0df6e6fce77b7ec2789