@@ -727,96 +727,99 @@ def default_kms_key= new_default_kms_key
727727 # #
728728 # storage = Google::Cloud::Storage.new
729729 # bucket = storage.bucket "my-bucket"
730- # bucket.customer_managed_encryption_enforcement_config #=> Google::Apis::StorageV1::Bucket::Encryption::CustomerManagedEncryptionEnforcementConfig.new
731- # restriction_mode: "NotRestricted"
730+ # bucket.customer_managed_encryption_enforcement_config
731+ # ==> #<Google::Apis::StorageV1::Bucket::Encryption::CustomerManagedEncryptionEnforcementConfig:0x00007f3b1c102e90 @restriction_mode= "NotRestricted">
732732 # The value for `restriction_mode` can be either "NotRestricted" or "FullyRestricted"
733733
734734 def customer_managed_encryption_enforcement_config
735735 @gapi . encryption &.customer_managed_encryption_enforcement_config
736736 end
737737 ##
738- # Sets the bucket's encryption configuration for customer-managed encryption that will be used to protect files.
739- # @param [Google::Apis::StorageV1::Bucket::Encryption::CustomerManagedEncryptionEnforcementConfig, nil] new_customer_managed_encryption_enforcement_config The bucket's encryption configuration, or `nil` to delete the encryption configuration.
740- # @example
738+ # Sets the customer-managed encryption enforcement configuration for the bucket.
739+ #
740+ # @param new_customer_managed_encryption_enforcement_config [Hash, nil]
741+ # The configuration hash for encryption enforcement.
742+ # * `:restriction_mode` (String) - Can be "NotRestricted" or "FullyRestricted".
743+ # Pass `nil` to clear the current configuration.
744+ #
745+ # @example Enforcing Customer-Managed Encryption
741746 # require "google/cloud/storage"
742- # #
747+ #
743748 # storage = Google::Cloud::Storage.new
744749 # bucket = storage.bucket "my-bucket"
745- # new_config = Google::Apis::StorageV1::Bucket::Encryption::CustomerManagedEncryptionEnforcementConfig.new restriction_mode: "FullyRestricted"
750+ #
751+ # # Set restriction mode to FullyRestricted
752+ # new_config = { restriction_mode: "FullyRestricted" }
746753 # bucket.customer_managed_encryption_enforcement_config = new_config
747- # The value for `restriction_mode` can be either "NotRestricted" or "FullyRestricted"
748-
754+ #
755+ # @return [Hash] The updated configuration hash.
756+ # @raise [Google::Cloud::Error] If the update fails due to permissions or invalid arguments.
749757 def customer_managed_encryption_enforcement_config = new_customer_managed_encryption_enforcement_config
750758 @gapi . encryption ||= API ::Bucket ::Encryption . new
751759 @gapi . encryption . customer_managed_encryption_enforcement_config =
752760 new_customer_managed_encryption_enforcement_config || { }
753761 patch_gapi! :encryption
754762 end
755763
756- ##
757- # Updates the bucket's encryption enforcement configuration.
758- #
759- # @param [Google::Apis::StorageV1::Bucket::Encryption::GoogleManagedEncryptionEnforcementConfig, Google::Apis::StorageV1::Bucket::Encryption::CustomerManagedEncryptionEnforcementConfig, Google::Apis::StorageV1::Bucket::Encryption::CustomerSuppliedEncryptionEnforcementConfig] incoming_config The new encryption enforcement configuration to apply.
760- #
761- # @raise [ArgumentError] If the provided config type is unsupported.
762- #
763- # @example
764- # require "google/cloud/storage"
765- #
766- # storage = Google::Cloud::Storage.new
767- # bucket = storage.bucket "my-bucket"
768- #
769- # new_config = Google::Apis::StorageV1::Bucket::Encryption::GoogleManagedEncryptionEnforcementConfig.new restriction_mode: "FullyRestricted"
770- # bucket.update_bucket_encryption_enforcement_config new_config
771- #
772- def update_bucket_encryption_enforcement_config incoming_config
773- attr_name = case incoming_config
774- when Google ::Apis ::StorageV1 ::Bucket ::Encryption ::GoogleManagedEncryptionEnforcementConfig
775- :google_managed_encryption_enforcement_config
776- when Google ::Apis ::StorageV1 ::Bucket ::Encryption ::CustomerManagedEncryptionEnforcementConfig
777- :customer_managed_encryption_enforcement_config
778- when Google ::Apis ::StorageV1 ::Bucket ::Encryption ::CustomerSuppliedEncryptionEnforcementConfig
779- :customer_supplied_encryption_enforcement_config
780- else
781- raise ArgumentError , "Unsupported config type: #{ incoming_config . class } "
782- end
783- encryption_patch = Google ::Apis ::StorageV1 ::Bucket ::Encryption . new
784- encryption_patch . public_send "#{ attr_name } =" , incoming_config
785- patch_gapi! :encryption , bucket_encryption_config : encryption_patch
786- end
787-
788- ##
789- # The bucket's encryption configuration for customer-supplied encryption keys. This configuration defines the
790- # default encryption behavior for the bucket and its files, and it can be used to enforce encryption requirements
791- # for the bucket.
764+ # Updates the bucket's encryption enforcement configuration.
765+ #
766+ # This method applies a patch to the bucket's encryption settings using the
767+ # provided configuration.
768+ #
769+ # @param incoming_config [Hash, Google::Apis::StorageV1::Bucket::Encryption]
770+ # The encryption configuration to apply. If a Hash is provided, it should
771+ # contain keys corresponding to the encryption enforcement types.
772+ #
773+ # @example Updating to Google-Managed Encryption
774+ # storage = Google::Cloud::Storage.new
775+ # bucket = storage.bucket "my-bucket"
776+ #
777+ # new_config = {
778+ # google_managed_encryption_enforcement_config: { restriction_mode: "NotRestricted" }
779+ # }
780+ #
781+ # bucket.update_bucket_encryption_enforcement_config new_config
782+ #
783+ # @return [void]
784+ # @raise [Google::Cloud::Error] If the API request fails (e.g., insufficient permissions).
785+ def update_bucket_encryption_enforcement_config incoming_config
786+ patch_gapi! :encryption , bucket_encryption_config : incoming_config
787+ end
788+
789+ ##
790+ # The bucket's encryption configuration for customer-supplied encryption keys.
792791 # For more information, see [Bucket encryption](https://docs.cloud.google.com/storage/docs/encryption/).
793- # @return [Google::Apis::StorageV1::Bucket::Encryption::CustomerSuppliedEncryptionEnforcementConfig, nil]
792+ # @return [Google::Apis::StorageV1::Bucket::Encryption::CustomerSuppliedEncryptionEnforcementConfig, nil]
794793 # The bucket's encryption configuration, or `nil` if no encryption configuration has been set.
795794 # @example
796795 # require "google/cloud/storage"
797796 #
798797 # storage = Google::Cloud::Storage.new
799798 # bucket = storage.bucket "my-bucket"
800- #
801- # new_config = Google::Apis::StorageV1::Bucket::Encryption::CustomerSuppliedEncryptionEnforcementConfig.new restriction_mode: "NotRestricted"
802- # bucket.customer_supplied_encryption_enforcement_config = new_config
799+ #
800+ # bucket.customer_supplied_encryption_enforcement_config
801+ # ==> #<Google::Apis::StorageV1::Bucket::Encryption::CustomerSuppliedEncryptionEnforcementConfig:0x00007f3b1c102e90 @restriction_mode="NotRestricted">
803802 # The value for `restriction_mode` can be either "NotRestricted" or "FullyRestricted".
804803
805804 def customer_supplied_encryption_enforcement_config
806805 @gapi . encryption &.customer_supplied_encryption_enforcement_config
807806 end
808807
809808 ##
810- # Sets the bucket's encryption configuration for customer-managed encryption that will be used to protect files.
811- # @param [Google::Apis::StorageV1::Bucket::Encryption::CustomerSuppliedEncryptionEnforcementConfig, nil] new_customer_supplied_encryption_enforcement_config The bucket's encryption configuration, or `nil` to delete the encryption configuration.
809+ # Sets the bucket's encryption configuration for customer-supplied encryption that will be used to protect files.
810+ # @param new_customer_supplied_encryption_enforcement_config [Hash, nil]
811+ # The configuration hash for encryption enforcement.
812+ # * `:restriction_mode` (String) - Can be "NotRestricted" or "FullyRestricted".
813+ # Pass `nil` to clear the current configuration.
812814 # @example
813815 # require "google/cloud/storage"
814816 #
815817 # storage = Google::Cloud::Storage.new
816818 # bucket = storage.bucket "my-bucket"
817- # new_config = Google::Apis::StorageV1::Bucket::Encryption::CustomerSuppliedEncryptionEnforcementConfig.new restriction_mode: "FullyRestricted"
819+ # new_config = { restriction_mode: "FullyRestricted" }
818820 # bucket.customer_supplied_encryption_enforcement_config = new_config
819- # The value for `restriction_mode` can be either "NotRestricted" or "FullyRestricted"
821+ # @return [Hash] The updated configuration hash.
822+ # @raise [Google::Cloud::Error] If the update fails due to permissions or invalid arguments.
820823
821824 def customer_supplied_encryption_enforcement_config = new_customer_supplied_encryption_enforcement_config
822825 @gapi . encryption ||= API ::Bucket ::Encryption . new
@@ -838,25 +841,34 @@ def customer_supplied_encryption_enforcement_config= new_customer_supplied_encry
838841 #
839842 # storage = Google::Cloud::Storage.new
840843 # bucket = storage.bucket "my-bucket"
841- # new_config= Google::Apis::StorageV1::Bucket::Encryption::GoogleManagedEncryptionEnforcementConfig.new restriction_mode: "NotRestricted"
842- # bucket.google_managed_encryption_enforcement_config = new_config
844+ # bucket.google_managed_encryption_enforcement_config
845+ # ==> #<Google::Apis::StorageV1::Bucket::Encryption::GoogleManagedEncryptionEnforcementConfig:0x00007f3b1c102e90 @restriction_mode="NotRestricted">
843846 # The value for `restriction_mode` can be either "NotRestricted" or "FullyRestricted".
844847
845848 def google_managed_encryption_enforcement_config
846849 @gapi . encryption &.google_managed_encryption_enforcement_config
847850 end
848851
849852 ##
850- # Sets the bucket's encryption configuration for google-managed encryption that will be used to protect files.
851- # @param [Google::Apis::StorageV1::Bucket::Encryption::GoogleManagedEncryptionEnforcementConfig, nil] new_google_managed_encryption_enforcement_config The bucket's encryption configuration, or `nil` to delete the encryption configuration.
852- # @example
853+ # Sets the google-managed encryption enforcement configuration for the bucket.
854+ #
855+ # @param new_google_managed_encryption_enforcement_config [Hash, nil]
856+ # The configuration hash for encryption enforcement.
857+ # * `:restriction_mode` (String) - Can be "NotRestricted" or "FullyRestricted".
858+ # Pass `nil` to clear the current configuration.
859+ #
860+ # @example Enforcing Customer-Managed Encryption
853861 # require "google/cloud/storage"
854- # #
862+ #
855863 # storage = Google::Cloud::Storage.new
856864 # bucket = storage.bucket "my-bucket"
857- # new_config = Google::Apis::StorageV1::Bucket::Encryption::GoogleManagedEncryptionEnforcementConfig.new restriction_mode: "FullyRestricted"
858- # bucket.google_managed_encryption_enforcement_config = new_config
859- # The value for `restriction_mode` can be either "NotRestricted" or "FullyRestricted"
865+ #
866+ # # Set restriction mode to FullyRestricted
867+ # new_config = { restriction_mode: "FullyRestricted" }
868+ # bucket.new_google_managed_encryption_enforcement_config = new_config
869+ #
870+ # @return [Hash] The updated configuration hash.
871+ # @raise [Google::Cloud::Error] If the update fails due to permissions or invalid arguments.
860872
861873 def google_managed_encryption_enforcement_config = new_google_managed_encryption_enforcement_config
862874 @gapi . encryption ||= API ::Bucket ::Encryption . new
0 commit comments