AzureDevOps Python REST API中的魔术客户端字符串是什么?

时间:2018-11-02 03:02:59

标签: python rest azure-devops azure-devops-rest-api

在适用于Azure DevOps(https://github.com/Microsoft/azure-devops-python-api)的Python REST 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'来自哪里?

更重要的是,用于操作的相应“魔术字符串”是什么:

  • WorkItems
  • 测试运行和结果
  • 任务
  • 建筑物
  • 等...

1 个答案:

答案 0 :(得分:0)

此魔术字符串来自vsts模块的文件夹组织。

Folder for core client

这是具有以下内容的路径:

  • 带点.的文件夹层次结构指示
  • 末尾的班级名称

例如,在我的PC上,我在文件 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"