0
votes

In Python REST API for Azure DevOps (https://github.com/Microsoft/azure-devops-python-api), there is only a single example given to parse the list of projects:

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

Where is this string 'vsts.core.v4_0.core_client.CoreClient' coming from?

And more importantly, what is the corresponding "magic string" for manipulating:

  • WorkItems
  • Test Runs and Results
  • Tasks
  • Builds
  • etc...
1

1 Answers

1
votes

This magic string is coming from the folders organization of vsts module.

Folder for core client

It is the path with:

  • indication of folder hierarchy with dots .
  • the name of the Class at the end

For example, on my PC, I have the class "CoreClient" in the file C:\Python36\Lib\site-packages\vsts\core\v4_0\core_client.py. That would give the magic string 'vsts.core.v4_0.core_client.CoreClient' (which happens to be the one in the example).

By doing some further exploration, I have found out following strings (I use API version 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 (to be checked): "vsts.task.v4_1.task_client.TaskClient"