CoreOps/VolumeGroupView/Remove-SDPVolumeGroupView.ps1

<#
    .SYNOPSIS
    Deletes a volume group view from the SDP.

    .DESCRIPTION
    Removes a view (snapshot record with `is_exposable=true`). The view
    must not have any active host mappings — remove those first.

    .PARAMETER id
    The unique identifier of the view to remove. Accepts piped input
    from Get-SDPVolumeGroupView.

    .PARAMETER context
    K2 context name. Defaults to 'sdpconnection'.

    .EXAMPLE
    Remove-SDPVolumeGroupView -id 12

    .EXAMPLE
    Get-SDPVolumeGroupView -name "test-vg:test-view" | Remove-SDPVolumeGroupView

    .NOTES
    Authored by J.R. Phillips (GitHub: JayAreP)

    .LINK
    https://github.com/silk-us/silk-sdp-powershell-sdk
#>


function Remove-SDPVolumeGroupView {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
    param(
        [parameter(Mandatory, ValueFromPipelineByPropertyName)]
        [Alias('pipeId')]
        [string] $id,
        [parameter()]
        [switch] $Force,
        [parameter()]
        [string] $context = 'sdpconnection'
    )

    begin {
        $endpoint = 'snapshots'
    }

    process {
        if ($Force -and -not $PSBoundParameters.ContainsKey('Confirm')) {
            $ConfirmPreference = 'None'
        }
        if ($PSCmdlet.ShouldProcess("SDPVolumeGroupView id=$id", 'Remove')) {
            Write-Verbose "Removing view with id $id"
            $results = Invoke-SDPRestCall -endpoint "$endpoint/$id" -method DELETE -context $context
            return $results
        }
    }
}