}
else {
my $stanza = undef;
try {
$stanza = from_json( $line );
debug sprintf '[%s] external credentials stanza added',
$
search({ -or => [
-bool => \q{ array_length(oid_parts, 1) IS NULL },
-bool => \q{ jsonb_typeof(value) != 'array' }, ] })->count) {
my @rows = $device->oids->search({},{
],
})->hri->all;
$oids{$_->{oid}} = {
%{ $_ },
value => (@{ from_json($_->{value}) })[0],
} for @rows;
}
# or we have an snmpwalk file on disk
elsif (-f $
=> $oid,
oid_parts => [], # not needed temporarily
value => to_json([ ((defined $type and $type eq 'BASE64') ? $value
ToJSON});
# this replacement will avoid the issue of relation names which override
# field names, causing TO_JSON to return object instances, breaking to_json
*DBIx::Class::Helper::Row::ToJSON:
:TO_JSON = sub {
my $self = shift;
my $columns_info = $self->columns_info($self->serializable_columns);
my $columns_data = { $self->get_columns };
return {
map +($_ =>
$columns_data->{$_}), keys %$columns_info
};
};
}
# for DBIx::Class::Helper::Row::ToJSON
# to allow text columns to be included in results
sub unserializable_data_types {
return {
pec::Functions qw/splitdir catdir catfile/;
use MIME::Base64 'decode_base64';
use SNMP::Info;
use JSON::PP ();
use base 'Exporter';
our @EXPORT = ();
our @EXPORT_OK = qw/
get_communities
snmp_com
Base64 encoded,
decodes it and then munge to handle data format, before finally pretty
render in JSON format.
=cut
sub get_code_info { return ($_[0]) =~ m/^(.+)::(.*?)$/ }
sub sub_name { retur
ength $encoded;
my $json = JSON::PP->new->utf8->pretty->allow_nonref->allow_unknown->canonical;
$json->sort_by( sub { sortable_oid($JSON::PP::a) cmp sortable_oid($JSON::PP::b) } );
retur
Netdisco::DB::ResultSet::Device;
use App::Netdisco::DB::ResultSet::DevicePort;
my %device_fields_json = ();
my @inline_device_actions = ();
my @inline_device_port_actions = ();
foreach my $config (@
'name'};
push @inline_device_actions, $config->{'name'};
++$device_fields_json{ $config->{'name'} } if $config->{'json_list'};
}
foreach my $config (@{ setting('custom_fields')->{'device_port'} |
map {( ('cf_'. $_) => \[
($device_fields_json{$_} ? q{ARRAY(SELECT json_array_elements_text((me.custom_fields ->> ?) ::json))::text[]}
: 'me.cu
ip => $device->addr,
-bool => \q{ jsonb_typeof(value) = 'array' },
})->hri->all;
send_error(
lar @rows;
my @snmpwalk = ();
foreach my $row (@rows) {
$row->{value} = (@{ from_json($row->{value}) })[0];
if (ref {} eq ref $row->{value}) {
foreach my $k (keys
t'})->resultset('DeviceSkip')->get_distinct_col('backend');
content_type 'application/json';
to_json \@backends;
};
ajax '/ajax/data/queue/typeahead/username' => require_role admin => sub {
enant'})->resultset('Admin')->get_distinct_col('username');
content_type 'application/json';
to_json \@users;
};
ajax '/ajax/data/queue/typeahead/action' => require_role admin => sub {
m
meta( param('query') || param('term') || param('action') );
content_type 'application/json';
to_json [
grep { $q ? m/^$q/ : true }
grep { defined }
List::MoreUtils::uniq
est->remote_address,
log => $log,
});
});
content_type('application/json');
to_json({});
};
ajax '/ajax/userlog' => require_login sub {
my @jobs = jq_userlog( session('
t;/; $_}
map { $_->log }
grep { $_->status eq 'error' }
grep { defined }
@jobs
],
);
content_type('application/json');
to_json(\%status);
};
true;
th
or request->path eq uri_for('/logout')->path
or request->path eq uri_for('/swagger.json')->path
or index(request->path, uri_for('/swagger-ui')->path) == 0
);
# Dancer wil
> {
'application/json' => { api_key => 'cc9d5c02d8898e5728b7d7a0339c0785' } } },
},
},
post '/login' => sub {
my $api = ((request->accept and request->accept =~ m/(?:json|javascript)/) ? tru
n => \'LOCALTIMESTAMP' });
if ($api) {
header('Content-Type' => 'application/json');
# if there's a current valid token then reissue it and reset timer
$
est_is_api
Client has requested JSON format data and an endpoint under C</api>.
=cut
sub request_is_api {
return ((request->accept and request->accept =~ m/(?:json|javascript)/) and (
index(r
_actions';
use App::Netdisco::Backend::Job;
use App::Netdisco::DB::ExplicitLocking ':modes';
use JSON::PP ();
use Try::Tiny;
use base 'Exporter';
our @EXPORT = ();
our @EXPORT_OK = qw/
jq_warm_thr
}
die 'failed to find row for custom field update' unless $row;
my $coder = JSON::PP->new->utf8(0)->allow_nonref(1)->allow_unknown(1);
$spec->{subaction} = $coder->enco
row->make_column_dirty('custom_fields');
$row->update({
custom_fields => \['jsonb_set(custom_fields, ?, ?)'
=> (qq{{$spec->{action}}}, $spec->{subac
@results;
if ( request->is_ajax ) {
my $json = to_json( \@results );
template 'ajax/report/ipinventory.tt', { results => $json }, { layout => 'noop' };
}
else {
he
};
}
if (request->is_ajax) {
my $json = to_json (\@results);
template 'ajax/report/portvlanmismatch.tt', { results => $json }, { layout => 'noop' };
}
else {
use File::ShareDir 'dist_dir';
use File::Slurper qw/read_text write_text/;
use File::Temp ();
use JSON::PP ();
use YAML::XS ();
use Try::Tiny;
=head1 NAME
App::Netdisco::Transport::Python
=head1 DE
klet {
my ($self, $job, $workerconf) = @_;
my $action = $workerconf->{action};
my $coder = JSON::PP->new->utf8(1)
->allow_nonref(1)
->allow
@results;
if ( request->is_ajax ) {
my $json = to_json( \@results );
template 'ajax/report/apclients.tt', { results => $json }, { layout => 'noop' };
}
else {
hea
=~ m/^\.1(\.\d+)*$/ or send_error('Bad OID Base', 404);
content_type 'application/json';
return to_json [{
text => 'No data for this device. Admins can request a snapshot in the Detail
unt;
# snapshot should run a loadmibs, but just in case that didn't happen...
return to_json [{
text => 'No MIB objects. Please run a loadmibs job.',
children => \0,
state
et_snmp_data($device->ip, $base);
to_json $items;
};
ajax '/ajax/data/snmp/typeahead' => require_login sub {
my $term = param('term') or return to_json [];
my $device = param('ip');
@results;
if ( request->is_ajax ) {
my $json = to_json (\@results);
template 'ajax/report/portadmindown.tt', { results => $json }, { layout => 'noop' };
}
else {
h
ar @results;
if (request->is_ajax) {
my $json = to_json( \@results );
template 'ajax/device/addresses.tt', { results => $json },
{ layout => undef };
}
else {
@results;
if ( request->is_ajax ) {
my $json = to_json (\@results);
template 'ajax/report/portblocking.tt', { results => $json }, { layout => 'noop' };
}
else {
he
scalar @results;
if (request->is_ajax) {
my $json = to_json( \@results );
template 'ajax/device/vlans.tt', { results => $json },
{ layout => 'noop' };
}
else {