line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AXL::Client::Simple::Phone; |
2
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
4069
|
use AXL::Client::Simple::LineResultSet; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
341
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
$VERSION = eval $VERSION; # numify for warning-free dev releases |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has client => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => 'AXL::Client::Simple', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
weak_ref => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has stash => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'HashRef', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has currentProfileName => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => 'Str', |
26
|
|
|
|
|
|
|
required => 0, |
27
|
|
|
|
|
|
|
lazy_build => 1, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
|
|
sub _build_currentProfileName { return (shift)->stash->{currentProfileName} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has loginUserId => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
isa => 'Str', |
35
|
|
|
|
|
|
|
required => 0, |
36
|
|
|
|
|
|
|
lazy_build => 1, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
|
|
sub _build_loginUserId { return (shift)->stash->{loginUserId} } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub has_active_em { |
42
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
43
|
0
|
|
0
|
|
|
|
return ($self->currentProfileName && $self->loginUserId); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has currentProfile => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
isa => 'AXL::Client::Simple::Phone', |
49
|
|
|
|
|
|
|
lazy_build => 1, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _build_currentProfile { |
53
|
0
|
|
|
0
|
|
|
my $self = shift; |
54
|
0
|
0
|
|
|
|
|
return $self if not $self->has_active_em; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $profile = $self->client->getDeviceProfile->( |
57
|
|
|
|
|
|
|
profileName => $self->currentProfileName); |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if (exists $profile->{'Fault'}) { |
60
|
0
|
|
|
|
|
|
my $f = $profile->{'Fault'}->{'faultstring'}; |
61
|
0
|
|
|
|
|
|
croak "Fault status returned from server in _build_currentProfile: $f\n"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return AXL::Client::Simple::Phone->new({ |
65
|
|
|
|
|
|
|
client => $self->client, |
66
|
0
|
|
|
|
|
|
stash => $profile->{'parameters'}->{'return'}->{'profile'}, |
67
|
|
|
|
|
|
|
}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has lines => ( |
71
|
|
|
|
|
|
|
is => 'ro', |
72
|
|
|
|
|
|
|
isa => 'AXL::Client::Simple::LineResultSet', |
73
|
|
|
|
|
|
|
lazy_build => 1, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _build_lines { |
77
|
0
|
|
|
0
|
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my @lines = map { { stash => $_ } } |
80
|
0
|
0
|
|
|
|
|
map { defined $_ ? $_ : () } |
81
|
0
|
|
|
|
|
|
map { $_->{'parameters'}->{'return'}->{'directoryNumber'} } |
82
|
0
|
|
|
|
|
|
map { $self->client->getLine->(uuid => $_) } |
83
|
0
|
|
|
|
|
|
map { $_->{'dirn'}->{'uuid'} } |
84
|
0
|
0
|
|
|
|
|
@{ $self->stash->{'lines'}->{'line'} || [] }; |
|
0
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return AXL::Client::Simple::LineResultSet->new({items => \@lines}); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
90
|
1
|
|
|
1
|
|
4
|
no Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
AXL::Client::Simple::Phone - Properties and Lines on a CUCM Handset |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 VERSION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This document refers to version 0.01 of AXL::Client::Simple::Phone |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SYNOPSIS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
First set up your CUCM AXL client as per L<AXL::Client::Simple>: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
use AXL::Client::Simple; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $cucm = AXL::Client::Simple->new({ |
110
|
|
|
|
|
|
|
server => 'call-manager-server.example.com', |
111
|
|
|
|
|
|
|
username => 'oliver', |
112
|
|
|
|
|
|
|
password => 's3krit', # or set in $ENV{AXL_PASS} |
113
|
|
|
|
|
|
|
}); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Then perform simple queries on the Unified Communications server: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $device = $cucm->get_phone('SEP001122334455'); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $lines = $device->lines; |
120
|
|
|
|
|
|
|
printf "this device has %s lines.\n", $lines->count; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
while ($lines->has_next) { |
123
|
|
|
|
|
|
|
my $l = $lines->next; |
124
|
|
|
|
|
|
|
print $l->alertingName, "\n"; |
125
|
|
|
|
|
|
|
print $l->extn, "\n"; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
if ($device->has_active_em) { |
129
|
|
|
|
|
|
|
# extension mobility is active, so the lines are different |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $profile = $device->currentProfile; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my $profile_lines = $profile->lines; |
134
|
|
|
|
|
|
|
printf "this profile has %s lines.\n", $profile_lines->count; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
while ($profile_lines->has_next) { |
137
|
|
|
|
|
|
|
my $l = $profile_lines->next; |
138
|
|
|
|
|
|
|
print $l->alertingName, "\n"; |
139
|
|
|
|
|
|
|
print $l->extn, "\n"; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 DESCRIPTION |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This module allows you to retrieve some properties of a device registered with |
146
|
|
|
|
|
|
|
a Cisco Unified Communications server, including its line numbers and |
147
|
|
|
|
|
|
|
extension mobility profile lines. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 METHODS |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 CONSTRUCTOR |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 AXL::Client::Simple::Phone->new( \%arguments ) |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
You would not normally call this constructor. Use the L<AXL::Client::Simple> |
156
|
|
|
|
|
|
|
constructor instead. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over 4 |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item C<< client => >> C<AXL::Client::Simple> object (required) |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
An instance of C<AXL::Client::Simple> which has been configured with your |
163
|
|
|
|
|
|
|
server location, user credentials and SOAP APIs. This will be stored as a weak |
164
|
|
|
|
|
|
|
reference. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item C<< stash => >> Hash Ref (required) |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This hash reference contains the raw data returned from the Unified |
169
|
|
|
|
|
|
|
Communications server when asked for properties of this device. From this |
170
|
|
|
|
|
|
|
stash are retrieved data to construct each property as listed below. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 LINES QUERY AND RESULT SET |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 $device->lines |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Query the Unified Communications server and retrieve phone line details for |
179
|
|
|
|
|
|
|
this device. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
The returned object contains the ordered collection of phone lines and is of |
182
|
|
|
|
|
|
|
type C<AXL::Client::Simple::LineResultSet>. It's an iterator, so you can walk |
183
|
|
|
|
|
|
|
through the list of lines (see the synposis, above). For example: |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
my $lines = $device->lines; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 $lines->next |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Provides the next item in the collection of lines, or C<undef> if there are no |
190
|
|
|
|
|
|
|
more items to return. Usually used in a loop along with C<has_next> like so: |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
while ($lines->has_next) { |
193
|
|
|
|
|
|
|
print $lines->next->alertingName, "\n"; # the alerting name field from CUCM |
194
|
|
|
|
|
|
|
print $lines->next->extn, "\n"; # the phone line extension number |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 $lines->peek |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Returns the next item without moving the state of the iterator forward. It |
200
|
|
|
|
|
|
|
returns C<undef> if it is at the end of the collection and there are no more |
201
|
|
|
|
|
|
|
items to return. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 $lines->has_next |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Returns a true value if there is another entry in the collection after the |
206
|
|
|
|
|
|
|
current item, otherwise returns a false value. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 $lines->reset |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Resets the iterator's cursor, so you can walk through the entries again from |
211
|
|
|
|
|
|
|
the start. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 $lines->count |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Returns the number of entries returned by the C<lines> server query. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 $lines->items |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Returns an array ref containing all the entries returned by the C<lines> |
220
|
|
|
|
|
|
|
server query. They are each objects of type C<AXL::Client::Simple::Line>. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head2 PHONE PROPERTIES |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head2 $device->currentProfileName |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
If the device has Extension Mobility enabled and an extension mobility profile |
227
|
|
|
|
|
|
|
is active, then its name will be returned by this accessor. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 $device->loginUserId |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
When Extension Mobility is active, you can find out the username of the logged |
232
|
|
|
|
|
|
|
in user by querying this property. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head2 $device->has_active_em |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
To easily find out whether Extension Mobility is active on a live handset, use |
237
|
|
|
|
|
|
|
this property which will return a true value if that is the case. Otherwise, |
238
|
|
|
|
|
|
|
it returns a false value. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 $device->currentProfile |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Assuming the device does have Extension Mobility active, then you can grab the |
243
|
|
|
|
|
|
|
extension mobility profile details from this property. In fact, what is |
244
|
|
|
|
|
|
|
returned is another instance of C<AXL::Client::Simple::Phone> (this module) |
245
|
|
|
|
|
|
|
which in turn allows you to access the profile's line numers via C<lines> as |
246
|
|
|
|
|
|
|
above. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 SEE ALSO |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=over 4 |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=item * L<http://developer.cisco.com/web/axl> |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=back |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 AUTHOR |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Oliver Gorwits C<< <oliver.gorwits@oucs.ox.ac.uk> >> |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Copyright (c) University of Oxford 2010. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
265
|
|
|
|
|
|
|
the same terms as Perl itself. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=cut |