gcloud 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 2015 Google Inc. All rights reserved.
|
3
2
|
#
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -13,21 +12,23 @@
|
|
13
12
|
# See the License for the specific language governing permissions and
|
14
13
|
# limitations under the License.
|
15
14
|
|
15
|
+
|
16
16
|
require "delegate"
|
17
17
|
|
18
18
|
module Gcloud
|
19
19
|
module Storage
|
20
20
|
class Bucket
|
21
21
|
##
|
22
|
-
#
|
22
|
+
# # Bucket Cors
|
23
23
|
#
|
24
24
|
# A special-case Array for managing the website CORS rules for a bucket.
|
25
|
-
# Accessed via a block argument to Project#create_bucket, Bucket#cors,
|
26
|
-
# Bucket#update.
|
25
|
+
# Accessed via a block argument to {Project#create_bucket}, {Bucket#cors},
|
26
|
+
# or {Bucket#update}.
|
27
27
|
#
|
28
|
-
#
|
29
|
-
# Sharing (CORS)
|
28
|
+
# @see https://cloud.google.com/storage/docs/cross-origin Cross-Origin
|
29
|
+
# Resource Sharing (CORS)
|
30
30
|
#
|
31
|
+
# @example
|
31
32
|
# require "gcloud"
|
32
33
|
#
|
33
34
|
# gcloud = Gcloud.new
|
@@ -47,47 +48,43 @@ module Gcloud
|
|
47
48
|
#
|
48
49
|
class Cors < DelegateClass(::Array)
|
49
50
|
##
|
51
|
+
# @private
|
50
52
|
# Initialize a new CORS rules builder with existing CORS rules, if any.
|
51
|
-
def initialize cors = []
|
53
|
+
def initialize cors = []
|
52
54
|
super cors.dup
|
53
55
|
@original = cors.dup
|
54
56
|
end
|
55
57
|
|
56
|
-
|
58
|
+
# @private
|
59
|
+
def changed?
|
57
60
|
@original != self
|
58
61
|
end
|
59
62
|
|
60
63
|
##
|
61
64
|
# Add a CORS rule to the CORS rules for a bucket. Accepts options for
|
62
65
|
# setting preflight response headers. Preflight requests and responses
|
63
|
-
# are required if the request method and headers are not both
|
64
|
-
# methods
|
65
|
-
# headers
|
66
|
-
#
|
67
|
-
# === Parameters
|
68
|
-
#
|
69
|
-
# +origin+::
|
70
|
-
# The {origin}[http://tools.ietf.org/html/rfc6454] or origins
|
71
|
-
# permitted for cross origin resource sharing with the bucket. Note:
|
72
|
-
# "*" is permitted in the list of origins, and means "any Origin".
|
73
|
-
# (+String+ or +Array+)
|
74
|
-
# +methods+::
|
75
|
-
# The list of HTTP methods permitted in cross origin resource sharing
|
76
|
-
# with the bucket. (GET, OPTIONS, POST, etc) Note: "*" is permitted in
|
77
|
-
# the list of methods, and means "any method". (+String+ or +Array+)
|
78
|
-
# +headers+::
|
79
|
-
# The list of header field names to send in the
|
80
|
-
# Access-Control-Allow-Headers header in the preflight response.
|
81
|
-
# Indicates the custom request headers that may be used in the actual
|
82
|
-
# request. (+String+ or +Array+)
|
83
|
-
# +max_age+::
|
84
|
-
# The value to send in the Access-Control-Max-Age header in the
|
85
|
-
# preflight response. Indicates how many seconds the results of a
|
86
|
-
# preflight request can be cached in a preflight result cache. The
|
87
|
-
# default value is +1800+ (30 minutes.) (+Integer+)
|
66
|
+
# are required if the request method and headers are not both [simple
|
67
|
+
# methods](http://www.w3.org/TR/cors/#simple-method) and [simple
|
68
|
+
# headers](http://www.w3.org/TR/cors/#simple-header).
|
88
69
|
#
|
89
|
-
#
|
70
|
+
# @param [String, Array<String>] origin The
|
71
|
+
# [origin](http://tools.ietf.org/html/rfc6454) or origins permitted
|
72
|
+
# for cross origin resource sharing with the bucket. Note: "*" is
|
73
|
+
# permitted in the list of origins, and means "any Origin".
|
74
|
+
# @param [String, Array<String>] methods The list of HTTP methods
|
75
|
+
# permitted in cross origin resource sharing with the bucket. (GET,
|
76
|
+
# OPTIONS, POST, etc) Note: "*" is permitted in the list of methods,
|
77
|
+
# and means "any method".
|
78
|
+
# @param [String, Array<String>] headers The list of header field names
|
79
|
+
# to send in the Access-Control-Allow-Headers header in the preflight
|
80
|
+
# response. Indicates the custom request headers that may be used in
|
81
|
+
# the actual request.
|
82
|
+
# @param [Integer] max_age The value to send in the
|
83
|
+
# Access-Control-Max-Age header in the preflight response. Indicates
|
84
|
+
# how many seconds the results of a preflight request can be cached in
|
85
|
+
# a preflight result cache. The default value is `1800` (30 minutes.)
|
90
86
|
#
|
87
|
+
# @example
|
91
88
|
# require "gcloud"
|
92
89
|
#
|
93
90
|
# gcloud = Gcloud.new
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#--
|
2
1
|
# Copyright 2015 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 "delegate"
|
17
17
|
|
18
18
|
module Gcloud
|
@@ -35,8 +35,8 @@ module Gcloud
|
|
35
35
|
end
|
36
36
|
|
37
37
|
##
|
38
|
-
# New Bucket::List from a response object.
|
39
|
-
def self.from_response resp, conn
|
38
|
+
# @private New Bucket::List from a response object.
|
39
|
+
def self.from_response resp, conn
|
40
40
|
buckets = Array(resp.data["items"]).map do |gapi_object|
|
41
41
|
Bucket.from_gapi gapi_object, conn
|
42
42
|
end
|
@@ -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 "pathname"
|
17
17
|
require "gcloud/version"
|
18
18
|
require "gcloud/backoff"
|
@@ -22,13 +22,15 @@ require "mime/types"
|
|
22
22
|
module Gcloud
|
23
23
|
module Storage
|
24
24
|
##
|
25
|
-
# Represents the connection to Storage,
|
25
|
+
# @private Represents the connection to Storage,
|
26
26
|
# as well as expose the API calls.
|
27
|
-
class Connection
|
27
|
+
class Connection
|
28
28
|
API_VERSION = "v1"
|
29
29
|
|
30
30
|
attr_accessor :project
|
31
|
-
|
31
|
+
|
32
|
+
# @private
|
33
|
+
attr_accessor :credentials
|
32
34
|
|
33
35
|
##
|
34
36
|
# Creates a new Connection instance.
|
@@ -303,7 +305,8 @@ module Gcloud
|
|
303
305
|
MIME::Types.of(path).first.to_s
|
304
306
|
end
|
305
307
|
|
306
|
-
|
308
|
+
# @private
|
309
|
+
def inspect
|
307
310
|
"#{self.class}(#{@project})"
|
308
311
|
end
|
309
312
|
|
@@ -354,7 +357,8 @@ module Gcloud
|
|
354
357
|
}.delete_if { |_, v| v.nil? } if website_main || website_404
|
355
358
|
end
|
356
359
|
|
357
|
-
|
360
|
+
# @private
|
361
|
+
def storage_class str
|
358
362
|
{ "durable_reduced_availability" => "DURABLE_REDUCED_AVAILABILITY",
|
359
363
|
"dra" => "DURABLE_REDUCED_AVAILABILITY",
|
360
364
|
"durable" => "DURABLE_REDUCED_AVAILABILITY",
|
@@ -405,7 +409,7 @@ module Gcloud
|
|
405
409
|
end
|
406
410
|
|
407
411
|
def incremental_backoff options = {}
|
408
|
-
Gcloud::Backoff.new(options).
|
412
|
+
Gcloud::Backoff.new(options).execute_gapi do
|
409
413
|
yield
|
410
414
|
end
|
411
415
|
end
|
@@ -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,13 +12,14 @@
|
|
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/credentials"
|
17
17
|
|
18
18
|
module Gcloud
|
19
19
|
module Storage
|
20
20
|
##
|
21
|
-
# Represents the OAuth 2.0 signing logic for Storage.
|
22
|
-
class Credentials < Gcloud::Credentials
|
21
|
+
# @private Represents the OAuth 2.0 signing logic for Storage.
|
22
|
+
class Credentials < Gcloud::Credentials
|
23
23
|
SCOPE = ["https://www.googleapis.com/auth/devstorage.full_control"]
|
24
24
|
PATH_ENV_VARS = %w(STORAGE_KEYFILE GCLOUD_KEYFILE GOOGLE_CLOUD_KEYFILE)
|
25
25
|
JSON_ENV_VARS = %w(STORAGE_KEYFILE_JSON GCLOUD_KEYFILE_JSON
|
@@ -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,19 +12,20 @@
|
|
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/errors"
|
17
17
|
|
18
18
|
module Gcloud
|
19
19
|
module Storage
|
20
20
|
##
|
21
|
-
#
|
21
|
+
# # Storage Error
|
22
22
|
#
|
23
23
|
# Base Storage exception class.
|
24
24
|
class Error < Gcloud::Error
|
25
25
|
end
|
26
26
|
|
27
27
|
##
|
28
|
-
#
|
28
|
+
# # ApiError
|
29
29
|
#
|
30
30
|
# Raised when an API call is not successful.
|
31
31
|
class ApiError < Error
|
@@ -43,7 +43,8 @@ module Gcloud
|
|
43
43
|
@errors = errors
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
# @private
|
47
|
+
def self.from_response resp
|
47
48
|
new resp.data["error"]["message"],
|
48
49
|
resp.data["error"]["code"],
|
49
50
|
resp.data["error"]["errors"]
|
@@ -51,7 +52,7 @@ module Gcloud
|
|
51
52
|
end
|
52
53
|
|
53
54
|
##
|
54
|
-
#
|
55
|
+
# # FileVerificationError
|
55
56
|
#
|
56
57
|
# Raised when a File download fails the verification.
|
57
58
|
class FileVerificationError < Error
|
@@ -68,7 +69,8 @@ module Gcloud
|
|
68
69
|
# The value of the digest on the downloaded file.
|
69
70
|
attr_accessor :local_digest
|
70
71
|
|
71
|
-
|
72
|
+
# @private
|
73
|
+
def self.for_md5 gcloud_digest, local_digest
|
72
74
|
new("The downloaded file failed MD5 verification.").tap do |e|
|
73
75
|
e.type = :md5
|
74
76
|
e.gcloud_digest = gcloud_digest
|
@@ -76,7 +78,8 @@ module Gcloud
|
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
79
|
-
|
81
|
+
# @private
|
82
|
+
def self.for_crc32c gcloud_digest, local_digest
|
80
83
|
new("The downloaded file failed CRC32c verification.").tap do |e|
|
81
84
|
e.type = :crc32c
|
82
85
|
e.gcloud_digest = gcloud_digest
|
@@ -86,7 +89,7 @@ module Gcloud
|
|
86
89
|
end
|
87
90
|
|
88
91
|
##
|
89
|
-
#
|
92
|
+
# # SignedUrlUnavailable Error
|
90
93
|
#
|
91
94
|
# This is raised when File#signed_url is unable to generate a URL due to
|
92
95
|
# missing credentials needed to create the URL.
|
data/lib/gcloud/storage/file.rb
CHANGED
@@ -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/file/acl"
|
17
17
|
require "gcloud/storage/file/list"
|
18
18
|
require "gcloud/storage/file/verifier"
|
@@ -20,19 +20,22 @@ require "gcloud/storage/file/verifier"
|
|
20
20
|
module Gcloud
|
21
21
|
module Storage
|
22
22
|
##
|
23
|
-
#
|
23
|
+
# # File
|
24
24
|
#
|
25
25
|
# Represents a File
|
26
|
-
# (
|
27
|
-
# belongs to a Bucket. Files (Objects) are
|
26
|
+
# ([Object](https://cloud.google.com/storage/docs/json_api/v1/objects)) that
|
27
|
+
# belongs to a {Bucket}. Files (Objects) are
|
28
28
|
# the individual pieces of data that you store in Google Cloud Storage. A
|
29
29
|
# file can be up to 5 TB in size. Files have two components:
|
30
30
|
# data and metadata. The data component is the data from an external file or
|
31
31
|
# other data source that you want to store in Google Cloud Storage. The
|
32
32
|
# metadata component is a collection of name-value pairs that describe
|
33
|
-
# various qualities of the data.
|
34
|
-
#
|
33
|
+
# various qualities of the data.
|
34
|
+
#
|
35
|
+
# @see https://cloud.google.com/storage/docs/concepts-techniques Concepts
|
36
|
+
# and Techniques
|
35
37
|
#
|
38
|
+
# @example
|
36
39
|
# require "gcloud"
|
37
40
|
#
|
38
41
|
# gcloud = Gcloud.new
|
@@ -41,20 +44,20 @@ module Gcloud
|
|
41
44
|
# bucket = storage.bucket "my-bucket"
|
42
45
|
#
|
43
46
|
# file = bucket.file "path/to/my-file.ext"
|
44
|
-
# file.download "/
|
47
|
+
# file.download "path/to/downloaded/file.ext"
|
45
48
|
#
|
46
49
|
class File
|
47
50
|
##
|
48
|
-
# The Connection object.
|
49
|
-
attr_accessor :connection
|
51
|
+
# @private The Connection object.
|
52
|
+
attr_accessor :connection
|
50
53
|
|
51
54
|
##
|
52
|
-
# The Google API Client object.
|
53
|
-
attr_accessor :gapi
|
55
|
+
# @private The Google API Client object.
|
56
|
+
attr_accessor :gapi
|
54
57
|
|
55
58
|
##
|
56
|
-
# Create an empty File object.
|
57
|
-
def initialize
|
59
|
+
# @private Create an empty File object.
|
60
|
+
def initialize
|
58
61
|
@connection = nil
|
59
62
|
@gapi = {}
|
60
63
|
end
|
@@ -79,7 +82,7 @@ module Gcloud
|
|
79
82
|
end
|
80
83
|
|
81
84
|
##
|
82
|
-
# The name of the
|
85
|
+
# The name of the {Bucket} containing this file.
|
83
86
|
def bucket
|
84
87
|
@gapi["bucket"]
|
85
88
|
end
|
@@ -140,7 +143,7 @@ module Gcloud
|
|
140
143
|
|
141
144
|
##
|
142
145
|
# The CRC32c checksum of the data, as described in
|
143
|
-
#
|
146
|
+
# [RFC 4960, Appendix B](http://tools.ietf.org/html/rfc4960#appendix-B).
|
144
147
|
# Encoded using base64 in big-endian byte order.
|
145
148
|
def crc32c
|
146
149
|
@gapi["crc32c"]
|
@@ -153,7 +156,7 @@ module Gcloud
|
|
153
156
|
end
|
154
157
|
|
155
158
|
##
|
156
|
-
# The
|
159
|
+
# The [Cache-Control](https://tools.ietf.org/html/rfc7234#section-5.2)
|
157
160
|
# directive for the file data.
|
158
161
|
def cache_control
|
159
162
|
@gapi["cacheControl"]
|
@@ -161,56 +164,56 @@ module Gcloud
|
|
161
164
|
|
162
165
|
##
|
163
166
|
# Updates the
|
164
|
-
#
|
167
|
+
# [Cache-Control](https://tools.ietf.org/html/rfc7234#section-5.2)
|
165
168
|
# directive for the file data.
|
166
169
|
def cache_control= cache_control
|
167
170
|
patch_gapi! cache_control: cache_control
|
168
171
|
end
|
169
172
|
|
170
173
|
##
|
171
|
-
# The
|
174
|
+
# The [Content-Disposition](https://tools.ietf.org/html/rfc6266) of the
|
172
175
|
# file data.
|
173
176
|
def content_disposition
|
174
177
|
@gapi["contentDisposition"]
|
175
178
|
end
|
176
179
|
|
177
180
|
##
|
178
|
-
# Updates the
|
181
|
+
# Updates the [Content-Disposition](https://tools.ietf.org/html/rfc6266)
|
179
182
|
# of the file data.
|
180
183
|
def content_disposition= content_disposition
|
181
184
|
patch_gapi! content_disposition: content_disposition
|
182
185
|
end
|
183
186
|
|
184
187
|
##
|
185
|
-
# The
|
186
|
-
#
|
188
|
+
# The [Content-Encoding
|
189
|
+
# ](https://tools.ietf.org/html/rfc7231#section-3.1.2.2) of the file data.
|
187
190
|
def content_encoding
|
188
191
|
@gapi["contentEncoding"]
|
189
192
|
end
|
190
193
|
|
191
194
|
##
|
192
|
-
# Updates the
|
193
|
-
#
|
195
|
+
# Updates the [Content-Encoding
|
196
|
+
# ](https://tools.ietf.org/html/rfc7231#section-3.1.2.2) of the file data.
|
194
197
|
def content_encoding= content_encoding
|
195
198
|
patch_gapi! content_encoding: content_encoding
|
196
199
|
end
|
197
200
|
|
198
201
|
##
|
199
|
-
# The
|
202
|
+
# The [Content-Language](http://tools.ietf.org/html/bcp47) of the file
|
200
203
|
# data.
|
201
204
|
def content_language
|
202
205
|
@gapi["contentLanguage"]
|
203
206
|
end
|
204
207
|
|
205
208
|
##
|
206
|
-
# Updates the
|
209
|
+
# Updates the [Content-Language](http://tools.ietf.org/html/bcp47) of the
|
207
210
|
# file data.
|
208
211
|
def content_language= content_language
|
209
212
|
patch_gapi! content_language: content_language
|
210
213
|
end
|
211
214
|
|
212
215
|
##
|
213
|
-
# The
|
216
|
+
# The [Content-Type](https://tools.ietf.org/html/rfc2616#section-14.17) of
|
214
217
|
# the file data.
|
215
218
|
def content_type
|
216
219
|
@gapi["contentType"]
|
@@ -218,7 +221,7 @@ module Gcloud
|
|
218
221
|
|
219
222
|
##
|
220
223
|
# Updates the
|
221
|
-
#
|
224
|
+
# [Content-Type](https://tools.ietf.org/html/rfc2616#section-14.17) of the
|
222
225
|
# file data.
|
223
226
|
def content_type= content_type
|
224
227
|
patch_gapi! content_type: content_type
|
@@ -244,13 +247,14 @@ module Gcloud
|
|
244
247
|
|
245
248
|
##
|
246
249
|
# Updates the file with changes made in the given block in a single
|
247
|
-
# PATCH request. The following attributes may be set: #cache_control
|
248
|
-
# #content_disposition
|
249
|
-
# #content_type
|
250
|
-
# block is completely mutable and will be included in the request.
|
250
|
+
# PATCH request. The following attributes may be set: {#cache_control=},
|
251
|
+
# {#content_disposition=}, {#content_encoding=}, {#content_language=},
|
252
|
+
# {#content_type=}, and {#metadata=}. The {#metadata} hash accessible in
|
253
|
+
# the block is completely mutable and will be included in the request.
|
251
254
|
#
|
252
|
-
#
|
255
|
+
# @yield [file] a block yielding a delegate object for updating the file
|
253
256
|
#
|
257
|
+
# @example
|
254
258
|
# require "gcloud"
|
255
259
|
#
|
256
260
|
# gcloud = Gcloud.new
|
@@ -279,27 +283,23 @@ module Gcloud
|
|
279
283
|
##
|
280
284
|
# Download the file's contents to a local file.
|
281
285
|
#
|
282
|
-
#
|
286
|
+
# By default, the download is verified by calculating the MD5 digest.
|
283
287
|
#
|
284
|
-
#
|
285
|
-
# The path
|
286
|
-
#
|
287
|
-
#
|
288
|
-
# The verification algoruthm used to ensure the downloaded file contents
|
289
|
-
# are correct. Default is +:md5+. (+Symbol+)
|
288
|
+
# @param [String] path The path on the local file system to write the data
|
289
|
+
# to. The path provided must be writable.
|
290
|
+
# @param [Symbol] verify The verification algoruthm used to ensure the
|
291
|
+
# downloaded file contents are correct. Default is `:md5`.
|
290
292
|
#
|
291
293
|
# Acceptable values are:
|
292
|
-
# * +md5+ - Verify file content match using the MD5 hash.
|
293
|
-
# * +crc32c+ - Verify file content match using the CRC32c hash.
|
294
|
-
# * +all+ - Perform all available file content verification.
|
295
|
-
# * +none+ - Don't perform file content verification.
|
296
294
|
#
|
297
|
-
#
|
295
|
+
# * `md5` - Verify file content match using the MD5 hash.
|
296
|
+
# * `crc32c` - Verify file content match using the CRC32c hash.
|
297
|
+
# * `all` - Perform all available file content verification.
|
298
|
+
# * `none` - Don't perform file content verification.
|
298
299
|
#
|
299
|
-
#
|
300
|
-
#
|
301
|
-
# === Examples
|
300
|
+
# @return [File] Returns a `::File` object on the local file system
|
302
301
|
#
|
302
|
+
# @example
|
303
303
|
# require "gcloud"
|
304
304
|
#
|
305
305
|
# gcloud = Gcloud.new
|
@@ -310,9 +310,7 @@ module Gcloud
|
|
310
310
|
# file = bucket.file "path/to/my-file.ext"
|
311
311
|
# file.download "path/to/downloaded/file.ext"
|
312
312
|
#
|
313
|
-
#
|
314
|
-
# The CRC32c digest can be used by passing :crc32c.
|
315
|
-
#
|
313
|
+
# @example Use the CRC32c digest by passing :crc32c.
|
316
314
|
# require "gcloud"
|
317
315
|
#
|
318
316
|
# gcloud = Gcloud.new
|
@@ -323,8 +321,7 @@ module Gcloud
|
|
323
321
|
# file = bucket.file "path/to/my-file.ext"
|
324
322
|
# file.download "path/to/downloaded/file.ext", verify: :crc32c
|
325
323
|
#
|
326
|
-
#
|
327
|
-
#
|
324
|
+
# @example Use the MD5 and CRC32c digests by passing :all.
|
328
325
|
# require "gcloud"
|
329
326
|
#
|
330
327
|
# gcloud = Gcloud.new
|
@@ -335,8 +332,7 @@ module Gcloud
|
|
335
332
|
# file = bucket.file "path/to/my-file.ext"
|
336
333
|
# file.download "path/to/downloaded/file.ext", verify: :all
|
337
334
|
#
|
338
|
-
#
|
339
|
-
#
|
335
|
+
# @example Disable the download verification by passing :none.
|
340
336
|
# require "gcloud"
|
341
337
|
#
|
342
338
|
# gcloud = Gcloud.new
|
@@ -363,43 +359,34 @@ module Gcloud
|
|
363
359
|
##
|
364
360
|
# Copy the file to a new location.
|
365
361
|
#
|
366
|
-
#
|
367
|
-
#
|
368
|
-
#
|
369
|
-
#
|
370
|
-
#
|
371
|
-
#
|
372
|
-
#
|
373
|
-
# path to copy the file to in the given bucket. (+String+)
|
374
|
-
# +acl+::
|
375
|
-
# A predefined set of access controls to apply to new file.
|
376
|
-
# (+String+)
|
362
|
+
# @param [String] dest_bucket_or_path Either the bucket to copy the file
|
363
|
+
# to, or the path to copy the file to in the current bucket.
|
364
|
+
# @param [String] dest_path If a bucket was provided in the first
|
365
|
+
# parameter, this contains the path to copy the file to in the given
|
366
|
+
# bucket.
|
367
|
+
# @param [String] acl A predefined set of access controls to apply to new
|
368
|
+
# file.
|
377
369
|
#
|
378
370
|
# Acceptable values are:
|
379
|
-
#
|
380
|
-
#
|
371
|
+
#
|
372
|
+
# * `auth`, `auth_read`, `authenticated`, `authenticated_read`,
|
373
|
+
# `authenticatedRead` - File owner gets OWNER access, and
|
381
374
|
# allAuthenticatedUsers get READER access.
|
382
|
-
# *
|
375
|
+
# * `owner_full`, `bucketOwnerFullControl` - File owner gets OWNER
|
383
376
|
# access, and project team owners get OWNER access.
|
384
|
-
# *
|
377
|
+
# * `owner_read`, `bucketOwnerRead` - File owner gets OWNER access, and
|
385
378
|
# project team owners get READER access.
|
386
|
-
# *
|
387
|
-
# *
|
379
|
+
# * `private` - File owner gets OWNER access.
|
380
|
+
# * `project_private`, `projectPrivate` - File owner gets OWNER access,
|
388
381
|
# and project team members get access according to their roles.
|
389
|
-
# *
|
382
|
+
# * `public`, `public_read`, `publicRead` - File owner gets OWNER
|
390
383
|
# access, and allUsers get READER access.
|
391
|
-
#
|
392
|
-
#
|
393
|
-
# latest version. (+Integer+)
|
394
|
-
#
|
395
|
-
# === Returns
|
396
|
-
#
|
397
|
-
# +File+ object
|
384
|
+
# @param [Integer] generation Select a specific revision of the file to
|
385
|
+
# copy. The default is the latest version.
|
398
386
|
#
|
399
|
-
#
|
400
|
-
#
|
401
|
-
# The file can also be copied to a new path in the current bucket:
|
387
|
+
# @return [Gcloud::Storage::File]
|
402
388
|
#
|
389
|
+
# @example The file can be copied to a new path in the current bucket:
|
403
390
|
# require "gcloud"
|
404
391
|
#
|
405
392
|
# gcloud = Gcloud.new
|
@@ -410,8 +397,7 @@ module Gcloud
|
|
410
397
|
# file = bucket.file "path/to/my-file.ext"
|
411
398
|
# file.copy "path/to/destination/file.ext"
|
412
399
|
#
|
413
|
-
# The file can also be copied to a different bucket:
|
414
|
-
#
|
400
|
+
# @example The file can also be copied to a different bucket:
|
415
401
|
# require "gcloud"
|
416
402
|
#
|
417
403
|
# gcloud = Gcloud.new
|
@@ -423,8 +409,7 @@ module Gcloud
|
|
423
409
|
# file.copy "new-destination-bucket",
|
424
410
|
# "path/to/destination/file.ext"
|
425
411
|
#
|
426
|
-
# The file can also be copied by specifying a generation:
|
427
|
-
#
|
412
|
+
# @example The file can also be copied by specifying a generation:
|
428
413
|
# file.copy "copy/of/previous/generation/file.ext",
|
429
414
|
# generation: 123456
|
430
415
|
#
|
@@ -446,12 +431,9 @@ module Gcloud
|
|
446
431
|
##
|
447
432
|
# Permanently deletes the file.
|
448
433
|
#
|
449
|
-
#
|
450
|
-
#
|
451
|
-
# +true+ if the file was deleted.
|
452
|
-
#
|
453
|
-
# === Example
|
434
|
+
# @return [Boolean] Returns `true` if the file was deleted.
|
454
435
|
#
|
436
|
+
# @example
|
455
437
|
# require "gcloud"
|
456
438
|
#
|
457
439
|
# gcloud = Gcloud.new
|
@@ -474,19 +456,17 @@ module Gcloud
|
|
474
456
|
|
475
457
|
##
|
476
458
|
# Public URL to access the file. If the file is not public, requests to
|
477
|
-
# the URL will return an error. (See File::Acl#public! and
|
478
|
-
# Bucket::DefaultAcl#public!)
|
479
|
-
#
|
480
|
-
#
|
481
|
-
# To share a file that is not public see #signed_url.
|
459
|
+
# the URL will return an error. (See {File::Acl#public!} and
|
460
|
+
# {Bucket::DefaultAcl#public!}) To share a file that is not public see
|
461
|
+
# {#signed_url}.
|
482
462
|
#
|
483
|
-
#
|
463
|
+
# @see https://cloud.google.com/storage/docs/access-public-data Accessing
|
464
|
+
# Public Data
|
484
465
|
#
|
485
|
-
#
|
486
|
-
#
|
487
|
-
#
|
488
|
-
# === Examples
|
466
|
+
# @param [String] protocol The protocol to use for the URL. Default is
|
467
|
+
# `HTTPS`.
|
489
468
|
#
|
469
|
+
# @example
|
490
470
|
# require "gcloud"
|
491
471
|
#
|
492
472
|
# gcloud = Gcloud.new
|
@@ -496,9 +476,7 @@ module Gcloud
|
|
496
476
|
# file = bucket.file "avatars/heidi/400x400.png"
|
497
477
|
# public_url = file.public_url
|
498
478
|
#
|
499
|
-
#
|
500
|
-
# option:
|
501
|
-
#
|
479
|
+
# @example Generate the URL with a protocol other than HTTPS:
|
502
480
|
# require "gcloud"
|
503
481
|
#
|
504
482
|
# gcloud = Gcloud.new
|
@@ -516,46 +494,41 @@ module Gcloud
|
|
516
494
|
##
|
517
495
|
# Access without authentication can be granted to a File for a specified
|
518
496
|
# period of time. This URL uses a cryptographic signature
|
519
|
-
# of your credentials to access the file.
|
520
|
-
# {Access Control Signed URLs guide
|
521
|
-
# }[https://cloud.google.com/storage/docs/access-control#Signed-URLs]
|
522
|
-
# for more.
|
497
|
+
# of your credentials to access the file.
|
523
498
|
#
|
524
499
|
# Generating a URL requires service account credentials, either by
|
525
|
-
# connecting with a service account when calling Gcloud.storage, or by
|
526
|
-
# passing in the service account
|
527
|
-
#
|
528
|
-
#
|
529
|
-
#
|
530
|
-
# https://cloud.google.com/storage/docs/authentication#service_accounts].
|
531
|
-
#
|
532
|
-
# === Parameters
|
533
|
-
#
|
534
|
-
# +method+::
|
535
|
-
# The HTTP verb to be used with the signed URL. Signed URLs can be used
|
536
|
-
# with +GET+, +HEAD+, +PUT+, and +DELETE+ requests. Default is +GET+.
|
537
|
-
# (+String+)
|
538
|
-
# +expires+::
|
539
|
-
# The number of seconds until the URL expires. Default is 300/5 minutes.
|
540
|
-
# (+Integer+)
|
541
|
-
# +content_type+::
|
542
|
-
# When provided, the client (browser) must send this value in the
|
543
|
-
# HTTP header. e.g. +text/plain+ (+String+)
|
544
|
-
# +content_md5+::
|
545
|
-
# The MD5 digest value in base64. If you provide this in the string, the
|
546
|
-
# client (usually a browser) must provide this HTTP header with this
|
547
|
-
# same value in its request. (+String+)
|
548
|
-
# +issuer+::
|
549
|
-
# Service Account's Client Email. (+String+)
|
550
|
-
# +client_email+::
|
551
|
-
# Service Account's Client Email. (+String+)
|
552
|
-
# +signing_key+::
|
553
|
-
# Service Account's Private Key. (+OpenSSL::PKey::RSA+ or +String+)
|
554
|
-
# +private_key+::
|
555
|
-
# Service Account's Private Key. (+OpenSSL::PKey::RSA+ or +String+)
|
556
|
-
#
|
557
|
-
# === Examples
|
500
|
+
# connecting with a service account when calling {Gcloud.storage}, or by
|
501
|
+
# passing in the service account `issuer` and `signing_key` values.
|
502
|
+
# Although the private key can be passed as a string for convenience,
|
503
|
+
# creating and storing an instance of `OpenSSL::PKey::RSA` is more
|
504
|
+
# efficient when making multiple calls to `signed_url`.
|
558
505
|
#
|
506
|
+
# A SignedUrlUnavailable is raised if the service account credentials are
|
507
|
+
# missing. Service account credentials are acquired by following the steps
|
508
|
+
# in [Service Account Authentication](
|
509
|
+
# https://cloud.google.com/storage/docs/authentication#service_accounts).
|
510
|
+
#
|
511
|
+
# @see https://cloud.google.com/storage/docs/access-control#Signed-URLs
|
512
|
+
# Access Control Signed URLs guide
|
513
|
+
#
|
514
|
+
# @param [String] method The HTTP verb to be used with the signed URL.
|
515
|
+
# Signed URLs can be used
|
516
|
+
# with `GET`, `HEAD`, `PUT`, and `DELETE` requests. Default is `GET`.
|
517
|
+
# @param [Integer] expires The number of seconds until the URL expires.
|
518
|
+
# Default is 300/5 minutes.
|
519
|
+
# @param [String] content_type When provided, the client (browser) must
|
520
|
+
# send this value in the HTTP header. e.g. `text/plain`
|
521
|
+
# @param [String] content_md5 The MD5 digest value in base64. If you
|
522
|
+
# provide this in the string, the client (usually a browser) must
|
523
|
+
# provide this HTTP header with this same value in its request.
|
524
|
+
# @param [String] issuer Service Account's Client Email.
|
525
|
+
# @param [String] client_email Service Account's Client Email.
|
526
|
+
# @param [OpenSSL::PKey::RSA, String] signing_key Service Account's
|
527
|
+
# Private Key.
|
528
|
+
# @param [OpenSSL::PKey::RSA, String] private_key Service Account's
|
529
|
+
# Private Key.
|
530
|
+
#
|
531
|
+
# @example
|
559
532
|
# require "gcloud"
|
560
533
|
#
|
561
534
|
# gcloud = Gcloud.new
|
@@ -565,8 +538,7 @@ module Gcloud
|
|
565
538
|
# file = bucket.file "avatars/heidi/400x400.png"
|
566
539
|
# shared_url = file.signed_url
|
567
540
|
#
|
568
|
-
# Any of the option parameters may be specified:
|
569
|
-
#
|
541
|
+
# @example Any of the option parameters may be specified:
|
570
542
|
# require "gcloud"
|
571
543
|
#
|
572
544
|
# gcloud = Gcloud.new
|
@@ -577,13 +549,7 @@ module Gcloud
|
|
577
549
|
# shared_url = file.signed_url method: "GET",
|
578
550
|
# expires: 300 # 5 minutes from now
|
579
551
|
#
|
580
|
-
#
|
581
|
-
# authenticated with a service account, those credentials can be passed in
|
582
|
-
# using the +issuer+ and +signing_key+ options. Although the private key
|
583
|
-
# can be passed as a string for convenience, creating and storing an
|
584
|
-
# instance of +OpenSSL::PKey::RSA+ is more efficient when making multiple
|
585
|
-
# calls to +signed_url+.
|
586
|
-
#
|
552
|
+
# @example Using the `issuer` and `signing_key` options:
|
587
553
|
# require "gcloud/storage"
|
588
554
|
#
|
589
555
|
# storage = Gcloud.storage
|
@@ -607,20 +573,16 @@ module Gcloud
|
|
607
573
|
end
|
608
574
|
|
609
575
|
##
|
610
|
-
# The File::Acl instance used to control access to the file.
|
576
|
+
# The {File::Acl} instance used to control access to the file.
|
611
577
|
#
|
612
578
|
# A file has owners, writers, and readers. Permissions can be granted to
|
613
579
|
# an individual user's email address, a group's email address, as well as
|
614
|
-
# many predefined lists.
|
615
|
-
# {Access Control guide
|
616
|
-
# }[https://cloud.google.com/storage/docs/access-control]
|
617
|
-
# for more.
|
580
|
+
# many predefined lists.
|
618
581
|
#
|
619
|
-
#
|
620
|
-
#
|
621
|
-
# Access to a file can be granted to a user by appending +"user-"+ to the
|
622
|
-
# email address:
|
582
|
+
# @see https://cloud.google.com/storage/docs/access-control Access Control
|
583
|
+
# guide
|
623
584
|
#
|
585
|
+
# @example Grant access to a user by pre-pending `"user-"` to an email:
|
624
586
|
# require "gcloud"
|
625
587
|
#
|
626
588
|
# gcloud = Gcloud.new
|
@@ -632,9 +594,7 @@ module Gcloud
|
|
632
594
|
# email = "heidi@example.net"
|
633
595
|
# file.acl.add_reader "user-#{email}"
|
634
596
|
#
|
635
|
-
#
|
636
|
-
# the email address:
|
637
|
-
#
|
597
|
+
# @example Grant access to a group by pre-pending `"group-"` to an email:
|
638
598
|
# require "gcloud"
|
639
599
|
#
|
640
600
|
# gcloud = Gcloud.new
|
@@ -646,9 +606,7 @@ module Gcloud
|
|
646
606
|
# email = "authors@example.net"
|
647
607
|
# file.acl.add_reader "group-#{email}"
|
648
608
|
#
|
649
|
-
#
|
650
|
-
# permissions:
|
651
|
-
#
|
609
|
+
# @example Or, grant access via a predefined permissions list:
|
652
610
|
# require "gcloud"
|
653
611
|
#
|
654
612
|
# gcloud = Gcloud.new
|
@@ -677,15 +635,15 @@ module Gcloud
|
|
677
635
|
alias_method :refresh!, :reload!
|
678
636
|
|
679
637
|
##
|
680
|
-
# URI of the location and file name in the format of
|
638
|
+
# @private URI of the location and file name in the format of
|
681
639
|
# <code>gs://my-bucket/file-name.json</code>.
|
682
|
-
def to_gs_url
|
640
|
+
def to_gs_url
|
683
641
|
"gs://#{bucket}/#{name}"
|
684
642
|
end
|
685
643
|
|
686
644
|
##
|
687
|
-
# New File from a Google API Client object.
|
688
|
-
def self.from_gapi gapi, conn
|
645
|
+
# @private New File from a Google API Client object.
|
646
|
+
def self.from_gapi gapi, conn
|
689
647
|
new.tap do |f|
|
690
648
|
f.gapi = gapi
|
691
649
|
f.connection = conn
|
@@ -733,8 +691,8 @@ module Gcloud
|
|
733
691
|
end
|
734
692
|
|
735
693
|
##
|
736
|
-
# Create a signed_url for a file.
|
737
|
-
class Signer
|
694
|
+
# @private Create a signed_url for a file.
|
695
|
+
class Signer
|
738
696
|
def initialize file
|
739
697
|
@file = file
|
740
698
|
end
|