зеркало из
1
0
Форкнуть 0

Merge pull request #97 from rsemenov/users/rsemenov/add-pr-status-samples

Add Pull Request Status API samples
This commit is contained in:
Matt Cooper 2018-01-29 07:14:03 -05:00 коммит произвёл GitHub
Родитель f8a6ac171e 788f8de181
Коммит 6e5940828d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 657 добавлений и 96 удалений

Просмотреть файл

@ -33,46 +33,43 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.Build2.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Chat.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Chat.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Common.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Core.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Dashboards.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.DistributedTask.Common.Contracts, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Policy.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.SourceControl.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Test.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.TestManagement.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Work.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.121.0-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.121.0-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>

Просмотреть файл

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" version="15.121.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundationServer.Client" version="15.121.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Client" version="15.121.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundationServer.Client" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Client" version="15.126.0-preview" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
</packages>

Просмотреть файл

@ -39,49 +39,46 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.Build2.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Chat.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Chat.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Common.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Core.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Dashboards.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.DistributedTask.Common.Contracts, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Policy.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.SourceControl.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Test.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.TestManagement.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Work.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.121.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.121.0-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Notifications.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Notifications.WebApi.15.121.0-preview\lib\net45\Microsoft.VisualStudio.Services.Notifications.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Notifications.WebApi.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.Notifications.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.121.0-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>

Просмотреть файл

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" version="15.121.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundationServer.Client" version="15.121.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Client" version="15.121.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Notifications.WebApi" version="15.121.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundationServer.Client" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Client" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Notifications.WebApi" version="15.126.0-preview" targetFramework="net452" />
<package id="MSTest.TestAdapter" version="1.1.18" targetFramework="net452" />
<package id="MSTest.TestFramework" version="1.1.18" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />

Просмотреть файл

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Microsoft.TeamServices.Samples.Client.Git
{
@ -69,6 +70,156 @@ namespace Microsoft.TeamServices.Samples.Client.Git
return $"{ChooseNamePart()}.{ChooseNamePart()}.{ChooseNamePart()}";
}
public static GitPullRequest CreatePullRequest(ClientSampleContext context, GitRepository repo)
{
VssConnection connection = context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
using (new ClientSampleHttpLoggerOutputSuppression())
{
GitPullRequest pullRequest = gitClient.GetPullRequestsAsync(
repo.Id,
new GitPullRequestSearchCriteria()
{
Status = PullRequestStatus.Active
}).Result.FirstOrDefault();
if (pullRequest == null)
{
pullRequest = CreatePullRequestInternal(context, repo, gitClient);
}
return pullRequest;
}
}
public static GitPullRequest AbandonPullRequest(ClientSampleContext context, GitRepository repo, int pullRequestId)
{
VssConnection connection = context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
using (new ClientSampleHttpLoggerOutputSuppression())
{
// clean up after ourselves (and in case logging is on, don't log these calls)
ClientSampleHttpLogger.SetSuppressOutput(context, true);
// abandon the PR
GitPullRequest updatedPr = new GitPullRequest()
{
Status = PullRequestStatus.Abandoned,
};
var pullRequest = gitClient.UpdatePullRequestAsync(updatedPr, repo.Id, pullRequestId).Result;
return pullRequest;
}
}
public static GitPullRequestStatus CreatePullRequestStatus(ClientSampleContext context, Guid repositoryId, int pullRequestId, int? iterationId = null)
{
VssConnection connection = context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
using (new ClientSampleHttpLoggerOutputSuppression())
{
GitPullRequestStatus status = GenerateSampleStatus(iterationId);
GitPullRequestStatus createdStatus = gitClient.CreatePullRequestStatusAsync(status, repositoryId, pullRequestId).Result;
return createdStatus;
}
}
public static string WithoutRefsPrefix(string refName)
{
if (!refName.StartsWith("refs/"))
{
throw new Exception("The ref name should have started with 'refs/' but it didn't.");
}
return refName.Remove(0, "refs/".Length);
}
public static GitPullRequestStatus GenerateSampleStatus(int? iterationId = null, bool includeProperties = false)
{
var status = new GitPullRequestStatus
{
Context = new GitStatusContext
{
Name = $"sample-status-{Rng.Next(1, 5)}",
Genre = "vsts-samples"
},
TargetUrl = "http://fabrikam-fiber-inc.com/CI/builds/1",
State = GitStatusState.Succeeded,
Description = "Sample status succeeded",
IterationId = iterationId
};
if (includeProperties)
{
status.Properties = new PropertiesCollection();
status.Properties["sampleId"] = Rng.Next(1, 10);
status.Properties["customInfo"] = "Custom status information";
status.Properties["startedDateTime"] = DateTime.UtcNow;
status.Properties["weight"] = 1.75;
status.Properties["bytes"] = Encoding.UTF8.GetBytes("this is sample base64 encoded string");
status.Properties["globalId"] = Guid.NewGuid();
}
return status;
}
private static GitPullRequest CreatePullRequestInternal(ClientSampleContext context, GitRepository repo, GitHttpClient gitClient)
{
// we need a new branch with changes in order to create a PR
// first, find the default branch
string defaultBranchName = WithoutRefsPrefix(repo.DefaultBranch);
GitRef defaultBranch = gitClient.GetRefsAsync(repo.Id, filter: defaultBranchName).Result.First();
// next, craft the branch and commit that we'll push
GitRefUpdate newBranch = new GitRefUpdate()
{
Name = $"refs/heads/vsts-api-sample/{ChooseRefsafeName()}",
OldObjectId = defaultBranch.ObjectId,
};
string newFileName = $"{ChooseItemsafeName()}.md";
GitCommitRef newCommit = new GitCommitRef()
{
Comment = "Add a sample file",
Changes = new GitChange[]
{
new GitChange()
{
ChangeType = VersionControlChangeType.Add,
Item = new GitItem() { Path = $"/vsts-api-sample/{newFileName}" },
NewContent = new ItemContent()
{
Content = "# Thank you for using VSTS!",
ContentType = ItemContentType.RawText,
},
}
},
};
// create the push with the new branch and commit
GitPush push = gitClient.CreatePushAsync(new GitPush()
{
RefUpdates = new GitRefUpdate[] { newBranch },
Commits = new GitCommitRef[] { newCommit },
}, repo.Id).Result;
// finally, create a PR
var pr = gitClient.CreatePullRequestAsync(new GitPullRequest()
{
SourceRefName = newBranch.Name,
TargetRefName = repo.DefaultBranch,
Title = $"Add {newFileName} (from VSTS REST samples)",
Description = "Adding this file from the pull request samples",
},
repo.Id).Result;
return pr;
}
private static string ChooseNamePart()
{
if (WordList == null)
@ -100,15 +251,6 @@ namespace Microsoft.TeamServices.Samples.Client.Git
WordList = words;
}
public static string WithoutRefsPrefix(string refName)
{
if (!refName.StartsWith("refs/"))
{
throw new Exception("The ref name should have started with 'refs/' but it didn't.");
}
return refName.Remove(0, "refs/".Length);
}
private static List<string> WordList;
private static Random Rng = new Random();
}

Просмотреть файл

@ -0,0 +1,134 @@
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.VisualStudio.Services.WebApi.Patch.Json;
using System;
using System.Collections.Generic;
namespace Microsoft.TeamServices.Samples.Client.Git
{
[ClientSample(GitWebApiConstants.AreaName, "pullRequestIterationStatuses")]
public class PullRequestIterationStatusesSample : ClientSample
{
[ClientSampleMethod]
public GitPullRequestStatus CreatePullRequestIterationStatus()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId);
GitPullRequestStatus status = GitSampleHelpers.GenerateSampleStatus();
GitPullRequestStatus createdStatus = gitClient.CreatePullRequestIterationStatusAsync(status, repo.Id, pullRequest.PullRequestId, 1).Result;
Console.WriteLine($"{createdStatus.Description}({createdStatus.Context.Genre}/{createdStatus.Context.Name}) with id {createdStatus.Id} created" +
$" on iteration {createdStatus.IterationId}");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return createdStatus;
}
[ClientSampleMethod]
public List<GitPullRequestStatus> GetPullRequestIterationStatuses()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId, 1);
GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId, 1);
Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}");
List<GitPullRequestStatus> iterationStatuses = gitClient.GetPullRequestIterationStatusesAsync(repo.Id, pullRequest.PullRequestId, 1).Result;
Console.WriteLine($"{iterationStatuses.Count} statuses found for pull request {pullRequest.PullRequestId} iteration {1}");
foreach (var status in iterationStatuses)
{
Console.WriteLine($"{status.Description}({status.Context.Genre}/{status.Context.Name}) with id {status.Id}");
}
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return iterationStatuses;
}
[ClientSampleMethod]
public GitPullRequestStatus GetPullRequestIterationStatus()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
GitPullRequestStatus generatedStatus = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId, 1);
Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}");
GitPullRequestStatus status = gitClient.GetPullRequestIterationStatusAsync(repo.Id, pullRequest.PullRequestId, 1, generatedStatus.Id).Result;
Console.WriteLine($"{status.Description}({status.Context.Genre}/{status.Context.Name}) with id {status.Id}");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return status;
}
[ClientSampleMethod]
public void DeletePullRequestIterationStatus()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
GitPullRequestStatus status = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId, 1);
Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}");
gitClient.DeletePullRequestIterationStatusAsync(repo.Id, pullRequest.PullRequestId, 1, status.Id).SyncResult();
Console.WriteLine($"Status {status.Id} deleted from pull request {pullRequest.PullRequestId}, iteration {1}");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
}
[ClientSampleMethod]
public void UpdatePullRequestIterationStatuses()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
GitPullRequestStatus status1 = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId, 1);
GitPullRequestStatus status2 = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId, 1);
Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}");
var patch = new JsonPatchDocument();
patch.Add(new JsonPatchOperation() { Operation = VisualStudio.Services.WebApi.Patch.Operation.Remove, Path = $"/{status1.Id}" });
patch.Add(new JsonPatchOperation() { Operation = VisualStudio.Services.WebApi.Patch.Operation.Remove, Path = $"/{status2.Id}" });
gitClient.UpdatePullRequestIterationStatusesAsync(patch, repo.Id, pullRequest.PullRequestId, 1).SyncResult();
Console.WriteLine($"Statuses {status1.Id}, and {status2.Id} deleted from the pull request {pullRequest.PullRequestId}, iteration {1}");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
}
}
}

Просмотреть файл

@ -0,0 +1,114 @@
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.VisualStudio.Services.WebApi.Patch;
using Microsoft.VisualStudio.Services.WebApi.Patch.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.TeamServices.Samples.Client.Git
{
[ClientSample(GitWebApiConstants.AreaName, "pullRequestProperties")]
public class PullRequestPropertiesSample : ClientSample
{
[ClientSampleMethod]
public PropertiesCollection GetPullRequestProperties()
{
VssConnection connection = Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
using (new ClientSampleHttpLoggerOutputSuppression())
{
JsonPatchDocument patch = new JsonPatchDocument();
patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/sampleId", Value = 8});
patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/startedDateTime", Value = DateTime.UtcNow });
gitClient.UpdatePullRequestPropertiesAsync(patch, repo.Id, pullRequest.PullRequestId).SyncResult();
}
Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId);
PropertiesCollection properties = gitClient.GetPullRequestPropertiesAsync(repo.Id, pullRequest.PullRequestId).SyncResult();
Console.WriteLine($"Pull request {pullRequest.PullRequestId} has {properties.Count} properties");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return properties;
}
[ClientSampleMethod]
public PropertiesCollection AddPullRequestProperties()
{
VssConnection connection = Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId);
JsonPatchDocument patch = new JsonPatchDocument();
patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/sampleId", Value = 8 });
patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/startedDateTime", Value = DateTime.UtcNow });
patch.Add(new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "",
Value = new Dictionary<string, object>()
{
{ "bytes", Encoding.UTF8.GetBytes("this is sample base64 encoded string") },
{ "globalId", Guid.NewGuid() }
}
});
PropertiesCollection properties = gitClient.UpdatePullRequestPropertiesAsync(patch, repo.Id, pullRequest.PullRequestId).SyncResult();
Console.WriteLine($"Pull request {pullRequest.PullRequestId} has {properties.Count} properties");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return properties;
}
[ClientSampleMethod]
public PropertiesCollection RemoveAndReplacePullRequestProperties()
{
VssConnection connection = Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId);
using (new ClientSampleHttpLoggerOutputSuppression())
{
JsonPatchDocument init = new JsonPatchDocument();
init.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/sampleId", Value = 8 });
init.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/startedDateTime", Value = DateTime.UtcNow });
gitClient.UpdatePullRequestPropertiesAsync(init, repo.Id, pullRequest.PullRequestId).SyncResult();
}
JsonPatchDocument patch = new JsonPatchDocument();
patch.Add(new JsonPatchOperation() { Operation = Operation.Replace, Path = "/sampleId", Value = 12 });
patch.Add(new JsonPatchOperation() { Operation = Operation.Remove, Path = "/startedDateTime", Value = null });
PropertiesCollection properties = gitClient.UpdatePullRequestPropertiesAsync(patch, repo.Id, pullRequest.PullRequestId).SyncResult();
Console.WriteLine($"Pull request {pullRequest.PullRequestId} has {properties.Count} properties");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return properties;
}
}
}

Просмотреть файл

@ -0,0 +1,180 @@
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.VisualStudio.Services.WebApi.Patch.Json;
using System;
using System.Collections.Generic;
namespace Microsoft.TeamServices.Samples.Client.Git
{
[ClientSample(GitWebApiConstants.AreaName, "pullRequestStatuses")]
public class PullRequestStatusesSample : ClientSample
{
[ClientSampleMethod]
public GitPullRequestStatus CreatePullRequestStatus()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId);
GitPullRequestStatus status = GitSampleHelpers.GenerateSampleStatus();
GitPullRequestStatus createdStatus = gitClient.CreatePullRequestStatusAsync(status, repo.Id, pullRequest.PullRequestId).Result;
Console.WriteLine($"{createdStatus.Description}({createdStatus.Context.Genre}/{createdStatus.Context.Name}) with id {createdStatus.Id} created");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return createdStatus;
}
[ClientSampleMethod]
public GitPullRequestStatus CreatePullRequestStatusWithIterationInBody()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId);
GitPullRequestStatus status = GitSampleHelpers.GenerateSampleStatus(1);
GitPullRequestStatus createdStatus = gitClient.CreatePullRequestStatusAsync(status, repo.Id, pullRequest.PullRequestId).Result;
Console.WriteLine($"{createdStatus.Description}({createdStatus.Context.Genre}/{createdStatus.Context.Name}) with id {createdStatus.Id} created"+
$" on iteration {createdStatus.IterationId}");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return createdStatus;
}
[ClientSampleMethod]
public GitPullRequestStatus CreatePullRequestStatusWithCustomProperties()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId);
GitPullRequestStatus status = GitSampleHelpers.GenerateSampleStatus(includeProperties: true);
GitPullRequestStatus createdStatus = gitClient.CreatePullRequestStatusAsync(status, repo.Id, pullRequest.PullRequestId).Result;
Console.WriteLine($"{createdStatus.Description}({createdStatus.Context.Genre}/{createdStatus.Context.Name}) with id {createdStatus.Id} created");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return createdStatus;
}
[ClientSampleMethod]
public List<GitPullRequestStatus> GetPullRequestStatuses()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId);
GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId);
Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}");
List<GitPullRequestStatus> statuses = gitClient.GetPullRequestStatusesAsync(repo.Id, pullRequest.PullRequestId).Result;
Console.WriteLine($"{statuses.Count} statuses found for pull request {pullRequest.PullRequestId}");
foreach (var status in statuses)
{
Console.WriteLine($"{status.Description}({status.Context.Genre}/{status.Context.Name}) with id {status.Id}");
}
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return statuses;
}
[ClientSampleMethod]
public GitPullRequestStatus GetPullRequestStatus()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
GitPullRequestStatus generatedStatus = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId);
Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}");
GitPullRequestStatus status = gitClient.GetPullRequestStatusAsync(repo.Id, pullRequest.PullRequestId, generatedStatus.Id).Result;
Console.WriteLine($"{status.Description}({status.Context.Genre}/{status.Context.Name}) with id {status.Id}");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
return status;
}
[ClientSampleMethod]
public void DeletePullRequestStatus()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
GitPullRequestStatus status = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId);
Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}");
gitClient.DeletePullRequestStatusAsync(repo.Id, pullRequest.PullRequestId, status.Id).SyncResult();
Console.WriteLine($"Status {status.Id} deleted from pull request {pullRequest.PullRequestId}");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
}
[ClientSampleMethod]
public void UpdatePullRequestStatuses()
{
VssConnection connection = this.Context.Connection;
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id);
GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo);
GitPullRequestStatus status1 = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId);
GitPullRequestStatus status2 = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId);
Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}");
var patch = new JsonPatchDocument();
patch.Add(new JsonPatchOperation() { Operation = VisualStudio.Services.WebApi.Patch.Operation.Remove, Path = $"/{status1.Id}" });
patch.Add(new JsonPatchOperation() { Operation = VisualStudio.Services.WebApi.Patch.Operation.Remove, Path = $"/{status2.Id}" });
gitClient.UpdatePullRequestStatusesAsync(patch, repo.Id, pullRequest.PullRequestId).SyncResult();
Console.WriteLine($"Statuses {status1.Id}, and {status2.Id} deleted from the pull request {pullRequest.PullRequestId}");
GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId);
}
}
}

Просмотреть файл

@ -18,7 +18,7 @@ namespace Microsoft.TeamServices.Samples.Client.Graph
{
VssConnection connection = Context.Connection;
GraphHttpClient graphClient = connection.GetClient<GraphHttpClient>();
PagedGraphGroups groups = graphClient.GetGroupsAsync().Result;
PagedGraphGroups groups = graphClient.ListGroupsAsync().Result;
foreach (var group in groups.GraphGroups)
{

Просмотреть файл

@ -70,13 +70,13 @@ namespace Microsoft.TeamServices.Samples.Client.Graph
// Part 6: Get every group the subject(user) is a member of
//
ClientSampleHttpLogger.SetOperationName(this.Context, "BatchGetMembershipsUserUp");
List<GraphMembership> membershipsForUser = graphClient.GetMembershipsAsync(userDescriptor).Result;
List<GraphMembership> membershipsForUser = graphClient.ListMembershipsAsync(userDescriptor).Result;
//
// Part 7: Get every member of the group
//
ClientSampleHttpLogger.SetOperationName(this.Context, "BatchGetMembershipsGroupDown");
List<GraphMembership> membershipsOfGroup = graphClient.GetMembershipsAsync(groupDescriptor, Microsoft.VisualStudio.Services.Graph.GraphTraversalDirection.Down).Result;
List<GraphMembership> membershipsOfGroup = graphClient.ListMembershipsAsync(groupDescriptor, Microsoft.VisualStudio.Services.Graph.GraphTraversalDirection.Down).Result;
//
// Part 8: Remove member from the group
@ -176,13 +176,13 @@ namespace Microsoft.TeamServices.Samples.Client.Graph
// Part 6: Get every group the subject('Contractors') is a member of
//
ClientSampleHttpLogger.SetOperationName(this.Context, "BatchGetMembershipsVSTSGroupUp");
List<GraphMembership> membershipsForUser = graphClient.GetMembershipsAsync(childGroupDescriptor).Result;
List<GraphMembership> membershipsForUser = graphClient.ListMembershipsAsync(childGroupDescriptor).Result;
//
// Part 7: Get every member of the 'Developers' group
//
ClientSampleHttpLogger.SetOperationName(this.Context, "BatchGetMembershipsVSTSGroupDown");
List<GraphMembership> membershipsOfGroup = graphClient.GetMembershipsAsync(parentGroupDescriptor, Microsoft.VisualStudio.Services.Graph.GraphTraversalDirection.Down).Result;
List<GraphMembership> membershipsOfGroup = graphClient.ListMembershipsAsync(parentGroupDescriptor, Microsoft.VisualStudio.Services.Graph.GraphTraversalDirection.Down).Result;
//
// Part 8: Remove member from the group
@ -266,13 +266,13 @@ namespace Microsoft.TeamServices.Samples.Client.Graph
// Part 6: Get every group the subject(AAD group) is a member of
//
ClientSampleHttpLogger.SetOperationName(this.Context, "BatchGetMembershipsAADGroupDown");
List<GraphMembership> membershipsForUser = graphClient.GetMembershipsAsync(aadGroupDescriptor).Result;
List<GraphMembership> membershipsForUser = graphClient.ListMembershipsAsync(aadGroupDescriptor).Result;
//
// Part 7: Get every member of the VSTS 'Developers' group
//
ClientSampleHttpLogger.SetOperationName(this.Context, "BatchGetMembershipsAADGroupUp");
List<GraphMembership> membershipsOfGroup = graphClient.GetMembershipsAsync(parentGroupDescriptor, Microsoft.VisualStudio.Services.Graph.GraphTraversalDirection.Down).Result;
List<GraphMembership> membershipsOfGroup = graphClient.ListMembershipsAsync(parentGroupDescriptor, Microsoft.VisualStudio.Services.Graph.GraphTraversalDirection.Down).Result;
//
// Part 8: Remove member from the group

Просмотреть файл

@ -18,7 +18,7 @@ namespace Microsoft.TeamServices.Samples.Client.Graph
{
VssConnection connection = Context.Connection;
GraphHttpClient graphClient = connection.GetClient<GraphHttpClient>();
PagedGraphUsers users = graphClient.GetUsersAsync().Result;
PagedGraphUsers users = graphClient.ListUsersAsync().Result;
foreach (var user in users.GraphUsers)
{

Просмотреть файл

@ -38,71 +38,68 @@
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.13.9.1126, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.13.9\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Logging, Version=1.1.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Logging.1.1.3\lib\net451\Microsoft.IdentityModel.Logging.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Logging, Version=1.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Logging.1.1.4\lib\net451\Microsoft.IdentityModel.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.1.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.5.1.3\lib\net451\Microsoft.IdentityModel.Tokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.5.1.4\lib\net451\Microsoft.IdentityModel.Tokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.ServiceBus.4.1.1\lib\net45\Microsoft.ServiceBus.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Build2.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Chat.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.Chat.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.Common.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Core.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Dashboards.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.DistributedTask.Common.Contracts, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Policy.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.SourceControl.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Test.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.TestManagement.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Work.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.122.1-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.15.126.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Client.Interactive, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.InteractiveClient.15.122.1-preview\lib\net45\Microsoft.VisualStudio.Services.Client.Interactive.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.InteractiveClient.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.Client.Interactive.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.122.1-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.ExtensionManagement.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.15.122.1-preview\lib\net45\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Gallery.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Gallery.WebApi.15.122.1-preview\lib\net45\Microsoft.VisualStudio.Services.Gallery.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Gallery.WebApi.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.Gallery.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Notifications.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Notifications.WebApi.15.122.1-preview\lib\net45\Microsoft.VisualStudio.Services.Notifications.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Notifications.WebApi.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.Notifications.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.ReleaseManagement.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Release.Client.15.122.1-preview\lib\net45\Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Release.Client.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.WebApi, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.122.1-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.15.126.0-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
@ -111,8 +108,8 @@
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.1.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.5.1.3\lib\net451\System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.5.1.4\lib\net451\System.IdentityModel.Tokens.Jwt.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>

Просмотреть файл

@ -68,7 +68,7 @@ namespace Microsoft.TeamServices.Samples.Client.ProjectsAndTeams
VssConnection connection = Context.Connection;
TeamHttpClient teamClient = connection.GetClient<TeamHttpClient>();
IEnumerable<IdentityRef> teamMembers = teamClient.GetTeamMembersAsync(projectId.ToString(), teamId.ToString()).Result;
IEnumerable<IdentityRef> teamMembers = teamClient.GetTeamMembers(projectId.ToString(), teamId.ToString()).Result;
Console.WriteLine("Members of {0}:", teamId);
foreach (var member in teamMembers)

Просмотреть файл

@ -3,18 +3,18 @@
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net452" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.13.9" targetFramework="net452" />
<package id="Microsoft.IdentityModel.Logging" version="1.1.3" targetFramework="net452" />
<package id="Microsoft.IdentityModel.Tokens" version="5.1.3" targetFramework="net452" />
<package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" version="15.122.1-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundationServer.Client" version="15.122.1-preview" targetFramework="net452" />
<package id="Microsoft.IdentityModel.Logging" version="1.1.4" targetFramework="net452" />
<package id="Microsoft.IdentityModel.Tokens" version="5.1.4" targetFramework="net452" />
<package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundationServer.Client" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Client" version="15.122.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.ExtensionManagement.WebApi" version="15.122.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Gallery.WebApi" version="15.122.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.InteractiveClient" version="15.122.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Notifications.WebApi" version="15.122.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Release.Client" version="15.122.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Client" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.ExtensionManagement.WebApi" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Gallery.WebApi" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.InteractiveClient" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Notifications.WebApi" version="15.126.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Release.Client" version="15.126.0-preview" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.1.3" targetFramework="net452" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.1.4" targetFramework="net452" />
<package id="WindowsAzure.ServiceBus" version="4.1.1" targetFramework="net452" />
</packages>