Skip to content

Commit 73d5882

Browse files
authored
Merge pull request #2222 from subray2014/users/subray/enhanceTeamsRscConfigStates
Add support for new states in RSC configuration.
2 parents 8989ffb + 69d62c1 commit 73d5882

10 files changed

+511
-130
lines changed

src/Teams/beta/custom/GetMgBetaChatRscConfiguration_Get.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ protected override void ProcessRecord()
237237
{
238238
await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletBeforeAPICall); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
239239

240+
MGTeamsInternalPermissionGrantPolicyCollection permissionGrantPolicyCollection =
241+
await this.Client.GetPermissionGrantPolicies(selectQuery: "id, resourceScopeType", eventListener: this, sender: this.Pipeline);
242+
243+
WriteVerbose($"Fetched permission grant policies for tenant.");
244+
245+
if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
246+
240247
// Get Teams App Settings
241248
Models.IMicrosoftGraphTeamsAppSettings teamsAppSettings = await this.Client.GetTeamsAppSettings(this, Pipeline);
242249

@@ -253,7 +260,11 @@ protected override void ProcessRecord()
253260

254261
RscConfigurationSynthesizer rscConfigurationConverter = new RscConfigurationSynthesizer();
255262
Models.IMicrosoftGraphRscConfiguration microsoftGraphRscConfiguration =
256-
rscConfigurationConverter.ConvertToChatRscConfiguration(teamsAppSettings, authorizationPolicy, this);
263+
rscConfigurationConverter.ConvertToChatRscConfiguration(
264+
permissionGrantPolicyCollection: permissionGrantPolicyCollection,
265+
teamsAppSettings: teamsAppSettings,
266+
authorizationPolicy: authorizationPolicy,
267+
eventListener: this);
257268

258269
WriteObject(microsoftGraphRscConfiguration);
259270

src/Teams/beta/custom/GetMgBetaTeamRscConfiguration_Get.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ protected override void ProcessRecord()
237237
{
238238
await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletBeforeAPICall); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
239239

240+
MGTeamsInternalPermissionGrantPolicyCollection permissionGrantPolicyCollection =
241+
await this.Client.GetPermissionGrantPolicies(selectQuery: "id, resourceScopeType", eventListener: this, sender: this.Pipeline);
242+
243+
WriteVerbose($"Fetched permission grant policies for tenant.");
244+
240245
// Get Group consent settings
241246
MGTeamsInternalTenantConsentSettingsCollection tenantConsentSettingCollection = await this.Client.GetTenantConsentSettings(this, Pipeline);
242247

@@ -252,8 +257,11 @@ protected override void ProcessRecord()
252257
if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
253258

254259
RscConfigurationSynthesizer rscConfigurationConverter = new RscConfigurationSynthesizer();
255-
Models.IMicrosoftGraphRscConfiguration microsoftGraphRscConfiguration =
256-
rscConfigurationConverter.ConvertToTeamRscConfiguration(tenantConsentSettingCollection, authorizationPolicy, this);
260+
Models.IMicrosoftGraphRscConfiguration microsoftGraphRscConfiguration = rscConfigurationConverter.ConvertToTeamRscConfiguration(
261+
permissionGrantPolicyCollection,
262+
tenantConsentSettingCollection,
263+
authorizationPolicy,
264+
this);
257265

258266
WriteObject(microsoftGraphRscConfiguration);
259267

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System.Text;
2+
3+
namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
4+
{
5+
/// <summary>
6+
/// Request to get all permission grant policies in the tenant.
7+
/// </summary>
8+
internal class GetPermissionGrantPolicyCollectionRequest : TeamsHttpRequest
9+
{
10+
/// <summary>
11+
/// Select query.
12+
/// </summary>
13+
private readonly string selectQuery;
14+
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="GetPermissionGrantPolicyCollectionRequest"/> class.
17+
/// </summary>
18+
/// <param name="servicePrincipalId">The service principal Id.</param>
19+
internal GetPermissionGrantPolicyCollectionRequest(string selectQuery)
20+
{
21+
this.selectQuery = selectQuery;
22+
}
23+
24+
/// <summary>
25+
/// Gets the Http method for the request.
26+
/// </summary>
27+
/// <returns>The http method.</returns>
28+
protected override System.Net.Http.HttpMethod GetHttpMethod()
29+
{
30+
return Runtime.Method.Get;
31+
}
32+
33+
/// <summary>
34+
/// Gets the base url for the request.
35+
/// </summary>
36+
/// <returns>string containing the base url.</returns>
37+
protected override string GetBaseUrl()
38+
{
39+
StringBuilder sb = new StringBuilder();
40+
sb.Append("https://graph.microsoft.com/beta/policies/permissiongrantpolicies");
41+
if (this.selectQuery != null)
42+
{
43+
sb.Append($"?$select={this.selectQuery}");
44+
}
45+
46+
return sb.ToString();
47+
}
48+
49+
/// <summary>
50+
/// Gets the body of the request as a string.
51+
/// </summary>
52+
/// <returns>The body.</returns>
53+
protected override string GetBodyAsString()
54+
{
55+
return null;
56+
}
57+
}
58+
}

src/Teams/beta/custom/MicrosoftGraphRscConfigurationState.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ public enum MicrosoftGraphRscConfigurationState
2121
/// <summary>
2222
/// Enabled for all apps.
2323
/// </summary>
24-
EnabledForAllApps
24+
EnabledForAllApps,
25+
26+
/// <summary>
27+
/// Enabled for selected group of users.
28+
/// </summary>
29+
EnabledForSelectedGroupOfUsers,
30+
31+
/// <summary>
32+
/// Custom configuration not understood by the sdk.
33+
/// </summary>
34+
Custom
2535
}
2636
}

0 commit comments

Comments
 (0)