Public/Remove-DuneAction.ps1

<#
.SYNOPSIS
Remove an action.
 
.DESCRIPTION
Deletes an action by sending a DELETE request. Accepts an action object via pipeline or by ID. ShouldProcess is observed.
 
.PARAMETER Action
A `DuneAction` object to remove. Accepts pipeline input.
 
.PARAMETER ActionId
The GUID of the action to remove.
 
.EXAMPLE
PS> Remove-DuneAction -ActionId 3d8f6b5a-...
Removes the action with the specified ID.
 
.EXAMPLE
PS> Get-DuneAction -Name "old" | Remove-DuneAction
Removes actions via pipeline.
#>

function Remove-DuneAction {
    [CmdletBinding(
        SupportsShouldProcess,
        DefaultParameterSetName = 'Id',
        ConfirmImpact = 'High'
    )]
    param(
        [Parameter(ValueFromPipeline, ParameterSetName = "Object")]
        [DuneAction]$Action,

        [Parameter(ParameterSetName = 'Id')]
        [guid]$ActionId
    )

    begin {}

    process {
        if ($PSCmdlet.ParameterSetName -eq 'Id') { $Action = Get-DuneAction -Id $ActionId }
        $Uri = "actions/$($Action.Id)"
        
        if ($PSCmdlet.ShouldProcess($Action.Name)) {
            $null = Invoke-DuneApiRequest -Uri $Uri -Method DELETE
        }
    }

    end {}
}