google-cloud-functions

Is it possible to get all documents in a Firestore Cloud Function?

℡╲_俬逩灬. 提交于 2020-06-09 12:51:28
问题 I want to update a value on all documents in a collection using cloud functions as they are dependent on the creation date, but looking through the Cloud Firestore Triggers examples it looks like all events are only able to access a single document. Is there a way to loop over all documents? 回答1: You'd typically use the Admin SDK for that in your Cloud Functions code. Once you have that, it's a matter of read the collection as usual. Check the node examples in the firebase documentation on

Firebase Cloud Functions: “status”:“INVALID_ARGUMENT”

馋奶兔 提交于 2020-06-09 05:49:47
问题 I am locally testing a Firebase Cloud Function. When I call this function using the local URL http://localhost:5001/projectName/us-central1/functionName as described here: exports.createSession = functions.https.onRequest((_req, res) => { res.status(200).send('TESTING'); }); the function works and it returns the string. However, when I call this function: exports.createSession = functions.https.onCall((data, context) => { return 'TESTING'; }); It throws the error: {"error":{"message":"Bad

Firebase Functions: Support Global variable across functions

限于喜欢 提交于 2020-06-09 05:15:48
问题 I want to cache most recent records (say last 24 hrs) in a http firebase function. In a http firebase function (say fetchLastXRecords), I look for the record in cache (defined Global variable to store the records) if not found fetch from database and set cache. Problem arises when I want to update any record of cache because this Global variable is not accessible by other firebase functions (could be real time database change triggers). What could be a good approach to update the records in

Python cloud function is not updated after rebuild

天大地大妈咪最大 提交于 2020-06-01 07:44:05
问题 Steps to reproduce: Enable these APIs: Cloud Repositories, Cloud Build, and Cloud Functions Create Repository and push content from here there. This is a simple Python Flask app returning simple Html with cloudbuild.yaml file. Create Cloud function using created repository with name la-repo-function-1 (which is referred in cloudbuild.yaml file) and using Python 3.7 with HTTP trigger and function to execute equal greetings_http Create Cloud Build trigger on that repo and point it to use

403 status from Firebase Cloud Function -> Google Books API

醉酒当歌 提交于 2020-06-01 05:41:21
问题 I'm currently working on creating a Firebase Cloud Function that retrieve a list of books from the NYTimes API and grabs some additional information from the Google Books API. By using the following URL : "https://www.googleapis.com/books/v1/volumes?q=isbn:&key=" I'm able to retrieve books' details based on an ISBN. My FREE quota for Google Books API is 1000 request per day and 100 request every 100 seconds per user. I'm only sending 15 requests and my current quota is below 200. My key is

403 status from Firebase Cloud Function -> Google Books API

南楼画角 提交于 2020-06-01 05:40:05
问题 I'm currently working on creating a Firebase Cloud Function that retrieve a list of books from the NYTimes API and grabs some additional information from the Google Books API. By using the following URL : "https://www.googleapis.com/books/v1/volumes?q=isbn:&key=" I'm able to retrieve books' details based on an ISBN. My FREE quota for Google Books API is 1000 request per day and 100 request every 100 seconds per user. I'm only sending 15 requests and my current quota is below 200. My key is

Where is openapi.yaml file in Google Cloud Function?

人盡茶涼 提交于 2020-06-01 05:09:31
问题 I created a simple Google Cloud Function and would like to restrict API access with API keys. It says I need to edit openapi.yaml file. I am not able to find it. Where I can find openapi.yaml file for Google Cloud project? 回答1: Have a look at this documentation: https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions#endpoints_configure The file corresponds to a manually-defined OpenAPI (formerly Swagger) definition that describes (in this case) your Cloud Function. You

Google Cloud Functions - how do I authenticate to AWS S3 bucket?

帅比萌擦擦* 提交于 2020-05-31 09:15:45
问题 I am trying to get a Google Cloud Function in Python 3.7 to take a file from Google Cloud Storage and upload it into AWS S3. In the command line, I would authenticate with awscli and then use the gsutil cp command to copy the file across. I have translated this process into python as: import subprocess def GCS_to_s3(arg1, arg2): subprocess.call(["aws configure set aws_access_key_id AKIA********"], shell=True) subprocess.call(["aws configure set aws_secret_access_key EgkjntEFFDVej"], shell

Firebase user's context.auth is present still allAuthenticatedUsers secured Google function error with UNAUTHENTICATED

做~自己de王妃 提交于 2020-05-31 05:43:44
问题 I wrote a simple cloud function: import * as functions from 'firebase-functions'; export const repeat = functions.https.onCall( function (data, context) { // Authentication user information is automatically added to the request. if (context.auth) { console.log(' context.auth is defined '); console.log(' uid is ' + context.auth.uid); } else { console.log(' context.auth undefine. '); } if (context.auth) { return { repeat_message: context.auth.uid + ' ' + data.message, repeat_count: data.count +

Firebase user's context.auth is present still allAuthenticatedUsers secured Google function error with UNAUTHENTICATED

怎甘沉沦 提交于 2020-05-31 05:43:31
问题 I wrote a simple cloud function: import * as functions from 'firebase-functions'; export const repeat = functions.https.onCall( function (data, context) { // Authentication user information is automatically added to the request. if (context.auth) { console.log(' context.auth is defined '); console.log(' uid is ' + context.auth.uid); } else { console.log(' context.auth undefine. '); } if (context.auth) { return { repeat_message: context.auth.uid + ' ' + data.message, repeat_count: data.count +