blob: 65796f1ad17922accc1e8ef7efb6a9d5f47f1d44 [file] [log] [blame]
:py:mod:`airflow.providers.microsoft.azure.hooks.cosmos`
========================================================
.. py:module:: airflow.providers.microsoft.azure.hooks.cosmos
.. autoapi-nested-parse::
This module contains integration with Azure CosmosDB.
AzureCosmosDBHook communicates via the Azure Cosmos library. Make sure that a
Airflow connection of type `azure_cosmos` exists. Authorization can be done by supplying a
login (=Endpoint uri), password (=secret key) and extra fields database_name and collection_name to specify
the default database and collection to use (see connection `azure_cosmos_default` for an example).
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.microsoft.azure.hooks.cosmos.AzureCosmosDBHook
Functions
~~~~~~~~~
.. autoapisummary::
airflow.providers.microsoft.azure.hooks.cosmos.get_database_link
airflow.providers.microsoft.azure.hooks.cosmos.get_collection_link
airflow.providers.microsoft.azure.hooks.cosmos.get_document_link
.. py:class:: AzureCosmosDBHook(azure_cosmos_conn_id = default_conn_name)
Bases: :py:obj:`airflow.hooks.base.BaseHook`
Interacts with Azure CosmosDB.
login should be the endpoint uri, password should be the master key
optionally, you can use the following extras to default these values
{"database_name": "<DATABASE_NAME>", "collection_name": "COLLECTION_NAME"}.
:param azure_cosmos_conn_id: Reference to the
:ref:`Azure CosmosDB connection<howto/connection:azure_cosmos>`.
.. py:attribute:: conn_name_attr
:annotation: = azure_cosmos_conn_id
.. py:attribute:: default_conn_name
:annotation: = azure_cosmos_default
.. py:attribute:: conn_type
:annotation: = azure_cosmos
.. py:attribute:: hook_name
:annotation: = Azure CosmosDB
.. py:method:: get_connection_form_widgets()
:staticmethod:
Returns connection widgets to add to connection form
.. py:method:: get_ui_field_behaviour()
:staticmethod:
Returns custom field behaviour
.. py:method:: get_conn(self)
Return a cosmos db client.
.. py:method:: does_collection_exist(self, collection_name, database_name)
Checks if a collection exists in CosmosDB.
.. py:method:: create_collection(self, collection_name, database_name = None)
Creates a new collection in the CosmosDB database.
.. py:method:: does_database_exist(self, database_name)
Checks if a database exists in CosmosDB.
.. py:method:: create_database(self, database_name)
Creates a new database in CosmosDB.
.. py:method:: delete_database(self, database_name)
Deletes an existing database in CosmosDB.
.. py:method:: delete_collection(self, collection_name, database_name = None)
Deletes an existing collection in the CosmosDB database.
.. py:method:: upsert_document(self, document, database_name=None, collection_name=None, document_id=None)
Inserts a new document (or updates an existing one) into an existing
collection in the CosmosDB database.
.. py:method:: insert_documents(self, documents, database_name = None, collection_name = None)
Insert a list of new documents into an existing collection in the CosmosDB database.
.. py:method:: delete_document(self, document_id, database_name = None, collection_name = None)
Delete an existing document out of a collection in the CosmosDB database.
.. py:method:: get_document(self, document_id, database_name = None, collection_name = None)
Get a document from an existing collection in the CosmosDB database.
.. py:method:: get_documents(self, sql_string, database_name = None, collection_name = None, partition_key = None)
Get a list of documents from an existing collection in the CosmosDB database via SQL query.
.. py:function:: get_database_link(database_id)
Get Azure CosmosDB database link
.. py:function:: get_collection_link(database_id, collection_id)
Get Azure CosmosDB collection link
.. py:function:: get_document_link(database_id, collection_id, document_id)
Get Azure CosmosDB document link