在用于Azure DevOps的Python REST API(https://github.com/Microsoft/azure-devops-python-api)中,只有一个示例用于解析项目列表:
from vsts.vss_connection import VssConnection
from msrest.authentication import BasicAuthentication
import pprint
# Fill in with your personal access token and org URL
personal_access_token = 'YOURPAT'
organization_url = 'https://dev.azure.com/YOURORG'
# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = VssConnection(base_url=organization_url, creds=credentials)
# Get a client (the "core" client provides access to projects, teams, etc)
core_client = connection.get_client('vsts.core.v4_0.core_client.CoreClient')
这个字符串'vsts.core.v4_0.core_client.CoreClient'
来自哪里?
更重要的是,操作的相应“魔术字符串”是什么:
这个神奇的字符串来自vsts
模块的文件夹组织。
它的路径是:
.
指示文件夹层次结构例如,在我的电脑上,我在文件C:\ Python36 \ Lib \ site-packages \ vsts \ core \ v4_0 \ core_client.py中有类“CoreClient"
。这将给出魔术字符串'vsts.core.v4_0.core_client.CoreClient'
(恰好是示例中的一个)。
通过做一些进一步的探索,我发现了以下字符串(我使用API版本4.1):
"vsts.work_item_tracking.v4_1.work_item_tracking_client.WorkItemTrackingClient"
"vsts.test.v4_1.test_client.TestClient"
"vsts.task.v4_1.task_client.TaskClient"