| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package AXL::Client::Simple; | 
| 2 | 1 |  |  | 1 |  | 14625 | use Moose; | 
|  | 1 |  |  |  |  | 312811 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | with qw/ | 
| 5 |  |  |  |  |  |  | AXL::Client::Simple::Role::SOAP | 
| 6 |  |  |  |  |  |  | AXL::Client::Simple::Role::getPhone | 
| 7 |  |  |  |  |  |  | AXL::Client::Simple::Role::getDeviceProfile | 
| 8 |  |  |  |  |  |  | AXL::Client::Simple::Role::getLine | 
| 9 |  |  |  |  |  |  | /; | 
| 10 | 1 |  |  | 1 |  | 4787 | use AXL::Client::Simple::Phone; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 36 |  | 
| 11 | 1 |  |  | 1 |  | 516 | use URI::Escape (); | 
|  | 1 |  |  |  |  | 1021 |  | 
|  | 1 |  |  |  |  | 19 |  | 
| 12 | 1 |  |  | 1 |  | 4 | use Carp; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 243 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | our $VERSION = '0.02'; | 
| 15 |  |  |  |  |  |  | $VERSION = eval $VERSION; # numify for warning-free dev releases | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | has username => ( | 
| 18 |  |  |  |  |  |  | is => 'ro', | 
| 19 |  |  |  |  |  |  | isa => 'Str', | 
| 20 |  |  |  |  |  |  | required => 1, | 
| 21 |  |  |  |  |  |  | ); | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | has password => ( | 
| 24 |  |  |  |  |  |  | is => 'ro', | 
| 25 |  |  |  |  |  |  | isa => 'Str', | 
| 26 |  |  |  |  |  |  | required => 1, | 
| 27 |  |  |  |  |  |  | ); | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | has server => ( | 
| 30 |  |  |  |  |  |  | is => 'ro', | 
| 31 |  |  |  |  |  |  | isa => 'Str', | 
| 32 |  |  |  |  |  |  | required => 1, | 
| 33 |  |  |  |  |  |  | ); | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | sub get_phone { | 
| 36 | 0 |  |  | 0 |  |  | my ($self, $phone_name) = @_; | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 0 |  |  |  |  |  | my $device = $self->getPhone->(phoneName => $phone_name); | 
| 39 | 0 | 0 |  |  |  |  | if (exists $device->{'Fault'}) { | 
| 40 | 0 |  |  |  |  |  | my $f = $device->{'Fault'}->{'faultstring'}; | 
| 41 | 0 |  |  |  |  |  | croak "Fault status returned from server in get_phone: $f\n"; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | return AXL::Client::Simple::Phone->new({ | 
| 45 |  |  |  |  |  |  | client => $self, | 
| 46 | 0 |  |  |  |  |  | stash  => $device->{'parameters'}->{'return'}->{'device'}, | 
| 47 |  |  |  |  |  |  | }); | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | sub BUILDARGS { | 
| 51 | 0 |  |  | 0 |  |  | my ($class, @rest) = @_; | 
| 52 | 0 | 0 |  |  |  |  | my $params = (scalar @rest == 1 ? $rest[0] : {@rest}); | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | # collect AXL password from environment as last resort | 
| 55 | 0 |  | 0 |  |  |  | $params->{password} ||= $ENV{AXL_PASS}; | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | # URI escape the username and password | 
| 58 | 0 |  | 0 |  |  |  | $params->{username} ||= ''; | 
| 59 | 0 |  |  |  |  |  | $params->{username} = URI::Escape::uri_escape($params->{username}); | 
| 60 | 0 |  |  |  |  |  | $params->{password} = URI::Escape::uri_escape($params->{password}); | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 0 |  |  |  |  |  | return $params; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; | 
| 66 | 1 |  |  | 1 |  | 4 | no Moose; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 67 |  |  |  |  |  |  | 1; | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | __END__ | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | =head1 NAME | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | AXL::Client::Simple - Cisco Unified Communications XML API | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | =head1 VERSION | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | This document refers to version 0.02 of AXL::Client::Simple | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | Set up your CUCM AXL client: | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | use AXL::Client::Simple; | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | my $cucm = AXL::Client::Simple->new({ | 
| 86 |  |  |  |  |  |  | server      => 'call-manager-server.example.com', | 
| 87 |  |  |  |  |  |  | username    => 'oliver', | 
| 88 |  |  |  |  |  |  | password    => 's3krit', # or set in $ENV{AXL_PASS} | 
| 89 |  |  |  |  |  |  | }); | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | Then perform simple queries on the Unified Communications server: | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | my $device = $cucm->get_phone('SEP001122334455'); | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | my $lines = $device->lines; | 
| 96 |  |  |  |  |  |  | printf "this device has %s lines.\n", $lines->count; | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | while ($lines->has_next) { | 
| 99 |  |  |  |  |  |  | my $l = $lines->next; | 
| 100 |  |  |  |  |  |  | print $l->alertingName, "\n"; | 
| 101 |  |  |  |  |  |  | print $l->extn, "\n"; | 
| 102 |  |  |  |  |  |  | } | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | if ($device->has_active_em) { | 
| 105 |  |  |  |  |  |  | # extension mobility is active, so the lines are different | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | my $profile = $device->currentProfile; | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | my $profile_lines = $profile->lines; | 
| 110 |  |  |  |  |  |  | printf "this profile has %s lines.\n", $profile_lines->count; | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | while ($profile_lines->has_next) { | 
| 113 |  |  |  |  |  |  | my $l = $profile_lines->next; | 
| 114 |  |  |  |  |  |  | print $l->alertingName, "\n"; | 
| 115 |  |  |  |  |  |  | print $l->extn, "\n"; | 
| 116 |  |  |  |  |  |  | } | 
| 117 |  |  |  |  |  |  | } | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | This module acts as a client to the Cisco Unified Communications | 
| 122 |  |  |  |  |  |  | Administrative XML interface (AXL). From here you can perform simple queries | 
| 123 |  |  |  |  |  |  | to retrieve phone device details and in particular the lines active on a | 
| 124 |  |  |  |  |  |  | device. | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | Although the API is presently very limited, it should be possible to add | 
| 127 |  |  |  |  |  |  | access to additional device and line properties, although performing other AXL | 
| 128 |  |  |  |  |  |  | calls is probably out of scope (hence the module being named Simple). | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | If the device is running Extension Mobility and a user is logged in, you can | 
| 131 |  |  |  |  |  |  | also retrieve the line details from the current mobility profile active on the | 
| 132 |  |  |  |  |  |  | handset. | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =head1 METHODS | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | =head2 AXL::Client::Simple->new( \%arguments ) | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | Instantiates a new AXL client. There won't be any connection to the server | 
| 139 |  |  |  |  |  |  | until you call the device retrieval method C<get_phone>. Arguments are: | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =over 4 | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =item C<< server => >> Fully Qualified Domain Name (required) | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | The host name of the CUCM server to which the module should connect. Note that | 
| 146 |  |  |  |  |  |  | the port number 8443 and the path C</axl/> are automatically appended so you | 
| 147 |  |  |  |  |  |  | need only provide the FQDN or IP address. | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | =item C<< username => >> String (required) | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | The account username under which the module will connect to CUCM. This value | 
| 152 |  |  |  |  |  |  | will be URI encoded by the module. | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | =item C<< password => >> String OR via C<$ENV{AXL_PASS}> (required) | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | The password of the account under which the module will connect to CUCM.  This | 
| 157 |  |  |  |  |  |  | value will be URI encoded by the module. You can also provide the password via | 
| 158 |  |  |  |  |  |  | the C<AXL_PASS> environment variable. | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  | =item C<< schema_path => >> String (optional) | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | A folder on your file system which contains the WSDL and Schema file which | 
| 163 |  |  |  |  |  |  | describe the Administrative XML (AXL) interface. They are shipped with this | 
| 164 |  |  |  |  |  |  | module so your providing this is optional. | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | =back | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  | =head2 C<< $cucm->get_phone( <device-name> ) >> | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | Retrieves the L<AXL::Client::Simple::Phone> object which reveals a limited | 
| 171 |  |  |  |  |  |  | number of phone properties and details on the active extensions on the | 
| 172 |  |  |  |  |  |  | handset. See that linked manual page for more details. | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  | =head1 REQUIREMENTS | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | =over 4 | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | =item * L<Moose> | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | =item * L<MooseX::Iterator> | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | =item * L<XML::Compile::SOAP> | 
| 183 |  |  |  |  |  |  |  | 
| 184 |  |  |  |  |  |  | =item * L<XML::Compile::WSDL11> | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  | =item * L<URI::Escape> | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | =item * L<File::ShareDir> | 
| 189 |  |  |  |  |  |  |  | 
| 190 |  |  |  |  |  |  | =back | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | =head1 AUTHOR | 
| 193 |  |  |  |  |  |  |  | 
| 194 |  |  |  |  |  |  | Oliver Gorwits C<< <oliver.gorwits@oucs.ox.ac.uk> >> | 
| 195 |  |  |  |  |  |  |  | 
| 196 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 197 |  |  |  |  |  |  |  | 
| 198 |  |  |  |  |  |  | Copyright (c) University of Oxford 2010. | 
| 199 |  |  |  |  |  |  |  | 
| 200 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify it under | 
| 201 |  |  |  |  |  |  | the same terms as Perl itself. | 
| 202 |  |  |  |  |  |  |  | 
| 203 |  |  |  |  |  |  | =cut |