airflow.providers.google.cloud.hooks.functions

This module contains a Google Cloud Functions Hook.

Attributes

TIME_TO_SLEEP_IN_SECONDS

Classes

CloudFunctionsHook

Google Cloud Functions APIs.

Module Contents

airflow.providers.google.cloud.hooks.functions.TIME_TO_SLEEP_IN_SECONDS = 1[source]
class airflow.providers.google.cloud.hooks.functions.CloudFunctionsHook(api_version, gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

Google Cloud Functions APIs.

All the methods in the hook where project_id is used must be called with keyword arguments rather than positional.

api_version[source]
get_conn()[source]

Retrieve the connection to Cloud Functions.

Returns:

Google Cloud Function services object.

Return type:

googleapiclient.discovery.build

get_function(name)[source]

Get the Cloud Function with given name.

Parameters:

name (str) – Name of the function.

Returns:

A Cloud Functions object representing the function.

Return type:

dict

create_new_function(location, body, project_id)[source]

Create a new function at the location specified in the body.

Parameters:
  • location (str) – The location of the function.

  • body (dict) – The body required by the Cloud Functions insert API.

  • project_id (str) – Google Cloud Project ID where the function belongs. If set to None or missing, the default project ID from the Google Cloud connection is used.

update_function(name, body, update_mask)[source]

Update Cloud Functions according to the specified update mask.

Parameters:
  • name (str) – The name of the function.

  • body (dict) – The body required by the cloud function patch API.

  • update_mask (list[str]) – The update mask - array of fields that should be patched.

upload_function_zip(location, zip_path, project_id)[source]

Upload ZIP file with sources.

Parameters:
  • location (str) – The location where the function is created.

  • zip_path (str) – The path of the valid .zip file to upload.

  • project_id (str) – Google Cloud Project ID where the function belongs. If set to None or missing, the default project ID from the Google Cloud connection is used.

Returns:

The upload URL that was returned by generateUploadUrl method.

Return type:

str

delete_function(name)[source]

Delete the specified Cloud Function.

Parameters:

name (str) – The name of the function.

call_function(function_id, input_data, location, project_id=PROVIDE_PROJECT_ID)[source]

Invoke a deployed Cloud Function.

This is done synchronously and should only be used for testing purposes, as very limited traffic is allowed.

Parameters:
  • function_id (str) – ID of the function to be called

  • input_data (dict) – Input to be passed to the function

  • location (str) – The location where the function is located.

  • project_id (str) – Google Cloud Project ID where the function belongs. If set to None or missing, the default project ID from the Google Cloud connection is used.

Was this entry helpful?