@ -681,6 +681,13 @@ tcl::namespace::eval punk::netbox {
variable contexts [dict create]
variable context_id 0
namespace eval argdoc {
variable PUNKARGS
set DYN_CONTEXTNAMES {${[punk::netbox::api_context_names]}}
}
proc api_context_names {} {
variable contexts
return [dict keys $contexts]
@ -845,7 +852,7 @@ tcl::namespace::eval punk::netbox {
set nowarnings [dict exists $received -nowarnings]
if {$filepath eq ""} {
set filepath [_datafile]
set filepath [_datafile -quiet ]
}
if {![file exists $filepath]} {
error "No existing datafile at '$filepath'\nUse api_context_create/api_context_save to configure and save contexts"
@ -900,12 +907,16 @@ tcl::namespace::eval punk::netbox {
set received [dict get $argd received]
set be_quiet [dict exists $received -quiet]
set nowarnings [dict exists $received -nowarnings]
if {!$bequiet} {
set filepath [_datafile]
} else {
set filepath [_datafile -quiet]
}
if {![file exists $filepath]} {
error "No existing datafile at '$filepath'\nCall api_context_load with a path to a .toml file with context records\nor use api_context_create/api_context_save."
}
if {!$be_quiet} {
puts stdout "Loading API token contexts from [_datafile] "
puts stdout "Loading API token contexts from $filepath "
}
if {$nowarnings} {
api_context_load -nowarnings
@ -992,6 +1003,7 @@ tcl::namespace::eval punk::netbox {
}
namespace eval argdoc {
lappend PUNKARGS [list {
@dynamic
@id -id ::punk::netbox::api_context_get
@cmd -name punk::netbox::api_context_get -help\
"Get api context fields for a single context.
@ -1003,7 +1015,7 @@ tcl::namespace::eval punk::netbox {
Contextids can be created in-memory using
api_context_create, or loaded from a .toml
file using api_context_load."\
-choices {${[punk::netbox::api_context_names] }}
-choices {${$DYN_CONTEXTNAMES }}
@values -min 0 -max -1
field -type string -multiple 1 -optional 1 -help\
"If no field arguments are supplied, all will
@ -1646,8 +1658,10 @@ tcl::namespace::eval punk::netbox {
append _number_filter_help [textblock::list_as_table -columns 3 -show_hseps 1 $_filter_number]
}
namespace eval argdoc {
punk::args::define {*}[list\
{
@dynamic
@id -id ::punk::netbox::status
@cmd -name punk::netbox::status -help\
"status_list
@ -1661,7 +1675,7 @@ tcl::namespace::eval punk::netbox {
A contextid can be created in-memory using
api_context_create, or loaded from a .toml
file using api_context_load."\
-choices {${[punk::netbox::api_context_names] }}
-choices {${$DYN_CONTEXTNAMES }}
@opts
}\
[set ::punk::netbox::argdoc::_RETURN_STATUS]\
@ -1669,6 +1683,7 @@ tcl::namespace::eval punk::netbox {
-ASYNC -type none
@values -min 0 -max 0
}]
}
::punk::netbox::system::make_rest_func_async ::punk::netbox::status api/status/ -verb get -body none
#test - to see what the create_interface procs look like with a callback
@ -1779,6 +1794,8 @@ tcl::namespace::eval punk::netbox {
tcl::namespace::eval punk::netbox::dcim {
namespace export {[a-z]*}
namespace eval argdoc {
set DYN_CONTEXTNAMES {${[punk::netbox::api_context_names]}}
lappend PUNKARGS [list\
{
@dynamic
@ -1792,7 +1809,7 @@ tcl::namespace::eval punk::netbox::dcim {
A contextid can be created in-memory using
api_context_create, or loaded from a .toml
file using api_context_load."\
-choices {${[punk::netbox::api_context_names] }}
-choices {${$DYN_CONTEXTNAMES }}
@opts
-id -type integer
-ID_FILTER -type list -minsize 2 -maxsize 2 -multiple 1 -unindentedfields {-help} -help\
@ -1866,6 +1883,7 @@ tcl::namespace::eval punk::netbox::dcim {
{
@values -min 0 -max 0
}]
}
::punk::netbox::system::make_rest_func_async ::punk::netbox::dcim::devices_list api/dcim/devices/ -verb get -body none
}