Skip to content

Commit

Permalink
Finalised Datastore documentation (#20138)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmytro Kazanzhy <[email protected]>
  • Loading branch information
kazanzhy and Dmytro Kazanzhy committed Dec 11, 2021
1 parent b157953 commit e926275
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
19 changes: 19 additions & 0 deletions airflow/providers/google/cloud/example_dags/example_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
CloudDatastoreAllocateIdsOperator,
CloudDatastoreBeginTransactionOperator,
CloudDatastoreCommitOperator,
CloudDatastoreDeleteOperationOperator,
CloudDatastoreExportEntitiesOperator,
CloudDatastoreGetOperationOperator,
CloudDatastoreImportEntitiesOperator,
CloudDatastoreRollbackOperator,
CloudDatastoreRunQueryOperator,
Expand Down Expand Up @@ -164,3 +166,20 @@
# 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]
14 changes: 14 additions & 0 deletions airflow/providers/google/cloud/operators/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -582,6 +588,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
Expand Down Expand Up @@ -638,6 +648,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
Expand Down
27 changes: 27 additions & 0 deletions docs/apache-airflow-providers-google/operators/cloud/datastore.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^
Expand Down
2 changes: 0 additions & 2 deletions tests/always/test_project_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand Down

0 comments on commit e926275

Please sign in to comment.