nsmcp::AccessSummaryTool method options (public)

 <instance of nsmcp::AccessSummaryTool[i]> options arguments

Defined in /usr/local/ns/tcl/nsmcp/access-tools.tcl

Decode and validate access-summary tool options. Convert the rooted JSON arguments to the supported query and pagination settings.

Parameters:
arguments (required)
Rooted ns_json typed triples for the tool's JSON argument object.
Returns:
A Tcl dictionary of access-summary options.

Testcases:
No testcase defined.
Source code:
set options {windowSeconds 600}
if {[lindex $arguments 1] ne "object"} {
    error "Expected arguments object"
}
foreach {key type value} [lindex $arguments 2] {
    if {$key eq "includePeerAddresses"} {
        if {$type ne "boolean"} {
            error "Expected boolean includePeerAddresses"
        }
    } elseif {$key in {path pool peer authenticationState period windowHandle}} {
        if {$type ne "string"} {
            error "Expected string path or pool"
        }
    } elseif {$key ni {from to bucketSeconds status windowSeconds lastMinutes} || $type ne "number" || ![string is entier -strict $value]} {
        error "Expected integer times/status or string path/pool"
    }
    dict set options $key $value
}
set selectors 0
foreach key {lastMinutes period windowHandle} {
    if {[dict exists $options $key]} {
        incr selectors
    }
}
set explicit [expr {[dict exists $options from] || [dict exists $options to]}]
if {$selectors>1 || ($selectors && $explicit)} {
    error "Use one of lastMinutes, period, windowHandle, or explicit from/to"
}
if {[dict exists $options windowHandle]} {
    set handle [dict get $options windowHandle]
    if {![regexp {^[0-9a-f]{64}$} $handle]} {
        error "Invalid windowHandle"
    }
    dict unset options windowHandle
    set checked [${:analytics} validateWindow $options]
    dict unset checked from
    dict unset checked to
    dict set checked windowHandle $handle
    return $checked
}
set now [clock seconds]
if {[dict exists $options period]} {
    if {[dict get $options period] ne "previous-hour"} {
        error "period must be previous-hour"
    }
    dict unset options period
    set end [expr {($now/3600)*3600}]
    dict set options from [expr {$end-3600}]
    dict set options to $end
} elseif {[dict exists $options lastMinutes] || !$explicit} {
    set minutes 60
    if {[dict exists $options lastMinutes]} {
        set minutes [dict get $options lastMinutes]
        dict unset options lastMinutes
    }
    if {$minutes<1 || $minutes>1440} {
        error "lastMinutes must be between 1 and 1440"
    }
    set end [expr {($now/60)*60}]
    dict set options from [expr {$end-$minutes*60}]
    dict set options to $end
}
return [${:analytics} validateWindow $options]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: