Public/Update-DuneActionDefinition.ps1

<#
.SYNOPSIS
Update the definition of a Dune Action.

.DESCRIPTION
Patches the YAML definition of a specific action. This is used to update the logic or parameters of an action without changing its metadata.

.PARAMETER Action
The DuneAction object to update.

.PARAMETER Id
The unique identifier (GUID) of the action to update.

.PARAMETER Definition
The new definition for the action in YAML format. (Eg. Get-Content $File -Raw)

.PARAMETER SchemaVersion
The version of the schema used for the definition.

.EXAMPLE
Update-DuneActionDefinition -Id '550e8400-e29b-41d4-a716-446655440000' -Definition $MyYamlString
#>


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

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

        [Parameter(Mandatory, HelpMessage="Format: YAML.")]
        [string]$Definition,

        [Parameter()]
        [int]$SchemaVersion
    )

    begin {}

    process {
        if ($Action) { $Id = $Action.Id }

        $Body = @{
            Definition = $Definition
        }

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

    end {}
}