blob: ebbb49bef854779c35f4c8755ef4fdf480212b04 [file] [log] [blame]
:py:mod:`airflow.providers.google.cloud.operators.compute`
==========================================================
.. py:module:: airflow.providers.google.cloud.operators.compute
.. autoapi-nested-parse::
This module contains Google Compute Engine operators.
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.google.cloud.operators.compute.ComputeEngineBaseOperator
airflow.providers.google.cloud.operators.compute.ComputeEngineStartInstanceOperator
airflow.providers.google.cloud.operators.compute.ComputeEngineStopInstanceOperator
airflow.providers.google.cloud.operators.compute.ComputeEngineSetMachineTypeOperator
airflow.providers.google.cloud.operators.compute.ComputeEngineCopyInstanceTemplateOperator
airflow.providers.google.cloud.operators.compute.ComputeEngineInstanceGroupUpdateManagerTemplateOperator
Attributes
~~~~~~~~~~
.. autoapisummary::
airflow.providers.google.cloud.operators.compute.SET_MACHINE_TYPE_VALIDATION_SPECIFICATION
airflow.providers.google.cloud.operators.compute.GCE_INSTANCE_TEMPLATE_VALIDATION_PATCH_SPECIFICATION
airflow.providers.google.cloud.operators.compute.GCE_INSTANCE_TEMPLATE_FIELDS_TO_SANITIZE
.. py:class:: ComputeEngineBaseOperator(*, zone, resource_id, project_id = None, gcp_conn_id = 'google_cloud_default', api_version = 'v1', impersonation_chain = None, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
Abstract base operator for Google Compute Engine operators to inherit from.
.. py:method:: execute(self, context)
This is the main method to derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
.. py:class:: ComputeEngineStartInstanceOperator(*, zone, resource_id, project_id = None, gcp_conn_id = 'google_cloud_default', api_version = 'v1', impersonation_chain = None, **kwargs)
Bases: :py:obj:`ComputeEngineBaseOperator`
Starts an instance in Google Compute Engine.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:ComputeEngineStartInstanceOperator`
: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.
:param gcp_conn_id: Optional, The connection ID used to connect to Google Cloud.
Defaults to 'google_cloud_default'.
:param api_version: Optional, API version used (for example v1 - or beta). Defaults
to v1.
:param impersonation_chain: 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).
.. py:attribute:: template_fields
:annotation: :Sequence[str] = ['project_id', 'zone', 'resource_id', 'gcp_conn_id', 'api_version', 'impersonation_chain']
.. py:method:: execute(self, context)
This is the main method to derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
.. py:class:: ComputeEngineStopInstanceOperator(*, zone, resource_id, project_id = None, gcp_conn_id = 'google_cloud_default', api_version = 'v1', impersonation_chain = None, **kwargs)
Bases: :py:obj:`ComputeEngineBaseOperator`
Stops an instance in Google Compute Engine.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:ComputeEngineStopInstanceOperator`
: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.
:param gcp_conn_id: Optional, The connection ID used to connect to Google Cloud.
Defaults to 'google_cloud_default'.
:param api_version: Optional, API version used (for example v1 - or beta). Defaults
to v1.
:param impersonation_chain: 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).
.. py:attribute:: template_fields
:annotation: :Sequence[str] = ['project_id', 'zone', 'resource_id', 'gcp_conn_id', 'api_version', 'impersonation_chain']
.. py:method:: execute(self, context)
This is the main method to derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
.. py:data:: SET_MACHINE_TYPE_VALIDATION_SPECIFICATION
.. py:class:: ComputeEngineSetMachineTypeOperator(*, zone, resource_id, body, project_id = None, gcp_conn_id = 'google_cloud_default', api_version = 'v1', validate_body = True, impersonation_chain = None, **kwargs)
Bases: :py:obj:`ComputeEngineBaseOperator`
Changes the machine type for a stopped instance to the machine type specified in
the request.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:ComputeEngineSetMachineTypeOperator`
: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#request-body
: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 gcp_conn_id: Optional, The connection ID used to connect to Google Cloud.
Defaults to 'google_cloud_default'.
:param api_version: Optional, API version used (for example v1 - or beta). Defaults
to v1.
:param validate_body: Optional, If set to False, body validation is not performed.
Defaults to False.
:param impersonation_chain: 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).
.. py:attribute:: template_fields
:annotation: :Sequence[str] = ['project_id', 'zone', 'resource_id', 'body', 'gcp_conn_id', 'api_version', 'impersonation_chain']
.. py:method:: execute(self, context)
This is the main method to derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
.. py:data:: GCE_INSTANCE_TEMPLATE_VALIDATION_PATCH_SPECIFICATION
:annotation: :List[Dict[str, Any]]
.. py:data:: GCE_INSTANCE_TEMPLATE_FIELDS_TO_SANITIZE
:annotation: = ['kind', 'id', 'name', 'creationTimestamp', 'properties.disks.sha256', 'properties.disks.kind',...
.. py:class:: ComputeEngineCopyInstanceTemplateOperator(*, resource_id, body_patch, project_id = None, request_id = None, gcp_conn_id = 'google_cloud_default', api_version = 'v1', validate_body = True, impersonation_chain = None, **kwargs)
Bases: :py:obj:`ComputeEngineBaseOperator`
Copies the instance template, applying specified changes.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:ComputeEngineCopyInstanceTemplateOperator`
:param resource_id: Name of the Instance Template
:param body_patch: Patch to the body of instanceTemplates object following rfc7386
PATCH semantics. The body_patch content follows
https://cloud.google.com/compute/docs/reference/rest/v1/instanceTemplates
Name field is required as we need to rename the template,
all the other fields are optional. It is important to follow PATCH semantics
- arrays are replaced fully, so if you need to update an array you should
provide the whole target array as patch element.
: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 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 gcp_conn_id: Optional, The connection ID used to connect to Google Cloud.
Defaults to 'google_cloud_default'.
:param api_version: Optional, API version used (for example v1 - or beta). Defaults
to v1.
:param validate_body: Optional, If set to False, body validation is not performed.
Defaults to False.
:param impersonation_chain: 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).
.. py:attribute:: template_fields
:annotation: :Sequence[str] = ['project_id', 'resource_id', 'request_id', 'gcp_conn_id', 'api_version', 'impersonation_chain']
.. py:method:: execute(self, context)
This is the main method to derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
.. py:class:: ComputeEngineInstanceGroupUpdateManagerTemplateOperator(*, resource_id, zone, source_template, destination_template, project_id = None, update_policy = None, request_id = None, gcp_conn_id = 'google_cloud_default', api_version='beta', impersonation_chain = None, **kwargs)
Bases: :py:obj:`ComputeEngineBaseOperator`
Patches the Instance Group Manager, replacing source template URL with the
destination one. API V1 does not have update/patch operations for Instance
Group Manager, so you must use beta or newer API version. Beta is the default.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:ComputeEngineInstanceGroupUpdateManagerTemplateOperator`
:param resource_id: Name of the Instance Group Manager
:param zone: Google Cloud zone where the Instance Group Manager exists.
:param source_template: URL of the template to replace.
:param destination_template: URL of the target 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.
: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 gcp_conn_id: Optional, The connection ID used to connect to Google Cloud.
Defaults to 'google_cloud_default'.
:param api_version: Optional, API version used (for example v1 - or beta). Defaults
to v1.
:param impersonation_chain: 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).
.. py:attribute:: template_fields
:annotation: :Sequence[str] = ['project_id', 'resource_id', 'zone', 'request_id', 'source_template', 'destination_template',...
.. py:method:: execute(self, context)
This is the main method to derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.