首页 文章

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

提问于
浏览
0

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

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

  • WorkItems

  • 测试运行和结果

  • 任务

  • 构建

  • 等......

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):

    • Workitems"vsts.work_item_tracking.v4_1.work_item_tracking_client.WorkItemTrackingClient"

    • Test Runs/Results"vsts.test.v4_1.test_client.TestClient"

    • Tasks (待检查): "vsts.task.v4_1.task_client.TaskClient"

相关问题