Net::Akamai - Utility to interface with Akamai's API


Net-Akamai documentation Contained in the Net-Akamai distribution.

Index


Code Index:

NAME

Top

Net::Akamai - Utility to interface with Akamai's API

SYNOPSIS

Top

 my $data = new Net::Akamai::RequestData(
	email=>'my@email.com', 
	user => 'myuser', 
	pwd => 'mypass'
 );
 $data->add_url('http://www.myurl.com');
 $data->add_url('http://www.myurl.com/somethingelse');
 my $ap = new Net::Akamai(req_data=>$data);
 my $res = $ap->purge;

 if (!$res->accepted) {
	die "$res";
 }
 elsif ($res->warning) {
	warn "$res";
 }

DESCRIPTION

Top

Handles akamai purge request of multiple URLs

Patches welcome for extra functionality

Attributes

Top

soap_version

SOAP::Lite version

proxy

akamai purge proxy

uri

akamai purge uri

soap

SOAP::Lite object

req_data

Net::Akamai::RequestData object to hold data associated with an akamai request

res_data

Net::Akamai::ResponseData object holds data associated with an akamai response

Methods

Top

purge

initiate the purge request

TODO

Top

more tests and doc
support to read urls from file
better error checking and failure reporting

AUTHOR

Top

John Goulah <jgoulah@cpan.org>

CONTRIBUTORS

Top

Aran Deltac <bluefeet@cpan.org>

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


Net-Akamai documentation Contained in the Net-Akamai distribution.
package Net::Akamai;

use Moose;

use Moose::Util::TypeConstraints;
use SOAP::Lite;
use Net::Akamai::RequestData;
use Net::Akamai::ResponseData;

our $VERSION = '0.14';

has 'soap_version' => (
	is => 'ro', 
	isa => 'Str',
	default => sub { SOAP::Lite->VERSION },
);

has 'proxy' => (
	is => 'ro',
	isa => 'Str',
	default => 'https://ccuapi.akamai.com:443/soap/servlet/soap/purge',
);

has 'uri' => (
	is => 'ro',
	isa => 'Str',
	default => 'http://ccuapi.akamai.com/purge',
);

has 'soap' => (
	is => 'ro', 
	isa => 'SOAP::Lite',
	lazy_build => 1,
);
sub _build_soap {
	my $self = shift;
	return SOAP::Lite->new(
		proxy => $self->proxy,
		uri => $self->uri,
	);
}

has 'req_data' => (
	is => 'ro', 
	isa => 'Net::Akamai::RequestData',
	handles => [qw/ add_url email user pwd /],
	lazy_build => 1,
);
sub _build_req_data {
	return Net::Akamai::RequestData->new();
}

coerce 'Net::Akamai::ResponseData'
	=> from 'HashRef'
	=> via { Net::Akamai::ResponseData->new($_) };

has 'res_data' => (
	is => 'rw', 
	isa => 'Net::Akamai::ResponseData',
	coerce    => 1,
);


sub purge {
	my $self = shift;

	my $r = $self->soap->purgeRequest(
		SOAP::Data->name("name" => $self->req_data->user),
		SOAP::Data->name("pwd" => $self->req_data->pwd),
		SOAP::Data->name("network" => $self->req_data->network),
		SOAP::Data->name("opt" => $self->req_data->options),
		SOAP::Data->name("uri" => $self->req_data->urls)
	);

	# store in response object
	my $res = $r->result();
	$self->res_data({
		uri_index => $res->{uriIndex},
		result_code => $res->{resultCode},
		est_time => $res->{estTime},
		session_id => $res->{sessionID},
		result_msg => $res->{resultMsg}, 	
	});

	return $self->res_data();
}

1;