gcloud 0.12.2 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +5 -13
  2. data/lib/gcloud.rb +27 -456
  3. data/lib/gcloud/bigquery.rb +2 -382
  4. data/lib/gcloud/datastore.rb +2 -576
  5. data/lib/gcloud/dns.rb +2 -321
  6. data/lib/gcloud/logging.rb +1 -322
  7. data/lib/gcloud/pubsub.rb +2 -476
  8. data/lib/gcloud/resource_manager.rb +2 -273
  9. data/lib/gcloud/storage.rb +2 -440
  10. data/lib/gcloud/translate.rb +1 -250
  11. data/lib/gcloud/version.rb +2 -2
  12. data/lib/gcloud/vision.rb +1 -501
  13. metadata +36 -332
  14. data/AUTHENTICATION.md +0 -75
  15. data/CHANGELOG.md +0 -382
  16. data/OVERVIEW.md +0 -259
  17. data/lib/gcloud/backoff.rb +0 -150
  18. data/lib/gcloud/bigquery/copy_job.rb +0 -97
  19. data/lib/gcloud/bigquery/credentials.rb +0 -29
  20. data/lib/gcloud/bigquery/data.rb +0 -239
  21. data/lib/gcloud/bigquery/dataset.rb +0 -753
  22. data/lib/gcloud/bigquery/dataset/access.rb +0 -507
  23. data/lib/gcloud/bigquery/dataset/list.rb +0 -169
  24. data/lib/gcloud/bigquery/extract_job.rb +0 -117
  25. data/lib/gcloud/bigquery/insert_response.rb +0 -81
  26. data/lib/gcloud/bigquery/job.rb +0 -299
  27. data/lib/gcloud/bigquery/job/list.rb +0 -172
  28. data/lib/gcloud/bigquery/load_job.rb +0 -202
  29. data/lib/gcloud/bigquery/project.rb +0 -475
  30. data/lib/gcloud/bigquery/query_data.rb +0 -234
  31. data/lib/gcloud/bigquery/query_job.rb +0 -137
  32. data/lib/gcloud/bigquery/schema.rb +0 -359
  33. data/lib/gcloud/bigquery/service.rb +0 -506
  34. data/lib/gcloud/bigquery/table.rb +0 -1141
  35. data/lib/gcloud/bigquery/table/list.rb +0 -180
  36. data/lib/gcloud/bigquery/view.rb +0 -475
  37. data/lib/gcloud/credentials.rb +0 -129
  38. data/lib/gcloud/datastore/commit.rb +0 -148
  39. data/lib/gcloud/datastore/credentials.rb +0 -35
  40. data/lib/gcloud/datastore/cursor.rb +0 -76
  41. data/lib/gcloud/datastore/dataset.rb +0 -660
  42. data/lib/gcloud/datastore/dataset/lookup_results.rb +0 -219
  43. data/lib/gcloud/datastore/dataset/query_results.rb +0 -386
  44. data/lib/gcloud/datastore/entity.rb +0 -449
  45. data/lib/gcloud/datastore/errors.rb +0 -41
  46. data/lib/gcloud/datastore/gql_query.rb +0 -211
  47. data/lib/gcloud/datastore/grpc_utils.rb +0 -132
  48. data/lib/gcloud/datastore/key.rb +0 -281
  49. data/lib/gcloud/datastore/properties.rb +0 -128
  50. data/lib/gcloud/datastore/query.rb +0 -348
  51. data/lib/gcloud/datastore/service.rb +0 -167
  52. data/lib/gcloud/datastore/transaction.rb +0 -362
  53. data/lib/gcloud/dns/change.rb +0 -158
  54. data/lib/gcloud/dns/change/list.rb +0 -173
  55. data/lib/gcloud/dns/credentials.rb +0 -29
  56. data/lib/gcloud/dns/importer.rb +0 -183
  57. data/lib/gcloud/dns/project.rb +0 -247
  58. data/lib/gcloud/dns/record.rb +0 -170
  59. data/lib/gcloud/dns/record/list.rb +0 -174
  60. data/lib/gcloud/dns/service.rb +0 -167
  61. data/lib/gcloud/dns/zone.rb +0 -759
  62. data/lib/gcloud/dns/zone/list.rb +0 -168
  63. data/lib/gcloud/dns/zone/transaction.rb +0 -176
  64. data/lib/gcloud/errors.rb +0 -206
  65. data/lib/gcloud/gce.rb +0 -56
  66. data/lib/gcloud/grpc_utils.rb +0 -87
  67. data/lib/gcloud/logging/credentials.rb +0 -29
  68. data/lib/gcloud/logging/entry.rb +0 -465
  69. data/lib/gcloud/logging/entry/http_request.rb +0 -141
  70. data/lib/gcloud/logging/entry/list.rb +0 -177
  71. data/lib/gcloud/logging/entry/operation.rb +0 -90
  72. data/lib/gcloud/logging/logger.rb +0 -307
  73. data/lib/gcloud/logging/metric.rb +0 -169
  74. data/lib/gcloud/logging/metric/list.rb +0 -172
  75. data/lib/gcloud/logging/project.rb +0 -642
  76. data/lib/gcloud/logging/resource.rb +0 -84
  77. data/lib/gcloud/logging/resource_descriptor.rb +0 -137
  78. data/lib/gcloud/logging/resource_descriptor/list.rb +0 -174
  79. data/lib/gcloud/logging/service.rb +0 -267
  80. data/lib/gcloud/logging/sink.rb +0 -227
  81. data/lib/gcloud/logging/sink/list.rb +0 -171
  82. data/lib/gcloud/pubsub/credentials.rb +0 -29
  83. data/lib/gcloud/pubsub/message.rb +0 -94
  84. data/lib/gcloud/pubsub/policy.rb +0 -204
  85. data/lib/gcloud/pubsub/project.rb +0 -482
  86. data/lib/gcloud/pubsub/received_message.rb +0 -160
  87. data/lib/gcloud/pubsub/service.rb +0 -334
  88. data/lib/gcloud/pubsub/subscription.rb +0 -565
  89. data/lib/gcloud/pubsub/subscription/list.rb +0 -208
  90. data/lib/gcloud/pubsub/topic.rb +0 -511
  91. data/lib/gcloud/pubsub/topic/list.rb +0 -174
  92. data/lib/gcloud/pubsub/topic/publisher.rb +0 -85
  93. data/lib/gcloud/resource_manager/credentials.rb +0 -30
  94. data/lib/gcloud/resource_manager/manager.rb +0 -266
  95. data/lib/gcloud/resource_manager/policy.rb +0 -211
  96. data/lib/gcloud/resource_manager/project.rb +0 -484
  97. data/lib/gcloud/resource_manager/project/list.rb +0 -167
  98. data/lib/gcloud/resource_manager/project/updater.rb +0 -130
  99. data/lib/gcloud/resource_manager/service.rb +0 -127
  100. data/lib/gcloud/storage/bucket.rb +0 -775
  101. data/lib/gcloud/storage/bucket/acl.rb +0 -810
  102. data/lib/gcloud/storage/bucket/cors.rb +0 -153
  103. data/lib/gcloud/storage/bucket/list.rb +0 -172
  104. data/lib/gcloud/storage/credentials.rb +0 -29
  105. data/lib/gcloud/storage/errors.rb +0 -65
  106. data/lib/gcloud/storage/file.rb +0 -842
  107. data/lib/gcloud/storage/file/acl.rb +0 -425
  108. data/lib/gcloud/storage/file/list.rb +0 -191
  109. data/lib/gcloud/storage/file/verifier.rb +0 -67
  110. data/lib/gcloud/storage/project.rb +0 -316
  111. data/lib/gcloud/storage/service.rb +0 -347
  112. data/lib/gcloud/translate/api.rb +0 -241
  113. data/lib/gcloud/translate/detection.rb +0 -137
  114. data/lib/gcloud/translate/language.rb +0 -69
  115. data/lib/gcloud/translate/service.rb +0 -80
  116. data/lib/gcloud/translate/translation.rb +0 -112
  117. data/lib/gcloud/vision/annotate.rb +0 -224
  118. data/lib/gcloud/vision/annotation.rb +0 -455
  119. data/lib/gcloud/vision/annotation/entity.rb +0 -234
  120. data/lib/gcloud/vision/annotation/face.rb +0 -1750
  121. data/lib/gcloud/vision/annotation/properties.rb +0 -245
  122. data/lib/gcloud/vision/annotation/safe_search.rb +0 -161
  123. data/lib/gcloud/vision/annotation/text.rb +0 -236
  124. data/lib/gcloud/vision/annotation/vertex.rb +0 -108
  125. data/lib/gcloud/vision/credentials.rb +0 -29
  126. data/lib/gcloud/vision/image.rb +0 -590
  127. data/lib/gcloud/vision/location.rb +0 -115
  128. data/lib/gcloud/vision/project.rb +0 -278
  129. data/lib/gcloud/vision/service.rb +0 -66
  130. data/lib/google/api/annotations.rb +0 -14
  131. data/lib/google/api/http.rb +0 -30
  132. data/lib/google/api/label.rb +0 -24
  133. data/lib/google/api/monitored_resource.rb +0 -25
  134. data/lib/google/datastore/v1beta3/datastore.rb +0 -115
  135. data/lib/google/datastore/v1beta3/datastore_services.rb +0 -33
  136. data/lib/google/datastore/v1beta3/entity.rb +0 -63
  137. data/lib/google/datastore/v1beta3/query.rb +0 -128
  138. data/lib/google/devtools/cloudtrace/v1/trace.rb +0 -78
  139. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +0 -32
  140. data/lib/google/example/library/v1/library.rb +0 -91
  141. data/lib/google/example/library/v1/library_services.rb +0 -40
  142. data/lib/google/iam/v1/iam_policy.rb +0 -33
  143. data/lib/google/iam/v1/iam_policy_services.rb +0 -30
  144. data/lib/google/iam/v1/policy.rb +0 -25
  145. data/lib/google/logging/type/http_request.rb +0 -28
  146. data/lib/google/logging/type/log_severity.rb +0 -27
  147. data/lib/google/logging/v2/log_entry.rb +0 -44
  148. data/lib/google/logging/v2/logging.rb +0 -56
  149. data/lib/google/logging/v2/logging_config.rb +0 -59
  150. data/lib/google/logging/v2/logging_config_services.rb +0 -32
  151. data/lib/google/logging/v2/logging_metrics.rb +0 -51
  152. data/lib/google/logging/v2/logging_metrics_services.rb +0 -32
  153. data/lib/google/logging/v2/logging_services.rb +0 -31
  154. data/lib/google/longrunning/operations.rb +0 -50
  155. data/lib/google/longrunning/operations_services.rb +0 -29
  156. data/lib/google/protobuf/descriptor.rb +0 -0
  157. data/lib/google/pubsub/v1/pubsub.rb +0 -129
  158. data/lib/google/pubsub/v1/pubsub_services.rb +0 -56
  159. data/lib/google/pubsub/v1beta2/pubsub.rb +0 -126
  160. data/lib/google/pubsub/v1beta2/pubsub_services.rb +0 -56
  161. data/lib/google/rpc/code.rb +0 -32
  162. data/lib/google/rpc/error_details.rb +0 -61
  163. data/lib/google/rpc/status.rb +0 -19
  164. data/lib/google/type/color.rb +0 -20
  165. data/lib/google/type/date.rb +0 -18
  166. data/lib/google/type/dayofweek.rb +0 -23
  167. data/lib/google/type/latlng.rb +0 -17
  168. data/lib/google/type/money.rb +0 -18
  169. data/lib/google/type/timeofday.rb +0 -19
@@ -1,4 +1,4 @@
1
- # Copyright 2015 Google Inc. All rights reserved.
1
+ # Copyright 2016 Google Inc. All rights reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -14,275 +14,4 @@
14
14
 
15
15
 
16
16
  require "gcloud"
17
- require "gcloud/resource_manager/manager"
18
-
19
- module Gcloud
20
- ##
21
- # Creates a new `Project` instance connected to the Resource Manager service.
22
- # Each call creates a new connection.
23
- #
24
- # For more information on connecting to Google Cloud see the [Authentication
25
- # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
26
- #
27
- # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
28
- # path the file must be readable.
29
- # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
30
- # set of resources and operations that the connection can access. See [Using
31
- # OAuth 2.0 to Access Google
32
- # APIs](https://developers.google.com/identity/protocols/OAuth2).
33
- #
34
- # The default scope is:
35
- #
36
- # * `https://www.googleapis.com/auth/cloud-platform`
37
- # @param [Integer] retries Number of times to retry requests on server error.
38
- # The default value is `3`. Optional.
39
- # @param [Integer] timeout Default timeout to use in requests. Optional.
40
- #
41
- # @return [Gcloud::ResourceManager::Manager]
42
- #
43
- # @example
44
- # require "gcloud/resource_manager"
45
- #
46
- # resource_manager = Gcloud.resource_manager
47
- # resource_manager.projects.each do |project|
48
- # puts projects.project_id
49
- # end
50
- #
51
- def self.resource_manager keyfile = nil, scope: nil, retries: nil,
52
- timeout: nil
53
- if keyfile.nil?
54
- credentials = Gcloud::ResourceManager::Credentials.default scope: scope
55
- else
56
- credentials = Gcloud::ResourceManager::Credentials.new keyfile,
57
- scope: scope
58
- end
59
- Gcloud::ResourceManager::Manager.new(
60
- Gcloud::ResourceManager::Service.new(
61
- credentials, retries: retries, timeout: timeout))
62
- end
63
-
64
- ##
65
- # # Google Cloud Resource Manager
66
- #
67
- # The Resource Manager API provides methods that you can use to
68
- # programmatically manage your projects in the Google Cloud Platform. You may
69
- # be familiar with managing projects in the [Developers
70
- # Console](https://developers.google.com/console/help/new/). With this API you
71
- # can do the following:
72
- #
73
- # * Get a list of all projects associated with an account
74
- # * Create new projects
75
- # * Update existing projects
76
- # * Delete projects
77
- # * Undelete, or recover, projects that you don't want to delete
78
- #
79
- # The Resource Manager API is a Beta release and is not covered by any SLA or
80
- # deprecation policy and may be subject to backward-incompatible changes.
81
- #
82
- # ## Accessing the Service
83
- #
84
- # Currently, the full functionality of the Resource Manager API is available
85
- # only to whitelisted users. (Contact your account manager or a member of the
86
- # Google Cloud sales team if you are interested in access.) Read-only methods
87
- # such as {ResourceManager::Manager#projects} and
88
- # {ResourceManager::Manager#project} are accessible to any user who enables
89
- # the Resource Manager API in the [Developers
90
- # Console](https://console.developers.google.com).
91
- #
92
- # ## Authentication
93
- #
94
- # The Resource Manager API currently requires authentication of a [User
95
- # Account](https://developers.google.com/identity/protocols/OAuth2), and
96
- # cannot currently be accessed with a [Service
97
- # Account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount).
98
- # To use a User Account install the [Google Cloud
99
- # SDK](http://cloud.google.com/sdk) and authenticate with the following:
100
- #
101
- # ```
102
- # $ gcloud auth login
103
- # ```
104
- #
105
- # Also make sure all `GCLOUD` environment variables are cleared of any service
106
- # accounts. Then gcloud-ruby will be able to detect the user authentication
107
- # and connect with those credentials.
108
- #
109
- # ```ruby
110
- # require "gcloud"
111
- #
112
- # gcloud = Gcloud.new
113
- # resource_manager = gcloud.resource_manager
114
- # ```
115
- #
116
- # ## Listing Projects
117
- #
118
- # Project is a collection of settings, credentials, and metadata about the
119
- # application or applications you're working on. You can retrieve and inspect
120
- # all projects that you have permissions to. (See
121
- # {Gcloud::ResourceManager::Manager#projects})
122
- #
123
- # ```ruby
124
- # require "gcloud"
125
- #
126
- # gcloud = Gcloud.new
127
- # resource_manager = gcloud.resource_manager
128
- # resource_manager.projects.each do |project|
129
- # puts projects.project_id
130
- # end
131
- # ```
132
- #
133
- # ## Managing Projects with Labels
134
- #
135
- # Labels can be added to or removed from projects. (See
136
- # {Gcloud::ResourceManager::Project#labels})
137
- #
138
- # ```ruby
139
- # require "gcloud"
140
- #
141
- # gcloud = Gcloud.new
142
- # resource_manager = gcloud.resource_manager
143
- # project = resource_manager.project "tokyo-rain-123"
144
- # # Label the project as production
145
- # project.update do |p|
146
- # p.labels["env"] = "production"
147
- # end
148
- # ```
149
- #
150
- # Projects can then be filtered by labels. (See
151
- # {Gcloud::ResourceManager::Manager#projects})
152
- #
153
- # ```ruby
154
- # require "gcloud"
155
- #
156
- # gcloud = Gcloud.new
157
- # resource_manager = gcloud.resource_manager
158
- # # Find only the productions projects
159
- # projects = resource_manager.projects filter: "labels.env:production"
160
- # projects.each do |project|
161
- # puts project.project_id
162
- # end
163
- # ```
164
- #
165
- # ## Creating a Project
166
- #
167
- # You can also use the API to create new projects. (See
168
- # {Gcloud::ResourceManager::Manager#create_project})
169
- #
170
- # ```ruby
171
- # require "gcloud"
172
- #
173
- # gcloud = Gcloud.new
174
- # resource_manager = gcloud.resource_manager
175
- # project = resource_manager.create_project "tokyo-rain-123",
176
- # name: "Todos Development",
177
- # labels: {env: :development}
178
- # ```
179
- #
180
- # ## Deleting a Project
181
- #
182
- # You can delete projects when they are no longer needed. (See
183
- # {Gcloud::ResourceManager::Manager#delete} and
184
- # {Gcloud::ResourceManager::Project#delete})
185
- #
186
- # ```ruby
187
- # require "gcloud"
188
- #
189
- # gcloud = Gcloud.new
190
- # resource_manager = gcloud.resource_manager
191
- # resource_manager.delete "tokyo-rain-123"
192
- # ```
193
- #
194
- # ## Undeleting a Project
195
- #
196
- # You can also restore a deleted project within the waiting period that starts
197
- # when the project was deleted. Restoring a project returns it to the state it
198
- # was in prior to being deleted. (See
199
- # {Gcloud::ResourceManager::Manager#undelete} and
200
- # {Gcloud::ResourceManager::Project#undelete})
201
- #
202
- # ```ruby
203
- # require "gcloud"
204
- #
205
- # gcloud = Gcloud.new
206
- # resource_manager = gcloud.resource_manager
207
- # resource_manager.undelete "tokyo-rain-123"
208
- # ```
209
- #
210
- # ## Configuring retries and timeout
211
- #
212
- # You can configure how many times API requests may be automatically retried.
213
- # When an API request fails, the response will be inspected to see if the
214
- # request meets criteria indicating that it may succeed on retry, such as
215
- # `500` and `503` status codes or a specific internal error code such as
216
- # `rateLimitExceeded`. If it meets the criteria, the request will be retried
217
- # after a delay. If another error occurs, the delay will be increased before a
218
- # subsequent attempt, until the `retries` limit is reached.
219
- #
220
- # You can also set the request `timeout` value in seconds.
221
- #
222
- # ```ruby
223
- # require "gcloud"
224
- #
225
- # gcloud = Gcloud.new
226
- # resource_manager = gcloud.resource_manager retries: 10, timeout: 120
227
- # ```
228
- #
229
- # See the [Resource Manager error
230
- # messages](https://cloud.google.com/resource-manager/docs/core_errors)
231
- # for a list of error conditions.
232
- #
233
- # ## Managing IAM Policies
234
- #
235
- # Google Cloud Identity and Access Management ([Cloud
236
- # IAM](https://cloud.google.com/iam/)) access control policies can be managed
237
- # on projects. These policies allow project owners to manage _who_ (identity)
238
- # has access to _what_ (role). See [Cloud IAM
239
- # Overview](https://cloud.google.com/iam/docs/overview) for more information.
240
- #
241
- # A project's access control policy can be retrieved. (See
242
- # {Gcloud::ResourceManager::Project#policy} and
243
- # {Gcloud::ResourceManager::Policy}.)
244
- #
245
- # ```ruby
246
- # require "gcloud"
247
- #
248
- # gcloud = Gcloud.new
249
- # resource_manager = gcloud.resource_manager
250
- # project = resource_manager.project "tokyo-rain-123"
251
- # policy = project.policy
252
- # ```
253
- #
254
- # A project's access control policy can also be updated:
255
- #
256
- # ```ruby
257
- # require "gcloud"
258
- #
259
- # gcloud = Gcloud.new
260
- # resource_manager = gcloud.resource_manager
261
- # project = resource_manager.project "tokyo-rain-123"
262
- #
263
- # policy = project.policy do |p|
264
- # p.add "roles/viewer", "serviceAccount:your-service-account"
265
- # end
266
- # ```
267
- #
268
- # And permissions can be tested on a project. (See
269
- # {Gcloud::ResourceManager::Project#test_permissions})
270
- #
271
- # ```ruby
272
- # require "gcloud"
273
- #
274
- # gcloud = Gcloud.new
275
- # resource_manager = gcloud.resource_manager
276
- # project = resource_manager.project "tokyo-rain-123"
277
- # perms = project.test_permissions "resourcemanager.projects.get",
278
- # "resourcemanager.projects.delete"
279
- # perms.include? "resourcemanager.projects.get" #=> true
280
- # perms.include? "resourcemanager.projects.delete" #=> false
281
- # ```
282
- #
283
- # For more information about using access control policies see [Managing
284
- # Policies](https://cloud.google.com/iam/docs/managing-policies).
285
- #
286
- module ResourceManager
287
- end
288
- end
17
+ require "google/cloud/resource_manager"
@@ -1,4 +1,4 @@
1
- # Copyright 2014 Google Inc. All rights reserved.
1
+ # Copyright 2016 Google Inc. All rights reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -14,442 +14,4 @@
14
14
 
15
15
 
16
16
  require "gcloud"
17
- require "gcloud/storage/project"
18
-
19
- module Gcloud
20
- ##
21
- # Creates a new object for connecting to the Storage service.
22
- # Each call creates a new connection.
23
- #
24
- # For more information on connecting to Google Cloud see the [Authentication
25
- # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
26
- #
27
- # @param [String] project Project identifier for the Storage service you are
28
- # connecting to.
29
- # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
30
- # path the file must be readable.
31
- # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
32
- # set of resources and operations that the connection can access. See [Using
33
- # OAuth 2.0 to Access Google
34
- # APIs](https://developers.google.com/identity/protocols/OAuth2).
35
- #
36
- # The default scope is:
37
- #
38
- # * `https://www.googleapis.com/auth/devstorage.full_control`
39
- # @param [Integer] retries Number of times to retry requests on server error.
40
- # The default value is `3`. Optional.
41
- # @param [Integer] timeout Default timeout to use in requests. Optional.
42
- #
43
- # @return [Gcloud::Storage::Project]
44
- #
45
- # @example
46
- # require "gcloud/storage"
47
- #
48
- # storage = Gcloud.storage "my-todo-project",
49
- # "/path/to/keyfile.json"
50
- #
51
- # bucket = storage.bucket "my-bucket"
52
- # file = bucket.file "path/to/my-file.ext"
53
- #
54
- def self.storage project = nil, keyfile = nil, scope: nil, retries: nil,
55
- timeout: nil
56
- project ||= Gcloud::Storage::Project.default_project
57
- project = project.to_s # Always cast to a string
58
- fail ArgumentError, "project is missing" if project.empty?
59
-
60
- if keyfile.nil?
61
- credentials = Gcloud::Storage::Credentials.default scope: scope
62
- else
63
- credentials = Gcloud::Storage::Credentials.new keyfile, scope: scope
64
- end
65
-
66
- Gcloud::Storage::Project.new(
67
- Gcloud::Storage::Service.new(
68
- project, credentials, retries: retries, timeout: timeout))
69
- end
70
-
71
- ##
72
- # # Google Cloud Storage
73
- #
74
- # Google Cloud Storage is an Internet service to store data in Google's cloud.
75
- # It allows world-wide storage and retrieval of any amount of data and at any
76
- # time, taking advantage of Google's own reliable and fast networking
77
- # infrastructure to perform data operations in a cost effective manner.
78
- #
79
- # The goal of gcloud-ruby is to provide a API that is comfortable to
80
- # Rubyists. Authentication is handled by {Gcloud#storage}. You can provide the
81
- # project and credential information to connect to the Storage service, or if
82
- # you are running on Google Compute Engine this configuration is taken care
83
- # of for you.
84
- #
85
- # ```ruby
86
- # require "gcloud"
87
- #
88
- # gcloud = Gcloud.new "my-todo-project",
89
- # "/path/to/keyfile.json"
90
- # storage = gcloud.storage
91
- #
92
- # bucket = storage.bucket "my-bucket"
93
- # file = bucket.file "path/to/my-file.ext"
94
- # ```
95
- #
96
- # You can learn more about various options for connection on the
97
- # [Authentication
98
- # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
99
- #
100
- # To learn more about Cloud Storage, read the
101
- # [Google Cloud Storage Overview
102
- # ](https://cloud.google.com/storage/docs/overview).
103
- #
104
- # ## Retrieving Buckets
105
- #
106
- # A Bucket is the container for your data. There is no limit on the number of
107
- # buckets that you can create in a project. You can use buckets to organize
108
- # and control access to your data. Each bucket has a unique name, which is how
109
- # they are retrieved: (See {Gcloud::Storage::Project#bucket})
110
- #
111
- # ```ruby
112
- # require "gcloud"
113
- #
114
- # gcloud = Gcloud.new
115
- # storage = gcloud.storage
116
- #
117
- # bucket = storage.bucket "my-todo-app"
118
- # ```
119
- #
120
- # You can also retrieve all buckets on a project: (See
121
- # {Gcloud::Storage::Project#buckets})
122
- #
123
- # ```ruby
124
- # require "gcloud"
125
- #
126
- # gcloud = Gcloud.new
127
- # storage = gcloud.storage
128
- #
129
- # all_buckets = storage.buckets
130
- # ```
131
- #
132
- # If you have a significant number of buckets, you may need to paginate
133
- # through them: (See {Gcloud::Storage::Bucket::List#token})
134
- #
135
- # ```ruby
136
- # require "gcloud"
137
- #
138
- # gcloud = Gcloud.new
139
- # storage = gcloud.storage
140
- #
141
- # all_buckets = []
142
- # tmp_buckets = storage.buckets
143
- # while tmp_buckets.any? do
144
- # tmp_buckets.each do |bucket|
145
- # all_buckets << bucket
146
- # end
147
- # # break loop if no more buckets available
148
- # break if tmp_buckets.token.nil?
149
- # # get the next group of buckets
150
- # tmp_buckets = storage.buckets token: tmp_buckets.token
151
- # end
152
- # ```
153
- #
154
- # ## Creating a Bucket
155
- #
156
- # A unique name is all that is needed to create a new bucket: (See
157
- # {Gcloud::Storage::Project#create_bucket})
158
- #
159
- # ```ruby
160
- # require "gcloud"
161
- #
162
- # gcloud = Gcloud.new
163
- # storage = gcloud.storage
164
- #
165
- # bucket = storage.create_bucket "my-todo-app-attachments"
166
- # ```
167
- #
168
- # ## Retrieving Files
169
- #
170
- # A File is an individual pieces of data that you store in Google Cloud
171
- # Storage. Files contain the data stored as well as metadata describing the
172
- # data. Files belong to a bucket and cannot be shared among buckets. There is
173
- # no limit on the number of objects that you can create in a bucket.
174
- #
175
- # Files are retrieved by their name, which is the path of the file in the
176
- # bucket: (See {Gcloud::Storage::Bucket#file})
177
- #
178
- # ```ruby
179
- # require "gcloud"
180
- #
181
- # gcloud = Gcloud.new
182
- # storage = gcloud.storage
183
- #
184
- # bucket = storage.bucket "my-todo-app"
185
- # file = bucket.file "avatars/heidi/400x400.png"
186
- # ```
187
- #
188
- # You can also retrieve all files in a bucket: (See Bucket#files)
189
- #
190
- # ```ruby
191
- # require "gcloud"
192
- #
193
- # gcloud = Gcloud.new
194
- # storage = gcloud.storage
195
- #
196
- # bucket = storage.bucket "my-todo-app"
197
- # all_files = bucket.files
198
- # ```
199
- #
200
- # Or you can retrieve all files in a specified path:
201
- #
202
- # ```ruby
203
- # require "gcloud"
204
- #
205
- # gcloud = Gcloud.new
206
- # storage = gcloud.storage
207
- #
208
- # bucket = storage.bucket "my-todo-app"
209
- # avatar_files = bucket.files prefix: "avatars/"
210
- # ```
211
- #
212
- # If you have a significant number of files, you may need to paginate through
213
- # them: (See {Gcloud::Storage::File::List#token})
214
- #
215
- # ```ruby
216
- # require "gcloud"
217
- #
218
- # gcloud = Gcloud.new
219
- # storage = gcloud.storage
220
- #
221
- # bucket = storage.bucket "my-todo-app"
222
- #
223
- # all_files = []
224
- # tmp_files = bucket.files
225
- # while tmp_files.any? do
226
- # tmp_files.each do |file|
227
- # all_files << file
228
- # end
229
- # # break loop if no more files available
230
- # break if tmp_files.token.nil?
231
- # # get the next group of files
232
- # tmp_files = bucket.files token: tmp_files.token
233
- # end
234
- # ```
235
- #
236
- # ## Creating a File
237
- #
238
- # A new File can be uploaded by specifying the location of a file on the local
239
- # file system, and the name/path that the file should be stored in the bucket.
240
- # (See {Gcloud::Storage::Bucket#create_file})
241
- #
242
- # ```ruby
243
- # require "gcloud"
244
- #
245
- # gcloud = Gcloud.new
246
- # storage = gcloud.storage
247
- #
248
- # bucket = storage.bucket "my-todo-app"
249
- # bucket.create_file "/var/todo-app/avatars/heidi/400x400.png",
250
- # "avatars/heidi/400x400.png"
251
- # ```
252
- #
253
- # ### Customer-supplied encryption keys
254
- #
255
- # By default, Google Cloud Storage manages server-side encryption keys on
256
- # your behalf. However, a [customer-supplied encryption
257
- # key](https://cloud.google.com/storage/docs/encryption#customer-supplied)
258
- # can be provided with the `encryption_key` and `encryption_key_sha256`
259
- # options. If given, the same key and SHA256 hash also must be provided to
260
- # subsequently download or copy the file. If you use customer-supplied
261
- # encryption keys, you must securely manage your keys and ensure that they are
262
- # not lost. Also, please note that file metadata is not encrypted, with the
263
- # exception of the CRC32C checksum and MD5 hash. The names of files and
264
- # buckets are also not encrypted, and you can read or update the metadata of
265
- # an encrypted file without providing the encryption key.
266
- #
267
- # ```ruby
268
- # require "gcloud"
269
- # require "digest/sha2"
270
- #
271
- # gcloud = Gcloud.new
272
- # storage = gcloud.storage
273
- # bucket = storage.bucket "my-todo-app"
274
- #
275
- # # Key generation shown for example purposes only. Write your own.
276
- # cipher = OpenSSL::Cipher.new "aes-256-cfb"
277
- # cipher.encrypt
278
- # key = cipher.random_key
279
- # key_hash = Digest::SHA256.digest key
280
- #
281
- # bucket.create_file "/var/todo-app/avatars/heidi/400x400.png",
282
- # "avatars/heidi/400x400.png",
283
- # encryption_key: key,
284
- # encryption_key_sha256: key_hash
285
- #
286
- # # Store your key and hash securely for later use.
287
- # file = bucket.file "avatars/heidi/400x400.png",
288
- # encryption_key: key,
289
- # encryption_key_sha256: key_hash
290
- # ```
291
- #
292
- # ## Downloading a File
293
- #
294
- # Files can be downloaded to the local file system. (See
295
- # {Gcloud::Storage::File#download})
296
- #
297
- # ```ruby
298
- # require "gcloud"
299
- #
300
- # gcloud = Gcloud.new
301
- # storage = gcloud.storage
302
- #
303
- # bucket = storage.bucket "my-todo-app"
304
- # file = bucket.file "avatars/heidi/400x400.png"
305
- # file.download "/var/todo-app/avatars/heidi/400x400.png"
306
- # ```
307
- #
308
- # ## Using Signed URLs
309
- #
310
- # Access without authentication can be granted to a File for a specified
311
- # period of time. This URL uses a cryptographic signature of your credentials
312
- # to access the file. (See {Gcloud::Storage::File#signed_url})
313
- #
314
- # ```ruby
315
- # require "gcloud"
316
- #
317
- # gcloud = Gcloud.new
318
- # storage = gcloud.storage
319
- #
320
- # bucket = storage.bucket "my-todo-app"
321
- # file = bucket.file "avatars/heidi/400x400.png"
322
- # shared_url = file.signed_url method: "GET",
323
- # expires: 300 # 5 minutes from now
324
- # ```
325
- #
326
- # ## Controlling Access to a Bucket
327
- #
328
- # Access to a bucket is controlled with {Gcloud::Storage::Bucket#acl}. A
329
- # bucket has owners, writers, and readers. Permissions can be granted to an
330
- # individual user's email address, a group's email address, as well as many
331
- # predefined lists. See the [Access Control
332
- # guide](https://cloud.google.com/storage/docs/access-control) for more.
333
- #
334
- # Access to a bucket can be granted to a user by appending `"user-"` to the
335
- # email address:
336
- #
337
- # ```ruby
338
- # require "gcloud"
339
- #
340
- # gcloud = Gcloud.new
341
- # storage = gcloud.storage
342
- #
343
- # bucket = storage.bucket "my-todo-app"
344
- #
345
- # email = "heidi@example.net"
346
- # bucket.acl.add_reader "user-#{email}"
347
- # ```
348
- #
349
- # Access to a bucket can be granted to a group by appending `"group-"` to the
350
- # email address:
351
- #
352
- # ```ruby
353
- # require "gcloud"
354
- #
355
- # gcloud = Gcloud.new
356
- # storage = gcloud.storage
357
- #
358
- # bucket = storage.bucket "my-todo-app"
359
- #
360
- # email = "authors@example.net"
361
- # bucket.acl.add_reader "group-#{email}"
362
- # ```
363
- #
364
- # Access to a bucket can also be granted to a predefined list of permissions:
365
- #
366
- # ```ruby
367
- # require "gcloud"
368
- #
369
- # gcloud = Gcloud.new
370
- # storage = gcloud.storage
371
- #
372
- # bucket = storage.bucket "my-todo-app"
373
- #
374
- # bucket.acl.public!
375
- # ```
376
- #
377
- # ## Controlling Access to a File
378
- #
379
- # Access to a file is controlled in two ways, either by the setting the
380
- # default permissions to all files in a bucket with
381
- # {Gcloud::Storage::Bucket#default_acl}, or by setting permissions to an
382
- # individual file with {Gcloud::Storage::File#acl}.
383
- #
384
- # Access to a file can be granted to a user by appending `"user-"` to the
385
- # email address:
386
- #
387
- # ```ruby
388
- # require "gcloud"
389
- #
390
- # gcloud = Gcloud.new
391
- # storage = gcloud.storage
392
- #
393
- # bucket = storage.bucket "my-todo-app"
394
- # file = bucket.file "avatars/heidi/400x400.png"
395
- #
396
- # email = "heidi@example.net"
397
- # file.acl.add_reader "user-#{email}"
398
- # ```
399
- #
400
- # Access to a file can be granted to a group by appending `"group-"` to the
401
- # email address:
402
- #
403
- # ```ruby
404
- # require "gcloud"
405
- #
406
- # gcloud = Gcloud.new
407
- # storage = gcloud.storage
408
- #
409
- # bucket = storage.bucket "my-todo-app"
410
- # file = bucket.file "avatars/heidi/400x400.png"
411
- #
412
- # email = "authors@example.net"
413
- # file.acl.add_reader "group-#{email}"
414
- # ```
415
- #
416
- # Access to a file can also be granted to a predefined list of permissions:
417
- #
418
- # ```ruby
419
- # require "gcloud"
420
- #
421
- # gcloud = Gcloud.new
422
- # storage = gcloud.storage
423
- #
424
- # bucket = storage.bucket "my-todo-app"
425
- # file = bucket.file "avatars/heidi/400x400.png"
426
- #
427
- # file.acl.public!
428
- # ```
429
- #
430
- # ## Configuring retries and timeout
431
- #
432
- # You can configure how many times API requests may be automatically retried.
433
- # When an API request fails, the response will be inspected to see if the
434
- # request meets criteria indicating that it may succeed on retry, such as
435
- # `500` and `503` status codes or a specific internal error code such as
436
- # `rateLimitExceeded`. If it meets the criteria, the request will be retried
437
- # after a delay. If another error occurs, the delay will be increased before a
438
- # subsequent attempt, until the `retries` limit is reached.
439
- #
440
- # You can also set the request `timeout` value in seconds.
441
- #
442
- # ```ruby
443
- # require "gcloud"
444
- #
445
- # gcloud = Gcloud.new
446
- # storage = gcloud.storage retries: 10, timeout: 120
447
- # ```
448
- #
449
- # See the [Storage status and error
450
- # codes](https://cloud.google.com/storage/docs/json_api/v1/status-codes)
451
- # for a list of error conditions.
452
- #
453
- module Storage
454
- end
455
- end
17
+ require "google/cloud/storage"