Skip to content

Commit 019dadb

Browse files
committed
Fixes #341 enabling the creation of a team on a group with await graphClient.Groups[groupPage[8].Id].Team.Request().PutAsync(team)
1 parent 1a0e1c9 commit 019dadb

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System.Threading;
2+
3+
namespace Microsoft.Graph
4+
{
5+
public partial interface ITeamRequest
6+
{
7+
/// <summary>
8+
/// Creates the specified Team using PUT.
9+
/// </summary>
10+
/// <param name="teamToCreate">The Team to create.</param>
11+
/// <returns>The created Team.</returns>
12+
System.Threading.Tasks.Task<Team> PutAsync(Team teamToCreate);
13+
14+
/// <summary>
15+
/// Creates the specified Team using PUT.
16+
/// </summary>
17+
/// <param name="teamToCreate">The Team to create.</param>
18+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
19+
/// <returns>The created Team.</returns>
20+
System.Threading.Tasks.Task<Team> PutAsync(Team teamToCreate, CancellationToken cancellationToken);
21+
}
22+
23+
public partial class TeamRequest
24+
{
25+
/// <summary>
26+
/// Creates the specified Team using PUT.
27+
/// </summary>
28+
/// <param name="teamToCreate">The Team to create.</param>
29+
/// <returns>The created Team.</returns>
30+
public System.Threading.Tasks.Task<Team> PutAsync(Team teamToCreate)
31+
{
32+
return this.PutAsync(teamToCreate, CancellationToken.None);
33+
}
34+
35+
/// <summary>
36+
/// Creates the specified Team using PUT.
37+
/// </summary>
38+
/// <param name="teamToCreate">The Team to create.</param>
39+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
40+
/// <returns>The created Team.</returns>
41+
public async System.Threading.Tasks.Task<Team> PutAsync(Team teamToCreate, CancellationToken cancellationToken)
42+
{
43+
this.ContentType = "application/json";
44+
this.Method = "PUT";
45+
var newEntity = await this.SendAsync<Team>(teamToCreate, cancellationToken).ConfigureAwait(false);
46+
this.InitializeCollectionProperties(newEntity);
47+
return newEntity;
48+
}
49+
}
50+
}

tests/Microsoft.Graph.Test/Microsoft.Graph.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
<Compile Include="Requests\Functional\ContactTests.cs" />
106106
<Compile Include="Requests\Functional\EventTests.cs" />
107107
<Compile Include="Requests\Functional\GraphTestBase.cs" />
108+
<Compile Include="Requests\Functional\GroupTests.cs" />
108109
<Compile Include="Requests\Functional\MailTests.cs" />
109110
<Compile Include="Requests\Functional\OneDriveTests.cs" />
110111
<Compile Include="Requests\Functional\ErrorTests.cs" />
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System.Collections.Generic;
4+
using Async = System.Threading.Tasks;
5+
6+
namespace Microsoft.Graph.Test.Requests.Functional
7+
{
8+
//[Ignore]
9+
[TestClass]
10+
public class GroupTests : GraphTestBase
11+
{
12+
/// <summary>
13+
/// Create a team on a group.
14+
/// </summary>
15+
[TestMethod]
16+
public async Async.Task GroupCreateTeam()
17+
{
18+
try
19+
{
20+
// Get a groups collection. We'll use the first entry to add the team. Results in a call to the service.
21+
IGraphServiceGroupsCollectionPage groupPage = await graphClient.Groups.Request().GetAsync();
22+
23+
// Create a team with settings.
24+
Team team = new Team()
25+
{
26+
MemberSettings = new TeamMemberSettings()
27+
{
28+
AllowCreateUpdateChannels = true
29+
}
30+
};
31+
32+
// Add a team to the group. Results in a call to the service.
33+
await graphClient.Groups[groupPage[8].Id].Team.Request().PutAsync(team);
34+
}
35+
catch (ServiceException e)
36+
{
37+
Assert.Fail(e.Error.ToString());
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)