google-cloud-storage 1.13.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +9 -1
- data/README.md +20 -11
- data/lib/google-cloud-storage.rb +4 -4
- data/lib/google/cloud/storage.rb +2 -602
- data/lib/google/cloud/storage/bucket.rb +93 -17
- data/lib/google/cloud/storage/bucket/cors.rb +57 -0
- data/lib/google/cloud/storage/bucket/lifecycle.rb +355 -0
- data/lib/google/cloud/storage/convert.rb +40 -0
- data/lib/google/cloud/storage/file.rb +2 -12
- data/lib/google/cloud/storage/notification.rb +3 -3
- data/lib/google/cloud/storage/project.rb +7 -13
- data/lib/google/cloud/storage/version.rb +1 -1
- metadata +8 -6
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Cloud
|
18
|
+
module Storage
|
19
|
+
##
|
20
|
+
# @private
|
21
|
+
#
|
22
|
+
# Internal conversion of raw data values to/from Storage values
|
23
|
+
module Convert
|
24
|
+
# @param [String,Symbol,Array<String,Symbol>] str
|
25
|
+
def storage_class_for str
|
26
|
+
return nil if str.nil?
|
27
|
+
return str.map { |s| storage_class_for s } if str.is_a? Array
|
28
|
+
{ "durable_reduced_availability" => "DURABLE_REDUCED_AVAILABILITY",
|
29
|
+
"dra" => "DURABLE_REDUCED_AVAILABILITY",
|
30
|
+
"durable" => "DURABLE_REDUCED_AVAILABILITY",
|
31
|
+
"nearline" => "NEARLINE",
|
32
|
+
"coldline" => "COLDLINE",
|
33
|
+
"multi_regional" => "MULTI_REGIONAL",
|
34
|
+
"regional" => "REGIONAL",
|
35
|
+
"standard" => "STANDARD" }[str.to_s.downcase] || str.to_s
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -13,6 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
|
16
|
+
require "google/cloud/storage/convert"
|
16
17
|
require "google/cloud/storage/file/acl"
|
17
18
|
require "google/cloud/storage/file/list"
|
18
19
|
require "google/cloud/storage/file/verifier"
|
@@ -62,6 +63,7 @@ module Google
|
|
62
63
|
# downloaded.read #=> "Hello world!"
|
63
64
|
#
|
64
65
|
class File
|
66
|
+
include Convert
|
65
67
|
##
|
66
68
|
# @private The Connection object.
|
67
69
|
attr_accessor :service
|
@@ -1486,18 +1488,6 @@ module Google
|
|
1486
1488
|
end
|
1487
1489
|
end
|
1488
1490
|
|
1489
|
-
def storage_class_for str
|
1490
|
-
return nil if str.nil?
|
1491
|
-
{ "durable_reduced_availability" => "DURABLE_REDUCED_AVAILABILITY",
|
1492
|
-
"dra" => "DURABLE_REDUCED_AVAILABILITY",
|
1493
|
-
"durable" => "DURABLE_REDUCED_AVAILABILITY",
|
1494
|
-
"nearline" => "NEARLINE",
|
1495
|
-
"coldline" => "COLDLINE",
|
1496
|
-
"multi_regional" => "MULTI_REGIONAL",
|
1497
|
-
"regional" => "REGIONAL",
|
1498
|
-
"standard" => "STANDARD" }[str.to_s.downcase] || str.to_s
|
1499
|
-
end
|
1500
|
-
|
1501
1491
|
##
|
1502
1492
|
# Yielded to a block to accumulate changes for a patch request.
|
1503
1493
|
class Updater < File
|
@@ -38,14 +38,14 @@ module Google
|
|
38
38
|
# require "google/cloud/storage"
|
39
39
|
#
|
40
40
|
# pubsub = Google::Cloud::Pubsub.new
|
41
|
+
# storage = Google::Cloud::Storage.new
|
42
|
+
#
|
41
43
|
# topic = pubsub.create_topic "my-topic"
|
42
44
|
# topic.policy do |p|
|
43
45
|
# p.add "roles/pubsub.publisher",
|
44
|
-
# "serviceAccount
|
45
|
-
# "@gs-project-accounts.iam.gserviceaccount.com"
|
46
|
+
# "serviceAccount:#{storage.service_account_email}"
|
46
47
|
# end
|
47
48
|
#
|
48
|
-
# storage = Google::Cloud::Storage.new
|
49
49
|
# bucket = storage.bucket "my-bucket"
|
50
50
|
#
|
51
51
|
# notification = bucket.create_notification topic.name
|
@@ -15,9 +15,11 @@
|
|
15
15
|
|
16
16
|
require "google/cloud/storage/errors"
|
17
17
|
require "google/cloud/storage/service"
|
18
|
+
require "google/cloud/storage/convert"
|
18
19
|
require "google/cloud/storage/credentials"
|
19
20
|
require "google/cloud/storage/bucket"
|
20
21
|
require "google/cloud/storage/bucket/cors"
|
22
|
+
require "google/cloud/storage/bucket/lifecycle"
|
21
23
|
require "google/cloud/storage/file"
|
22
24
|
|
23
25
|
module Google
|
@@ -46,6 +48,7 @@ module Google
|
|
46
48
|
# file = bucket.file "path/to/my-file.ext"
|
47
49
|
#
|
48
50
|
class Project
|
51
|
+
include Convert
|
49
52
|
##
|
50
53
|
# @private The Service object.
|
51
54
|
attr_accessor :service
|
@@ -318,7 +321,7 @@ module Google
|
|
318
321
|
#
|
319
322
|
# @yield [bucket] a block for configuring the bucket before it is
|
320
323
|
# created
|
321
|
-
# @yieldparam [Bucket]
|
324
|
+
# @yieldparam [Bucket] bucket the bucket object to be configured
|
322
325
|
#
|
323
326
|
# @return [Google::Cloud::Storage::Bucket]
|
324
327
|
#
|
@@ -342,6 +345,8 @@ module Google
|
|
342
345
|
# "*",
|
343
346
|
# headers: ["X-My-Custom-Header"],
|
344
347
|
# max_age: 300
|
348
|
+
#
|
349
|
+
# b.lifecycle.add_set_storage_class_rule "COLDLINE", age: 10
|
345
350
|
# end
|
346
351
|
#
|
347
352
|
def create_bucket bucket_name, acl: nil, default_acl: nil,
|
@@ -366,6 +371,7 @@ module Google
|
|
366
371
|
yield updater if block_given?
|
367
372
|
updater.check_for_changed_labels!
|
368
373
|
updater.check_for_mutable_cors!
|
374
|
+
updater.check_for_mutable_lifecycle!
|
369
375
|
gapi = service.insert_bucket \
|
370
376
|
new_bucket, acl: acl_rule(acl), default_acl: acl_rule(default_acl),
|
371
377
|
user_project: user_project
|
@@ -492,18 +498,6 @@ module Google
|
|
492
498
|
def acl_rule option_name
|
493
499
|
Bucket::Acl.predefined_rule_for option_name
|
494
500
|
end
|
495
|
-
|
496
|
-
def storage_class_for str
|
497
|
-
return nil if str.nil?
|
498
|
-
{ "durable_reduced_availability" => "DURABLE_REDUCED_AVAILABILITY",
|
499
|
-
"dra" => "DURABLE_REDUCED_AVAILABILITY",
|
500
|
-
"durable" => "DURABLE_REDUCED_AVAILABILITY",
|
501
|
-
"nearline" => "NEARLINE",
|
502
|
-
"coldline" => "COLDLINE",
|
503
|
-
"multi_regional" => "MULTI_REGIONAL",
|
504
|
-
"regional" => "REGIONAL",
|
505
|
-
"standard" => "STANDARD" }[str.to_s.downcase] || str.to_s
|
506
|
-
end
|
507
501
|
end
|
508
502
|
end
|
509
503
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -197,16 +197,16 @@ dependencies:
|
|
197
197
|
name: yard-doctest
|
198
198
|
requirement: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- - "
|
200
|
+
- - "~>"
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: 0.1.
|
202
|
+
version: 0.1.13
|
203
203
|
type: :development
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
|
-
- - "
|
207
|
+
- - "~>"
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: 0.1.
|
209
|
+
version: 0.1.13
|
210
210
|
description: google-cloud-storage is the official library for Google Cloud Storage.
|
211
211
|
email:
|
212
212
|
- mike@blowmage.com
|
@@ -223,7 +223,9 @@ files:
|
|
223
223
|
- lib/google/cloud/storage/bucket.rb
|
224
224
|
- lib/google/cloud/storage/bucket/acl.rb
|
225
225
|
- lib/google/cloud/storage/bucket/cors.rb
|
226
|
+
- lib/google/cloud/storage/bucket/lifecycle.rb
|
226
227
|
- lib/google/cloud/storage/bucket/list.rb
|
228
|
+
- lib/google/cloud/storage/convert.rb
|
227
229
|
- lib/google/cloud/storage/credentials.rb
|
228
230
|
- lib/google/cloud/storage/errors.rb
|
229
231
|
- lib/google/cloud/storage/file.rb
|