API Documentation

Connection

TFSAPI

class tfs.TFSAPI(server_url, project='DefaultCollection', user=None, password=None, pat=None, verify=False, auth_type=<class 'requests.auth.HTTPBasicAuth'>, connect_timeout=20, read_timeout=180)[source]

Bases: object

copy_workitem(workitem, with_links_and_attachments=False, from_another_project=False, target_type=None, target_area=None, target_iteration=None, validate_only=None, bypass_rules=None, suppress_notifications=None, api_version=1.0)[source]

Create a copy of a work item

Parameters:
  • workitem – Source workitem
  • with_links_and_attachments – When True, all relations are copied
  • from_another_project – When True, certain fields are not copied
  • target_type – When specified, the copy will have this type instead of the source one
  • target_area – When specified, the copy will have this area instead of the source one
  • target_iteration – When specified, the copy will have this iteration instead of the source one
  • validate_only – When True, do not actually create a work item, a dry run of sorts
  • bypass_rules – When True, can bypass restrictions like <ALLOWEDVALUES> and such
  • suppress_notifications – When true, notifications are [supposedly] not sent
  • api_version – API version to use
Returns:

WorkItem instance of a newly created copy

create_workitem(type_, fields=None, relations_raw=None, validate_only=None, bypass_rules=None, suppress_notifications=None, api_version=1.0)[source]

Create work item. Doc: https://docs.microsoft.com/en-us/rest/api/vsts/wit/work%20items/create

Parameters:
  • type – Work item
  • fields – Dictionary containing field values
  • relations_raw – List containing relations which are dict(rel, url[, attributes])
  • validate_only – When True, do not actually create a work item, a dry run of sorts
  • bypass_rules – When True, can bypass restrictions like <ALLOWEDVALUES> and such
  • suppress_notifications – When true, notifications are [supposedly] not sent
  • api_version – API version to use
Returns:

WorkItem instance of a newly created WI

download_file(uri, filename)[source]
get_changeset(id_)[source]
get_changesets(from_=None, to_=None, item_path=None, top=10000)[source]
get_gitrepositories()[source]
get_gitrepository(name)[source]
get_project(name)[source]
get_projects()[source]
get_tfs_object(uri, payload=None, object_class=<class 'tfs.resources.TFSObject'>, project=False)[source]

Send requests and return any object in TFS

get_workitem(id_, fields=None)[source]
get_workitems(work_items_ids, fields=None, batch_size=50, expand='all')[source]
run_query(path)[source]
run_wiql(query, params=None)[source]
update_workitem(work_item_id, update_data, params=None)[source]

TFSHTTPClient

class tfs.TFSHTTPClient(base_url, project, user, password, pat, verify=False, timeout=None, auth_type=None)[source]

Bases: object

static get_collection_and_project(project)[source]
send_get(uri, payload=None, project=False, json=True)[source]
send_patch(uri, data, headers, payload=None, project=False)[source]
send_post(uri, data, headers, payload=None, project=False)[source]

Resources

TFSObject

class tfs.TFSObject(data=None, tfs=None, uri='')[source]

Bases: object

get(key, default=None)[source]

Workitem

class tfs.Workitem(data=None, tfs=None, uri='')[source]

Bases: tfs.resources.TFSObject

add_relations_raw(relations_raw, params=None)[source]

Add attachments, related (work item) links and/or hyperlinks

Parameters:relations_raw – List of relations. Each relation is a dict with the following keys: rel, url, attributes
attachments
child_ids
childs
field_names
find_in_relation(relation_type)[source]

Get relation by typename. Auto add

Parameters:relation_type
Returns:
get(key, default=None)[source]
history
parent
parent_id
revisions

Attachment

class tfs.Attachment(data=None, tfs=None, uri='')[source]

Bases: tfs.resources.TFSObject

download(path='.')[source]

Changeset

class tfs.Changeset(data=None, tfs=None, uri='')[source]

Bases: tfs.resources.TFSObject

workitems

Projects

class tfs.Projects(data=None, tfs=None, uri='')[source]

Bases: tfs.resources.TFSObject

team

TFSQuery

class tfs.TFSQuery(data=None, tfs=None, uri='')[source]

Bases: tfs.resources.TFSObject

workitems

Wiql

class tfs.Wiql(data=None, tfs=None, uri='')[source]

Bases: tfs.resources.TFSObject

Work Item Query Language

workitem_ids
workitems