google-api-client 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/google-api-client.gemspec +2 -2
- data/lib/google/api_client.rb +1 -1
- data/lib/google/api_client/auth/key_utils.rb +11 -11
- data/lib/google/api_client/auth/storage.rb +1 -0
- data/lib/google/api_client/batch.rb +22 -21
- data/lib/google/api_client/request.rb +3 -3
- data/lib/google/api_client/service/simple_file_store.rb +1 -1
- data/lib/google/api_client/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7795b17bc7f1e2d4c7392d03a199d73d65506cda
|
4
|
+
data.tar.gz: 1c34e8d5611f5a5b1420c128efdfbfd80f579a96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1f5254be2d4f3e0d71fc3b7e101301b386dfb98ed83b73df81faaa6c108bc4358afa6df17291d48bfe21a2aa8d0417f0a569a29ae20d59753dc6f83fb27cfdc
|
7
|
+
data.tar.gz: 3620bcec3013d916174af9dd30fe004f3938c33b787680bebf71bad8366878ad56172f85a017497b1bd7c60191277bfd6be525449f8844eadf452394181e5296
|
data/CHANGELOG.md
CHANGED
data/google-api-client.gemspec
CHANGED
@@ -28,11 +28,11 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_runtime_dependency 'faraday', '~> 0.9'
|
29
29
|
s.add_runtime_dependency 'googleauth', '~> 0.3'
|
30
30
|
s.add_runtime_dependency 'multi_json', '~> 1.10'
|
31
|
-
s.add_runtime_dependency 'autoparse',
|
31
|
+
s.add_runtime_dependency 'autoparse', '~> 0.3'
|
32
32
|
s.add_runtime_dependency 'extlib', '~> 0.9'
|
33
33
|
s.add_runtime_dependency 'launchy', '~> 2.4'
|
34
34
|
s.add_runtime_dependency 'retriable', '~> 1.4'
|
35
|
-
s.add_runtime_dependency 'activesupport', '
|
35
|
+
s.add_runtime_dependency 'activesupport', '~> 3.2'
|
36
36
|
|
37
37
|
s.add_development_dependency 'rake', '~> 10.0'
|
38
38
|
s.add_development_dependency 'yard', '~> 0.8'
|
data/lib/google/api_client.rb
CHANGED
@@ -25,44 +25,44 @@ module Google
|
|
25
25
|
#
|
26
26
|
# @param [String] keyfile
|
27
27
|
# Path of the PKCS12 file to load. If not a path to an actual file,
|
28
|
-
# assumes the string is the content of the file itself.
|
28
|
+
# assumes the string is the content of the file itself.
|
29
29
|
# @param [String] passphrase
|
30
30
|
# Passphrase for unlocking the private key
|
31
31
|
#
|
32
32
|
# @return [OpenSSL::PKey] The private key for signing assertions.
|
33
33
|
def self.load_from_pkcs12(keyfile, passphrase)
|
34
|
-
load_key(keyfile, passphrase) do |content,
|
35
|
-
OpenSSL::PKCS12.new(content,
|
34
|
+
load_key(keyfile, passphrase) do |content, pass_phrase|
|
35
|
+
OpenSSL::PKCS12.new(content, pass_phrase).key
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
|
40
40
|
##
|
41
41
|
# Loads a key from a PEM file.
|
42
42
|
#
|
43
43
|
# @param [String] keyfile
|
44
44
|
# Path of the PEM file to load. If not a path to an actual file,
|
45
|
-
# assumes the string is the content of the file itself.
|
45
|
+
# assumes the string is the content of the file itself.
|
46
46
|
# @param [String] passphrase
|
47
47
|
# Passphrase for unlocking the private key
|
48
48
|
#
|
49
49
|
# @return [OpenSSL::PKey] The private key for signing assertions.
|
50
50
|
#
|
51
51
|
def self.load_from_pem(keyfile, passphrase)
|
52
|
-
load_key(keyfile, passphrase) do | content,
|
53
|
-
OpenSSL::PKey::RSA.new(content,
|
52
|
+
load_key(keyfile, passphrase) do | content, pass_phrase|
|
53
|
+
OpenSSL::PKey::RSA.new(content, pass_phrase)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
private
|
58
|
-
|
58
|
+
|
59
59
|
##
|
60
60
|
# Helper for loading keys from file or memory. Accepts a block
|
61
61
|
# to handle the specific file format.
|
62
62
|
#
|
63
63
|
# @param [String] keyfile
|
64
64
|
# Path of thefile to load. If not a path to an actual file,
|
65
|
-
# assumes the string is the content of the file itself.
|
65
|
+
# assumes the string is the content of the file itself.
|
66
66
|
# @param [String] passphrase
|
67
67
|
# Passphrase for unlocking the private key
|
68
68
|
#
|
@@ -86,8 +86,8 @@ module Google
|
|
86
86
|
block.call(content, passphrase)
|
87
87
|
rescue OpenSSL::OpenSSLError
|
88
88
|
raise ArgumentError.new("Invalid keyfile or passphrase")
|
89
|
-
end
|
90
|
-
end
|
89
|
+
end
|
90
|
+
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -35,7 +35,7 @@ module Google
|
|
35
35
|
|
36
36
|
##
|
37
37
|
# Initialize the call response
|
38
|
-
#
|
38
|
+
#
|
39
39
|
# @param [String] call_id
|
40
40
|
# UUID of the original call
|
41
41
|
# @param [Fixnum] status
|
@@ -48,7 +48,7 @@ module Google
|
|
48
48
|
@call_id, @status, @headers, @body = call_id, status, headers, body
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
# Wraps multiple API calls into a single over-the-wire HTTP request.
|
53
53
|
#
|
54
54
|
# @example
|
@@ -58,7 +58,7 @@ module Google
|
|
58
58
|
# batch = Google::APIClient::BatchRequest.new do |result|
|
59
59
|
# puts result.data
|
60
60
|
# end
|
61
|
-
#
|
61
|
+
#
|
62
62
|
# batch.add(:api_method => urlshortener.url.insert, :body_object => { 'longUrl' => 'http://example.com/foo' })
|
63
63
|
# batch.add(:api_method => urlshortener.url.insert, :body_object => { 'longUrl' => 'http://example.com/bar' })
|
64
64
|
#
|
@@ -80,16 +80,17 @@ module Google
|
|
80
80
|
# Callback for every call's response. Won't be called if a call defined
|
81
81
|
# a callback of its own.
|
82
82
|
#
|
83
|
-
# @return [Google::APIClient::BatchRequest]
|
83
|
+
# @return [Google::APIClient::BatchRequest]
|
84
84
|
# The constructed object.
|
85
85
|
#
|
86
86
|
# @yield [Google::APIClient::Result]
|
87
87
|
# block to be called when result ready
|
88
88
|
def initialize(options = {}, &block)
|
89
89
|
@calls = []
|
90
|
+
@global_callback = nil
|
90
91
|
@global_callback = block if block_given?
|
91
92
|
@last_auto_id = 0
|
92
|
-
|
93
|
+
|
93
94
|
@base_id = SecureRandom.uuid
|
94
95
|
|
95
96
|
options[:uri] ||= 'https://www.googleapis.com/batch'
|
@@ -104,7 +105,7 @@ module Google
|
|
104
105
|
# automatically be generated, avoiding collisions. If duplicate call IDs
|
105
106
|
# are provided, an error will be thrown.
|
106
107
|
#
|
107
|
-
# @param [Hash, Google::APIClient::Request] call
|
108
|
+
# @param [Hash, Google::APIClient::Request] call
|
108
109
|
# the call to be added.
|
109
110
|
# @param [String] call_id
|
110
111
|
# the ID to be used for this call. Must be unique
|
@@ -126,7 +127,7 @@ module Google
|
|
126
127
|
'A call with this ID already exists: %s' % call_id
|
127
128
|
end
|
128
129
|
callback = block_given? ? block : @global_callback
|
129
|
-
@calls << [call_id, call, callback]
|
130
|
+
@calls << [call_id, call, callback]
|
130
131
|
return self
|
131
132
|
end
|
132
133
|
|
@@ -165,12 +166,12 @@ module Google
|
|
165
166
|
if @calls.nil? || @calls.empty?
|
166
167
|
raise BatchError, 'Cannot make an empty batch request'
|
167
168
|
end
|
168
|
-
parts = @calls.map {|(call_id, call,
|
169
|
+
parts = @calls.map {|(call_id, call, _callback)| serialize_call(call_id, call)}
|
169
170
|
build_multipart(parts, 'multipart/mixed', BATCH_BOUNDARY)
|
170
171
|
super
|
171
172
|
end
|
172
|
-
|
173
|
-
|
173
|
+
|
174
|
+
|
174
175
|
protected
|
175
176
|
|
176
177
|
##
|
@@ -183,7 +184,7 @@ module Google
|
|
183
184
|
# @param [Hash] headers
|
184
185
|
# the hash of headers and their values.
|
185
186
|
#
|
186
|
-
# @return [String]
|
187
|
+
# @return [String]
|
187
188
|
# the value of the desired header.
|
188
189
|
def find_header(name, headers)
|
189
190
|
_, header = headers.detect do |h, v|
|
@@ -197,7 +198,7 @@ module Google
|
|
197
198
|
#
|
198
199
|
# @api private
|
199
200
|
#
|
200
|
-
# @return [String]
|
201
|
+
# @return [String]
|
201
202
|
# the new, unique ID.
|
202
203
|
def new_id
|
203
204
|
@last_auto_id += 1
|
@@ -216,7 +217,7 @@ module Google
|
|
216
217
|
# @param [String] header
|
217
218
|
# Content-ID header value.
|
218
219
|
#
|
219
|
-
# @return [String]
|
220
|
+
# @return [String]
|
220
221
|
# The extracted ID value.
|
221
222
|
def header_to_id(header)
|
222
223
|
if !header.start_with?('<') || !header.end_with?('>') ||
|
@@ -224,7 +225,7 @@ module Google
|
|
224
225
|
raise BatchError, 'Invalid value for Content-ID: "%s"' % header
|
225
226
|
end
|
226
227
|
|
227
|
-
|
228
|
+
_base, call_id = header[1...-1].split('+')
|
228
229
|
return Addressable::URI.unencode(call_id)
|
229
230
|
end
|
230
231
|
|
@@ -236,7 +237,7 @@ module Google
|
|
236
237
|
# @param [String] response
|
237
238
|
# the response to parse.
|
238
239
|
#
|
239
|
-
# @return [Array<Hash>, String]
|
240
|
+
# @return [Array<Hash>, String]
|
240
241
|
# the headers and the body, separately.
|
241
242
|
def split_headers_and_body(response)
|
242
243
|
headers = {}
|
@@ -263,12 +264,12 @@ module Google
|
|
263
264
|
# @param [String] call_response
|
264
265
|
# the request to deserialize.
|
265
266
|
#
|
266
|
-
# @return [Google::APIClient::BatchedCallResponse]
|
267
|
+
# @return [Google::APIClient::BatchedCallResponse]
|
267
268
|
# the parsed and converted response.
|
268
269
|
def deserialize_call_response(call_response)
|
269
270
|
outer_headers, outer_body = split_headers_and_body(call_response)
|
270
271
|
status_line, payload = outer_body.split("\n", 2)
|
271
|
-
|
272
|
+
_protocol, status, _reason = status_line.split(' ', 3)
|
272
273
|
|
273
274
|
headers, body = split_headers_and_body(payload)
|
274
275
|
content_id = find_header('Content-ID', outer_headers)
|
@@ -284,7 +285,7 @@ module Google
|
|
284
285
|
# @param [Google::APIClient::Request] call
|
285
286
|
# the call to serialize.
|
286
287
|
#
|
287
|
-
# @return [Faraday::UploadIO]
|
288
|
+
# @return [Faraday::UploadIO]
|
288
289
|
# the serialized request
|
289
290
|
def serialize_call(call_id, call)
|
290
291
|
method, uri, headers, body = call.to_http_request
|
@@ -293,7 +294,7 @@ module Google
|
|
293
294
|
request << "\r\n%s: %s" % [header, value]
|
294
295
|
end
|
295
296
|
if body
|
296
|
-
# TODO - CompositeIO if body is a stream
|
297
|
+
# TODO - CompositeIO if body is a stream
|
297
298
|
request << "\r\n\r\n"
|
298
299
|
if body.respond_to?(:read)
|
299
300
|
request << body.read
|
@@ -303,7 +304,7 @@ module Google
|
|
303
304
|
end
|
304
305
|
Faraday::UploadIO.new(StringIO.new(request), 'application/http', 'ruby-api-request', 'Content-ID' => id_to_header(call_id))
|
305
306
|
end
|
306
|
-
|
307
|
+
|
307
308
|
##
|
308
309
|
# Convert an id to a Content-ID header value.
|
309
310
|
#
|
@@ -319,7 +320,7 @@ module Google
|
|
319
320
|
def id_to_header(call_id)
|
320
321
|
return '<%s+%s>' % [@base_id, Addressable::URI.encode(call_id)]
|
321
322
|
end
|
322
|
-
|
323
|
+
|
323
324
|
end
|
324
325
|
end
|
325
326
|
end
|
@@ -27,7 +27,7 @@ module Google
|
|
27
27
|
# Represents an API request.
|
28
28
|
class Request
|
29
29
|
include Google::APIClient::Logging
|
30
|
-
|
30
|
+
|
31
31
|
MULTIPART_BOUNDARY = "-----------RubyApiMultipartPost".freeze
|
32
32
|
|
33
33
|
# @return [Hash] Request parameters
|
@@ -157,7 +157,7 @@ module Google
|
|
157
157
|
# @return [Google::APIClient::Result]
|
158
158
|
# result of API request
|
159
159
|
def send(connection, is_retry = false)
|
160
|
-
self.body.rewind if is_retry && self.body.respond_to?(:rewind)
|
160
|
+
self.body.rewind if is_retry && self.body.respond_to?(:rewind)
|
161
161
|
env = self.to_env(connection)
|
162
162
|
logger.debug { "#{self.class} Sending API request #{env[:method]} #{env[:url].to_s} #{env[:request_headers]}" }
|
163
163
|
http_response = connection.app.call(env)
|
@@ -244,7 +244,7 @@ module Google
|
|
244
244
|
)
|
245
245
|
end
|
246
246
|
|
247
|
-
|
247
|
+
http_request.to_env(connection)
|
248
248
|
end
|
249
249
|
|
250
250
|
##
|
@@ -124,7 +124,7 @@ module Google
|
|
124
124
|
# Read the entire cache file from disk.
|
125
125
|
# Will avoid reading if there have been no changes.
|
126
126
|
def read_file
|
127
|
-
if !File.
|
127
|
+
if !File.exist? @file_path
|
128
128
|
@cache = nil
|
129
129
|
else
|
130
130
|
# Check for changes after our last read or write.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Aman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -141,14 +141,14 @@ dependencies:
|
|
141
141
|
name: activesupport
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- - "
|
144
|
+
- - "~>"
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '3.2'
|
147
147
|
type: :runtime
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- - "
|
151
|
+
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '3.2'
|
154
154
|
- !ruby/object:Gem::Dependency
|