API-PureStorage
view release on metacpan or search on metacpan
lib/API/PureStorage.pm view on Meta::CPAN
my $url = shift @_;
my $ret = $self->{client}->GET($url);
my $num = $ret->responseCode();
my $con = $ret->responseContent();
if ( $num == 500 ) {
die "API returned error 500 for '$url' - $con\n";
}
if ( $num != 200 ) {
die "API returned code $num for URL '$url'\n";
}
print 'DEBUG: GET ', $url, ' -> ', $num, ":\n", Dumper(from_json($con)), "\n" if $debug;
return from_json($con);
}
sub _api_post {
my $self = shift @_;
my $url = shift @_;
my $data = shift @_;
my $ret = $self->{client}->POST($url, to_json($data));
my $num = $ret->responseCode();
my $con = $ret->responseContent();
if ( $num == 500 ) {
die "API returned error 500 for '$url' - $con\n";
}
if ( $num != 200 ) {
die "API returned code $num for URL '$url'\n";
}
print 'DEBUG: POST ', $url, ' -> ', $num, ":\n", Dumper(from_json($con)), "\n" if $debug;
return from_json($con);
}
1;
__END__
=head1 NAME
API::PureStorage - Interacting with Pure Storage devices
=head1 SYNOPSIS
my $pure = new API::PureStorage ($host, $api_token);
my $info = $pure->array_info();
my $percent = sprintf('%0.2f', (100 * $info->{total} / $info->{capacity}));
print "The array $host is currently $percent full\n";
print "\nVolumes on host $host:\n";
my $vol_info = $pure->volume_info();
for my $vol (sort { lc($a->{name}) cmp lc($b->{name}) } @$vol_info) {
my $detail = $pure->volume_detail($vol->{name});
print join("\t", $detail->{name}, $detail->{serial}, $detail->{created}), "\n";
}
=head1 DESCRIPTION
This module is a wrapper around the Pure Storage API for their devices.
It currently supports API v1.4 and earlier. It supports a limited set of
the available API commands: basic reading of volume and array information.
=head1 METHODS
( run in 0.595 second using v1.01-cache-2.11-cpan-de7293f3b23 )