-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Teams custom cmdlets for Pre-Approval (#1745)
* Stash * Taking PR comments. * Stash * Stash * Separating exception handler. * Adding extra validations. * Validate permission names for each scope. * Add sensitivity label validation * Fix bug in validator * Renaming files to be consistent with naming.
- Loading branch information
1 parent
9772bcc
commit cae1f90
Showing
43 changed files
with
5,305 additions
and
0 deletions.
There are no files selected for viewing
369 changes: 369 additions & 0 deletions
369
src/Teams/beta/custom/GetMgBetaTeamAppPreApproval_Get.cs
Large diffs are not rendered by default.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
...stom/HttpRequests/AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests | ||
{ | ||
using Microsoft.Graph.Beta.PowerShell.Runtime.Json; | ||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Request to associate service principal with permission grant preapproval policy. | ||
/// </summary> | ||
internal class AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest : TeamsHttpRequest | ||
{ | ||
/// <summary> | ||
/// The service principal Id. | ||
/// </summary> | ||
private string servicePrincipalId; | ||
|
||
/// <summary> | ||
/// The permission grant preapproval policy id. | ||
/// </summary> | ||
private string permissionGrantPreApprovalPolicyId; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest"/> class. | ||
/// </summary> | ||
/// <param name="servicePrincipalId">The service principal Id.</param> | ||
/// <param name="permissionGrantPreApprovalPolicyId">The preapproval policy Id.</param> | ||
internal AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest( | ||
string servicePrincipalId, | ||
string permissionGrantPreApprovalPolicyId) | ||
{ | ||
this.servicePrincipalId = servicePrincipalId; | ||
this.permissionGrantPreApprovalPolicyId = permissionGrantPreApprovalPolicyId; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the Http method for the request. | ||
/// </summary> | ||
/// <returns>The http method.</returns> | ||
protected override System.Net.Http.HttpMethod GetHttpMethod() | ||
{ | ||
return Runtime.Method.Post; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base url for the request. | ||
/// </summary> | ||
/// <returns>string containing the base url.</returns> | ||
protected override string GetBaseUrl() | ||
{ | ||
return $"https://graph.microsoft.com/beta/servicePrincipals/{this.servicePrincipalId}/permissionGrantPreApprovalPolicies/$ref"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the body of the request as a string. | ||
/// </summary> | ||
/// <returns>The body.</returns> | ||
protected override string GetBodyAsString() | ||
{ | ||
string body = | ||
new JsonObject( | ||
new Dictionary<string, string> | ||
{ | ||
{ | ||
"@odata.id", | ||
$"https://graph.microsoft.com/beta/policies/permissionGrantPreApprovalPolicies/{this.permissionGrantPreApprovalPolicyId}" | ||
} | ||
}); | ||
return body; | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/Teams/beta/custom/HttpRequests/CreatePermissionGrantPreApprovalPolicyRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests | ||
{ | ||
using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal; | ||
|
||
/// <summary> | ||
/// Request to create the given permission grant pre approval policy. | ||
/// </summary> | ||
internal class CreatePermissionGrantPreApprovalPolicyRequest : TeamsHttpRequest | ||
{ | ||
/// <summary> | ||
/// The preapproval policy to be created. | ||
/// </summary> | ||
private MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeCreated; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CreatePermissionGrantPreApprovalPolicyRequest"/> class. | ||
/// </summary> | ||
/// <param name="preApprovalPolicyToBeCreated">The preapproval policy to be created.</param> | ||
internal CreatePermissionGrantPreApprovalPolicyRequest( | ||
MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeCreated) | ||
{ | ||
this.preApprovalPolicyToBeCreated = preApprovalPolicyToBeCreated; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the Http method for the request. | ||
/// </summary> | ||
/// <returns>The http method.</returns> | ||
protected override System.Net.Http.HttpMethod GetHttpMethod() | ||
{ | ||
return Runtime.Method.Post; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base url for the request. | ||
/// </summary> | ||
/// <returns>string containing the base url.</returns> | ||
protected override string GetBaseUrl() | ||
{ | ||
return $"https://graph.microsoft.com/beta/policies/permissionGrantPreApprovalPolicies"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the body of the request as a string. | ||
/// </summary> | ||
/// <returns>The body.</returns> | ||
protected override string GetBodyAsString() | ||
{ | ||
return preApprovalPolicyToBeCreated.ToJson(); | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/Teams/beta/custom/HttpRequests/CreateServicePrincipalRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests | ||
{ | ||
using Microsoft.Graph.Beta.PowerShell.Runtime.Json; | ||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Request to create service principal. | ||
/// </summary> | ||
internal class CreateServicePrincipalRequest : TeamsHttpRequest | ||
{ | ||
/// <summary> | ||
/// The azure ad app id. | ||
/// </summary> | ||
private string azureAdAppId; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CreateServicePrincipalRequest"/> class. | ||
/// </summary> | ||
/// <param name="azureAdAppId">The AAd app Id.</param> | ||
/// <param name="permissionGrantPreApprovalPolicyId">The preapproval policy Id.</param> | ||
internal CreateServicePrincipalRequest(string azureAdAppId) | ||
{ | ||
this.azureAdAppId = azureAdAppId; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the Http method for the request. | ||
/// </summary> | ||
/// <returns>The http method.</returns> | ||
protected override System.Net.Http.HttpMethod GetHttpMethod() | ||
{ | ||
return Runtime.Method.Post; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base url for the request. | ||
/// </summary> | ||
/// <returns>string containing the base url.</returns> | ||
protected override string GetBaseUrl() | ||
{ | ||
return $"https://graph.microsoft.com/beta/servicePrincipals"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the body of the request as a string. | ||
/// </summary> | ||
/// <returns>The body.</returns> | ||
protected override string GetBodyAsString() | ||
{ | ||
string body = | ||
new JsonObject( | ||
new Dictionary<string, string> | ||
{ | ||
{ | ||
"appId", | ||
this.azureAdAppId | ||
} | ||
}); | ||
return body; | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
.../beta/custom/HttpRequests/GetMicrosoftGraphResourceSpecificPermissionCollectionRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests | ||
{ | ||
/// <summary> | ||
/// Request to get resource specific permissions for Microsoft Graph's service principal. | ||
/// </summary> | ||
internal class GetMicrosoftGraphResourceSpecificPermissionCollectionRequest : TeamsHttpRequest | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GetMicrosoftGraphResourceSpecificPermissionCollectionRequest"/> class. | ||
/// </summary> | ||
internal GetMicrosoftGraphResourceSpecificPermissionCollectionRequest() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets the Http method for the request. | ||
/// </summary> | ||
/// <returns>The http method.</returns> | ||
protected override System.Net.Http.HttpMethod GetHttpMethod() | ||
{ | ||
return Runtime.Method.Get; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base url for the request. | ||
/// </summary> | ||
/// <returns>string containing the base url.</returns> | ||
protected override string GetBaseUrl() | ||
{ | ||
return $"https://graph.microsoft.com/beta/serviceprincipals/appId=00000003-0000-0000-c000-000000000000/resourceSpecificApplicationPermissions"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the body of the request as a string. | ||
/// </summary> | ||
/// <returns>The body.</returns> | ||
protected override string GetBodyAsString() | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...ttpRequests/GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests | ||
{ | ||
/// <summary> | ||
/// Request to get permission grant pre approval policies associated with the service principal. | ||
/// </summary> | ||
internal class GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest : TeamsHttpRequest | ||
{ | ||
/// <summary> | ||
/// The service principal Id. | ||
/// </summary> | ||
private string servicePrincipalId; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest"/> class. | ||
/// </summary> | ||
/// <param name="servicePrincipalId">The service principal Id.</param> | ||
internal GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest(string servicePrincipalId) | ||
{ | ||
this.servicePrincipalId = servicePrincipalId; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the Http method for the request. | ||
/// </summary> | ||
/// <returns>The http method.</returns> | ||
protected override System.Net.Http.HttpMethod GetHttpMethod() | ||
{ | ||
return Runtime.Method.Get; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base url for the request. | ||
/// </summary> | ||
/// <returns>string containing the base url.</returns> | ||
protected override string GetBaseUrl() | ||
{ | ||
return $"https://graph.microsoft.com/beta/servicePrincipals/{servicePrincipalId}/permissionGrantPreApprovalPolicies"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the body of the request as a string. | ||
/// </summary> | ||
/// <returns>The body.</returns> | ||
protected override string GetBodyAsString() | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/Teams/beta/custom/HttpRequests/GetSensitivityLabelCollectionRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests | ||
{ | ||
/// <summary> | ||
/// Request to get sensitivity labels visible to current caller. | ||
/// </summary> | ||
internal class GetSensitivityLabelCollectionRequest : TeamsHttpRequest | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GetSensitivityLabelCollectionRequest"/> class. | ||
/// </summary> | ||
internal GetSensitivityLabelCollectionRequest() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets the Http method for the request. | ||
/// </summary> | ||
/// <returns>The http method.</returns> | ||
protected override System.Net.Http.HttpMethod GetHttpMethod() | ||
{ | ||
return Runtime.Method.Get; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base url for the request. | ||
/// </summary> | ||
/// <returns>string containing the base url.</returns> | ||
protected override string GetBaseUrl() | ||
{ | ||
return $"https://graph.microsoft.com/beta/me/security/informationProtection/sensitivityLabels"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the body of the request as a string. | ||
/// </summary> | ||
/// <returns>The body.</returns> | ||
protected override string GetBodyAsString() | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/Teams/beta/custom/HttpRequests/GetServicePrincipalRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests | ||
{ | ||
/// <summary> | ||
/// Request to get service principal. | ||
/// </summary> | ||
internal class GetServicePrincipalRequest : TeamsHttpRequest | ||
{ | ||
/// <summary> | ||
/// The AAD app id. | ||
/// </summary> | ||
private string azureAdAppId; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GetServicePrincipalRequest"/> class. | ||
/// </summary> | ||
/// <param name="azureAdAppId">The AAd app Id.</param> | ||
internal GetServicePrincipalRequest(string azureAdAppId) | ||
{ | ||
this.azureAdAppId = azureAdAppId; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the Http method for the request. | ||
/// </summary> | ||
/// <returns>The http method.</returns> | ||
protected override System.Net.Http.HttpMethod GetHttpMethod() | ||
{ | ||
return Runtime.Method.Get; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base url for the request. | ||
/// </summary> | ||
/// <returns>string containing the base url.</returns> | ||
protected override string GetBaseUrl() | ||
{ | ||
return $"https://graph.microsoft.com/beta/servicePrincipals/appId={this.azureAdAppId}"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the body of the request as a string. | ||
/// </summary> | ||
/// <returns>The body.</returns> | ||
protected override string GetBodyAsString() | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.