gcloud 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/CHANGELOG.md +21 -0
- data/lib/gcloud.rb +0 -5
- data/lib/gcloud/bigquery.rb +31 -62
- data/lib/gcloud/bigquery/connection.rb +58 -35
- data/lib/gcloud/bigquery/dataset.rb +147 -18
- data/lib/gcloud/bigquery/dataset/access.rb +477 -0
- data/lib/gcloud/bigquery/dataset/list.rb +1 -1
- data/lib/gcloud/bigquery/errors.rb +2 -0
- data/lib/gcloud/bigquery/job.rb +30 -6
- data/lib/gcloud/bigquery/job/list.rb +1 -1
- data/lib/gcloud/bigquery/project.rb +47 -8
- data/lib/gcloud/bigquery/query_job.rb +1 -5
- data/lib/gcloud/bigquery/table.rb +185 -47
- data/lib/gcloud/bigquery/table/list.rb +1 -1
- data/lib/gcloud/bigquery/table/schema.rb +252 -0
- data/lib/gcloud/bigquery/view.rb +25 -0
- data/lib/gcloud/datastore/connection.rb +4 -0
- data/lib/gcloud/datastore/dataset.rb +5 -2
- data/lib/gcloud/datastore/errors.rb +1 -1
- data/lib/gcloud/datastore/properties.rb +1 -0
- data/lib/gcloud/datastore/proto.rb +3 -0
- data/lib/gcloud/errors.rb +23 -0
- data/lib/gcloud/gce.rb +62 -0
- data/lib/gcloud/pubsub/connection.rb +4 -0
- data/lib/gcloud/pubsub/errors.rb +2 -0
- data/lib/gcloud/pubsub/project.rb +5 -3
- data/lib/gcloud/pubsub/subscription/list.rb +1 -1
- data/lib/gcloud/pubsub/topic.rb +1 -1
- data/lib/gcloud/pubsub/topic/list.rb +1 -1
- data/lib/gcloud/storage.rb +16 -0
- data/lib/gcloud/storage/bucket.rb +31 -1
- data/lib/gcloud/storage/bucket/acl.rb +12 -10
- data/lib/gcloud/storage/bucket/list.rb +1 -1
- data/lib/gcloud/storage/connection.rb +4 -0
- data/lib/gcloud/storage/errors.rb +2 -0
- data/lib/gcloud/storage/file.rb +13 -0
- data/lib/gcloud/storage/file/acl.rb +6 -5
- data/lib/gcloud/storage/file/list.rb +1 -1
- data/lib/gcloud/storage/project.rb +4 -2
- data/lib/gcloud/version.rb +1 -1
- metadata +6 -2
data/lib/gcloud/pubsub/errors.rb
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
+
require "gcloud/gce"
|
16
17
|
require "gcloud/pubsub/connection"
|
17
18
|
require "gcloud/pubsub/credentials"
|
18
19
|
require "gcloud/pubsub/errors"
|
@@ -73,7 +74,8 @@ module Gcloud
|
|
73
74
|
def self.default_project #:nodoc:
|
74
75
|
ENV["PUBSUB_PROJECT"] ||
|
75
76
|
ENV["GCLOUD_PROJECT"] ||
|
76
|
-
ENV["GOOGLE_CLOUD_PROJECT"]
|
77
|
+
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
78
|
+
Gcloud::GCE.project_id
|
77
79
|
end
|
78
80
|
|
79
81
|
##
|
@@ -260,7 +262,7 @@ module Gcloud
|
|
260
262
|
ensure_connection!
|
261
263
|
resp = connection.list_topics options
|
262
264
|
if resp.success?
|
263
|
-
Topic::List.
|
265
|
+
Topic::List.from_response resp, connection
|
264
266
|
else
|
265
267
|
fail ApiError.from_response(resp)
|
266
268
|
end
|
@@ -392,7 +394,7 @@ module Gcloud
|
|
392
394
|
ensure_connection!
|
393
395
|
resp = connection.list_subscriptions options
|
394
396
|
if resp.success?
|
395
|
-
Subscription::List.
|
397
|
+
Subscription::List.from_response resp, connection
|
396
398
|
else
|
397
399
|
fail ApiError.from_response(resp)
|
398
400
|
end
|
@@ -34,7 +34,7 @@ module Gcloud
|
|
34
34
|
|
35
35
|
##
|
36
36
|
# New Subscription::List from a response object.
|
37
|
-
def self.
|
37
|
+
def self.from_response resp, conn #:nodoc:
|
38
38
|
subs = Array(resp.data["subscriptions"]).map do |gapi_object|
|
39
39
|
if gapi_object.is_a? String
|
40
40
|
Subscription.new_lazy gapi_object, conn
|
data/lib/gcloud/pubsub/topic.rb
CHANGED
@@ -299,7 +299,7 @@ module Gcloud
|
|
299
299
|
ensure_connection!
|
300
300
|
resp = connection.list_topics_subscriptions name, options
|
301
301
|
if resp.success?
|
302
|
-
Subscription::List.
|
302
|
+
Subscription::List.from_response resp, connection
|
303
303
|
else
|
304
304
|
fail ApiError.from_response(resp)
|
305
305
|
end
|
data/lib/gcloud/storage.rb
CHANGED
@@ -227,6 +227,22 @@ module Gcloud
|
|
227
227
|
# bucket.create_file "/var/todo-app/avatars/heidi/400x400.png",
|
228
228
|
# "avatars/heidi/400x400.png"
|
229
229
|
#
|
230
|
+
# === A note about large uploads
|
231
|
+
#
|
232
|
+
# You may encounter a broken pipe error while attempting to upload large
|
233
|
+
# files. To avoid this problem, add
|
234
|
+
# {httpclient}[https://rubygems.org/gems/httpclient] as a dependency to your
|
235
|
+
# project, and configure {Faraday}[https://rubygems.org/gems/faraday] to use
|
236
|
+
# it, after requiring Gcloud, but before initiating your Gcloud connection.
|
237
|
+
#
|
238
|
+
# require "gcloud"
|
239
|
+
#
|
240
|
+
# Faraday.default_adapter = :httpclient
|
241
|
+
#
|
242
|
+
# gcloud = Gcloud.new
|
243
|
+
# storage = gcloud.storage
|
244
|
+
# bucket = storage.bucket "my-todo-app"
|
245
|
+
#
|
230
246
|
# == Downloading a File
|
231
247
|
#
|
232
248
|
# Files can be downloaded to the local file system. (See File#download)
|
@@ -208,7 +208,7 @@ module Gcloud
|
|
208
208
|
ensure_connection!
|
209
209
|
resp = connection.list_files name, options
|
210
210
|
if resp.success?
|
211
|
-
File::List.
|
211
|
+
File::List.from_response resp, connection
|
212
212
|
else
|
213
213
|
fail ApiError.from_response(resp)
|
214
214
|
end
|
@@ -324,6 +324,23 @@ module Gcloud
|
|
324
324
|
# "destination/path/file.ext",
|
325
325
|
# chunk_size: 1024*1024 # 1 MB chunk
|
326
326
|
#
|
327
|
+
# ==== A note about large uploads
|
328
|
+
#
|
329
|
+
# You may encounter a broken pipe error while attempting to upload large
|
330
|
+
# files. To avoid this problem, add
|
331
|
+
# {httpclient}[https://rubygems.org/gems/httpclient] as a dependency to
|
332
|
+
# your project, and configure {Faraday}[https://rubygems.org/gems/faraday]
|
333
|
+
# to use it, after requiring Gcloud, but before initiating your Gcloud
|
334
|
+
# connection.
|
335
|
+
#
|
336
|
+
# require "gcloud"
|
337
|
+
#
|
338
|
+
# Faraday.default_adapter = :httpclient
|
339
|
+
#
|
340
|
+
# gcloud = Gcloud.new
|
341
|
+
# storage = gcloud.storage
|
342
|
+
# bucket = storage.bucket "my-todo-app"
|
343
|
+
#
|
327
344
|
def create_file file, path = nil, options = {}
|
328
345
|
ensure_connection!
|
329
346
|
ensure_file_exists! file
|
@@ -447,6 +464,19 @@ module Gcloud
|
|
447
464
|
@default_acl ||= Bucket::DefaultAcl.new self
|
448
465
|
end
|
449
466
|
|
467
|
+
##
|
468
|
+
# Reloads the bucket with current data from the Storage service.
|
469
|
+
def reload!
|
470
|
+
ensure_connection!
|
471
|
+
resp = connection.get_bucket name
|
472
|
+
if resp.success?
|
473
|
+
@gapi = resp.data
|
474
|
+
else
|
475
|
+
fail ApiError.from_response(resp)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
alias_method :refresh!, :reload!
|
479
|
+
|
450
480
|
##
|
451
481
|
# New Bucket from a Google API Client object.
|
452
482
|
def self.from_gapi gapi, conn #:nodoc:
|
@@ -69,15 +69,16 @@ module Gcloud
|
|
69
69
|
#
|
70
70
|
# bucket = storage.bucket "my-bucket"
|
71
71
|
#
|
72
|
-
# bucket.acl.
|
72
|
+
# bucket.acl.reload!
|
73
73
|
#
|
74
|
-
def
|
74
|
+
def reload!
|
75
75
|
resp = @connection.list_bucket_acls @bucket
|
76
76
|
acls = resp.data["items"]
|
77
77
|
@owners = entities_from_acls acls, "OWNER"
|
78
78
|
@writers = entities_from_acls acls, "WRITER"
|
79
79
|
@readers = entities_from_acls acls, "READER"
|
80
80
|
end
|
81
|
+
alias_method :refresh!, :reload!
|
81
82
|
|
82
83
|
##
|
83
84
|
# Lists the owners of the bucket.
|
@@ -98,7 +99,7 @@ module Gcloud
|
|
98
99
|
# bucket.acl.owners.each { |owner| puts owner }
|
99
100
|
#
|
100
101
|
def owners
|
101
|
-
|
102
|
+
reload! if @owners.nil?
|
102
103
|
@owners
|
103
104
|
end
|
104
105
|
|
@@ -121,7 +122,7 @@ module Gcloud
|
|
121
122
|
# bucket.acl.writers.each { |writer| puts writer }
|
122
123
|
#
|
123
124
|
def writers
|
124
|
-
|
125
|
+
reload! if @writers.nil?
|
125
126
|
@writers
|
126
127
|
end
|
127
128
|
|
@@ -144,7 +145,7 @@ module Gcloud
|
|
144
145
|
# bucket.acl.readers.each { |reader| puts reader }
|
145
146
|
#
|
146
147
|
def readers
|
147
|
-
|
148
|
+
reload! if @readers.nil?
|
148
149
|
@readers
|
149
150
|
end
|
150
151
|
|
@@ -535,15 +536,16 @@ module Gcloud
|
|
535
536
|
#
|
536
537
|
# bucket = storage.bucket "my-bucket"
|
537
538
|
#
|
538
|
-
# bucket.default_acl.
|
539
|
+
# bucket.default_acl.reload!
|
539
540
|
#
|
540
|
-
def
|
541
|
+
def reload!
|
541
542
|
resp = @connection.list_default_acls @bucket
|
542
543
|
acls = resp.data["items"]
|
543
544
|
@owners = entities_from_acls acls, "OWNER"
|
544
545
|
@writers = entities_from_acls acls, "WRITER"
|
545
546
|
@readers = entities_from_acls acls, "READER"
|
546
547
|
end
|
548
|
+
alias_method :refresh!, :reload!
|
547
549
|
|
548
550
|
##
|
549
551
|
# Lists the default owners for files in the bucket.
|
@@ -564,7 +566,7 @@ module Gcloud
|
|
564
566
|
# bucket.default_acl.owners.each { |owner| puts owner }
|
565
567
|
#
|
566
568
|
def owners
|
567
|
-
|
569
|
+
reload! if @owners.nil?
|
568
570
|
@owners
|
569
571
|
end
|
570
572
|
|
@@ -587,7 +589,7 @@ module Gcloud
|
|
587
589
|
# bucket.default_acl.writers.each { |writer| puts writer }
|
588
590
|
#
|
589
591
|
def writers
|
590
|
-
|
592
|
+
reload! if @writers.nil?
|
591
593
|
@writers
|
592
594
|
end
|
593
595
|
|
@@ -610,7 +612,7 @@ module Gcloud
|
|
610
612
|
# bucket.default_acl.readers.each { |reader| puts reader }
|
611
613
|
#
|
612
614
|
def readers
|
613
|
-
|
615
|
+
reload! if @readers.nil?
|
614
616
|
@readers
|
615
617
|
end
|
616
618
|
|
@@ -34,7 +34,7 @@ module Gcloud
|
|
34
34
|
|
35
35
|
##
|
36
36
|
# New Bucket::List from a response object.
|
37
|
-
def self.
|
37
|
+
def self.from_response resp, conn #:nodoc:
|
38
38
|
buckets = Array(resp.data["items"]).map do |gapi_object|
|
39
39
|
Bucket.from_gapi gapi_object, conn
|
40
40
|
end
|
data/lib/gcloud/storage/file.rb
CHANGED
@@ -463,6 +463,19 @@ module Gcloud
|
|
463
463
|
@acl ||= File::Acl.new self
|
464
464
|
end
|
465
465
|
|
466
|
+
##
|
467
|
+
# Reloads the file with current data from the Storage service.
|
468
|
+
def reload!
|
469
|
+
ensure_connection!
|
470
|
+
resp = connection.get_file bucket, name
|
471
|
+
if resp.success?
|
472
|
+
@gapi = resp.data
|
473
|
+
else
|
474
|
+
fail ApiError.from_response(resp)
|
475
|
+
end
|
476
|
+
end
|
477
|
+
alias_method :refresh!, :reload!
|
478
|
+
|
466
479
|
##
|
467
480
|
# URI of the location and file name in the format of
|
468
481
|
# <code>gs://my-bucket/file-name.json</code>.
|
@@ -73,15 +73,16 @@ module Gcloud
|
|
73
73
|
# bucket = storage.bucket "my-bucket"
|
74
74
|
#
|
75
75
|
# file = bucket.file "path/to/my-file.ext"
|
76
|
-
# file.acl.
|
76
|
+
# file.acl.reload!
|
77
77
|
#
|
78
|
-
def
|
78
|
+
def reload!
|
79
79
|
resp = @connection.list_file_acls @bucket, @file
|
80
80
|
acls = resp.data["items"]
|
81
81
|
@owners = entities_from_acls acls, "OWNER"
|
82
82
|
@writers = entities_from_acls acls, "WRITER"
|
83
83
|
@readers = entities_from_acls acls, "READER"
|
84
84
|
end
|
85
|
+
alias_method :refresh!, :reload!
|
85
86
|
|
86
87
|
##
|
87
88
|
# Lists the owners of the file.
|
@@ -103,7 +104,7 @@ module Gcloud
|
|
103
104
|
# file.acl.owners.each { |owner| puts owner }
|
104
105
|
#
|
105
106
|
def owners
|
106
|
-
|
107
|
+
reload! if @owners.nil?
|
107
108
|
@owners
|
108
109
|
end
|
109
110
|
|
@@ -127,7 +128,7 @@ module Gcloud
|
|
127
128
|
# file.acl.writers.each { |writer| puts writer }
|
128
129
|
#
|
129
130
|
def writers
|
130
|
-
|
131
|
+
reload! if @writers.nil?
|
131
132
|
@writers
|
132
133
|
end
|
133
134
|
|
@@ -151,7 +152,7 @@ module Gcloud
|
|
151
152
|
# file.acl.readers.each { |reader| puts reader }
|
152
153
|
#
|
153
154
|
def readers
|
154
|
-
|
155
|
+
reload! if @readers.nil?
|
155
156
|
@readers
|
156
157
|
end
|
157
158
|
|
@@ -13,6 +13,7 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
+
require "gcloud/gce"
|
16
17
|
require "gcloud/storage/errors"
|
17
18
|
require "gcloud/storage/connection"
|
18
19
|
require "gcloud/storage/credentials"
|
@@ -79,7 +80,8 @@ module Gcloud
|
|
79
80
|
def self.default_project #:nodoc:
|
80
81
|
ENV["STORAGE_PROJECT"] ||
|
81
82
|
ENV["GCLOUD_PROJECT"] ||
|
82
|
-
ENV["GOOGLE_CLOUD_PROJECT"]
|
83
|
+
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
84
|
+
Gcloud::GCE.project_id
|
83
85
|
end
|
84
86
|
|
85
87
|
##
|
@@ -147,7 +149,7 @@ module Gcloud
|
|
147
149
|
def buckets options = {}
|
148
150
|
resp = connection.list_buckets options
|
149
151
|
if resp.success?
|
150
|
-
Bucket::List.
|
152
|
+
Bucket::List.from_response resp, connection
|
151
153
|
else
|
152
154
|
fail ApiError.from_response(resp)
|
153
155
|
end
|
data/lib/gcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Silvano Luciani
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beefcake
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/gcloud/bigquery/credentials.rb
|
230
230
|
- lib/gcloud/bigquery/data.rb
|
231
231
|
- lib/gcloud/bigquery/dataset.rb
|
232
|
+
- lib/gcloud/bigquery/dataset/access.rb
|
232
233
|
- lib/gcloud/bigquery/dataset/list.rb
|
233
234
|
- lib/gcloud/bigquery/errors.rb
|
234
235
|
- lib/gcloud/bigquery/extract_job.rb
|
@@ -241,6 +242,7 @@ files:
|
|
241
242
|
- lib/gcloud/bigquery/query_job.rb
|
242
243
|
- lib/gcloud/bigquery/table.rb
|
243
244
|
- lib/gcloud/bigquery/table/list.rb
|
245
|
+
- lib/gcloud/bigquery/table/schema.rb
|
244
246
|
- lib/gcloud/bigquery/view.rb
|
245
247
|
- lib/gcloud/credentials.rb
|
246
248
|
- lib/gcloud/datastore.rb
|
@@ -256,6 +258,8 @@ files:
|
|
256
258
|
- lib/gcloud/datastore/proto.rb
|
257
259
|
- lib/gcloud/datastore/query.rb
|
258
260
|
- lib/gcloud/datastore/transaction.rb
|
261
|
+
- lib/gcloud/errors.rb
|
262
|
+
- lib/gcloud/gce.rb
|
259
263
|
- lib/gcloud/proto/datastore_v1.pb.rb
|
260
264
|
- lib/gcloud/pubsub.rb
|
261
265
|
- lib/gcloud/pubsub/connection.rb
|