::Dumper;
use Date::Format;
use English qw( -no_match_vars);
use HTTP::Request;
use JSON qw( encode_json decode_json );
use LWP::UserAgent;
use List::Util qw(any all pairs none);
use Readonly;
use Sca
t -u > xml.services
grep -ri '"protocol":"' botocore/botocore/data/* | grep 'json' | \
cut -f 8 -d '/' | sort -u > json.services
grep -ri '"protocol":"' botocore/botocore/data/* | grep 'query' | \
an API class. Content-Type can however be
overridden when invoking APIs if we guess wrong.
rest-json => application/x-amz-1.1
rest-xml => application/xml
query => application/x-www-form-urlen
Data::Dumper;
use English qw( -no_match_vars );
use Getopt::Long qw(:config no_ignore_case);
use JSON;
use List::Util qw(pairs);
use Term::ANSIColor;
use Text::ASCIITable;
use Readonly;
Readonly ou
is_hash is_array);
use Carp;
use Data::Dumper;
use English qw(-no_match_vars);
use JSON qw(decode_json encode_json);
use Scalar::Util qw(reftype blessed);
use List::Util qw(any none);
use POSIX qw(s
rue false) ) {
return {
0 => JSON::false,
1 => JSON::true,
true => JSON::true,
false => JSON::false,
}->{$data};
}
return
of 'rolling your own' API
use strict;
use warnings;
use parent qw(APIExample Amazon::API);
use JSON::PP;
use Data::Dumper;
use English qw(-no_match_vars);
our $DESCRIPTIONS = {
PutParameter =>
=> 'AmazonSSM',
api_methods => \@API_METHODS,
content_type => 'application/x-amz-json-1.1',
debug => $ENV{DEBUG},
%options
}
);
return $self;
}
##########
ame,
Value => $value,
Type => 'SecureString',
Overwrite => JSON::PP::true
}
)
);
}
else {
print {*STDOUT} "usage: $PROGRAM_NAME run Put
ime),
to_template_var('class') => $shape_class,
to_template_var('shape') => JSON->new->pretty->encode($shape),
to_template_var('service') => $service,
to_template_va
::Botocore::Shape);
use strict;
use warnings;
use JSON qw(decode_json);
our $SHAPE = <<'SHAPE';
@shape@
SHAPE
our $SHAPE_DEFINITION = decode_json($SHAPE);
########################################
PIExample Amazon::API::STS );
use Carp;
use Data::Dumper;
use English qw( -no_match_vars );
use JSON::PP;
our $VERSION = '0.01';
our $DESCRIPTIONS = { AssumeRole => 'Executes the AssumeRole API' }
ptions);
my $credentials = $sts->get_credentials_from_role( shift @ARGV );
if ($credentials) {
print {*STDOUT} JSON::PP->new->pretty->encode($credentials);
}
return $credentials;
}
1;
);
use File::Find;
use File::Path qw(make_path);
use Getopt::Long qw(:config no_ignore_case);
use JSON;
use List::MoreUtils qw( first_index );
use List::Util qw( max );
use Pod::Usage;
use Pod::Text;
################################
sub fetch_json_file {
########################################################################
my ($path) = @_;
my $json;
open my $fh, '<', $path
or croak
' . $path;
{
local $RS = undef;
$json = JSON->new->utf8->decode(<$fh>);
}
close $fh
or croak 'could not close ' . $path;
return $json;
}
#######################################
rnings;
use Carp;
use Data::Dumper;
use English qw( -no_match_vars );
use APIExample qw(dump_json);
use parent qw( APIExample Amazon::API::Route53 );
our $VERSION = '0.01';
our $DESCRIPTIONS
ckage->service($options);
my $hosted_zones = $rt53->ListHostedZones();
print {*STDOUT} dump_json($hosted_zones);
return $hosted_zones;
}
#####################################################
$package->service($options);
my $record_sets
= $rt53->ListResourceRecordSets( { HostedZoneId => $args[0] } );
print {*STDOUT} dump_json($record_sets);
return $record_sets;
}
1;
__END__
API class without using the
# Botocore metadata
use strict;
use warnings;
use Data::Dumper;
use JSON::PP;
our @API_METHODS = qw ( DescribeRule ListRules ListTargetsByRule );
use parent qw(Amazon::
kage, $options, @args ) = @_;
my $cwe = $package->service($options);
return print {*STDOUT} JSON::PP->new->pretty->encode( $cwe->ListRules() );
}
###############################################
e strict;
use warnings;
use Data::Dumper;
use Amazon::API qw( param_n );
use APIExample qw( dump_json );
use parent qw( APIExample Amazon::API::EC2 );
BEGIN {
our $VERSION = $Amazon::API::EC2::VE
service($options);
my $ec2_instances = $ec2->DescribeInstances;
return print {*STDOUT} dump_json($ec2_instances);
}
########################################################################
sub
$package->service($options);
my $vpc_list = $ec2->DescribeVpcs;
return print {*STDOUT} dump_json($vpc_list);
}
########################################################################
sub _Desc
;
use strict;
use warnings;
use APIExample qw(:booleans dump_json);
use parent qw(APIExample Amazon::API);
use Data::Dumper;
use JSON::PP;
use Data::UUID;
use List::Util qw(any none);
local $Data
s, @args ) = @_;
my $secrets_mgr = $package->service($options);
return print {*STDOUT} dump_json( $secrets_mgr->ListSecrets() );
}
##############################################################
ames;
return print {*STDOUT} dump_json(
$secrets_mgr->DeleteSecret(
{ SecretId => $secret,
ForceDeleteWithoutRecovery => JSON::PP::true
}
)
);
}
##
use strict;
use warnings;
use Carp;
use Data::Dumper;
use JSON qw(encode_json);
use Scalar::Util qw( reftype );
use APIExample qw(dump_json);
use parent qw(APIExample Amazon::API::SQS);
our $DESCR
my $sqs = $package->service($options);
my $rsp = $sqs->ListQueues();
print {*STDOUT} dump_json($rsp);
return $rsp;
}
#######################################################################
Url => $queue_url,
ReceiptHandle => $receipt_handle
}
);
print {*STDOUT} dump_json($rsp);
return $rsp;
}
#######################################################################
package Amazon::ECR;
use strict;
use warnings;
use Data::Dumper;
use JSON;
our $DESCRIPTIONS = { GetAuthorizationToken =>
q{Retrieves an authorization token: run GetAuthorizationToken}, };
use
egistry_V20150921',
api_methods => \@API_METHODS,
content_type => 'application/x-amz-json-1.1',
debug => $ENV{DEBUG} // 0,
%options
}
);
return $self;
}
#####
##############
my ( $package, $options ) = @_;
my $ecr = $package->service($options);
my $rsp = $ecr->GetAuthorizationToken();
return print {*STDOUT} JSON->new->pretty->encode($rsp);
}
1;
ata::Dumper;
use JSON;
use Readonly;
our $VERSION = '0.03';
Readonly::Scalar our $TRUE => 1;
Readonly::Scalar our $FALSE => 0;
use parent qw(Exporter);
our @EXPORT = qw(dump_json normalize_option
########################
sub slurp_json {
########################################################################
my ($file) = @_;
my $json = eval { return JSON::PP->new->decode( slurp($file) )
};
croak "ERROR: could not decode JSON string:\n$EVAL_ERROR\n"
if !$json || $EVAL_ERROR;
return $json;
}
########################################################################
sub slurp {
rror;
use strict;
use warnings;
use Data::Dumper;
use English qw( -no_match_vars );
use JSON qw( decode_json );
use Scalar::Util qw( reftype );
use XML::Simple qw( XMLin );
__PACKAGE__->follow_best
=~ /json/xmsi ) {
$message = eval { return decode_json($raw_message); };
}
# try a little harder...
if ( !$message || $EVAL_ERROR ) {
$message = eval { return decode_json($ra
_END__
=pod
=head1 NAME
C<Amazon::API::Error>
=head1 SYNOPSIS
my $result = eval {
decode_json(
$cwe->PutPermission(
{ Action => "PutEvents",
Principal => "12345465