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

问题描述 投票:0回答:1

在用于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'来自哪里?

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

  • 工作项目
  • 测试运行和结果
  • 任务
  • 构建
  • 等等...
python rest azure-devops azure-devops-rest-api
1个回答
0
投票

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

Folder for core client

它的路径是:

  • 用点.指示文件夹层次结构
  • 最后的类的名称

例如,在我的电脑上,我在文件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"
© www.soinside.com 2019 - 2024. All rights reserved.