_rs({}, {
'+columns' => [
{ router_ip => \q{(SELECT key FROM json_each_text(seen_on_router_last::json) ORDER BY value::timestamp DESC LIMIT 1)} },
{ router_name => \q{COAL
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
;
bless $self, $class;
return $self;
}
sub TO_JSON {
my ($self) = @_;
# Return a copy of the object as a hash reference for JSON encoding
return {%$self};
}
sub ip {
return
lain string. It defaults to an empty string if not provided.
=head2 TO_JSON
This method is used to convert the object to a JSON representation.
=head2 ip
my $ip_address = $geo_details->ip();
lls
sub _dedup_cases
{
my $cases = shift;
require JSON::MaybeXS;
JSON::MaybeXS->import();
my %seen;
my @rc = grep {
my $dump = encode_json($_);
!$seen{$dump}++
} @{$cases};
return \@rc;
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
s;
# vim:readonly
# This module has been automatically generated from share/admin-id-to-operator.json
# by lib/Travel/Status/DE/DBRIS/Operators.pm.PL.
# Do not edit, changes will be lost.
use strict
ings;
use 5.020;
use utf8;
our $VERSION = '0.18';
# Automatically generated, see share/stations.json
my %admin_id_to_operator = (
'OWRE' => ['RE', 'Ostdeutsche Eisenbahn GmbH'],
'8006D2' => ['DB', '
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
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
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
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;
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
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
$
_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
use 5.006;
use strict;
use warnings;
use Cache::LRU;
use LWP::UserAgent;
use HTTP::Headers;
use JSON;
use Geo::DetailsLite;
use Net::CIDR;
use Net::CIDR::Set;
our $VERSION = '3.2.0';
use constant D
elf->{ua}->default_headers(
HTTP::Headers->new(
Accept => 'application/json',
Authorization => 'Bearer ' . $token
)
);
$self->{ua}->agent("IPinfo
_type =~ m{application/json}i ) {
eval { $info = from_json( $response->decoded_content ); };
if ($@) {
return ( undef, 'Error parsing JSON response.' );
e JSON::PP;
local *UNIVERSAL::TO_JSON = sub { +{ %{$_[0]} } };
my $json = JSON::PP->new->ascii->pretty->canonical->allow_unknown->allow_blessed->convert_blessed;
$data = $json-
can output the deduplicated feed in either Atom or JSON format.
It is designed to be run from the command line, and it can be configured using
a JSON configuration file. The configuration file should
s
and functionality to be added in the future.
=head1 CONFIGURATION
The configuration file is a JSON file that specifies the feeds to be
aggregated, the output format, and the maximum number of entr
he output.
By default, the configuration file should be located at
C<~/.feed-deduplicator/config.json>, but this can be overridden by setting
the C<FEED_DEDUP_CONFIG> environment variable.
The confi
orker::Status';
use App::Netdisco::JobQueue 'jq_insert';
use Dancer::Plugin::DBIC 'schema';
use JSON::PP ();
register_worker({ phase => 'check' }, sub {
my ($job, $workerconf) = @_;
return Sta
');
});
register_worker({ phase => 'main' }, sub {
my ($job, $workerconf) = @_;
my $coder = JSON::PP->new->utf8(0)->allow_nonref(1)->allow_unknown(1);
my $sched = $coder->decode( $job->extra |
Netdisco::Backend::Role::Scheduler;
use Dancer qw/:moose :syntax :script/;
use NetAddr::IP;
use JSON::PP ();
use Algorithm::Cron;
use App::Netdisco::Util::MCE;
use App::Netdisco::JobQueue qw/jq_ins
ive', $wid;
return debug "sch ($wid): no need for scheduler... quitting"
}
my $coder = JSON::PP->new->utf8(0)->allow_nonref(1)->allow_unknown(1);
while (1) {
# sleep until some poi
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
use 5.006;
use strict;
use warnings;
use Cache::LRU;
use LWP::UserAgent;
use HTTP::Headers;
use JSON;
use Geo::Details;
use Net::CIDR;
use Net::CIDR::Set;
our $VERSION = '3.2.0';
use constant DEFAU
elf->{ua}->default_headers(
HTTP::Headers->new(
Accept => 'application/json',
Authorization => 'Bearer ' . $token
)
);
$self->{ua}->agent("IPinfo
_type =~ m{application/json}i ) {
eval { $info = from_json( $response->decoded_content ); };
if ($@) {
return ( undef, 'Error parsing JSON response.' );