se;
use namespace::autoclean;
use Types::Standard qw/Str HashRef/;
use Path::Tiny;
use JSON::MaybeXS 'decode_json';
with 'Badge::Depot';
# ABSTRACT: Travis plugin for Badge::Depot
our $AUTHORITY = 'c
my $self = shift;
return {} if !path('META.json')->exists;
my $json = path('META.json')->slurp_utf8;
my $data = decode_json($json);
return {} if !exists $data->{'resources'}{'r
r configuration. It looks for the C<resources/repository/web> setting in C<META.json>:
=over 4
=item *
If C<META.json> doesn't exist in the dist root, C<user> and C<repo> are required.
=item *
If
=> 'all';
use parent qw( Plack::Middleware );
use Plack::Util;
use HTTP::Exception '4XX';
use JSON::XS;
use YAML::Syck;
use URI::Escape::XS qw/decodeURIComponent/;
use Encode;
our $VERSION = '0.1
1") ? return 1 : return 0;
}
### Set default mime types
my $MIME_TYPES = {
'application/json' => sub { JSON::XS->new->utf8->allow_nonref->encode($_[0]) },
'text/yaml' => sub {
local $
tml($data, $env, $header); #struct, env
return Encode::encode_utf8($ret) if $ret;
}
return JSON::XS->new->utf8->allow_nonref->encode($data); # Just show content
}
};
sub prepare_app {
my $se
nt 6.02;
# This isn't used directly but we want the dependency
use LWP::Protocol::https 6.02;
use JSON::MaybeXS;
our $VERSION = 'v0.55.5'; # TRIAL VERSION
# CF credentials
has '_user' => (
is
, can throw exceptions under ::Exception::
Readonly my $CF_URL => 'https://www.cloudflare.com/api_json.html';
method _apiCall ( $act is ro, %args is ro ) {
# query cloudflare
Readonly my $res
d',)
unless $res->is_success;
# Handle errors from CF
Readonly my $info => decode_json($res->decoded_content);
CloudFlare::Client::Exception::Upstream::->throw(
errorCode =
'||', # optional
);
my $vm = Ovirt::VM->new(%con);
# return xml / json output
print $vm->list_xml;
print $vm->list_json;
# list vm separated by new line
# return attributes specified on '
se strict;
use REST::Client;
use MIME::Base64;
use Cpanel::JSON::XS qw(encode_json);
use IDCHECKIO::ResponseIDCIO;
use JSON::Parse 'parse_json';
=head1 NAME
IDCHECKIO::Client - Client to use the ID
cation/json");
$self->{_client}->addHeader("Authorization", "");
my $auth = encode_base64("$self->{_user}:$self->{_pwd}");
$self->{_client}->addHeader("Content-Type", "application/json");
$
$line2,
'line3' => $line3,
};
my $json_data = encode_json $data;
my $result;
$self->{_client}->POST($url, $json_data);
my $json = parse_json($self->{_client}->responseContent());
if
# Net::IPA.pm -- Perl 5 interface of the (Free)IPA JSON-RPC API
#
# for more information about this api see: https://vda.li/en/posts/2015/05/28/talking-to-freeipa-api-with-sessions/
#
# written by
2, see LICENSE file for more information.
package Net::IPA::Methods;
use strict;
use JSON;
our $USE_RAW = JSON::true;
#** Ping request
#*
sub ping
{
return {
method => 'ping',
params => [
my ($user, %args) = @_;
unless(%args){
%args = (
all => 0,
no_members => JSON::false,
pkey_only => JSON::false,
);
}
$args{raw} = $USE_RAW unless(exists $args{raw});
return {
me
# Net::IPA.pm -- Perl 5 interface of the (Free)IPA JSON-RPC API
#
# for more information about this api see: https://vda.li/en/posts/2015/05/28/talking-to-freeipa-api-with-sessions/
#
# written by
ask = {
'gcid' => "",
'cid' => '',
'filesize' => 0,
'ext_json' => { 'autoname' => 1 },
};
my $res = $self->url_resolve($url)->{'taskInfo'};
$task
ame && $task->{'name'} ne $filename ) {
$task->{'name'} = $filename;
$task->{'ext_json'}->{'autoname'} = 0;
}
return $task;
}
sub create_task {
my $self = shift;
my (
::Xunlei;
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
use URI::Escape;
use JSON;
use File::Basename;
use File::Path qw/mkpath/;
use Time::HiRes qw/gettimeofday/;
use POSIX qw/s
shift;
my ( $user, $pass, %options ) = @_;
my $self = {
'ua' => undef,
'json' => undef,
'user' => $user,
'pass' => md5pass($pass),
};
my $cookie_file
_jar( { file => $cookie_file } );
$self->{'ua'}->agent(DEFAULT_USER_AGENT);
$self->{'json'} = JSON->new->allow_nonref;
bless $self, $class;
return $self;
}
sub get_downloaders {
# Net::IPA.pm -- Perl 5 interface of the (Free)IPA JSON-RPC API
#
# for more information about this api see: https://vda.li/en/posts/2015/05/28/talking-to-freeipa-api-with-sessions/
#
# written by
e Net::IPA;
our $VERSION = '1.0';
=head1 NAME
Net::IPA.pm -- Perl 5 interface of the (Free)IPA JSON-RPC API
=head1 SYNOPSIS
use Net::IPA;
my $ipa = new Net::IPA(
hostname => 'ipa.server.
se strict;
use Net::IPA::Methods;
use Net::IPA::Response;
use vars qw($AUTOLOAD);
use Carp;
use JSON;
use LWP::UserAgent; # http://search.cpan.org/~ether/libwww-perl-6.15/lib/LWP/UserAgent.pm
use LW
kage Ovirt;
use v5.10;
use LWP::UserAgent;
use Scalar::Util qw(looks_like_number);
use Carp;
use JSON;
use XML::LibXML;
use URI::Escape;
use Moo::Role;
=head1 NAME
Ovirt - Bindings for oVirt REST A
=> 'ovirt-mgr.example.com',
api_output => 'xml', # optional, default to json
vm_output_attrs => 'id,name,state,description', # optional
cluste
;
my $host = Ovirt::Host ->new(%con);
# return xml output / json
print $vm->list_xml;
print $vm->list_json;
# list attributes based on 'vm_output_attrs
om log4perl
http_post = (rwp) if true, use http post method instead of get
post_json = (rwp) set json content to be post
ssl = (ro) if 'on', use https (default is 'off')
ssl_v
define if it's xa datasource, yes/no (default is 'no')
=cut
has [qw/url log json_data resource_url http_post post_json /] => ( is => 'rwp' );
has [qw/username password/]
croak "post_json not set"
unless $self->post_json;
my $req = HTTP::Request->new(POST => $self->url);
$req->content_type ('application/json');
$req->
use strict;
use warnings;
use Role::Tiny;
use Test::More;
use Test::Deep qw( cmp_deeply );
sub json_deeply {
my ( $t, $ptr, $expect, $desc ) = @_;
# Pointer is an optional argument
if
a simple scalar (did you mean to use json_is()?)"
if !ref $expect;
$desc ||= qq{deeply match JSON Pointer "$ptr"};
my $given = $t->tx->res->json( $ptr );
local $Test::Builder::
t::Builder::Level + 1;
my $result = cmp_deeply( $given, $expect, $desc )
or diag "Got JSON: ", explain $given;
return $t->success( $result );
}
sub text_deeply {
my ( $t, $sel, $
icroTemplate::_PerRequest';
}
1;
=head1 NAME
Catalyst::View::Text::MicroTemplate::PerRequest - JSON View that owns its data
=head1 SYNOPSIS
MyApp->inject_components(
'View::HTML' => {
;
}
sub endpoint :Chained(midpoint) Args(0) {
my ($self, $c) = @_;
$c->view('JSON')->created({
a => 1,
b => 2,
c => 3,
});
}
# template $HOM
tyle view that produces JSON is L<Catalyst::View::JSON::PerRequest>.
In fact this was written so that I could have a view that did HTML with an identical
interface as that JSON view, to make it easier
DATE
our $VERSION = '0.03'; # VERSION
use 5.010001;
use strict;
use warnings;
use JSON::MaybeXS;
my $json = JSON::MaybeXS->new->allow_nonref;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK
2";
}
} else {
return $json->encode("$str");
}
}
sub decode_js_string {
my $str = shift;
if ($str =~ /\A"/o) {
$json->decode($str);
} elsif ($str =~ /\A'/o
JavaScript literal representation using double
quotes (C<">). This is currently implemented using JSON encoding.
If C<$mode> is set to 1, will produce literal representation using single quotes
(C<'>
ib for Google OAuth 2.0
$Google::OAuth2::Client::Simple::VERSION = '0.004';
use Carp;
use Cpanel::JSON::XS;
use Furl;
use Moo;
use URI;
=head1 NAME
Google::OAuth2::Client::Simple - Client for Google
ype', 'application/x-www-form-urlencoded'],
content => \%params
);
return decode_json($response->decoded_content());
}
=head2 refresh_token($refresh_token)
For use when you require
ype', 'application/x-www-form-urlencoded'],
content => \%params
);
return decode_json($response->decoded_content());
}
=head2 revoke_token($access_token)
Revokes the access token on
->http_post) {
$self->_set_post_json('{"operation":"read-attribute","name":"server-state","json.pretty":1}');
$self->log->debug($self->post_json);
}
else {
$self->_set_
resource_url('/?operation=attribute&name=server-state&json.pretty');
$self->log->debug($self->resource_url);
}
$self->get_api_response();
}
=head2 get_jvm_usage
return jvm usag
et_resource_url('/core-service/platform-mbean/type/memory?operation=resource&include-runtime=true&json.pretty');
$self->log->debug($self->resource_url);
$self->get_api_response();
}
=hea
es> documentation to know more about swat meta stories.
=head1 Advanced usage
=head2 handling json responses
Modify Kelp controller
=head3 GET /user/id
$ cat user/id/get.pm
my ($s
$id}->{age}
}
Add json handler to swat test:
$ cat user/id/get.handler
my $headers = shift;
my $body = shift;
use JSON;
$hash = decode_json($body);
return "$h
); # SvTYPE is IV or NV?
my $type = ref($value);
if (!$type) {
return string_to_json($value);
} elsif ($type eq 'ARRAY') {
return sprintf('[%s]', join(", ", map { _serial
\f',
"\b" => '\b',
"\"" => '\"',
"\\" => '\\\\',
"\'" => '\\\'',
);
sub string_to_json {
my ($arg) = @_;
$arg =~ s/([\x22\x5c\n\r\t\f\b])/$esc{$1}/g;
$arg =~ s/\//\\\//g i
package Test::Mojo::More;
use Mojo::Base 'Test::Mojo';
use Test::More;
use Mojo::JSON::Pointer;
use Mojo::Message::Request;
use Mojolicious;
use Mojolicious::Controller;
use Mojo::Transaction::HTTP;
} );
$t = $t->flash_is( '/error/message', 'error message' );
Check flash the given JSON Pointer with Mojo::JSON::Pointer.
=cut
sub flash_is {
my ($self, $key, $value, $desc) = @_;
my ( $flash,
deeply',
_pointer( $flash, $path ? "/$path" : "" ),
$value,
$desc || "flash exact match for JSON Pointer \"$key\"",
);
}
=head2 C<flash_has>
$t = $t->flash_has( '/error' );
$t = $t->flas