Public/New-DuneAction.ps1
|
<#
.SYNOPSIS Create a new action. .DESCRIPTION POSTs a new action to the `actions` endpoint. Provide `SchemaVersion` and `Definition`. .PARAMETER SchemaVersion The schema version for the action definition. Required. .PARAMETER Definition The action definition as a JSON string. Required. .PARAMETER Name An optional name for the action. .EXAMPLE PS> New-DuneAction -SchemaVersion 1 -Definition '{"steps":[...]}' Creates a new action with the given definition. #> function New-DuneAction { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [int]$SchemaVersion, [Parameter(Mandatory=$true)] [string]$Definition, [Parameter()] [string]$Name ) begin {} process { $Body = @{ SchemaVersion = $SchemaVersion Definition = $Definition } if ($PSBoundParameters.ContainsKey('Name')) { $Body.Name = $Name } $Return = Invoke-DuneApiRequest -Uri 'actions' -Method 'POST' -Body $Body $ReturnObject = if ($Return.Content) { $Return.Content | ConvertFrom-Json | ConvertTo-DuneClassObject -Class DuneAction } return $ReturnObject } end {} } |