@@ -351,15 +351,33 @@ def get_entities(self):
351351 self ._ensure_loaded ()
352352 return list (self .entities .values ())
353353
354- def reload (self , connection = None ):
354+ @staticmethod
355+ def _client_or_connection (client ):
356+ """Temporary method to get a connection from a client.
357+
358+ If the client is null, gets the connection from the environment.
359+
360+ :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
361+ :param client: Optional. The client to use. If not passed, falls back
362+ to default connection.
363+
364+ :rtype: :class:`gcloud.storage.connection.Connection`
365+ :returns: The connection determined from the ``client`` or environment.
366+ """
367+ if client is None :
368+ return _require_connection ()
369+ else :
370+ return client .connection
371+
372+ def reload (self , client = None ):
355373 """Reload the ACL data from Cloud Storage.
356374
357- :type connection : :class:`gcloud.storage.connection.Connection ` or None
358- :param connection: explicit connection to use for API request;
359- defaults to instance property .
375+ :type client : :class:`gcloud.storage.client.Client ` or ``NoneType``
376+ :param client: Optional. The client to use. If not passed, falls back
377+ to default connection .
360378 """
361379 path = self .reload_path
362- connection = _require_connection ( connection )
380+ connection = self . _client_or_connection ( client )
363381
364382 self .entities .clear ()
365383
@@ -368,16 +386,16 @@ def reload(self, connection=None):
368386 for entry in found .get ('items' , ()):
369387 self .add_entity (self .entity_from_dict (entry ))
370388
371- def save (self , acl = None , connection = None ):
389+ def save (self , acl = None , client = None ):
372390 """Save this ACL for the current bucket.
373391
374392 :type acl: :class:`gcloud.storage.acl.ACL`, or a compatible list.
375393 :param acl: The ACL object to save. If left blank, this will save
376394 current entries.
377395
378- :type connection : :class:`gcloud.storage.connection.Connection ` or None
379- :param connection: explicit connection to use for API request;
380- defaults to instance property .
396+ :type client : :class:`gcloud.storage.client.Client ` or ``NoneType``
397+ :param client: Optional. The client to use. If not passed, falls back
398+ to default connection .
381399 """
382400 if acl is None :
383401 acl = self
@@ -387,7 +405,7 @@ def save(self, acl=None, connection=None):
387405
388406 if save_to_backend :
389407 path = self .save_path
390- connection = _require_connection ( connection )
408+ connection = self . _client_or_connection ( client )
391409 result = connection .api_request (
392410 method = 'PATCH' ,
393411 path = path ,
@@ -398,19 +416,19 @@ def save(self, acl=None, connection=None):
398416 self .add_entity (self .entity_from_dict (entry ))
399417 self .loaded = True
400418
401- def clear (self , connection = None ):
419+ def clear (self , client = None ):
402420 """Remove all ACL entries.
403421
404422 Note that this won't actually remove *ALL* the rules, but it
405423 will remove all the non-default rules. In short, you'll still
406424 have access to a bucket that you created even after you clear
407425 ACL rules with this method.
408426
409- :type connection : :class:`gcloud.storage.connection.Connection ` or None
410- :param connection: explicit connection to use for API request;
411- defaults to instance property .
427+ :type client : :class:`gcloud.storage.client.Client ` or ``NoneType``
428+ :param client: Optional. The client to use. If not passed, falls back
429+ to default connection .
412430 """
413- self .save ([], connection )
431+ self .save ([], client = client )
414432
415433
416434class BucketACL (ACL ):
0 commit comments