google-cloud-storage 1.16.0 → 1.17.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
  SHA256:
3
- metadata.gz: 49f8e8d016fa4aab87babc4c20e8f471eb9923c3263625668aa2eb7fe029dc0a
4
- data.tar.gz: bf4bbdd4b7570a58a8d63184ef5869c9b7d0ca0870d7044f64158ff6dcd8af9e
3
+ metadata.gz: 99549b865b9a4222f87a79ca84f7bfb6f9291e48284fd27a8be32cd91a7fe6d5
4
+ data.tar.gz: b4aee052f8aa4f56caa8c37ddd1d8cac51ad562f85f8bb1b14f9166bc7d65bd2
5
5
  SHA512:
6
- metadata.gz: 413d832b96b41b17733db3f50ae67e1d79322da88161bb8857c1eff5caf8e6ddc26fea2833090e261b00883d294b398f587c25f86cead52cbb13c37cce2dd4a8
7
- data.tar.gz: 94926a277a7c7f296b6789cbbd4022a96a6ee34b4ac00041b4bb68f87af3c1ad448211b7627266a9cce557bd7d2d2e464a2156866de8938f5f8855a59877f43a
6
+ metadata.gz: 02ff1dab5acafa5b56ee161c1cae21fabd901f6e6edecd802d511c17732d8f837ac4e723babed90feaf2c54054880a36e908302b5ea64dc308e86107858fcc39
7
+ data.tar.gz: d154a90c24ae673416bb3759d040bb9299cd3a6c53b53b3406a4fe663b525cda298b5fc69da041e828cb7503faf3f7f4380e878bfb3a01dc4b962f71e7ec2b1f
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 1.17.0 / 2019-02-07
4
+
5
+ * Add support for Bucket Policy Only with `Bucket#policy_only?`,
6
+ `Bucket#policy_only=` and `Bucket#policy_only_locked_at`.
7
+ Read more at https://cloud.google.com/storage/docs/bucket-policy-only
8
+
3
9
  ### 1.16.0 / 2019-02-01
4
10
 
5
11
  * Make use of Credentials#project_id
@@ -42,6 +42,10 @@ module Google
42
42
  #
43
43
  class Bucket
44
44
  include Convert
45
+ ##
46
+ # @private Alias to the Google Client API module
47
+ API = Google::Apis::StorageV1
48
+
45
49
  ##
46
50
  # @private The Service object.
47
51
  attr_accessor :service
@@ -82,7 +86,7 @@ module Google
82
86
  # @private Create an empty Bucket object.
83
87
  def initialize
84
88
  @service = nil
85
- @gapi = Google::Apis::StorageV1::Bucket.new
89
+ @gapi = API::Bucket.new
86
90
  @user_project = nil
87
91
  end
88
92
 
@@ -300,7 +304,7 @@ module Google
300
304
  # @param [String] logging_bucket The bucket to hold the logging output
301
305
  #
302
306
  def logging_bucket= logging_bucket
303
- @gapi.logging ||= Google::Apis::StorageV1::Bucket::Logging.new
307
+ @gapi.logging ||= API::Bucket::Logging.new
304
308
  @gapi.logging.log_bucket = logging_bucket
305
309
  patch_gapi! :logging
306
310
  end
@@ -329,7 +333,7 @@ module Google
329
333
  # @param [String] logging_prefix The logging object prefix.
330
334
  #
331
335
  def logging_prefix= logging_prefix
332
- @gapi.logging ||= Google::Apis::StorageV1::Bucket::Logging.new
336
+ @gapi.logging ||= API::Bucket::Logging.new
333
337
  @gapi.logging.log_object_prefix = logging_prefix
334
338
  patch_gapi! :logging
335
339
  end
@@ -381,7 +385,7 @@ module Google
381
385
  # for the bucket.
382
386
  #
383
387
  def versioning= new_versioning
384
- @gapi.versioning ||= Google::Apis::StorageV1::Bucket::Versioning.new
388
+ @gapi.versioning ||= API::Bucket::Versioning.new
385
389
  @gapi.versioning.enabled = new_versioning
386
390
  patch_gapi! :versioning
387
391
  end
@@ -411,7 +415,7 @@ module Google
411
415
  # @param [String] website_main The main page suffix.
412
416
  #
413
417
  def website_main= website_main
414
- @gapi.website ||= Google::Apis::StorageV1::Bucket::Website.new
418
+ @gapi.website ||= API::Bucket::Website.new
415
419
  @gapi.website.main_page_suffix = website_main
416
420
  patch_gapi! :website
417
421
  end
@@ -459,7 +463,7 @@ module Google
459
463
  # How to Host a Static Website
460
464
  #
461
465
  def website_404= website_404
462
- @gapi.website ||= Google::Apis::StorageV1::Bucket::Website.new
466
+ @gapi.website ||= API::Bucket::Website.new
463
467
  @gapi.website.not_found_page = website_404
464
468
  patch_gapi! :website
465
469
  end
@@ -501,7 +505,7 @@ module Google
501
505
  # # Project#bucket or Project#buckets to access this bucket.
502
506
  #
503
507
  def requester_pays= new_requester_pays
504
- @gapi.billing ||= Google::Apis::StorageV1::Bucket::Billing.new
508
+ @gapi.billing ||= API::Bucket::Billing.new
505
509
  @gapi.billing.requester_pays = new_requester_pays
506
510
  patch_gapi! :billing
507
511
  end
@@ -549,7 +553,7 @@ module Google
549
553
  # bucket.default_kms_key = kms_key_name
550
554
  #
551
555
  def default_kms_key= new_default_kms_key
552
- @gapi.encryption = Google::Apis::StorageV1::Bucket::Encryption.new \
556
+ @gapi.encryption = API::Bucket::Encryption.new \
553
557
  default_kms_key_name: new_default_kms_key
554
558
  patch_gapi! :encryption
555
559
  end
@@ -604,8 +608,7 @@ module Google
604
608
  if new_retention_period.nil?
605
609
  @gapi.retention_policy = nil
606
610
  else
607
- @gapi.retention_policy ||= \
608
- Google::Apis::StorageV1::Bucket::RetentionPolicy.new
611
+ @gapi.retention_policy ||= API::Bucket::RetentionPolicy.new
609
612
  @gapi.retention_policy.retention_period = new_retention_period
610
613
  end
611
614
 
@@ -757,6 +760,100 @@ module Google
757
760
  true
758
761
  end
759
762
 
763
+ ##
764
+ # Whether the bucket's file IAM configuration enables Bucket Policy
765
+ # Only. The default is false. This value can be modified by calling
766
+ # {Bucket#policy_only=}.
767
+ #
768
+ # If true, access checks only use bucket-level IAM policies or above,
769
+ # all object ACLs within the bucket are no longer evaluated, and
770
+ # access-control is configured solely through the bucket's IAM policy.
771
+ # Any requests which attempt to use the ACL API to view or manipulate
772
+ # ACLs will fail with 400 errors.
773
+ #
774
+ # @return [Boolean] Returns `false` if the bucket has no IAM
775
+ # configuration or if Bucket Policy Only is not enabled in the IAM
776
+ # configuration. Returns `true` if Bucket Policy Only is enabled in
777
+ # the IAM configuration.
778
+ #
779
+ # @example
780
+ # require "google/cloud/storage"
781
+ #
782
+ # storage = Google::Cloud::Storage.new
783
+ #
784
+ # bucket = storage.bucket "my-bucket"
785
+ #
786
+ # bucket.policy_only = true
787
+ # bucket.policy_only? # true
788
+ #
789
+ def policy_only?
790
+ return false unless @gapi.iam_configuration &&
791
+ @gapi.iam_configuration.bucket_policy_only
792
+ !@gapi.iam_configuration.bucket_policy_only.enabled.nil? &&
793
+ @gapi.iam_configuration.bucket_policy_only.enabled
794
+ end
795
+
796
+ ##
797
+ # If enabled, access checks only use bucket-level IAM policies or above,
798
+ # all object ACLs within the bucket are no longer evaluated, and
799
+ # access-control is configured solely through the bucket's IAM policy.
800
+ # Any requests which attempt to use the ACL API to view or manipulate
801
+ # ACLs will fail with 400 errors.
802
+ #
803
+ # @param [Boolean] new_policy_only When set to `true`, Bucket Policy
804
+ # Only is enabled in the bucket's IAM configuration.
805
+ #
806
+ # @example
807
+ # require "google/cloud/storage"
808
+ #
809
+ # storage = Google::Cloud::Storage.new
810
+ #
811
+ # bucket = storage.bucket "my-bucket"
812
+ #
813
+ # bucket.policy_only = true
814
+ # bucket.policy_only? # true
815
+ #
816
+ # bucket.default_acl.public! # Google::Cloud::InvalidArgumentError
817
+ #
818
+ # # The deadline for disabling Bucket Policy Only.
819
+ # puts bucket.policy_only_locked_at
820
+ #
821
+ def policy_only= new_policy_only
822
+ @gapi.iam_configuration ||= API::Bucket::IamConfiguration.new \
823
+ bucket_policy_only: \
824
+ API::Bucket::IamConfiguration::BucketPolicyOnly.new
825
+ @gapi.iam_configuration.bucket_policy_only.enabled = new_policy_only
826
+ patch_gapi! :iam_configuration
827
+ end
828
+
829
+ ##
830
+ # The deadline time for disabling Bucket Policy Only by calling
831
+ # {Bucket#policy_only=}. After the locked time the Bucket Policy Only
832
+ # setting cannot be changed from true to false. Corresponds to the
833
+ # property `locked_time`.
834
+ #
835
+ # @return [DateTime, nil] The deadline time for changing
836
+ # {Bucket#policy_only=} from true to false, or `nil` if
837
+ # {Bucket#policy_only?} is false.
838
+ #
839
+ # @example
840
+ # require "google/cloud/storage"
841
+ #
842
+ # storage = Google::Cloud::Storage.new
843
+ #
844
+ # bucket = storage.bucket "my-bucket"
845
+ #
846
+ # bucket.policy_only = true
847
+ #
848
+ # # The deadline for disabling Bucket Policy Only.
849
+ # puts bucket.policy_only_locked_at
850
+ #
851
+ def policy_only_locked_at
852
+ return nil unless @gapi.iam_configuration &&
853
+ @gapi.iam_configuration.bucket_policy_only
854
+ @gapi.iam_configuration.bucket_policy_only.locked_time
855
+ end
856
+
760
857
  ##
761
858
  # Updates the bucket with changes made in the given block in a single
762
859
  # PATCH request. The following attributes may be set: {#cors},
@@ -1243,7 +1340,7 @@ module Google
1243
1340
  user_project: user_project }
1244
1341
  destination_gapi = nil
1245
1342
  if block_given?
1246
- destination_gapi = Google::Apis::StorageV1::Object.new
1343
+ destination_gapi = API::Object.new
1247
1344
  updater = File::Updater.new destination_gapi
1248
1345
  yield updater
1249
1346
  updater.check_for_changed_metadata!
@@ -1910,7 +2007,7 @@ module Google
1910
2007
  patch_args = Hash[attributes.map do |attr|
1911
2008
  [attr, @gapi.send(attr)]
1912
2009
  end]
1913
- patch_gapi = Google::Apis::StorageV1::Bucket.new patch_args
2010
+ patch_gapi = API::Bucket.new patch_args
1914
2011
  @gapi = service.patch_bucket name, patch_gapi,
1915
2012
  user_project: user_project
1916
2013
  @lazy = nil
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.16.0".freeze
19
+ VERSION = "1.17.0".freeze
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.16.0
4
+ version: 1.17.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: 2019-02-04 00:00:00.000000000 Z
12
+ date: 2019-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0.23'
34
+ version: '0.26'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0.23'
41
+ version: '0.26'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: googleauth
44
44
  requirement: !ruby/object:Gem::Requirement