google-apis-core 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/google/apis/core/api_command.rb +6 -0
- data/lib/google/apis/core/storage_upload.rb +10 -1
- data/lib/google/apis/core/version.rb +1 -1
- data/lib/google/apis/options.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 583273506a9fe0af61d3973c3f3a12e1dd12bc1058285a3f6a841b8c18e8394b
|
4
|
+
data.tar.gz: c6df64e6173b2e6c1b9917b9f7f9a5a9ac5c76ff523f4e4ea69c4a0e88db6d2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84d0d6629c7c901f486e8b77382598efd3c1327a3a01bab7fd8d85e38ec767749615391b8edf00dab555721d1634dc3870190d86c33f486aa3c5aa9ad60b1d52
|
7
|
+
data.tar.gz: 2a2999bd411dd62b51c1c6a0528dd3e453e06d4bf88a58448fa3b2d0831187c5c5f708de1dd1f18da941a023e0586d3bac2a9dd68ea9a6b945737b39a76816c2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 0.9.1 (2022-10-18)
|
4
|
+
|
5
|
+
#### Bug Fixes
|
6
|
+
|
7
|
+
* Storage upload to handle empty string/file cases ([#12306](https://github.com/googleapis/google-api-ruby-client/issues/12306))
|
8
|
+
|
9
|
+
### 0.9.0 (2022-09-18)
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* add support to have invocation-id header ([#11655](https://github.com/googleapis/google-api-ruby-client/issues/11655))
|
14
|
+
|
3
15
|
### 0.8.0 (2022-09-16)
|
4
16
|
|
5
17
|
#### Features
|
@@ -18,6 +18,7 @@ require 'google/apis/core/http_command'
|
|
18
18
|
require 'google/apis/errors'
|
19
19
|
require 'json'
|
20
20
|
require 'retriable'
|
21
|
+
require "securerandom"
|
21
22
|
|
22
23
|
module Google
|
23
24
|
module Apis
|
@@ -161,6 +162,7 @@ module Google
|
|
161
162
|
xgac = "gl-ruby/#{RUBY_VERSION} gdcl/#{munged_client_version}"
|
162
163
|
xgac = old_xgac.empty? ? xgac : "#{old_xgac} #{xgac}"
|
163
164
|
header.delete_if { |k, v| k.downcase == 'x-goog-api-client' }
|
165
|
+
xgac.concat(" ",invocation_id_header) if options.add_invocation_id_header
|
164
166
|
header['X-Goog-Api-Client'] = xgac
|
165
167
|
end
|
166
168
|
|
@@ -172,6 +174,10 @@ module Google
|
|
172
174
|
header['X-Goog-User-Project'] = quota_project_id if quota_project_id
|
173
175
|
end
|
174
176
|
|
177
|
+
def invocation_id_header
|
178
|
+
"gccl-invocation-id/#{SecureRandom.uuid}"
|
179
|
+
end
|
180
|
+
|
175
181
|
# Attempt to parse a JSON error message
|
176
182
|
# @param [String] body
|
177
183
|
# HTTP response body
|
@@ -139,7 +139,7 @@ module Google
|
|
139
139
|
current_chunk_size = remaining_content_size < CHUNK_SIZE ? remaining_content_size : CHUNK_SIZE
|
140
140
|
|
141
141
|
request_header = header.dup
|
142
|
-
request_header[CONTENT_RANGE_HEADER] =
|
142
|
+
request_header[CONTENT_RANGE_HEADER] = get_content_range_header current_chunk_size
|
143
143
|
request_header[CONTENT_LENGTH_HEADER] = current_chunk_size
|
144
144
|
chunk_body = upload_io.read(current_chunk_size)
|
145
145
|
|
@@ -175,6 +175,15 @@ module Google
|
|
175
175
|
def streamable?(upload_source)
|
176
176
|
upload_source.is_a?(IO) || upload_source.is_a?(StringIO) || upload_source.is_a?(Tempfile)
|
177
177
|
end
|
178
|
+
|
179
|
+
def get_content_range_header current_chunk_size
|
180
|
+
if upload_io.size == 0
|
181
|
+
numerator = "*"
|
182
|
+
else
|
183
|
+
numerator = sprintf("%d-%d", @offset, @offset+current_chunk_size-1)
|
184
|
+
end
|
185
|
+
sprintf('bytes %s/%d', numerator, upload_io.size)
|
186
|
+
end
|
178
187
|
end
|
179
188
|
end
|
180
189
|
end
|
data/lib/google/apis/options.rb
CHANGED
@@ -39,7 +39,8 @@ module Google
|
|
39
39
|
:api_format_version,
|
40
40
|
:use_opencensus,
|
41
41
|
:quota_project,
|
42
|
-
:query
|
42
|
+
:query,
|
43
|
+
:add_invocation_id_header)
|
43
44
|
|
44
45
|
# General client options
|
45
46
|
class ClientOptions
|
@@ -95,6 +96,8 @@ module Google
|
|
95
96
|
# @return [String] Project ID to charge quota, or `nil` to default to the credentials-specified project.
|
96
97
|
# @!attribute [rw] query
|
97
98
|
# @return [Hash<String,String>] Additional HTTP URL query parameters to include in requests.
|
99
|
+
# @!attribute [rw] add_invocation_id_header
|
100
|
+
# @return [Boolean] True if the header gccl-invocation-id need to be set
|
98
101
|
|
99
102
|
# Get the default options
|
100
103
|
# @return [Google::Apis::RequestOptions]
|
@@ -129,5 +132,6 @@ module Google
|
|
129
132
|
RequestOptions.default.api_format_version = nil
|
130
133
|
RequestOptions.default.use_opencensus = true
|
131
134
|
RequestOptions.default.quota_project = nil
|
135
|
+
RequestOptions.default.add_invocation_id_header = false
|
132
136
|
end
|
133
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-apis-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: representable
|
@@ -186,7 +186,7 @@ licenses:
|
|
186
186
|
metadata:
|
187
187
|
bug_tracker_uri: https://github.com/googleapis/google-api-ruby-client/issues
|
188
188
|
changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-core/CHANGELOG.md
|
189
|
-
documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.
|
189
|
+
documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.9.1
|
190
190
|
source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-core
|
191
191
|
post_install_message:
|
192
192
|
rdoc_options: []
|