The Pushover API client implementation
# pragmas
use 5.10.0;
# imports
use Moo;
use Carp;
use JSON;
use LWP::UserAgent;
# version
our $VERSION = 0.021;
# accessors
has token => (is => 'rw');
ha
g data
my $res = $self->_ua->post(
'https://api.pushover.net/1/messages.json', $args
);
return JSON::decode_json($res->decoded_content)
}
sub _auth_validation {
my $self = shift;
# au
nt>'
);
Method C<message> send a notification for an specificated user and returns
decoded C<JSON> from API http response.
Official message API docs at L<https://pushover.net/api#messages>
=h
# AJAX communication
require JSON;
$hta->show(
AJAX => sub {
my($request) = @_;
print JSON::encode_json($request);
my $ok = int(rand(
(JSON::decode_json($rq_raw));
my $reply = "HTTP/1.1 200 OK\n";
$reply .= "Content-Type: text/html; charset=utf-8\n\n";
$reply .= JSON::encode_json
or die "Win32::Process is needed for ajax fuctionality\n";
eval { require JSON }
or die "JSON is needed for ajax fuctionality\n";
Win32::Process::Create(
m
token => $token,
file => {
file => $local_file
}}
)->res->json;
}
sub upload_data {
my ($self, $token, $data, $key ) = @_;
my $ua = Mojo::UserAgent->ne
n,
file => {
filename => $key,
content => $data,
}}
)->res->json;
}
sub upload_stream {
my ($self, $token, $local_file, $key, $mimetype) = @_;
my $ua =
on' => 'UpToken ' . $token,
},
$bput_data)->res->json;
$ctx[$block_nu] = $result->{ctx};
}
}
my $mkfile_api = $self->upapi
# 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
) ? $coerced
: Carp::confess "I should be unreachable!"
} @vals
}
=for Pod::Coverage TO_JSON TO_ZPL damn type
=cut
sub type {
# array() has an empty ->type
}
sub new { bless [ @_[1 .. $
module( $cls->inflated_type );
$cls->inflated_type->new(@$self)
}
{ no warnings 'once';
*TO_JSON = *unbless;
*TO_ZPL = *unbless;
*damn = *unbless;
}
sub unbless { [ @{ $_[0] } ] }
e methods documented below, these objects provide a
C<TO_JSON> method exporting a plain ARRAY-type reference for convenience when
feeding L<JSON::Tiny> or similar, as well as a C<TO_ZPL> method for
co
# 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
# 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
rict;
use warnings;
# ABSTRACT: Simple interface to the Google Analytics Core Reporting API
use JSON;
use LWP::UserAgent;
use Net::Google::Analytics::Request;
use Net::Google::Analytics::Response;
u
http_res->decoded_content);
return $res;
}
my $json = from_json($http_res->decoded_content);
$res->_parse_json($json);
$res->start_index($start_index);
$res->is_success(1
); # 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/([\x00-\x08
00;
use strict;
use warnings;
use parent qw/Exporter/;
use Carp;
use HTTP::Tiny;
use JSON::MaybeXS qw/decode_json/;
use Scalar::Util qw/looks_like_number/;
use WebService::TDWTF::Article;
my @subs =
nse = $ht->get($url);
croak $response->{reason} unless $response->{success};
$response = decode_json $response->{content};
croak $response->{Status} if ref $response eq 'HASH' && !exists $response-
L<WebService::TDWTF>. Each such object is guaranteed to
be a blessed hashref corresponding to the JSON returned by the TDWTF
API (possibly with some extra keys), so the data inside can be
obtained by
}
sub _parse_json {
my ($self, $json) = @_;
$self->items_per_page($json->{itemsPerPage});
$self->total_results($json->{totalResults});
$self->contains_sampled_data($json->{containsSa
a});
$self->profile_info($json->{profileInfo});
my $json_totals = $json->{totalsForAllResults};
my %totals;
while (my ($json_name, $total) = each(%$json_totals)) {
my $column
al;
}
$self->_totals(\%totals);
my @column_headers;
for my $column_header (@{ $json->{columnHeaders} }) {
push(@column_headers, {
name => _parse_column_na
h2::VERSION = '3.05';
use strict;
use warnings;
# ABSTRACT: OAuth2 for Google Analytics API
use JSON;
use LWP::UserAgent;
use URI;
sub new {
my $class = shift;
my $self = { @_ };
die(
;
die('error getting token: ' . $res->status_line) unless $res->is_success;
return from_json($res->decoded_content);
}
sub refresh_access_token {
my ($self, $refresh_token) = @_;
m
;
die('error getting token: ' . $res->status_line) unless $res->is_success;
return from_json($res->decoded_content);
}
sub interactive {
my $self = shift;
my $url = $self->authoriz
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
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
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
'||', # 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 '
::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 {
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 =