Public/Set-DuneDeploymentSequence.ps1
|
<# .SYNOPSIS Update a deployment's sequence configuration. .DESCRIPTION Updates the sequence (batches and usage) for a deployment. Identify the deployment by `Id` or pass a `DuneDeployment` object via pipeline. The `Batches` parameter describes batch structure for the deployment sequence. .PARAMETER Id The GUID of the deployment whose sequence will be updated. Mandatory in the `Id` parameter set. .PARAMETER Deployment A `DuneDeployment` object; when provided via pipeline, the deployment id will be used to update the sequence. .PARAMETER Usage The `SequenceUsage` value (for example `OnStart`) describing when the sequence applies. .PARAMETER Batches Hashtable describing batch configuration. Expected format: `@{'0'=@{PostBatchDelayMinutes=3;Items=@([DuneComputeNodeObject])};'1'=@{...}}`. .EXAMPLE PS> Set-DuneDeploymentSequence -Id 3d8f6b5a-... -Usage OnStart -Batches @{ '0' = @{ PostBatchDelayMinutes = 3; Items = @() } } Update the `OnStart` sequence for a deployment. .EXAMPLE PS> Get-DuneDeployment -Name "app" | Set-DuneDeploymentSequence -Batches @{ '0' = @{ PostBatchDelayMinutes = 2; Items = @() } } Pipeline example using the `Deployment` parameter set. #> function Set-DuneDeploymentSequence { [CmdletBinding(DefaultParameterSetName = "Default")] param ( [Parameter(Mandatory, ParameterSetName = "Id")] [guid]$Id, [Parameter(Mandatory, ParameterSetName = "Deployment", ValueFromPipeline)] [DuneDeployment]$Deployment, [SequenceUsage]$Usage = "OnStart", [Hashtable]$Batches #format: @{'0'=@{PostBatchDelayMinutes=3;Items=@([DuneComputeNodeObject])};'1'=@{PostBatchDelayMinutes=2;Items=@([DuneComputeNodeObject]])} ) begin { Write-Debug "$($MyInvocation.MyCommand)|begin" $ReturnObjects = @() $BaseUri = 'deployments/{0}/sequences' $Method = 'PATCH' } process { Write-Debug "$($MyInvocation.MyCommand)|process|$($PSCmdlet.ParameterSetName)" if ($PSCmdlet.ParameterSetName -eq 'Deployment') { $Id = $Deployment.Id } # Build Uri $Uri = $BaseUri -f $Id $Body = @{ Usage = $Usage.toString() Batches = $Batches } $ResultItems = Invoke-DuneApiRequest -Method $Method -Uri $Uri -Body $Body } end { Write-Debug "$($MyInvocation.MyCommand)|end" return $ReturnObjects } } |