File tree Expand file tree Collapse file tree 3 files changed +30
-5
lines changed Expand file tree Collapse file tree 3 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -280,16 +280,24 @@ def create(self):
280280 if (
281281 (
282282 self ._encryption_config
283- and self ._encryption_config .kms_key_name
283+ and (
284+ self ._encryption_config .kms_key_name
285+ or self ._encryption_config .kms_key_names
286+ )
284287 and self ._encryption_config .encryption_type
285288 != CreateBackupEncryptionConfig .EncryptionType .CUSTOMER_MANAGED_ENCRYPTION
286289 )
287290 and self ._encryption_config
288- and self ._encryption_config .kms_key_name
291+ and (
292+ self ._encryption_config .kms_key_name
293+ or self ._encryption_config .kms_key_names
294+ )
289295 and self ._encryption_config .encryption_type
290296 != CopyBackupEncryptionConfig .EncryptionType .CUSTOMER_MANAGED_ENCRYPTION
291297 ):
292- raise ValueError ("kms_key_name only used with CUSTOMER_MANAGED_ENCRYPTION" )
298+ raise ValueError (
299+ "kms_key_name or kms_key_names only used with CUSTOMER_MANAGED_ENCRYPTION"
300+ )
293301
294302 api = self ._instance ._client .database_admin_api
295303 metadata = _metadata_with_prefix (self .name )
Original file line number Diff line number Diff line change @@ -911,11 +911,16 @@ def restore(self, source):
911911 )
912912 if (
913913 self .encryption_config
914- and self .encryption_config .kms_key_name
914+ and (
915+ self .encryption_config .kms_key_name
916+ or self .encryption_config .kms_key_names
917+ )
915918 and self .encryption_config .encryption_type
916919 != RestoreDatabaseEncryptionConfig .EncryptionType .CUSTOMER_MANAGED_ENCRYPTION
917920 ):
918- raise ValueError ("kms_key_name only used with CUSTOMER_MANAGED_ENCRYPTION" )
921+ raise ValueError (
922+ "kms_key_name or kms_key_names only used with CUSTOMER_MANAGED_ENCRYPTION"
923+ )
919924 api = self ._instance ._client .database_admin_api
920925 metadata = _metadata_with_prefix (self .name )
921926 request = RestoreDatabaseRequest (
Original file line number Diff line number Diff line change @@ -210,6 +210,18 @@ def test_ctor_w_encryption_config(self):
210210 self .assertIs (database ._instance , instance )
211211 self .assertEqual (database ._encryption_config , encryption_config )
212212
213+ def test_ctor_w_multiple_kms_keys (self ):
214+ from google .cloud .spanner_admin_database_v1 import EncryptionConfig
215+
216+ instance = _Instance (self .INSTANCE_NAME )
217+ encryption_config = EncryptionConfig (kms_key_names = ["kms_key1" , "kms_key2" ])
218+ database = self ._make_one (
219+ self .DATABASE_ID , instance , encryption_config = encryption_config
220+ )
221+ self .assertEqual (database .database_id , self .DATABASE_ID )
222+ self .assertIs (database ._instance , instance )
223+ self .assertEqual (database ._encryption_config , encryption_config )
224+
213225 def test_ctor_w_directed_read_options (self ):
214226 client = _Client (directed_read_options = DIRECTED_READ_OPTIONS )
215227 instance = _Instance (self .INSTANCE_NAME , client = client )
You can’t perform that action at this time.
0 commit comments