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

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