|
1 | 1 | """
|
2 | 2 | Example Firebase Functions written in Python
|
3 | 3 | """
|
4 |
| -from firebase_functions import db, options, https, params, pubsub |
| 4 | +from firebase_functions import db_fn, https_fn, options, params, pubsub_fn |
5 | 5 | from firebase_admin import initialize_app
|
6 | 6 |
|
7 | 7 | initialize_app()
|
|
13 | 13 | )
|
14 | 14 |
|
15 | 15 |
|
16 |
| -@db.on_value_written( |
| 16 | +@db_fn.on_value_written( |
17 | 17 | reference="hello",
|
18 | 18 | region=options.SupportedRegion.EUROPE_WEST1,
|
19 | 19 | )
|
20 |
| -def onwriteexample(event: db.Event[db.Change[object]]) -> None: |
| 20 | +def onwriteexample(event: db_fn.Event[db_fn.Change[object]]) -> None: |
21 | 21 | print("Hello from db write event:", event)
|
22 | 22 |
|
23 | 23 |
|
24 |
| -@db.on_value_created(reference="hello/{any_thing_here}/bar") |
25 |
| -def oncreatedexample(event: db.Event[object]) -> None: |
| 24 | +@db_fn.on_value_created(reference="hello/{any_thing_here}/bar") |
| 25 | +def oncreatedexample(event: db_fn.Event[object]) -> None: |
26 | 26 | print("Hello from db create event:", event)
|
27 | 27 |
|
28 | 28 |
|
29 |
| -@db.on_value_deleted(reference="hello/{any_thing_here}/bar") |
30 |
| -def ondeletedexample(event: db.Event[object]) -> None: |
| 29 | +@db_fn.on_value_deleted(reference="hello/{any_thing_here}/bar") |
| 30 | +def ondeletedexample(event: db_fn.Event[object]) -> None: |
31 | 31 | print("Hello from db delete event:", event)
|
32 | 32 |
|
33 | 33 |
|
34 |
| -@db.on_value_updated(reference="hello") |
35 |
| -def onupdatedexample(event: db.Event[db.Change[object]]) -> None: |
| 34 | +@db_fn.on_value_updated(reference="hello") |
| 35 | +def onupdatedexample(event: db_fn.Event[db_fn.Change[object]]) -> None: |
36 | 36 | print("Hello from db updated event:", event)
|
37 | 37 |
|
38 | 38 |
|
39 |
| -@https.on_request() |
40 |
| -def onrequestexample(req: https.Request) -> https.Response: |
| 39 | +@https_fn.on_request() |
| 40 | +def onrequestexample(req: https_fn.Request) -> https_fn.Response: |
41 | 41 | print("on request function data:", req.data)
|
42 |
| - return https.Response("Hello from https on request function example") |
| 42 | + return https_fn.Response("Hello from https on request function example") |
43 | 43 |
|
44 | 44 |
|
45 |
| -@https.on_call() |
46 |
| -def oncallexample(req: https.CallableRequest): |
| 45 | +@https_fn.on_call() |
| 46 | +def oncallexample(req: https_fn.CallableRequest): |
47 | 47 | print("on call function data:", req)
|
48 | 48 | if req.data == "error_test":
|
49 |
| - raise https.HttpsError( |
50 |
| - https.FunctionsErrorCode.INVALID_ARGUMENT, |
| 49 | + raise https_fn.HttpsError( |
| 50 | + https_fn.FunctionsErrorCode.INVALID_ARGUMENT, |
51 | 51 | "This is a test",
|
52 | 52 | "This is some details of the test",
|
53 | 53 | )
|
54 | 54 | return "Hello from https on call function example"
|
55 | 55 |
|
56 | 56 |
|
57 |
| -@pubsub.on_message_published( |
| 57 | +@pubsub_fn.on_message_published( |
58 | 58 | topic="hello",)
|
59 | 59 | def onmessagepublishedexample(
|
60 |
| - event: pubsub.CloudEvent[pubsub.MessagePublishedData]) -> None: |
| 60 | + event: pubsub_fn.CloudEvent[pubsub_fn.MessagePublishedData]) -> None: |
61 | 61 | print("Hello from pubsub event:", event)
|
0 commit comments