Azure Purview Catalog client library for Python¶
Azure Purview Catalog is a fully managed cloud service whose users can discover the data sources they need and understand the data sources they find. At the same time, Data Catalog helps organizations get more value from their existing investments.
Search for data using technical or business terms
Browse associated technical, business, semantic, and operational metadata
Identify the sensitivity level of data.
Please rely heavily on the `service’s documentation <https://azure.microsoft.com/services/purview/>`_ and our `client docs <https://aka.ms/azsdk/python/protocol/quickstart>`_ to use this library
Python 2.7, or 3.6 or later is required to use this package.
Create a Purview Resource¶
Follow these instructions to create your Purview resource
Install the package¶
Install the Azure Purview Catalog client library for Python with pip:
pip install azure-purview-catalog
Authenticate the client¶
To authenticate with AAD, you must first pip install ``azure-identity` <https://pypi.org/project/azure-identity/>`_ and enable AAD authentication on your Purview resource
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
Use the returned token credential to authenticate the client:
from azure.purview.catalog import PurviewCatalogClient from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential() client = PurviewCatalogClient(endpoint="https://<my-account-name>.catalog.purview.azure.com", credential=credential)
This package offers request builders so you can build http requests and send these requests to the service using the
For more information on how to use request builders and our clients, see here.
The following section shows you how to initialize and authenticate your client, then get all of your type-defs.
Get All Type Definitions¶
from azure.purview.catalog import PurviewCatalogClient from azure.identity import DefaultAzureCredential from azure.purview.catalog.rest import types from azure.core.exceptions import HttpResponseError credential = DefaultAzureCredential() client = PurviewCatalogClient(endpoint="https://<my-account-name>.catalog.purview.azure.com", credential=credential) request = types.build_get_all_type_definitions_request() response = client.send_request(request) try: response.raise_for_status() json_response = response.json() # print out all of your entity definitions print(json_response['entityDefs']) except HttpResponseError as e: print(e)
The Purview Catalog client will raise exceptions defined in [Azure Core][azure_core] if you call
.raise_for_status() on your responses.
This library uses the standard logging library for logging. Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO level.
Detailed DEBUG level logging, including request/response bodies and unredacted
headers, can be enabled on a client with the
logging_enable keyword argument:
import sys import logging from azure.identity import DefaultAzureCredential from azure.purview.catalog import PurviewCatalogClient # Create a logger for the 'azure' SDK logger = logging.getLogger('azure') logger.setLevel(logging.DEBUG) # Configure a console output handler = logging.StreamHandler(stream=sys.stdout) logger.addHandler(handler) endpoint = "https://<my-account-name>.catalog.purview.azure.com" credential = DefaultAzureCredential() # This client will log detailed information about its HTTP sessions, at DEBUG level client = PurviewCatalogClient(endpoint=endpoint, credential=credential, logging_enable=True)
logging_enable can enable detailed logging for a single
even when it isn’t enabled for the client:
result = client.send_request(request, logging_enable=True)
For more generic samples, see our client docs.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
Indices and tables¶
- azure.purview.catalog package
- azure.purview.catalog.aio package
- azure.purview.catalog.core package
- azure.purview.catalog.rest package