I am trying to trigger a Scheduled Query through a Cloud Function in GCP. I tried to follow several tutorials and examples and went through the documentation too but with the new version of the API google-cloud-bigquery-datatransfer==3.1.1
I can't find anything showing the proper procedure.
You will find below my current code :
from google.cloud import bigquery_datatransfer_v1
def triggerQuery (parent, requested_run_time):
client = bigquery_datatransfer_v1.DataTransferServiceClient()
project_id = '###' # Enter your projectID here
location_id = 'europe' # Enter your locationID here
transfer_id = '###' # Enter your transferId here
transfer_config = {...}
path = f"projects/{project_id}/locations/{location_id}/transferConfigs/{transfer_id}"
parent = client.transfer_config_path(project_id, transfer_id)
response = client.start_manual_transfer_runs(path)
print(response)
I tried passing to client.start_manual_transfer_runs
either path
or parent
but I get :
TypeError: Invalid constructor input for StartManualTransferRunsRequest: 'projects/###/locations/europe/transferConfigs/###'
I also need to specify that the Cloud Function is associated to the proper Service Account that has the rights to run queries in BigQuery.
Help would be greatly appreciated !
You need to enter parameters of manual transfer run in dictionary format. Below code works for me: