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

Merge pull request #110 from Microsoft/users/jmarks/ProjectGroupSample

Adding sample for creating groups at the project level
This commit is contained in:
Justin Marks 2018-02-23 13:33:53 -08:00 коммит произвёл GitHub
Родитель 791326c392 b3b18c89c7
Коммит dec49488b5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 62 добавлений и 4 удалений

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

@ -38,7 +38,6 @@ namespace Microsoft.TeamServices.Samples.Client.Runner
try
{
ClientSampleUtils.RunClientSampleMethods(connectionUrl, null, area: area, resource: resource, outputPath: outputPath);
}
catch (Exception ex)

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

@ -41,7 +41,7 @@ namespace Microsoft.TeamServices.Samples.Client.Graph
// Part 2: get the descriptor
//
ClientSampleHttpLogger.SetOperationName(this.Context, "GetDescriptorById");
GraphDescriptorResult descriptor = graphClient.GetDescriptorAsync(storageKey).Result; //TODO: This is failing!!!!!
GraphDescriptorResult descriptor = graphClient.GetDescriptorAsync(storageKey).Result;
try
{
if (descriptor.Value != userDescriptor) throw new Exception();

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

@ -1,4 +1,5 @@
using Microsoft.VisualStudio.Services.Graph;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.Graph;
using Microsoft.VisualStudio.Services.Graph.Client;
using Microsoft.VisualStudio.Services.WebApi;
using System;
@ -82,6 +83,64 @@ namespace Microsoft.TeamServices.Samples.Client.Graph
}
}
/// <summary>
/// Create a new project level group and then delete the group
/// </summary>
[ClientSampleMethod]
public void CreateDeleteProjectVSTSGroup()
{
// Get the client
VssConnection connection = Context.Connection;
//
// Part 1: get the project id
//
ClientSampleHttpLogger.SetOperationName(this.Context, "GetProjectId");
ProjectHttpClient projectClient = connection.GetClient<ProjectHttpClient>();
string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
TeamProject project = projectClient.GetProject(projectName, includeCapabilities: true, includeHistory: true).Result;
Guid projectId = project.Id;
//
// Part 2: get the project scope descriptor
//
ClientSampleHttpLogger.SetOperationName(this.Context, "GetProjectScopeDescriptor");
GraphHttpClient graphClient = connection.GetClient<GraphHttpClient>();
GraphDescriptorResult projectDescriptor = graphClient.GetDescriptorAsync(projectId).Result;
//
// Part 3: create a group at the project level
//
ClientSampleHttpLogger.SetOperationName(this.Context, "CreateGroupInProject");
GraphGroupCreationContext createGroupContext = new GraphGroupVstsCreationContext
{
DisplayName = "Project Developers-" + Guid.NewGuid(),
Description = "Group at project level created via client library"
};
GraphGroup newGroup = graphClient.CreateGroupAsync(createGroupContext, projectDescriptor.Value).Result;
string groupDescriptor = newGroup.Descriptor;
Context.Log("New group created! ID: {0}", groupDescriptor);
//
// Part 4: delete the group
//
ClientSampleHttpLogger.SetOperationName(this.Context, "DeleteGroup");
graphClient.DeleteGroupAsync(groupDescriptor).SyncResult();
// Try to get the deleted group (should result in an exception)
ClientSampleHttpLogger.SetOperationName(this.Context, "GetDisabledGroup");
try
{
newGroup = graphClient.GetGroupAsync(groupDescriptor).Result;
}
catch (Exception e)
{
Context.Log("Unable to get the deleted group:" + e.Message);
}
}
/// <summary>
/// Add an existing Azure Active Directory group to the VSTS account, and then remove it
/// </summary>

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

@ -37,7 +37,7 @@ Microsoft.TeamServices.Samples.Client.Runner.exe
/url:https://fabrikam.visualstudio.com /area:wit /resource:*
```
#### Run all graph samples against vsts
#### Run all graph samples against VSTS/SPS
```
Microsoft.TeamServices.Samples.Client.Runner.exe