| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package AXL::Client::Simple; |
|
2
|
1
|
|
|
1
|
|
38615
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
use AXL::Client::Simple::Phone; |
|
11
|
|
|
|
|
|
|
use URI::Escape (); |
|
12
|
|
|
|
|
|
|
use Carp; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
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
|
|
|
|
|
|
|
my ($self, $phone_name) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $device = $self->getPhone->(phoneName => $phone_name); |
|
39
|
|
|
|
|
|
|
if (exists $device->{'Fault'}) { |
|
40
|
|
|
|
|
|
|
my $f = $device->{'Fault'}->{'faultstring'}; |
|
41
|
|
|
|
|
|
|
croak "Fault status returned from server in get_phone: $f\n"; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return AXL::Client::Simple::Phone->new({ |
|
45
|
|
|
|
|
|
|
client => $self, |
|
46
|
|
|
|
|
|
|
stash => $device->{'parameters'}->{'return'}->{'device'}, |
|
47
|
|
|
|
|
|
|
}); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub BUILDARGS { |
|
51
|
|
|
|
|
|
|
my ($class, @rest) = @_; |
|
52
|
|
|
|
|
|
|
my $params = (scalar @rest == 1 ? $rest[0] : {@rest}); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# collect AXL password from environment as last resort |
|
55
|
|
|
|
|
|
|
$params->{password} ||= $ENV{AXL_PASS}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# URI escape the username and password |
|
58
|
|
|
|
|
|
|
$params->{username} ||= ''; |
|
59
|
|
|
|
|
|
|
$params->{username} = URI::Escape::uri_escape($params->{username}); |
|
60
|
|
|
|
|
|
|
$params->{password} = URI::Escape::uri_escape($params->{password}); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $params; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
66
|
|
|
|
|
|
|
no Moose; |
|
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.01 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<URI::Escape> |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * L<File::ShareDir> |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=back |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 AUTHOR |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Oliver Gorwits C<< <oliver.gorwits@oucs.ox.ac.uk> >> |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Copyright (c) University of Oxford 2010. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
|
199
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |