This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new e926275 Finalised Datastore documentation (#20138)
e926275 is described below
commit e9262752dce86225e960b420287a51c532b21107
Author: Dmytro Kazanzhy <[email protected]>
AuthorDate: Sat Dec 11 16:43:40 2021 +0200
Finalised Datastore documentation (#20138)
Co-authored-by: Dmytro Kazanzhy <[email protected]>
---
.../google/cloud/example_dags/example_datastore.py | 19 +++++++++++++++
.../providers/google/cloud/operators/datastore.py | 14 +++++++++++
.../operators/cloud/datastore.rst | 27 ++++++++++++++++++++++
tests/always/test_project_structure.py | 2 --
4 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/airflow/providers/google/cloud/example_dags/example_datastore.py
b/airflow/providers/google/cloud/example_dags/example_datastore.py
index 96497d2..d55d7d3 100644
--- a/airflow/providers/google/cloud/example_dags/example_datastore.py
+++ b/airflow/providers/google/cloud/example_dags/example_datastore.py
@@ -31,7 +31,9 @@ from airflow.providers.google.cloud.operators.datastore
import (
CloudDatastoreAllocateIdsOperator,
CloudDatastoreBeginTransactionOperator,
CloudDatastoreCommitOperator,
+ CloudDatastoreDeleteOperationOperator,
CloudDatastoreExportEntitiesOperator,
+ CloudDatastoreGetOperationOperator,
CloudDatastoreImportEntitiesOperator,
CloudDatastoreRollbackOperator,
CloudDatastoreRunQueryOperator,
@@ -164,3 +166,20 @@ with models.DAG(
# begin_transaction_commit >> commit_task
# begin_transaction_to_rollback >> rollback_transaction
# begin_transaction_query >> run_query
+
+ OPERATION_NAME = 'operations/example-operation-unique-id'
+ # [START get_operation_state]
+ get_operation = CloudDatastoreGetOperationOperator(
+ task_id='get_operation',
+ name=OPERATION_NAME,
+ gcp_conn_id='google_cloud_default',
+ )
+ # [END get_operation_state]
+
+ # [START delete_operation]
+ delete_operation = CloudDatastoreDeleteOperationOperator(
+ task_id='delete_operation',
+ name=OPERATION_NAME,
+ gcp_conn_id='google_cloud_default',
+ )
+ # [END delete_operation]
diff --git a/airflow/providers/google/cloud/operators/datastore.py
b/airflow/providers/google/cloud/operators/datastore.py
index 029696f..c52f92a 100644
--- a/airflow/providers/google/cloud/operators/datastore.py
+++ b/airflow/providers/google/cloud/operators/datastore.py
@@ -33,6 +33,9 @@ class CloudDatastoreExportEntitiesOperator(BaseOperator):
For more information on how to use this operator, take a look at the
guide:
:ref:`howto/operator:CloudDatastoreExportEntitiesOperator`
+ .. seealso::
+ https://cloud.google.com/datastore/docs/export-import-entities
+
:param bucket: name of the cloud storage bucket to backup data
:type bucket: str
:param namespace: optional namespace path in the specified Cloud Storage
bucket
@@ -147,6 +150,9 @@ class CloudDatastoreImportEntitiesOperator(BaseOperator):
For more information on how to use this operator, take a look at the
guide:
:ref:`howto/operator:CloudDatastoreImportEntitiesOperator`
+ .. seealso::
+ https://cloud.google.com/datastore/docs/export-import-entities
+
:param bucket: container in Cloud Storage to store data
:type bucket: str
:param file: path of the backup metadata file in the specified Cloud
Storage bucket.
@@ -583,6 +589,10 @@ class CloudDatastoreGetOperationOperator(BaseOperator):
Gets the latest state of a long-running operation.
.. seealso::
+ For more information on how to use this operator, take a look at the
guide:
+ :ref:`howto/operator:CloudDatastoreGetOperationOperator`
+
+ .. seealso::
https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects.operations/get
:param name: the name of the operation resource.
@@ -639,6 +649,10 @@ class CloudDatastoreDeleteOperationOperator(BaseOperator):
Deletes the long-running operation.
.. seealso::
+ For more information on how to use this operator, take a look at the
guide:
+ :ref:`howto/operator:CloudDatastoreDeleteOperationOperator`
+
+ .. seealso::
https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects.operations/delete
:param name: the name of the operation resource.
diff --git a/docs/apache-airflow-providers-google/operators/cloud/datastore.rst
b/docs/apache-airflow-providers-google/operators/cloud/datastore.rst
index cb373a4..7068d1c 100644
--- a/docs/apache-airflow-providers-google/operators/cloud/datastore.rst
+++ b/docs/apache-airflow-providers-google/operators/cloud/datastore.rst
@@ -160,6 +160,33 @@ use
:class:`~airflow.providers.google.cloud.operators.datastore.CloudDatastoreRo
:start-after: [START how_to_rollback_transaction]
:end-before: [END how_to_rollback_transaction]
+.. _howto/operator:CloudDatastoreGetOperationOperator:
+
+Get operation state
+-------------------
+
+To get the current state of a long-running operation use
+:class:`~airflow.providers.google.cloud.operators.datastore.CloudDatastoreGetOperationOperator`
+
+.. exampleinclude::
/../../airflow/providers/google/cloud/example_dags/example_datastore.py
+ :language: python
+ :dedent: 4
+ :start-after: [START get_operation_state]
+ :end-before: [END get_operation_state]
+
+.. _howto/operator:CloudDatastoreDeleteOperationOperator:
+
+Delete operation
+----------------
+
+To delete an operation use
+:class:`~airflow.providers.google.cloud.operators.datastore.CloudDatastoreDeleteOperationOperator`
+
+.. exampleinclude::
/../../airflow/providers/google/cloud/example_dags/example_datastore.py
+ :language: python
+ :dedent: 4
+ :start-after: [START delete_operation]
+ :end-before: [END delete_operation]
References
^^^^^^^^^^
diff --git a/tests/always/test_project_structure.py
b/tests/always/test_project_structure.py
index ea55257..3200f39 100644
--- a/tests/always/test_project_structure.py
+++ b/tests/always/test_project_structure.py
@@ -214,8 +214,6 @@ class TestGoogleProviderProjectStructure(unittest.TestCase):
'airflow.providers.google.cloud.operators.dlp.CloudDLPDeleteDeidentifyTemplateOperator',
'airflow.providers.google.cloud.operators.dlp.CloudDLPListDLPJobsOperator',
'airflow.providers.google.cloud.operators.dlp.CloudDLPRedactImageOperator',
-
'airflow.providers.google.cloud.operators.datastore.CloudDatastoreDeleteOperationOperator',
-
'airflow.providers.google.cloud.operators.datastore.CloudDatastoreGetOperationOperator',
'airflow.providers.google.cloud.sensors.gcs.GCSObjectUpdateSensor',
'airflow.providers.google.cloud.sensors.gcs.GCSUploadSessionCompleteSensor',
}