blib/lib/Net/Cisco/ACS/DeviceGroup.pm

filter: Statementstmt 67.5% 27 / 40 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 75.0% 6 / 8 Podpod 100% 2 / 2 totaltotal 57.3% 35 / 61 CC 5 SCAR 25.8
CC
5
Cov
56%
toXML
30.0
header
2.0
BEGIN
1.0
CRAP 13.2
« blib/lib/Net/Cisco/ACS/Host.pm ↑ Summary blib/lib/Net/Cisco/ACS/IdentityGroup.pm »
1 package Net::Cisco::ACS::DeviceGroup;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 BEGIN {
7 1 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS %actions);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶ $VERSION = '0.02';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 @ISA = qw(Exporter);
11 1 @EXPORT = qw();
12 1 @EXPORT_OK = qw();
13 1 %EXPORT_TAGS = ();
14 };
15  
16 1 %actions = ( "query" => "/Rest/NetworkDevice/DeviceGroup",
17 "create" => "/Rest/NetworkDevice/DeviceGroup",
18 "update" => "/Rest/NetworkDevice/DeviceGroup",
19 "getByName" => "/Rest/NetworkDevice/DeviceGroup/name/",
20 "getById" => "/Rest/NetworkDevice/DeviceGroup/id/",
21 );
22  
23 # MOOSE!
24
25 1 has 'description' => (
26 is => 'rw',
27 isa => 'Any',
28 );
29  
30 1 has 'id' => (
31 is => 'rw',
32 isa => 'Str',
33 );
34  
35 1 has 'name' => (
36 is => 'rw',
37 isa => 'Str',
38 );
39  
40 1 has 'groupType' => (
41 is => 'rw',
42 isa => 'Str',
43 );
44  
45 # No Moose
46  
47 sub toXML
48 0 ▶{ my $self = shift;
Subroutine toXML: not called CC=5 SCAR=34.0
Pod documented
49 0 my $result = "";
50 0 my $id = $self->id;
51 0 ▶ my $description = $self->description || "";
Condition0%0/2
$self->description || ''
l!l
00
MC/DC0%0/1
$self->description || ''
$self->description
Truth table0%0/2
A
A= $self->description
Aresult
11
00
52 0 ▶ my $name = $self->name || "";
Condition0%0/2
$self->name || ''
l!l
00
MC/DC0%0/1
$self->name || ''
$self->name
Truth table0%0/2
A
A= $self->name
Aresult
11
00
53 0 ▶ my $grouptype = $self->groupType || "Location";
Condition0%0/2
$self->groupType || 'Location'
l!l
00
MC/DC0%0/1
$self->groupType || 'Location'
$self->groupType
Truth table0%0/2
A
A= $self->groupType
Aresult
11
00
54 0 ▶ if ($id) { $result = " <id>$id</id>\n"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($id) 0 0 0
55
56 0 $result = <<XML;
57 <description>$description</description>
58 <name>$name</name>
59 <groupType>$grouptype</groupType>
60 XML
61  
62 0 return $result;
63 }
64  
65 sub header
66 0 ▶{ my $self = shift;
Subroutine header: not called CC=1 SCAR=6.9
Pod documented
67 0 my $devices = shift;
68 0 return qq(<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns1:deviceGroup xmlns:ns1="networkdevice.rest.mgmt.acs.nm.cisco.com">$devices</ns1:deviceGroup>);
69 }
70
71 =head1 NAME
72  
73 Net::Cisco::ACS::DeviceGroup - Access Cisco ACS functionality through REST API - DeviceGroup fields
74  
75 =head1 SYNOPSIS
76  
77 use Net::Cisco::ACS;
78 use Net::Cisco::ACS::DeviceGroup;
79
80 my $acs = Net::Cisco::ACS->new(hostname => '10.0.0.1', username => 'acsadmin', password => 'testPassword');
81
82 my %devicegroups = $acs->devicegroups;
83 # Retrieve all device groups from ACS
84 # Returns hash with device name / Net::Cisco::ACS::DeviceGroup pairs
85  
86 print $acs->devicegroups->{"All Locations"}->toXML;
87 # Dump in XML format (used by ACS for API calls)
88
89 my $device = $acs->devicegroups("name","All Locations");
90 # Faster call to request specific device group information by name
91  
92 my $devicegroup = $acs->devicegroups("id","250");
93 # Faster call to request specific device group information by ID (assigned by ACS, present in Net::Cisco::ACS::DeviceGroup)
94  
95 $devicegroup->id(0); # Required for new device group!
96 my $id = $acs->create($devicegroup);
97 # Create new device group based on Net::Cisco::ACS::DeviceGroup instance
98 # Return value is ID generated by ACS
99 print "Record ID is $id" if $id;
100 print $Net::Cisco::ACS::ERROR unless $id;
101 # $Net::Cisco::ACS::ERROR contains details about failure
102  
103 my $id = $acs->update($devicegroup);
104 # Update existing device based on Net::Cisco::ACS::DeviceGroup instance
105 # Return value is ID generated by ACS
106 print "Record ID is $id" if $id;
107 print $Net::Cisco::ACS::ERROR unless $id;
108 # $Net::Cisco::ACS::ERROR contains details about failure
109  
110 $acs->delete($devicegroup);
111 # Delete existing device based on Net::Cisco::ACS::DeviceGroup instance
112
113 =head1 DESCRIPTION
114  
115 The Net::Cisco::ACS::DeviceGroup class holds all the device group relevant information from Cisco ACS 5.x
116  
117 =head1 USAGE
118  
119 All calls are typically handled through an instance of the L<Net::Cisco::ACS> class. L<Net::Cisco::ACS::DeviceGroup> acts as a container for device group related information.
120  
121 =over 3
122  
123 =item new
124  
125 Class constructor. Returns object of Net::Cisco::ACS::DeviceGroup on succes. The following fields can be set / retrieved:
126  
127 =over 5
128  
129 =item description
130 =item name
131 =item id
132 =item groupType
133  
134 Formatting rules may be in place & enforced by Cisco ACS.
135  
136 =back
137  
138 =over 3
139  
140 =item description
141  
142 The device group account description, typically used for full device group name.
143  
144 =item name
145  
146 The device group name. This is a required value in the constructor but can be redefined afterwards.
147  
148 =item groupType
149  
150 This points to the type of Device Group, typically Location or Device Type but can be customized. See also L<Net::Cisco::ACS::Device> C<deviceType>.
151  
152 =item id
153  
154 Cisco ACS generates a unique ID for each Device Group record. This field cannot be updated within ACS but is used for reference. Set to 0 when creating a new record or when duplicating an existing device group.
155  
156 =item toXML
157  
158 Dump the record in ACS accept XML formatting (without header).
159  
160 =item header
161  
162 Generate the correct XML header. Takes output of C<toXML> as argument.
163  
164 =back
165  
166 =head1 BUGS
167  
168 None yet
169  
170 =head1 SUPPORT
171  
172 None yet :)
173  
174 =head1 AUTHOR
175  
176 Hendrik Van Belleghem
177 CPAN ID: BEATNIK
178 hendrik.vanbelleghem@gmail.com
179  
180 =head1 COPYRIGHT
181  
182 This program is free software licensed under the...
183  
184 The General Public License (GPL)
185 Version 2, June 1991
186  
187 The full text of the license can be found in the
188 LICENSE file included with this module.
189  
190  
191 =head1 SEE ALSO
192  
193 perl(1).
194  
195 =cut
196  
197 #################### main pod documentation end ###################
198 1 __PACKAGE__->meta->make_immutable();
199  
200 1 1;
201 # The preceding line will help the module return a true value
202  
« blib/lib/Net/Cisco/ACS/Host.pm ↑ Summary blib/lib/Net/Cisco/ACS/IdentityGroup.pm »