gcloud 0.6.3 → 0.7.0
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 +8 -8
- data/AUTHENTICATION.md +13 -9
- data/CHANGELOG.md +8 -3
- data/OVERVIEW.md +46 -8
- data/lib/gcloud.rb +123 -117
- data/lib/gcloud/backoff.rb +43 -15
- data/lib/gcloud/bigquery.rb +211 -195
- data/lib/gcloud/bigquery/connection.rb +9 -9
- data/lib/gcloud/bigquery/copy_job.rb +15 -16
- data/lib/gcloud/bigquery/credentials.rb +3 -3
- data/lib/gcloud/bigquery/data.rb +12 -11
- data/lib/gcloud/bigquery/dataset.rb +162 -216
- data/lib/gcloud/bigquery/dataset/access.rb +59 -43
- data/lib/gcloud/bigquery/dataset/list.rb +3 -3
- data/lib/gcloud/bigquery/errors.rb +9 -5
- data/lib/gcloud/bigquery/extract_job.rb +18 -18
- data/lib/gcloud/bigquery/insert_response.rb +7 -4
- data/lib/gcloud/bigquery/job.rb +48 -44
- data/lib/gcloud/bigquery/job/list.rb +3 -3
- data/lib/gcloud/bigquery/load_job.rb +24 -25
- data/lib/gcloud/bigquery/project.rb +145 -204
- data/lib/gcloud/bigquery/query_data.rb +10 -9
- data/lib/gcloud/bigquery/query_job.rb +23 -32
- data/lib/gcloud/bigquery/table.rb +238 -280
- data/lib/gcloud/bigquery/table/list.rb +3 -3
- data/lib/gcloud/bigquery/table/schema.rb +79 -87
- data/lib/gcloud/bigquery/view.rb +69 -82
- data/lib/gcloud/credentials.rb +3 -9
- data/lib/gcloud/datastore.rb +194 -170
- data/lib/gcloud/datastore/connection.rb +12 -8
- data/lib/gcloud/datastore/credentials.rb +6 -4
- data/lib/gcloud/datastore/dataset.rb +74 -141
- data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
- data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
- data/lib/gcloud/datastore/entity.rb +81 -76
- data/lib/gcloud/datastore/errors.rb +10 -8
- data/lib/gcloud/datastore/key.rb +41 -77
- data/lib/gcloud/datastore/properties.rb +3 -3
- data/lib/gcloud/datastore/proto.rb +7 -4
- data/lib/gcloud/datastore/query.rb +26 -3
- data/lib/gcloud/datastore/transaction.rb +12 -8
- data/lib/gcloud/dns.rb +180 -152
- data/lib/gcloud/dns/change.rb +16 -16
- data/lib/gcloud/dns/change/list.rb +3 -3
- data/lib/gcloud/dns/connection.rb +9 -10
- data/lib/gcloud/dns/credentials.rb +3 -3
- data/lib/gcloud/dns/errors.rb +9 -5
- data/lib/gcloud/dns/importer.rb +17 -23
- data/lib/gcloud/dns/project.rb +42 -64
- data/lib/gcloud/dns/record.rb +58 -46
- data/lib/gcloud/dns/record/list.rb +6 -7
- data/lib/gcloud/dns/zone.rb +198 -289
- data/lib/gcloud/dns/zone/list.rb +3 -3
- data/lib/gcloud/dns/zone/transaction.rb +56 -72
- data/lib/gcloud/errors.rb +174 -3
- data/lib/gcloud/gce.rb +3 -4
- data/lib/gcloud/grpc_utils.rb +76 -0
- data/lib/gcloud/logging.rb +308 -0
- data/lib/gcloud/logging/credentials.rb +29 -0
- data/lib/gcloud/logging/entry.rb +303 -0
- data/lib/gcloud/logging/entry/http_request.rb +141 -0
- data/lib/gcloud/logging/entry/list.rb +111 -0
- data/lib/gcloud/logging/entry/operation.rb +90 -0
- data/lib/gcloud/logging/logger.rb +307 -0
- data/lib/gcloud/logging/metric.rb +175 -0
- data/lib/gcloud/logging/metric/list.rb +98 -0
- data/lib/gcloud/logging/project.rb +650 -0
- data/lib/gcloud/logging/resource.rb +95 -0
- data/lib/gcloud/logging/resource_descriptor.rb +140 -0
- data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
- data/lib/gcloud/logging/service.rb +258 -0
- data/lib/gcloud/logging/sink.rb +233 -0
- data/lib/gcloud/logging/sink/list.rb +97 -0
- data/lib/gcloud/pubsub.rb +241 -199
- data/lib/gcloud/pubsub/credentials.rb +3 -3
- data/lib/gcloud/pubsub/message.rb +26 -20
- data/lib/gcloud/pubsub/project.rb +166 -233
- data/lib/gcloud/pubsub/received_message.rb +28 -38
- data/lib/gcloud/pubsub/service.rb +323 -0
- data/lib/gcloud/pubsub/subscription.rb +172 -242
- data/lib/gcloud/pubsub/subscription/list.rb +11 -9
- data/lib/gcloud/pubsub/topic.rb +152 -271
- data/lib/gcloud/pubsub/topic/batch.rb +66 -0
- data/lib/gcloud/pubsub/topic/list.rb +9 -7
- data/lib/gcloud/resource_manager.rb +158 -138
- data/lib/gcloud/resource_manager/connection.rb +6 -5
- data/lib/gcloud/resource_manager/credentials.rb +3 -3
- data/lib/gcloud/resource_manager/errors.rb +9 -5
- data/lib/gcloud/resource_manager/manager.rb +54 -86
- data/lib/gcloud/resource_manager/project.rb +69 -88
- data/lib/gcloud/resource_manager/project/list.rb +4 -5
- data/lib/gcloud/resource_manager/project/updater.rb +12 -14
- data/lib/gcloud/search.rb +158 -135
- data/lib/gcloud/search/api_client.rb +7 -7
- data/lib/gcloud/search/connection.rb +8 -8
- data/lib/gcloud/search/credentials.rb +3 -3
- data/lib/gcloud/search/document.rb +64 -87
- data/lib/gcloud/search/document/list.rb +5 -5
- data/lib/gcloud/search/errors.rb +9 -5
- data/lib/gcloud/search/field_value.rb +32 -38
- data/lib/gcloud/search/field_values.rb +50 -80
- data/lib/gcloud/search/fields.rb +44 -65
- data/lib/gcloud/search/index.rb +163 -204
- data/lib/gcloud/search/index/list.rb +5 -5
- data/lib/gcloud/search/project.rb +31 -47
- data/lib/gcloud/search/result.rb +27 -31
- data/lib/gcloud/search/result/list.rb +6 -6
- data/lib/gcloud/storage.rb +224 -190
- data/lib/gcloud/storage/bucket.rb +202 -227
- data/lib/gcloud/storage/bucket/acl.rb +83 -170
- data/lib/gcloud/storage/bucket/cors.rb +31 -34
- data/lib/gcloud/storage/bucket/list.rb +3 -3
- data/lib/gcloud/storage/connection.rb +11 -7
- data/lib/gcloud/storage/credentials.rb +3 -3
- data/lib/gcloud/storage/errors.rb +11 -8
- data/lib/gcloud/storage/file.rb +129 -171
- data/lib/gcloud/storage/file/acl.rb +51 -99
- data/lib/gcloud/storage/file/list.rb +3 -3
- data/lib/gcloud/storage/file/verifier.rb +3 -2
- data/lib/gcloud/storage/project.rb +111 -132
- data/lib/gcloud/upload.rb +4 -7
- data/lib/gcloud/version.rb +2 -4
- data/lib/google/api/annotations.rb +14 -0
- data/lib/google/api/http.rb +30 -0
- data/lib/google/api/label.rb +24 -0
- data/lib/google/api/monitored_resource.rb +25 -0
- data/lib/google/datastore/v1beta3/datastore.rb +115 -0
- data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
- data/lib/google/datastore/v1beta3/entity.rb +63 -0
- data/lib/google/datastore/v1beta3/query.rb +128 -0
- data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
- data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
- data/lib/google/example/library/v1/library.rb +91 -0
- data/lib/google/example/library/v1/library_services.rb +40 -0
- data/lib/google/iam/v1/iam_policy.rb +33 -0
- data/lib/google/iam/v1/iam_policy_services.rb +30 -0
- data/lib/google/iam/v1/policy.rb +25 -0
- data/lib/google/logging/type/http_request.rb +28 -0
- data/lib/google/logging/type/log_severity.rb +27 -0
- data/lib/google/logging/v2/log_entry.rb +44 -0
- data/lib/google/logging/v2/logging.rb +56 -0
- data/lib/google/logging/v2/logging_config.rb +59 -0
- data/lib/google/logging/v2/logging_config_services.rb +32 -0
- data/lib/google/logging/v2/logging_metrics.rb +51 -0
- data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
- data/lib/google/logging/v2/logging_services.rb +31 -0
- data/lib/google/longrunning/operations.rb +50 -0
- data/lib/google/longrunning/operations_services.rb +29 -0
- data/lib/google/protobuf/any.rb +17 -0
- data/lib/google/protobuf/api.rb +31 -0
- data/lib/google/protobuf/descriptor.rb +0 -0
- data/lib/google/protobuf/duration.rb +17 -0
- data/lib/google/protobuf/empty.rb +15 -0
- data/lib/google/protobuf/field_mask.rb +16 -0
- data/lib/google/protobuf/source_context.rb +16 -0
- data/lib/google/protobuf/struct.rb +35 -0
- data/lib/google/protobuf/timestamp.rb +17 -0
- data/lib/google/protobuf/type.rb +79 -0
- data/lib/google/protobuf/wrappers.rb +48 -0
- data/lib/google/pubsub/v1/pubsub.rb +129 -0
- data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
- data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
- data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
- data/lib/google/rpc/code.rb +32 -0
- data/lib/google/rpc/error_details.rb +61 -0
- data/lib/google/rpc/status.rb +19 -0
- data/lib/google/type/color.rb +20 -0
- data/lib/google/type/date.rb +18 -0
- data/lib/google/type/dayofweek.rb +23 -0
- data/lib/google/type/latlng.rb +17 -0
- data/lib/google/type/money.rb +18 -0
- data/lib/google/type/timeofday.rb +19 -0
- metadata +101 -4
- data/lib/gcloud/pubsub/connection.rb +0 -295
- data/lib/gcloud/pubsub/errors.rb +0 -93
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#--
|
|
2
1
|
# Copyright 2014 Google Inc. All rights reserved.
|
|
3
2
|
#
|
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,6 +12,7 @@
|
|
|
13
12
|
# See the License for the specific language governing permissions and
|
|
14
13
|
# limitations under the License.
|
|
15
14
|
|
|
15
|
+
|
|
16
16
|
require "gcloud/storage/bucket/acl"
|
|
17
17
|
require "gcloud/storage/bucket/list"
|
|
18
18
|
require "gcloud/storage/bucket/cors"
|
|
@@ -22,10 +22,11 @@ require "gcloud/upload"
|
|
|
22
22
|
module Gcloud
|
|
23
23
|
module Storage
|
|
24
24
|
##
|
|
25
|
-
#
|
|
25
|
+
# # Bucket
|
|
26
26
|
#
|
|
27
27
|
# Represents a Storage bucket. Belongs to a Project and has many Files.
|
|
28
28
|
#
|
|
29
|
+
# @example
|
|
29
30
|
# require "gcloud"
|
|
30
31
|
#
|
|
31
32
|
# gcloud = Gcloud.new
|
|
@@ -36,23 +37,23 @@ module Gcloud
|
|
|
36
37
|
#
|
|
37
38
|
class Bucket
|
|
38
39
|
##
|
|
39
|
-
# The Connection object.
|
|
40
|
-
attr_accessor :connection
|
|
40
|
+
# @private The Connection object.
|
|
41
|
+
attr_accessor :connection
|
|
41
42
|
|
|
42
43
|
##
|
|
43
|
-
# The Google API Client object.
|
|
44
|
-
attr_accessor :gapi
|
|
44
|
+
# @private The Google API Client object.
|
|
45
|
+
attr_accessor :gapi
|
|
45
46
|
|
|
46
47
|
##
|
|
47
|
-
# Create an empty Bucket object.
|
|
48
|
-
def initialize
|
|
48
|
+
# @private Create an empty Bucket object.
|
|
49
|
+
def initialize
|
|
49
50
|
@connection = nil
|
|
50
51
|
@gapi = {}
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
##
|
|
54
55
|
# The kind of item this is.
|
|
55
|
-
# For buckets, this is always
|
|
56
|
+
# For buckets, this is always `storage#bucket`.
|
|
56
57
|
def kind
|
|
57
58
|
@gapi["kind"]
|
|
58
59
|
end
|
|
@@ -83,19 +84,22 @@ module Gcloud
|
|
|
83
84
|
|
|
84
85
|
##
|
|
85
86
|
# Returns the current CORS configuration for a static website served from
|
|
86
|
-
# the bucket.
|
|
87
|
-
#
|
|
87
|
+
# the bucket.
|
|
88
|
+
#
|
|
88
89
|
# The return value is a frozen (unmodifiable) array of hashes containing
|
|
89
90
|
# the attributes specified for the Bucket resource field
|
|
90
|
-
#
|
|
91
|
+
# [cors](https://cloud.google.com/storage/docs/json_api/v1/buckets#cors).
|
|
91
92
|
#
|
|
92
93
|
# This method also accepts a block for updating the bucket's CORS rules.
|
|
93
|
-
# See Bucket::Cors for details.
|
|
94
|
+
# See {Bucket::Cors} for details.
|
|
94
95
|
#
|
|
95
|
-
#
|
|
96
|
+
# @see https://cloud.google.com/storage/docs/cross-origin Cross-Origin
|
|
97
|
+
# Resource Sharing (CORS)
|
|
96
98
|
#
|
|
97
|
-
#
|
|
99
|
+
# @yield [cors] a block for setting CORS rules
|
|
100
|
+
# @yieldparam [Bucket::Cors] cors the object accepting CORS rules
|
|
98
101
|
#
|
|
102
|
+
# @example Retrieving the bucket's CORS rules.
|
|
99
103
|
# require "gcloud"
|
|
100
104
|
#
|
|
101
105
|
# gcloud = Gcloud.new
|
|
@@ -107,8 +111,7 @@ module Gcloud
|
|
|
107
111
|
# # "responseHeader"=>["X-My-Custom-Header"],
|
|
108
112
|
# # "maxAgeSeconds"=>3600}]
|
|
109
113
|
#
|
|
110
|
-
# Updating the bucket's CORS rules inside a block.
|
|
111
|
-
#
|
|
114
|
+
# @example Updating the bucket's CORS rules inside a block.
|
|
112
115
|
# require "gcloud"
|
|
113
116
|
#
|
|
114
117
|
# gcloud = Gcloud.new
|
|
@@ -135,11 +138,14 @@ module Gcloud
|
|
|
135
138
|
|
|
136
139
|
##
|
|
137
140
|
# Updates the CORS configuration for a static website served from the
|
|
138
|
-
# bucket.
|
|
139
|
-
#
|
|
141
|
+
# bucket.
|
|
142
|
+
#
|
|
140
143
|
# Accepts an array of hashes containing the attributes specified for the
|
|
141
|
-
#
|
|
142
|
-
# cors
|
|
144
|
+
# [resource description of
|
|
145
|
+
# cors](https://cloud.google.com/storage/docs/json_api/v1/buckets#cors).
|
|
146
|
+
#
|
|
147
|
+
# @see https://cloud.google.com/storage/docs/cross-origin Cross-Origin
|
|
148
|
+
# Resource Sharing (CORS)
|
|
143
149
|
def cors= new_cors
|
|
144
150
|
patch_gapi! cors: new_cors
|
|
145
151
|
end
|
|
@@ -150,29 +156,36 @@ module Gcloud
|
|
|
150
156
|
# storage within this region. Defaults to US.
|
|
151
157
|
# See the developer's guide for the authoritative list.
|
|
152
158
|
#
|
|
153
|
-
# https://cloud.google.com/storage/docs/concepts-techniques
|
|
159
|
+
# @see https://cloud.google.com/storage/docs/concepts-techniques
|
|
154
160
|
def location
|
|
155
161
|
@gapi["location"]
|
|
156
162
|
end
|
|
157
163
|
|
|
158
164
|
##
|
|
159
|
-
# The destination bucket name for the bucket's logs.
|
|
160
|
-
#
|
|
165
|
+
# The destination bucket name for the bucket's logs.
|
|
166
|
+
#
|
|
167
|
+
# @see https://cloud.google.com/storage/docs/access-logs Access Logs
|
|
168
|
+
#
|
|
161
169
|
def logging_bucket
|
|
162
170
|
@gapi["logging"]["logBucket"] if @gapi["logging"]
|
|
163
171
|
end
|
|
164
172
|
|
|
165
173
|
##
|
|
166
|
-
# Updates the destination bucket for the bucket's logs.
|
|
167
|
-
#
|
|
168
|
-
#
|
|
174
|
+
# Updates the destination bucket for the bucket's logs.
|
|
175
|
+
#
|
|
176
|
+
# @see https://cloud.google.com/storage/docs/access-logs Access Logs
|
|
177
|
+
#
|
|
178
|
+
# @param [String] logging_bucket The bucket to hold the logging output
|
|
179
|
+
#
|
|
169
180
|
def logging_bucket= logging_bucket
|
|
170
181
|
patch_gapi! logging_bucket: logging_bucket
|
|
171
182
|
end
|
|
172
183
|
|
|
173
184
|
##
|
|
174
185
|
# The logging object prefix for the bucket's logs. For more information,
|
|
175
|
-
#
|
|
186
|
+
#
|
|
187
|
+
# @see https://cloud.google.com/storage/docs/access-logs Access Logs
|
|
188
|
+
#
|
|
176
189
|
def logging_prefix
|
|
177
190
|
@gapi["logging"]["logObjectPrefix"] if @gapi["logging"]
|
|
178
191
|
end
|
|
@@ -180,12 +193,13 @@ module Gcloud
|
|
|
180
193
|
##
|
|
181
194
|
# Updates the logging object prefix. This prefix will be used to create
|
|
182
195
|
# log object names for the bucket. It can be at most 900 characters and
|
|
183
|
-
# must be a
|
|
184
|
-
# name
|
|
196
|
+
# must be a [valid object
|
|
197
|
+
# name](https://cloud.google.com/storage/docs/bucket-naming#objectnames).
|
|
185
198
|
# By default, the object prefix is the name
|
|
186
|
-
# of the bucket for which the logs are enabled.
|
|
187
|
-
#
|
|
188
|
-
#
|
|
199
|
+
# of the bucket for which the logs are enabled.
|
|
200
|
+
#
|
|
201
|
+
# @see https://cloud.google.com/storage/docs/access-logs Access Logs
|
|
202
|
+
#
|
|
189
203
|
def logging_prefix= logging_prefix
|
|
190
204
|
patch_gapi! logging_prefix: logging_prefix
|
|
191
205
|
end
|
|
@@ -193,74 +207,85 @@ module Gcloud
|
|
|
193
207
|
##
|
|
194
208
|
# The bucket's storage class. This defines how objects in the bucket are
|
|
195
209
|
# stored and determines the SLA and the cost of storage. Values include
|
|
196
|
-
#
|
|
210
|
+
# `STANDARD`, `NEARLINE`, and `DURABLE_REDUCED_AVAILABILITY`.
|
|
197
211
|
def storage_class
|
|
198
212
|
@gapi["storageClass"]
|
|
199
213
|
end
|
|
200
214
|
|
|
201
215
|
##
|
|
202
|
-
# Whether
|
|
203
|
-
# Versioning
|
|
216
|
+
# Whether [Object
|
|
217
|
+
# Versioning](https://cloud.google.com/storage/docs/object-versioning) is
|
|
204
218
|
# enabled for the bucket.
|
|
205
219
|
def versioning?
|
|
206
220
|
!@gapi["versioning"].nil? && @gapi["versioning"]["enabled"]
|
|
207
221
|
end
|
|
208
222
|
|
|
209
223
|
##
|
|
210
|
-
# Updates whether
|
|
211
|
-
# Versioning
|
|
212
|
-
# enabled for the bucket.
|
|
224
|
+
# Updates whether [Object
|
|
225
|
+
# Versioning](https://cloud.google.com/storage/docs/object-versioning) is
|
|
226
|
+
# enabled for the bucket.
|
|
227
|
+
#
|
|
228
|
+
# @return [Boolean]
|
|
229
|
+
#
|
|
213
230
|
def versioning= new_versioning
|
|
214
231
|
patch_gapi! versioning: new_versioning
|
|
215
232
|
end
|
|
216
233
|
|
|
217
234
|
##
|
|
218
235
|
# The index page returned from a static website served from the bucket
|
|
219
|
-
# when a site visitor requests the top level directory.
|
|
220
|
-
#
|
|
221
|
-
#
|
|
236
|
+
# when a site visitor requests the top level directory.
|
|
237
|
+
#
|
|
238
|
+
# @see https://cloud.google.com/storage/docs/website-configuration#step4
|
|
239
|
+
# How to Host a Static Website
|
|
240
|
+
#
|
|
222
241
|
def website_main
|
|
223
242
|
@gapi["website"]["mainPageSuffix"] if @gapi["website"]
|
|
224
243
|
end
|
|
225
244
|
|
|
226
245
|
##
|
|
227
246
|
# Updates the index page returned from a static website served from the
|
|
228
|
-
# bucket when a site visitor requests the top level directory.
|
|
229
|
-
#
|
|
230
|
-
#
|
|
231
|
-
#
|
|
247
|
+
# bucket when a site visitor requests the top level directory.
|
|
248
|
+
#
|
|
249
|
+
# @see https://cloud.google.com/storage/docs/website-configuration#step4
|
|
250
|
+
# How to Host a Static Website
|
|
251
|
+
#
|
|
232
252
|
def website_main= website_main
|
|
233
253
|
patch_gapi! website_main: website_main
|
|
234
254
|
end
|
|
235
255
|
|
|
236
256
|
##
|
|
237
257
|
# The page returned from a static website served from the bucket when a
|
|
238
|
-
# site visitor requests a resource that does not exist.
|
|
239
|
-
#
|
|
240
|
-
#
|
|
258
|
+
# site visitor requests a resource that does not exist.
|
|
259
|
+
#
|
|
260
|
+
# @see https://cloud.google.com/storage/docs/website-configuration#step4
|
|
261
|
+
# How to Host a Static Website
|
|
262
|
+
#
|
|
241
263
|
def website_404
|
|
242
264
|
@gapi["website"]["notFoundPage"] if @gapi["website"]
|
|
243
265
|
end
|
|
244
266
|
|
|
245
267
|
##
|
|
246
268
|
# Updates the page returned from a static website served from the bucket
|
|
247
|
-
# when a site visitor requests a resource that does not exist.
|
|
248
|
-
#
|
|
249
|
-
#
|
|
250
|
-
#
|
|
269
|
+
# when a site visitor requests a resource that does not exist.
|
|
270
|
+
#
|
|
271
|
+
# @see https://cloud.google.com/storage/docs/website-configuration#step4
|
|
272
|
+
# How to Host a Static Website
|
|
273
|
+
#
|
|
251
274
|
def website_404= website_404
|
|
252
275
|
patch_gapi! website_404: website_404
|
|
253
276
|
end
|
|
254
277
|
|
|
255
278
|
##
|
|
256
279
|
# Updates the bucket with changes made in the given block in a single
|
|
257
|
-
# PATCH request. The following attributes may be set: #cors
|
|
258
|
-
# #logging_bucket
|
|
259
|
-
# #website_404
|
|
260
|
-
# block is completely mutable and will be
|
|
280
|
+
# PATCH request. The following attributes may be set: {#cors=},
|
|
281
|
+
# {#logging_bucket=}, {#logging_prefix=}, {#versioning=},
|
|
282
|
+
# {#website_main=}, and {#website_404=}. In addition, the #cors
|
|
283
|
+
# configuration accessible in the block is completely mutable and will be
|
|
284
|
+
# included in the request. (See {Bucket::Cors})
|
|
261
285
|
#
|
|
262
|
-
#
|
|
286
|
+
# @yield [bucket] a block yielding a delegate object for updating the file
|
|
263
287
|
#
|
|
288
|
+
# @example
|
|
264
289
|
# require "gcloud"
|
|
265
290
|
#
|
|
266
291
|
# gcloud = Gcloud.new
|
|
@@ -274,9 +299,7 @@ module Gcloud
|
|
|
274
299
|
# b.cors[1]["responseHeader"] << "X-Another-Custom-Header"
|
|
275
300
|
# end
|
|
276
301
|
#
|
|
277
|
-
# New CORS rules can also be added in a nested block
|
|
278
|
-
# details.
|
|
279
|
-
#
|
|
302
|
+
# @example New CORS rules can also be added in a nested block:
|
|
280
303
|
# require "gcloud"
|
|
281
304
|
#
|
|
282
305
|
# gcloud = Gcloud.new
|
|
@@ -302,18 +325,16 @@ module Gcloud
|
|
|
302
325
|
# Permanently deletes the bucket.
|
|
303
326
|
# The bucket must be empty before it can be deleted.
|
|
304
327
|
#
|
|
305
|
-
#
|
|
306
|
-
#
|
|
307
|
-
#
|
|
308
|
-
# The number of times the API call should be retried.
|
|
309
|
-
# Default is Gcloud::Backoff.retries. (+Integer+)
|
|
310
|
-
#
|
|
311
|
-
# === Returns
|
|
328
|
+
# The API call to delete the bucket may be retried under certain
|
|
329
|
+
# conditions. See {Gcloud::Backoff} to control this behavior, or
|
|
330
|
+
# specify the wanted behavior using the `retries` option.
|
|
312
331
|
#
|
|
313
|
-
#
|
|
332
|
+
# @param [Integer] retries The number of times the API call should be
|
|
333
|
+
# retried. Default is Gcloud::Backoff.retries.
|
|
314
334
|
#
|
|
315
|
-
#
|
|
335
|
+
# @return [Boolean] Returns `true` if the bucket was deleted.
|
|
316
336
|
#
|
|
337
|
+
# @example
|
|
317
338
|
# require "gcloud"
|
|
318
339
|
#
|
|
319
340
|
# gcloud = Gcloud.new
|
|
@@ -322,10 +343,7 @@ module Gcloud
|
|
|
322
343
|
# bucket = storage.bucket "my-bucket"
|
|
323
344
|
# bucket.delete
|
|
324
345
|
#
|
|
325
|
-
#
|
|
326
|
-
# conditions. See Gcloud::Backoff to control this behavior, or
|
|
327
|
-
# specify the wanted behavior in the call:
|
|
328
|
-
#
|
|
346
|
+
# @example Specify the number of retries to attempt:
|
|
329
347
|
# require "gcloud"
|
|
330
348
|
#
|
|
331
349
|
# gcloud = Gcloud.new
|
|
@@ -348,37 +366,28 @@ module Gcloud
|
|
|
348
366
|
##
|
|
349
367
|
# Retrieves a list of files matching the criteria.
|
|
350
368
|
#
|
|
351
|
-
#
|
|
352
|
-
#
|
|
353
|
-
#
|
|
354
|
-
#
|
|
355
|
-
#
|
|
356
|
-
#
|
|
357
|
-
#
|
|
358
|
-
#
|
|
359
|
-
#
|
|
360
|
-
#
|
|
361
|
-
#
|
|
362
|
-
#
|
|
363
|
-
#
|
|
364
|
-
#
|
|
365
|
-
#
|
|
366
|
-
#
|
|
367
|
-
#
|
|
368
|
-
#
|
|
369
|
-
#
|
|
370
|
-
#
|
|
371
|
-
#
|
|
372
|
-
#
|
|
373
|
-
# }[https://cloud.google.com/storage/docs/object-versioning].
|
|
374
|
-
# (+Boolean+)
|
|
375
|
-
#
|
|
376
|
-
# === Returns
|
|
377
|
-
#
|
|
378
|
-
# Array of Gcloud::Storage::File (See Gcloud::Storage::File::List)
|
|
379
|
-
#
|
|
380
|
-
# === Examples
|
|
381
|
-
#
|
|
369
|
+
# @param [String] prefix Filter results to files whose names begin with
|
|
370
|
+
# this prefix.
|
|
371
|
+
# @param [String] delimiter Returns results in a directory-like mode.
|
|
372
|
+
# `items` will contain only objects whose names, aside from the
|
|
373
|
+
# `prefix`, do not contain `delimiter`. Objects whose names, aside from
|
|
374
|
+
# the `prefix`, contain `delimiter` will have their name, truncated
|
|
375
|
+
# after the `delimiter`, returned in `prefixes`. Duplicate `prefixes`
|
|
376
|
+
# are omitted.
|
|
377
|
+
# @param [String] token A previously-returned page token representing part
|
|
378
|
+
# of the larger set of results to view.
|
|
379
|
+
# @param [Integer] max Maximum number of items plus prefixes to return. As
|
|
380
|
+
# duplicate prefixes are omitted, fewer total results may be returned
|
|
381
|
+
# than requested. The default value of this parameter is 1,000 items.
|
|
382
|
+
# @param [Boolean] versions If `true`, lists all versions of an object as
|
|
383
|
+
# distinct results. The default is `false`. For more information, see
|
|
384
|
+
# [Object Versioning
|
|
385
|
+
# ](https://cloud.google.com/storage/docs/object-versioning).
|
|
386
|
+
#
|
|
387
|
+
# @return [Array<Gcloud::Storage::File>] (See
|
|
388
|
+
# {Gcloud::Storage::File::List})
|
|
389
|
+
#
|
|
390
|
+
# @example
|
|
382
391
|
# require "gcloud"
|
|
383
392
|
#
|
|
384
393
|
# gcloud = Gcloud.new
|
|
@@ -390,9 +399,7 @@ module Gcloud
|
|
|
390
399
|
# puts file.name
|
|
391
400
|
# end
|
|
392
401
|
#
|
|
393
|
-
#
|
|
394
|
-
# through them: (See File::List#token)
|
|
395
|
-
#
|
|
402
|
+
# @example With pagination: (See {File::List#token})
|
|
396
403
|
# require "gcloud"
|
|
397
404
|
#
|
|
398
405
|
# gcloud = Gcloud.new
|
|
@@ -433,20 +440,13 @@ module Gcloud
|
|
|
433
440
|
##
|
|
434
441
|
# Retrieves a file matching the path.
|
|
435
442
|
#
|
|
436
|
-
#
|
|
437
|
-
#
|
|
438
|
-
#
|
|
439
|
-
# Name (path) of the file. (+String+)
|
|
440
|
-
# +generation+::
|
|
441
|
-
# When present, selects a specific revision of this object.
|
|
442
|
-
# Default is the latest version. (+Integer+)
|
|
443
|
-
#
|
|
444
|
-
# === Returns
|
|
443
|
+
# @param [String] path Name (path) of the file.
|
|
444
|
+
# @param [Integer] generation When present, selects a specific revision of
|
|
445
|
+
# this object. Default is the latest version.
|
|
445
446
|
#
|
|
446
|
-
# Gcloud::Storage::File
|
|
447
|
-
#
|
|
448
|
-
# === Example
|
|
447
|
+
# @return [Gcloud::Storage::File, nil] Returns nil if file does not exist
|
|
449
448
|
#
|
|
449
|
+
# @example
|
|
450
450
|
# require "gcloud"
|
|
451
451
|
#
|
|
452
452
|
# gcloud = Gcloud.new
|
|
@@ -473,73 +473,68 @@ module Gcloud
|
|
|
473
473
|
# Create a new File object by providing a path to a local file to upload
|
|
474
474
|
# and the path to store it with in the bucket.
|
|
475
475
|
#
|
|
476
|
-
#
|
|
476
|
+
# A `chunk_size` value can be provided in the options to be used
|
|
477
|
+
# in resumable uploads. This value is the number of bytes per
|
|
478
|
+
# chunk and must be divisible by 256KB. If it is not divisible
|
|
479
|
+
# by 256KB then it will be lowered to the nearest acceptable
|
|
480
|
+
# value.
|
|
477
481
|
#
|
|
478
|
-
#
|
|
479
|
-
#
|
|
480
|
-
#
|
|
481
|
-
#
|
|
482
|
-
# +acl+::
|
|
483
|
-
# A predefined set of access controls to apply to this file.
|
|
484
|
-
# (+String+)
|
|
482
|
+
# @param [String] file Path of the file on the filesystem to upload.
|
|
483
|
+
# @param [String] path Path to store the file in Google Cloud Storage.
|
|
484
|
+
# @param [String] acl A predefined set of access controls to apply to this
|
|
485
|
+
# file.
|
|
485
486
|
#
|
|
486
487
|
# Acceptable values are:
|
|
487
|
-
#
|
|
488
|
-
#
|
|
488
|
+
#
|
|
489
|
+
# * `auth`, `auth_read`, `authenticated`, `authenticated_read`,
|
|
490
|
+
# `authenticatedRead` - File owner gets OWNER access, and
|
|
489
491
|
# allAuthenticatedUsers get READER access.
|
|
490
|
-
# *
|
|
492
|
+
# * `owner_full`, `bucketOwnerFullControl` - File owner gets OWNER
|
|
491
493
|
# access, and project team owners get OWNER access.
|
|
492
|
-
# *
|
|
494
|
+
# * `owner_read`, `bucketOwnerRead` - File owner gets OWNER access, and
|
|
493
495
|
# project team owners get READER access.
|
|
494
|
-
# *
|
|
495
|
-
# *
|
|
496
|
+
# * `private` - File owner gets OWNER access.
|
|
497
|
+
# * `project_private`, `projectPrivate` - File owner gets OWNER access,
|
|
496
498
|
# and project team members get access according to their roles.
|
|
497
|
-
# *
|
|
499
|
+
# * `public`, `public_read`, `publicRead` - File owner gets OWNER
|
|
498
500
|
# access, and allUsers get READER access.
|
|
499
|
-
#
|
|
500
|
-
#
|
|
501
|
-
# response header to be returned when the file is downloaded.
|
|
502
|
-
#
|
|
503
|
-
#
|
|
504
|
-
# response header to be returned when the file is downloaded.
|
|
505
|
-
#
|
|
506
|
-
#
|
|
507
|
-
#
|
|
508
|
-
#
|
|
509
|
-
#
|
|
510
|
-
#
|
|
511
|
-
#
|
|
512
|
-
#
|
|
513
|
-
#
|
|
514
|
-
#
|
|
515
|
-
#
|
|
516
|
-
#
|
|
517
|
-
#
|
|
518
|
-
#
|
|
519
|
-
#
|
|
520
|
-
# The CRC32c checksum of the file data, as described in
|
|
521
|
-
# {RFC 4960, Appendix B}[http://tools.ietf.org/html/rfc4960#appendix-B].
|
|
501
|
+
# @param [String] cache_control The
|
|
502
|
+
# [Cache-Control](https://tools.ietf.org/html/rfc7234#section-5.2)
|
|
503
|
+
# response header to be returned when the file is downloaded.
|
|
504
|
+
# @param [String] content_disposition The
|
|
505
|
+
# [Content-Disposition](https://tools.ietf.org/html/rfc6266)
|
|
506
|
+
# response header to be returned when the file is downloaded.
|
|
507
|
+
# @param [String] content_encoding The [Content-Encoding
|
|
508
|
+
# ](https://tools.ietf.org/html/rfc7231#section-3.1.2.2) response header
|
|
509
|
+
# to be returned when the file is downloaded.
|
|
510
|
+
# @param [String] content_language The
|
|
511
|
+
# [Content-Language](http://tools.ietf.org/html/bcp47) response
|
|
512
|
+
# header to be returned when the file is downloaded.
|
|
513
|
+
# @param [String] content_type The
|
|
514
|
+
# [Content-Type](https://tools.ietf.org/html/rfc2616#section-14.17)
|
|
515
|
+
# response header to be returned when the file is downloaded.
|
|
516
|
+
# @param [Integer] chunk_size The number of bytes per chunk in a resumable
|
|
517
|
+
# upload. Must be divisible by 256KB. If it is not divisible by 265KB
|
|
518
|
+
# then it will be lowered to the nearest acceptable value.
|
|
519
|
+
# @param [String] crc32c The CRC32c checksum of the file data, as
|
|
520
|
+
# described in [RFC 4960, Appendix
|
|
521
|
+
# B](http://tools.ietf.org/html/rfc4960#appendix-B).
|
|
522
522
|
# If provided, Cloud Storage will only create the file if the value
|
|
523
523
|
# matches the value calculated by the service. See
|
|
524
|
-
#
|
|
525
|
-
# for more information.
|
|
526
|
-
#
|
|
527
|
-
#
|
|
528
|
-
#
|
|
529
|
-
#
|
|
530
|
-
#
|
|
531
|
-
#
|
|
532
|
-
#
|
|
533
|
-
#
|
|
534
|
-
#
|
|
535
|
-
#
|
|
536
|
-
#
|
|
537
|
-
#
|
|
538
|
-
#
|
|
539
|
-
# Gcloud::Storage::File
|
|
540
|
-
#
|
|
541
|
-
# === Examples
|
|
542
|
-
#
|
|
524
|
+
# [Validation](https://cloud.google.com/storage/docs/hashes-etags)
|
|
525
|
+
# for more information.
|
|
526
|
+
# @param [String] md5 The MD5 hash of the file data. If provided, Cloud
|
|
527
|
+
# Storage will only create the file if the value matches the value
|
|
528
|
+
# calculated by the service. See
|
|
529
|
+
# [Validation](https://cloud.google.com/storage/docs/hashes-etags) for
|
|
530
|
+
# more information.
|
|
531
|
+
# @param [Hash] metadata A hash of custom, user-provided web-safe keys and
|
|
532
|
+
# arbitrary string values that will returned with requests for the file
|
|
533
|
+
# as "x-goog-meta-" response headers.
|
|
534
|
+
#
|
|
535
|
+
# @return [Gcloud::Storage::File]
|
|
536
|
+
#
|
|
537
|
+
# @example
|
|
543
538
|
# require "gcloud"
|
|
544
539
|
#
|
|
545
540
|
# gcloud = Gcloud.new
|
|
@@ -549,8 +544,7 @@ module Gcloud
|
|
|
549
544
|
#
|
|
550
545
|
# bucket.create_file "path/to/local.file.ext"
|
|
551
546
|
#
|
|
552
|
-
# Additionally, a destination path can be specified.
|
|
553
|
-
#
|
|
547
|
+
# @example Additionally, a destination path can be specified.
|
|
554
548
|
# require "gcloud"
|
|
555
549
|
#
|
|
556
550
|
# gcloud = Gcloud.new
|
|
@@ -561,12 +555,7 @@ module Gcloud
|
|
|
561
555
|
# bucket.create_file "path/to/local.file.ext",
|
|
562
556
|
# "destination/path/file.ext"
|
|
563
557
|
#
|
|
564
|
-
#
|
|
565
|
-
# in resumable uploads. This value is the number of bytes per
|
|
566
|
-
# chunk and must be divisible by 256KB. If it is not divisible
|
|
567
|
-
# by 265KB then it will be lowered to the nearest acceptable
|
|
568
|
-
# value.
|
|
569
|
-
#
|
|
558
|
+
# @example Specify the chunk size as a number of bytes:
|
|
570
559
|
# require "gcloud"
|
|
571
560
|
#
|
|
572
561
|
# gcloud = Gcloud.new
|
|
@@ -578,29 +567,30 @@ module Gcloud
|
|
|
578
567
|
# "destination/path/file.ext",
|
|
579
568
|
# chunk_size: 1024*1024 # 1 MB chunk
|
|
580
569
|
#
|
|
581
|
-
#
|
|
570
|
+
# #### Troubleshooting large uploads
|
|
582
571
|
#
|
|
583
572
|
# You may encounter errors while attempting to upload large files. Below
|
|
584
573
|
# are a couple of common cases and their solutions.
|
|
585
574
|
#
|
|
586
|
-
#
|
|
575
|
+
# ##### Handling memory errors
|
|
587
576
|
#
|
|
588
|
-
# If you encounter a memory error such as
|
|
589
|
-
# a resumable upload and setting the
|
|
577
|
+
# If you encounter a memory error such as `NoMemoryError`, try performing
|
|
578
|
+
# a resumable upload and setting the `chunk_size` option to a value that
|
|
590
579
|
# works for your environment, as explained in the final example above.
|
|
591
580
|
#
|
|
592
|
-
#
|
|
581
|
+
# ##### Handling broken pipe errors
|
|
593
582
|
#
|
|
594
|
-
# To avoid broken pipe (
|
|
595
|
-
#
|
|
583
|
+
# To avoid broken pipe (`Errno::EPIPE`) errors when uploading, add the
|
|
584
|
+
# [httpclient](https://rubygems.org/gems/httpclient) gem to your project,
|
|
596
585
|
# and the configuration shown below. These lines must execute after you
|
|
597
586
|
# require gcloud but before you make your first gcloud connection. The
|
|
598
|
-
# first statement configures
|
|
587
|
+
# first statement configures [Faraday](https://rubygems.org/gems/faraday)
|
|
599
588
|
# to use httpclient. The second statement, which should only be added if
|
|
600
589
|
# you are using a version of Faraday at or above 0.9.2, is a workaround
|
|
601
|
-
# for
|
|
602
|
-
# issue
|
|
590
|
+
# for [this gzip
|
|
591
|
+
# issue](https://github.com/GoogleCloudPlatform/gcloud-ruby/issues/367).
|
|
603
592
|
#
|
|
593
|
+
# @example
|
|
604
594
|
# require "gcloud"
|
|
605
595
|
#
|
|
606
596
|
# # Use httpclient to avoid broken pipe errors with large uploads
|
|
@@ -639,16 +629,12 @@ module Gcloud
|
|
|
639
629
|
#
|
|
640
630
|
# A bucket has owners, writers, and readers. Permissions can be granted to
|
|
641
631
|
# an individual user's email address, a group's email address, as well as
|
|
642
|
-
# many predefined lists.
|
|
643
|
-
# {Access Control guide
|
|
644
|
-
# }[https://cloud.google.com/storage/docs/access-control]
|
|
645
|
-
# for more.
|
|
632
|
+
# many predefined lists.
|
|
646
633
|
#
|
|
647
|
-
#
|
|
648
|
-
#
|
|
649
|
-
# Access to a bucket can be granted to a user by appending +"user-"+ to
|
|
650
|
-
# the email address:
|
|
634
|
+
# @see https://cloud.google.com/storage/docs/access-control Access Control
|
|
635
|
+
# guide
|
|
651
636
|
#
|
|
637
|
+
# @example Grant access to a user by pre-pending `"user-"` to an email:
|
|
652
638
|
# require "gcloud"
|
|
653
639
|
#
|
|
654
640
|
# gcloud = Gcloud.new
|
|
@@ -659,9 +645,7 @@ module Gcloud
|
|
|
659
645
|
# email = "heidi@example.net"
|
|
660
646
|
# bucket.acl.add_reader "user-#{email}"
|
|
661
647
|
#
|
|
662
|
-
#
|
|
663
|
-
# the email address:
|
|
664
|
-
#
|
|
648
|
+
# @example Grant access to a group by pre-pending `"group-"` to an email:
|
|
665
649
|
# require "gcloud"
|
|
666
650
|
#
|
|
667
651
|
# gcloud = Gcloud.new
|
|
@@ -672,9 +656,7 @@ module Gcloud
|
|
|
672
656
|
# email = "authors@example.net"
|
|
673
657
|
# bucket.acl.add_reader "group-#{email}"
|
|
674
658
|
#
|
|
675
|
-
#
|
|
676
|
-
# permissions:
|
|
677
|
-
#
|
|
659
|
+
# @example Or, grant access via a predefined permissions list:
|
|
678
660
|
# require "gcloud"
|
|
679
661
|
#
|
|
680
662
|
# gcloud = Gcloud.new
|
|
@@ -694,16 +676,12 @@ module Gcloud
|
|
|
694
676
|
#
|
|
695
677
|
# A bucket's files have owners, writers, and readers. Permissions can be
|
|
696
678
|
# granted to an individual user's email address, a group's email address,
|
|
697
|
-
# as well as many predefined lists.
|
|
698
|
-
# {Access Control guide
|
|
699
|
-
# }[https://cloud.google.com/storage/docs/access-control]
|
|
700
|
-
# for more.
|
|
701
|
-
#
|
|
702
|
-
# === Examples
|
|
679
|
+
# as well as many predefined lists.
|
|
703
680
|
#
|
|
704
|
-
#
|
|
705
|
-
#
|
|
681
|
+
# @see https://cloud.google.com/storage/docs/access-control Access Control
|
|
682
|
+
# guide
|
|
706
683
|
#
|
|
684
|
+
# @example Grant access to a user by pre-pending `"user-"` to an email:
|
|
707
685
|
# require "gcloud"
|
|
708
686
|
#
|
|
709
687
|
# gcloud = Gcloud.new
|
|
@@ -714,9 +692,7 @@ module Gcloud
|
|
|
714
692
|
# email = "heidi@example.net"
|
|
715
693
|
# bucket.default_acl.add_reader "user-#{email}"
|
|
716
694
|
#
|
|
717
|
-
#
|
|
718
|
-
# +"group-"+ to the email address:
|
|
719
|
-
#
|
|
695
|
+
# @example Grant access to a group by pre-pending `"group-"` to an email
|
|
720
696
|
# require "gcloud"
|
|
721
697
|
#
|
|
722
698
|
# gcloud = Gcloud.new
|
|
@@ -727,9 +703,7 @@ module Gcloud
|
|
|
727
703
|
# email = "authors@example.net"
|
|
728
704
|
# bucket.default_acl.add_reader "group-#{email}"
|
|
729
705
|
#
|
|
730
|
-
#
|
|
731
|
-
# permissions:
|
|
732
|
-
#
|
|
706
|
+
# @example Or, grant access via a predefined permissions list:
|
|
733
707
|
# require "gcloud"
|
|
734
708
|
#
|
|
735
709
|
# gcloud = Gcloud.new
|
|
@@ -738,6 +712,7 @@ module Gcloud
|
|
|
738
712
|
# bucket = storage.bucket "my-todo-app"
|
|
739
713
|
#
|
|
740
714
|
# bucket.default_acl.public!
|
|
715
|
+
#
|
|
741
716
|
def default_acl
|
|
742
717
|
@default_acl ||= Bucket::DefaultAcl.new self
|
|
743
718
|
end
|
|
@@ -756,8 +731,8 @@ module Gcloud
|
|
|
756
731
|
alias_method :refresh!, :reload!
|
|
757
732
|
|
|
758
733
|
##
|
|
759
|
-
# New Bucket from a Google API Client object.
|
|
760
|
-
def self.from_gapi gapi, conn
|
|
734
|
+
# @private New Bucket from a Google API Client object.
|
|
735
|
+
def self.from_gapi gapi, conn
|
|
761
736
|
new.tap do |f|
|
|
762
737
|
f.gapi = gapi
|
|
763
738
|
f.connection = conn
|
|
@@ -790,8 +765,8 @@ module Gcloud
|
|
|
790
765
|
end
|
|
791
766
|
|
|
792
767
|
##
|
|
793
|
-
# Determines if a resumable upload should be used.
|
|
794
|
-
def resumable_upload? file
|
|
768
|
+
# @private Determines if a resumable upload should be used.
|
|
769
|
+
def resumable_upload? file
|
|
795
770
|
::File.size?(file).to_i > Upload.resumable_threshold
|
|
796
771
|
end
|
|
797
772
|
|