blob: 4d38840cc0bea764bf1d63db73173a671f273f8b [file] [log] [blame]
:py:mod:`airflow.providers.google.cloud.hooks.datastore`
========================================================
.. py:module:: airflow.providers.google.cloud.hooks.datastore
.. autoapi-nested-parse::
This module contains Google Datastore hook.
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.google.cloud.hooks.datastore.DatastoreHook
.. py:class:: DatastoreHook(gcp_conn_id = 'google_cloud_default', delegate_to = None, api_version = 'v1', impersonation_chain = None)
Bases: :py:obj:`airflow.providers.google.common.hooks.base_google.GoogleBaseHook`
Interact with Google Cloud Datastore. This hook uses the Google Cloud connection.
This object is not threads safe. If you want to make multiple requests
simultaneously, you will need to create a hook per thread.
:param api_version: The version of the API it is going to connect to.
.. py:method:: get_conn(self)
Establishes a connection to the Google API.
:return: a Google Cloud Datastore service object.
:rtype: Resource
.. py:method:: allocate_ids(self, partial_keys, project_id)
Allocate IDs for incomplete keys.
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/allocateIds
:param partial_keys: a list of partial keys.
:param project_id: Google Cloud project ID against which to make the request.
:return: a list of full keys.
:rtype: list
.. py:method:: begin_transaction(self, project_id, transaction_options)
Begins a new transaction.
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/beginTransaction
:param project_id: Google Cloud project ID against which to make the request.
:param transaction_options: Options for a new transaction.
:return: a transaction handle.
:rtype: str
.. py:method:: commit(self, body, project_id)
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.
:param project_id: Google Cloud project ID against which to make the request.
:return: the response body of the commit request.
:rtype: dict
.. py:method:: lookup(self, keys, project_id, 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.
:param project_id: Google Cloud project ID against which to make the request.
:return: the response body of the lookup request.
:rtype: dict
.. py:method:: rollback(self, transaction, project_id)
Roll back a transaction.
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/rollback
:param transaction: the transaction to roll back.
:param project_id: Google Cloud project ID against which to make the request.
.. py:method:: run_query(self, body, project_id)
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.
:param project_id: Google Cloud project ID against which to make the request.
:return: the batch of query results.
:rtype: dict
.. py:method:: get_operation(self, name)
Gets the latest state of a long-running operation.
.. seealso::
https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects.operations/get
:param name: the name of the operation resource.
:return: a resource operation instance.
:rtype: dict
.. py:method:: delete_operation(self, name)
Deletes the long-running operation.
.. seealso::
https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects.operations/delete
:param name: the name of the operation resource.
:return: none if successful.
:rtype: dict
.. py:method:: poll_operation_until_done(self, name, polling_interval_in_seconds)
Poll backup operation state until it's completed.
:param name: the name of the operation resource
:param polling_interval_in_seconds: The number of seconds to wait before calling another request.
:return: a resource operation instance.
:rtype: dict
.. py:method:: export_to_storage_bucket(self, bucket, project_id, namespace = None, entity_filter = None, labels = None)
Export entities from Cloud Datastore to Cloud Storage for backup.
.. note::
Keep in mind that this requests the Admin API not the Data API.
.. seealso::
https://cloud.google.com/datastore/docs/reference/admin/rest/v1/projects/export
:param bucket: The name of the Cloud Storage bucket.
:param namespace: The Cloud Storage namespace path.
:param entity_filter: Description of what data from the project is included in the export.
:param labels: Client-assigned labels.
:param project_id: Google Cloud project ID against which to make the request.
:return: a resource operation instance.
:rtype: dict
.. py:method:: import_from_storage_bucket(self, bucket, file, project_id, namespace = None, entity_filter = None, labels = None)
Import a backup from Cloud Storage to Cloud Datastore.
.. note::
Keep in mind that this requests the Admin API not the Data API.
.. seealso::
https://cloud.google.com/datastore/docs/reference/admin/rest/v1/projects/import
:param bucket: The name of the Cloud Storage bucket.
:param file: the metadata file written by the projects.export operation.
:param namespace: The Cloud Storage namespace path.
:param entity_filter: specify which kinds/namespaces are to be imported.
:param labels: Client-assigned labels.
:param project_id: Google Cloud project ID against which to make the request.
:return: a resource operation instance.
:rtype: dict