::nsmcp::LogTool ::nsmcp::LogTool arguments execute validate ::nsmcp::Tool ::nsmcp::Tool describe execute name permission validate ::nsmcp::LogTool->::nsmcp::Tool ::nsmcp::ServerDescribe ::nsmcp::ServerDescribe execute ::nsmcp::ServerDescribe->::nsmcp::Tool ::nsmcp::StatsTool ::nsmcp::StatsTool available encode unavailable ::nsmcp::StatsTool->::nsmcp::Tool ::nsmcp::AccessSummaryTool ::nsmcp::AccessSummaryTool execute options validate ::nsmcp::AccessSummaryTool->::nsmcp::Tool ::nx::Object ::nx::Object __default_accessor __default_method_call_protection __object_configureparameter __resolve_method_path contains copy delete object method delete object property delete object variable destroy_on_cleanup info consts info info info lookup parameters info lookup slots info lookup syntax info lookup variables info object method args info object method body info object method callprotection info object method debug info object method definition info object method definitionhandle info object method deprecated info object method exists info object method handle info object method origin info object method parameters info object method registrationhandle info object method returns info object method submethods info object method syntax info object method type info object slots info object variables info variable definition info variable name info variable parameter move object alias object forward object method object property object variable private protected public qn require namespace require object method require private object method require protected object method require public object method serialize ::nsmcp::Tool->::nx::Object

Class ::nsmcp::LogTool

::nsmcp::LogTool[i] create ... \
           [ -description:required description:required ] \
           [ -inputSchema (default "{} object {type string object properties object {} additionalProperties boolean false}") ] \
           [ -name:required name:required ] \
           [ -operation:required operation:required ] \
           [ -outputSchema (default "") ] \
           [ -permission:required permission:required ] \
           [ -service:required service:required ]

Defined in /usr/local/ns/tcl/nsmcp/lib/log-tools.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nsmcp::Tool[i]
::nx::Class create ::nsmcp::LogTool \
     -superclass ::nsmcp::Tool

Methods (to be applied on instances)

  • execute (scripted, public)

     <instance of nsmcp::LogTool[i]> execute context arguments
    Parameters:
    context (required)
    arguments (required)

    Testcases:
    No testcase defined.
    set values [:arguments $arguments]
    switch ${:operation} {
        errors {return [${:service} start $context errors]}
        requestContext {return [${:service} start $context requestContext [dict get $values identifier]]}
        results {
            if {[dict exists $values jobHandle]} {return [${:service} poll $context [dict get $values jobHandle]]}
            set values [dict merge {cursor 0 limit 20 includePeerAddresses false} $values]
            return [${:service} results $context [dict get $values resultHandle] [dict get $values cursor]  [dict get $values limit] [dict get $values includePeerAddresses]]
        }
    }
  • validate (scripted, public)

     <instance of nsmcp::LogTool[i]> validate arguments
    Parameters:
    arguments (required)

    Testcases:
    No testcase defined.
    if {[lindex $arguments 1] ne "object"} {
        return -code error -errorcode {NSMCP RPC -32602} "Expected arguments object"
    }
    set allowed [dict get [dict create errors {} requestContext {identifier} results {jobHandle resultHandle cursor limit includePeerAddresses}] ${:operation}]
    foreach {key type value} [lindex $arguments 2] {
        if {$key ni $allowed} {return -code error -errorcode {NSMCP RPC -32602} "Unknown log argument"}
        set expected string
        if {$key eq "limit"} {set expected number}
        if {$key eq "includePeerAddresses"} {set expected boolean}
        if {$type ne $expected} {return -code error -errorcode {NSMCP RPC -32602} "Invalid log argument type"}
        if {$key in {jobHandle resultHandle} && ![regexp {^[0-9a-f]{64}$} $value]} {
            return -code error -errorcode {NSMCP RPC -32602} "Invalid log handle"
        }
        if {$key eq "limit" && (![string is integer -strict $value] || $value < 1 || $value > 100)} {
            return -code error -errorcode {NSMCP RPC -32602} "Limit must be between 1 and 100"
        }
        if {$key eq "cursor" && (![string is entier -strict $value] || $value < 0)} {
            return -code error -errorcode {NSMCP RPC -32602} "Invalid cursor"
        }
    }
    set values [:arguments $arguments]
    if {${:operation} eq "requestContext" && (![dict exists $values identifier] ||
        ![::nsmcp::logRecordParser validRequestIdentifier [dict get $values identifier]])} {
        return -code error -errorcode {NSMCP RPC -32602} "Expected a dash-delimited log-thread identifier"
    }
    if {${:operation} eq "results"} {
        if {[dict exists $values jobHandle] == [dict exists $values resultHandle]} {
            return -code error -errorcode {NSMCP RPC -32602} "Supply exactly one of jobHandle (poll a job) or resultHandle (read a page)"
        }
        if {[dict exists $values jobHandle] && [dict size $values]!=1} {
            return -code error -errorcode {NSMCP RPC -32602} "Poll with jobHandle alone. Paging and includePeerAddresses apply to resultHandle pages; for access summaries set includePeerAddresses on access_summary"
        }
    }