@@ -755,10 +755,8 @@ def customer_managed_encryption_enforcement_config
755755 # @example Setting via Request Object (Google API Client)
756756 # require "google/apis/storage_v1"
757757 #
758- # # Create the enforcement config sub-object
759758 # enforcement_config = { restriction_mode: "FullyRestricted" }
760759 #
761- # # Initialize the parent Encryption request object
762760 # request_obj = Google::Apis::StorageV1::Bucket::Encryption.new(
763761 # customer_managed_encryption_enforcement_config: enforcement_config
764762 # )
@@ -800,34 +798,34 @@ def customer_managed_encryption_enforcement_config= new_customer_managed_encrypt
800798 # bucket.update_bucket_encryption_enforcement_config config_obj
801799 # @raise [ArgumentError] If the config is empty, contains invalid keys, or is the wrong type.
802800 def update_bucket_encryption_enforcement_config incoming_config
803- allowed_keys = [
804- :google_managed_encryption_enforcement_config ,
805- :customer_managed_encryption_enforcement_config ,
806- :customer_supplied_encryption_enforcement_config
807- ]
808-
809- if incoming_config . is_a? Hash
810- input_keys = incoming_config . keys
811- raise ArgumentError , "Config cannot be empty" if input_keys . empty?
812-
813- extra_keys = input_keys - allowed_keys
814- unless extra_keys . empty?
815- raise ArgumentError , "Invalid config detected: #{ extra_keys . join ( ', ' ) } . " \
816- "Only #{ allowed_keys . join ( ', ' ) } are allowed."
817- end
801+ allowed_keys = [
802+ :google_managed_encryption_enforcement_config ,
803+ :customer_managed_encryption_enforcement_config ,
804+ :customer_supplied_encryption_enforcement_config
805+ ]
806+
807+ if incoming_config . is_a? Hash
808+ input_keys = incoming_config . keys
809+ raise ArgumentError , "Config cannot be empty" if input_keys . empty?
810+
811+ extra_keys = input_keys - allowed_keys
812+ unless extra_keys . empty?
813+ raise ArgumentError , "Invalid config detected: #{ extra_keys . join ( ', ' ) } . " \
814+ "Only #{ allowed_keys . join ( ', ' ) } are allowed."
815+ end
818816
819- elsif incoming_config . is_a? Google ::Apis ::StorageV1 ::Bucket ::Encryption
820- # For objects, ensure at least one of the allowed enforcement configs is present
821- has_any_config = allowed_keys . any? { |key | !incoming_config . send ( key ) . nil? }
822- binding . pry
823- raise ArgumentError , "Encryption request object must have at least one enforcement config set" unless has_any_config
824-
825- else
826- raise ArgumentError , "incoming_config must be a Hash or Google::Apis::StorageV1::Bucket::Encryption"
827- end
817+ elsif incoming_config . is_a? Google ::Apis ::StorageV1 ::Bucket ::Encryption
818+ # For objects, ensure at least one of the allowed enforcement configs is present
819+ has_any_config = allowed_keys . any? { |key | !incoming_config . send ( key ) . nil? }
820+ binding . pry
821+ raise ArgumentError , "Encryption request object must have at least one enforcement config set" unless has_any_config
822+
823+ else
824+ raise ArgumentError , "incoming_config must be a Hash or Google::Apis::StorageV1::Bucket::Encryption"
825+ end
828826
829- patch_gapi! :encryption , bucket_encryption_config : incoming_config
830- end
827+ patch_gapi! :encryption , bucket_encryption_config : incoming_config
828+ end
831829
832830 ##
833831 # The bucket's encryption configuration for customer-supplied encryption keys.
@@ -865,10 +863,8 @@ def customer_supplied_encryption_enforcement_config
865863 # @example Setting via Request Object (Google API Client)
866864 # require "google/apis/storage_v1"
867865 #
868- # # Create the enforcement config sub-object
869866 # enforcement_config = { restriction_mode: "FullyRestricted" }
870867 #
871- # # Initialize the parent Encryption request object
872868 # request_obj = Google::Apis::StorageV1::Bucket::Encryption.new(
873869 # customer_supplied_encryption_enforcement_config: enforcement_config
874870 # )
@@ -926,10 +922,8 @@ def google_managed_encryption_enforcement_config
926922 # @example Setting via Request Object (Google API Client)
927923 # require "google/apis/storage_v1"
928924 #
929- # # Create the enforcement config sub-object
930925 # enforcement_config = { restriction_mode: "FullyRestricted" }
931926 #
932- # # Initialize the parent Encryption request object
933927 # request_obj = Google::Apis::StorageV1::Bucket::Encryption.new(
934928 # google_managed_encryption_enforcement_config: enforcement_config
935929 # )
0 commit comments