AzureDevOps Python REST API 中这个神奇的客户端字符串是什么?

What is this magic client string in AzureDevOps Python REST API?

在 Python REST API for Azure DevOps (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' 来自哪里?

更重要的是,对应的"magic string"是什么来操纵:

这个神奇的字符串来自 vsts 模块的文件夹组织。

路径为:

  • 用点表示文件夹层次结构 .
  • 结尾Class的名字

例如,在我的 PC 上,我在文件 C:\Python36\Lib\site-packages\vsts\core\v4_0\core_client.py 中有 class "CoreClient"。那会给出神奇的字符串 'vsts.core.v4_0.core_client.CoreClient' (恰好是示例中的字符串)。

通过进一步探索,我发现了以下字符串(我使用 API 4.1 版):

  • 工作项"vsts.work_item_tracking.v4_1.work_item_tracking_client.WorkItemTrackingClient"
  • 测试Runs/Results"vsts.test.v4_1.test_client.TestClient"
  • 任务(有待检查): "vsts.task.v4_1.task_client.TaskClient"