AXL-Client-Simple
view release on metacpan or search on metacpan
lib/AXL/Client/Simple.pm view on Meta::CPAN
package AXL::Client::Simple;
use Moose;
with qw/
AXL::Client::Simple::Role::SOAP
AXL::Client::Simple::Role::getPhone
AXL::Client::Simple::Role::getDeviceProfile
AXL::Client::Simple::Role::getLine
/;
use AXL::Client::Simple::Phone;
use URI::Escape ();
use Carp;
our $VERSION = '0.02';
$VERSION = eval $VERSION; # numify for warning-free dev releases
has username => (
is => 'ro',
isa => 'Str',
required => 1,
);
has password => (
is => 'ro',
isa => 'Str',
required => 1,
);
has server => (
is => 'ro',
isa => 'Str',
required => 1,
);
sub get_phone {
my ($self, $phone_name) = @_;
my $device = $self->getPhone->(phoneName => $phone_name);
if (exists $device->{'Fault'}) {
my $f = $device->{'Fault'}->{'faultstring'};
croak "Fault status returned from server in get_phone: $f\n";
}
return AXL::Client::Simple::Phone->new({
client => $self,
stash => $device->{'parameters'}->{'return'}->{'device'},
});
}
sub BUILDARGS {
my ($class, @rest) = @_;
my $params = (scalar @rest == 1 ? $rest[0] : {@rest});
# collect AXL password from environment as last resort
$params->{password} ||= $ENV{AXL_PASS};
# URI escape the username and password
$params->{username} ||= '';
$params->{username} = URI::Escape::uri_escape($params->{username});
$params->{password} = URI::Escape::uri_escape($params->{password});
return $params;
}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
__END__
=head1 NAME
AXL::Client::Simple - Cisco Unified Communications XML API
=head1 VERSION
This document refers to version 0.02 of AXL::Client::Simple
=head1 SYNOPSIS
Set up your CUCM AXL client:
use AXL::Client::Simple;
my $cucm = AXL::Client::Simple->new({
server => 'call-manager-server.example.com',
username => 'oliver',
password => 's3krit', # or set in $ENV{AXL_PASS}
});
Then perform simple queries on the Unified Communications server:
my $device = $cucm->get_phone('SEP001122334455');
my $lines = $device->lines;
printf "this device has %s lines.\n", $lines->count;
while ($lines->has_next) {
my $l = $lines->next;
print $l->alertingName, "\n";
print $l->extn, "\n";
}
if ($device->has_active_em) {
# extension mobility is active, so the lines are different
my $profile = $device->currentProfile;
my $profile_lines = $profile->lines;
printf "this profile has %s lines.\n", $profile_lines->count;
( run in 1.289 second using v1.01-cache-2.11-cpan-39bf76dae61 )