Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Teams custom cmdlets for Pre-Approval #1745

369 changes: 369 additions & 0 deletions src/Teams/beta/custom/GetMgBetaTeamAppPreApproval_Get.cs

Large diffs are not rendered by default.

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;
}
}
}
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();
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
Loading