IPBlock',
form_class => 'App::Manoc::Form::IPBlock',
view_object_perm => undef,
json_columns => [qw( id name from_addr to_addr )],
);
before 'view' => sub {
my ( $self, $c
{},
),
name => $_->name
}, @ifaces;
$c->stash( json_data => \@data );
$c->forward('View::JSON');
}
__PACKAGE__->meta->make_immutable;
1;
# Local Variables:
# mode: cp
S
=over 4
=item *
App::Manoc::ControllerRole::CommonCRUD
=item *
App::Manoc::ControllerRole::JSONView
=back
=head1 ACTIONS
=head2 cabling
=head2 list_uncabled_js
=head1 AUTHORS
=over 4
=it
return ( $filter, $attr );
}
sub datatable_row {
my ( $self, $c, $row ) = @_;
my $json_data = {
hostname => $row->hostname,
os => $row->os,
href => $c
$json_data->{hardware} = {
label => $hw->label,
href => $c->manoc_uri_for_object("hw"),
location => $hw->display_location
};
}
return $json_
ommonCRUD
=item *
App::Manoc::ControllerRole::JQDatatable
=item *
App::Manoc::ControllerRole::JSONView
=item *
App::Manoc::ControllerRole::CSVView
=back
=head1 ACTIONS
=head2 create
Override
e base 'Exporter';
use Sparrow::Constants;
use Sparrow::Misc;
use Carp;
use File::Basename;
use JSON;
use version;
use Getopt::Long qw(GetOptionsFromArray);
use Archive::Extract;
use File::Path q
t"){
open F, "$plg_src/sparrow.json" or confess "can't open file $plg_src/sparrow.json to read: $!";
my $sp = join "", <F>;
my $spj = decode_json($sp);
close F;
if ( $spj
{
wanted => sub {
my $file = $_;
return unless $file eq 'sparrow.json';
my @args = (".","--local");
push @args, "--force" if $force;
d") and
return ( $first->padded cmp padded_ipaddr("$second") );
return -1;
}
sub TO_JSON {
shift->_stringify();
}
__PACKAGE__->meta->make_immutable;
1;
# Local Variables:
# mode: c
address
Return the address in unpadded form. Automatically called by stringification.
=head2 TO_JSON
Convert to string
=head1 SYNOSPIS
my $addr = App::Manoc::IPAddress::IPv4->new('10.1.100.1');
Sparrow::Misc;
use Sparrow::Commands::Plugin;
use Carp;
use File::Basename;
use File::Path;
use JSON;
use YAML;
use Config::General ;
use Data::Dumper;
use File::Copy;
use Term::ANSIColor;
use Ge
public|private)@//;
}
if (! $ptype and -f sparrow_root."/plugins/public/$pid/sparrow.json" and -d sparrow_root."/plugins/private/$pid" ){
warn "both public and private $pid plugin
ercome this ambiguity";
return;
}elsif( -f sparrow_root."/plugins/public/$pid/sparrow.json" and $ptype ne 'private' ){
my @task_args = ($project,$tid,'plugin',"public\@$pid");
class => 'ManocDB::Vlan',
form_class => 'App::Manoc::Form::Vlan',
json_columns => [ 'id', 'name', 'description' ],
view_object_perm => undef,
object_l
package Sparrow::Commands::TaskBox;
use strict;
use base 'Exporter';
use Carp;
use JSON;
use YAML;
use Sparrow::Commands::Project;
use Sparrow::Commands::Task;
use Sparrow::Commands::Plugin;
use Sp
/\.(yaml|yml)$/){
$tasklist = Load($spec_str);
} elsif ($path=~/\.(json|js)$/) {
$tasklist = decode_json($spec_str);
} else {
die "unsupported task box spec format: $path";
w_root()."/cache/task_$i.json";
open JSON, ">", $path or confess "can't open file $path to read: $!";
print JSON encode_json($task->{data}||{});
close JSON;
(my $safe_task_
.
Assemble representations of data
=item 5.
Serialize those representations in formats such as JSON, XML, etc.
=item 6.
Set HTTP response headers
=item 7.
Generate appropriate error messages
=
installation includes two built-in serialization modules:
C<JSON>, which serializes responses using the
L<JSON|https://en.wikipedia.org/JSON> format, and C<Text>, which can generate
either tab-separat
prefixes, i.e. "/data1.0/my/operation.json" vs. "/data2.0/my/operation.json"
=item *
A version parameter, i.e. "/my/operation.json?v=1.0"
vs. "/my/operation.json?v=2.0"
=back
The section on L<VER
Edit warehouse',
create_page_title => 'New warehouse',
view_object_perm => undef,
json_columns => [ 'id', 'name' ],
object_list_options => {
prefetch => 'building',
package App::Manoc::ControllerRole::JSONEdit;
#ABSTRACT: Role for adding JSON support for object edit and creation
use Moose::Role;
our $VERSION = '2.99.4'; ##TRIAL VERSION
use namespace::autoclean;
e_form_json_response');
}
sub edit_js : Chained('object') : PathPart('edit/js') : Args(0) {
my ( $self, $c ) = @_;
$c->forward('object_form_edit');
$c->forward('prepare_form_json_respon
my $json_data = {};
$json_data->{form_ok} = $success;
if ( !$success ) {
$json_data->{errors} = $c->stash->{form_delete_error} || "";
}
$c->stash( current_view => 'JSON' );
l_rows,
recordsFiltered => $filtered_rows,
};
$c->stash( 'json_data' => $data );
$c->forward('View::JSON');
}
1;
# Local Variables:
# mode: cperl
# indent-tabs-mode: nil
# cperl-
use IO::File;
use LWP::UserAgent;
use Data::Dumper;
use Sys::Hostname;
use IO::Socket::INET;
use JSON qw();
use Data::Transform::ExplicitMetadata;
use Sub::Name qw(subname);
use Devel::hdb::Router;
ass;
$self->_make_json_encoder();
$self->_make_listen_socket();
$parent_pid = eval { getppid() } if ($Devel::hdb::TESTHARNESS);
return $self;
}
sub _make_json_encoder {
my $self
{json} = JSON->new->utf8->allow_nonref();
return $self;
}
sub encode_json {
my $self = shift;
my $json = $self->{json};
return map { $json->encode($_) } @_;
}
sub decode_json {
m
$self->log("github_http is deprecated. "
. "Consider using META.json instead,\n"
. "which can store URLs for both git clone "
en use the C<web> key.
Instead of setting C<github_http>, you should use the MetaJSON plugin
to include a v2 META.json file with both URLs.
=item * repository
You can set this attribute if you want
package App::Manoc::ControllerRole::JSONView;
#ABSTRACT: Role for adding JSON support for view and view list
use Moose::Role;
our $VERSION = '2.99.4'; ##TRIAL VERSION
use namespace::autoclean;
use
equires 'serialize_objects';
sub prepare_json_object {
my ( $self, $c, $row ) = @_;
return $self->serialize_object( $c, $row );
}
sub prepare_json_objects {
my ( $self, $c, $rows ) = @
json_data => $self->prepare_json_object( $c, $c->stash->{object} ),
current_view => 'JSON'
);
}
sub object_list_js : Private {
my ( $self, $c ) = @_;
$c->stash(
json
config',
);
return [ 200,
[ 'Content-Type' => 'application/json' ],
[ $app->encode_json(\%data) ]
];
}
sub program_name {
my($class, $app, $env) = @_;
$PROGRAM_NAME;
return [200, ['Content-Type' => 'text/plain'],
[ $app->encode_json({ program_name => $PROGRAM_NAME }) ],
];
}
1;
=pod
=head1 NAME
Devel::hdb::App::Prog
me of the running program, $0
=head2 Routes
=over 4
=item GET /program_name
Returns 200 and a JSON-encoded hash with one key:
program_name => $0 when the program was started
=back
=head1 SEE A
orm};
my $process_status = $form->is_valid;
my $json_data = {};
$json_data->{form_ok} = $process_status ? 1 : 0;
$json_data->{status} = $process_status ? 'success' : 'error'
$form->item_id;
$json_data->{message} = $self->object_updated_message;
$json_data->{redirect} = $self->get_form_success_url($c)->as_string;
$json_data->{object_id} = $form
->item_id;
$form->item->can('label') and
$json_data->{object_label} = $form->item->label;
}
elsif ( $c->stash->{object_form_ajax_add_html} ) {
my $template_name =
ge($package) };
return [ 200,
[ 'Content-Type' => 'application/json' ],
[ $app->encode_json({ name => $package, packages => \@sub_packages, subroutines => \@subs }) ]
keys;
return [ 200,
[ 'Content-Type' => 'application/json' ],
[ $app->encode_json(\%data) ],
];
} else {
return [ 404,
Get information about the named package, or 'main::' if no package is given.
Returns 200 and a JSON in the body:
{
name: String - package name
packages: [ // list of packages under this p
ION
If you need the content of a formular as hashref or for processing with other modules
like C<JSON> you can use this model.
=head1 METHODS
=head2 create
This method creates a hashref from a fil
orm_constraint_integer => 'This field must be an integer',
form_constraint_json => 'This field must be a valid JSON string',
form_constraint_length => 'Must be between [_1] and [_2] charac