blob: 5dcc7df5af2fd19587ac5241c358041944477188 [file] [log] [blame]
:py:mod:`airflow.providers.google.cloud.operators.spanner`
==========================================================
.. py:module:: airflow.providers.google.cloud.operators.spanner
.. autoapi-nested-parse::
This module contains Google Spanner operators.
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.google.cloud.operators.spanner.SpannerDeployInstanceOperator
airflow.providers.google.cloud.operators.spanner.SpannerDeleteInstanceOperator
airflow.providers.google.cloud.operators.spanner.SpannerQueryDatabaseInstanceOperator
airflow.providers.google.cloud.operators.spanner.SpannerDeployDatabaseInstanceOperator
airflow.providers.google.cloud.operators.spanner.SpannerUpdateDatabaseInstanceOperator
airflow.providers.google.cloud.operators.spanner.SpannerDeleteDatabaseInstanceOperator
.. py:class:: SpannerDeployInstanceOperator(*, instance_id, configuration_name, node_count, display_name, project_id = None, gcp_conn_id = 'google_cloud_default', impersonation_chain = None, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
Creates a new Cloud Spanner instance, or if an instance with the same instance_id
exists in the specified project, updates the Cloud Spanner instance.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:SpannerDeployInstanceOperator`
:param instance_id: Cloud Spanner instance ID.
:param configuration_name: The name of the Cloud Spanner instance configuration
defining how the instance will be created. Required for
instances that do not yet exist.
:param node_count: (Optional) The number of nodes allocated to the Cloud Spanner
instance.
:param display_name: (Optional) The display name for the Cloud Spanner instance in
the Google Cloud Console. (Must be between 4 and 30 characters.) If this value is not set
in the constructor, the name is the same as the instance ID.
:param project_id: Optional, the ID of the project which owns the Cloud Spanner
Database. If set to None or missing, the default project_id from the Google Cloud connection is used.
:param gcp_conn_id: The connection ID used to connect to Google Cloud.
: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', 'instance_id', 'configuration_name', 'display_name', 'gcp_conn_id', 'impersonation_chain']
.. py:attribute:: operator_extra_links
.. 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:: SpannerDeleteInstanceOperator(*, instance_id, project_id = None, gcp_conn_id = 'google_cloud_default', impersonation_chain = None, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
Deletes a Cloud Spanner instance. If an instance does not exist,
no action is taken and the operator succeeds.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:SpannerDeleteInstanceOperator`
:param instance_id: The Cloud Spanner instance ID.
:param project_id: Optional, the ID of the project that owns the Cloud Spanner
Database. If set to None or missing, the default project_id from the Google Cloud connection is used.
:param gcp_conn_id: The connection ID used to connect to Google Cloud.
: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', 'instance_id', 'gcp_conn_id', '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:: SpannerQueryDatabaseInstanceOperator(*, instance_id, database_id, query, project_id = None, gcp_conn_id = 'google_cloud_default', impersonation_chain = None, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
Executes an arbitrary DML query (INSERT, UPDATE, DELETE).
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:SpannerQueryDatabaseInstanceOperator`
:param instance_id: The Cloud Spanner instance ID.
:param database_id: The Cloud Spanner database ID.
:param query: The query or list of queries to be executed. Can be a path to a SQL
file.
:param project_id: Optional, the ID of the project that owns the Cloud Spanner
Database. If set to None or missing, the default project_id from the Google Cloud connection is used.
:param gcp_conn_id: The connection ID used to connect to Google Cloud.
: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', 'instance_id', 'database_id', 'query', 'gcp_conn_id', 'impersonation_chain']
.. py:attribute:: template_ext
:annotation: :Sequence[str] = ['.sql']
.. py:attribute:: template_fields_renderers
.. py:attribute:: operator_extra_links
.. 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:method:: sanitize_queries(queries)
:staticmethod:
Drops empty query in queries.
:param queries: queries
:rtype: None
.. py:class:: SpannerDeployDatabaseInstanceOperator(*, instance_id, database_id, ddl_statements, project_id = None, gcp_conn_id = 'google_cloud_default', impersonation_chain = None, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
Creates a new Cloud Spanner database, or if database exists,
the operator does nothing.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:SpannerDeployDatabaseInstanceOperator`
:param instance_id: The Cloud Spanner instance ID.
:param database_id: The Cloud Spanner database ID.
:param ddl_statements: The string list containing DDL for the new database.
:param project_id: Optional, the ID of the project that owns the Cloud Spanner
Database. If set to None or missing, the default project_id from the Google Cloud connection is used.
:param gcp_conn_id: The connection ID used to connect to Google Cloud.
: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', 'instance_id', 'database_id', 'ddl_statements', 'gcp_conn_id', 'impersonation_chain']
.. py:attribute:: template_ext
:annotation: :Sequence[str] = ['.sql']
.. py:attribute:: template_fields_renderers
.. py:attribute:: operator_extra_links
.. 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:: SpannerUpdateDatabaseInstanceOperator(*, instance_id, database_id, ddl_statements, project_id = None, operation_id = None, gcp_conn_id = 'google_cloud_default', impersonation_chain = None, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
Updates a Cloud Spanner database with the specified DDL statement.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:SpannerUpdateDatabaseInstanceOperator`
:param instance_id: The Cloud Spanner instance ID.
:param database_id: The Cloud Spanner database ID.
:param ddl_statements: The string list containing DDL to apply to the database.
:param project_id: Optional, the ID of the project that owns the Cloud Spanner
Database. If set to None or missing, the default project_id from the Google Cloud connection is used.
:param operation_id: (Optional) Unique per database operation id that can
be specified to implement idempotency check.
:param gcp_conn_id: The connection ID used to connect to Google Cloud.
: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', 'instance_id', 'database_id', 'ddl_statements', 'gcp_conn_id', 'impersonation_chain']
.. py:attribute:: template_ext
:annotation: :Sequence[str] = ['.sql']
.. py:attribute:: template_fields_renderers
.. py:attribute:: operator_extra_links
.. 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:: SpannerDeleteDatabaseInstanceOperator(*, instance_id, database_id, project_id = None, gcp_conn_id = 'google_cloud_default', impersonation_chain = None, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
Deletes a Cloud Spanner database.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:SpannerDeleteDatabaseInstanceOperator`
:param instance_id: Cloud Spanner instance ID.
:param database_id: Cloud Spanner database ID.
:param project_id: Optional, the ID of the project that owns the Cloud Spanner
Database. If set to None or missing, the default project_id from the Google Cloud connection is used.
:param gcp_conn_id: The connection ID used to connect to Google Cloud.
: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', 'instance_id', 'database_id', 'gcp_conn_id', '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.