ARS-Simple
view release on metacpan or search on metacpan
lib/ARS/Simple.pm view on Meta::CPAN
package ARS::Simple;
use 5.006;
use strict;
use warnings FATAL => 'all';
use ARS 1.68;
use Carp;
use Data::Dumper;
our $VERSION = '0.01';
$Data::Dumper::Indent=1;
$Data::Dumper::Sortkeys=1;
our %config;
my $user;
my $pword;
BEGIN
{
my $module = 'ARS/Simple.pm';
my $cfg = $INC{$module};
unless ($cfg)
{
die "Wrong case in use statement or $module module renamed. Perl is case sensitive!!!\n";
}
my $compiled = !(-e $cfg); # if the module was not read from disk => the script has been "compiled"
$cfg =~ s/\.pm$/.cfg/;
if ($compiled or -e $cfg)
{
# In a Perl2Exe or PerlApp created executable or PerlCtrl
# generated COM object or the cfg is known to exist
eval {require $cfg};
if ($@ and $@ !~ /Can't locate /) #' <-- syntax higlighter
{
carp "Error in $cfg : $@";
}
}
}
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless($self, $class);
# Run initialisation code
$self->_init(@_);
return $self;
}
sub DESTROY
{
my $self = shift;
if ($self->{ctl})
{
ars_Logoff($self->{ctl});
}
}
sub _check_initialised
{
my $self = shift;
unless ($self->{ctl})
{
$self->_carp("Connected to Remedy ARSystem has not been establised yet.\n");
return;
}
lib/ARS/Simple.pm view on Meta::CPAN
{
$ARS::DEBUGGING = 1;
}
$self->{debug} = $args->{debug} ? 1 : 0;
## Now connect to Remedy
if ($self->{server} && $user && $pword)
{
my $ctl = ars_Login($self->{server}, $user, $pword);
if ($ctl)
{
$self->{ctl} = $ctl;
}
else
{
croak(__PACKAGE__ . " object initialisation failed.\nFailed to log into Remedy server=" . $self->{server} . " as user '$user' with supplied password: $ars_errstr\n");
}
}
else
{
croak(__PACKAGE__ . " object initialisation failed, server, user and password are required\n");
}
}
# GG test - need to find and store the current value of AR_SERVER_INFO_MAX_ENTRIES
# so we can set reset_limit if not defined
#my %s = ars_GetServerInfo($self->{ctl});
#print Dumper(\%s);
1; # End of ARS::Simple
__END__
=head1 NAME
ARS::Simple - A simplified interface to Remedy ARSystem
=head1 SYNOPSIS
A simple interface to Remedy ARSystem utilising the ARSperl API interface.
Keeps your code more readable and by use of the cache avoids your credentials
being spread through all your scripts.
use ARS::Simple;
my $ar = ARS::Simple->new({
server => 'my_remedy_server',
user => 'admin',
password => 'admin',
});
### Get the Entry-ID/Request-ID for all User's with Login starting with 'g'
# Here $eid is any array reference of entry-id/request-id values
my $data = $ar->get_list({
form => 'User',
query => qq{'Login' LIKE "g%"},
});
print Data::Dumper->Dump([$data], ['data']), "\n";
# Resulting data dump:
# $data = {
# 'eids' => [
# '000000000004467',
# '000000000004469',
# '000000000004470',
# ],
# 'numMatches' => 3
#};
### Get data from a form, based on a query (as you would use in the User Tool)
my $form = 'User';
my $entryListLabel = $ar->get_data_by_label({
form => $form,
query => qq{'Login Name' LIKE "ge%"}, # Login Name = FID 101
lfid => { 'LoginName', 101, 'FullName', 8, 'LicenseType', 109, },
});
print Data::Dumper->Dump([$entryListLabel], ['entryListLabel']), "\n";
# Resulting data dump:
# $entryListLabel = {
# '000000000014467' => {
# 'FullName' => 'Geoff Batty',
# 'LicenseType' => 0,
# 'LoginName' => 'gbatty'
# },
# '000000000014469' => {
# 'FullName' => 'Greg George',
# 'LicenseType' => 2,
# 'LoginName' => 'gregg'
# },
# '000000000024470' => {
# 'FullName' => 'Gabrielle Gustoff',
# 'LicenseType' => 0,
# 'LoginName' => 'ggustoff'
# },
# Update a record, change the Login Name to 'greg'
my %lvp = ( LoginName => 'greg' );
$ar->update_record({
eid => '000000000014469',
form => 'User',
lvp => \%lvp,
lfid => { 'LoginName', 101, 'FullName', 8, 'LicenseType', 109, },
});
=head1 VERSION
Version 0.01
=head2 FEATURES
=over 4
=item *
Provides obfuscated storage for default user and password so they are
not scattered throuhout all your scripts
=item *
Provide a perlish interface to ARSperl which makes your code
more readable
=back
=head1 METHODS
=head2 new
Constructor for ARS::Simple. There are three required arguments:
=over 4
=item server
The name (or possibly IP Address) of the Remedy ARSystem server you
wish to connect to.
( run in 1.281 second using v1.01-cache-2.11-cpan-39bf76dae61 )