{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator/issues/121","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator/issues/121/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator/issues/121/events","html_url":"https://github.com/GoogleCloudPlatform/cloud-functions-emulator/pull/121","id":239000525,"number":121,"title":"Support Firebase event types","user":{"login":"laurenzlong","id":3990804,"avatar_url":"https://avatars0.githubusercontent.com/u/3990804?v=4","gravatar_id":"","url":"https://api.github.com/users/laurenzlong","html_url":"https://github.com/laurenzlong","followers_url":"https://api.github.com/users/laurenzlong/followers","following_url":"https://api.github.com/users/laurenzlong/following{/other_user}","gists_url":"https://api.github.com/users/laurenzlong/gists{/gist_id}","starred_url":"https://api.github.com/users/laurenzlong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laurenzlong/subscriptions","organizations_url":"https://api.github.com/users/laurenzlong/orgs","repos_url":"https://api.github.com/users/laurenzlong/repos","events_url":"https://api.github.com/users/laurenzlong/events{/privacy}","received_events_url":"https://api.github.com/users/laurenzlong/received_events","type":"User","site_admin":false},"labels":[{"id":467912214,"url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":{"login":"laurenzlong","id":3990804,"avatar_url":"https://avatars0.githubusercontent.com/u/3990804?v=4","gravatar_id":"","url":"https://api.github.com/users/laurenzlong","html_url":"https://github.com/laurenzlong","followers_url":"https://api.github.com/users/laurenzlong/followers","following_url":"https://api.github.com/users/laurenzlong/following{/other_user}","gists_url":"https://api.github.com/users/laurenzlong/gists{/gist_id}","starred_url":"https://api.github.com/users/laurenzlong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laurenzlong/subscriptions","organizations_url":"https://api.github.com/users/laurenzlong/orgs","repos_url":"https://api.github.com/users/laurenzlong/repos","events_url":"https://api.github.com/users/laurenzlong/events{/privacy}","received_events_url":"https://api.github.com/users/laurenzlong/received_events","type":"User","site_admin":false},"assignees":[{"login":"laurenzlong","id":3990804,"avatar_url":"https://avatars0.githubusercontent.com/u/3990804?v=4","gravatar_id":"","url":"https://api.github.com/users/laurenzlong","html_url":"https://github.com/laurenzlong","followers_url":"https://api.github.com/users/laurenzlong/followers","following_url":"https://api.github.com/users/laurenzlong/following{/other_user}","gists_url":"https://api.github.com/users/laurenzlong/gists{/gist_id}","starred_url":"https://api.github.com/users/laurenzlong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laurenzlong/subscriptions","organizations_url":"https://api.github.com/users/laurenzlong/orgs","repos_url":"https://api.github.com/users/laurenzlong/repos","events_url":"https://api.github.com/users/laurenzlong/events{/privacy}","received_events_url":"https://api.github.com/users/laurenzlong/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2017-06-27T22:23:05Z","updated_at":"2017-07-18T00:37:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator/pulls/121","html_url":"https://github.com/GoogleCloudPlatform/cloud-functions-emulator/pull/121","diff_url":"https://github.com/GoogleCloudPlatform/cloud-functions-emulator/pull/121.diff","patch_url":"https://github.com/GoogleCloudPlatform/cloud-functions-emulator/pull/121.patch"},"body":"Fixes https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/84\r\n\r\n**To deploy a Firebase database function**\r\n\r\nCreate a .runtimeconfig.json in your functions directory that look like:\r\n```\r\n{\r\n\t\"firebase\": {\r\n\t\t\"databaseURL\": \"https://project-id.firebaseio.com\"\r\n\t}\r\n}\r\n```\r\nThen run:\r\n```\r\nfunctions deploy <functionName> --trigger-provider=google.firebase.database\r\n --trigger-event=ref.write\r\n```\r\n\r\n**To call a Firebase database function**\r\n```\r\n# data field must be an object with a data field (representing the previous state) \r\nand a delta field (representing the new state). The command below mocks an event \r\nof a new write of \"hello\" at /path\r\nfunctions call <functionName> --data='{\"data\":null,\"delta\":\"hello\"}'\r\n --resource=projects/_/instances/project-id/refs/path\r\n```\r\n\r\n_Similar process for deploying/calling other Firebase events._\r\n\r\nEmulating database functions will be coming soon in the Firebase CLI, which will be easier to use since there won't be need for as many flags, and there wouldn't be a need to create the .runtimeconfig.json\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator/issues/comments/315924359","html_url":"https://github.com/GoogleCloudPlatform/cloud-functions-emulator/pull/121#issuecomment-315924359","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/cloud-functions-emulator/issues/121","id":315924359,"user":{"login":"jmdobry","id":1213510,"avatar_url":"https://avatars0.githubusercontent.com/u/1213510?v=4","gravatar_id":"","url":"https://api.github.com/users/jmdobry","html_url":"https://github.com/jmdobry","followers_url":"https://api.github.com/users/jmdobry/followers","following_url":"https://api.github.com/users/jmdobry/following{/other_user}","gists_url":"https://api.github.com/users/jmdobry/gists{/gist_id}","starred_url":"https://api.github.com/users/jmdobry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmdobry/subscriptions","organizations_url":"https://api.github.com/users/jmdobry/orgs","repos_url":"https://api.github.com/users/jmdobry/repos","events_url":"https://api.github.com/users/jmdobry/events{/privacy}","received_events_url":"https://api.github.com/users/jmdobry/received_events","type":"User","site_admin":false},"created_at":"2017-07-18T00:37:42Z","updated_at":"2017-07-18T00:37:42Z","body":"This won't work. The `CallFunctionRequest` message in the Cloud Functions proto only supports the `name` and `data` fields, and we can't add other fields to the message. This is why the `gcloud beta functions call` command in the Gcloud SDK does not accept `resource`, `params`, or `auth` options from the user.\r\n\r\nI think for now (until Cloud Functions changes) the Emulator will need to look at the configured trigger-event/provider of the deployed function and attach some mock metadata to the event payload on its own. Or, think of another way for the user to provide the event metadata to the function without using the `call` command."}}
{"actor":{"display_login":"jmdobry"}}