nsmcp::CodexLogSummaryTool method options (protected)

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

Defined in /usr/local/ns/tcl/nsmcp/codex-logs.tcl

Parameters:
arguments (required)

Testcases:
No testcase defined.
Source code:
if {[lindex $arguments 1] ne "object"} {
    return -code error -errorcode {NSMCP RPC -32602} "Expected arguments object"
}
set values {}
foreach {key type value} [lindex $arguments 2] {
    if {$key ni {from to lastMinutes limit} || $type ne "number"
        || ![regexp {^(0|[1-9][0-9]*)$} $value] || [dict exists $values $key]} {
        return -code error -errorcode {NSMCP RPC -32602} "Invalid Codex log argument"
    }
    dict set values $key $value
}
if {[dict exists $values from] != [dict exists $values to]
    || ([dict exists $values from] && [dict exists $values lastMinutes])} {
    return -code error -errorcode {NSMCP RPC -32602} "Supply both from and to, or lastMinutes"
}
set limit [expr {[dict exists $values limit] ? [dict get $values limit] : 20}]
if {$limit < 1 || $limit > 50} {
    return -code error -errorcode {NSMCP RPC -32602} "limit must be 1..50"
}
if {[dict exists $values from]} {
    set from [dict get $values from]
    set to [dict get $values to]
    if {$to <= $from || $to - $from > 86400} {
        return -code error -errorcode {NSMCP RPC -32602} "Window must be positive and at most one day"
    }
} else {
    set minutes [expr {[dict exists $values lastMinutes] ? [dict get $values lastMinutes] : 10}]
    if {$minutes < 1 || $minutes > 1440} {
        return -code error -errorcode {NSMCP RPC -32602} "lastMinutes must be 1..1440"
    }
    set to [expr {[clock seconds] + 1}]
    set from [expr {$to - $minutes * 60}]
}
return [list $from $to $limit]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: