3434from google .cloud .storage .acl import BucketACL
3535from google .cloud .storage .acl import DefaultObjectACL
3636from google .cloud .storage .blob import Blob
37+ from google .cloud .storage .blob import _get_encryption_headers
3738
3839
3940def _blobs_page_start (iterator , page , response ):
@@ -228,7 +229,7 @@ def path(self):
228229
229230 return self .path_helper (self .name )
230231
231- def get_blob (self , blob_name , client = None ):
232+ def get_blob (self , blob_name , client = None , encryption_key = None , ** kwargs ):
232233 """Get a blob object by name.
233234
234235 This will return None if the blob doesn't exist:
@@ -245,14 +246,27 @@ def get_blob(self, blob_name, client=None):
245246 :param client: Optional. The client to use. If not passed, falls back
246247 to the ``client`` stored on the current bucket.
247248
249+ :type encryption_key: bytes
250+ :param encryption_key:
251+ Optional 32 byte encryption key for customer-supplied encryption.
252+ See
253+ https://cloud.google.com/storage/docs/encryption#customer-supplied.
254+
255+ :type kwargs: dict
256+ :param kwargs: Keyword arguments to pass to the
257+ :class:`~google.cloud.storage.blob.Blob` constructor.
258+
248259 :rtype: :class:`google.cloud.storage.blob.Blob` or None
249260 :returns: The blob object if it exists, otherwise None.
250261 """
251262 client = self ._require_client (client )
252- blob = Blob (bucket = self , name = blob_name )
263+ blob = Blob (bucket = self , name = blob_name , encryption_key = encryption_key ,
264+ ** kwargs )
253265 try :
266+ headers = _get_encryption_headers (encryption_key )
254267 response = client ._connection .api_request (
255- method = 'GET' , path = blob .path , _target_object = blob )
268+ method = 'GET' , path = blob .path , _target_object = blob ,
269+ headers = headers )
256270 # NOTE: We assume response.get('name') matches `blob_name`.
257271 blob ._set_properties (response )
258272 # NOTE: This will not fail immediately in a batch. However, when
0 commit comments