3535_RESERVED_FILTERS = ('$key' , '$value' , '$priority' )
3636
3737
38- def get_reference (path = '/' , app = None ):
38+ def reference (path = '/' , app = None ):
3939 """Returns a database Reference representing the node at the specified path.
4040
4141 If no path is specified, this function returns a Reference that represents the database root.
@@ -69,7 +69,7 @@ class Reference(object):
6969 def __init__ (self , ** kwargs ):
7070 """Creates a new Reference using the provided parameters.
7171
72- This method is for internal use only. Use db.get_reference () to obtain an instance of
72+ This method is for internal use only. Use db.reference () to obtain an instance of
7373 Reference.
7474 """
7575 self ._client = kwargs .get ('client' )
@@ -119,7 +119,7 @@ def child(self, path):
119119 full_path = self ._pathurl + '/' + path
120120 return Reference (client = self ._client , path = full_path )
121121
122- def get_value (self ):
122+ def get (self ):
123123 """Returns the value at the current location of the database.
124124
125125 Returns:
@@ -130,41 +130,21 @@ def get_value(self):
130130 """
131131 return self ._client .request ('get' , self ._add_suffix ())
132132
133- def get_priority (self ):
134- """Returns the priority of this node, if specified.
135-
136- Returns:
137- object: A priority value or None.
138-
139- Raises:
140- ApiCallError: If an error occurs while communicating with the remote database server.
141- """
142- return self ._client .request ('get' , self ._add_suffix ('/.priority.json' ))
143-
144- def set_value (self , value , priority = None ):
133+ def set (self , value ):
145134 """Sets the data at this location to the given value.
146135
147- The value must be JSON-serializable and not None. If a priority is specified, the node will
148- be assigned that priority along with the value.
136+ The value must be JSON-serializable and not None.
149137
150138 Args:
151139 value: JSON-serialable value to be set at this location.
152- priority: A numeric or alphanumeric priority value (optional).
153140
154141 Raises:
155- ValueError: If the value is None or priority is invalid .
142+ ValueError: If the value is None.
156143 TypeError: If the value is not JSON-serializable.
157144 ApiCallError: If an error occurs while communicating with the remote database server.
158145 """
159146 if value is None :
160147 raise ValueError ('Value must not be None.' )
161- if priority is not None :
162- Reference ._check_priority (priority )
163- if isinstance (value , dict ):
164- value = dict (value )
165- value ['.priority' ] = priority
166- else :
167- value = {'.value' : value , '.priority' : priority }
168148 params = {'print' : 'silent' }
169149 self ._client .request_oneway ('put' , self ._add_suffix (), json = value , params = params )
170150
@@ -191,7 +171,7 @@ def push(self, value=''):
191171 push_id = output .get ('name' )
192172 return self .child (push_id )
193173
194- def update_children (self , value ):
174+ def update (self , value ):
195175 """Updates the specified child keys of this Reference to the provided values.
196176
197177 Args:
@@ -257,20 +237,6 @@ def order_by_value(self):
257237 """
258238 return Query (order_by = '$value' , client = self ._client , pathurl = self ._add_suffix ())
259239
260- def order_by_priority (self ):
261- """Creates a Query that orderes data by priority.
262-
263- Returned Query can be used to set additional parameters, and execute complex database
264- queries (e.g. limit queries, range queries). Due to a limitation of the
265- underlying REST API, the order-by-priority constraint can only be enforced during
266- the execution time of the Query. When the Query returns results, the actual results
267- will be returned as an unordered collection.
268-
269- Returns:
270- Query: A database Query instance.
271- """
272- return Query (order_by = '$priority' , client = self ._client , pathurl = self ._add_suffix ())
273-
274240 def _add_suffix (self , suffix = '.json' ):
275241 return self ._pathurl + suffix
276242
@@ -294,8 +260,7 @@ class Query(object):
294260 the final result is returned by the server as an unordered collection. Therefore the Query
295261 interface performs another round of sorting at the client-side before returning the results
296262 to the caller. This client-side sorted results are returned to the user as a Python
297- OrderedDict. However, client-side sorting is not feasible for order-by-priority queries.
298- Therefore for such queries results are returned as a regular unordered dict.
263+ OrderedDict.
299264 """
300265
301266 def __init__ (self , ** kwargs ):
@@ -315,7 +280,7 @@ def __init__(self, **kwargs):
315280 if kwargs :
316281 raise ValueError ('Unexpected keyword arguments: {0}' .format (kwargs ))
317282
318- def set_limit_first (self , limit ):
283+ def limit_to_first (self , limit ):
319284 """Creates a query with limit, and anchors it to the start of the window.
320285
321286 Args:
@@ -334,7 +299,7 @@ def set_limit_first(self, limit):
334299 self ._params ['limitToFirst' ] = limit
335300 return self
336301
337- def set_limit_last (self , limit ):
302+ def limit_to_last (self , limit ):
338303 """Creates a query with limit, and anchors it to the end of the window.
339304
340305 Args:
@@ -353,7 +318,7 @@ def set_limit_last(self, limit):
353318 self ._params ['limitToLast' ] = limit
354319 return self
355320
356- def set_start_at (self , start ):
321+ def start_at (self , start ):
357322 """Sets the lower bound for a range query.
358323
359324 The Query will only return child nodes with a value greater than or equal to the specified
@@ -373,7 +338,7 @@ def set_start_at(self, start):
373338 self ._params ['startAt' ] = json .dumps (start )
374339 return self
375340
376- def set_end_at (self , end ):
341+ def end_at (self , end ):
377342 """Sets the upper bound for a range query.
378343
379344 The Query will only return child nodes with a value less than or equal to the specified
@@ -393,7 +358,7 @@ def set_end_at(self, end):
393358 self ._params ['endAt' ] = json .dumps (end )
394359 return self
395360
396- def set_equal_to (self , value ):
361+ def equal_to (self , value ):
397362 """Sets an equals constraint on the Query.
398363
399364 The Query will only return child nodes whose value is equal to the specified value.
@@ -419,7 +384,7 @@ def querystr(self):
419384 params .append ('{0}={1}' .format (key , self ._params [key ]))
420385 return '&' .join (params )
421386
422- def run (self ):
387+ def get (self ):
423388 """Executes this Query and returns the results.
424389
425390 The results will be returned as a sorted list or an OrderedDict, except in the case of
@@ -587,18 +552,19 @@ def __init__(self, url=None, auth=None, session=None):
587552 @classmethod
588553 def from_app (cls , app ):
589554 """Created a new _Client for a given App"""
590- url = app .options .get ('dbURL ' )
555+ url = app .options .get ('databaseURL ' )
591556 if not url or not isinstance (url , six .string_types ):
592557 raise ValueError (
593- 'Invalid dbURL option: "{0}". dbURL must be a non-empty URL string.' .format (url ))
558+ 'Invalid databaseURL option: "{0}". databaseURL must be a non-empty URL '
559+ 'string.' .format (url ))
594560 parsed = urllib .parse .urlparse (url )
595561 if parsed .scheme != 'https' :
596562 raise ValueError (
597- 'Invalid dbURL option: "{0}". dbURL must be an HTTPS URL.' .format (url ))
563+ 'Invalid databaseURL option: "{0}". databaseURL must be an HTTPS URL.' .format (url ))
598564 elif not parsed .netloc .endswith ('.firebaseio.com' ):
599565 raise ValueError (
600- 'Invalid dbURL option: "{0}". dbURL must be a valid URL to a Firebase Realtime '
601- 'Database instance.' .format (url ))
566+ 'Invalid databaseURL option: "{0}". databaseURL must be a valid URL to a '
567+ 'Firebase Realtime Database instance.' .format (url ))
602568 return _Client ('https://{0}' .format (parsed .netloc ), _OAuth (app ), requests .Session ())
603569
604570 def request (self , method , urlpath , ** kwargs ):
@@ -668,5 +634,6 @@ def __init__(self, app):
668634 self ._app = app
669635
670636 def __call__ (self , req ):
671- req .headers ['Authorization' ] = 'Bearer {0}' .format (self ._app .get_token ())
637+ # pylint: disable=protected-access
638+ req .headers ['Authorization' ] = 'Bearer {0}' .format (self ._app ._get_token ())
672639 return req
0 commit comments