Net-Intermapper
view release on metacpan or search on metacpan
lib/Net/Intermapper.pm view on Meta::CPAN
package Net::Intermapper;
use strict;
use Moose;
# REST IO stuff here
use IO::Socket::SSL qw( SSL_VERIFY_NONE );
use LWP::UserAgent;
# Generics
use File::Path;
use URI::Escape;
use Text::CSV_XS;
use Data::Dumper;
use XML::Simple;
# Net::Intermapper::*
use Net::Intermapper::User;
use Net::Intermapper::Device;
use Net::Intermapper::Interface;
use Net::Intermapper::Map;
use Net::Intermapper::Vertice;
BEGIN {
use Exporter ();
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $ERROR %_CHANGED);
$VERSION = '0.04';
@ISA = qw(Exporter);
@EXPORT = qw();
@EXPORT_OK = qw();
%EXPORT_TAGS = ();
%_CHANGED = ();
$ERROR = ""; # TODO: Document error properly!
}
# Moose!
has 'ssl_options' => (
is => 'rw',
isa => 'HashRef',
default => sub { { 'SSL_verify_mode' => SSL_VERIFY_NONE, 'verify_hostname' => '0' } }
);
has 'ssl' => (
is => 'rw',
isa => 'Str',
default => '1',
);
has 'hostname' => (
is => 'rw',
isa => 'Str',
required => '1',
);
has 'port' => (
is => 'rw',
isa => 'Int',
default => sub { 8181 },
);
has 'modifyport' => (
is => 'rw',
isa => 'Int',
default => sub { 443 },
);
lib/Net/Intermapper.pm view on Meta::CPAN
$intermapper->vertices($vertices);
# At this point, there is no real reason to do this as update, create and delete work with explicit arguments.
# But it can be done with users, devices, interfaces, maps and vertices
# Pass a hashref to each method. This will NOT affect the smart-caching (only explicit calls to create, update and delete do this - for now).
=item create
This method created a new entry in Intermapper, depending on the argument passed. Record type is detected automatically.
$intermapper->username("admin");
$intermapper->password("nmsadmin");
my $user = Net::Intermapper::User->new(Name=>"testuser", Password=>"Test12345");
my $response = $intermapper->create($user);
# Error checking needs to be added
# print $Net::Intermapper::ERROR unless $id;
# $Net::Intermapper::ERROR contains details about failure
# Add more examples
# Interfaces and maps cannot be explicitly created!
=item update
This method updates an existing entry in Intermapper, depending on the argument passed. Record type is detected automatically.
my $user = $intermapper->users->{"testuser"};
$user->Password("TopSecret"); # Change password. Password policies will be enforced!
my $response = $intermapper->update($user);
# Error checking needs to be added
# Update user based on Net::Intermapper::User instance
# print $Net::Intermapper::ERROR unless $id;
# $Net::Intermapper::ERROR contains details about failure
=item delete
This method deletes an existing entry in Intermapper, depending on the argument passed. Record type is detected automatically.
my $user = $intermapper->users->{"bob"};
my $response = $intermapper->delete($user);
# Delete existing user
my $device = $intermapper->devices->{"UniqueDeviceID"}; # This key is generated by Intermapper
$intermapper->delete($device);
# Delete existing device
=item $ERROR
NEEDS TO BE ADDED
This variable will contain detailed error information.
=back
=head1 REQUIREMENTS
For this library to work, you need an instance with Intermapper (obviously) or a simulator like L<Net::Intermapper::Mock>.
=over 3
=item L<Moose>
=item L<IO::Socket::SSL>
=item L<LWP::UserAgent>
=item L<XML::Simple>
=item L<MIME::Base64>
=item L<URI::Escape>
=item L<Text::CSV_XS>
=back
=head1 BUGS
None so far
=head1 TODO
=over 3
=item Filtering should be added (match= keyword in Intermapper documentation)
=item XML input and output needs to be completed!
=item $ERROR variable needs to actually contain error message!
=back
=head1 SUPPORT
None so far :)
=head1 AUTHOR
Hendrik Van Belleghem
CPAN ID: BEATNIK
hendrik.vanbelleghem@gmail.com
=head1 COPYRIGHT
This program is free software licensed under the...
The General Public License (GPL)
Version 2, June 1991
The full text of the license can be found in the
LICENSE file included with this module.
=head1 SEE ALSO
L<http://download.intermapper.com/docs/UserGuide/Content/09-Reference/09-05-Advanced_Importing/the_directive_line.htm>
L<http://download.intermapper.com/schema/imserverschema.html>
=cut
#################### main pod documentation end ###################
__PACKAGE__->meta->make_immutable();
( run in 0.624 second using v1.01-cache-2.11-cpan-5b529ec07f3 )