blob: 46e6ec7aa7e480de54467262fad562ba48c51ea4 [file] [log] [blame]
:mod:`airflow.contrib.hooks.datastore_hook`
===========================================
.. py:module:: airflow.contrib.hooks.datastore_hook
Module Contents
---------------
.. py:class:: DatastoreHook(datastore_conn_id='google_cloud_datastore_default', delegate_to=None)
Bases::class:`airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook`
Interact with Google Cloud Datastore. This hook uses the Google Cloud Platform
connection.
This object is not threads safe. If you want to make multiple requests
simultaneously, you will need to create a hook per thread.
.. method:: get_conn(self, version='v1')
Returns a Google Cloud Datastore service object.
.. method:: allocate_ids(self, partialKeys)
Allocate IDs for incomplete keys.
see https://cloud.google.com/datastore/docs/reference/rest/v1/projects/allocateIds
:param partialKeys: a list of partial keys
:return: a list of full keys.
.. method:: begin_transaction(self)
Get a new transaction handle
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/beginTransaction
:return: a transaction handle
.. method:: commit(self, body)
Commit a transaction, optionally creating, deleting or modifying some entities.
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/commit
:param body: the body of the commit request
:return: the response body of the commit request
.. method:: lookup(self, keys, read_consistency=None, transaction=None)
Lookup some entities by key
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/lookup
:param keys: the keys to lookup
:param read_consistency: the read consistency to use. default, strong or eventual.
Cannot be used with a transaction.
:param transaction: the transaction to use, if any.
:return: the response body of the lookup request.
.. method:: rollback(self, transaction)
Roll back a transaction
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/rollback
:param transaction: the transaction to roll back
.. method:: run_query(self, body)
Run a query for entities.
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/runQuery
:param body: the body of the query request
:return: the batch of query results.
.. method:: get_operation(self, name)
Gets the latest state of a long-running operation
:param name: the name of the operation resource
.. method:: delete_operation(self, name)
Deletes the long-running operation
:param name: the name of the operation resource
.. method:: poll_operation_until_done(self, name, polling_interval_in_seconds)
Poll backup operation state until it's completed
.. method:: export_to_storage_bucket(self, bucket, namespace=None, entity_filter=None, labels=None)
Export entities from Cloud Datastore to Cloud Storage for backup
.. method:: import_from_storage_bucket(self, bucket, file, namespace=None, entity_filter=None, labels=None)
Import a backup from Cloud Storage to Cloud Datastore