Public/Enable-DuneResourceAlerting.ps1
|
<# .SYNOPSIS Enable alerting for a Dune resource. .DESCRIPTION Enables alerting on a Dune resource and returns a `DuneJob` object representing the operation. Target the resource either by `Id` or by passing a `DuneResource` object via pipeline. .PARAMETER Id The GUID of the resource for which to enable alerting. Mandatory in the `Id` parameter set. .PARAMETER Resource A `DuneResource` object; the resource whose alerting will be enabled. Mandatory in the `Resource` parameter set and accepts pipeline input. .PARAMETER SendNotification Switch indicating whether to send notifications about the alerting change. .EXAMPLE PS> Enable-DuneResourceAlerting -Id 3d8f6b5a-... -SendNotification Enables alerting for the specified resource and sends a notification. .EXAMPLE PS> Get-DuneResource -Name "myvm" | Enable-DuneResourceAlerting Pipeline example using the `Resource` parameter set. #> function Enable-DuneResourceAlerting { [CmdletBinding(DefaultParameterSetName='Default')] param ( [Parameter(Mandatory, ParameterSetName = "Id")] [guid]$Id, [Parameter(Mandatory, ParameterSetName = "Resource", ValueFromPipeline)] [DuneResource]$Resource, [Parameter()] [switch]$SendNotification ) begin {} process { Write-Debug "$($MyInvocation.MyCommand)|process|$($PSCmdlet.ParameterSetName)" if ($Resource) { $Id = $Resource.Id } $Url = "resources/$($Id)/enablealerting" $Body = @{ SendNotification = $SendNotification } $Return = Invoke-DuneApiRequest $Url -Method POST -Body $Body $ReturnObject = if ($Return.Content) { $Return.Content | ConvertFrom-Json | ConvertTo-DuneClassObject -Class DuneJob } return $ReturnObject } end {} } |