airflow.providers.google.cloud.operators.functions

This module contains Google Cloud Functions operators.

Module Contents

Classes

CloudFunctionDeployFunctionOperator

Create or update a function in Google Cloud Functions.

ZipPathPreprocessor

Pre-processes zip path parameter.

CloudFunctionDeleteFunctionOperator

Deletes the specified function from Google Cloud Functions.

CloudFunctionInvokeFunctionOperator

Invokes a deployed Cloud Function. To be used for testing purposes as very limited traffic is allowed.

Attributes

CLOUD_FUNCTION_VALIDATION

GCF_SOURCE_ARCHIVE_URL

GCF_SOURCE_UPLOAD_URL

SOURCE_REPOSITORY

GCF_ZIP_PATH

FUNCTION_NAME_PATTERN

FUNCTION_NAME_COMPILED_PATTERN

airflow.providers.google.cloud.operators.functions.CLOUD_FUNCTION_VALIDATION: list[dict[str, Any]][source]
class airflow.providers.google.cloud.operators.functions.CloudFunctionDeployFunctionOperator(*, location, body, project_id=None, gcp_conn_id='google_cloud_default', api_version='v1', zip_path=None, validate_body=True, impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Create or update a function in Google Cloud Functions.

See also

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

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

  • body (dict) – 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 | None) – (Optional) Google Cloud project ID where the function should be created.

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

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

  • zip_path (str | None) – 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.

  • impersonation_chain (str | Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields: Sequence[str] = ('body', 'project_id', 'location', 'gcp_conn_id', 'api_version', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

airflow.providers.google.cloud.operators.functions.GCF_SOURCE_ARCHIVE_URL = 'sourceArchiveUrl'[source]
airflow.providers.google.cloud.operators.functions.GCF_SOURCE_UPLOAD_URL = 'sourceUploadUrl'[source]
airflow.providers.google.cloud.operators.functions.SOURCE_REPOSITORY = 'sourceRepository'[source]
airflow.providers.google.cloud.operators.functions.GCF_ZIP_PATH = 'zip_path'[source]
class airflow.providers.google.cloud.operators.functions.ZipPathPreprocessor(body, zip_path=None)[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 (str | None) – (optional) 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.

upload_function: bool | None[source]
should_upload_function()[source]

Checks if function source should be uploaded.

preprocess_body()[source]

Modifies sourceUploadUrl body field in special way when zip_path is not empty.

airflow.providers.google.cloud.operators.functions.FUNCTION_NAME_PATTERN = '^projects/[^/]+/locations/[^/]+/functions/[^/]+$'[source]
airflow.providers.google.cloud.operators.functions.FUNCTION_NAME_COMPILED_PATTERN[source]
class airflow.providers.google.cloud.operators.functions.CloudFunctionDeleteFunctionOperator(*, name, gcp_conn_id='google_cloud_default', api_version='v1', impersonation_chain=None, project_id=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

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: CloudFunctionDeleteFunctionOperator

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.

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

  • impersonation_chain (str | Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields: Sequence[str] = ('name', 'gcp_conn_id', 'api_version', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.functions.CloudFunctionInvokeFunctionOperator(*, function_id, input_data, location, project_id=None, gcp_conn_id='google_cloud_default', api_version='v1', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Invokes a deployed Cloud Function. To be used for testing purposes as very limited traffic is allowed.

See also

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

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 | None) – Optional, Google Cloud Project project_id where the function belongs. If set to None or missing, the default project_id from the Google Cloud connection is used.

  • impersonation_chain (str | Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

Returns

None

template_fields: Sequence[str] = ('function_id', 'input_data', 'location', 'project_id', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?