Public/Set-DuneAction.ps1

<#
.SYNOPSIS
Update an action.

.DESCRIPTION
PUT to `actions/[id]` to update allowed properties such as `IsDisabled`.
#>

function Set-DuneAction {
    [CmdletBinding()]
    param(
        [Parameter(ValueFromPipeline, ParameterSetName = "Object")]
        [DuneAction]$Action,

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

        [Parameter()]
        [bool]$IsDisabled
    )

    begin {}

    process {
        if ($Action) { $Id = $Action.Id }
        $Body = @{}
        if ($PSBoundParameters.ContainsKey('IsDisabled')) { $Body.IsDisabled = $IsDisabled }
        if (-not $Body.Keys) { Throw 'No properties specified to update.' }

        $Uri = "actions/$Id"
        $null = Invoke-DuneApiRequest -Uri $Uri -Method 'PUT' -Body $Body
    }

    end {}
}