blob: 615681265bf33d7fd2cb6cc96386b7949f8cc709 [file] [log] [blame]
:mod:`airflow.contrib.hooks.gcp_function_hook`
==============================================
.. py:module:: airflow.contrib.hooks.gcp_function_hook
Module Contents
---------------
.. data:: TIME_TO_SLEEP_IN_SECONDS
:annotation: = 1
.. py:class:: GcfHook(api_version, gcp_conn_id='google_cloud_default', delegate_to=None)
Bases: :class:`airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook`
Hook for the Google Cloud Functions APIs.
All the methods in the hook where project_id is used must be called with
keyword arguments rather than positional.
.. attribute:: _conn
.. staticmethod:: _full_location(project_id, location)
Retrieve full location of the function in the form of
projects/<GCP_PROJECT_ID>/locations/<GCP_LOCATION>
:param project_id: The Google Cloud Project project_id where the function belongs.
:type project_id: str
:param location: The location where the function is created.
:type location: str
:return:
.. method:: get_conn(self)
Retrieves the connection to Cloud Functions.
:return: Google Cloud Function services object.
:rtype: dict
.. method:: get_function(self, name)
Returns the Cloud Function with the given name.
:param name: Name of the function.
:type name: str
:return: A Cloud Functions object representing the function.
:rtype: dict
.. method:: create_new_function(self, location, body, project_id=None)
Creates a new function in Cloud Function in the location specified in the body.
:param location: The location of the function.
:type location: str
:param body: The body required by the Cloud Functions insert API.
:type body: dict
:param project_id: Optional, Google Cloud Project project_id where the function belongs.
If set to None or missing, the default project_id from the GCP connection is used.
:type project_id: str
:return: None
.. method:: update_function(self, name, body, update_mask)
Updates Cloud Functions according to the specified update mask.
:param name: The name of the function.
:type name: str
:param body: The body required by the cloud function patch API.
:type body: dict
:param update_mask: The update mask - array of fields that should be patched.
:type update_mask: [str]
:return: None
.. method:: upload_function_zip(self, location, zip_path, project_id=None)
Uploads zip file with sources.
:param location: The location where the function is created.
:type location: str
:param zip_path: The path of the valid .zip file to upload.
:type zip_path: str
:param project_id: Optional, Google Cloud Project project_id where the function belongs.
If set to None or missing, the default project_id from the GCP connection is used.
:type project_id: str
:return: The upload URL that was returned by generateUploadUrl method.
.. method:: delete_function(self, name)
Deletes the specified Cloud Function.
:param name: The name of the function.
:type name: str
:return: None
.. method:: _wait_for_operation_to_complete(self, operation_name)
Waits for the named operation to complete - checks status of the
asynchronous call.
:param operation_name: The name of the operation.
:type operation_name: str
:return: The response returned by the operation.
:rtype: dict
:exception: AirflowException in case error is returned.