airflow.contrib.operators.gcp_function_operator

Module Contents

airflow.contrib.operators.gcp_function_operator._validate_available_memory_in_mb(value)[source]
airflow.contrib.operators.gcp_function_operator._validate_max_instances(value)[source]
airflow.contrib.operators.gcp_function_operator.CLOUD_FUNCTION_VALIDATION[source]
class airflow.contrib.operators.gcp_function_operator.GcfFunctionDeployOperator(location, body, project_id=None, gcp_conn_id='google_cloud_default', api_version='v1', zip_path=None, validate_body=True, *args, **kwargs)[source]

Bases:airflow.models.BaseOperator

Creates a function in Google Cloud Functions. If a function with this name already exists, it will be updated.

See also

For more information on how to use this operator, take a look at the guide: GcfFunctionDeployOperator

Parameters
  • location (str) – Google Cloud Platform region where the function should be created.

  • body (dict or google.cloud.functions.v1.CloudFunction) – Body of the Cloud Functions definition. The body must be a Cloud Functions dictionary as described in: https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions . Different API versions require different variants of the Cloud Functions dictionary.

  • project_id (str) – (Optional) Google Cloud Platform project ID where the function should be created.

  • gcp_conn_id (str) – (Optional) The connection ID used to connect to Google Cloud Platform - default ‘google_cloud_default’.

  • api_version (str) – (Optional) API version used (for example v1 - default - or v1beta1).

  • zip_path (str) – Path to zip file containing source code of the function. If the path is set, the sourceUploadUrl should not be specified in the body or it should be empty. Then the zip file will be uploaded using the upload URL generated via generateUploadUrl from the Cloud Functions API.

  • validate_body (bool) – If set to False, body validation is not performed.

template_fields = ['project_id', 'location', 'gcp_conn_id', 'api_version'][source]
_validate_inputs(self)[source]
_validate_all_body_fields(self)[source]
_create_new_function(self)[source]
_update_function(self)[source]
_check_if_function_exists(self)[source]
_upload_source_code(self)[source]
_set_airflow_version_label(self)[source]
execute(self, context)[source]
airflow.contrib.operators.gcp_function_operator.GCF_SOURCE_ARCHIVE_URL = sourceArchiveUrl[source]
airflow.contrib.operators.gcp_function_operator.GCF_SOURCE_UPLOAD_URL = sourceUploadUrl[source]
airflow.contrib.operators.gcp_function_operator.SOURCE_REPOSITORY = sourceRepository[source]
airflow.contrib.operators.gcp_function_operator.GCF_ZIP_PATH = zip_path[source]
class airflow.contrib.operators.gcp_function_operator.ZipPathPreprocessor(body, zip_path)[source]

Pre-processes zip path parameter.

Responsible for checking if the zip path parameter is correctly specified in relation with source_code body fields. Non empty zip path parameter is special because it is mutually exclusive with sourceArchiveUrl and sourceRepository body fields. It is also mutually exclusive with non-empty sourceUploadUrl. The pre-process modifies sourceUploadUrl body field in special way when zip_path is not empty. An extra step is run when execute method is called and sourceUploadUrl field value is set in the body with the value returned by generateUploadUrl Cloud Function API method.

Parameters
  • body (dict) – Body passed to the create/update method calls.

  • zip_path – path to the zip file containing source code.

upload_function[source]
static _is_present_and_empty(dictionary, field)[source]
_verify_upload_url_and_no_zip_path(self)[source]
_verify_upload_url_and_zip_path(self)[source]
_verify_archive_url_and_zip_path(self)[source]
should_upload_function(self)[source]
preprocess_body(self)[source]
airflow.contrib.operators.gcp_function_operator.FUNCTION_NAME_PATTERN = ^projects/[^/]+/locations/[^/]+/functions/[^/]+$[source]
airflow.contrib.operators.gcp_function_operator.FUNCTION_NAME_COMPILED_PATTERN[source]
class airflow.contrib.operators.gcp_function_operator.GcfFunctionDeleteOperator(name, gcp_conn_id='google_cloud_default', api_version='v1', *args, **kwargs)[source]

Bases:airflow.models.BaseOperator

Deletes the specified function from Google Cloud Functions.

See also

For more information on how to use this operator, take a look at the guide: GcfFunctionDeleteOperator

Parameters
  • name (str) – A fully-qualified function name, matching the pattern: ^projects/[^/]+/locations/[^/]+/functions/[^/]+$

  • gcp_conn_id (str) – The connection ID to use to connect to Google Cloud Platform.

  • api_version (str) – API version used (for example v1 or v1beta1).

template_fields = ['name', 'gcp_conn_id', 'api_version'][source]
_validate_inputs(self)[source]
execute(self, context)[source]