airflow.contrib.operators.gcp_spanner_operator

Module Contents

class airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDeployOperator(instance_id, configuration_name, node_count, display_name, project_id=None, gcp_conn_id='google_cloud_default', *args, **kwargs)[source]

Bases: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.

Parameters
  • instance_id (str) – Cloud Spanner instance ID.

  • configuration_name (str) – The name of the Cloud Spanner instance configuration defining how the instance will be created. Required for instances that do not yet exist.

  • node_count (int) – (Optional) The number of nodes allocated to the Cloud Spanner instance.

  • display_name (str) – (Optional) The display name for the Cloud Spanner instance in the GCP 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.

  • project_id (str) – Optional, the ID of the project which owns the Cloud Spanner Database. If set to None or missing, the default project_id from the GCP connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud Platform.

template_fields = ['project_id', 'instance_id', 'configuration_name', 'display_name', 'gcp_conn_id'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDeleteOperator(instance_id, project_id=None, gcp_conn_id='google_cloud_default', *args, **kwargs)[source]

Bases:airflow.models.BaseOperator

Deletes a Cloud Spanner instance. If an instance does not exist, no action is taken and the operator succeeds.

See also

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

Parameters
  • instance_id (str) – The Cloud Spanner instance ID.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the GCP connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud Platform.

template_fields = ['project_id', 'instance_id', 'gcp_conn_id'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseQueryOperator(instance_id, database_id, query, project_id=None, gcp_conn_id='google_cloud_default', *args, **kwargs)[source]

Bases:airflow.models.BaseOperator

Executes an arbitrary DML query (INSERT, UPDATE, DELETE).

See also

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

Parameters
  • instance_id (str) – The Cloud Spanner instance ID.

  • database_id (str) – The Cloud Spanner database ID.

  • query (str or list) – The query or list of queries to be executed. Can be a path to a SQL file.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the GCP connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud Platform.

template_fields = ['project_id', 'instance_id', 'database_id', 'query', 'gcp_conn_id'][source]
template_ext = ['.sql'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
static sanitize_queries(queries)[source]
class airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseDeployOperator(instance_id, database_id, ddl_statements, project_id=None, gcp_conn_id='google_cloud_default', *args, **kwargs)[source]

Bases:airflow.models.BaseOperator

Creates a new Cloud Spanner database, or if database exists, the operator does nothing.

See also

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

Parameters
  • instance_id (str) – The Cloud Spanner instance ID.

  • database_id (str) – The Cloud Spanner database ID.

  • ddl_statements (list[str]) – The string list containing DDL for the new database.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the GCP connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud Platform.

template_fields = ['project_id', 'instance_id', 'database_id', 'ddl_statements', 'gcp_conn_id'][source]
template_ext = ['.sql'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseUpdateOperator(instance_id, database_id, ddl_statements, project_id=None, operation_id=None, gcp_conn_id='google_cloud_default', *args, **kwargs)[source]

Bases:airflow.models.BaseOperator

Updates a Cloud Spanner database with the specified DDL statement.

See also

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

Parameters
  • instance_id (str) – The Cloud Spanner instance ID.

  • database_id (str) – The Cloud Spanner database ID.

  • ddl_statements (list[str]) – The string list containing DDL to apply to the database.

  • project_id (str) – Optional, the ID of the project that owns the the Cloud Spanner Database. If set to None or missing, the default project_id from the GCP connection is used.

  • operation_id (str) – (Optional) Unique per database operation id that can be specified to implement idempotency check.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud Platform.

template_fields = ['project_id', 'instance_id', 'database_id', 'ddl_statements', 'gcp_conn_id'][source]
template_ext = ['.sql'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseDeleteOperator(instance_id, database_id, project_id=None, gcp_conn_id='google_cloud_default', *args, **kwargs)[source]

Bases:airflow.models.BaseOperator

Deletes a Cloud Spanner database.

See also

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

Parameters
  • instance_id (str) – Cloud Spanner instance ID.

  • database_id (str) – Cloud Spanner database ID.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the GCP connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud Platform.

template_fields = ['project_id', 'instance_id', 'database_id', 'gcp_conn_id'][source]
_validate_inputs(self)[source]
execute(self, context)[source]