google-cloud-storage 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 785ee684ed3d6225bea9ef029a33739162b73482
4
- data.tar.gz: 795d5c813467496884077148427406a138086e3d
3
+ metadata.gz: 234c7b1b0ea7f2033e0428c202ca6fc5a9390f68
4
+ data.tar.gz: 54912b87f802825f3d4a6a88126a20d826e382d3
5
5
  SHA512:
6
- metadata.gz: 8d943e560150efb216a55999bcf327277bccf5b12329a6b382147a16a29e1509e4c722c28993bf1cd626b88f51b4cec4d444b141df3881fea2595a7b4e45262c
7
- data.tar.gz: 1a74ee5f03dff72f2ab1cdb7568bab73cb6b7d5ece7818f310712b8dff0e67e0e9eccfe2c178c36c1dd51763008b20f59d0f08c757a08ce159c47e26fce8717b
6
+ metadata.gz: 4c813e0e7bae98753ad441d4a015ace5cab50d053821cbbcc0a64ab2fd4705f7f83707f122c225e8251816df667855098992485720c37b4ceff8dff2c55d768b
7
+ data.tar.gz: 0fde8c69671d845976c975aa67d6520d1421ff8e25ae8140625350e83bd9dd649eabd6fd31dc83aed6f0f0f6b32d3bb1456d493f67f3ea08f0e17705686dcf14
@@ -439,8 +439,7 @@ module Google
439
439
  #
440
440
  # The requester pays feature enables the owner of a bucket to indicate that
441
441
  # a client accessing the bucket or a file it contains must assume the
442
- # transit costs related to the access. This feature is currently available
443
- # only to whitelisted projects.
442
+ # transit costs related to the access.
444
443
  #
445
444
  # Assign transit costs for bucket and file operations to requesting clients
446
445
  # with the `requester_pays` flag:
@@ -48,23 +48,20 @@ module Google
48
48
  attr_accessor :gapi
49
49
 
50
50
  ##
51
- # A boolean value or a project ID string for a requester pays
52
- # bucket and its files. If this attribute is set to `true`, transit
53
- # costs for operations on the bucket will be billed to the current
54
- # project for this client. (See {Project#project} for the ID of the
55
- # current project.) If this attribute is set to a project ID, and that
56
- # project is authorized for the currently authenticated service account,
57
- # transit costs will be billed to the that project. The default is
58
- # `nil`.
51
+ # A boolean value or a project ID string to indicate the project to
52
+ # be billed for operations on the bucket and its files. If this
53
+ # attribute is set to `true`, transit costs for operations on the bucket
54
+ # will be billed to the current project for this client. (See
55
+ # {Project#project} for the ID of the current project.) If this
56
+ # attribute is set to a project ID, and that project is authorized for
57
+ # the currently authenticated service account, transit costs will be
58
+ # billed to that project. This attribute is required with requester
59
+ # pays-enabled buckets. The default is `nil`.
59
60
  #
60
61
  # In general, this attribute should be set when first retrieving the
61
62
  # bucket by providing the `user_project` option to {Project#bucket}.
62
63
  #
63
- # The requester pays feature is currently available only to whitelisted
64
- # projects.
65
- #
66
- # See also {#requester_pays=} and {#requester_pays} to enable requester
67
- # pays for a bucket.
64
+ # See also {#requester_pays=} and {#requester_pays}.
68
65
  #
69
66
  # @example Setting a non-default project:
70
67
  # require "google/cloud/storage"
@@ -346,8 +343,6 @@ module Google
346
343
  # {Project#buckets} to indicate the project to which the access costs
347
344
  # should be billed.
348
345
  #
349
- # This feature is currently available only to whitelisted projects.
350
- #
351
346
  # @return [Boolean, nil] Returns `true` if requester pays is enabled for
352
347
  # the bucket.
353
348
  #
@@ -363,8 +358,6 @@ module Google
363
358
  # {Project#bucket} and {Project#buckets} to indicate the project to
364
359
  # which the access costs should be billed.
365
360
  #
366
- # This feature is currently available only to whitelisted projects.
367
- #
368
361
  # @param [Boolean] new_requester_pays When set to `true`, requester pays
369
362
  # is enabled for the bucket.
370
363
  #
@@ -713,6 +706,116 @@ module Google
713
706
  alias_method :upload_file, :create_file
714
707
  alias_method :new_file, :create_file
715
708
 
709
+ ##
710
+ # Concatenates a list of existing files in the bucket into a new file in
711
+ # the bucket. There is a limit (currently 32) to the number of files
712
+ # that can be composed in a single operation.
713
+ #
714
+ # To compose files encrypted with a customer-supplied encryption key,
715
+ # use the `encryption_key` option. All source files must have been
716
+ # encrypted with the same key, and the resulting destination file will
717
+ # also be encrypted with the same key.
718
+ #
719
+ # @param [Array<String, Google::Cloud::Storage::File>] sources The list
720
+ # of source file names or objects that will be concatenated into a
721
+ # single file.
722
+ # @param [String] destination The name of the new file.
723
+ # @param [String] acl A predefined set of access controls to apply to
724
+ # this file.
725
+ #
726
+ # Acceptable values are:
727
+ #
728
+ # * `auth`, `auth_read`, `authenticated`, `authenticated_read`,
729
+ # `authenticatedRead` - File owner gets OWNER access, and
730
+ # allAuthenticatedUsers get READER access.
731
+ # * `owner_full`, `bucketOwnerFullControl` - File owner gets OWNER
732
+ # access, and project team owners get OWNER access.
733
+ # * `owner_read`, `bucketOwnerRead` - File owner gets OWNER access,
734
+ # and project team owners get READER access.
735
+ # * `private` - File owner gets OWNER access.
736
+ # * `project_private`, `projectPrivate` - File owner gets OWNER
737
+ # access, and project team members get access according to their
738
+ # roles.
739
+ # * `public`, `public_read`, `publicRead` - File owner gets OWNER
740
+ # access, and allUsers get READER access.
741
+ #
742
+ # @param [String, nil] encryption_key Optional. The customer-supplied,
743
+ # AES-256 encryption key used to encrypt the source files, if one was
744
+ # used. All source files must have been encrypted with the same key,
745
+ # and the resulting destination file will also be encrypted with the
746
+ # key.
747
+ #
748
+ # @yield [file] A block yielding a delegate file object for setting the
749
+ # properties of the destination file.
750
+ #
751
+ # @return [Google::Cloud::Storage::File] The new file.
752
+ #
753
+ # @example
754
+ # require "google/cloud/storage"
755
+ #
756
+ # storage = Google::Cloud::Storage.new
757
+ #
758
+ # bucket = storage.bucket "my-bucket"
759
+ #
760
+ # sources = ["path/to/my-file-1.ext", "path/to/my-file-2.ext"]
761
+ #
762
+ # new_file = bucket.compose sources, "path/to/new-file.ext"
763
+ #
764
+ # @example Set the properties of the new file in a block:
765
+ # require "google/cloud/storage"
766
+ #
767
+ # storage = Google::Cloud::Storage.new
768
+ #
769
+ # bucket = storage.bucket "my-bucket"
770
+ #
771
+ # sources = ["path/to/my-file-1.ext", "path/to/my-file-2.ext"]
772
+ #
773
+ # new_file = bucket.compose sources, "path/to/new-file.ext" do |f|
774
+ # f.cache_control = "private, max-age=0, no-cache"
775
+ # f.content_disposition = "inline; filename=filename.ext"
776
+ # f.content_encoding = "deflate"
777
+ # f.content_language = "de"
778
+ # f.content_type = "application/json"
779
+ # end
780
+ #
781
+ # @example Specify the generation of source files (but skip retrieval):
782
+ # require "google/cloud/storage"
783
+ #
784
+ # storage = Google::Cloud::Storage.new
785
+ #
786
+ # bucket = storage.bucket "my-bucket"
787
+ #
788
+ # file_1 = bucket.file "path/to/my-file-1.ext",
789
+ # generation: 1490390259479000, skip_lookup: true
790
+ # file_2 = bucket.file "path/to/my-file-2.ext",
791
+ # generation: 1490310974144000, skip_lookup: true
792
+ #
793
+ # new_file = bucket.compose [file_1, file_2], "path/to/new-file.ext"
794
+ #
795
+ def compose sources, destination, acl: nil, encryption_key: nil
796
+ ensure_service!
797
+ sources = Array sources
798
+ if sources.size < 2
799
+ fail ArgumentError, "must provide at least two source files"
800
+ end
801
+
802
+ options = { acl: File::Acl.predefined_rule_for(acl),
803
+ key: encryption_key,
804
+ user_project: user_project }
805
+ destination_gapi = nil
806
+ if block_given?
807
+ destination_gapi = Google::Apis::StorageV1::Object.new
808
+ updater = File::Updater.new destination_gapi
809
+ yield updater
810
+ updater.check_for_changed_metadata!
811
+ end
812
+ gapi = service.compose_file name, sources, destination,
813
+ destination_gapi, options
814
+ File.from_gapi gapi, service
815
+ end
816
+ alias_method :compose_file, :compose
817
+ alias_method :combine, :compose
818
+
716
819
  ##
717
820
  # Access without authentication can be granted to a File for a specified
718
821
  # period of time. This URL uses a cryptographic signature of your
@@ -49,24 +49,21 @@ module Google
49
49
  "public_write" => "publicReadWrite" }
50
50
 
51
51
  ##
52
- # A boolean value or a project ID string for a requester pays
53
- # bucket and its files. If this attribute is set to `true`, transit
54
- # costs for operations on the bucket will be billed to the current
55
- # project for this client. (See {Project#project} for the ID of the
56
- # current project.) If this attribute is set to a project ID, and that
57
- # project is authorized for the currently authenticated service
58
- # account, transit costs will be billed to the that project. The
59
- # default is `nil`.
52
+ # A boolean value or a project ID string to indicate the project to
53
+ # be billed for operations on the bucket and its files. If this
54
+ # attribute is set to `true`, transit costs for operations on the
55
+ # bucket will be billed to the current project for this client. (See
56
+ # {Project#project} for the ID of the current project.) If this
57
+ # attribute is set to a project ID, and that project is authorized for
58
+ # the currently authenticated service account, transit costs will be
59
+ # billed to that project. This attribute is required with requester
60
+ # pays-enabled buckets. The default is `nil`.
60
61
  #
61
62
  # In general, this attribute should be set when first retrieving the
62
63
  # owning bucket by providing the `user_project` option to
63
64
  # {Project#bucket}.
64
65
  #
65
- # The requester pays feature is currently available only to
66
- # whitelisted projects.
67
- #
68
- # See also {Bucket#requester_pays=} and {Bucket#requester_pays} to
69
- # enable requester pays for a bucket.
66
+ # See also {Bucket#requester_pays=} and {Bucket#requester_pays}.
70
67
  #
71
68
  attr_accessor :user_project
72
69
 
@@ -476,24 +473,21 @@ module Google
476
473
  "public_read" => "publicRead" }
477
474
 
478
475
  ##
479
- # A boolean value or a project ID string for a requester pays
480
- # bucket and its files. If this attribute is set to `true`, transit
481
- # costs for operations on the bucket will be billed to the current
482
- # project for this client. (See {Project#project} for the ID of the
483
- # current project.) If this attribute is set to a project ID, and that
484
- # project is authorized for the currently authenticated service
485
- # account, transit costs will be billed to the that project. The
486
- # default is `nil`.
476
+ # A boolean value or a project ID string to indicate the project to
477
+ # be billed for operations on the bucket and its files. If this
478
+ # attribute is set to `true`, transit costs for operations on the
479
+ # bucket will be billed to the current project for this client. (See
480
+ # {Project#project} for the ID of the current project.) If this
481
+ # attribute is set to a project ID, and that project is authorized for
482
+ # the currently authenticated service account, transit costs will be
483
+ # billed to that project. This attribute is required with requester
484
+ # pays-enabled buckets. The default is `nil`.
487
485
  #
488
486
  # In general, this attribute should be set when first retrieving the
489
487
  # owning bucket by providing the `user_project` option to
490
488
  # {Project#bucket}.
491
489
  #
492
- # The requester pays feature is currently available only to
493
- # whitelisted projects.
494
- #
495
- # See also {Bucket#requester_pays=} and {Bucket#requester_pays} to
496
- # enable requester pays for a bucket.
490
+ # See also {Bucket#requester_pays=} and {Bucket#requester_pays}.
497
491
  #
498
492
  attr_accessor :user_project
499
493
 
@@ -60,7 +60,8 @@ module Google
60
60
  # {Project#project} for the ID of the current project.) If this
61
61
  # attribute is set to a project ID, and that project is authorized for
62
62
  # the currently authenticated service account, transit costs will be
63
- # billed to the that project. The default is `nil`.
63
+ # billed to that project. This attribute is required with requester
64
+ # pays-enabled buckets. The default is `nil`.
64
65
  #
65
66
  # In general, this attribute should be set when first retrieving the
66
67
  # owning bucket by providing the `user_project` option to
@@ -51,24 +51,21 @@ module Google
51
51
  "public_read" => "publicRead" }
52
52
 
53
53
  ##
54
- # A boolean value or a project ID string for a requester pays
55
- # bucket and its files. If this attribute is set to `true`, transit
56
- # costs for operations on the file will be billed to the current
57
- # project for this client. (See {Project#project} for the ID of the
58
- # current project.) If this attribute is set to a project ID, and that
59
- # project is authorized for the currently authenticated service
60
- # account, transit costs will be billed to the that project. The
61
- # default is `nil`.
54
+ # A boolean value or a project ID string to indicate the project to
55
+ # be billed for operations on the bucket and its files. If this
56
+ # attribute is set to `true`, transit costs for operations on the
57
+ # bucket will be billed to the current project for this client. (See
58
+ # {Project#project} for the ID of the current project.) If this
59
+ # attribute is set to a project ID, and that project is authorized for
60
+ # the currently authenticated service account, transit costs will be
61
+ # billed to that project. This attribute is required with requester
62
+ # pays-enabled buckets. The default is `nil`.
62
63
  #
63
64
  # In general, this attribute should be set when first retrieving the
64
65
  # owning bucket by providing the `user_project` option to
65
66
  # {Project#bucket}.
66
67
  #
67
- # The requester pays feature is currently available only to
68
- # whitelisted projects.
69
- #
70
- # See also {Bucket#requester_pays=} and {Bucket#requester_pays} to
71
- # enable requester pays for a bucket.
68
+ # See also {Bucket#requester_pays=} and {Bucket#requester_pays}.
72
69
  #
73
70
  attr_accessor :user_project
74
71
 
@@ -60,7 +60,8 @@ module Google
60
60
  attr_accessor :gapi
61
61
 
62
62
  ##
63
- # @private The project ID string for a requester pays bucket.
63
+ # @private A boolean value or a project ID string to indicate the
64
+ # project to be billed for operations.
64
65
  attr_accessor :user_project
65
66
 
66
67
  attr_reader :bucket
@@ -99,8 +99,8 @@ module Google
99
99
  # {#project} for the ID of the current project.) If this parameter is
100
100
  # set to a project ID other than the current project, and that project
101
101
  # is authorized for the currently authenticated service account,
102
- # transit costs will be billed to the given project. The default is
103
- # `nil`.
102
+ # transit costs will be billed to the given project. This parameter is
103
+ # required with requester pays-enabled buckets. The default is `nil`.
104
104
  #
105
105
  # The value provided will be applied to all operations on the returned
106
106
  # bucket instances and their files.
@@ -162,7 +162,8 @@ module Google
162
162
  # client. (See {#project} for the ID of the current project.) If this
163
163
  # parameter is set to a project ID other than the current project, and
164
164
  # that project is authorized for the currently authenticated service
165
- # account, transit costs will be billed to the given project. The
165
+ # account, transit costs will be billed to the given project. This
166
+ # parameter is required with requester pays-enabled buckets. The
166
167
  # default is `nil`.
167
168
  #
168
169
  # The value provided will be applied to all operations on the returned
@@ -181,7 +182,7 @@ module Google
181
182
  # bucket = storage.bucket "my-bucket"
182
183
  # puts bucket.name
183
184
  #
184
- # @example With `user_project` set to pay for a requester pays bucket:
185
+ # @example With `user_project` set to bill costs to the default project:
185
186
  # require "google/cloud/storage"
186
187
  #
187
188
  # storage = Google::Cloud::Storage.new
@@ -347,6 +347,25 @@ module Google
347
347
  end
348
348
  end
349
349
 
350
+ ## Copy a file from source bucket/object to a
351
+ # destination bucket/object.
352
+ def compose_file bucket_name, source_files, destination_path,
353
+ destination_gapi, acl: nil, key: nil, user_project: nil
354
+
355
+ compose_req = Google::Apis::StorageV1::ComposeRequest.new \
356
+ source_objects: compose_file_source_objects(source_files),
357
+ destination: destination_gapi
358
+
359
+ execute do
360
+ service.compose_object \
361
+ bucket_name, destination_path,
362
+ compose_req,
363
+ destination_predefined_acl: acl,
364
+ user_project: user_project(user_project),
365
+ options: key_options(key)
366
+ end
367
+ end
368
+
350
369
  ##
351
370
  # Download contents of a file.
352
371
  def download_file bucket_name, file_path, target_path, generation: nil,
@@ -504,6 +523,19 @@ module Google
504
523
  "false" => "NONE" }[str_or_bool.to_s.downcase]
505
524
  end
506
525
 
526
+ def compose_file_source_objects source_files
527
+ source_files.map do |file|
528
+ if file.is_a? Google::Cloud::Storage::File
529
+ Google::Apis::StorageV1::ComposeRequest::SourceObject.new \
530
+ name: file.name,
531
+ generation: file.generation
532
+ else
533
+ Google::Apis::StorageV1::ComposeRequest::SourceObject.new \
534
+ name: file
535
+ end
536
+ end
537
+ end
538
+
507
539
  def execute
508
540
  yield
509
541
  rescue Google::Apis::Error => e
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.6.0"
19
+ VERSION = "1.7.0"
20
20
  end
21
21
  end
22
22
  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.6.0
4
+ version: 1.7.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: 2017-09-29 00:00:00.000000000 Z
12
+ date: 2017-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  version: '0'
230
230
  requirements: []
231
231
  rubyforge_project:
232
- rubygems_version: 2.6.13
232
+ rubygems_version: 2.6.14
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: API Client library for Google Cloud Storage