
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. 
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
# See the License for the specific language governing permissions and
# limitations under the License. 
# ----------------------------------------------------------------------------------

<#
.Synopsis
Commits the set of resources included in the request body. 
The commit operation is triggered on the moveResources in the moveState 'CommitPending' or 'CommitFailed', on a successful completion the moveResource moveState do a transition to Committed. 
To aid the user to prerequisite the operation the client can call operation with validateOnly property set to true. 
.Description
Commits the set of resources included in the request body. 
The commit operation is triggered on the moveResources in the moveState 'CommitPending' or 'CommitFailed', on a successful completion the moveResource moveState do a transition to Committed. 
To aid the user to prerequisite the operation the client can call operation with validateOnly property set to true. 
.Example
PS C:\> Invoke-AzResourceMoverCommit -ResourceGroupName RG-MoveCollection-demoRM -MoveCollectionName PS-centralus-westcentralus-demoRM -MoveResource $('psdemorm') -ValidateOnly


AdditionalInfo :
Code           :
Detail         :
EndTime        : 8/21/2020 6:17:00 AM
Id             : /subscriptions/e80eb9fa-c996-4435-aa32-5af6f3d3077c/resourceGroups/RG-MoveCollection-demoRM/providers/Microsoft. Migrate/MoveColl
                 ections/PS-centralus-westcentralus-demoRM/operations/5524d3f4-dd47-4572-9d8d-c62d3b513ee0
Message        :
Name           : 5524d3f4-dd47-4572-9d8d-c62d3b513ee0
Property       : Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Models. Api20191001Preview. OperationStatusProperties
StartTime      : 8/21/2020 6:16:59 AM
Status         : Succeeded

.Example
PS C:\>Invoke-AzResourceMoverCommit -ResourceGroupName RG-MoveCollection-demoRM -MoveCollectionName PS-centralus-westcentralus-demoRM -MoveResource $('psdemorm')

AdditionalInfo :
Code           :
Detail         :
EndTime        : 8/21/2020 6:17:00 AM
Id             : /subscriptions/e80eb9fa-c996-4435-aa32-5af6f3d3077c/resourceGroups/RG-MoveCollection-demoRM/providers/Microsoft. Migrate/MoveColl
                 ections/PS-centralus-westcentralus-demoRM/operations/5524d3f4-dd47-4572-9d8d-c62d3b513ee0
Message        :
Name           : 5524d3f4-dd47-4572-9d8d-c62d3b513ee0
Property       : Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Models. Api20191001Preview. OperationStatusProperties
StartTime      : 8/21/2020 6:16:59 AM
Status         : Succeeded


.Example
PS C:\> Invoke-AzResourceMoverCommit -ResourceGroupName RG-MoveCollection-demoRM -MoveCollectionName PS-centralus-westcentralus-demoRM -MoveResourceInputType MoveResourceSourceId  -MoveResource $('/subscriptions/e80eb9fa-c996-4435-aa32-5af6f3d3077c/resourceGroups/PSDemoRM')

AdditionalInfo :
Code           :
Detail         :
EndTime        : 8/21/2020 6:19:29 AM
Id             : /subscriptions/e80eb9fa-c996-4435-aa32-5af6f3d3077c/resourceGroups/RG-MoveCollection-demoRM/providers/Microsoft. Migrate/MoveColl
                 ections/PS-centralus-westcentralus-demoRM/operations/aa9e2c4d-2160-4e36-b6fa-7465a3829ae9
Message        :
Name           : aa9e2c4d-2160-4e36-b6fa-7465a3829ae9
Property       : Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Models. Api20191001Preview. OperationStatusProperties
StartTime      : 8/21/2020 6:19:28 AM
Status         : Succeeded



.Outputs
Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Models. Api20191001Preview. IOperationStatus
.Link
https://docs.microsoft.com/en-us/powershell/module/az.resourcemover/invoke-azresourcemovercommit
#>
function Invoke-AzResourceMoverCommit {
[OutputType([Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Models. Api20191001Preview. IOperationStatus])]
[CmdletBinding(DefaultParameterSetName='CommitExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
    [Parameter(Mandatory)]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Path')]
    [System. String]
    # The Move Collection Name. 
    ${MoveCollectionName},

    [Parameter(Mandatory)]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Path')]
    [System. String]
    # The Resource Group Name. 
    ${ResourceGroupName},

    [Parameter()]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Path')]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Runtime. DefaultInfo(Script='(Get-AzContext).Subscription. Id')]
    [System. String]
    # The Subscription ID. 
    ${SubscriptionId},

    [Parameter(Mandatory)]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Body')]
    [System. String[]]
    # Gets or sets the list of resource Id's, by default it accepts move resource id's unless the input type is switched via moveResourceInputType property. 
    ${MoveResource},

    [Parameter()]
    [ArgumentCompleter([Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Support. MoveResourceInputType])]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Body')]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Support. MoveResourceInputType]
    # Defines the move resource input type. 
    ${MoveResourceInputType},

    [Parameter()]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Body')]
    [System. Management. Automation. SwitchParameter]
    # Gets or sets a value indicating whether the operation needs to only run pre-requisite. 
    ${ValidateOnly},

    [Parameter()]
    [Alias('AzureRMContext', 'AzureCredential')]
    [ValidateNotNull()]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Azure')]
    [System. Management. Automation. PSObject]
    # The credentials, account, tenant, and subscription used for communication with Azure. 
    ${DefaultProfile},

    [Parameter()]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Runtime')]
    [System. Management. Automation. SwitchParameter]
    # Run the command as a job
    ${AsJob},

    [Parameter(DontShow)]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Runtime')]
    [System. Management. Automation. SwitchParameter]
    # Wait for .NET debugger to attach
    ${Break},

    [Parameter(DontShow)]
    [ValidateNotNull()]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Runtime')]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Runtime. SendAsyncStep[]]
    # SendAsync Pipeline Steps to be appended to the front of the pipeline
    ${HttpPipelineAppend},

    [Parameter(DontShow)]
    [ValidateNotNull()]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Runtime')]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Runtime. SendAsyncStep[]]
    # SendAsync Pipeline Steps to be prepended to the front of the pipeline
    ${HttpPipelinePrepend},

    [Parameter()]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Runtime')]
    [System. Management. Automation. SwitchParameter]
    # Run the command asynchronously
    ${NoWait},

    [Parameter(DontShow)]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Runtime')]
    [System. Uri]
    # The URI for the proxy server to use
    ${Proxy},

    [Parameter(DontShow)]
    [ValidateNotNull()]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Runtime')]
    [System. Management. Automation. PSCredential]
    # Credentials for a proxy server to use for the remote call
    ${ProxyCredential},

    [Parameter(DontShow)]
    [Microsoft. Azure. PowerShell. Cmdlets. ResourceMover. Category('Runtime')]
    [System. Management. Automation. SwitchParameter]
    # Use the default credentials for the proxy
    ${ProxyUseDefaultCredentials}
)

begin {
    try {
        $outBuffer = $null
        if ($PSBoundParameters. TryGetValue('OutBuffer', [ref]$outBuffer)) {
            $PSBoundParameters['OutBuffer'] = 1
        }
        $parameterSet = $PSCmdlet. ParameterSetName
        $mapping = @{
            CommitExpanded = 'Az. ResourceMover.private\Invoke-AzResourceMoverCommit_CommitExpanded';
        }
        if (('CommitExpanded') -contains $parameterSet -and -not $PSBoundParameters. ContainsKey('SubscriptionId')) {
            $PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription. Id
        }
        $wrappedCmd = $ExecutionContext. InvokeCommand. GetCommand(($mapping[$parameterSet]), [System. Management. Automation. CommandTypes]::Cmdlet)
        $scriptCmd = {& $wrappedCmd @PSBoundParameters}
        $steppablePipeline = $scriptCmd. GetSteppablePipeline($MyInvocation. CommandOrigin)
        $steppablePipeline. Begin($PSCmdlet)
    } catch {
        throw
    }
}

process {
    try {
        $steppablePipeline. Process($_)
    } catch {
        throw
    }
}

end {
    try {
        $steppablePipeline. End()
    } catch {
        throw
    }
}
}
