Functions/Public/Releases/Remove-GitHubReleaseAsset.ps1

function Remove-GitHubReleaseAsset {
    <#
    .Synopsis
    This command deletes a GitHub release asset.

    .Description
    This command is responsible for deleting a GitHub release asset

    .PARAMETER Owner
        Optional, the Owner of the repo that you want to create the release on, default to the authenticated user

    .PARAMETER Repository
        Mandatory, the name of the Repository that you want to create the release on.

    .Parameter Id
    The Id of the Gist to remove or remove files from.

    .Example
    PS C:\> Remove-GitHubRelease -Owner 'test-organization' -RepositoryName 'test-repo' -Id 1234567

    #>


    [CmdletBinding(ConfirmImpact = 'High', SupportsShouldProcess = $true)]
    [OutputType([Void])]
    Param (
        [Parameter(Mandatory)]
        [string] $Owner,

        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [ValidatePattern('^[\w-\.]+$')]
        [Alias('Repository')]
        [string] $RepositoryName,

        [Parameter(Mandatory)]
        [String] $Id,

        # Optional base URL of the GitHub API, for example "https://ghe.mycompany.com/api/v3/" (including the trailing slash).
        # Defaults to "https://api.github.com"
        [Uri] $BaseUri = [Uri]::new('https://api.github.com'),
        [Security.SecureString] $Token = (Get-GitHubToken)
    )

    Process {
        $ApiCall = @{
            Uri = "repos/$Owner/$RepositoryName/releases/assets/$Id"
            Method = 'delete'
            Token = $Token
            BaseUri = $BaseUri
        }
    }

    end {
        if ($PSCmdlet.ShouldProcess($Id)) {
            Invoke-GitHubApi @ApiCall
        }
    }
}