gcloud 0.1.0 → 0.1.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.
Files changed (67) hide show
  1. checksums.yaml +13 -5
  2. data/AUTHENTICATION.md +71 -0
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +10 -15
  5. data/lib/gcloud.rb +30 -0
  6. data/lib/gcloud/backoff.rb +3 -0
  7. data/lib/gcloud/credentials.rb +47 -30
  8. data/lib/gcloud/datastore.rb +246 -15
  9. data/lib/gcloud/datastore/connection.rb +4 -2
  10. data/lib/gcloud/datastore/credentials.rb +3 -1
  11. data/lib/gcloud/datastore/dataset.rb +130 -25
  12. data/lib/gcloud/datastore/dataset/lookup_results.rb +1 -0
  13. data/lib/gcloud/datastore/dataset/query_results.rb +7 -5
  14. data/lib/gcloud/datastore/entity.rb +99 -17
  15. data/lib/gcloud/datastore/errors.rb +13 -2
  16. data/lib/gcloud/datastore/key.rb +133 -2
  17. data/lib/gcloud/datastore/properties.rb +6 -1
  18. data/lib/gcloud/datastore/proto.rb +2 -1
  19. data/lib/gcloud/datastore/query.rb +4 -4
  20. data/lib/gcloud/datastore/transaction.rb +3 -0
  21. data/lib/gcloud/storage.rb +280 -13
  22. data/lib/gcloud/storage/bucket.rb +248 -11
  23. data/lib/gcloud/storage/bucket/acl.rb +631 -4
  24. data/lib/gcloud/storage/bucket/list.rb +1 -0
  25. data/lib/gcloud/storage/connection.rb +1 -0
  26. data/lib/gcloud/storage/credentials.rb +3 -1
  27. data/lib/gcloud/storage/errors.rb +9 -1
  28. data/lib/gcloud/storage/file.rb +231 -6
  29. data/lib/gcloud/storage/file/acl.rb +365 -2
  30. data/lib/gcloud/storage/file/list.rb +1 -0
  31. data/lib/gcloud/storage/file/verifier.rb +1 -0
  32. data/lib/gcloud/storage/project.rb +119 -10
  33. data/lib/gcloud/version.rb +18 -3
  34. metadata +33 -80
  35. data/.gemtest +0 -0
  36. data/.rubocop.yml +0 -17
  37. data/Manifest.txt +0 -66
  38. data/Rakefile +0 -35
  39. data/gcloud.gemspec +0 -63
  40. data/rakelib/console.rake +0 -28
  41. data/rakelib/manifest.rake +0 -24
  42. data/rakelib/proto.rake +0 -17
  43. data/rakelib/rubocop.rake +0 -17
  44. data/rakelib/test.rake +0 -144
  45. data/test/gcloud/datastore/proto/test_cursor.rb +0 -36
  46. data/test/gcloud/datastore/proto/test_direction.rb +0 -60
  47. data/test/gcloud/datastore/proto/test_operator.rb +0 -76
  48. data/test/gcloud/datastore/proto/test_value.rb +0 -231
  49. data/test/gcloud/datastore/test_connection.rb +0 -93
  50. data/test/gcloud/datastore/test_credentials.rb +0 -38
  51. data/test/gcloud/datastore/test_dataset.rb +0 -413
  52. data/test/gcloud/datastore/test_entity.rb +0 -161
  53. data/test/gcloud/datastore/test_entity_exclude.rb +0 -225
  54. data/test/gcloud/datastore/test_key.rb +0 -189
  55. data/test/gcloud/datastore/test_query.rb +0 -271
  56. data/test/gcloud/datastore/test_transaction.rb +0 -121
  57. data/test/gcloud/storage/test_backoff.rb +0 -127
  58. data/test/gcloud/storage/test_bucket.rb +0 -270
  59. data/test/gcloud/storage/test_bucket_acl.rb +0 -253
  60. data/test/gcloud/storage/test_default_acl.rb +0 -256
  61. data/test/gcloud/storage/test_file.rb +0 -221
  62. data/test/gcloud/storage/test_file_acl.rb +0 -367
  63. data/test/gcloud/storage/test_project.rb +0 -180
  64. data/test/gcloud/storage/test_storage.rb +0 -29
  65. data/test/gcloud/storage/test_verifier.rb +0 -62
  66. data/test/gcloud/test_version.rb +0 -8
  67. data/test/helper.rb +0 -91
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2014 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,16 +18,22 @@ require "gcloud"
17
18
  module Gcloud
18
19
  module Datastore
19
20
  ##
21
+ # = Datastore Error
22
+ #
20
23
  # Base Datastore exception class.
21
24
  class Error < Gcloud::Error
22
25
  end
23
26
 
24
27
  ##
28
+ # = KeyfileError
29
+ #
25
30
  # Raised when a keyfile is not correct.
26
31
  class KeyfileError < Gcloud::Datastore::Error
27
32
  end
28
33
 
29
34
  ##
35
+ # = ApiError
36
+ #
30
37
  # Raised when an API call is not successful.
31
38
  class ApiError < Gcloud::Datastore::Error
32
39
  ##
@@ -37,7 +44,7 @@ module Gcloud
37
44
  # The response object of the failed HTTP request.
38
45
  attr_reader :response
39
46
 
40
- def initialize method, response = nil
47
+ def initialize method, response = nil #:nodoc:
41
48
  super("API call to #{method} was not successful")
42
49
  @method = method
43
50
  @response = response
@@ -45,18 +52,22 @@ module Gcloud
45
52
  end
46
53
 
47
54
  ##
55
+ # = PropertyError
56
+ #
48
57
  # Raised when a property is not correct.
49
58
  class PropertyError < Gcloud::Datastore::Error
50
59
  end
51
60
 
52
61
  ##
62
+ # = TransactionError
63
+ #
53
64
  # General error for Transaction problems.
54
65
  class TransactionError < Gcloud::Datastore::Error
55
66
  ##
56
67
  # An error that occurred within the transaction. (optional)
57
68
  attr_reader :inner
58
69
 
59
- def initialize message, inner = nil
70
+ def initialize message, inner = nil #:nodoc:
60
71
  super(message)
61
72
  @inner = inner
62
73
  end
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2014 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +18,7 @@ require "gcloud/datastore/proto"
17
18
  module Gcloud
18
19
  module Datastore
19
20
  ##
20
- # Datastore Key
21
+ # = Key
21
22
  #
22
23
  # Every Datastore record has an identifying key, which includes the record's
23
24
  # entity kind and a unique identifier. The identifier may be either a key
@@ -28,14 +29,55 @@ module Gcloud
28
29
  class Key
29
30
  ##
30
31
  # The kind of the Key.
32
+ #
33
+ # === Returns
34
+ #
35
+ # +String+
36
+ #
37
+ # === Example
38
+ #
39
+ # key = Gcloud::Datastore::Key.new "User"
40
+ # key.kind #=> "User"
41
+ # key.kind = "Task"
42
+ #
31
43
  attr_accessor :kind
32
44
 
33
45
  ##
34
46
  # The dataset_id of the Key.
47
+ #
48
+ # === Returns
49
+ #
50
+ # +String+
51
+ #
52
+ # === Example
53
+ #
54
+ # require "glcoud/datastore"
55
+ #
56
+ # dataset = Gcloud.datastore "my-todo-project",
57
+ # "/path/to/keyfile.json"
58
+ #
59
+ # entity = dataset.find "User", "heidi"
60
+ # entity.key.dataset_id #=> "my-todo-project"
61
+ #
35
62
  attr_accessor :dataset_id
36
63
 
37
64
  ##
38
65
  # The namespace of the Key.
66
+ #
67
+ # === Returns
68
+ #
69
+ # +String+ or +nil+
70
+ #
71
+ # === Example
72
+ #
73
+ # require "glcoud/datastore"
74
+ #
75
+ # dataset = Gcloud.datastore "my-todo-project",
76
+ # "/path/to/keyfile.json"
77
+ #
78
+ # entity = dataset.find "User", "heidi"
79
+ # entity.key.namespace #=> "ns~todo-project"
80
+ #
39
81
  attr_accessor :namespace
40
82
 
41
83
  def initialize kind = nil, id_or_name = nil
@@ -50,6 +92,20 @@ module Gcloud
50
92
  ##
51
93
  # Set the id of the Key.
52
94
  # If a name is already present it will be removed.
95
+ #
96
+ # === Returns
97
+ #
98
+ # +Integer+ or +nil+
99
+ #
100
+ # === Example
101
+ #
102
+ # key = Gcloud::Datastore::Key.new "User", "heidi"
103
+ # key.id #=> nil
104
+ # key.name #=> "heidi"
105
+ # key.id = 654321
106
+ # key.id #=> 654321
107
+ # key.name #=> nil
108
+ #
53
109
  def id= new_id #:nodoc:
54
110
  @name = nil if new_id
55
111
  @id = new_id
@@ -57,11 +113,35 @@ module Gcloud
57
113
 
58
114
  ##
59
115
  # The id of the Key.
116
+ #
117
+ # === Returns
118
+ #
119
+ # +Integer+ or +nil+
120
+ #
121
+ # === Example
122
+ #
123
+ # key = Gcloud::Datastore::Key.new "User", 123456
124
+ # key.id #=> 123456
125
+ #
60
126
  attr_reader :id
61
127
 
62
128
  ##
63
129
  # Set the name of the Key.
64
130
  # If an id is already present it will be removed.
131
+ #
132
+ # === Returns
133
+ #
134
+ # +String+ or +nil+
135
+ #
136
+ # === Example
137
+ #
138
+ # key = Gcloud::Datastore::Key.new "User", 123456
139
+ # key.id #=> 123456
140
+ # key.name #=> nil
141
+ # key.name = "heidi"
142
+ # key.id #=> nil
143
+ # key.name #=> "heidi"
144
+ #
65
145
  def name= new_name #:nodoc:
66
146
  @id = nil if new_name
67
147
  @name = new_name
@@ -69,10 +149,30 @@ module Gcloud
69
149
 
70
150
  ##
71
151
  # The name of the Key.
152
+ #
153
+ # === Returns
154
+ #
155
+ # +String+ or +nil+
156
+ #
157
+ # === Example
158
+ #
159
+ # key = Gcloud::Datastore::Key.new "User", "heidi"
160
+ # key.name #=> "heidi"
161
+ #
72
162
  attr_reader :name
73
163
 
74
164
  ##
75
165
  # Set the parent of the Key.
166
+ #
167
+ # === Returns
168
+ #
169
+ # +Key+ or +nil+
170
+ #
171
+ # === Example
172
+ #
173
+ # key = Gcloud::Datastore::Key.new "List", "todos"
174
+ # key.parent = Gcloud::Datastore::Key.new "User", "heidi"
175
+ #
76
176
  def parent= new_parent #:nodoc:
77
177
  # store key if given an entity
78
178
  new_parent = new_parent.key if new_parent.respond_to? :key
@@ -81,6 +181,24 @@ module Gcloud
81
181
 
82
182
  ##
83
183
  # The parent of the Key.
184
+ #
185
+ # === Returns
186
+ #
187
+ # +Key+ or +nil+
188
+ #
189
+ # === Example
190
+ #
191
+ # require "glcoud/datastore"
192
+ #
193
+ # dataset = Gcloud.datastore
194
+ #
195
+ # user = dataset.find "User", "heidi"
196
+ # query = Gcloud::Datastore::Query.new
197
+ # query.kind("List").
198
+ # ancestor(user.key)
199
+ # lists = dataset.run query
200
+ # lists.first.key.parent #=> Key("User", "heidi")
201
+ #
84
202
  attr_reader :parent
85
203
 
86
204
  ##
@@ -88,7 +206,16 @@ module Gcloud
88
206
  # Each inner array contains two values, the kind and the id or name.
89
207
  # If neither an id or name exist then nil will be returned.
90
208
  #
91
- # puts key.path #=> [["Person", "username"], ["Task", 123456]]
209
+ # === Returns
210
+ #
211
+ # Array of arrays
212
+ #
213
+ # === Example
214
+ #
215
+ # key = Gcloud::Datastore::Key.new "List", "todos"
216
+ # key.parent = Gcloud::Datastore::Key.new "User", "heidi"
217
+ # key.path #=> [["User", "heidi"], ["List", "todos"]]
218
+ #
92
219
  def path
93
220
  new_path = parent ? parent.path : []
94
221
  new_path << [kind, (id || name)]
@@ -97,6 +224,8 @@ module Gcloud
97
224
  ##
98
225
  # Determine if the key is complete.
99
226
  # A complete key has either an id or a name.
227
+ #
228
+ # Inverse of #incomplete?
100
229
  def complete?
101
230
  !incomplete?
102
231
  end
@@ -104,6 +233,8 @@ module Gcloud
104
233
  ##
105
234
  # Determine if the key is incomplete.
106
235
  # An incomplete key has neither an id nor a name.
236
+ #
237
+ # Inverse of #complete?
107
238
  def incomplete?
108
239
  kind.nil? || (id.nil? && (name.nil? || name.empty?))
109
240
  end
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2015 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +16,11 @@
15
16
  module Gcloud
16
17
  module Datastore
17
18
  ##
18
- # Properties
19
+ # = Properties
20
+ #
21
+ # Hash-like data structure for Datastore properties.
22
+ #
23
+ # See Entity#properties
19
24
  class Properties
20
25
  def initialize properties = {}
21
26
  @hash = {}
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2014 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -241,7 +242,7 @@ module Gcloud
241
242
  end
242
243
  end
243
244
 
244
- class Key
245
+ class Key #:nodoc:
245
246
  def dup
246
247
  proto_request_body = ""
247
248
  self.encode proto_request_body
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2014 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +20,9 @@ require "gcloud/datastore/proto"
19
20
  module Gcloud
20
21
  module Datastore
21
22
  ##
22
- # Query represents a query to be made to the Datastore.
23
+ # = Query
24
+ #
25
+ # Represents the search criteria against a Datastore.
23
26
  #
24
27
  # query = Gcloud::Datastore::Query.new
25
28
  # query.kind("Task").
@@ -178,12 +181,9 @@ module Gcloud
178
181
  self
179
182
  end
180
183
 
181
- # rubocop:disable Style/TrivialAccessors
182
184
  def to_proto #:nodoc:
183
- # Disabled rubocop because this implementation will most likely change.
184
185
  @_query
185
186
  end
186
- # rubocop:enable Style/TrivialAccessors
187
187
  end
188
188
  end
189
189
  end
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2014 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +16,8 @@
15
16
  module Gcloud
16
17
  module Datastore
17
18
  ##
19
+ # = Transaction
20
+ #
18
21
  # Special Connection instance for running transactions.
19
22
  #
20
23
  # See Gcloud::Datastore::Dataset.transaction
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2014 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,26 +16,38 @@
15
16
  require "gcloud"
16
17
  require "gcloud/storage/project"
17
18
 
18
- ##
19
+ #--
19
20
  # Google Cloud Storage
20
21
  module Gcloud
21
22
  ##
22
- # Create a new Storage project.
23
+ # Creates a new object for connecting to the Storage service.
24
+ # Each call creates a new connection.
25
+ #
26
+ # === Parameters
27
+ #
28
+ # +project+::
29
+ # Project identifier for the Storage service you are connecting to.
30
+ # (+String+)
31
+ # +keyfile+::
32
+ # Keyfile downloaded from Google Cloud. If file path the file must be
33
+ # readable. (+String+ or +Hash+)
34
+ #
35
+ # === Returns
36
+ #
37
+ # Gcloud::Storage::Project
38
+ #
39
+ # === Example
40
+ #
41
+ # require "glcoud/storage"
23
42
  #
24
43
  # storage = Gcloud.storage "my-todo-project",
25
44
  # "/path/to/keyfile.json"
45
+ #
26
46
  # bucket = storage.find_bucket "my-bucket"
27
47
  # file = bucket.find_file "path/to/my-file.ext"
28
48
  #
29
- # @param project [String] the project identifier for the Storage
30
- # account you are connecting to.
31
- # @param keyfile [String] the path to the keyfile you downloaded from
32
- # Google Cloud. The file must readable.
33
- # @return [Gcloud::Storage::Project] storage project.
34
- #
35
- # See Gcloud::Storage::Project
36
- def self.storage project = ENV["STORAGE_PROJECT"],
37
- keyfile = nil
49
+ def self.storage project = nil, keyfile = nil
50
+ project ||= Gcloud::Storage::Project.default_project
38
51
  if keyfile.nil?
39
52
  credentials = Gcloud::Storage::Credentials.default
40
53
  else
@@ -44,14 +57,268 @@ module Gcloud
44
57
  end
45
58
 
46
59
  ##
47
- # Google Cloud Storage
60
+ # = Google Cloud Storage
61
+ #
62
+ # Google Cloud Storage is an Internet service to store data in Google's cloud.
63
+ # It allows world-wide storage and retrieval of any amount of data and at any
64
+ # time, taking advantage of Google's own reliable and fast networking
65
+ # infrastructure to perform data operations in a cost effective manner.
66
+ #
67
+ # Gcloud's goal is to provide a API that is familiar and comfortable to
68
+ # Rubyists. Authentication is handled by Gcloud.storage. You can provide the
69
+ # project and credential information to connect to the Storage service, or if
70
+ # you are running on Google Compute Engine this configuration is taken care
71
+ # of for you.
72
+ #
73
+ # require "glcoud/storage"
48
74
  #
49
75
  # storage = Gcloud.storage "my-todo-project",
50
76
  # "/path/to/keyfile.json"
77
+ #
51
78
  # bucket = storage.find_bucket "my-bucket"
52
79
  # file = bucket.find_file "path/to/my-file.ext"
53
80
  #
54
- # See Gcloud::Storage::Project
81
+ # You can learn more about various options for connection on the
82
+ # {Authentication Guide}[link:AUTHENTICATION.md].
83
+ #
84
+ # To learn more about Datastore, read the
85
+ # {Google Cloud Storage Overview
86
+ # }[https://cloud.google.com/storage/docs/overview].
87
+ #
88
+ # == Retrieving Buckets
89
+ #
90
+ # A Bucket is the container for your data. There is no limit on the number of
91
+ # buckets that you can create in a project. You can use buckets to organize
92
+ # and control access to your data. Each bucket has a unique name, which is how
93
+ # they are retrieved: (See Project#find_bucket)
94
+ #
95
+ # require "gcloud/storage"
96
+ #
97
+ # storage = Gcloud.storage
98
+ #
99
+ # bucket = storage.find_bucket "my-todo-app"
100
+ #
101
+ # You can also retrieve all buckets on a project: (See Project#buckets)
102
+ #
103
+ # require "gcloud/storage"
104
+ #
105
+ # storage = Gcloud.storage
106
+ #
107
+ # all_buckets = storage.buckets
108
+ #
109
+ # If you have a significant number of buckets, you may need to paginate
110
+ # through them: (See Bucket::List#token)
111
+ #
112
+ # require "gcloud/storage"
113
+ #
114
+ # storage = Gcloud.storage
115
+ #
116
+ # all_buckets = []
117
+ # tmp_buckets = storage.buckets
118
+ # while tmp_buckets.any? do
119
+ # tmp_buckets.each do |bucket|
120
+ # all_buckets << bucket
121
+ # end
122
+ # # break loop if no more buckets available
123
+ # break if tmp_buckets.token.nil?
124
+ # # get the next group of buckets
125
+ # tmp_buckets = storage.buckets token: tmp_buckets.token
126
+ # end
127
+ #
128
+ # == Creating a Bucket
129
+ #
130
+ # A unique name is all that is needed to create a new bucket:
131
+ # (See Project#create_bucket)
132
+ #
133
+ # require "gcloud/storage"
134
+ #
135
+ # storage = Gcloud.storage
136
+ #
137
+ # bucket = storage.create_bucket "my-todo-app-attachments"
138
+ #
139
+ # == Retrieving Files
140
+ #
141
+ # A File is an individual pieces of data that you store in Google Cloud
142
+ # Storage. Files contain the data stored as well as metadata describing the
143
+ # data. Files belong to a bucket and cannot be shared among buckets. There is
144
+ # no limit on the number of objects that you can create in a bucket.
145
+ #
146
+ # Files are retrieved by their name, which is the path of the file in the
147
+ # bucket: (See Bucket#find_file)
148
+ #
149
+ # require "gcloud/storage"
150
+ #
151
+ # storage = Gcloud.storage
152
+ #
153
+ # bucket = storage.find_bucket "my-todo-app"
154
+ # file = bucket.find_file "avatars/heidi/400x400.png"
155
+ #
156
+ # You can also retrieve all files in a bucket: (See Bucket#files)
157
+ #
158
+ # require "gcloud/storage"
159
+ #
160
+ # storage = Gcloud.storage
161
+ #
162
+ # bucket = storage.find_bucket "my-todo-app"
163
+ # all_files = bucket.files
164
+ #
165
+ # Or you can retrieve all files in a specified path:
166
+ #
167
+ # require "gcloud/storage"
168
+ #
169
+ # storage = Gcloud.storage
170
+ #
171
+ # bucket = storage.find_bucket "my-todo-app"
172
+ # avatar_files = bucket.files prefix: "avatars/"
173
+ #
174
+ # If you have a significant number of files, you may need to paginate through
175
+ # them: (See File::List#token)
176
+ #
177
+ # require "gcloud/storage"
178
+ #
179
+ # storage = Gcloud.storage
180
+ #
181
+ # bucket = storage.find_bucket "my-todo-app"
182
+ #
183
+ # all_files = []
184
+ # tmp_files = bucket.files
185
+ # while tmp_files.any? do
186
+ # tmp_files.each do |file|
187
+ # all_files << file
188
+ # end
189
+ # # break loop if no more files available
190
+ # break if tmp_files.token.nil?
191
+ # # get the next group of files
192
+ # tmp_files = bucket.files token: tmp_files.token
193
+ # end
194
+ #
195
+ # == Creating a File
196
+ #
197
+ # A new File can be uploaded by specifying the location of a file on the local
198
+ # file system, and the name/path that the file should be stored in the bucket.
199
+ # (See Bucket#create_file)
200
+ #
201
+ # require "gcloud/storage"
202
+ #
203
+ # storage = Gcloud.storage
204
+ #
205
+ # bucket = storage.find_bucket "my-todo-app"
206
+ # bucket.create_file "/var/todo-app/avatars/heidi/400x400.png",
207
+ # "avatars/heidi/400x400.png"
208
+ #
209
+ # == Downloading a File
210
+ #
211
+ # Files can be downloaded to the local file system. (See File#download)
212
+ #
213
+ # require "gcloud/storage"
214
+ #
215
+ # storage = Gcloud.storage
216
+ #
217
+ # bucket = storage.find_bucket "my-todo-app"
218
+ # file = bucket.find_file "avatars/heidi/400x400.png"
219
+ # file.download "/var/todo-app/avatars/heidi/400x400.png"
220
+ #
221
+ # == Using Signed URLs
222
+ #
223
+ # Access without authentication can be granted to a File for a specified
224
+ # period of time. This URL uses a cryptographic signature
225
+ # of your credentials to access the file. (See File#signed_url)
226
+ #
227
+ # require "gcloud/storage"
228
+ #
229
+ # storage = Gcloud.storage
230
+ #
231
+ # bucket = storage.find_bucket "my-todo-app"
232
+ # file = bucket.find_file "avatars/heidi/400x400.png"
233
+ # shared_url = file.signed_url method: "GET",
234
+ # expires: 300 # 5 minutes from now
235
+ #
236
+ # == Controlling Access to a Bucket
237
+ #
238
+ # Access to a bucket is controlled with Bucket#acl. A bucket has owners,
239
+ # writers, and readers. Permissions can be granted to an individual user's
240
+ # email address, a group's email address, as well as many predefined lists.
241
+ # See the
242
+ # {Access Control guide}[https://cloud.google.com/storage/docs/access-control]
243
+ # for more.
244
+ #
245
+ # Access to a bucket can be granted to a user by appending +"user-"+ to the
246
+ # email address:
247
+ #
248
+ # require "gcloud/storage"
249
+ #
250
+ # storage = Gcloud.storage
251
+ #
252
+ # bucket = storage.find_bucket "my-todo-app"
253
+ #
254
+ # email = "heidi@example.net"
255
+ # bucket.acl.add_reader "user-#{email}"
256
+ #
257
+ # Access to a bucket can be granted to a group by appending +"group-"+ to the
258
+ # email address:
259
+ #
260
+ # require "gcloud/storage"
261
+ #
262
+ # storage = Gcloud.storage
263
+ #
264
+ # bucket = storage.find_bucket "my-todo-app"
265
+ #
266
+ # email = "authors@example.net"
267
+ # bucket.acl.add_reader "group-#{email}"
268
+ #
269
+ # Access to a bucket can also be granted to a predefined list of permissions:
270
+ #
271
+ # require "gcloud/storage"
272
+ #
273
+ # storage = Gcloud.storage
274
+ #
275
+ # bucket = storage.find_bucket "my-todo-app"
276
+ #
277
+ # bucket.acl.public!
278
+ #
279
+ # == Controlling Access to a File
280
+ #
281
+ # Access to a file is controlled in two ways, either by the setting the
282
+ # default permissions to all files in a bucket with Bucket#default_acl, or by
283
+ # setting permissions to an individual file with File#acl.
284
+ #
285
+ # Access to a file can be granted to a user by appending +"user-"+ to the
286
+ # email address:
287
+ #
288
+ # require "gcloud/storage"
289
+ #
290
+ # storage = Gcloud.storage
291
+ #
292
+ # bucket = storage.find_bucket "my-todo-app"
293
+ # file = bucket.find_file "avatars/heidi/400x400.png"
294
+ #
295
+ # email = "heidi@example.net"
296
+ # file.acl.add_reader "user-#{email}"
297
+ #
298
+ # Access to a file can be granted to a group by appending +"group-"+ to the
299
+ # email address:
300
+ #
301
+ # require "gcloud/storage"
302
+ #
303
+ # storage = Gcloud.storage
304
+ #
305
+ # bucket = storage.find_bucket "my-todo-app"
306
+ # file = bucket.find_file "avatars/heidi/400x400.png"
307
+ #
308
+ # email = "authors@example.net"
309
+ # file.acl.add_reader "group-#{email}"
310
+ #
311
+ # Access to a file can also be granted to a predefined list of permissions:
312
+ #
313
+ # require "gcloud/storage"
314
+ #
315
+ # storage = Gcloud.storage
316
+ #
317
+ # bucket = storage.find_bucket "my-todo-app"
318
+ # file = bucket.find_file "avatars/heidi/400x400.png"
319
+ #
320
+ # file.acl.public!
321
+ #
55
322
  module Storage
56
323
  ##
57
324
  # Retrieve resumable threshold.