Package: azure-purview-administration
Azure Purview Administration client library for PythonAzure Purview is a fully managed cloud service.Please rely heavily on theservice's documentationto use this librarySource code|Package (PyPI)|API reference documentation|Product documentationDisclaimerAzure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, please refer tohttps://github.com/Azure/azure-sdk-for-python/issues/20691Getting startedPrerequisitesPython 2.7, or 3.6 or later is required to use this package.You must have anAzure subscriptionand aPurviewto use this package.Create a Purview ResourceFollowtheseinstructions to create your Purview resourceInstall the packageInstall the Azure Purview Account client library for Python withpip:pipinstallazure-purview-administrationAuthenticate the clientTo use anAzure Active Directory (AAD) token credential,
provide an instance of the desired credential type obtained from theazure-identitylibrary.To authenticate with AAD, you must firstpipinstallazure-identityandenable AAD authentication on your Purview resourceAfter setup, you can choose which type ofcredentialfrom azure.identity to use.
As an example,DefaultAzureCredentialcan be used to authenticate the client: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_SECRETUse the returned token credential to authenticate the client:fromazure.purview.administration.accountimportPurviewAccountClientfromazure.purview.administration.metadatapoliciesimportPurviewMetadataPoliciesClientfromazure.identityimportDefaultAzureCredentialcredential=DefaultAzureCredential()endpoint="https://<my-account-name>.purview.azure.com"account_client=PurviewAccountClient(endpoint=endpoint,credential=credential)metadatapolicy_client=PurviewMetadataPoliciesClient(endpoint=endpoint,credential=credential)Key conceptsClientThe package contains two kinds of client:PurviewAccountClientandPurviewMetadataPoliciesClient. You could use them
with one package according to your requirements.ExamplesThe following section shows you how to initialize and authenticate your client, then list all of your keys.Get KeysGet Keysfromazure.purview.administration.accountimportPurviewAccountClientfromazure.identityimportDefaultAzureCredentialcredential=DefaultAzureCredential()client=PurviewAccountClient(endpoint="https://<my-account-name>.purview.azure.com",credential=credential)response=client.accounts.get_access_keys()print(response)The following section shows you how to initialize and authenticate your client, then list all of your roles.List_RolesList Rolesfromazure.purview.administration.metadatapoliciesimportPurviewMetadataPoliciesClientfromazure.identityimportDefaultAzureCredentialcredential=DefaultAzureCredential()client=PurviewMetadataPoliciesClient(endpoint="https://<my-account-name>.purview.azure.com",credential=credential)response=client.metadata_roles.list()result=[itemforiteminresponse]print(result)TroubleshootingGeneralThe Purview client will raise exceptions if status code of your responses is not defined.LoggingThis library uses the standardlogginglibrary 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 thelogging_enablekeyword argument:importsysimportloggingfromazure.identityimportDefaultAzureCredentialfromazure.purview.administration.accountimportPurviewAccountClient# Create a logger for the 'azure' SDKlogger=logging.getLogger('azure')logger.setLevel(logging.DEBUG)# Configure a console outputhandler=logging.StreamHandler(stream=sys.stdout)logger.addHandler(handler)endpoint="https://<my-account-name>.purview.azure.com"credential=DefaultAzureCredential()# This client will log detailed information about its HTTP sessions, at DEBUG levelclient=PurviewAccountClient(endpoint=endpoint,credential=credential,logging_enable=True)Similarly,logging_enablecan enable detailed logging for a single call,
even when it isn't enabled for the client:result=client.accounts.get_access_keys(logging_enable=True)Next stepsFor more generic samples, see ourclient docs.ContributingThis 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, visitcla.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.This project has adopted theMicrosoft Open Source Code of Conduct. For more information see theCode of Conduct FAQor contactopencode@microsoft.comwith any additional questions or comments.Release History1.0.0b1 (2021-09-29)This is the initial release of the Azure Purview Administration library.This package includes the operations ofazure-purview-accountthat was previously released