Public/Connectors/New-SIAHttpsRelayInstallScript.ps1

function New-SIAHttpsRelayInstallScript {
    <#
    .SYNOPSIS
        Generates a SIA HTTPS relay installation script.
    .DESCRIPTION
        Calls the HTTPS relay setup-script generation operation.
    .PARAMETER HttpsRelayOs
        The target operating system for the HTTPS relay. Defaults to
        'linux', matching CyberArk's own default.
    .PARAMETER ExpirationMinutes
        How long the generated script remains valid, in minutes.
    .PARAMETER ProtocolPortMap
        A map of protocol name to port the relay should listen on, e.g.
        @{ SSH = 2222; POSTGRES = 5432; MYSQL = 3306 }.
    .PARAMETER ProxyHost
        Proxy host the relay should use to reach SIA.
    .PARAMETER ProxyPort
        Proxy port the relay should use to reach SIA.
    .PARAMETER WindowsInstallationPath
        Custom installation path, for Windows relay hosts only.
    .EXAMPLE
        New-SIAHttpsRelayInstallScript -HttpsRelayOs linux -ProtocolPortMap @{ SSH = 2222 }

        Requests an installation script for a Linux HTTPS relay listening for SSH on port 2222.
    .INPUTS
        None.
    .OUTPUTS
        psSIA.HttpsRelayInstallScript
    .LINK
        https://api-docs.cyberark.com/secure-infra-access/docs/sia-connector-api
    #>

    [CmdletBinding()]
    [OutputType('psSIA.HttpsRelayInstallScript')]
    [Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '',
        Justification = 'Generates a downloadable script; it does not create or modify any tenant resource.')]
    param(
        [ValidateSet('windows', 'darwin', 'linux')]
        [string]$HttpsRelayOs = 'linux',

        [int]$ExpirationMinutes,

        [hashtable]$ProtocolPortMap,

        [string]$ProxyHost,

        [int]$ProxyPort,

        [string]$WindowsInstallationPath
    )

    $body = @{ https_relay_os = $HttpsRelayOs }
    if ($PSBoundParameters.ContainsKey('ExpirationMinutes')) { $body.expiration_minutes = $ExpirationMinutes }
    if ($PSBoundParameters.ContainsKey('ProtocolPortMap')) { $body.protocol_port_map = $ProtocolPortMap }
    if ($PSBoundParameters.ContainsKey('ProxyHost')) { $body.proxy_host = $ProxyHost }
    if ($PSBoundParameters.ContainsKey('ProxyPort')) { $body.proxy_port = $ProxyPort }
    if ($PSBoundParameters.ContainsKey('WindowsInstallationPath')) { $body.windows_installation_path = $WindowsInstallationPath }

    Invoke-SIARequest -Method POST -Path '/api/https-relays/setup-script' -Body $body |
        ConvertFrom-SIAResponse -TypeName 'psSIA.HttpsRelayInstallScript'
}