Class TfsClient
A class to provide a way to interact with a TFS/VSTS bug database.
Implements
Inherited Members
Namespace: Microsoft.Internal.Studios.Aruba.Tfs
Assembly: Aruba.Tfs.dll
Syntax
public class TfsClient : IDisposableConstructors
View SourceTfsClient(TfsConfig)
Initializes a new instance of the TfsClient class.
Declaration
public TfsClient(TfsConfig config)Parameters
| Type | Name | Description | 
|---|---|---|
| TfsConfig | config | The configuration data for the TfsClient. | 
Fields
View SourceFieldPatchPathPrefix
The prefix of the path to the field patch.
Declaration
public const string FieldPatchPathPrefix = "/fields/"Field Value
| Type | Description | 
|---|---|
| string | 
TagFieldKey
The ADO field name for the Tag field.
Declaration
public const string TagFieldKey = "System.Tags"Field Value
| Type | Description | 
|---|---|
| string | 
Properties
View SourceConfiguration
Gets the configuration data for the TfsClient.
Declaration
public TfsConfig Configuration { get; }Property Value
| Type | Description | 
|---|---|
| TfsConfig | 
Methods
View SourceCreateAttachmentAsync(string)
Uploads an attachment not linked to a specific work item.
Declaration
public Task<AttachmentReference> CreateAttachmentAsync(string filePath)Parameters
| Type | Name | Description | 
|---|---|---|
| string | filePath | The path to the file. | 
Returns
| Type | Description | 
|---|---|
| Task<AttachmentReference> | The attachment reference. | 
CreateAttachmentAsync(string, JsonPatchDocument)
Uploads an attachment to a work item.
Declaration
public Task CreateAttachmentAsync(string filePath, JsonPatchDocument patchDocument)Parameters
| Type | Name | Description | 
|---|---|---|
| string | filePath | The path to the file. | 
| JsonPatchDocument | patchDocument | The JSON patch document. | 
Returns
| Type | Description | 
|---|---|
| Task | An awaitable task. | 
CreateWorkItemAsync(JsonPatchDocument)
Creates a new work item given a Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchDocument object.
Declaration
public Task<WorkItem> CreateWorkItemAsync(JsonPatchDocument patchDocument)Parameters
| Type | Name | Description | 
|---|---|---|
| JsonPatchDocument | patchDocument | The JSON patch document to create the work item from. | 
Returns
| Type | Description | 
|---|---|
| Task<WorkItem> | The work item if created successfully. | 
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()FollowWorkItemAsync(int, CancellationToken)
Follows a work item.
Declaration
public Task FollowWorkItemAsync(int workItemID, CancellationToken cancellationToken = default)Parameters
| Type | Name | Description | 
|---|---|---|
| int | workItemID | The work item ID. | 
| CancellationToken | cancellationToken | The cancellation token for canceling the task. | 
Returns
| Type | Description | 
|---|---|
| Task | A task representing the asynchronous operation. | 
GetAllUsersAsync(IEnumerable<string>?, string?)
Gets all the users for a given organization.
Declaration
public Task<PagedGraphUsers> GetAllUsersAsync(IEnumerable<string>? subjectTypes = null, string? continuationToken = null)Parameters
| Type | Name | Description | 
|---|---|---|
| IEnumerable<string> | subjectTypes | A comma separated list of user subject subtypes to reduce the retrieved results, e.g. 'msa','aad','svc',etc | 
| string | continuationToken | The continuation token to use for the request. | 
Returns
| Type | Description | 
|---|---|
| Task<PagedGraphUsers> | A list of graph users as a task. | 
GetAttachmentAsync(Guid, CancellationToken)
Downloads an attachment.
Declaration
public Task<Stream> GetAttachmentAsync(Guid id, CancellationToken cancellationToken = default)Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | id | The id of the attachment. | 
| CancellationToken | cancellationToken | The cancellation token for canceling the task. | 
Returns
| Type | Description | 
|---|---|
| Task<Stream> | A stream for the attachment. | 
GetCurrentUserDisplayName()
Gets the current user display name.
Declaration
public string GetCurrentUserDisplayName()Returns
| Type | Description | 
|---|---|
| string | The current user display name. | 
GetFieldPatchPath(string)
Gets the path to the field patch.
Declaration
public static string GetFieldPatchPath(string fieldKey)Parameters
| Type | Name | Description | 
|---|---|---|
| string | fieldKey | The key of the field to find. | 
Returns
| Type | Description | 
|---|---|
| string | The path to the field patch. | 
GetFieldsAsync()
Gets all the fields from TFS/VSTS.
Declaration
public Task<List<WorkItemField2>> GetFieldsAsync()Returns
| Type | Description | 
|---|---|
| Task<List<WorkItemField2>> | A list of the fields as a task. | 
GetGroupPathsAsync(TreeStructureGroup)
Gets the paths of all nodes in the specified group.
Declaration
public Task<IEnumerable<string>> GetGroupPathsAsync(TreeStructureGroup group)Parameters
| Type | Name | Description | 
|---|---|---|
| TreeStructureGroup | group | The group to find the paths of all the nodes in. | 
Returns
| Type | Description | 
|---|---|
| Task<IEnumerable<string>> | A collection of strings of paths to each node in the group. | 
GetTagsAsync()
Gets the tags associated with the current work item store.
Declaration
public Task<List<WebApiTagDefinition>> GetTagsAsync()Returns
| Type | Description | 
|---|---|
| Task<List<WebApiTagDefinition>> | A list of all tags. | 
GetTargetWorkItemTypeFieldWithReferencesAsync()
Gets the work item type field with references that matches the target type as specified by the Configuration.
Declaration
public Task<List<WorkItemTypeFieldWithReferences>> GetTargetWorkItemTypeFieldWithReferencesAsync()Returns
| Type | Description | 
|---|---|
| Task<List<WorkItemTypeFieldWithReferences>> | The matching work item type or null as a task. | 
GetWorkItemFromIdAsync(string, CancellationToken)
Gets the WorkItem given the work item ID.
Declaration
public Task<WorkItem> GetWorkItemFromIdAsync(string stringBugId, CancellationToken cancellationToken = default)Parameters
| Type | Name | Description | 
|---|---|---|
| string | stringBugId | The ID of the work item. | 
| CancellationToken | cancellationToken | The cancellation token for cancelling the task. | 
Returns
| Type | Description | 
|---|---|
| Task<WorkItem> | The work item. | 
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | Thrown when the bug ID passed is not an integer. | 
| VssServiceException | Thrown when the bug ID passed cannot be found. | 
GetWorkItemLinkTypeEndAsync(string)
Gets the WorkItemRelationType for the given link type.
Declaration
public Task<WorkItemRelationType> GetWorkItemLinkTypeEndAsync(string linkTypeName)Parameters
| Type | Name | Description | 
|---|---|---|
| string | linkTypeName | The name of the link type to get. | 
Returns
| Type | Description | 
|---|---|
| Task<WorkItemRelationType> | The WorkItemRelationType. | 
GetWorkItemLinkTypesAsync()
Gets a list of available link types.
Declaration
public Task<List<WorkItemRelationType>> GetWorkItemLinkTypesAsync()Returns
| Type | Description | 
|---|---|
| Task<List<WorkItemRelationType>> | A list of the available link types as strings. | 
GetWorkItemTypesAsync()
Gets the different work item types.
Declaration
public Task<List<WorkItemType>> GetWorkItemTypesAsync()Returns
| Type | Description | 
|---|---|
| Task<List<WorkItemType>> | A list of the work item types as a task. | 
InitializeAsync()
Initializes the client, ensuring there is an established connection with TFS and can access the work item store.
Declaration
public Task InitializeAsync()Returns
| Type | Description | 
|---|---|
| Task | awaitable task | 
QueryAsync(string, CancellationToken)
Runs the given query (wiql string).
Declaration
public Task<IEnumerable<WorkItem>> QueryAsync(string query, CancellationToken cancellationToken = default)Parameters
| Type | Name | Description | 
|---|---|---|
| string | query | A query to run as a string. | 
| CancellationToken | cancellationToken | The cancellation token to cancel the task. | 
Returns
| Type | Description | 
|---|---|
| Task<IEnumerable<WorkItem>> | The enumeration of work items returned from the query. | 
Remarks
An empty enumeration is returned if query is null or empty.
UpdateWorkItemAsync(JsonPatchDocument, int)
Creates a new work item given a Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchDocument object.
Declaration
public Task<WorkItem> UpdateWorkItemAsync(JsonPatchDocument patchDocument, int workItemID)Parameters
| Type | Name | Description | 
|---|---|---|
| JsonPatchDocument | patchDocument | The JSON patch document to create the work item from. | 
| int | workItemID | The ID of the work item to update. | 
Returns
| Type | Description | 
|---|---|
| Task<WorkItem> | The work item if created successfully. | 
ValidatePatchDocumentAsync(JsonPatchDocument)
Validates the JSON patch document.
Declaration
public Task ValidatePatchDocumentAsync(JsonPatchDocument patchDocument)Parameters
| Type | Name | Description | 
|---|---|---|
| JsonPatchDocument | patchDocument | The JSON patch document. | 
Returns
| Type | Description | 
|---|---|
| Task | An awaitable task. |