ata = P->data->to_json($data) if $data;
my $res = P->http->get(
"https://api.telegram.org/bot$self->{key}/$path",
headers => [ 'Content-Type' => 'application/json', ],
dat
a => $data
);
$data = P->data->from_json( $res->{data} );
return res 200, $data;
}
# TODO
sub set_webhook ( $self, $url, %args ) {
return;
}
sub poll_updates ( $self, $timeout =
::OpenSSL::RSA qw[];
use Pcore::Util::Scalar qw[is_ref];
use Pcore::Util::Data qw[to_b64u to_json from_json to_uri];
has key => ( required => 1 );
has scope => ( required => 1 );
has _token
t_arg => undef );
has _openssl_rsa => ( init_arg => undef );
const our $JWT_HEADER => to_b64u to_json {
alg => 'RS256',
typ => 'JWT',
};
sub BUILD ( $self, $args ) {
$self->{key} = P->cf
my $key = $self->{key};
my $issue_time = time;
my $jwt_claim_set = to_b64u to_json {
aud => 'https://www.googleapis.com/oauth2/v4/token',
iss => $key->{
package Pcore::API::Chrome::Tab;
use Pcore -class, -res;
use Pcore::Util::Data qw[to_json from_json from_b64];
use Pcore::Util::Scalar qw[weaken];
use Pcore::WebSocket::raw;
use overload #
'&{}
^GLOBAL_PHASE} ne 'DESTRUCT' ) {
my $url = "http://$self->{chrome}->{listen}->{host_port}/json/close/$self->{id}";
Coro::async_pool sub ($url) { P->http->get($url) }, $url;
}
lf->{chrome}->{listen}->{host_port}/json/close/$self->{id}");
}
sub activate ( $self ) {
return P->http->get("http://$self->{chrome}->{listen}->{host_port}/json/activate/$self->{id}");
}
sub lis
ne/api/v1.40/#operation/ImageList
sub get_images ($self) {
return $self->_req( 'GET', 'images/json' );
}
# https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild
sub image_build ( $self,
id );
for my $stream ( split /\r\n/sm, $res->{data}->$* ) {
my $data = P->data->from_json($stream);
$log .= $data->{stream} if exists $data->{stream};
if ( exists $data-
headers => [
'X-Registry-Auth' => P->data->to_b64(
P->data->to_json( {
username => $username,
password => $token,
sername}:$self->{token}", $EMPTY )
],
);
my $data = $res->{data} ? P->data->from_json( $res->{data} ) : undef;
if ($res) {
$self->{_token} = $data->{token};
retu
ation => "Bearer $self->{_token}",
],
);
my $data = $res->{data} ? P->data->from_json( $res->{data} ) : undef;
if ($res) {
return res 200, $data;
}
else {
ept => 'application/vnd.docker.distribution.manifest.v2+json',
],
);
my $data = $res->{data} ? P->data->from_json( $res->{data} ) : undef;
if ($res) {
$data->{dige
t-Type' => 'application/json',
$self->{_login_token} ? ( Authorization => 'JWT ' . $self->{_login_token} ) : (),
],
data => $data ? P->data->to_json($data) : undef
);
return res [ $res->{status}, $res->{reason} ], $res->{data} && $res->{data}->$* ? P->data->from_json( $res->{data} ) : ();
}
# USER / NAMESPACE
sub get_user ( $self, $username ) {
return $self-
#!/usr/bin/env perl
package main v0.1.0;
use Pcore;
use Pcore::Util::Data qw[from_json to_json];
use Pcore::Util::Text qw[decode_utf8 encode_utf8];
my $cv = P->cv;
AnyEvent::Socket::tcp_server( '1
\n");
last if !$msg;
# decode message, ignore invalid json
eval { $msg = from_json $msg->$*; 1; } or last;
my $cmd = 'CMD_' . ( delete( $msg->[1]->{c
data => encode_utf8( $args->{data} ),
ignore => 0,
}
);
my $json = to_json [
$id,
{ status => $res->{status},
reason => $res->{