google-cloud-functions

Failed to configure trigger providers/cloud.firestore/eventTypes/document.update

爱⌒轻易说出口 提交于 2020-01-25 06:03:08
问题 I plan on updating the news_author_user_type every time an update happens on user_type in users node Here's my code exports.onUpdateUserType = functions.firestore .document('users/{user_id') .onUpdate((change, context) => { const newUserDoc = change.after.data(); const user_type = newUserDoc.user_type; const user_id = context.auth.uid; const db = admin.firestore(); const newsRef = db.collection('news').where('news_author_id', '==', user_id); const news = newsRef.get().then(onSnapshot => {

Dialogflow Fulfillment TypeError : Cannot read property 'Parameters'

半腔热情 提交于 2020-01-24 22:15:48
问题 Hello I'm trying to make a webhook to my mysql database and everything worked perfectly, until I tried to add parameters. I always get this error in the firebase cloudfunctions TypeError: Cannot read property 'parameters' of undefined at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/user_code/index.js:17:47) at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:57:9) at /var/tmp/worker/worker.js:783:7 at /var/tmp/worker/worker.js:766:11 at

Cloud Container Builder, ZIP does not support timestamps before 1980

∥☆過路亽.° 提交于 2020-01-24 22:05:50
问题 I'm trying the following tutorial. Automatic serverless deployments with Cloud Source Repositories and Container Builder But I got the error below. $ gcloud container builds submit --config deploy.yaml . BUILD Already have image (with digest): gcr.io/cloud-builders/gcloud ERROR: (gcloud.beta.functions.deploy) Error creating a ZIP archive with the source code for directory .: ZIP does not support timestamps before 1980 ERROR ERROR: build step 0 "gcr.io/cloud-builders/gcloud" failed: exit

Adding @google-cloud/logging in typescript functions project gives error

痞子三分冷 提交于 2020-01-24 21:53:05
问题 EDIT: for others with the same problem - using const Logging: any = require('@google-cloud/logging') together with var logger = Logging() in the body of the class worked like a charm! Remember to use var logger = Logging() to instantiate the logger library. Otherwise you will still get the logger.log is not a function ! Original post I've got a firebase functions project, written in typescript - transpiled with webpack. I'm currently trying to implement the @google-cloud/logging library, but

firebase functions and external API

浪尽此生 提交于 2020-01-24 20:30:46
问题 const functions = require('firebase-functions'); exports.apiResponse = functions.https.onRequest((request, response) => { const url = "https://test-proj-heroku.herokuapp.com/api/plans" const https = require('https'); var req = https.get(url, (resp) => { let data = ''; resp.on('data', (chunk) => { data += chunk; }); resp.on('end', () => { var result = JSON.parse(data); response.send({ fulfillmentText: "Firebase 🔥 API Is Running..." }); }); }).on("error", (err) => { console.log("Error: " + err

tmp file in Google cloud Functions for Python

对着背影说爱祢 提交于 2020-01-24 19:32:09
问题 Python runs like a charm on google cloud functions, but for the tmp files. Here's my simplified code: FILE_PATH = "{}/report.pdf".format(tempfile.gettempdir()) pdf.output(FILE_PATH) ... with open(FILE_PATH,'rb') as f: data = f.read() f.close() encoded = base64.b64encode(data).decode() attachment = Attachment() attachment.content = str(encoded) attachment.type = "application/pdf" attachment.filename = "report" attachment.disposition = "attachment" attachment.content_id = "Report" mail = Mail

Deploying Google Cloud function from a Google Build

谁说胖子不能爱 提交于 2020-01-24 19:20:07
问题 When attempting to deploy a simple function, I am running into a 403 error. Here is my full yaml: steps: # Install Dependencies - name: 'python' id: Pip install args: ['pip3', 'install', '-r', 'requirements.txt', '--user'] # Run Tests - name: 'python' args: ['python3', '-m', 'pytest', 'functions/folder_a/test/'] # Deploy Cloud Functions - name: 'gcr.io/cloud-builders/gcloud' id: 'helloFunction' args: ['functions', 'deploy', 'hello', '--source' , 'functions/folder_a/main.py', '--runtime' ,

Batched Writes or Transaction in Cloud Functions? [duplicate]

末鹿安然 提交于 2020-01-24 01:26:07
问题 This question already has an answer here : Is there any benefit to Batched Writes over Transactions other than offline availability? [closed] (1 answer) Closed 7 months ago . I have the following Cloud Function and want to find out whether I should use batched writes or a transaction: const firestore = admin.firestore() // The following two queries potentially return hundreds of documents. const queryA = firestore.collectionGroup('a').where('b', '==', 'c'), queryB = firestore.collection('b')

How can I get specific document data from firestore querysnapshot?

大兔子大兔子 提交于 2020-01-23 12:05:33
问题 I got a querysnapshot in a function. And want to bring the whole querysnapshot to another function (functionTwo). In functionTwo, I want to get a specific document in the querysnapshot WITHOUT forEach. The specific doc can be changed by different case. ref_serial_setting.get() .then(querysnapshot => { return functionTwo(querysnapshot) }) .catch(err => { console.log('Error getting documents', err) }) let functionTwo = (querysnapshot) => { // getting value const dataKey_1 = "dataKey_1" // Tried

How can I get specific document data from firestore querysnapshot?

不问归期 提交于 2020-01-23 12:04:26
问题 I got a querysnapshot in a function. And want to bring the whole querysnapshot to another function (functionTwo). In functionTwo, I want to get a specific document in the querysnapshot WITHOUT forEach. The specific doc can be changed by different case. ref_serial_setting.get() .then(querysnapshot => { return functionTwo(querysnapshot) }) .catch(err => { console.log('Error getting documents', err) }) let functionTwo = (querysnapshot) => { // getting value const dataKey_1 = "dataKey_1" // Tried