0
votes

The google cloud docs describe how one can set up the google cloud functions written in python, which are to be triggered by firestore events (e.g. create, write, delete). https://cloud.google.com/functions/docs/calling/cloud-firestore

The docs also mention the use of wildcards (placeholders) in the document path:

Wildcards are written in triggers using curly braces, as follows: "projects/YOUR_PROJECT_ID/databases/(default)/documents/collection/{document_wildcard}"

However, I can't find how to access the value of the document_wildcard from within the cloud function. E.g. I can't find it on the context variable.

Does someone have a hint? Are the values of wildcards available inside python google cloud functions?

1
From looking at the code samples in the documentation you linked, it seems the code extracts the parameter(s) from manipulating event.value.name. - Frank van Puffelen

1 Answers

0
votes

The value of the wildcards can be found in data.value.name - many thanks to Frank van Puffelen for pointing this out.

E.g., the following google cloud function

def my_cloud_function(data, context):
    print(data.get("value").get("name"))
    return

triggered by create events on

projects/YOUR_PROJECT_ID/databases/(default)/documents/collection/{document_wildcard}

prints the actual full path to the created document, e.g.

projects/YOUR_PROJECT_ID/databases/(default)/documents/collection/o6NNBsnWfaA9N5iJx7r9