Public/ControlPanel/Set-R1ControlPanelConfiguration.ps1

# .ExternalHelp psRadiantOne-help.xml
function Set-R1ControlPanelConfiguration {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
    [OutputType([void])]
    param(
        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidatePattern('^#[0-9A-Fa-f]{6}$')]
        [string]$dashboardColorTheme,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateRange(0, [int]::MaxValue)]
        [int]$controlPanelTimeout,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [bool]$lockControlPanel,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateRange(0, [int]::MaxValue)]
        [int]$maxConcurrentUsers,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [string]$bannerText,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidatePattern('^$|^#[0-9A-Fa-f]{6}$')]
        [string]$bannerBackgroundColor,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidatePattern('^$|^#[0-9A-Fa-f]{6}$')]
        [string]$bannerTextColor,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [string]$messageContent,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [string]$messageTitle,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [bool]$warning,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [bool]$popup
    )

    Begin {

        Assert-R1Session -RequireToken

    }#begin

    Process {

        $URI = Resolve-R1ServiceUrl -Service Settings -Path 'control_panel_configuration'

        #Retrieve the current settings and send them back with the supplied values applied over
        #them, so a setting left unspecified keeps its current value.
        $Existing = Get-R1ControlPanelConfiguration

        $Template = [ordered]@{
            dashboardColorTheme   = '#000000'
            controlPanelTimeout   = 30
            lockControlPanel      = $false
            maxConcurrentUsers    = 0
            bannerText            = ''
            bannerBackgroundColor = ''
            bannerTextColor       = ''
            messageContent        = ''
            messageTitle          = ''
            warning               = $false
            popup                 = $false
        }

        $Request = Merge-R1Parameter -Template $Template -BoundParameter ($PSBoundParameters | Get-Parameter) -Fallback $Existing

        $Body = $Request | ConvertTo-R1JsonBody

        if ($PSCmdlet.ShouldProcess($Script:psRadiantOneSession.BaseURI, 'Update Control Panel Configuration')) {

            $null = Invoke-R1RestMethod -Uri $URI -Method PUT -Body $Body

        }

    }#process

    End { }#end

}