@@ -125,26 +125,33 @@ def child(self, path):
125
125
full_path = self ._pathurl + '/' + path
126
126
return Reference (client = self ._client , path = full_path )
127
127
128
- def get (self , etag = False ):
128
+ def get (self , etag = False , shallow = False ):
129
129
"""Returns the value, and optionally the ETag, at the current location of the database.
130
130
131
131
Args:
132
132
etag: A boolean indicating whether the Etag value should be returned or not (optional).
133
+ shallow: A boolean indicating whether to execute a shallow read (optional). Shallow
134
+ reads do not retrieve the child nodes of the current database location. Cannot be
135
+ set to True if ``etag`` is also set to True.
133
136
134
137
Returns:
135
138
object: If etag is False returns the decoded JSON value of the current database location.
136
139
If etag is True, returns a 2-tuple consisting of the decoded JSON value and the Etag
137
140
associated with the current database location.
138
141
139
142
Raises:
143
+ ValueError: If both ``etag`` and ``shallow`` are set to True.
140
144
ApiCallError: If an error occurs while communicating with the remote database server.
141
145
"""
142
146
if etag :
147
+ if shallow :
148
+ raise ValueError ('etag and shallow cannot both be set to True.' )
143
149
headers , data = self ._client .headers_and_body (
144
150
'get' , self ._add_suffix (), headers = {'X-Firebase-ETag' : 'true' })
145
151
return data , headers .get ('ETag' )
146
152
else :
147
- return self ._client .body ('get' , self ._add_suffix ())
153
+ params = 'shallow=true' if shallow else None
154
+ return self ._client .body ('get' , self ._add_suffix (), params = params )
148
155
149
156
def get_if_changed (self , etag ):
150
157
"""Gets data in this location only if the specified ETag does not match.
0 commit comments