Please help me set up the Looker action end to end from setting the infra and getting the permission and also what I am going to do is there is table look in dashboard and there will be three column where we need to write some notes using the action and then it has to go to cloud function and it has to update the bigquery table
Solved! Go to Solution.
Correct, thats specified in the answer above.
Hi SachinS
if I understand correctly, you want to be able to write back to BigQuery. I had put together a guide a while back, happy to share that with you. Please be aware: this has been created a while ago, so some things might have changed from wording/functionality, but it should explain the way on how to set this up!
## requirements.txt
google-cloud-bigquery==1.27.2
## main.py
from google.cloud import bigquery
client = bigquery.Client()
def annotate(request):
"""Update a BQ table from a Looker action"""
request_json = request.get_json()
geo = request_json['data']['geo_id']
date = request_json['data']['date']
notes = request_json['form_params']['notes']
data = [{'geo_id': geo, 'date': date, 'notes': notes}]
table_ref = client.dataset('public').table('annotations') # Check schema + table name
table = client.get_table(table_ref)
try:
r = client.insert_rows_json(table, data)
return {"inserted_data": data[0],
"looker": {
"success": true,
"refresh_query": true
}
}
except Exception as e:
print(e) # Errors will get logged in Stackdriver
```
join: annotations { # Or whatever the table name is
relationship: one_to_one
type: left_outer
sql_on: ${annotations.geo_id} = ${table.geo_id} AND ${annotations.date_raw} = ${table.date_raw} ;;
}
```
and also cloud function should be in allow all traffic state to work on this looker , because in my case looker is one GCP project and cloud function and bigquery is in another GCP project
Correct, thats specified in the answer above.
In our case clients are not ok with allow all traffic , in that case what other alternative steps need to follow for this
and also do we have any supporting document that says that allow all traffic is must for looker action
@marcwo can you please reply on the above queries
Hi
this is a guide on a way to achieve what you are trying to solve, there is no documentation stating that.
There is no way currently to send authentication through the cell_action. The only way I can think of right now is to imitate some kind of authentication thats user_attribute based and gets send with the action and get compared to something for example stored in secret manager, to ensure only users who are authorized can successfully trigger the endpoint.
Thanks and have a good day.
@marcwo is there any other way to achieve my usecase , if we cant use the looker action with allow all traffic cloud function.
Thank you