Skip to content

Commit 40c6bbd

Browse files
authored
Merge pull request #40 from invertase/rename-fn-modules
refactor: rename fn modules to include `_fn` postfix
2 parents 4eb9153 + f7eb95e commit 40c6bbd

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

docs/generate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ if [[ "$OUTDIR" == "" ]]; then
8282
fi
8383

8484
TITLE="Firebase Python SDK for Cloud Functions"
85-
PY_MODULES='firebase_functions firebase_functions.core firebase_functions.https firebase_functions.params firebase_functions.db firebase_functions.options firebase_functions.pubsub firebase_functions.storage'
85+
PY_MODULES='firebase_functions firebase_functions.core firebase_functions.https_fn firebase_functions.params firebase_functions.db_fn firebase_functions.options firebase_functions.pubsub_fn firebase_functions.storage_fn'
8686
DEVSITE_PATH='/docs/reference/functions-python'
8787

8888
#

example/functions/main.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Example Firebase Functions written in Python
33
"""
4-
from firebase_functions import db, options, https, params, pubsub
4+
from firebase_functions import db_fn, https_fn, options, params, pubsub_fn
55
from firebase_admin import initialize_app
66

77
initialize_app()
@@ -13,49 +13,49 @@
1313
)
1414

1515

16-
@db.on_value_written(
16+
@db_fn.on_value_written(
1717
reference="hello",
1818
region=options.SupportedRegion.EUROPE_WEST1,
1919
)
20-
def onwriteexample(event: db.Event[db.Change[object]]) -> None:
20+
def onwriteexample(event: db_fn.Event[db_fn.Change[object]]) -> None:
2121
print("Hello from db write event:", event)
2222

2323

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:
2626
print("Hello from db create event:", event)
2727

2828

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:
3131
print("Hello from db delete event:", event)
3232

3333

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:
3636
print("Hello from db updated event:", event)
3737

3838

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:
4141
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")
4343

4444

45-
@https.on_call()
46-
def oncallexample(req: https.CallableRequest):
45+
@https_fn.on_call()
46+
def oncallexample(req: https_fn.CallableRequest):
4747
print("on call function data:", req)
4848
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,
5151
"This is a test",
5252
"This is some details of the test",
5353
)
5454
return "Hello from https on call function example"
5555

5656

57-
@pubsub.on_message_published(
57+
@pubsub_fn.on_message_published(
5858
topic="hello",)
5959
def onmessagepublishedexample(
60-
event: pubsub.CloudEvent[pubsub.MessagePublishedData]) -> None:
60+
event: pubsub_fn.CloudEvent[pubsub_fn.MessagePublishedData]) -> None:
6161
print("Hello from pubsub event:", event)

samples/basic_storage/functions/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22
Example Firebase Functions for Storage triggers.
33
"""
44

5-
from firebase_functions import storage
6-
from firebase_functions.storage import StorageObjectData, CloudEvent
5+
from firebase_functions import storage_fn
6+
from firebase_functions.storage_fn import StorageObjectData, CloudEvent
77
from firebase_admin import initialize_app
88

99
initialize_app()
1010

1111

12-
@storage.on_object_finalized()
12+
@storage_fn.on_object_finalized()
1313
def onobjectfinalizedexample(event: CloudEvent[StorageObjectData]):
1414
"""
1515
This function will be triggered when a new object is created in the bucket.
1616
"""
1717
print(event)
1818

1919

20-
@storage.on_object_archived()
20+
@storage_fn.on_object_archived()
2121
def onobjectarchivedexample(event: CloudEvent[StorageObjectData]):
2222
"""
2323
This function will be triggered when an object is archived in the bucket.
2424
"""
2525
print(event)
2626

2727

28-
@storage.on_object_deleted()
28+
@storage_fn.on_object_deleted()
2929
def onobjectdeletedexample(event: CloudEvent[StorageObjectData]):
3030
"""
3131
This function will be triggered when an object is deleted in the bucket.
3232
"""
3333
print(event)
3434

3535

36-
@storage.on_object_metadata_updated()
36+
@storage_fn.on_object_metadata_updated()
3737
def onobjectmetadataupdatedexample(event: CloudEvent[StorageObjectData]):
3838
"""
3939
This function will be triggered when an object's metadata is updated in the bucket.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)