Public/New-OnePAMResource.ps1

function New-OnePAMResource {
    <#
    .SYNOPSIS
        Creates a new OnePAM resource.
    .DESCRIPTION
        Creates a new SSH, RDP, database, or HTTPS resource.
    .PARAMETER Name
        Display name for the resource.
    .PARAMETER Type
        Resource type: ssh, rdp, database, or https.
    .PARAMETER TargetHost
        Target hostname or IP address.
    .PARAMETER Port
        Target port number.
    .PARAMETER AgentId
        UUID of the agent endpoint managing this resource.
    .PARAMETER Enabled
        Whether the resource is enabled (default: true).
    .EXAMPLE
        New-OnePAMResource -Name "prod-db" -Type database -TargetHost "db.internal" -Port 5432 -AgentId "abc-123"
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$Name,

        [Parameter(Mandatory)]
        [ValidateSet('ssh', 'rdp', 'database', 'https')]
        [string]$Type,

        [Parameter(Mandatory)]
        [Alias('Host')]
        [string]$TargetHost,

        [int]$Port,

        [string]$AgentId,

        [bool]$Enabled = $true
    )

    $body = @{
        name    = $Name
        type    = $Type
        host    = $TargetHost
        enabled = $Enabled
    }
    if ($Port -gt 0) { $body['port'] = $Port }
    if ($AgentId) { $body['agent_id'] = $AgentId }

    $resp = Invoke-OpApi -Method POST -Path '/api/v1/resources' -Body $body
    if ($resp.resource) { return $resp.resource }
    $resp
}