Skip to content

Commit e926275

Browse files
kazanzhyDmytro Kazanzhy
andauthored
Finalised Datastore documentation (#20138)
Co-authored-by: Dmytro Kazanzhy <[email protected]>
1 parent b157953 commit e926275

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed

airflow/providers/google/cloud/example_dags/example_datastore.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
CloudDatastoreAllocateIdsOperator,
3232
CloudDatastoreBeginTransactionOperator,
3333
CloudDatastoreCommitOperator,
34+
CloudDatastoreDeleteOperationOperator,
3435
CloudDatastoreExportEntitiesOperator,
36+
CloudDatastoreGetOperationOperator,
3537
CloudDatastoreImportEntitiesOperator,
3638
CloudDatastoreRollbackOperator,
3739
CloudDatastoreRunQueryOperator,
@@ -164,3 +166,20 @@
164166
# begin_transaction_commit >> commit_task
165167
# begin_transaction_to_rollback >> rollback_transaction
166168
# begin_transaction_query >> run_query
169+
170+
OPERATION_NAME = 'operations/example-operation-unique-id'
171+
# [START get_operation_state]
172+
get_operation = CloudDatastoreGetOperationOperator(
173+
task_id='get_operation',
174+
name=OPERATION_NAME,
175+
gcp_conn_id='google_cloud_default',
176+
)
177+
# [END get_operation_state]
178+
179+
# [START delete_operation]
180+
delete_operation = CloudDatastoreDeleteOperationOperator(
181+
task_id='delete_operation',
182+
name=OPERATION_NAME,
183+
gcp_conn_id='google_cloud_default',
184+
)
185+
# [END delete_operation]

airflow/providers/google/cloud/operators/datastore.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class CloudDatastoreExportEntitiesOperator(BaseOperator):
3333
For more information on how to use this operator, take a look at the guide:
3434
:ref:`howto/operator:CloudDatastoreExportEntitiesOperator`
3535
36+
.. seealso::
37+
https://cloud.google.com/datastore/docs/export-import-entities
38+
3639
:param bucket: name of the cloud storage bucket to backup data
3740
:type bucket: str
3841
:param namespace: optional namespace path in the specified Cloud Storage bucket
@@ -147,6 +150,9 @@ class CloudDatastoreImportEntitiesOperator(BaseOperator):
147150
For more information on how to use this operator, take a look at the guide:
148151
:ref:`howto/operator:CloudDatastoreImportEntitiesOperator`
149152
153+
.. seealso::
154+
https://cloud.google.com/datastore/docs/export-import-entities
155+
150156
:param bucket: container in Cloud Storage to store data
151157
:type bucket: str
152158
:param file: path of the backup metadata file in the specified Cloud Storage bucket.
@@ -582,6 +588,10 @@ class CloudDatastoreGetOperationOperator(BaseOperator):
582588
"""
583589
Gets the latest state of a long-running operation.
584590
591+
.. seealso::
592+
For more information on how to use this operator, take a look at the guide:
593+
:ref:`howto/operator:CloudDatastoreGetOperationOperator`
594+
585595
.. seealso::
586596
https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects.operations/get
587597
@@ -638,6 +648,10 @@ class CloudDatastoreDeleteOperationOperator(BaseOperator):
638648
"""
639649
Deletes the long-running operation.
640650
651+
.. seealso::
652+
For more information on how to use this operator, take a look at the guide:
653+
:ref:`howto/operator:CloudDatastoreDeleteOperationOperator`
654+
641655
.. seealso::
642656
https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects.operations/delete
643657

docs/apache-airflow-providers-google/operators/cloud/datastore.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,33 @@ use :class:`~airflow.providers.google.cloud.operators.datastore.CloudDatastoreRo
160160
:start-after: [START how_to_rollback_transaction]
161161
:end-before: [END how_to_rollback_transaction]
162162

163+
.. _howto/operator:CloudDatastoreGetOperationOperator:
164+
165+
Get operation state
166+
-------------------
167+
168+
To get the current state of a long-running operation use
169+
:class:`~airflow.providers.google.cloud.operators.datastore.CloudDatastoreGetOperationOperator`
170+
171+
.. exampleinclude:: /../../airflow/providers/google/cloud/example_dags/example_datastore.py
172+
:language: python
173+
:dedent: 4
174+
:start-after: [START get_operation_state]
175+
:end-before: [END get_operation_state]
176+
177+
.. _howto/operator:CloudDatastoreDeleteOperationOperator:
178+
179+
Delete operation
180+
----------------
181+
182+
To delete an operation use
183+
:class:`~airflow.providers.google.cloud.operators.datastore.CloudDatastoreDeleteOperationOperator`
184+
185+
.. exampleinclude:: /../../airflow/providers/google/cloud/example_dags/example_datastore.py
186+
:language: python
187+
:dedent: 4
188+
:start-after: [START delete_operation]
189+
:end-before: [END delete_operation]
163190

164191
References
165192
^^^^^^^^^^

tests/always/test_project_structure.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ class TestGoogleProviderProjectStructure(unittest.TestCase):
214214
'airflow.providers.google.cloud.operators.dlp.CloudDLPDeleteDeidentifyTemplateOperator',
215215
'airflow.providers.google.cloud.operators.dlp.CloudDLPListDLPJobsOperator',
216216
'airflow.providers.google.cloud.operators.dlp.CloudDLPRedactImageOperator',
217-
'airflow.providers.google.cloud.operators.datastore.CloudDatastoreDeleteOperationOperator',
218-
'airflow.providers.google.cloud.operators.datastore.CloudDatastoreGetOperationOperator',
219217
'airflow.providers.google.cloud.sensors.gcs.GCSObjectUpdateSensor',
220218
'airflow.providers.google.cloud.sensors.gcs.GCSUploadSessionCompleteSensor',
221219
}

0 commit comments

Comments
 (0)