nsmcp::AccessTrafficSelection object method options (public)

 nsmcp::AccessTrafficSelection[i] options options

Defined in /usr/local/ns/tcl/nsmcp/log-traffic-failed.tcl

Validate and supply defaults for failed-traffic selection.

Parameters:
options (required)
A query dictionary containing the requested time bounds.
Returns:
Validated options with status, source and bucket defaults.

Testcases:
No testcase defined.
Source code:
set options [dict merge {status {} statusClass {} pool {} method {} recordSource all bucketSeconds {}} $options]
set status [dict get $options status]
set class [dict get $options statusClass]
if {$status ne {} && (![string is integer -strict $status] || $status<100 || $status>599)} {
    error "status must be 100..599"
}
if {$class ne {} && $class ni {1xx 2xx 3xx 4xx 5xx 4xx/5xx}} {
    error "statusClass must be 1xx..5xx or 4xx/5xx"
}
if {$status ne {} && $class ne {}} {
    error "Use status or statusClass, not both"
}
foreach key {pool method} {
    set value [dict get $options $key]
    if {[string length [encoding convertto utf-8 $value]]>128 || [regexp {[\x00-\x20\x7f]} $value]} {
        error "$key must be an exact value without spaces/control characters, at most 128 UTF-8 bytes"
    }
}
if {[dict get $options method] ne {} && ![regexp {^[A-Z][A-Z0-9_-]{0,31}$} [dict get $options method]]} {
    error "method must be an uppercase HTTP method, at most 32 characters"
}
if {[dict get $options recordSource] ni {all driver connection unknown}} {
    error "Invalid recordSource"
}
set seconds [dict get $options bucketSeconds]
set span [expr {[dict get $options to]-[dict get $options from]}]
if {$seconds eq {}} {
    set seconds [expr {max(1,int(ceil($span/60.0)))}]
}
if {![string is integer -strict $seconds] || $seconds<1 || int(ceil($span/double($seconds)))>3600} {
    error "bucketSeconds must be positive and produce at most 3600 buckets"
}
dict set options bucketSeconds $seconds
return $options
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: