PyTfsClient

Python Microsoft Team Foundation Server Library is a client that can work with Microsoft TFS workitems


Keywords
TFS, AZURE, API, Team, Foundation, Server
License
MIT
Install
pip install PyTfsClient==1.9.0

Documentation

TESTS

Run tests

PyTfsClient library (TFS API Python client)

Microsoft Team Foundation Server Python Library is a Microsoft TFS API Python client that can work with Microsoft TFS.

Installing

Feel free to use command "pip install pytfsclient"

Basic usage

  1. Install pytfsclient package
  2. Import package
import pytfsclient
from pytfsclient.client_factory import ClientFactory
  1. Create and configure Base TFS Client
### IF authentificate with PAT
client_connection = ClientFactory.create_pat('<personal access token>', 'https://tfs-server/tfs/', 'DefaultCollection/MyProject')
### OR with user name and password
client_connection = ClientFactory.create_ntlm('username', 'userpassword', 'https://tfs-server/tfs/', 'DefaultCollection/MyProject')
  1. Get facade your need

    3.1 If you want to manage workitems

    workitem_client = ClientFactory.get_workitem_client(client_connection)

    3.2 If you want to manage projects, teams, team members

    project_client = ClientFactory.get_project_client(client_connection)
  2. Manage TFS items

    4.1 Managing workitems

    wi = workitem_client.get_single_workitem(100500)
    print('Item: Id={}, Title={}, State={}'.format(wi.id, wi.title, wi['System.State']))
    wi['Custom.Field'] = 'Value'
    wi.update_fields()
    print('Item custom field: {}'.format(wi['Custom.Field']))
    
    workitems = client.get_workitems([1, 2, 3])
    for wi in workitems:
        print('Item: id={}, Title={}'.format(wi.id, wi.title))

Coding style

https://google.github.io/styleguide/pyguide.html

Additional API

  • It can send mentions to another user (see MentionClient::send_mention)
  • It can get project identities (groups, teams, etc.) without Graph API.