diff --git a/src/Teams/beta/custom/GetMgBetaTeamAppPreApproval_Get.cs b/src/Teams/beta/custom/GetMgBetaTeamAppPreApproval_Get.cs
new file mode 100644
index 00000000000..45e5c757520
--- /dev/null
+++ b/src/Teams/beta/custom/GetMgBetaTeamAppPreApproval_Get.cs
@@ -0,0 +1,369 @@
+namespace Microsoft.Graph.Beta.PowerShell.Cmdlets
+{
+ using Microsoft.Graph.Beta.PowerShell.TeamsInternal;
+ using System;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Get Preapproval policy associated with a Teams App.
+ ///
+ [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"MgBetaTeamAppPreApproval_Get")]
+ [global::System.Management.Automation.OutputType(typeof(Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApproval))]
+ [global::Microsoft.Graph.Beta.PowerShell.Description(@"Get Preapproval policy associated with a Teams App.")]
+ [global::Microsoft.Graph.Beta.PowerShell.Generated]
+ public partial class GetMgBetaTeamAppPreApproval_Get : global::System.Management.Automation.PSCmdlet,
+ Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener
+ {
+ /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet)
+ private global::System.Management.Automation.InvocationInfo __invocationInfo;
+
+ ///
+ /// The for this operation.
+ ///
+ private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource();
+
+ /// Wait for .NET debugger to attach
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.SwitchParameter Break { get; set; }
+
+ /// The reference to the client API class.
+ public Microsoft.Graph.Beta.PowerShell.Teams Client => Microsoft.Graph.Beta.PowerShell.Module.Instance.ClientAPI;
+
+ /// SendAsync Pipeline Steps to be appended to the front of the pipeline
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public Microsoft.Graph.Beta.PowerShell.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; }
+
+ /// SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public Microsoft.Graph.Beta.PowerShell.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; }
+
+ /// Accessor for our copy of the InvocationInfo.
+ public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation; set { __invocationInfo = value; } }
+
+ ///
+ /// cancellation delegate. Stops the cmdlet when called.
+ ///
+ global::System.Action Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel;
+
+ /// cancellation token.
+ global::System.Threading.CancellationToken Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Token => _cancellationTokenSource.Token;
+
+ ///
+ /// The instance of the that the remote call will use.
+ ///
+ private Microsoft.Graph.Beta.PowerShell.Runtime.HttpPipeline Pipeline { get; set; }
+
+ /// The URI for the proxy server to use
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Uri Proxy { get; set; }
+
+ /// Credentials for a proxy server to use for the remote call
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.PSCredential ProxyCredential { get; set; }
+
+ /// Use the default credentials for the proxy
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; }
+
+ /// Backing field for property.
+ private string _teamsAppId;
+
+ ///
+ /// Gets or sets the Teams App Id.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "key: id of Teams App")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Description = @"key: id of Teams App",
+ SerializedName = @"teamsAppId",
+ PossibleTypes = new[] { typeof(string) })]
+ public string TeamsAppId { get => this._teamsAppId; set => this._teamsAppId = value; }
+
+ ///
+ /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what
+ /// happens on that response. Implement this method in a partial class to enable this behavior
+ ///
+ /// the raw response message as an global::System.Net.Http.HttpResponseMessage.
+ /// the body result as a Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphODataErrorsOdataError
+ /// from the remote call
+ /// /// Determines if the rest of the onDefault method should be processed, or if the method should
+ /// return immediately (set to true to skip further processing )
+
+ partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow);
+
+ ///
+ /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens
+ /// on that response. Implement this method in a partial class to enable this behavior
+ ///
+ /// the raw response message as an global::System.Net.Http.HttpResponseMessage.
+ /// the body result as a Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamworkDevice
+ /// from the remote call
+ /// /// Determines if the rest of the onOk method should be processed, or if the method should return
+ /// immediately (set to true to skip further processing )
+
+ partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow);
+
+ ///
+ /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet)
+ ///
+ protected override void BeginProcessing()
+ {
+ Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);
+ if (Break)
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.AttachDebugger.Break();
+ }
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletBeginProcessing).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+
+ /// Performs clean-up after the command execution
+ protected override void EndProcessing()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletEndProcessing).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+
+ ///
+ /// Intializes a new instance of the cmdlet class.
+ ///
+ public GetMgBetaTeamAppPreApproval_Get()
+ {
+
+ }
+
+ /// Handles/Dispatches events during the call to the REST service.
+ /// The message id
+ /// The message cancellation token. When this call is cancelled, this should be true
+ /// Detailed message data for the message event.
+ ///
+ /// A that will be complete when handling of the message is completed.
+ ///
+ async global::System.Threading.Tasks.Task Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData)
+ {
+ using (NoSynchronizationContext)
+ {
+ if (token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ switch (id)
+ {
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Verbose:
+ {
+ WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Warning:
+ {
+ WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Information:
+ {
+ var data = messageData();
+ WriteInformation(data.Message, new string[] { });
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Debug:
+ {
+ WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Error:
+ {
+ WriteError(new global::System.Management.Automation.ErrorRecord(new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ return;
+ }
+ }
+ await Microsoft.Graph.Beta.PowerShell.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Graph.Beta.PowerShell.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Graph.Beta.PowerShell.Runtime.EventData), InvocationInformation, this.ParameterSetName, null);
+ if (token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ }
+ }
+
+ /// Performs execution of the command.
+ protected override void ProcessRecord()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordStart).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ try
+ {
+ // work
+ using (var asyncCommandRuntime = new Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token))
+ {
+ asyncCommandRuntime.Wait(ProcessRecordAsync(), ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token);
+ }
+ }
+ catch (global::System.AggregateException aggregateException)
+ {
+ // unroll the inner exceptions to get the root cause
+ foreach (var innerException in aggregateException.Flatten().InnerExceptions)
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ // Write exception out to error channel.
+ WriteError(new global::System.Management.Automation.ErrorRecord(innerException, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ }
+ }
+ catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException) == null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null)
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ // Write exception out to error channel.
+ WriteError(new global::System.Management.Automation.ErrorRecord(exception, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ }
+ finally
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordEnd).Wait();
+ }
+ }
+
+ /// Performs execution of the command, working asynchronously if required.
+ ///
+ /// A that will be complete when handling of the method is completed.
+ ///
+ protected async global::System.Threading.Tasks.Task ProcessRecordAsync()
+ {
+ using (NoSynchronizationContext)
+ {
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordAsyncStart); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletGetPipeline); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ Pipeline = Microsoft.Graph.Beta.PowerShell.Module.Instance.CreatePipeline(InvocationInformation, this.ParameterSetName);
+ if (null != HttpPipelinePrepend)
+ {
+ Pipeline.Prepend((this.CommandRuntime as Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend);
+ }
+ if (null != HttpPipelineAppend)
+ {
+ Pipeline.Append((this.CommandRuntime as Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend);
+ }
+ // get the client instance
+ try
+ {
+ 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; }
+
+ this.ValidateInputParameters();
+
+ // Get the Teams App
+ Models.IMicrosoftGraphTeamsApp teamsApp = await this.Client.GetTeamsApp(
+ this.TeamsAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Found Teams App with Id: '{teamsApp.Id}'");
+
+ Models.IMicrosoftGraphTeamsAppDefinition publishedAppDefinition =
+ teamsApp?.AppDefinitions?.SingleOrDefault(a => string.Equals(a.PublishingState, "published", StringComparison.OrdinalIgnoreCase));
+ if (publishedAppDefinition == null)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ResourceNotFound,
+ $"Published App Definition was not found for Teams App with Id: '{teamsApp.Id}'.");
+ }
+
+ if (string.IsNullOrEmpty(publishedAppDefinition.AzureAdAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.RequiredPropertyNotFound,
+ $"Teams App with Id: '{teamsApp.Id}' does not have a valid AAd App Id.");
+ }
+
+ WriteVerbose($"Found published Teams App Definition with AzureAdAppId: '{publishedAppDefinition.AzureAdAppId}'");
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ Models.IMicrosoftGraphEntity servicePrincipal = await this.Client.GetServicePrincipal(
+ publishedAppDefinition.AzureAdAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Found service principal with Id: '{servicePrincipal.Id}'");
+
+ // Validate no policies associated with sp
+ Models.TeamsInternal.MGTeamsInternalPermissionGrantPreApprovalPolicyCollection policiesAssociatedWithServicePrincipal =
+ await this.Client.GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipal(
+ servicePrincipal.Id,
+ this,
+ Pipeline);
+
+ int numOfPoliciesAssociatedWithServicePrincipal = policiesAssociatedWithServicePrincipal.Value?.Count() ?? 0;
+ if (numOfPoliciesAssociatedWithServicePrincipal == 0)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ResourceNotFound,
+ $"Service principal with Id: '{servicePrincipal.Id}' has no associated policy.");
+ }
+ else if (numOfPoliciesAssociatedWithServicePrincipal > 1)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.UnsupportedScenario,
+ $"Service principal with Id: '{servicePrincipal.Id}' has more than 1 associated pre-approval policy. Scenario is unsupported.");
+ }
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ Models.TeamsInternal.MGTeamsInternalResourceSpecificPermissionCollection rscPermissionCollection =
+ await this.Client.GetMicrosoftGraphResourceSpecificPermissionCollection(this, Pipeline);
+
+ TeamsAppPreApprovalPolicyConverter teamsAppPreApprovalPolicyConverter =
+ new TeamsAppPreApprovalPolicyConverter(rscPermissionCollection.Value);
+
+ Models.IMicrosoftGraphTeamsAppPreApproval teamsAppPreapproval =
+ await teamsAppPreApprovalPolicyConverter.ConvertToTeamsAppPreApproval(this.TeamsAppId, policiesAssociatedWithServicePrincipal.Value.Single());
+
+ WriteObject(teamsAppPreapproval);
+
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletAfterAPICall); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+ catch (System.Exception ex)
+ {
+ TeamsExceptionHandler.HandleException(
+ ex,
+ new
+ {
+ TeamsAppId = this.TeamsAppId,
+ },
+ errorRecord => WriteError(errorRecord),
+ this);
+ ((Runtime.IEventListener)this).Signal(Runtime.Events.CmdletException, $"{ex.GetType().Name} - {ex.Message} : {ex.StackTrace}").Wait();
+ if (((Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+ finally
+ {
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordAsyncEnd);
+ }
+ }
+ }
+
+ /// Interrupts currently running code within the command.
+ protected override void StopProcessing()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Cancel();
+ base.StopProcessing();
+ }
+
+ ///
+ /// Validate the input parameters of the cmdlet.
+ ///
+ private void ValidateInputParameters()
+ {
+ if (string.IsNullOrWhiteSpace(this.TeamsAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.TeamsAppId)}' cannot be empty.");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/HttpRequests/AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest.cs b/src/Teams/beta/custom/HttpRequests/AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest.cs
new file mode 100644
index 00000000000..2bf2daa6c22
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest.cs
@@ -0,0 +1,70 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ using Microsoft.Graph.Beta.PowerShell.Runtime.Json;
+ using System.Collections.Generic;
+
+ ///
+ /// Request to associate service principal with permission grant preapproval policy.
+ ///
+ internal class AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest : TeamsHttpRequest
+ {
+ ///
+ /// The service principal Id.
+ ///
+ private string servicePrincipalId;
+
+ ///
+ /// The permission grant preapproval policy id.
+ ///
+ private string permissionGrantPreApprovalPolicyId;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The service principal Id.
+ /// The preapproval policy Id.
+ internal AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest(
+ string servicePrincipalId,
+ string permissionGrantPreApprovalPolicyId)
+ {
+ this.servicePrincipalId = servicePrincipalId;
+ this.permissionGrantPreApprovalPolicyId = permissionGrantPreApprovalPolicyId;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Post;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/servicePrincipals/{this.servicePrincipalId}/permissionGrantPreApprovalPolicies/$ref";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ string body =
+ new JsonObject(
+ new Dictionary
+ {
+ {
+ "@odata.id",
+ $"https://graph.microsoft.com/beta/policies/permissionGrantPreApprovalPolicies/{this.permissionGrantPreApprovalPolicyId}"
+ }
+ });
+ return body;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/CreatePermissionGrantPreApprovalPolicyRequest.cs b/src/Teams/beta/custom/HttpRequests/CreatePermissionGrantPreApprovalPolicyRequest.cs
new file mode 100644
index 00000000000..24da3ee4039
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/CreatePermissionGrantPreApprovalPolicyRequest.cs
@@ -0,0 +1,52 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal;
+
+ ///
+ /// Request to create the given permission grant pre approval policy.
+ ///
+ internal class CreatePermissionGrantPreApprovalPolicyRequest : TeamsHttpRequest
+ {
+ ///
+ /// The preapproval policy to be created.
+ ///
+ private MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeCreated;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The preapproval policy to be created.
+ internal CreatePermissionGrantPreApprovalPolicyRequest(
+ MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeCreated)
+ {
+ this.preApprovalPolicyToBeCreated = preApprovalPolicyToBeCreated;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Post;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/policies/permissionGrantPreApprovalPolicies";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return preApprovalPolicyToBeCreated.ToJson();
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/CreateServicePrincipalRequest.cs b/src/Teams/beta/custom/HttpRequests/CreateServicePrincipalRequest.cs
new file mode 100644
index 00000000000..ab903e8988e
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/CreateServicePrincipalRequest.cs
@@ -0,0 +1,62 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ using Microsoft.Graph.Beta.PowerShell.Runtime.Json;
+ using System.Collections.Generic;
+
+ ///
+ /// Request to create service principal.
+ ///
+ internal class CreateServicePrincipalRequest : TeamsHttpRequest
+ {
+ ///
+ /// The azure ad app id.
+ ///
+ private string azureAdAppId;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The AAd app Id.
+ /// The preapproval policy Id.
+ internal CreateServicePrincipalRequest(string azureAdAppId)
+ {
+ this.azureAdAppId = azureAdAppId;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Post;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/servicePrincipals";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ string body =
+ new JsonObject(
+ new Dictionary
+ {
+ {
+ "appId",
+ this.azureAdAppId
+ }
+ });
+ return body;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/GetMicrosoftGraphResourceSpecificPermissionCollectionRequest.cs b/src/Teams/beta/custom/HttpRequests/GetMicrosoftGraphResourceSpecificPermissionCollectionRequest.cs
new file mode 100644
index 00000000000..fff539a311f
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/GetMicrosoftGraphResourceSpecificPermissionCollectionRequest.cs
@@ -0,0 +1,42 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ ///
+ /// Request to get resource specific permissions for Microsoft Graph's service principal.
+ ///
+ internal class GetMicrosoftGraphResourceSpecificPermissionCollectionRequest : TeamsHttpRequest
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal GetMicrosoftGraphResourceSpecificPermissionCollectionRequest()
+ {
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Get;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/serviceprincipals/appId=00000003-0000-0000-c000-000000000000/resourceSpecificApplicationPermissions";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest.cs b/src/Teams/beta/custom/HttpRequests/GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest.cs
new file mode 100644
index 00000000000..187d931c679
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest.cs
@@ -0,0 +1,49 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ ///
+ /// Request to get permission grant pre approval policies associated with the service principal.
+ ///
+ internal class GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest : TeamsHttpRequest
+ {
+ ///
+ /// The service principal Id.
+ ///
+ private string servicePrincipalId;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The service principal Id.
+ internal GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest(string servicePrincipalId)
+ {
+ this.servicePrincipalId = servicePrincipalId;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Get;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/servicePrincipals/{servicePrincipalId}/permissionGrantPreApprovalPolicies";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/GetSensitivityLabelCollectionRequest.cs b/src/Teams/beta/custom/HttpRequests/GetSensitivityLabelCollectionRequest.cs
new file mode 100644
index 00000000000..30f81eb9c17
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/GetSensitivityLabelCollectionRequest.cs
@@ -0,0 +1,42 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ ///
+ /// Request to get sensitivity labels visible to current caller.
+ ///
+ internal class GetSensitivityLabelCollectionRequest : TeamsHttpRequest
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal GetSensitivityLabelCollectionRequest()
+ {
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Get;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/me/security/informationProtection/sensitivityLabels";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/GetServicePrincipalRequest.cs b/src/Teams/beta/custom/HttpRequests/GetServicePrincipalRequest.cs
new file mode 100644
index 00000000000..dc21d064ded
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/GetServicePrincipalRequest.cs
@@ -0,0 +1,49 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ ///
+ /// Request to get service principal.
+ ///
+ internal class GetServicePrincipalRequest : TeamsHttpRequest
+ {
+ ///
+ /// The AAD app id.
+ ///
+ private string azureAdAppId;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The AAd app Id.
+ internal GetServicePrincipalRequest(string azureAdAppId)
+ {
+ this.azureAdAppId = azureAdAppId;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Get;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/servicePrincipals/appId={this.azureAdAppId}";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/GetTeamsAppRequest.cs b/src/Teams/beta/custom/HttpRequests/GetTeamsAppRequest.cs
new file mode 100644
index 00000000000..4f017f84da0
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/GetTeamsAppRequest.cs
@@ -0,0 +1,48 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ ///
+ /// Request to get Teams app.
+ ///
+ internal class GetTeamsAppRequest : TeamsHttpRequest
+ {
+ ///
+ /// The teams app Id.
+ ///
+ private string teamsAppId;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal GetTeamsAppRequest(string teamsAppId)
+ {
+ this.teamsAppId = teamsAppId;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Get;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/appCatalogs/teamsApps/{this.teamsAppId}?$expand=appDefinitions";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicyRequest.cs b/src/Teams/beta/custom/HttpRequests/RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicyRequest.cs
new file mode 100644
index 00000000000..9c9da91166d
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicyRequest.cs
@@ -0,0 +1,56 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ ///
+ /// Request to remove association between service principal and preapproval policy.
+ ///
+ internal class RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicyRequest : TeamsHttpRequest
+ {
+ ///
+ /// The service principal Id.
+ ///
+ private string servicePrincipalId;
+
+ ///
+ /// The pre approval policy Id.
+ ///
+ private string permissionGrantPreApprovalPolicyId;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicyRequest(
+ string servicePrincipalId,
+ string permissionGrantPreApprovalPolicyId)
+ {
+ this.servicePrincipalId = servicePrincipalId;
+ this.permissionGrantPreApprovalPolicyId = permissionGrantPreApprovalPolicyId;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Delete;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/servicePrincipals/{this.servicePrincipalId}/permissionGrantPreApprovalPolicies/{this.permissionGrantPreApprovalPolicyId}/$ref";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/RemovePermissionGrantPreApprovalPolicyRequest.cs b/src/Teams/beta/custom/HttpRequests/RemovePermissionGrantPreApprovalPolicyRequest.cs
new file mode 100644
index 00000000000..5f7e0ec7592
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/RemovePermissionGrantPreApprovalPolicyRequest.cs
@@ -0,0 +1,48 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ ///
+ /// Request to remove permission grant preapproval policy.
+ ///
+ internal class RemovePermissionGrantPreApprovalPolicyRequest : TeamsHttpRequest
+ {
+ ///
+ /// The policy id.
+ ///
+ private string policyId;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal RemovePermissionGrantPreApprovalPolicyRequest(string policyId)
+ {
+ this.policyId = policyId;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Delete;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/policies/permissionGrantPreApprovalPolicies/{this.policyId}";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/TeamsHttpRequest.cs b/src/Teams/beta/custom/HttpRequests/TeamsHttpRequest.cs
new file mode 100644
index 00000000000..ca589c8890d
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/TeamsHttpRequest.cs
@@ -0,0 +1,46 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ ///
+ /// Teams HTTP Request.
+ ///
+ internal abstract class TeamsHttpRequest
+ {
+ ///
+ /// Get Http Request message for this instance.
+ ///
+ /// HTTP request message.
+ internal System.Net.Http.HttpRequestMessage GetHttpRequestMessage()
+ {
+ string baseUrl = this.GetBaseUrl();
+ var _url = new System.Uri(baseUrl);
+ var request = new System.Net.Http.HttpRequestMessage(this.GetHttpMethod(), _url);
+
+ // set body content
+ var body = this.GetBodyAsString();
+ if (body != null )
+ {
+ request.Content = new System.Net.Http.StringContent(body, System.Text.Encoding.UTF8);
+ request.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ }
+ return request;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected abstract System.Net.Http.HttpMethod GetHttpMethod();
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected abstract string GetBaseUrl();
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected abstract string GetBodyAsString();
+ }
+}
diff --git a/src/Teams/beta/custom/HttpRequests/UpdatePermissionGrantPreApprovalPolicyRequest.cs b/src/Teams/beta/custom/HttpRequests/UpdatePermissionGrantPreApprovalPolicyRequest.cs
new file mode 100644
index 00000000000..dcf7da4b89c
--- /dev/null
+++ b/src/Teams/beta/custom/HttpRequests/UpdatePermissionGrantPreApprovalPolicyRequest.cs
@@ -0,0 +1,58 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests
+{
+ using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal;
+
+ ///
+ /// Request to update preapproval policy.
+ ///
+ internal class UpdatePermissionGrantPreApprovalPolicyRequest : TeamsHttpRequest
+ {
+ ///
+ /// The policy id.
+ ///
+ private string policyId;
+
+ ///
+ /// The policy contents.
+ ///
+ private MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeUpdated;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal UpdatePermissionGrantPreApprovalPolicyRequest(
+ string policyId,
+ MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeUpdated)
+ {
+ this.policyId = policyId;
+ this.preApprovalPolicyToBeUpdated = preApprovalPolicyToBeUpdated;
+ }
+
+ ///
+ /// Gets the Http method for the request.
+ ///
+ /// The http method.
+ protected override System.Net.Http.HttpMethod GetHttpMethod()
+ {
+ return Runtime.Method.Patch;
+ }
+
+ ///
+ /// Gets the base url for the request.
+ ///
+ /// string containing the base url.
+ protected override string GetBaseUrl()
+ {
+ return $"https://graph.microsoft.com/beta/policies/permissionGrantPreApprovalPolicies/{this.policyId}";
+ }
+
+ ///
+ /// Gets the body of the request as a string.
+ ///
+ /// The body.
+ protected override string GetBodyAsString()
+ {
+ return preApprovalPolicyToBeUpdated.ToJson();
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/MicrosoftGraphSensitivityLabelSelectionMode.cs b/src/Teams/beta/custom/MicrosoftGraphSensitivityLabelSelectionMode.cs
new file mode 100644
index 00000000000..6ee55a97a95
--- /dev/null
+++ b/src/Teams/beta/custom/MicrosoftGraphSensitivityLabelSelectionMode.cs
@@ -0,0 +1,23 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models
+{
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Microsoft Sensitivity label selection mode.
+ ///
+ public enum MicrosoftGraphSensitivityLabelCondition
+ {
+ ///
+ /// Pre approval policy will be applied on any sensitivity label (or absence of).
+ ///
+ AnySensitivityLabel,
+
+ ///
+ /// Pre approval policy will be applied on specific sentivity labels.
+ ///
+ SpecificSensivityLabel
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.PowerShell.cs b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.PowerShell.cs
new file mode 100644
index 00000000000..9bcdd3fdcc9
--- /dev/null
+++ b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.PowerShell.cs
@@ -0,0 +1,229 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models
+{
+ using Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell;
+ using System;
+
+ /// conversationMember
+ [System.ComponentModel.TypeConverter(typeof(MicrosoftGraphTeamsAppPreapprovalTypeConverter))]
+ public partial class MicrosoftGraphTeamsAppPreApproval
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApproval DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new MicrosoftGraphTeamsAppPreApproval(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApproval DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new MicrosoftGraphTeamsAppPreApproval(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApproval FromJsonString(string jsonText) => FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal MicrosoftGraphTeamsAppPreApproval(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+
+ // actually deserialize
+ if (content.Contains("TeamsAppId"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).TeamsAppId = (string)content.GetValueForProperty("TeamsAppId", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).TeamsAppId, global::System.Convert.ToString);
+ }
+
+ if (content.Contains("ResourceSpecificApplicationPermissionsAllowedForTeams"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).ResourceSpecificApplicationPermissionsAllowedForTeams = (string[])content.GetValueForProperty("ResourceSpecificApplicationPermissionsAllowedForTeams", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).ResourceSpecificApplicationPermissionsAllowedForTeams, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString));
+ }
+
+ if (content.Contains("ResourceSpecificApplicationPermissionsAllowedForChats"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).ResourceSpecificApplicationPermissionsAllowedForChats = (string[])content.GetValueForProperty("ResourceSpecificApplicationPermissionsAllowedForChats", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).ResourceSpecificApplicationPermissionsAllowedForChats, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString));
+ }
+
+ if (content.Contains("TeamLevelSensitivityLabelCondition"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).TeamLevelSensitivityLabelCondition =
+ (MicrosoftGraphSensitivityLabelCondition?)content.GetValueForProperty(
+ "TeamLevelSensitivityLabelCondition",
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).TeamLevelSensitivityLabelCondition,
+ o =>
+ {
+ if (Enum.TryParse(
+ System.Convert.ToString(o),
+ out MicrosoftGraphSensitivityLabelCondition parsedObj))
+ {
+ return parsedObj;
+ }
+
+ return null;
+ });
+ }
+
+ if (content.Contains("SpecificSensitivityLabelIdsApplicableToTeams"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).SpecificSensitivityLabelIdsApplicableToTeams = (string[])content.GetValueForProperty("SpecificSensitivityLabelIdsApplicableToTeams", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).SpecificSensitivityLabelIdsApplicableToTeams, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString));
+ }
+
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphEntityInternal)this).Id = (string)content.GetValueForProperty("Id", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphEntityInternal)this).Id, global::System.Convert.ToString);
+ }
+
+ // this type is a dictionary; copy elements from source to here.
+ CopyFrom(content);
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal MicrosoftGraphTeamsAppPreApproval(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+
+ // actually deserialize
+ if (content.Contains("TeamsAppId"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).TeamsAppId = (string)content.GetValueForProperty("TeamsAppId", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).TeamsAppId, global::System.Convert.ToString);
+ }
+
+ if (content.Contains("ResourceSpecificApplicationPermissionsAllowedForTeams"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).ResourceSpecificApplicationPermissionsAllowedForTeams = (string[])content.GetValueForProperty("ResourceSpecificApplicationPermissionsAllowedForTeams", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).ResourceSpecificApplicationPermissionsAllowedForTeams, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString));
+ }
+
+ if (content.Contains("ResourceSpecificApplicationPermissionsAllowedForChats"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).ResourceSpecificApplicationPermissionsAllowedForChats = (string[])content.GetValueForProperty("ResourceSpecificApplicationPermissionsAllowedForChats", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).ResourceSpecificApplicationPermissionsAllowedForChats, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString));
+ }
+
+ if (content.Contains("TeamLevelSensitivityLabelCondition"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).TeamLevelSensitivityLabelCondition =
+ (MicrosoftGraphSensitivityLabelCondition?)content.GetValueForProperty(
+ "TeamLevelSensitivityLabelCondition",
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).TeamLevelSensitivityLabelCondition,
+ o =>
+ {
+ if (Enum.TryParse(
+ System.Convert.ToString(o),
+ out MicrosoftGraphSensitivityLabelCondition parsedObj))
+ {
+ return parsedObj;
+ }
+
+ return null;
+ });
+ }
+
+ if (content.Contains("SpecificSensitivityLabelIdsApplicableToTeams"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).SpecificSensitivityLabelIdsApplicableToTeams = (string[])content.GetValueForProperty("SpecificSensitivityLabelIdsApplicableToTeams", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApprovalInternal)this).SpecificSensitivityLabelIdsApplicableToTeams, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString));
+ }
+
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphEntityInternal)this).Id = (string)content.GetValueForProperty("Id", ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphEntityInternal)this).Id, global::System.Convert.ToString);
+ }
+
+ // this type is a dictionary; copy elements from source to here.
+ CopyFrom(content);
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Graph.Beta.PowerShell.Runtime.SerializationMode.IncludeAll)?.ToString();
+ }
+ /// conversationMember
+ [System.ComponentModel.TypeConverter(typeof(MicrosoftGraphTeamsAppPreapprovalTypeConverter))]
+ public partial interface IMicrosoftGraphTeamsAppPreApproval
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.TypeConverter.cs b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.TypeConverter.cs
new file mode 100644
index 00000000000..d338447a107
--- /dev/null
+++ b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.TypeConverter.cs
@@ -0,0 +1,146 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models
+{
+ using Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class MicrosoftGraphTeamsAppPreapprovalTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false.
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true, will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApproval ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApproval).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return MicrosoftGraphTeamsAppPreApproval.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()); ;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return MicrosoftGraphConversationMember.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return MicrosoftGraphConversationMember.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true, will ignore the case when converting.
+ /// will always return null.
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.cs b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.cs
new file mode 100644
index 00000000000..ac9b21f8427
--- /dev/null
+++ b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.cs
@@ -0,0 +1,234 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models
+{
+ using Microsoft.Graph.Beta.PowerShell.TeamsInternal;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Model representing association between a Teams App and Preapproval policies.
+ ///
+ public partial class MicrosoftGraphTeamsAppPreApproval :
+ IMicrosoftGraphTeamsAppPreApproval,
+ IMicrosoftGraphTeamsAppPreApprovalInternal,
+ Runtime.IValidates
+ {
+ ///
+ /// Backing field for Inherited model
+ ///
+ private Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphEntity __microsoftGraphEntity = new Microsoft.Graph.Beta.PowerShell.Models.MicrosoftGraphEntity();
+
+ /// The unique identifier for an entity. Read-only.
+ [Microsoft.Graph.Beta.PowerShell.Origin(Microsoft.Graph.Beta.PowerShell.PropertyOrigin.Inherited)]
+ public string Id { get => ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphEntityInternal)__microsoftGraphEntity).Id; set => ((Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphEntityInternal)__microsoftGraphEntity).Id = value ?? null; }
+
+ /// Backing field for property.
+ private string _teamsAppId;
+
+ ///
+ /// Gets or sets the Teams App Id.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Origin(Microsoft.Graph.Beta.PowerShell.PropertyOrigin.Owned)]
+ public string TeamsAppId { get => this._teamsAppId; set => this._teamsAppId = value; }
+
+ /// Backing field for property.
+ private MicrosoftGraphSensitivityLabelCondition? _teamLevelSensitivityLabelCondition;
+
+ ///
+ /// Label selection mode for teams.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Origin(Microsoft.Graph.Beta.PowerShell.PropertyOrigin.Owned)]
+ public MicrosoftGraphSensitivityLabelCondition? TeamLevelSensitivityLabelCondition { get => this._teamLevelSensitivityLabelCondition; set => this._teamLevelSensitivityLabelCondition = value; }
+
+ /// Backing field for property.
+ private string[] _resourceSpecificApplicationPermissionsAllowedForTeams;
+
+ ///
+ /// Resource Specific Permissions Allowed for Teams.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Origin(Microsoft.Graph.Beta.PowerShell.PropertyOrigin.Owned)]
+ public string[] ResourceSpecificApplicationPermissionsAllowedForTeams { get => this._resourceSpecificApplicationPermissionsAllowedForTeams; set => this._resourceSpecificApplicationPermissionsAllowedForTeams = value; }
+
+ /// Backing field for property.
+ private string[] _resourceSpecificApplicationPermissionsAllowedForChats;
+
+ ///
+ /// Resource Specific Permissions Allowed for chats.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Origin(Microsoft.Graph.Beta.PowerShell.PropertyOrigin.Owned)]
+ public string[] ResourceSpecificApplicationPermissionsAllowedForChats { get => this._resourceSpecificApplicationPermissionsAllowedForChats; set => this._resourceSpecificApplicationPermissionsAllowedForChats = value; }
+
+ /// Backing field for property.
+ private string[] _specificSensitivityLabelIdsApplicableToTeams;
+
+ ///
+ /// Specific Sensitivity label ids applicable to Teams.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Origin(Microsoft.Graph.Beta.PowerShell.PropertyOrigin.Owned)]
+ public string[] SpecificSensitivityLabelIdsApplicableToTeams { get => this._specificSensitivityLabelIdsApplicableToTeams; set => this._specificSensitivityLabelIdsApplicableToTeams = value; }
+
+ /// Creates an new instance.
+ public MicrosoftGraphTeamsAppPreApproval()
+ {
+
+ }
+
+ /// Validates that this object meets the validation criteria.
+ /// an instance that will receive validation
+ /// events.
+ ///
+ /// A that will be complete when validation is completed.
+ ///
+ public async global::System.Threading.Tasks.Task Validate(Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener eventListener)
+ {
+ await eventListener.AssertNotNull(nameof(__microsoftGraphEntity), __microsoftGraphEntity);
+ await eventListener.AssertObjectIsValid(nameof(__microsoftGraphEntity), __microsoftGraphEntity);
+
+ if (string.IsNullOrWhiteSpace(this.TeamsAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.TeamsAppId)}' cannot be empty.");
+ }
+
+ if (this.TeamLevelSensitivityLabelCondition == null)
+ {
+ if (this.ResourceSpecificApplicationPermissionsAllowedForTeams != null || this.SpecificSensitivityLabelIdsApplicableToTeams != null)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.ResourceSpecificApplicationPermissionsAllowedForTeams)}' and '{nameof(this.SpecificSensitivityLabelIdsApplicableToTeams)}' are not allowed without specifying '{nameof(this.TeamLevelSensitivityLabelCondition)}'.");
+ }
+ }
+ else if (this.TeamLevelSensitivityLabelCondition == MicrosoftGraphSensitivityLabelCondition.AnySensitivityLabel)
+ {
+ if (this.SpecificSensitivityLabelIdsApplicableToTeams?.Any() == true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.SpecificSensitivityLabelIdsApplicableToTeams)}' cannot be specified for '{nameof(this.TeamLevelSensitivityLabelCondition)}' : '{this.TeamLevelSensitivityLabelCondition}'.");
+ }
+
+ if (this.ResourceSpecificApplicationPermissionsAllowedForTeams?.Any() != true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.ResourceSpecificApplicationPermissionsAllowedForTeams)}' must be specified for '{nameof(this.TeamLevelSensitivityLabelCondition)}' : '{this.TeamLevelSensitivityLabelCondition}'.");
+ }
+ }
+ else if (this.TeamLevelSensitivityLabelCondition == MicrosoftGraphSensitivityLabelCondition.SpecificSensivityLabel)
+ {
+ if (this.SpecificSensitivityLabelIdsApplicableToTeams?.Any() != true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.SpecificSensitivityLabelIdsApplicableToTeams)}' must be specified for '{nameof(this.TeamLevelSensitivityLabelCondition)}' : '{this.TeamLevelSensitivityLabelCondition}'.");
+ }
+
+ if (this.ResourceSpecificApplicationPermissionsAllowedForTeams?.Any() != true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.ResourceSpecificApplicationPermissionsAllowedForTeams)}' must be specified for '{nameof(this.TeamLevelSensitivityLabelCondition)}' : '{this.TeamLevelSensitivityLabelCondition}'.");
+ }
+ }
+ }
+ }
+
+ ///
+ /// Model representing association between a Teams App and Preapproval policies.
+ ///
+ public partial interface IMicrosoftGraphTeamsAppPreApproval :
+ Microsoft.Graph.Beta.PowerShell.Runtime.IJsonSerializable,
+ IMicrosoftGraphEntity
+ {
+ ///
+ /// Gets or sets the Teams App Id.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"teamsAppId",
+ SerializedName = @"key: id of Teams App",
+ PossibleTypes = new[] { typeof(string) })]
+ string TeamsAppId { get; set; }
+
+ ///
+ /// Resource Specific Permissions Allowed for Teams.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Resource Specific Permissions Allowed for Teams",
+ SerializedName = @"resourceSpecificApplicationPermissionsAllowedForTeams",
+ PossibleTypes = new[] { typeof(string) })]
+ string[] ResourceSpecificApplicationPermissionsAllowedForTeams { get; set; }
+
+ ///
+ /// Resource Specific Permissions Allowed for chats.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Resource Specific Permissions Allowed for Chats",
+ SerializedName = @"resourceSpecificApplicationPermissionsAllowedForChats",
+ PossibleTypes = new[] { typeof(string) })]
+ string[] ResourceSpecificApplicationPermissionsAllowedForChats { get; set; }
+
+ ///
+ /// Label selection mode for teams.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Label selection mode for teams",
+ SerializedName = @"teamLevelSensitivityLabelCondition",
+ PossibleTypes = new[] { typeof(string) })]
+ MicrosoftGraphSensitivityLabelCondition? TeamLevelSensitivityLabelCondition { get; set; }
+
+ ///
+ /// Specific Sensitivity label ids applicable to Teams.
+ ///
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Specific Sensitivity label ids applicable to Teams",
+ SerializedName = @"specificSensitivityLabelIdsApplicableToTeams",
+ PossibleTypes = new[] { typeof(string) })]
+ string[] SpecificSensitivityLabelIdsApplicableToTeams { get; set; }
+ }
+
+ ///
+ /// Internal model representing association between a Teams App and Preapproval policies.
+ ///
+ internal partial interface IMicrosoftGraphTeamsAppPreApprovalInternal :
+ IMicrosoftGraphEntityInternal
+ {
+ ///
+ /// Gets or sets the Teams App Id.
+ ///
+ string TeamsAppId { get; set; }
+
+ ///
+ /// Resource Specific Permissions Allowed for Teams.
+ ///
+ string[] ResourceSpecificApplicationPermissionsAllowedForTeams { get; set; }
+
+ ///
+ /// Resource Specific Permissions Allowed for chats.
+ ///
+ string[] ResourceSpecificApplicationPermissionsAllowedForChats { get; set; }
+
+ ///
+ /// Label selection mode for teams.
+ ///
+ MicrosoftGraphSensitivityLabelCondition? TeamLevelSensitivityLabelCondition { get; set; }
+
+ ///
+ /// Specific Sensitivity label ids applicable to Teams.
+ ///
+ string[] SpecificSensitivityLabelIdsApplicableToTeams { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.dictionary.cs b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.dictionary.cs
new file mode 100644
index 00000000000..25834e14ee9
--- /dev/null
+++ b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.dictionary.cs
@@ -0,0 +1,63 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models
+{
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ public partial class MicrosoftGraphTeamsAppPreApproval :
+ Microsoft.Graph.Beta.PowerShell.Runtime.IAssociativeArray
+ {
+
+ global::System.Collections.Generic.IDictionary Microsoft.Graph.Beta.PowerShell.Runtime.IAssociativeArray.AdditionalProperties { get => __microsoftGraphEntity.AdditionalProperties; }
+
+ [System.Runtime.CompilerServices.IndexerName("EntityItem")]
+ public global::System.Object this[global::System.String index] { get => __microsoftGraphEntity[index]; set => __microsoftGraphEntity[index] = value; }
+
+ ///
+ ///
+ public void Add(global::System.String key, global::System.Object value) => __microsoftGraphEntity.Add(key, value);
+
+ public void Clear() => __microsoftGraphEntity.Clear();
+
+ ///
+ public bool ContainsKey(global::System.String key) => __microsoftGraphEntity.ContainsKey(key);
+
+ ///
+ public void CopyFrom(global::System.Collections.IDictionary source)
+ {
+ if (null != source)
+ {
+ foreach (var property in Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { "Id", "TeamsAppId", "ResourceSpecificApplicationPermissionsAllowedForTeams", "ResourceSpecificApplicationPermissionsAllowedForChats", "TeamLevelSensitivityLabelSelectionMode", "SpecificSensitivityLabelIdsApplicableToTeams" }))
+ {
+ if ((null != property.Key && null != property.Value))
+ {
+ this.__microsoftGraphEntity.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo(property.Value));
+ }
+ }
+ }
+ }
+
+ ///
+ public void CopyFrom(global::System.Management.Automation.PSObject source)
+ {
+ if (null != source)
+ {
+ foreach (var property in Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { "Id", "TeamsAppId", "ResourceSpecificApplicationPermissionsAllowedForTeams", "ResourceSpecificApplicationPermissionsAllowedForChats", "TeamLevelSensitivityLabelSelectionMode", "SpecificSensitivityLabelIdsApplicableToTeams" }))
+ {
+ if ((null != property.Key && null != property.Value))
+ {
+ this.__microsoftGraphEntity.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo(property.Value));
+ }
+ }
+ }
+ }
+
+ ///
+ public bool Remove(global::System.String key) => __microsoftGraphEntity.Remove(key);
+
+ ///
+ ///
+ public bool TryGetValue(global::System.String key, out global::System.Object value) => __microsoftGraphEntity.TryGetValue(key, out value);
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.json.cs b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.json.cs
new file mode 100644
index 00000000000..3bfe417822f
--- /dev/null
+++ b/src/Teams/beta/custom/MicrosoftGraphTeamsAppPreApproval.json.cs
@@ -0,0 +1,158 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models
+{
+ using System;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ /// teamsApp
+ public partial class MicrosoftGraphTeamsAppPreApproval
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json);
+
+ partial void AfterToJson(ref Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject container, Microsoft.Graph.Beta.PowerShell.Runtime.SerializationMode serializationMode);
+
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsApp.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsApp.
+ public static Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApproval FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json ? new MicrosoftGraphTeamsAppPreApproval(json, new global::System.Collections.Generic.HashSet() { @"id", @"resourceSpecificApplicationPermissionsAllowedForTeams", @"resourceSpecificApplicationPermissionsAllowedForChats", @"teamLevelSensitivityLabelSelectionMode", @"specificSensitivityLabelIdsApplicableToTeams" }) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject instance to deserialize from.
+ ///
+ internal MicrosoftGraphTeamsAppPreApproval(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json, global::System.Collections.Generic.HashSet exclusions = null)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+
+ __microsoftGraphEntity = new Microsoft.Graph.Beta.PowerShell.Models.MicrosoftGraphEntity(json, new global::System.Collections.Generic.HashSet((exclusions ?? new System.Collections.Generic.HashSet())) { @"id", @"teamsAppId", @"resourceSpecificApplicationPermissionsAllowedForTeams", @"resourceSpecificApplicationPermissionsAllowedForChats", @"teamLevelSensitivityLabelSelectionMode", @"specificSensitivityLabelIdsApplicableToTeams" });
+ { _teamsAppId = If(json?.PropertyT("teamsAppId"), out var __jsonTeamsAppId) ? (string)__jsonTeamsAppId : (string)TeamsAppId; }
+ { _resourceSpecificApplicationPermissionsAllowedForTeams = If(json?.PropertyT("resourceSpecificApplicationPermissionsAllowedForTeams"), out var __jsonResourceSpecificApplicationPermissionsAllowedForTeams) ? If(__jsonResourceSpecificApplicationPermissionsAllowedForTeams as Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(() => global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u) => (string)(__u is Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null))))() : null : ResourceSpecificApplicationPermissionsAllowedForTeams; }
+ { _resourceSpecificApplicationPermissionsAllowedForChats = If(json?.PropertyT("resourceSpecificApplicationPermissionsAllowedForChats"), out var __jsonResourceSpecificApplicationPermissionsAllowedForChats) ? If(__jsonResourceSpecificApplicationPermissionsAllowedForChats as Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(() => global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u) => (string)(__u is Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null))))() : null : ResourceSpecificApplicationPermissionsAllowedForChats; }
+ { _teamLevelSensitivityLabelCondition =
+ If(json?.PropertyT("teamLevelSensitivityLabelCondition"), out var __jsonTeamLevelSensitivityLabelSelectionMode)
+ ? (MicrosoftGraphSensitivityLabelCondition?)Enum.Parse(typeof(MicrosoftGraphSensitivityLabelCondition?), __jsonTeamLevelSensitivityLabelSelectionMode.ToString())
+ : TeamLevelSensitivityLabelCondition;
+ }
+ { _specificSensitivityLabelIdsApplicableToTeams = If(json?.PropertyT("specificSensitivityLabelIdsApplicableToTeams"), out var __jsonSpecificSensitivityLabelIdsApplicableToTeams) ? If(__jsonSpecificSensitivityLabelIdsApplicableToTeams as Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(() => global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u) => (string)(__u is Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null))))() : null : SpecificSensitivityLabelIdsApplicableToTeams; }
+
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null, a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject container, Microsoft.Graph.Beta.PowerShell.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+
+ __microsoftGraphEntity?.ToJson(container, serializationMode);
+
+ AddIf(null != (((object)this._teamsAppId)?.ToString()) ? (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this._teamLevelSensitivityLabelCondition.ToString()) : null, "teamsAppId", container.Add);
+
+ if (null != this._resourceSpecificApplicationPermissionsAllowedForTeams)
+ {
+ var __w = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.XNodeArray();
+ foreach (var __x in this._resourceSpecificApplicationPermissionsAllowedForTeams)
+ {
+ AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(__x.ToString()) : null, __w.Add);
+ }
+ container.Add("resourceSpecificApplicationPermissionsAllowedForTeams", __w);
+ }
+
+ if (null != this._resourceSpecificApplicationPermissionsAllowedForChats)
+ {
+ var __w = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.XNodeArray();
+ foreach (var __x in this._resourceSpecificApplicationPermissionsAllowedForChats)
+ {
+ AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(__x.ToString()) : null, __w.Add);
+ }
+ container.Add("resourceSpecificApplicationPermissionsAllowedForChats", __w);
+ }
+
+ AddIf(null != (((object)this._teamLevelSensitivityLabelCondition)?.ToString()) ? (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this._teamLevelSensitivityLabelCondition.ToString()) : null, "teamLevelSensitivityLabelSelectionMode", container.Add);
+
+ if (null != this._specificSensitivityLabelIdsApplicableToTeams)
+ {
+ var __w = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.XNodeArray();
+ foreach (var __x in this._specificSensitivityLabelIdsApplicableToTeams)
+ {
+ AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(__x.ToString()) : null, __w.Add);
+ }
+ container.Add("specificSensitivityLabelIdsApplicableToTeams", __w);
+ }
+
+ AfterToJson(ref container);
+ AfterToJson(ref container, serializationMode);
+
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/NewMgBetaTeamAppPreapproval_Create.cs b/src/Teams/beta/custom/NewMgBetaTeamAppPreapproval_Create.cs
new file mode 100644
index 00000000000..ef0ef76acb1
--- /dev/null
+++ b/src/Teams/beta/custom/NewMgBetaTeamAppPreapproval_Create.cs
@@ -0,0 +1,518 @@
+namespace Microsoft.Graph.Beta.PowerShell.Cmdlets
+{
+ using Microsoft.Graph.Beta.PowerShell.Models;
+ using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal;
+ using Microsoft.Graph.Beta.PowerShell.TeamsInternal;
+ using System;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Create Preapproval policy associated with a Teams App.
+ ///
+ [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"MgBetaTeamAppPreApproval_Create", SupportsShouldProcess = true)]
+ [global::System.Management.Automation.OutputType(typeof(Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppPreApproval))]
+ [global::Microsoft.Graph.Beta.PowerShell.Description(@"Create Preapproval policy associated with a Teams App.")]
+ [global::Microsoft.Graph.Beta.PowerShell.Generated]
+ public partial class NewMgBetaTeamAppPreapproval_Create : global::System.Management.Automation.PSCmdlet,
+ Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener
+ {
+ ///
+ /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet).
+ ///
+ private global::System.Management.Automation.InvocationInfo __invocationInfo;
+
+ ///
+ /// The for this operation.
+ ///
+ private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource();
+
+ /// Wait for .NET debugger to attach
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.SwitchParameter Break { get; set; }
+
+ /// The reference to the client API class.
+ public Microsoft.Graph.Beta.PowerShell.Teams Client => Microsoft.Graph.Beta.PowerShell.Module.Instance.ClientAPI;
+
+ /// Backing field for property.
+ private string _teamsAppId;
+
+ ///
+ /// Gets or sets the Teams App Id.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "key: id of Teams App")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Description = @"key: id of Teams App",
+ SerializedName = @"teamsAppId",
+ PossibleTypes = new[] { typeof(string) })]
+ public string TeamsAppId { get => this._teamsAppId; set => this._teamsAppId = value; }
+
+ /// Backing field for property.
+ private string[] _resourceSpecificApplicationPermissionsAllowedForTeams;
+
+ ///
+ /// Resource Specific Permissions Allowed for Teams.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Resource Specific Permissions Allowed for Teams")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Resource Specific Permissions Allowed for Teams",
+ SerializedName = @"resourceSpecificApplicationPermissionsAllowedForTeams",
+ PossibleTypes = new[] { typeof(string) })]
+ public string[] ResourceSpecificApplicationPermissionsAllowedForTeams { get => this._resourceSpecificApplicationPermissionsAllowedForTeams; set => this._resourceSpecificApplicationPermissionsAllowedForTeams = value; }
+
+ ///
+ /// Backing field for property.
+ ///
+ private string[] _resourceSpecificApplicationPermissionsAllowedForChats;
+
+ ///
+ /// Resource Specific Permissions Allowed for chats.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Resource Specific Permissions Allowed for Chats")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Resource Specific Permissions Allowed for Chats",
+ SerializedName = @"resourceSpecificApplicationPermissionsAllowedForChats",
+ PossibleTypes = new[] { typeof(string) })]
+ public string[] ResourceSpecificApplicationPermissionsAllowedForChats { get => this._resourceSpecificApplicationPermissionsAllowedForChats; set => this._resourceSpecificApplicationPermissionsAllowedForChats = value; }
+
+ ///
+ /// Backing field for property.
+ ///
+ private MicrosoftGraphSensitivityLabelCondition? _teamLevelSensitivityLabelCondition;
+
+ ///
+ /// Label selection mode for teams.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Label selection mode for Teams.")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Label selection mode for Teams.",
+ SerializedName = @"teamLevelSensitivityLabelCondition",
+ PossibleTypes = new[] { typeof(MicrosoftGraphSensitivityLabelCondition?) })]
+ public MicrosoftGraphSensitivityLabelCondition? TeamLevelSensitivityLabelCondition { get => this._teamLevelSensitivityLabelCondition; set => this._teamLevelSensitivityLabelCondition = value; }
+
+ /// Backing field for property.
+ private string[] _specificSensitivityLabelIdsApplicableToTeams;
+
+ ///
+ /// Specific Sensitivity label ids applicable to Teams.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Specific Sensitivity label ids applicable to Teams.")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Specific Sensitivity label ids applicable to Teams.",
+ SerializedName = @"specificSensitivityLabelIdsApplicableToTeams",
+ PossibleTypes = new[] { typeof(string) })]
+ public string[] SpecificSensitivityLabelIdsApplicableToTeams { get => this._specificSensitivityLabelIdsApplicableToTeams; set => this._specificSensitivityLabelIdsApplicableToTeams = value; }
+
+ /// SendAsync Pipeline Steps to be appended to the front of the pipeline
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public Microsoft.Graph.Beta.PowerShell.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; }
+
+ /// SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public Microsoft.Graph.Beta.PowerShell.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; }
+
+ /// Accessor for our copy of the InvocationInfo.
+ public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation; set { __invocationInfo = value; } }
+
+ ///
+ /// cancellation delegate. Stops the cmdlet when called.
+ ///
+ global::System.Action Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel;
+
+ /// cancellation token.
+ global::System.Threading.CancellationToken Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Token => _cancellationTokenSource.Token;
+
+ ///
+ /// The instance of the that the remote call will use.
+ ///
+ private Microsoft.Graph.Beta.PowerShell.Runtime.HttpPipeline Pipeline { get; set; }
+
+ /// The URI for the proxy server to use
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Uri Proxy { get; set; }
+
+ /// Credentials for a proxy server to use for the remote call
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.PSCredential ProxyCredential { get; set; }
+
+ /// Use the default credentials for the proxy
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; }
+
+ ///
+ /// overrideOnCreated will be called before the regular onCreated has been processed, allowing customization of what
+ /// happens on that response. Implement this method in a partial class to enable this behavior
+ ///
+ /// the raw response message as an global::System.Net.Http.HttpResponseMessage.
+ /// the body result as a Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsAppInstallation
+ /// from the remote call
+ /// /// Determines if the rest of the onCreated method should be processed, or if the method should
+ /// return immediately (set to true to skip further processing )
+
+ partial void overrideOnCreated(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow);
+
+ ///
+ /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what
+ /// happens on that response. Implement this method in a partial class to enable this behavior
+ ///
+ /// the raw response message as an global::System.Net.Http.HttpResponseMessage.
+ /// the body result as a Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphODataErrorsOdataError
+ /// from the remote call
+ /// /// Determines if the rest of the onDefault method should be processed, or if the method should
+ /// return immediately (set to true to skip further processing )
+
+ partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow);
+
+ ///
+ /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet)
+ ///
+ protected override void BeginProcessing()
+ {
+ Microsoft.Graph.Beta.PowerShell.Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);
+ if (Break)
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.AttachDebugger.Break();
+ }
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletBeginProcessing).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+
+ /// Performs clean-up after the command execution
+ protected override void EndProcessing()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletEndProcessing).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+
+ /// Handles/Dispatches events during the call to the REST service.
+ /// The message id
+ /// The message cancellation token. When this call is cancelled, this should be true
+ /// Detailed message data for the message event.
+ ///
+ /// A that will be complete when handling of the message is completed.
+ ///
+ async global::System.Threading.Tasks.Task Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData)
+ {
+ using (NoSynchronizationContext)
+ {
+ if (token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ switch (id)
+ {
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Verbose:
+ {
+ WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Warning:
+ {
+ WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Information:
+ {
+ var data = messageData();
+ WriteInformation(data.Message, new string[] { });
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Debug:
+ {
+ WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Error:
+ {
+ WriteError(new global::System.Management.Automation.ErrorRecord(new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ return;
+ }
+ }
+ await Microsoft.Graph.Beta.PowerShell.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Graph.Beta.PowerShell.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Graph.Beta.PowerShell.Runtime.EventData), InvocationInformation, this.ParameterSetName, null);
+ if (token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ }
+ }
+
+ ///
+ /// Intializes a new instance of the cmdlet class.
+ ///
+ public NewMgBetaTeamAppPreapproval_Create()
+ {
+
+ }
+
+ /// Performs execution of the command.
+ protected override void ProcessRecord()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordStart).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ try
+ {
+ // work
+ if (ShouldProcess("Create Teams App PreApproval"))
+ {
+ using (var asyncCommandRuntime = new Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token))
+ {
+ asyncCommandRuntime.Wait(ProcessRecordAsync(), ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token);
+ }
+ }
+ }
+ catch (global::System.AggregateException aggregateException)
+ {
+ // unroll the inner exceptions to get the root cause
+ foreach (var innerException in aggregateException.Flatten().InnerExceptions)
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ // Write exception out to error channel.
+ WriteError(new global::System.Management.Automation.ErrorRecord(innerException, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ }
+ }
+ catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException) == null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null)
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ // Write exception out to error channel.
+ WriteError(new global::System.Management.Automation.ErrorRecord(exception, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ }
+ finally
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordEnd).Wait();
+ }
+ }
+
+ ///
+ /// Performs execution of the command, working asynchronously if required.
+ ///
+ ///
+ /// A that will be complete when handling of the method is completed.
+ ///
+ protected async global::System.Threading.Tasks.Task ProcessRecordAsync()
+ {
+ using (NoSynchronizationContext)
+ {
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordAsyncStart); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletGetPipeline); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ Pipeline = Microsoft.Graph.Beta.PowerShell.Module.Instance.CreatePipeline(InvocationInformation, this.ParameterSetName);
+ if (null != HttpPipelinePrepend)
+ {
+ Pipeline.Prepend((this.CommandRuntime as Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend);
+ }
+ if (null != HttpPipelineAppend)
+ {
+ Pipeline.Append((this.CommandRuntime as Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend);
+ }
+ // get the client instance
+ try
+ {
+ 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; }
+
+ this.ValidateInputParameters();
+
+ // Get sensitivity labels.
+ MGTeamsInternalSensitivityLabelCollection sensitivityLabelCollection = await this.Client.GetSensitivityLabelCollection(
+ this,
+ Pipeline);
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ TeamsAppPreApprovalValidator teamsAppPreApprovalValidator = new TeamsAppPreApprovalValidator(sensitivityLabelCollection);
+ teamsAppPreApprovalValidator.ValidateConditionsForTeamsAppPreApproval(
+ this.TeamsAppId,
+ this.ResourceSpecificApplicationPermissionsAllowedForChats,
+ this.TeamLevelSensitivityLabelCondition,
+ this.SpecificSensitivityLabelIdsApplicableToTeams,
+ this.ResourceSpecificApplicationPermissionsAllowedForTeams);
+
+ // Get the Teams App
+ Models.IMicrosoftGraphTeamsApp teamsApp = await this.Client.GetTeamsApp(
+ this.TeamsAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Found Teams App with Id: '{teamsApp.Id}'");
+
+ Models.IMicrosoftGraphTeamsAppDefinition publishedAppDefinition =
+ teamsApp?.AppDefinitions?.SingleOrDefault(a => string.Equals(a.PublishingState, "published", StringComparison.OrdinalIgnoreCase));
+ if (publishedAppDefinition == null)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ResourceNotFound,
+ $"Published App Definition was not found for Teams App with Id: '{teamsApp.Id}'.");
+ }
+
+ if (string.IsNullOrEmpty(publishedAppDefinition.AzureAdAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.RequiredPropertyNotFound,
+ $"Teams App with Id: '{teamsApp.Id}' does not have a valid AAd App Id.");
+ }
+
+ WriteVerbose($"Found published Teams App Definition with AzureAdAppId: '{publishedAppDefinition.AzureAdAppId}'");
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ Models.IMicrosoftGraphEntity servicePrincipal = null;
+ bool isServicePrincipalCreationNeeded = false;
+ try
+ {
+ servicePrincipal = await this.Client.GetServicePrincipal(
+ publishedAppDefinition.AzureAdAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Found service principal with Id: '{servicePrincipal.Id}'");
+ }
+ catch (MGTeamsInternalServiceRequestException ex)
+ {
+ if (ex.HttpStatusCode == System.Net.HttpStatusCode.NotFound)
+ {
+ WriteVerbose($"Could not find service principal for AAD app with Id: '{publishedAppDefinition.AzureAdAppId}'");
+ isServicePrincipalCreationNeeded = true;
+ }
+ else
+ {
+ throw;
+ }
+ }
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ if (isServicePrincipalCreationNeeded)
+ {
+ servicePrincipal = await this.Client.CreateServicePrincipal(
+ publishedAppDefinition.AzureAdAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Created service principal with Id: '{servicePrincipal.Id}'");
+ }
+ else
+ {
+ // Validate no policies associated with sp
+ MGTeamsInternalPermissionGrantPreApprovalPolicyCollection policiesAssociatedWithServicePrincipal =
+ await this.Client.GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipal(
+ servicePrincipal.Id,
+ this,
+ Pipeline);
+
+ if (policiesAssociatedWithServicePrincipal.Value?.Any() == true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ConflictingUpdate,
+ $"Service principal with Id: '{servicePrincipal.Id}' already has associated pre approval policies.");
+ }
+ else
+ {
+ WriteVerbose($"No preapproval policies associated with service principal Id: '{servicePrincipal.Id}'.");
+ }
+ }
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ MGTeamsInternalResourceSpecificPermissionCollection rscPermissionCollection =
+ await this.Client.GetMicrosoftGraphResourceSpecificPermissionCollection(this, Pipeline);
+
+ TeamsAppPreApprovalPolicyConverter teamsAppPreApprovalPolicyConverter =
+ new TeamsAppPreApprovalPolicyConverter(rscPermissionCollection.Value);
+
+ MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeCreated =
+ await teamsAppPreApprovalPolicyConverter.ConvertToPermissionGrantPreApprovalPolicy(
+ this.ResourceSpecificApplicationPermissionsAllowedForChats,
+ this.TeamLevelSensitivityLabelCondition,
+ this.SpecificSensitivityLabelIdsApplicableToTeams,
+ this.ResourceSpecificApplicationPermissionsAllowedForTeams);
+
+ WriteVerbose($"PreApprovalPolicy to be created: '{preApprovalPolicyToBeCreated.ToJson()}'");
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ MGTeamsInternalPermissionGrantPreApprovalPolicy createdPreApprovalPolicy =
+ await this.Client.CreatePermissionGrantPreApprovalPolicy(
+ preApprovalPolicyToBeCreated,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Created preapproval policy with Id '{createdPreApprovalPolicy.Id}'.");
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ await this.Client.AssociateServicePrincipalWithPermissionGrantPreApprovalPolicy(
+ servicePrincipal.Id,
+ createdPreApprovalPolicy.Id,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Associated service principal '{servicePrincipal.Id}' with preapproval policy '{createdPreApprovalPolicy.Id}'.");
+
+ IMicrosoftGraphTeamsAppPreApproval createdObject =
+ await teamsAppPreApprovalPolicyConverter.ConvertToTeamsAppPreApproval(this.TeamsAppId, createdPreApprovalPolicy);
+
+ WriteObject(createdObject);
+
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletAfterAPICall); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+ catch (System.Exception ex)
+ {
+ TeamsExceptionHandler.HandleException(
+ ex,
+ new
+ {
+ TeamsAppId = this.TeamsAppId,
+ TeamLevelSensitivityLabelCondition = this.TeamLevelSensitivityLabelCondition,
+ SpecificSensitivityLabelIdsApplicableToTeams = this.SpecificSensitivityLabelIdsApplicableToTeams,
+ ResourceSpecificApplicationPermissionsAllowedForTeams = this.ResourceSpecificApplicationPermissionsAllowedForTeams,
+ ResourceSpecificApplicationPermissionsAllowedForChats = this.ResourceSpecificApplicationPermissionsAllowedForChats,
+ },
+ errorRecord => WriteError(errorRecord),
+ this);
+ ((Runtime.IEventListener)this).Signal(Runtime.Events.CmdletException, $"{ex.GetType().Name} - {ex.Message} : {ex.StackTrace}").Wait();
+ if (((Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+ finally
+ {
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordAsyncEnd);
+ }
+ }
+ }
+
+ /// Interrupts currently running code within the command.
+ protected override void StopProcessing()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Cancel();
+ base.StopProcessing();
+ }
+
+ ///
+ /// Validate the input parameters of the cmdlet.
+ ///
+ private void ValidateInputParameters()
+ {
+ if (string.IsNullOrWhiteSpace(this.TeamsAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.TeamsAppId)}' cannot be empty.");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/RemoveMgBetaTeamAppPreApproval_Delete.cs b/src/Teams/beta/custom/RemoveMgBetaTeamAppPreApproval_Delete.cs
new file mode 100644
index 00000000000..3a1cfc1cddd
--- /dev/null
+++ b/src/Teams/beta/custom/RemoveMgBetaTeamAppPreApproval_Delete.cs
@@ -0,0 +1,345 @@
+namespace Microsoft.Graph.Beta.PowerShell.Cmdlets
+{
+ using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal;
+ using Microsoft.Graph.Beta.PowerShell.TeamsInternal;
+ using System;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Delete PreApproval policy associated with a Teams App.
+ ///
+ [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Remove, @"MgBetaTeamsAppPreApproval_Delete", SupportsShouldProcess = true)]
+ [global::System.Management.Automation.OutputType(typeof(bool))]
+ [global::Microsoft.Graph.Beta.PowerShell.Description(@"Delete Preapproval policy associated with a Teams App.")]
+ [global::Microsoft.Graph.Beta.PowerShell.Generated]
+ public partial class RemoveMgBetaTeamAppPreApproval_Delete : global::System.Management.Automation.PSCmdlet,
+ Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener
+ {
+ /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet)
+ private global::System.Management.Automation.InvocationInfo __invocationInfo;
+
+ ///
+ /// The for this operation.
+ ///
+ private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource();
+
+ /// Wait for .NET debugger to attach
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.SwitchParameter Break { get; set; }
+
+ /// Backing field for property.
+ private string _teamsAppId;
+
+ ///
+ /// Gets or sets the Teams App Id.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "key: id of Teams App")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Description = @"key: id of Teams App",
+ SerializedName = @"teamsAppId",
+ PossibleTypes = new[] { typeof(string) })]
+ public string TeamsAppId { get => this._teamsAppId; set => this._teamsAppId = value; }
+
+ /// The reference to the client API class.
+ public Microsoft.Graph.Beta.PowerShell.Teams Client => Microsoft.Graph.Beta.PowerShell.Module.Instance.ClientAPI;
+
+ /// SendAsync Pipeline Steps to be appended to the front of the pipeline
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public Microsoft.Graph.Beta.PowerShell.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; }
+
+ /// SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public Microsoft.Graph.Beta.PowerShell.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; }
+
+ /// Accessor for our copy of the InvocationInfo.
+ public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation; set { __invocationInfo = value; } }
+
+ ///
+ /// cancellation delegate. Stops the cmdlet when called.
+ ///
+ global::System.Action Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel;
+
+ /// cancellation token.
+ global::System.Threading.CancellationToken Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Token => _cancellationTokenSource.Token;
+
+ ///
+ /// The instance of the that the remote call will use.
+ ///
+ private Microsoft.Graph.Beta.PowerShell.Runtime.HttpPipeline Pipeline { get; set; }
+
+ /// The URI for the proxy server to use
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Uri Proxy { get; set; }
+
+ /// Credentials for a proxy server to use for the remote call
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.PSCredential ProxyCredential { get; set; }
+
+ /// Use the default credentials for the proxy
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; }
+
+ ///
+ /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what
+ /// happens on that response. Implement this method in a partial class to enable this behavior
+ ///
+ /// the raw response message as an global::System.Net.Http.HttpResponseMessage.
+ /// the body result as a Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphODataErrorsOdataError
+ /// from the remote call
+ /// /// Determines if the rest of the onDefault method should be processed, or if the method should
+ /// return immediately (set to true to skip further processing )
+
+ partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow);
+
+ ///
+ /// overrideOnNoContent will be called before the regular onNoContent has been processed, allowing customization of
+ /// what happens on that response. Implement this method in a partial class to enable this behavior
+ ///
+ /// the raw response message as an global::System.Net.Http.HttpResponseMessage.
+ /// /// Determines if the rest of the onNoContent method should be processed, or if the method should
+ /// return immediately (set to true to skip further processing )
+
+ partial void overrideOnNoContent(global::System.Net.Http.HttpResponseMessage responseMessage, ref global::System.Threading.Tasks.Task returnNow);
+
+ ///
+ /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet)
+ ///
+ protected override void BeginProcessing()
+ {
+ Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);
+ if (Break)
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.AttachDebugger.Break();
+ }
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletBeginProcessing).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+
+ /// Performs clean-up after the command execution
+ protected override void EndProcessing()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletEndProcessing).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+
+ /// Handles/Dispatches events during the call to the REST service.
+ /// The message id
+ /// The message cancellation token. When this call is cancelled, this should be true
+ /// Detailed message data for the message event.
+ ///
+ /// A that will be complete when handling of the message is completed.
+ ///
+ async global::System.Threading.Tasks.Task Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData)
+ {
+ using (NoSynchronizationContext)
+ {
+ if (token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ switch (id)
+ {
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Verbose:
+ {
+ WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Warning:
+ {
+ WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Information:
+ {
+ var data = messageData();
+ WriteInformation(data.Message, new string[] { });
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Debug:
+ {
+ WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Error:
+ {
+ WriteError(new global::System.Management.Automation.ErrorRecord(new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ return;
+ }
+ }
+ await Microsoft.Graph.Beta.PowerShell.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Graph.Beta.PowerShell.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Graph.Beta.PowerShell.Runtime.EventData), InvocationInformation, this.ParameterSetName, null);
+ if (token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ }
+ }
+
+ /// Performs execution of the command.
+ protected override void ProcessRecord()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordStart).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ try
+ {
+ // work
+ if (ShouldProcess("Delete Teams App Pre Approval."))
+ {
+ using (var asyncCommandRuntime = new Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token))
+ {
+ asyncCommandRuntime.Wait(ProcessRecordAsync(), ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token);
+ }
+ }
+ }
+ catch (global::System.AggregateException aggregateException)
+ {
+ // unroll the inner exceptions to get the root cause
+ foreach (var innerException in aggregateException.Flatten().InnerExceptions)
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ // Write exception out to error channel.
+ WriteError(new global::System.Management.Automation.ErrorRecord(innerException, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ }
+ }
+ catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException) == null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null)
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ // Write exception out to error channel.
+ WriteError(new global::System.Management.Automation.ErrorRecord(exception, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ }
+ finally
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordEnd).Wait();
+ }
+ }
+
+ /// Performs execution of the command, working asynchronously if required.
+ ///
+ /// A that will be complete when handling of the method is completed.
+ ///
+ protected async global::System.Threading.Tasks.Task ProcessRecordAsync()
+ {
+ using (NoSynchronizationContext)
+ {
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordAsyncStart); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletGetPipeline); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ Pipeline = Microsoft.Graph.Beta.PowerShell.Module.Instance.CreatePipeline(InvocationInformation, this.ParameterSetName);
+ if (null != HttpPipelinePrepend)
+ {
+ Pipeline.Prepend((this.CommandRuntime as Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend);
+ }
+ if (null != HttpPipelineAppend)
+ {
+ Pipeline.Append((this.CommandRuntime as Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend);
+ }
+ // get the client instance
+ try
+ {
+ 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; }
+
+ // Get the Teams App
+ Models.IMicrosoftGraphTeamsApp teamsApp = await this.Client.GetTeamsApp(
+ this.TeamsAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Found Teams App with Id: '{teamsApp.Id}'");
+
+ Models.IMicrosoftGraphTeamsAppDefinition publishedAppDefinition =
+ teamsApp?.AppDefinitions?.SingleOrDefault(a => string.Equals(a.PublishingState, "published", StringComparison.OrdinalIgnoreCase));
+ if (publishedAppDefinition == null)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ResourceNotFound,
+ $"Published App Definition was not found for Teams App with Id: '{teamsApp.Id}'.");
+ }
+
+ if (string.IsNullOrEmpty(publishedAppDefinition.AzureAdAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.RequiredPropertyNotFound,
+ $"Teams App with Id: '{teamsApp.Id}' does not have a valid AAd App Id.");
+ }
+
+ WriteVerbose($"Found published Teams App Definition with AzureAdAppId: '{publishedAppDefinition.AzureAdAppId}'");
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ Models.IMicrosoftGraphEntity servicePrincipal = await this.Client.GetServicePrincipal(
+ publishedAppDefinition.AzureAdAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Found service principal with Id: '{servicePrincipal.Id}'");
+
+ // Validate no policies associated with sp
+ MGTeamsInternalPermissionGrantPreApprovalPolicyCollection policiesAssociatedWithServicePrincipal =
+ await this.Client.GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipal(
+ servicePrincipal.Id,
+ this,
+ Pipeline);
+
+ foreach (MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicy in policiesAssociatedWithServicePrincipal.Value)
+ {
+ await this.Client.RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicy(
+ servicePrincipal.Id,
+ preApprovalPolicy.Id,
+ this,
+ Pipeline);
+
+ await this.Client.RemovePermissionGrantPreApprovalPolicy(
+ preApprovalPolicy.Id,
+ this,
+ Pipeline);
+ }
+
+ this.WriteObject(true);
+
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletAfterAPICall); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+ catch (System.Exception ex)
+ {
+ TeamsExceptionHandler.HandleException(
+ ex,
+ new
+ {
+ TeamsAppId = this.TeamsAppId,
+ },
+ errorRecord => WriteError(errorRecord),
+ this);
+ ((Runtime.IEventListener)this).Signal(Runtime.Events.CmdletException, $"{ex.GetType().Name} - {ex.Message} : {ex.StackTrace}").Wait();
+ if (((Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+ finally
+ {
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordAsyncEnd);
+ }
+ }
+ }
+
+ ///
+ /// Intializes a new instance of the cmdlet class.
+ ///
+ public RemoveMgBetaTeamAppPreApproval_Delete()
+ {
+
+ }
+
+ /// Interrupts currently running code within the command.
+ protected override void StopProcessing()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Cancel();
+ base.StopProcessing();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/Teams.cs b/src/Teams/beta/custom/Teams.cs
new file mode 100644
index 00000000000..78d1340d4d9
--- /dev/null
+++ b/src/Teams/beta/custom/Teams.cs
@@ -0,0 +1,401 @@
+namespace Microsoft.Graph.Beta.PowerShell
+{
+ using Microsoft.Graph.Beta.PowerShell.Cmdlets;
+ using Microsoft.Graph.Beta.PowerShell.TeamsInternal.Requests;
+ using Microsoft.Graph.Beta.PowerShell.Runtime.Json;
+ using System;
+ using System.Collections.Generic;
+ using System.Threading.Tasks;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+ using Microsoft.Graph.Beta.PowerShell.TeamsInternal;
+ using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal;
+
+ public partial class Teams
+ {
+ ///
+ /// Get teams app with given id.
+ ///
+ /// The teams app id.
+ /// The event listener.
+ /// Http Request sender.
+ /// Teams app.
+ public async System.Threading.Tasks.Task GetTeamsApp(
+ string teamsAppId,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ GetTeamsAppRequest getTeamsAppRequest = new GetTeamsAppRequest(teamsAppId);
+
+ return await this.ExecuteHttpRequestAsync(
+ getTeamsAppRequest,
+ json => Models.MicrosoftGraphTeamsApp.FromJson(json),
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Get service principal for the given azure app Id.
+ ///
+ /// The azure AD app Id.
+ /// The event listener.
+ /// The http request sender.
+ /// Service principal.
+ public async System.Threading.Tasks.Task GetServicePrincipal(
+ string azureAdAppId,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ GetServicePrincipalRequest getServicePrincipalRequest = new GetServicePrincipalRequest(azureAdAppId);
+
+ return await this.ExecuteHttpRequestAsync(
+ getServicePrincipalRequest,
+ json => Models.MicrosoftGraphEntity.FromJson(json),
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Create service principal for the given azure AD app Id.
+ ///
+ /// Azure AD app Id.
+ /// The event listener.
+ /// The http request sender.
+ /// Service Principal.
+ internal async System.Threading.Tasks.Task CreateServicePrincipal(
+ string azureAdAppId,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ CreateServicePrincipalRequest createServicePrincipalRequest = new CreateServicePrincipalRequest(azureAdAppId);
+
+ return await this.ExecuteHttpRequestAsync(
+ createServicePrincipalRequest,
+ json => Models.MicrosoftGraphEntity.FromJson(json),
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Get permission grant policies associated with the given service principal.
+ ///
+ /// The service principal Id.
+ /// The event listener.
+ /// The http request sender.
+ /// Preapproval policy collection.
+ internal async System.Threading.Tasks.Task GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipal(
+ string servicePrincipalId,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest request =
+ new GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipalRequest(servicePrincipalId);
+
+ return await this.ExecuteHttpRequestAsync(
+ request,
+ json => MGTeamsInternalPermissionGrantPreApprovalPolicyCollection.FromJson(json),
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Get resource specific permissions registered in Microsoft Graph.
+ ///
+ /// The event listener.
+ /// The http request sender.
+ /// RSC permission collection.
+ internal async System.Threading.Tasks.Task GetMicrosoftGraphResourceSpecificPermissionCollection(
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ GetMicrosoftGraphResourceSpecificPermissionCollectionRequest request =
+ new GetMicrosoftGraphResourceSpecificPermissionCollectionRequest();
+
+ return await this.ExecuteHttpRequestAsync(
+ request,
+ json => MGTeamsInternalResourceSpecificPermissionCollection.FromJson(json),
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Create permission grant preapproval policy.
+ ///
+ /// The preapproval policy to be created.
+ /// The event listener.
+ /// The http request sender.
+ /// Preapproval policy.
+ internal async System.Threading.Tasks.Task CreatePermissionGrantPreApprovalPolicy(
+ MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeCreated,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ CreatePermissionGrantPreApprovalPolicyRequest request =
+ new CreatePermissionGrantPreApprovalPolicyRequest(preApprovalPolicyToBeCreated);
+
+ return await this.ExecuteHttpRequestAsync(
+ request,
+ json => MGTeamsInternalPermissionGrantPreApprovalPolicy.FromJson(json),
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Update permission grant policy.
+ ///
+ /// The policy Id.
+ /// The updated policy.
+ /// The event listener.
+ /// Http request sender.
+ /// Task tracking operation.
+ internal async Task UpdatePermissionGrantPreApprovalPolicy(
+ string policyId,
+ MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicyToBeUpdated,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ UpdatePermissionGrantPreApprovalPolicyRequest request =
+ new UpdatePermissionGrantPreApprovalPolicyRequest(policyId, preApprovalPolicyToBeUpdated);
+
+ await this.ExecuteHttpRequestAsync(
+ request,
+ null,
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Remove the given pemission grant policy.
+ ///
+ /// The policy Id.
+ /// The event listener.
+ /// The http request sender.
+ /// Task tracking operation.
+ internal async Task RemovePermissionGrantPreApprovalPolicy(
+ string policyId,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ RemovePermissionGrantPreApprovalPolicyRequest request =
+ new RemovePermissionGrantPreApprovalPolicyRequest(policyId);
+
+ await this.ExecuteHttpRequestAsync(
+ request,
+ null,
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Associate SP with preapproval policy.
+ ///
+ /// The service principal Id.
+ /// The preapproval policy Id.
+ /// The event listener.
+ /// Http request sender.
+ /// Task tracking operation.
+ internal async Task AssociateServicePrincipalWithPermissionGrantPreApprovalPolicy(
+ string servicePrincipalId,
+ string permissionGrantPreApprovalPolicyId,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest request =
+ new AssociateServicePrincipalWithPermissionGrantPreApprovalPolicyRequest(
+ servicePrincipalId,
+ permissionGrantPreApprovalPolicyId);
+
+ await this.ExecuteHttpRequestAsync(
+ request,
+ outputConverter: null,
+ eventListener: eventListener,
+ sender: sender);
+ }
+ }
+
+ ///
+ /// Remove association between service principal and preapproval policy.
+ ///
+ /// The service principal Id.
+ /// The pre approval policy Id.
+ /// The event listener.
+ /// Http request sender.
+ /// Task tracking operation.
+ internal async Task RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicy(
+ string servicePrincipalId,
+ string permissionGrantPreApprovalPolicyId,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicyRequest request =
+ new RemoveAssociationBetweenServicePrincipalAndPreapprovalPolicyRequest(
+ servicePrincipalId,
+ permissionGrantPreApprovalPolicyId);
+
+ await this.ExecuteHttpRequestAsync(
+ request,
+ outputConverter: null,
+ eventListener: eventListener,
+ sender: sender);
+ }
+ }
+
+ ///
+ /// Get sensitivity labels visible to current caller.
+ ///
+ /// The event listener.
+ /// The http request sender.
+ /// Sensitivity label collection.
+ internal async System.Threading.Tasks.Task GetSensitivityLabelCollection(
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender)
+ {
+ // Constant Parameters
+ using (NoSynchronizationContext)
+ {
+ GetSensitivityLabelCollectionRequest request =
+ new GetSensitivityLabelCollectionRequest();
+
+ return await this.ExecuteHttpRequestAsync(
+ request,
+ json => MGTeamsInternalSensitivityLabelCollection.FromJson(json),
+ eventListener,
+ sender);
+ }
+ }
+
+ ///
+ /// Execute HTTP request.
+ ///
+ /// The type of the response object.
+ /// The http request.
+ /// Converter from json to the output type.
+ /// The event listener.
+ /// The HTTP request sender.
+ /// The result object.
+ private async Task ExecuteHttpRequestAsync(
+ TeamsHttpRequest teamsHttpRequest,
+ System.Func outputConverter,
+ Runtime.IEventListener eventListener,
+ Runtime.ISendAsync sender) where T : class
+ {
+ using (NoSynchronizationContext)
+ {
+ System.Net.Http.HttpRequestMessage request = null;
+ System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+
+ request = teamsHttpRequest.GetHttpRequestMessage();
+
+ await eventListener.Signal(Runtime.Events.BeforeCall, request);
+ _response = await sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Runtime.Events.ResponseCreated, _response);
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ this.LogResponseInformation(_response, eventListener);
+ await eventListener.Signal(Runtime.Events.BeforeResponseDispatch, _response);
+
+ string responseBody = await _response.Content.ReadAsStringAsync();
+ if (_response.IsSuccessStatusCode)
+ {
+ if (typeof(T) == typeof(MGTeamsInternalGenericEmptyResponse))
+ {
+ return MGTeamsInternalGenericEmptyResponse.LazyInstance.Value as T;
+ }
+
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode responseAsJsonNode = Runtime.Json.JsonNode.Parse(responseBody);
+ return outputConverter(responseAsJsonNode);
+ }
+ else
+ {
+ throw new MGTeamsInternalServiceRequestException(
+ _response.StatusCode,
+ Models.MicrosoftGraphODataErrorsOdataError.FromJson(Runtime.Json.JsonNode.Parse(responseBody)));
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Log Response Information.
+ ///
+ /// The http response.
+ /// The event listener.
+ private void LogResponseInformation(System.Net.Http.HttpResponseMessage response, Runtime.IEventListener eventListener)
+ {
+ string requestId = response.GetFirstHeader("request-id");
+ string clientRequestId = response.GetFirstHeader("client-request-id");
+ string date = response.GetFirstHeader("Date");
+
+ if (string.IsNullOrEmpty(requestId) || string.IsNullOrEmpty(clientRequestId) || string.IsNullOrEmpty(date))
+ {
+ this.LogVerbose($"Invoked Http request with Url: '{response.RequestMessage.Method.Method} {response.RequestMessage.RequestUri}', ResponseCode: '{response.StatusCode}'.", eventListener);
+ this.LogVerbose($"Response headers: '{response.Headers.ToString()}'.", eventListener);
+ }
+ else
+ {
+ this.LogVerbose($"Invoked Http request with Url: '{response.RequestMessage.Method.Method} {response.RequestMessage.RequestUri}', ResponseCode: '{response.StatusCode}', RequestId: '{requestId}', ClientRequestId: '{clientRequestId}', Date: '{date}'.", eventListener);
+ }
+ }
+
+ ///
+ /// Log verbose.
+ ///
+ /// The log message.
+ /// The event listener.
+ private void LogVerbose(string message, Runtime.IEventListener eventListener)
+ {
+ eventListener.Signal(
+ Microsoft.Graph.Beta.PowerShell.Runtime.Events.Verbose,
+ () => new Microsoft.Graph.Beta.PowerShell.Runtime.EventData
+ {
+ Message = message,
+ });
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/TeamsAppPreApprovalPolicyConverter.cs b/src/Teams/beta/custom/TeamsAppPreApprovalPolicyConverter.cs
new file mode 100644
index 00000000000..0a6bed6b94d
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsAppPreApprovalPolicyConverter.cs
@@ -0,0 +1,307 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal
+{
+ using Microsoft.Graph.Beta.PowerShell.Models;
+ using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+
+ ///
+ /// Converts Teams App Preapproval to permission grant policy model and vice versa.
+ ///
+ internal class TeamsAppPreApprovalPolicyConverter
+ {
+ ///
+ /// Collection of RSC permissions.
+ ///
+ private IEnumerable rscPermissionCollection;
+
+ ///
+ /// Backing field for RSC permissions name to Id map.
+ ///
+ private IDictionary rscPermisssionNameToIdMapPrivate = null;
+
+ ///
+ /// Backing field for RSC permission Id to name map.
+ ///
+ private IDictionary rscPermisssionIdToNameMapPrivate = null;
+
+ ///
+ /// RSC permission name to Id map.
+ ///
+ private IDictionary RscPermisssionNameToIdMap
+ {
+ get
+ {
+ if (this.rscPermisssionNameToIdMapPrivate == null)
+ {
+ if (this.rscPermissionCollection != null)
+ {
+ this.rscPermisssionNameToIdMapPrivate = this.rscPermissionCollection.ToDictionary(
+ e => e.Value,
+ e => e.Id,
+ StringComparer.OrdinalIgnoreCase);
+ }
+ }
+
+ return this.rscPermisssionNameToIdMapPrivate;
+ }
+ }
+
+ ///
+ /// RSC permission Id to name map.
+ ///
+ private IDictionary RscPermisssionIdToNameMap
+ {
+ get
+ {
+ if (this.rscPermisssionIdToNameMapPrivate == null)
+ {
+ if (this.rscPermissionCollection != null)
+ {
+ this.rscPermisssionIdToNameMapPrivate = this.rscPermissionCollection.ToDictionary(
+ e => e.Id,
+ e => e.Value,
+ StringComparer.OrdinalIgnoreCase);
+ }
+ }
+
+ return this.rscPermisssionIdToNameMapPrivate;
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// RSC permisssion collection.
+ internal TeamsAppPreApprovalPolicyConverter(IEnumerable rscPermissionCollection)
+ {
+ this.rscPermissionCollection = rscPermissionCollection;
+ }
+
+ ///
+ /// Convert the given set of conditions to a permission grant preapproval policy.
+ ///
+ /// RSC permissions allowed for chats.
+ /// Team level sensitivity label selection mode.
+ /// Specific sensitivity label ids applicable to teams.
+ /// RSC permissions allowed for teams.
+ /// Task wrapping the preapproval policy.
+ internal async Task ConvertToPermissionGrantPreApprovalPolicy(
+ IEnumerable resourceSpecificApplicationPermissionsAllowedForChats,
+ MicrosoftGraphSensitivityLabelCondition? teamLevelSensitivityLabelSelectionMode,
+ IEnumerable specificSensitivityLabelIdsApplicableToTeams,
+ IEnumerable resourceSpecificApplicationPermissionsAllowedForTeams)
+ {
+ bool createTeamCondition =
+ resourceSpecificApplicationPermissionsAllowedForTeams?.Any() == true ||
+ teamLevelSensitivityLabelSelectionMode != null ||
+ specificSensitivityLabelIdsApplicableToTeams?.Any() == true;
+
+ bool createChatCondition =
+ resourceSpecificApplicationPermissionsAllowedForChats != null;
+
+ List preApprovalConditions = new List();
+ if (createChatCondition)
+ {
+ IEnumerable chatRscPermissionIds =
+ await this.ValidateAndGetRscPermissionIds(resourceSpecificApplicationPermissionsAllowedForChats);
+
+ MGTeamsInternalPreapprovalDetail preapprovalDetail = new MGTeamsInternalPreapprovalDetail(
+ scopeType: "chat",
+ sensitivityLabels: new MGTeamsInternalAllScopeSensitivityLabels(),
+ permissions: new MGTeamsInternalEnumeratedPreApprovedPermissions(chatRscPermissionIds));
+
+ preApprovalConditions.Add(preapprovalDetail);
+ }
+
+ if (createTeamCondition)
+ {
+ IEnumerable teamRscPermissionIds =
+ await this.ValidateAndGetRscPermissionIds(resourceSpecificApplicationPermissionsAllowedForTeams);
+
+ MGTeamsInternalPreapprovalDetail preapprovalDetail = new MGTeamsInternalPreapprovalDetail(
+ scopeType: "group",
+ sensitivityLabels: this.GetTeamSensitivityLabelsForPreApprovalDetail(
+ teamLevelSensitivityLabelSelectionMode,
+ specificSensitivityLabelIdsApplicableToTeams),
+ permissions: new MGTeamsInternalEnumeratedPreApprovedPermissions(teamRscPermissionIds));
+
+ preApprovalConditions.Add(preapprovalDetail);
+ }
+
+ MGTeamsInternalPermissionGrantPreApprovalPolicy preApprovalPolicy =
+ new MGTeamsInternalPermissionGrantPreApprovalPolicy(conditions: preApprovalConditions);
+
+ return preApprovalPolicy;
+ }
+
+ ///
+ /// Convert the given permission grant policy to a Teams App Preapproval object.
+ ///
+ /// The teams app Id.
+ /// The preapproval policy.
+ /// Teams App Preapproval object
+ internal async Task ConvertToTeamsAppPreApproval(
+ string teamsAppId,
+ MGTeamsInternalPermissionGrantPreApprovalPolicy permissionGrantPreApprovalPolicy)
+ {
+ MicrosoftGraphTeamsAppPreApproval teamsAppPreApproval = new MicrosoftGraphTeamsAppPreApproval();
+ teamsAppPreApproval.Id = $"TeamsAppPreApproval_{teamsAppId}_{permissionGrantPreApprovalPolicy.Id}";
+
+ teamsAppPreApproval.TeamsAppId = teamsAppId;
+
+ if (permissionGrantPreApprovalPolicy.Conditions.Count() > 2)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.UnsupportedScenario,
+ $"Unsupported scenario. Preapproval policy '{permissionGrantPreApprovalPolicy.Id}' has more than 2 conditions.");
+ }
+
+ MGTeamsInternalPreapprovalDetail groupCondition =
+ permissionGrantPreApprovalPolicy.Conditions.FirstOrDefault(c => string.Equals(c.ScopeType, "group"));
+
+ MGTeamsInternalPreapprovalDetail chatCondition =
+ permissionGrantPreApprovalPolicy.Conditions.FirstOrDefault(c => string.Equals(c.ScopeType, "chat"));
+
+ if (permissionGrantPreApprovalPolicy.Conditions.Any(c => c != groupCondition && c != chatCondition))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.UnsupportedScenario,
+ $"Unsupported scenario. Preapproval policy '{permissionGrantPreApprovalPolicy.Id}' has unsupported conditions.");
+ }
+
+ if (groupCondition != null)
+ {
+ if (string.Equals(groupCondition.SensitivityLabels.OdataType, "#microsoft.graph.allScopeSensitivityLabels", System.StringComparison.OrdinalIgnoreCase))
+ {
+ teamsAppPreApproval.TeamLevelSensitivityLabelCondition = MicrosoftGraphSensitivityLabelCondition.AnySensitivityLabel;
+ }
+ else if (string.Equals(groupCondition.SensitivityLabels.OdataType, "#microsoft.graph.enumeratedScopeSensitivityLabels", System.StringComparison.OrdinalIgnoreCase))
+ {
+ teamsAppPreApproval.TeamLevelSensitivityLabelCondition = MicrosoftGraphSensitivityLabelCondition.SpecificSensivityLabel;
+ MGTeamsInternalEnumeratedScopeSensitivityLabels mGTeamsInternalEnumeratedScopeSensitivityLabels =
+ groupCondition.SensitivityLabels as MGTeamsInternalEnumeratedScopeSensitivityLabels;
+ teamsAppPreApproval.SpecificSensitivityLabelIdsApplicableToTeams = mGTeamsInternalEnumeratedScopeSensitivityLabels.SensitivityLabels.ToArray();
+ }
+ else
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.UnsupportedScenario,
+ $"Unsupported scope sensitivity label '{groupCondition.SensitivityLabels.OdataType}' in preapproval policy '{permissionGrantPreApprovalPolicy.Id}'.");
+ }
+
+ MGTeamsInternalEnumeratedPreApprovedPermissions mGTeamsInternalEnumeratedPreApprovedPermissions =
+ groupCondition.Permissions as MGTeamsInternalEnumeratedPreApprovedPermissions;
+ if (mGTeamsInternalEnumeratedPreApprovedPermissions != null)
+ {
+ teamsAppPreApproval.ResourceSpecificApplicationPermissionsAllowedForTeams =
+ this.ConvertToPermissionNames(mGTeamsInternalEnumeratedPreApprovedPermissions.PermissionIds).ToArray();
+ }
+ else
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.UnsupportedScenario,
+ $"Unsupported permission type '{groupCondition.Permissions.OdataType}' in preapproval policy '{permissionGrantPreApprovalPolicy.Id}'.");
+ }
+ }
+
+ if (chatCondition != null)
+ {
+ MGTeamsInternalEnumeratedPreApprovedPermissions mGTeamsInternalEnumeratedPreApprovedPermissions =
+ chatCondition.Permissions as MGTeamsInternalEnumeratedPreApprovedPermissions;
+ if (mGTeamsInternalEnumeratedPreApprovedPermissions != null)
+ {
+ teamsAppPreApproval.ResourceSpecificApplicationPermissionsAllowedForChats =
+ this.ConvertToPermissionNames(mGTeamsInternalEnumeratedPreApprovedPermissions.PermissionIds).ToArray();
+ }
+ else
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.UnsupportedScenario,
+ $"Unsupported permission type '{chatCondition.Permissions.OdataType}' in preapproval policy '{permissionGrantPreApprovalPolicy.Id}'.");
+ }
+ }
+
+ return teamsAppPreApproval;
+ }
+
+ ///
+ /// Convert the given permission Ids to permission names.
+ ///
+ /// The permission Ids.
+ /// Permission names.
+ private IEnumerable ConvertToPermissionNames(IEnumerable permissionIds)
+ {
+ List rscPermissionNames = new List();
+
+ foreach (string rscPermissionId in permissionIds)
+ {
+ if (this.RscPermisssionIdToNameMap.TryGetValue(rscPermissionId, out string rscPermissionName))
+ {
+ rscPermissionNames.Add(rscPermissionName);
+ }
+ else
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ResourceNotFound,
+ $"No resource specific permission was found with Id '{rscPermissionId}'.");
+ }
+ }
+
+ return rscPermissionNames;
+ }
+
+ ///
+ /// Get Scope sensitivity label model for the given label selection mode and ids.
+ ///
+ /// The team level label selection mode.
+ /// The label ids.
+ /// Scope sensitivity labels.
+ private MGTeamsInternalScopeSensitivityLabels GetTeamSensitivityLabelsForPreApprovalDetail(
+ MicrosoftGraphSensitivityLabelCondition? teamLevelSensitivityLabelSelectionMode,
+ IEnumerable specificSensitivityLabelIdsApplicableToTeams)
+ {
+ if (teamLevelSensitivityLabelSelectionMode == MicrosoftGraphSensitivityLabelCondition.AnySensitivityLabel)
+ {
+ return new MGTeamsInternalAllScopeSensitivityLabels();
+ }
+
+ if (teamLevelSensitivityLabelSelectionMode == MicrosoftGraphSensitivityLabelCondition.SpecificSensivityLabel)
+ {
+ return new MGTeamsInternalEnumeratedScopeSensitivityLabels(specificSensitivityLabelIdsApplicableToTeams);
+ }
+
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.UnsupportedScenario,
+ $"Invalid label selection mode: '{teamLevelSensitivityLabelSelectionMode}'");
+ }
+
+ ///
+ /// Validate the given RSC permission name and get corresponding permission Ids.
+ ///
+ /// The permission names.
+ /// Permision Ids.
+ private async System.Threading.Tasks.Task> ValidateAndGetRscPermissionIds(IEnumerable resourceSpecificApplicationPermissionNames)
+ {
+ List rscPermissionIds = new List();
+
+ foreach (string rscPermissionName in resourceSpecificApplicationPermissionNames)
+ {
+ if (this.RscPermisssionNameToIdMap.TryGetValue(rscPermissionName, out string rscPermissionId))
+ {
+ rscPermissionIds.Add(rscPermissionId);
+ }
+ else
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ResourceNotFound,
+ $"No resource specific permission was found with name '{rscPermissionName}'.");
+ }
+ }
+
+ return rscPermissionIds;
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/TeamsAppPreApprovalValidator.cs b/src/Teams/beta/custom/TeamsAppPreApprovalValidator.cs
new file mode 100644
index 00000000000..11942b61c6f
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsAppPreApprovalValidator.cs
@@ -0,0 +1,155 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal
+{
+ using Microsoft.Graph.Beta.PowerShell.Models;
+ using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// Validator for Teams App Preapproval objects.
+ ///
+ internal class TeamsAppPreApprovalValidator
+ {
+ private IDictionary sensitivityLabelDictionary;
+
+ internal TeamsAppPreApprovalValidator(MGTeamsInternalSensitivityLabelCollection mGTeamsInternalSensitivityLabelCollection)
+ {
+ this.sensitivityLabelDictionary = (mGTeamsInternalSensitivityLabelCollection?.Value ?? Enumerable.Empty()).ToDictionary(s => s.Id, StringComparer.OrdinalIgnoreCase);
+ }
+
+ ///
+ /// Validate the given Teams App Preapproval object.
+ ///
+ /// The teams app preapproval object.
+ internal void Validate(IMicrosoftGraphTeamsAppPreApproval microsoftGraphTeamsAppPreApproval)
+ {
+ if (string.IsNullOrWhiteSpace(microsoftGraphTeamsAppPreApproval.Id))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.RequiredPropertyNotFound,
+ $"'Id' is empty.");
+ }
+
+ this.ValidateConditionsForTeamsAppPreApproval(
+ microsoftGraphTeamsAppPreApproval.TeamsAppId,
+ microsoftGraphTeamsAppPreApproval.ResourceSpecificApplicationPermissionsAllowedForChats,
+ microsoftGraphTeamsAppPreApproval.TeamLevelSensitivityLabelCondition,
+ microsoftGraphTeamsAppPreApproval.SpecificSensitivityLabelIdsApplicableToTeams,
+ microsoftGraphTeamsAppPreApproval.ResourceSpecificApplicationPermissionsAllowedForTeams);
+ }
+
+ ///
+ /// Validate that the given conditions are valid for a teams app preapproval object.
+ ///
+ /// The teams app id.
+ /// RSC permissions allowed for chats.
+ /// Team level sensitivity label selection mode.
+ /// Specific sensitivity label ids applicable to teams.
+ /// RSC permissions allowed for teams.
+ /// Task wrapping the preapproval policy.
+ internal void ValidateConditionsForTeamsAppPreApproval(
+ string teamsAppId,
+ IEnumerable resourceSpecificApplicationPermissionsAllowedForChats,
+ MicrosoftGraphSensitivityLabelCondition? teamLevelSensitivityLabelCondition,
+ IEnumerable specificSensitivityLabelIdsApplicableToTeams,
+ IEnumerable resourceSpecificApplicationPermissionsAllowedForTeams)
+ {
+ if (string.IsNullOrWhiteSpace(teamsAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(teamsAppId)}' cannot be empty.");
+ }
+
+ if (resourceSpecificApplicationPermissionsAllowedForChats == null &&
+ resourceSpecificApplicationPermissionsAllowedForTeams == null)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"Both '{nameof(resourceSpecificApplicationPermissionsAllowedForTeams)}' and '{nameof(resourceSpecificApplicationPermissionsAllowedForChats)}' cannot be empty.");
+ }
+
+ if (resourceSpecificApplicationPermissionsAllowedForChats != null)
+ {
+ foreach (string permissionName in resourceSpecificApplicationPermissionsAllowedForChats)
+ {
+ if (!permissionName.EndsWith("chat", System.StringComparison.OrdinalIgnoreCase))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{permissionName}' is not a valid permission for chat scope.");
+ }
+ }
+ }
+
+ if (resourceSpecificApplicationPermissionsAllowedForTeams != null)
+ {
+ foreach (string permissionName in resourceSpecificApplicationPermissionsAllowedForTeams)
+ {
+ if (!permissionName.EndsWith("group", System.StringComparison.OrdinalIgnoreCase))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{permissionName}' is not a valid permission for team scope.");
+ }
+ }
+ }
+
+ if (specificSensitivityLabelIdsApplicableToTeams != null)
+ {
+ foreach (string sensitivityLabelId in specificSensitivityLabelIdsApplicableToTeams)
+ {
+ if (!this.sensitivityLabelDictionary.TryGetValue(sensitivityLabelId, out _))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'Sensitivity Label '{sensitivityLabelId}' was not found.");
+ }
+ }
+ }
+
+ if (teamLevelSensitivityLabelCondition == null)
+ {
+ if (resourceSpecificApplicationPermissionsAllowedForTeams != null || specificSensitivityLabelIdsApplicableToTeams != null)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(resourceSpecificApplicationPermissionsAllowedForTeams)}' and '{nameof(specificSensitivityLabelIdsApplicableToTeams)}' are not allowed without specifying '{nameof(teamLevelSensitivityLabelCondition)}'.");
+ }
+ }
+ else if (teamLevelSensitivityLabelCondition == MicrosoftGraphSensitivityLabelCondition.AnySensitivityLabel)
+ {
+ if (specificSensitivityLabelIdsApplicableToTeams?.Any() == true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(specificSensitivityLabelIdsApplicableToTeams)}' cannot be specified for '{nameof(teamLevelSensitivityLabelCondition)}' : '{teamLevelSensitivityLabelCondition}'.");
+ }
+
+ if (resourceSpecificApplicationPermissionsAllowedForTeams?.Any() != true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(resourceSpecificApplicationPermissionsAllowedForTeams)}' must be specified for '{nameof(teamLevelSensitivityLabelCondition)}' : '{teamLevelSensitivityLabelCondition}'.");
+ }
+ }
+ else if (teamLevelSensitivityLabelCondition == MicrosoftGraphSensitivityLabelCondition.SpecificSensivityLabel)
+ {
+ if (specificSensitivityLabelIdsApplicableToTeams?.Any() != true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(specificSensitivityLabelIdsApplicableToTeams)}' must be specified for '{nameof(teamLevelSensitivityLabelCondition)}' : '{teamLevelSensitivityLabelCondition}'.");
+ }
+
+ if (resourceSpecificApplicationPermissionsAllowedForTeams?.Any() != true)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(resourceSpecificApplicationPermissionsAllowedForTeams)}' must be specified for '{nameof(teamLevelSensitivityLabelCondition)}' : '{teamLevelSensitivityLabelCondition}'.");
+ }
+ }
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/TeamsExceptionHandler.cs b/src/Teams/beta/custom/TeamsExceptionHandler.cs
new file mode 100644
index 00000000000..b09c77d78d3
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsExceptionHandler.cs
@@ -0,0 +1,140 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal
+{
+ using Microsoft.Graph.Beta.PowerShell.Runtime;
+ using System;
+
+ ///
+ /// Exception handler for Teams.
+ ///
+ internal class TeamsExceptionHandler
+ {
+ ///
+ /// Handle exceptions for teams workload.
+ ///
+ /// The exception.
+ /// The target object.
+ /// The error logger.
+ /// The event listener.
+ internal static void HandleException(
+ Exception ex,
+ object targetObject,
+ Action errorLogger,
+ Runtime.IEventListener eventListener)
+ {
+ if (ex is MGTeamsInternalServiceRequestException)
+ {
+ TeamsExceptionHandler.HandleTeamsInternalServiceRequestException(
+ ex as MGTeamsInternalServiceRequestException,
+ targetObject,
+ errorLogger);
+ }
+ else if (ex is MGTeamsInternalException)
+ {
+ TeamsExceptionHandler.HandleTeamsInternalException(
+ ex as MGTeamsInternalException,
+ targetObject,
+ errorLogger);
+ }
+ else
+ {
+ TeamsExceptionHandler.HandleGenericException(
+ ex,
+ targetObject,
+ errorLogger,
+ eventListener);
+ }
+ }
+
+ ///
+ /// Handle Teams Internal Service Request Exception.
+ ///
+ /// The exception.
+ /// The target object.
+ /// The error logger.
+ private static void HandleTeamsInternalServiceRequestException(
+ MGTeamsInternalServiceRequestException ex,
+ object targetObject,
+ Action errorLogger)
+ {
+ string code = ex.ODataError.Error?.Code;
+ string message = ex.ODataError.Error?.Message;
+ errorLogger(new global::System.Management.Automation.ErrorRecord(
+ new global::System.Exception($"[{code}] : {message}"),
+ code,
+ global::System.Management.Automation.ErrorCategory.InvalidOperation,
+ targetObject)
+ {
+ ErrorDetails = new global::System.Management.Automation.ErrorDetails(message)
+ });
+ }
+
+ ///
+ /// Handle Teams internal exception
+ ///
+ /// The exception.
+ /// The target object.
+ /// The error logger.
+ private static void HandleTeamsInternalException(
+ MGTeamsInternalException ex,
+ object targetObject,
+ Action errorLogger)
+ {
+ errorLogger(new global::System.Management.Automation.ErrorRecord(
+ ex,
+ ex.ErrorType.ToString(),
+ global::System.Management.Automation.ErrorCategory.InvalidOperation,
+ targetObject)
+ {
+ ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message)
+ });
+ }
+
+ ///
+ /// Handle generic exception.
+ ///
+ /// Exception.
+ /// The target object.
+ /// The error logger.
+ /// The event listener.
+ private static void HandleGenericException(
+ Exception ex,
+ object targetObject,
+ Action errorLogger,
+ Runtime.IEventListener eventListener)
+ {
+ string stackMessage = $"Ran into error: '{ex.StackTrace}'";
+
+ // Log verbose.
+ eventListener.Signal(
+ Microsoft.Graph.Beta.PowerShell.Runtime.Events.Verbose,
+ () => new Microsoft.Graph.Beta.PowerShell.Runtime.EventData
+ {
+ Message = stackMessage,
+ });
+
+ UndeclaredResponseException undeclaredResponseException = ex as UndeclaredResponseException;
+ if (undeclaredResponseException != null)
+ {
+ errorLogger(new System.Management.Automation.ErrorRecord(
+ undeclaredResponseException,
+ undeclaredResponseException.StatusCode.ToString(),
+ System.Management.Automation.ErrorCategory.InvalidOperation,
+ targetObject)
+ {
+ ErrorDetails = new global::System.Management.Automation.ErrorDetails(undeclaredResponseException.Message)
+ {
+ RecommendedAction = undeclaredResponseException.Action
+ }
+ });
+ }
+ else
+ {
+ errorLogger(new global::System.Management.Automation.ErrorRecord(
+ ex,
+ string.Empty,
+ global::System.Management.Automation.ErrorCategory.NotSpecified,
+ null));
+ }
+ }
+ }
+}
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllPreApprovedPermissions.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllPreApprovedPermissions.cs
new file mode 100644
index 00000000000..db22d3726f3
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllPreApprovedPermissions.cs
@@ -0,0 +1,46 @@
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ ///
+ /// Teams internal model for all approved permissions in preapproval policies.
+ ///
+ internal class MGTeamsInternalAllPreApprovedPermissions : MGTeamsInternalPreApprovedPermissions
+ {
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalAllPreApprovedPermissions.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalAllPreApprovedPermissions.
+ internal static new MGTeamsInternalAllPreApprovedPermissions FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ return new MGTeamsInternalAllPreApprovedPermissions(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalAllPreApprovedPermissions(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ : base(json)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalAllPreApprovedPermissions()
+ : base(permissionKind: "all", odataType: "#microsoft.graph.allPreApprovedPermissions")
+ {
+ }
+
+ ///
+ /// Serialize this instance to a JsonNode.
+ ///
+ /// Json Node.
+ internal override Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson()
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject =
+ (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)base.ToJson();
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllPreApprovedPermissionsOnResourceApp.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllPreApprovedPermissionsOnResourceApp.cs
new file mode 100644
index 00000000000..dd32b98f790
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllPreApprovedPermissionsOnResourceApp.cs
@@ -0,0 +1,71 @@
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for all approved permissions on a specific resource in preapproval policies.
+ ///
+ internal class MGTeamsInternalAllPreApprovedPermissionsOnResourceApp : MGTeamsInternalPreApprovedPermissions
+ {
+ ///
+ /// The resource application Id.
+ ///
+ internal string ResourceApplicationId { get; private set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalAllPreApprovedPermissionsOnResourceApp.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalAllPreApprovedPermissionsOnResourceApp.
+ internal static new MGTeamsInternalAllPreApprovedPermissionsOnResourceApp FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ return new MGTeamsInternalAllPreApprovedPermissionsOnResourceApp(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalAllPreApprovedPermissionsOnResourceApp(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ : base(json)
+ {
+ string resourceApplicationId = If(json.PropertyT("resourceApplicationId"), out var jsonResourceApplicationId)
+ ? (string)ResourceApplicationId
+ : string.Empty;
+
+ this.SetProperties(resourceApplicationId);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalAllPreApprovedPermissionsOnResourceApp()
+ : base(permissionKind: "allPermissionsOnResourceApp", odataType: "#microsoft.graph.allPreApprovedPermissionsOnResourceApp")
+ {
+ this.SetProperties(resourceApplicationId: "00000003-0000-0000-c000-000000000000");
+ }
+
+ ///
+ /// Initialize properties of this object.
+ ///
+ private void SetProperties(string resourceApplicationId)
+ {
+ this.ResourceApplicationId = resourceApplicationId;
+ }
+
+ ///
+ /// Serializes this instance into a .
+ ///
+ internal override Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson()
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject =
+ (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)base.ToJson();
+
+ if (this.ResourceApplicationId != null)
+ {
+ jsonObject.Add("resourceApplicationId", (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this.ResourceApplicationId));
+ }
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllScopeSensitivityLabels.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllScopeSensitivityLabels.cs
new file mode 100644
index 00000000000..d29eb8b70ba
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalAllScopeSensitivityLabels.cs
@@ -0,0 +1,45 @@
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ ///
+ /// Teams internal model for all scope sensitivity labels in preapproval policies.
+ ///
+ internal class MGTeamsInternalAllScopeSensitivityLabels : MGTeamsInternalScopeSensitivityLabels
+ {
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalAllScopeSensitivityLabels.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalAllScopeSensitivityLabels.
+ internal static new MGTeamsInternalAllScopeSensitivityLabels FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ return new MGTeamsInternalAllScopeSensitivityLabels(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalAllScopeSensitivityLabels(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json) :
+ base(json)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalAllScopeSensitivityLabels() :
+ base(labelKind: "all", type: "#microsoft.graph.allScopeSensitivityLabels")
+ {
+ }
+
+ ///
+ /// Serializes this instance into a .
+ ///
+ internal override Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson()
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject =
+ (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)base.ToJson();
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalEnumeratedPreApprovedPermissions.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalEnumeratedPreApprovedPermissions.cs
new file mode 100644
index 00000000000..7d7885df911
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalEnumeratedPreApprovedPermissions.cs
@@ -0,0 +1,105 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for enumerated preapproved permissions in preapproval policies.
+ ///
+ internal class MGTeamsInternalEnumeratedPreApprovedPermissions : MGTeamsInternalPreApprovedPermissions
+ {
+ ///
+ /// The permission Ids.
+ ///
+ internal IEnumerable PermissionIds { get; private set; }
+
+ ///
+ /// The Resource Application Id.
+ ///
+ internal string ResourceApplicationId { get; private set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalEnumeratedPreApprovedPermissions.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalEnumeratedPreApprovedPermissions.
+ internal static new MGTeamsInternalEnumeratedPreApprovedPermissions FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ return new MGTeamsInternalEnumeratedPreApprovedPermissions(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalEnumeratedPreApprovedPermissions(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ : base(json)
+ {
+ IEnumerable permissionIds = If(json.PropertyT("permissionIds"), out var jsonPermissionIds)
+ ? jsonPermissionIds.Select(j => (string)j).ToArray()
+ : Array.Empty();
+
+ string resourceApplicationId = If(json.PropertyT("resourceApplicationId"), out var jsonResourceApplicationId)
+ ? (string)ResourceApplicationId
+ : string.Empty;
+
+ this.SetProperties(permissionIds, resourceApplicationId);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalEnumeratedPreApprovedPermissions(
+ IEnumerable permissionIds)
+ : base(permissionKind: "enumerated", odataType: "#microsoft.graph.enumeratedPreApprovedPermissions")
+ {
+ this.SetProperties(permissionIds, resourceApplicationId: "00000003-0000-0000-c000-000000000000");
+ }
+
+ ///
+ /// Initialize properties of this object.
+ ///
+ private void SetProperties(
+ IEnumerable permissionIds,
+ string resourceApplicationId)
+ {
+ this.PermissionIds = permissionIds;
+ this.ResourceApplicationId = resourceApplicationId;
+ }
+
+ ///
+ /// Serialize this instance to a JsonNode.
+ ///
+ /// Json Node.
+ internal override Runtime.Json.JsonNode ToJson()
+ {
+ Runtime.Json.JsonObject jsonObject =
+ (Runtime.Json.JsonObject)base.ToJson();
+
+ if (this.PermissionIds != null)
+ {
+ var permissionIdsJson = new Runtime.Json.XNodeArray();
+ foreach (var singlePermissionId in this.PermissionIds)
+ {
+ if (singlePermissionId != null)
+ {
+ permissionIdsJson.Add(new Runtime.Json.JsonString(singlePermissionId));
+ }
+ }
+
+ jsonObject.Add("permissionIds", permissionIdsJson);
+ }
+
+ if (this.ResourceApplicationId != null)
+ {
+ jsonObject.Add("resourceApplicationId", (Runtime.Json.JsonNode)new Runtime.Json.JsonString(this.ResourceApplicationId));
+ }
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalEnumeratedScopeSensitivityLabels.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalEnumeratedScopeSensitivityLabels.cs
new file mode 100644
index 00000000000..0def745a6f3
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalEnumeratedScopeSensitivityLabels.cs
@@ -0,0 +1,86 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for enumerated scope sensitivity labels in preapproval policies.
+ ///
+ internal class MGTeamsInternalEnumeratedScopeSensitivityLabels : MGTeamsInternalScopeSensitivityLabels
+ {
+ ///
+ /// The Sensitivity labels.
+ ///
+ internal IEnumerable SensitivityLabels { get; private set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalEnumeratedScopeSensitivityLabels.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalEnumeratedScopeSensitivityLabels.
+ internal static new MGTeamsInternalEnumeratedScopeSensitivityLabels FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ return new MGTeamsInternalEnumeratedScopeSensitivityLabels(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalEnumeratedScopeSensitivityLabels(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ :base(json)
+ {
+ IEnumerable sensitivityLabels = If(json.PropertyT("sensitivityLabels"), out var jsonSensitivityLabels)
+ ? jsonSensitivityLabels.Select(j => (string)j).ToArray()
+ : Array.Empty();
+
+ this.SetProperties(sensitivityLabels);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalEnumeratedScopeSensitivityLabels(IEnumerable sensitivityLabels) : base(labelKind: "enumerated", type: "#microsoft.graph.enumeratedScopeSensitivityLabels")
+ {
+ this.SetProperties(sensitivityLabels);
+ }
+
+ ///
+ /// Initialize properties of this object.
+ ///
+ private void SetProperties(IEnumerable sensitivityLabels)
+ {
+ this.SensitivityLabels = sensitivityLabels;
+ }
+
+ ///
+ /// Serialize this instance to a JsonNode.
+ ///
+ /// Json Node.
+ internal override Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson()
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject =
+ (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)base.ToJson();
+
+ if (this.SensitivityLabels != null)
+ {
+ var sensitivityLabelsJson = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.XNodeArray();
+ foreach (var singleSensitivityLabel in this.SensitivityLabels)
+ {
+ if (singleSensitivityLabel != null)
+ {
+ sensitivityLabelsJson.Add(new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(singleSensitivityLabel));
+ }
+ }
+
+ jsonObject.Add("sensitivityLabels", sensitivityLabelsJson);
+ }
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalException.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalException.cs
new file mode 100644
index 00000000000..212378de5fa
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalException.cs
@@ -0,0 +1,37 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal
+{
+ ///
+ /// Internal custom exception for Teams workload.
+ ///
+ internal class MGTeamsInternalException : System.Exception
+ {
+ ///
+ /// The error type.
+ ///
+ internal MGTeamsInternalErrorType ErrorType { get; }
+
+ ///
+ /// Initializes a new instance of the MGTeamsInternalException class.
+ ///
+ internal MGTeamsInternalException(MGTeamsInternalErrorType errorType, string errorMessage) : base(errorMessage)
+ {
+ this.ErrorType = errorType;
+ }
+ }
+
+ ///
+ /// Error type enum.
+ ///
+ internal enum MGTeamsInternalErrorType
+ {
+ ConflictingUpdate,
+ InvalidCmdletInput,
+ RequiredPropertyNotFound,
+ ResourceNotFound,
+ ServiceRequestFailed,
+ UnsupportedScenario
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalGenericEmptyResponse.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalGenericEmptyResponse.cs
new file mode 100644
index 00000000000..faacd5c600c
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalGenericEmptyResponse.cs
@@ -0,0 +1,16 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal
+{
+ using System;
+
+ ///
+ /// Class representing a generic empty http response.
+ ///
+ internal class MGTeamsInternalGenericEmptyResponse
+ {
+ ///
+ /// Lazy singleton instance for this class.
+ ///
+ internal static Lazy LazyInstance { get; } =
+ new Lazy(System.Threading.LazyThreadSafetyMode.PublicationOnly);
+ }
+}
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPermissionGrantPreApprovalPolicy.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPermissionGrantPreApprovalPolicy.cs
new file mode 100644
index 00000000000..44cb2b60006
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPermissionGrantPreApprovalPolicy.cs
@@ -0,0 +1,105 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model a preapproval policy.
+ ///
+ internal class MGTeamsInternalPermissionGrantPreApprovalPolicy
+ {
+ ///
+ /// The Id of the policy
+ ///
+ internal string Id { get; set; }
+
+ ///
+ /// Conditions in the policy.
+ ///
+ internal IEnumerable Conditions { get; set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalPermissionGrantPreApprovalPolicy.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphTeamsApp.
+ internal static MGTeamsInternalPermissionGrantPreApprovalPolicy FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode json)
+ {
+ Runtime.Json.JsonObject jsonObject = json as Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject;
+ return jsonObject == null
+ ? null
+ : new MGTeamsInternalPermissionGrantPreApprovalPolicy(jsonObject);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalPermissionGrantPreApprovalPolicy(Runtime.Json.JsonObject json)
+ {
+ string id = If(json.PropertyT("id"), out var jsonId)
+ ? (string)jsonId
+ : null;
+
+ IEnumerable conditions = If(json.PropertyT("conditions"), out var jsonConditions)
+ ? jsonConditions
+ .Where(j => j is Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)
+ .Select(j => MGTeamsInternalPreapprovalDetail.FromJson((Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)j))
+ .ToArray()
+ : Array.Empty();
+
+ this.SetProperties(id, conditions);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalPermissionGrantPreApprovalPolicy(IEnumerable conditions)
+ {
+ this.SetProperties(id: null, conditions: conditions);
+ }
+
+ ///
+ /// Initialize properties of this object.
+ ///
+ private void SetProperties(string id, IEnumerable conditions)
+ {
+ this.Id = id;
+ this.Conditions = conditions;
+ }
+
+ ///
+ /// Serialize this instance to a JsonNode.
+ ///
+ /// Json Node.
+ public Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson()
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject();
+
+ if (this.Id!= null)
+ {
+ jsonObject.Add("id", (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this.Id));
+ }
+
+ if (this.Conditions != null)
+ {
+ var conditionsJson = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.XNodeArray();
+ foreach (var singleCondition in this.Conditions)
+ {
+ if (singleCondition != null)
+ {
+ conditionsJson.Add(singleCondition.ToJson());
+ }
+ }
+
+ jsonObject.Add("conditions", conditionsJson);
+ }
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPermissionGrantPreApprovalPolicyCollection.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPermissionGrantPreApprovalPolicyCollection.cs
new file mode 100644
index 00000000000..d92cd8fc87d
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPermissionGrantPreApprovalPolicyCollection.cs
@@ -0,0 +1,47 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for preapproval policy collection.
+ ///
+ internal class MGTeamsInternalPermissionGrantPreApprovalPolicyCollection
+ {
+ ///
+ /// Collection of policies.
+ ///
+ internal IEnumerable Value { get; private set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalPermissionGrantPreApprovalPolicyCollection.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalPermissionGrantPreApprovalPolicyCollection.
+ internal static MGTeamsInternalPermissionGrantPreApprovalPolicyCollection FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode jsonNode)
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject = jsonNode as Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject;
+ return jsonObject == null
+ ? null
+ : new MGTeamsInternalPermissionGrantPreApprovalPolicyCollection(jsonObject);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalPermissionGrantPreApprovalPolicyCollection(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ this.Value = If(json.PropertyT("value"), out var jsonValue)
+ ? jsonValue
+ .Where(j => j is Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)
+ .Select(j => MGTeamsInternalPermissionGrantPreApprovalPolicy.FromJson((Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)j))
+ .ToArray()
+ : Array.Empty();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPreApprovedPermissions.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPreApprovedPermissions.cs
new file mode 100644
index 00000000000..dc4257dc846
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPreApprovedPermissions.cs
@@ -0,0 +1,122 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for permissions in preapproval policies.
+ ///
+ internal class MGTeamsInternalPreApprovedPermissions
+ {
+ ///
+ /// Permission kind.
+ ///
+ internal string PermissionKind { get; private set; }
+
+ ///
+ /// Permission type.
+ ///
+ internal string PermissionType { get; private set; }
+
+ ///
+ /// Odata type of the object.
+ ///
+ internal string OdataType { get; private set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalPreApprovedPermissions.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalPreApprovedPermissions.
+ internal static MGTeamsInternalPreApprovedPermissions FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ string odataType = If(json.PropertyT("@odata.type"), out var jsonType)
+ ? (string)jsonType
+ : string.Empty;
+
+ if (string.Equals(odataType, "#microsoft.graph.allPreApprovedPermissions", System.StringComparison.OrdinalIgnoreCase))
+ {
+ return MGTeamsInternalAllPreApprovedPermissions.FromJson(json);
+ }
+
+ if (string.Equals(odataType, "#microsoft.graph.enumeratedPreApprovedPermissions", System.StringComparison.OrdinalIgnoreCase))
+ {
+ return MGTeamsInternalEnumeratedPreApprovedPermissions.FromJson(json);
+ }
+
+ if (string.Equals(odataType, "#microsoft.graph.allPreApprovedPermissionsOnResourceApp", System.StringComparison.OrdinalIgnoreCase))
+ {
+ return MGTeamsInternalAllPreApprovedPermissionsOnResourceApp.FromJson(json);
+ }
+
+ return new MGTeamsInternalPreApprovedPermissions(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalPreApprovedPermissions(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ string odataType = If(json.PropertyT("@odata.type"), out var jsonType)
+ ? (string)jsonType
+ : string.Empty;
+ string permissionKind = If(json.PropertyT("permissionKind"), out var jsonPermissionKind)
+ ? (string)jsonPermissionKind
+ : string.Empty;
+ string permissionType = If(json.PropertyT("permissionType"), out var jsonPermissionType)
+ ? (string)jsonPermissionType
+ : string.Empty;
+
+ this.SetProperties(permissionKind: permissionKind, permissionType: permissionType, odataType: odataType);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalPreApprovedPermissions(string permissionKind, string odataType)
+ {
+ this.SetProperties(permissionKind, permissionType: "application", odataType: odataType);
+ }
+
+ ///
+ /// Initialize properties of this object.
+ ///
+ private void SetProperties(
+ string permissionKind,
+ string permissionType,
+ string odataType)
+ {
+ this.PermissionKind = permissionKind;
+ this.PermissionType = permissionType;
+ this.OdataType = odataType;
+ }
+
+ ///
+ /// Serialize this instance to a JsonNode.
+ ///
+ /// Json Node.
+ internal virtual Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson()
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject();
+
+ if (this.PermissionKind != null)
+ {
+ jsonObject.Add("permissionKind", (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this.PermissionKind));
+ }
+
+ if (this.PermissionType != null)
+ {
+ jsonObject.Add("permissionType", (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this.PermissionType));
+ }
+
+ if (this.OdataType != null)
+ {
+ jsonObject.Add("@odata.type", (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this.OdataType));
+ }
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPreapprovalDetail.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPreapprovalDetail.cs
new file mode 100644
index 00000000000..ca7573f55a3
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalPreapprovalDetail.cs
@@ -0,0 +1,105 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for preapproval detail.
+ ///
+ internal class MGTeamsInternalPreapprovalDetail
+ {
+ ///
+ /// The scope type (chat/group).
+ ///
+ internal string ScopeType { get; private set; }
+
+ ///
+ /// Sensitivity labels that this policy requires.
+ ///
+ internal MGTeamsInternalScopeSensitivityLabels SensitivityLabels { get; private set; }
+
+ ///
+ /// Permissions granted through this policy.
+ ///
+ internal MGTeamsInternalPreApprovedPermissions Permissions { get; private set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal static MGTeamsInternalPreapprovalDetail FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ return new MGTeamsInternalPreapprovalDetail(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalPreapprovalDetail(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ string scopeType = If(json.PropertyT("scopeType"), out var jsonScopeType)
+ ? (string)jsonScopeType
+ : null;
+ MGTeamsInternalScopeSensitivityLabels sensitivityLabels = If(json.PropertyT("sensitivityLabels"), out var jsonSensitivityLabels)
+ ? MGTeamsInternalScopeSensitivityLabels.FromJson(jsonSensitivityLabels)
+ : null;
+ MGTeamsInternalPreApprovedPermissions permissions = If(json.PropertyT("permissions"), out var jsonPermissions)
+ ? MGTeamsInternalPreApprovedPermissions.FromJson(jsonPermissions)
+ : null;
+
+ this.SetProperties(scopeType, sensitivityLabels, permissions);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalPreapprovalDetail(
+ string scopeType,
+ MGTeamsInternalScopeSensitivityLabels sensitivityLabels,
+ MGTeamsInternalPreApprovedPermissions permissions)
+ {
+ this.SetProperties(scopeType, sensitivityLabels, permissions);
+ }
+
+ ///
+ /// Initialize properties of this object.
+ ///
+ private void SetProperties(
+ string scopeType,
+ MGTeamsInternalScopeSensitivityLabels sensitivityLabels,
+ MGTeamsInternalPreApprovedPermissions permissions)
+ {
+ this.ScopeType = scopeType;
+ this.SensitivityLabels = sensitivityLabels;
+ this.Permissions = permissions;
+ }
+
+ ///
+ /// Serialize this instance to a JsonNode.
+ ///
+ /// Json Node.
+ internal Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson()
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject();
+
+ if (this.ScopeType != null)
+ {
+ jsonObject.Add("scopeType", (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this.ScopeType));
+ }
+
+ if (this.SensitivityLabels != null)
+ {
+ jsonObject.Add("sensitivityLabels", this.SensitivityLabels.ToJson());
+ }
+
+ if (this.Permissions != null)
+ {
+ jsonObject.Add("permissions", this.Permissions.ToJson());
+ }
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalResourceSpecificPermission.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalResourceSpecificPermission.cs
new file mode 100644
index 00000000000..9a2bde24f6a
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalResourceSpecificPermission.cs
@@ -0,0 +1,47 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for all resource specific permission.
+ ///
+ internal class MGTeamsInternalResourceSpecificPermission
+ {
+ ///
+ /// The permission Id.
+ ///
+ internal string Id { get; set; }
+
+ ///
+ /// The permission value.
+ ///
+ internal string Value { get; set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalResourceSpecificPermission.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalResourceSpecificPermission.
+ public static MGTeamsInternalResourceSpecificPermission FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ return new MGTeamsInternalResourceSpecificPermission(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalResourceSpecificPermission(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ this.Id = If(json.PropertyT("id"), out var jsonId)
+ ? (string)jsonId
+ : string.Empty;
+ this.Value = If(json.PropertyT("value"), out var jsonValue)
+ ? (string)jsonValue
+ : string.Empty;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalResourceSpecificPermissionCollection.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalResourceSpecificPermissionCollection.cs
new file mode 100644
index 00000000000..14ad84d0f0e
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalResourceSpecificPermissionCollection.cs
@@ -0,0 +1,46 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for resource specific permission collection.
+ ///
+ internal class MGTeamsInternalResourceSpecificPermissionCollection
+ {
+ ///
+ /// The collection of resource specific permissions.
+ ///
+ internal MGTeamsInternalResourceSpecificPermission[] Value { get; set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalResourceSpecificPermissionCollection.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalResourceSpecificPermissionCollection.
+ internal static MGTeamsInternalResourceSpecificPermissionCollection FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode jsonNode)
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject = jsonNode as Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject;
+ return jsonObject == null
+ ? null
+ : new MGTeamsInternalResourceSpecificPermissionCollection(jsonObject);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalResourceSpecificPermissionCollection(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ this.Value = If(json.PropertyT("value"), out var jsonValue)
+ ? jsonValue
+ .Where(j => j is Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)
+ .Select(j => MGTeamsInternalResourceSpecificPermission.FromJson((Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)j))
+ .ToArray()
+ : Array.Empty();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalScopeSensitivityLabels.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalScopeSensitivityLabels.cs
new file mode 100644
index 00000000000..1d3e11447ed
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalScopeSensitivityLabels.cs
@@ -0,0 +1,101 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for sensitivity labels in preapproval policies.
+ ///
+ internal class MGTeamsInternalScopeSensitivityLabels
+ {
+ ///
+ /// The label kind.
+ ///
+ internal string LabelKind { get; private set; }
+
+ ///
+ /// The odata type of the object.
+ ///
+ internal string OdataType { get; private set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalScopeSensitivityLabels.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalScopeSensitivityLabels.
+ internal static MGTeamsInternalScopeSensitivityLabels FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ string type = If(json.PropertyT("@odata.type"), out var jsonType)
+ ? (string)jsonType
+ : string.Empty;
+
+ if (string.Equals(type, "#microsoft.graph.allScopeSensitivityLabels", System.StringComparison.OrdinalIgnoreCase))
+ {
+ return MGTeamsInternalAllScopeSensitivityLabels.FromJson(json);
+ }
+
+ if (string.Equals(type, "#microsoft.graph.enumeratedScopeSensitivityLabels", System.StringComparison.OrdinalIgnoreCase))
+ {
+ return MGTeamsInternalEnumeratedScopeSensitivityLabels.FromJson(json);
+ }
+
+ return new MGTeamsInternalScopeSensitivityLabels(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalScopeSensitivityLabels(string labelKind, string type)
+ {
+ this.SetProperties(labelKind: labelKind, type: type);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalScopeSensitivityLabels(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ string type = If(json.PropertyT("@odata.type"), out var jsonType)
+ ? (string)jsonType
+ : string.Empty;
+
+ string labelKind = If(json.PropertyT("labelKind"), out var jsonLabelKind)
+ ? (string)jsonLabelKind
+ : string.Empty;
+
+ this.SetProperties(labelKind: labelKind, type: type);
+ }
+
+ ///
+ /// Initialize properties of this object.
+ ///
+ private void SetProperties(string labelKind, string type)
+ {
+ this.LabelKind = labelKind;
+ this.OdataType = type;
+ }
+
+ ///
+ /// Serialize this instance to a JsonNode.
+ ///
+ /// Json Node.
+ internal virtual Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode ToJson()
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject = new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject();
+
+ if (this.LabelKind != null)
+ {
+ jsonObject.Add("labelKind", (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this.LabelKind));
+ }
+
+ if (this.OdataType != null)
+ {
+ jsonObject.Add("@odata.type", (Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonString(this.OdataType));
+ }
+
+ return jsonObject;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalSensitivityLabel.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalSensitivityLabel.cs
new file mode 100644
index 00000000000..6b2f07f2062
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalSensitivityLabel.cs
@@ -0,0 +1,63 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for information protection sensitivity labels.
+ ///
+ internal class MGTeamsInternalSensitivityLabel
+ {
+ ///
+ /// The Id.
+ ///
+ internal string Id { get; private set; }
+
+ ///
+ /// The display name of the label.
+ ///
+ internal string Name { get; private set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalSensitivityLabel.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalSensitivityLabel.
+ internal static MGTeamsInternalSensitivityLabel FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ return new MGTeamsInternalSensitivityLabel(json);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalSensitivityLabel(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ string id = If(json.PropertyT("id"), out var jsonId)
+ ? (string)jsonId
+ : null;
+
+ string name = If(json.PropertyT("name"), out var jsonName)
+ ? (string)jsonName
+ : null;
+
+ this.SetProperties(id, name);
+ }
+
+ ///
+ /// Initialize properties of this object.
+ ///
+ /// The Id.
+ /// The name.
+ private void SetProperties(string id, string name)
+ {
+ this.Id = id;
+ this.Name = name;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalSensitivityLabelCollection.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalSensitivityLabelCollection.cs
new file mode 100644
index 00000000000..5f8c75940a3
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalSensitivityLabelCollection.cs
@@ -0,0 +1,46 @@
+// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6306, generator: {generator})
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal
+{
+ using System;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Teams internal model for information protection sensitivity label collection.
+ ///
+ internal class MGTeamsInternalSensitivityLabelCollection
+ {
+ ///
+ /// The collection of information protection sensitivity labels.
+ ///
+ internal MGTeamsInternalSensitivityLabel[] Value { get; set; }
+
+ ///
+ /// Deserializes a into an instance of MGTeamsInternalSensitivityLabelCollection.
+ ///
+ /// a to deserialize from.
+ /// an instance of MGTeamsInternalSensitivityLabelCollection.
+ internal static MGTeamsInternalSensitivityLabelCollection FromJson(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonNode jsonNode)
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject jsonObject = jsonNode as Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject;
+ return jsonObject == null
+ ? null
+ : new MGTeamsInternalSensitivityLabelCollection(jsonObject);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal MGTeamsInternalSensitivityLabelCollection(Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject json)
+ {
+ this.Value = If(json.PropertyT("value"), out var jsonValue)
+ ? jsonValue
+ .Where(j => j is Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)
+ .Select(j => MGTeamsInternalSensitivityLabel.FromJson((Microsoft.Graph.Beta.PowerShell.Runtime.Json.JsonObject)j))
+ .ToArray()
+ : Array.Empty();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalServiceRequestException.cs b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalServiceRequestException.cs
new file mode 100644
index 00000000000..d5b49950df9
--- /dev/null
+++ b/src/Teams/beta/custom/TeamsInternalModels/MGTeamsInternalServiceRequestException.cs
@@ -0,0 +1,33 @@
+namespace Microsoft.Graph.Beta.PowerShell.TeamsInternal
+{
+ using System.Net;
+
+ ///
+ /// Internal custom http request exception for Teams workload.
+ ///
+ internal class MGTeamsInternalServiceRequestException : MGTeamsInternalException
+ {
+ ///
+ /// The Http status code of the error.
+ ///
+ internal HttpStatusCode HttpStatusCode { get; }
+
+ ///
+ /// The odata error.
+ ///
+ internal Models.IMicrosoftGraphODataErrorsOdataError ODataError { get; }
+
+ ///
+ /// Initializes a new instance of the MGTeamsInternalServiceRequestException class.
+ ///
+ /// The http status code.
+ /// The odata error.
+ internal MGTeamsInternalServiceRequestException(
+ System.Net.HttpStatusCode httpStatusCode,
+ Models.IMicrosoftGraphODataErrorsOdataError odataError) : base(MGTeamsInternalErrorType.ServiceRequestFailed, odataError?.Error?.Message)
+ {
+ this.HttpStatusCode = httpStatusCode;
+ this.ODataError = odataError;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Teams/beta/custom/UpdateMgBetaTeamAppPreApproval_Update.cs b/src/Teams/beta/custom/UpdateMgBetaTeamAppPreApproval_Update.cs
new file mode 100644
index 00000000000..135a7ac6c5c
--- /dev/null
+++ b/src/Teams/beta/custom/UpdateMgBetaTeamAppPreApproval_Update.cs
@@ -0,0 +1,474 @@
+namespace Microsoft.Graph.Beta.PowerShell.Cmdlets
+{
+ using Microsoft.Graph.Beta.PowerShell.Models;
+ using Microsoft.Graph.Beta.PowerShell.Models.TeamsInternal;
+ using Microsoft.Graph.Beta.PowerShell.TeamsInternal;
+ using System;
+ using System.Linq;
+ using static Microsoft.Graph.Beta.PowerShell.Runtime.Extensions;
+
+ ///
+ /// Update Preapproval policy associated with a Teams App.
+ ///
+ [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"MgBetaTeamAppPreApproval_Update", SupportsShouldProcess = true)]
+ [global::System.Management.Automation.OutputType(typeof(bool))]
+ [global::Microsoft.Graph.Beta.PowerShell.Description(@"Update Preapproval policy associated with a Teams App.")]
+ [global::Microsoft.Graph.Beta.PowerShell.Generated]
+ public partial class UpdateMgBetaTeamAppPreApproval_Update : global::System.Management.Automation.PSCmdlet,
+ Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener
+ {
+ /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet)
+ private global::System.Management.Automation.InvocationInfo __invocationInfo;
+
+ ///
+ /// The for this operation.
+ ///
+ private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource();
+
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Additional Parameters")]
+ public global::System.Collections.Hashtable AdditionalProperties { get; set; } = new System.Collections.Hashtable();
+
+ /// Wait for .NET debugger to attach
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.SwitchParameter Break { get; set; }
+
+ /// The reference to the client API class.
+ public Microsoft.Graph.Beta.PowerShell.Teams Client => Microsoft.Graph.Beta.PowerShell.Module.Instance.ClientAPI;
+
+ /// Backing field for property.
+ private string _teamsAppId;
+
+ ///
+ /// Gets or sets the Teams App Id.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "key: id of Teams App")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Description = @"key: id of Teams App",
+ SerializedName = @"teamsAppId",
+ PossibleTypes = new[] { typeof(string) })]
+ public string TeamsAppId { get => this._teamsAppId; set => this._teamsAppId = value; }
+
+ /// Backing field for property.
+ private string[] _resourceSpecificApplicationPermissionsAllowedForTeams;
+
+ ///
+ /// Resource Specific Permissions Allowed for Teams.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Resource Specific Permissions Allowed for Teams")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Resource Specific Permissions Allowed for Teams",
+ SerializedName = @"resourceSpecificApplicationPermissionsAllowedForTeams",
+ PossibleTypes = new[] { typeof(string) })]
+ public string[] ResourceSpecificApplicationPermissionsAllowedForTeams { get => this._resourceSpecificApplicationPermissionsAllowedForTeams; set => this._resourceSpecificApplicationPermissionsAllowedForTeams = value; }
+
+ ///
+ /// Backing field for property.
+ ///
+ private string[] _resourceSpecificApplicationPermissionsAllowedForChats;
+
+ ///
+ /// Resource Specific Permissions Allowed for chats.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Resource Specific Permissions Allowed for Chats")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Resource Specific Permissions Allowed for Chats",
+ SerializedName = @"resourceSpecificApplicationPermissionsAllowedForChats",
+ PossibleTypes = new[] { typeof(string) })]
+ public string[] ResourceSpecificApplicationPermissionsAllowedForChats { get => this._resourceSpecificApplicationPermissionsAllowedForChats; set => this._resourceSpecificApplicationPermissionsAllowedForChats = value; }
+
+ ///
+ /// Backing field for property.
+ ///
+ private MicrosoftGraphSensitivityLabelCondition? _teamLevelSensitivityLabelCondition;
+
+ ///
+ /// Label selection mode for teams.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Label selection mode for Teams.")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Label selection mode for Teams.",
+ SerializedName = @"teamLevelSensitivityLabelCondition",
+ PossibleTypes = new[] { typeof(MicrosoftGraphSensitivityLabelCondition?) })]
+ public MicrosoftGraphSensitivityLabelCondition? TeamLevelSensitivityLabelCondition { get => this._teamLevelSensitivityLabelCondition; set => this._teamLevelSensitivityLabelCondition = value; }
+
+ /// Backing field for property.
+ private string[] _specificSensitivityLabelIdsApplicableToTeams;
+
+ ///
+ /// Specific Sensitivity label ids applicable to Teams.
+ ///
+ [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Specific Sensitivity label ids applicable to Teams.")]
+ [Microsoft.Graph.Beta.PowerShell.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Description = @"Specific Sensitivity label ids applicable to Teams.",
+ SerializedName = @"specificSensitivityLabelIdsApplicableToTeams",
+ PossibleTypes = new[] { typeof(string) })]
+ public string[] SpecificSensitivityLabelIdsApplicableToTeams { get => this._specificSensitivityLabelIdsApplicableToTeams; set => this._specificSensitivityLabelIdsApplicableToTeams = value; }
+
+ /// SendAsync Pipeline Steps to be appended to the front of the pipeline
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public Microsoft.Graph.Beta.PowerShell.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; }
+
+ /// SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public Microsoft.Graph.Beta.PowerShell.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; }
+
+ /// Accessor for our copy of the InvocationInfo.
+ public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation; set { __invocationInfo = value; } }
+
+ ///
+ /// cancellation delegate. Stops the cmdlet when called.
+ ///
+ global::System.Action Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel;
+
+ /// cancellation token.
+ global::System.Threading.CancellationToken Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Token => _cancellationTokenSource.Token;
+
+ ///
+ /// The instance of the that the remote call will use.
+ ///
+ private Microsoft.Graph.Beta.PowerShell.Runtime.HttpPipeline Pipeline { get; set; }
+
+ /// The URI for the proxy server to use
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Uri Proxy { get; set; }
+
+ /// Credentials for a proxy server to use for the remote call
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")]
+ [global::System.Management.Automation.ValidateNotNull]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.PSCredential ProxyCredential { get; set; }
+
+ /// Use the default credentials for the proxy
+ [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")]
+ [global::Microsoft.Graph.Beta.PowerShell.Category(global::Microsoft.Graph.Beta.PowerShell.ParameterCategory.Runtime)]
+ public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; }
+
+ partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow);
+
+ ///
+ /// overrideOnNoContent will be called before the regular onNoContent has been processed, allowing customization of
+ /// what happens on that response. Implement this method in a partial class to enable this behavior
+ ///
+ /// the raw response message as an global::System.Net.Http.HttpResponseMessage.
+ /// /// Determines if the rest of the onNoContent method should be processed, or if the method should
+ /// return immediately (set to true to skip further processing )
+
+ partial void overrideOnNoContent(global::System.Net.Http.HttpResponseMessage responseMessage, ref global::System.Threading.Tasks.Task returnNow);
+
+ ///
+ /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet)
+ ///
+ protected override void BeginProcessing()
+ {
+ Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);
+ if (Break)
+ {
+ Microsoft.Graph.Beta.PowerShell.Runtime.AttachDebugger.Break();
+ }
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletBeginProcessing).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+
+ /// Performs clean-up after the command execution
+ protected override void EndProcessing()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletEndProcessing).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+
+ /// Handles/Dispatches events during the call to the REST service.
+ /// The message id
+ /// The message cancellation token. When this call is cancelled, this should be true
+ /// Detailed message data for the message event.
+ ///
+ /// A that will be complete when handling of the message is completed.
+ ///
+ async global::System.Threading.Tasks.Task Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData)
+ {
+ using (NoSynchronizationContext)
+ {
+ if (token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ switch (id)
+ {
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Verbose:
+ {
+ WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Warning:
+ {
+ WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Information:
+ {
+ var data = messageData();
+ WriteInformation(data.Message, new string[] { });
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Debug:
+ {
+ WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}");
+ return;
+ }
+ case Microsoft.Graph.Beta.PowerShell.Runtime.Events.Error:
+ {
+ WriteError(new global::System.Management.Automation.ErrorRecord(new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ return;
+ }
+ }
+ await Microsoft.Graph.Beta.PowerShell.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Graph.Beta.PowerShell.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Graph.Beta.PowerShell.Runtime.EventData), InvocationInformation, this.ParameterSetName, null);
+ if (token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ }
+ }
+
+ /// Performs execution of the command.
+ protected override void ProcessRecord()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordStart).Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ try
+ {
+ // work
+ if (ShouldProcess("Update Teams App PreApproval"))
+ {
+ using (var asyncCommandRuntime = new Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token))
+ {
+ asyncCommandRuntime.Wait(ProcessRecordAsync(), ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token);
+ }
+ }
+ }
+ catch (global::System.AggregateException aggregateException)
+ {
+ // unroll the inner exceptions to get the root cause
+ foreach (var innerException in aggregateException.Flatten().InnerExceptions)
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ // Write exception out to error channel.
+ WriteError(new global::System.Management.Automation.ErrorRecord(innerException, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ }
+ }
+ catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException) == null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null)
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ // Write exception out to error channel.
+ WriteError(new global::System.Management.Automation.ErrorRecord(exception, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
+ }
+ finally
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordEnd).Wait();
+ }
+ }
+
+ /// Performs execution of the command, working asynchronously if required.
+ ///
+ /// A that will be complete when handling of the method is completed.
+ ///
+ protected async global::System.Threading.Tasks.Task ProcessRecordAsync()
+ {
+ using (NoSynchronizationContext)
+ {
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordAsyncStart); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletGetPipeline); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ Pipeline = Microsoft.Graph.Beta.PowerShell.Module.Instance.CreatePipeline(InvocationInformation, this.ParameterSetName);
+ if (null != HttpPipelinePrepend)
+ {
+ Pipeline.Prepend((this.CommandRuntime as Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend);
+ }
+ if (null != HttpPipelineAppend)
+ {
+ Pipeline.Append((this.CommandRuntime as Microsoft.Graph.Beta.PowerShell.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend);
+ }
+ // get the client instance
+ try
+ {
+ 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; }
+
+ this.ValidateInputParameters();
+
+ // Get the Teams App
+ Models.IMicrosoftGraphTeamsApp teamsApp = await this.Client.GetTeamsApp(
+ this.TeamsAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Found Teams App with Id: '{teamsApp.Id}'");
+
+ Models.IMicrosoftGraphTeamsAppDefinition publishedAppDefinition =
+ teamsApp?.AppDefinitions?.SingleOrDefault(a => string.Equals(a.PublishingState, "published", StringComparison.OrdinalIgnoreCase));
+ if (publishedAppDefinition == null)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ResourceNotFound,
+ $"Published App Definition was not found for Teams App with Id: '{teamsApp.Id}'.");
+ }
+
+ if (string.IsNullOrEmpty(publishedAppDefinition.AzureAdAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.RequiredPropertyNotFound,
+ $"Teams App with Id: '{teamsApp.Id}' does not have a valid AAd App Id.");
+ }
+
+ WriteVerbose($"Found published Teams App Definition with AzureAdAppId: '{publishedAppDefinition.AzureAdAppId}'");
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ Models.IMicrosoftGraphEntity servicePrincipal = await this.Client.GetServicePrincipal(
+ publishedAppDefinition.AzureAdAppId,
+ this,
+ Pipeline);
+
+ WriteVerbose($"Found service principal with Id: '{servicePrincipal.Id}'");
+
+ // Validate no policies associated with sp
+ MGTeamsInternalPermissionGrantPreApprovalPolicyCollection policiesAssociatedWithServicePrincipal =
+ await this.Client.GetPermissionGrantPreApprovalPoliciesAssociatedWithServicePrincipal(
+ servicePrincipal.Id,
+ this,
+ Pipeline);
+
+ int numOfPoliciesAssociatedWithServicePrincipal = policiesAssociatedWithServicePrincipal.Value?.Count() ?? 0;
+ if (numOfPoliciesAssociatedWithServicePrincipal == 0)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.ResourceNotFound,
+ $"Service principal with Id: '{servicePrincipal.Id}' has no associated policy.");
+ }
+ else if (numOfPoliciesAssociatedWithServicePrincipal > 1)
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.UnsupportedScenario,
+ $"Service principal with Id: '{servicePrincipal.Id}' has more than 1 associated pre-approval policy. Scenario is unsupported.");
+ }
+
+ if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+
+ MGTeamsInternalResourceSpecificPermissionCollection rscPermissionCollection =
+ await this.Client.GetMicrosoftGraphResourceSpecificPermissionCollection(this, Pipeline);
+
+ TeamsAppPreApprovalPolicyConverter teamsAppPreApprovalPolicyConverter =
+ new TeamsAppPreApprovalPolicyConverter(rscPermissionCollection.Value);
+
+ Models.IMicrosoftGraphTeamsAppPreApproval teamsAppPreapproval =
+ await teamsAppPreApprovalPolicyConverter.ConvertToTeamsAppPreApproval(this.TeamsAppId, policiesAssociatedWithServicePrincipal.Value.Single());
+
+ if (this.InvocationInformation.BoundParameters.ContainsKey("ResourceSpecificApplicationPermissionsAllowedForTeams"))
+ {
+ teamsAppPreapproval.ResourceSpecificApplicationPermissionsAllowedForTeams = this.ResourceSpecificApplicationPermissionsAllowedForTeams;
+ }
+
+ if (this.InvocationInformation.BoundParameters.ContainsKey("ResourceSpecificApplicationPermissionsAllowedForChats"))
+ {
+ teamsAppPreapproval.ResourceSpecificApplicationPermissionsAllowedForChats = this.ResourceSpecificApplicationPermissionsAllowedForChats;
+ }
+
+ if (this.InvocationInformation.BoundParameters.ContainsKey("TeamLevelSensitivityLabelCondition"))
+ {
+ teamsAppPreapproval.TeamLevelSensitivityLabelCondition = this.TeamLevelSensitivityLabelCondition;
+ }
+
+ if (this.InvocationInformation.BoundParameters.ContainsKey("SpecificSensitivityLabelIdsApplicableToTeams"))
+ {
+ teamsAppPreapproval.SpecificSensitivityLabelIdsApplicableToTeams = this.SpecificSensitivityLabelIdsApplicableToTeams;
+ }
+
+ // Get sensitivity labels.
+ MGTeamsInternalSensitivityLabelCollection sensitivityLabelCollection = await this.Client.GetSensitivityLabelCollection(
+ this,
+ Pipeline);
+
+ TeamsAppPreApprovalValidator teamsAppPreApprovalValidator = new TeamsAppPreApprovalValidator(sensitivityLabelCollection);
+ teamsAppPreApprovalValidator.Validate(teamsAppPreapproval);
+
+ MGTeamsInternalPermissionGrantPreApprovalPolicy mGTeamsInternalPermissionGrantPreApprovalPolicy =
+ await teamsAppPreApprovalPolicyConverter.ConvertToPermissionGrantPreApprovalPolicy(
+ teamsAppPreapproval.ResourceSpecificApplicationPermissionsAllowedForChats,
+ teamsAppPreapproval.TeamLevelSensitivityLabelCondition,
+ teamsAppPreapproval.SpecificSensitivityLabelIdsApplicableToTeams,
+ teamsAppPreapproval.ResourceSpecificApplicationPermissionsAllowedForTeams);
+
+ await this.Client.UpdatePermissionGrantPreApprovalPolicy(
+ policiesAssociatedWithServicePrincipal.Value.Single().Id,
+ mGTeamsInternalPermissionGrantPreApprovalPolicy,
+ this,
+ Pipeline);
+
+ this.WriteObject(true);
+
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletAfterAPICall); if (((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+ catch (System.Exception ex)
+ {
+ TeamsExceptionHandler.HandleException(
+ ex,
+ new
+ {
+ TeamsAppId = this.TeamsAppId,
+ TeamLevelSensitivityLabelCondition = this.TeamLevelSensitivityLabelCondition,
+ SpecificSensitivityLabelIdsApplicableToTeams = this.SpecificSensitivityLabelIdsApplicableToTeams,
+ ResourceSpecificApplicationPermissionsAllowedForTeams = this.ResourceSpecificApplicationPermissionsAllowedForTeams,
+ ResourceSpecificApplicationPermissionsAllowedForChats = this.ResourceSpecificApplicationPermissionsAllowedForChats,
+ },
+ errorRecord => WriteError(errorRecord),
+ this);
+ ((Runtime.IEventListener)this).Signal(Runtime.Events.CmdletException, $"{ex.GetType().Name} - {ex.Message} : {ex.StackTrace}").Wait();
+ if (((Runtime.IEventListener)this).Token.IsCancellationRequested) { return; }
+ }
+ finally
+ {
+ await ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Signal(Microsoft.Graph.Beta.PowerShell.Runtime.Events.CmdletProcessRecordAsyncEnd);
+ }
+ }
+ }
+
+ /// Interrupts currently running code within the command.
+ protected override void StopProcessing()
+ {
+ ((Microsoft.Graph.Beta.PowerShell.Runtime.IEventListener)this).Cancel();
+ base.StopProcessing();
+ }
+
+ ///
+ /// Intializes a new instance of the cmdlet class.
+ ///
+ public UpdateMgBetaTeamAppPreApproval_Update()
+ {
+
+ }
+
+ ///
+ /// Validate the input parameters of the cmdlet.
+ ///
+ private void ValidateInputParameters()
+ {
+ if (string.IsNullOrWhiteSpace(this.TeamsAppId))
+ {
+ throw new MGTeamsInternalException(
+ MGTeamsInternalErrorType.InvalidCmdletInput,
+ $"'{nameof(this.TeamsAppId)}' cannot be empty.");
+ }
+ }
+ }
+}
\ No newline at end of file