Microsoft Azure Purview Administration Client Library for Python
项目描述
Azure Purview Administration客户端库
Azure Purview是一个完全托管的云服务。
请务必参考服务的文档以使用此库
免责声明
Azure SDK Python包对Python 2.7的支持将于2022年1月1日结束。有关更多信息,请参阅https://github.com/Azure/azure-sdk-for-python/issues/20691
入门
先决条件
创建Purview资源
按照这些说明创建您的 Purview 资源
安装包
使用 pip 安装 Python 的 Azure Purview 账户客户端库
pip install azure-purview-administration
验证客户端
要使用 Azure Active Directory (AAD) 令牌凭证,提供从 azure-identity 库获取的期望凭证类型的实例。
要使用 AAD 验证,您必须首先 pip 安装 azure-identity
并在您的 Purview 资源上 启用 AAD 验证
设置完成后,您可以选择从 azure.identity 使用哪种类型的 凭证。例如,可以使用 DefaultAzureCredential 来验证客户端
将 AAD 应用程序的客户端 ID、租户 ID 和客户端密钥的值设置为环境变量:AZURE_CLIENT_ID、AZURE_TENANT_ID、AZURE_CLIENT_SECRET
使用返回的令牌凭证来验证客户端
from azure.purview.administration.account import PurviewAccountClient
from azure.purview.administration.metadatapolicies import PurviewMetadataPoliciesClient
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()
endpoint = "https://<my-account-name>.purview.azure.com"
account_client = PurviewAccountClient(endpoint=endpoint, credential=credential)
metadatapolicy_client = PurviewMetadataPoliciesClient(endpoint=endpoint, credential=credential)
关键概念
客户端
该包包含两种客户端:PurviewAccountClient
和 PurviewMetadataPoliciesClient
。您可以根据需要使用一个包使用它们。
示例
以下部分将向您展示如何初始化和验证您的客户端,然后列出所有密钥。
获取密钥
from azure.purview.administration.account import PurviewAccountClient
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()
client = PurviewAccountClient(endpoint="https://<my-account-name>.purview.azure.com", credential=credential)
response = client.accounts.get_access_keys()
print(response)
以下部分将向您展示如何初始化和验证您的客户端,然后列出所有角色。
列出角色
from azure.purview.administration.metadatapolicies import PurviewMetadataPoliciesClient
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()
client = PurviewMetadataPoliciesClient(endpoint="https://<my-account-name>.purview.azure.com", credential=credential)
response = client.metadata_roles.list()
result = [item for item in response]
print(result)
故障排除
一般
如果您的响应状态代码未定义,Purview 客户端将引发异常。
日志记录
此库使用标准的 logging 库进行日志记录。HTTP 会话(URL、标头等)的基本信息以 INFO 级别记录。
可以通过客户端的 logging_enable
关键字参数启用详细的 DEBUG 级别日志记录,包括请求/响应正文和未删除的标头。
import sys
import logging
from azure.identity import DefaultAzureCredential
from azure.purview.administration.account import PurviewAccountClient
# 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>.purview.azure.com"
credential = DefaultAzureCredential()
# This client will log detailed information about its HTTP sessions, at DEBUG level
client = PurviewAccountClient(endpoint=endpoint, credential=credential, logging_enable=True)
同样,logging_enable
可以即使在客户端未启用的情况下,也可以为单个调用启用详细日志记录。
result = client.accounts.get_access_keys(logging_enable=True)
下一步
有关更多通用示例,请参阅我们的 客户端文档。
贡献
此项目欢迎贡献和建议。大多数贡献都需要您同意一个贡献者许可协议(CLA),声明您有权,并且实际上确实授予我们使用您的贡献的权利。有关详细信息,请访问 cla.microsoft.com。
当您提交拉取请求时,CLA-bot 将自动确定您是否需要提供 CLA,并以适当的方式装饰 PR(例如,标签,注释)。只需遵循机器人提供的说明即可。您只需在所有使用我们的 CLA 的存储库中这样做一次。
此项目采用了 Microsoft 开源行为准则。有关更多信息,请参阅 行为准则常见问题解答 或联系 opencode@microsoft.com 以获取任何额外的问题或评论。
发行历史
1.0.0b1 (2021-09-29)
- 这是 Azure Purview 管理库的初始版本。
- 此包包括之前发布的
azure-purview-account
操作
项目详情
azure-purview-administration-1.0.0b1.zip的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d04271dc3b73904d3b5fbc1ab43c6658ebec53ac84f1c3d4386b76a7e82808d4 |
|
MD5 | 7a3b3872256c32a8e77389a796ec5e06 |
|
BLAKE2b-256 | 724c28f35c83750e5794321108d8b997e185945969138eb91658f21548b1275e |
azure_purview_administration-1.0.0b1-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | eb070be5a63d34730a4c5b819e73b3e9f7b950d2b1e6f528ef73b89799965458 |
|
MD5 | 63bc7a741e4ec250a9edea594ac58d97 |
|
BLAKE2b-256 | 3789fe37aaa9fde191e916f5ea4e9468bb5395dc6f944b58c47198b118f86ae9 |