@@ -45,15 +45,32 @@ def __init__(self, name=None):
4545 self ._properties = {}
4646 self ._changes = set ()
4747
48- def reload (self , connection = None ):
48+ @staticmethod
49+ def _client_or_connection (client ):
50+ """Temporary method to get a connection from a client.
51+
52+ If the client is null, gets the connection from the environment.
53+
54+ :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
55+ :param client: Optional. The client to use. If not passed, falls back
56+ to default connection.
57+
58+ :rtype: :class:`gcloud.storage.connection.Connection`
59+ :returns: The connection determined from the ``client`` or environment.
60+ """
61+ if client is None :
62+ return _require_connection ()
63+ else :
64+ return client .connection
65+
66+ def reload (self , client = None ):
4967 """Reload properties from Cloud Storage.
5068
51- :type connection: :class:`gcloud.storage.connection.Connection`
52- :param connection: An explicit connection to use for the API request.
53- If not passed, use the connection assigned to
54- the object in its constructor.
69+ :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
70+ :param client: Optional. The client to use. If not passed, falls back
71+ to default connection.
5572 """
56- connection = _require_connection ( connection )
73+ connection = self . _client_or_connection ( client )
5774 # Pass only '?projection=noAcl' here because 'acl' and related
5875 # are handled via custom endpoints.
5976 query_params = {'projection' : 'noAcl' }
@@ -90,17 +107,16 @@ def _set_properties(self, value):
90107 # If the values are reset, the changes must as well.
91108 self ._changes = set ()
92109
93- def patch (self , connection = None ):
110+ def patch (self , client = None ):
94111 """Sends all changed properties in a PATCH request.
95112
96113 Updates the ``_properties`` with the response from the backend.
97114
98- :type connection: :class:`gcloud.storage.connection.Connection`
99- :param connection: An explicit connection to use for the API request.
100- If not passed, use the connection assigned to
101- the object in its constructor.
115+ :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
116+ :param client: Optional. The client to use. If not passed, falls back
117+ to default connection.
102118 """
103- connection = _require_connection ( connection )
119+ connection = self . _client_or_connection ( client )
104120 # Pass '?projection=full' here because 'PATCH' documented not
105121 # to work properly w/ 'noAcl'.
106122 update_properties = dict ((key , self ._properties [key ])
0 commit comments