| 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 | 1 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 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.03'; | |||||||||||
| 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 || ''
MC/DC0%0/1
$self->description || ''
$self->description
Truth table0%0/2
A
A= $self->description
| |||||||||||||
| 45 | 0 | ▶ | my $name = $self->name || ""; | ||||||||||
|
Condition0%0/2
$self->name || ''
MC/DC0%0/1
$self->name || ''
$self->name
Truth table0%0/2
A
A= $self->name
| |||||||||||||
| 46 | 0 | my $result = ""; | |||||||||||
| 47 | |||||||||||||
| 48 | 0 | ▶ | if ($id) { $result = " <id>$id</id>\n"; } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 | |||||||||||||
| 124 | =item name | ||||||||||||
| 125 | |||||||||||||
| 126 | =item id | ||||||||||||
| 127 | |||||||||||||
| 128 | Formatting rules may be in place & enforced by Cisco ACS. | ||||||||||||
| 129 | |||||||||||||
| 130 | =back | ||||||||||||
| 131 | |||||||||||||
| 132 | =item description | ||||||||||||
| 133 | |||||||||||||
| 134 | The identity group description. | ||||||||||||
| 135 | |||||||||||||
| 136 | =item name | ||||||||||||
| 137 | |||||||||||||
| 138 | 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. | ||||||||||||
| 139 | |||||||||||||
| 140 | =item id | ||||||||||||
| 141 | |||||||||||||
| 142 | 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. | ||||||||||||
| 143 | |||||||||||||
| 144 | =item toXML | ||||||||||||
| 145 | |||||||||||||
| 146 | Dump the record in ACS accept XML formatting (without header). | ||||||||||||
| 147 | |||||||||||||
| 148 | =item header | ||||||||||||
| 149 | |||||||||||||
| 150 | Generate the correct XML header. Takes output of C<toXML> as argument. | ||||||||||||
| 151 | |||||||||||||
| 152 | =back | ||||||||||||
| 153 | |||||||||||||
| 154 | =head1 BUGS | ||||||||||||
| 155 | |||||||||||||
| 156 | None so far | ||||||||||||
| 157 | |||||||||||||
| 158 | =head1 SUPPORT | ||||||||||||
| 159 | |||||||||||||
| 160 | None so far :) | ||||||||||||
| 161 | |||||||||||||
| 162 | =head1 AUTHOR | ||||||||||||
| 163 | |||||||||||||
| 164 | Hendrik Van Belleghem | ||||||||||||
| 165 | CPAN ID: BEATNIK | ||||||||||||
| 166 | hendrik.vanbelleghem@gmail.com | ||||||||||||
| 167 | |||||||||||||
| 168 | =head1 COPYRIGHT | ||||||||||||
| 169 | |||||||||||||
| 170 | This program is free software licensed under the... | ||||||||||||
| 171 | |||||||||||||
| 172 | The General Public License (GPL) | ||||||||||||
| 173 | Version 2, June 1991 | ||||||||||||
| 174 | |||||||||||||
| 175 | The full text of the license can be found in the | ||||||||||||
| 176 | LICENSE file included with this module. | ||||||||||||
| 177 | |||||||||||||
| 178 | |||||||||||||
| 179 | =head1 SEE ALSO | ||||||||||||
| 180 | |||||||||||||
| 181 | perl(1). | ||||||||||||
| 182 | |||||||||||||
| 183 | =cut | ||||||||||||
| 184 | |||||||||||||
| 185 | #################### main pod documentation end ################### | ||||||||||||
| 186 | 1 | __PACKAGE__->meta->make_immutable(); | |||||||||||
| 187 | |||||||||||||
| 188 | 1 | 1; | |||||||||||
| 189 | # The preceding line will help the module return a true value | ||||||||||||
| 190 | |||||||||||||