| :py:mod:`airflow.providers.google.cloud.hooks.compute` |
| ====================================================== |
| |
| .. py:module:: airflow.providers.google.cloud.hooks.compute |
| |
| .. autoapi-nested-parse:: |
| |
| This module contains a Google Compute Engine Hook. |
| |
| |
| |
| Module Contents |
| --------------- |
| |
| Classes |
| ~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.providers.google.cloud.hooks.compute.GceOperationStatus |
| airflow.providers.google.cloud.hooks.compute.ComputeEngineHook |
| |
| |
| |
| |
| Attributes |
| ~~~~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.providers.google.cloud.hooks.compute.TIME_TO_SLEEP_IN_SECONDS |
| |
| |
| .. py:data:: TIME_TO_SLEEP_IN_SECONDS |
| :annotation: = 1 |
| |
| |
| |
| .. py:class:: GceOperationStatus |
| |
| Class with GCE operations statuses. |
| |
| .. py:attribute:: PENDING |
| :annotation: = PENDING |
| |
| |
| |
| .. py:attribute:: RUNNING |
| :annotation: = RUNNING |
| |
| |
| |
| .. py:attribute:: DONE |
| :annotation: = DONE |
| |
| |
| |
| |
| .. py:class:: ComputeEngineHook(api_version = 'v1', gcp_conn_id = 'google_cloud_default', delegate_to = None, impersonation_chain = None) |
| |
| Bases: :py:obj:`airflow.providers.google.common.hooks.base_google.GoogleBaseHook` |
| |
| Hook for Google Compute Engine APIs. |
| |
| All the methods in the hook where project_id is used must be called with |
| keyword arguments rather than positional. |
| |
| .. py:method:: get_conn(self) |
| |
| Retrieves connection to Google Compute Engine. |
| :return: Google Compute Engine services object |
| :rtype: dict |
| |
| |
| .. py:method:: start_instance(self, zone, resource_id, project_id) |
| |
| Starts an existing instance defined by project_id, zone and resource_id. |
| Must be called with keyword arguments rather than positional. |
| |
| :param zone: Google Cloud zone where the instance exists |
| :param resource_id: Name of the Compute Engine instance resource |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| :return: None |
| |
| |
| .. py:method:: stop_instance(self, zone, resource_id, project_id) |
| |
| Stops an instance defined by project_id, zone and resource_id |
| Must be called with keyword arguments rather than positional. |
| |
| :param zone: Google Cloud zone where the instance exists |
| :param resource_id: Name of the Compute Engine instance resource |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| :return: None |
| |
| |
| .. py:method:: set_machine_type(self, zone, resource_id, body, project_id) |
| |
| Sets machine type of an instance defined by project_id, zone and resource_id. |
| Must be called with keyword arguments rather than positional. |
| |
| :param zone: Google Cloud zone where the instance exists. |
| :param resource_id: Name of the Compute Engine instance resource |
| :param body: Body required by the Compute Engine setMachineType API, |
| as described in |
| https://cloud.google.com/compute/docs/reference/rest/v1/instances/setMachineType |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| :return: None |
| |
| |
| .. py:method:: get_instance_template(self, resource_id, project_id) |
| |
| Retrieves instance template by project_id and resource_id. |
| Must be called with keyword arguments rather than positional. |
| |
| :param resource_id: Name of the instance template |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| :return: Instance template representation as object according to |
| https://cloud.google.com/compute/docs/reference/rest/v1/instanceTemplates |
| :rtype: dict |
| |
| |
| .. py:method:: insert_instance_template(self, body, project_id = PROVIDE_PROJECT_ID, request_id = None) |
| |
| Inserts instance template using body specified |
| Must be called with keyword arguments rather than positional. |
| |
| :param body: Instance template representation as object according to |
| https://cloud.google.com/compute/docs/reference/rest/v1/instanceTemplates |
| :param request_id: Optional, unique request_id that you might add to achieve |
| full idempotence (for example when client call times out repeating the request |
| with the same request id will not create a new instance template again) |
| It should be in UUID format as defined in RFC 4122 |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| :return: None |
| |
| |
| .. py:method:: get_instance_group_manager(self, zone, resource_id, project_id = PROVIDE_PROJECT_ID) |
| |
| Retrieves Instance Group Manager by project_id, zone and resource_id. |
| Must be called with keyword arguments rather than positional. |
| |
| :param zone: Google Cloud zone where the Instance Group Manager exists |
| :param resource_id: Name of the Instance Group Manager |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| :return: Instance group manager representation as object according to |
| https://cloud.google.com/compute/docs/reference/rest/beta/instanceGroupManagers |
| :rtype: dict |
| |
| |
| .. py:method:: patch_instance_group_manager(self, zone, resource_id, body, project_id, request_id = None) |
| |
| Patches Instance Group Manager with the specified body. |
| Must be called with keyword arguments rather than positional. |
| |
| :param zone: Google Cloud zone where the Instance Group Manager exists |
| :param resource_id: Name of the Instance Group Manager |
| :param body: Instance Group Manager representation as json-merge-patch object |
| according to |
| https://cloud.google.com/compute/docs/reference/rest/beta/instanceTemplates/patch |
| :param request_id: Optional, unique request_id that you might add to achieve |
| full idempotence (for example when client call times out repeating the request |
| with the same request id will not create a new instance template again). |
| It should be in UUID format as defined in RFC 4122 |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| :return: None |
| |
| |
| .. py:method:: get_instance_info(self, zone, resource_id, project_id) |
| |
| Gets instance information. |
| |
| :param zone: Google Cloud zone where the Instance Group Manager exists |
| :param resource_id: Name of the Instance Group Manager |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| |
| |
| .. py:method:: get_instance_address(self, zone, resource_id, project_id = PROVIDE_PROJECT_ID, use_internal_ip = False) |
| |
| Return network address associated to instance. |
| |
| :param zone: Google Cloud zone where the Instance Group Manager exists |
| :param resource_id: Name of the Instance Group Manager |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| :param use_internal_ip: If true, return private IP address. |
| |
| |
| .. py:method:: set_instance_metadata(self, zone, resource_id, metadata, project_id) |
| |
| Set instance metadata. |
| |
| :param zone: Google Cloud zone where the Instance Group Manager exists |
| :param resource_id: Name of the Instance Group Manager |
| :param metadata: The new instance metadata. |
| :param project_id: Optional, Google Cloud project ID where the |
| Compute Engine Instance exists. If set to None or missing, |
| the default project_id from the Google Cloud connection is used. |
| |
| |
| |