view release on metacpan or search on metacpan
{
die "Do not execute this script directly, run:\n\tperl Makefile.PL
\tmake\n\tmake test\n\tmake install\n
If you are using ActivePerl under Windows use 'nmake' or 'dmake' instead of 'make'.";
}
}
if (($configfile && -f $configfile) || -f 'blib/lib/ARS/Simple.cfg') { exit; }
my $user = '';
my $password = '';
my $proxy = '';
unless ($ENV{PERL_MM_USE_DEFAULT} || $ENV{AUTOMATED_TESTING} || !-t STDIN)
{
print "\n================ Set the defaults for module ARS::Simple ================\n";
print "\nSpecify defaults for ARS::Simple? (y/N) ";
$res = <STDIN>;
exit unless $res =~ /^y$/i;
if (! $configfile)
{
#exit if -f $configfile;
# Gather the defaults
print "\nDefault user to use for Remedy: ";
$user = <STDIN>;
$user =~ s/^\s+//;
$user =~ s/\s+$//;
print "Password for user '$user': ";
$password = <STDIN>;
$password =~ s/^\s+//;
$password =~ s/\s+$//;
print "\nSaving config file, using the following:\n";
}
if (! $configfile)
{
$configfile = 'blib/lib/ARS/Simple.cfg';
}
open $fh, '>', $configfile || die "failed to open $configfile: $!";
print $fh "# Config file for ARS::Simple\n# generated by Config.PL (".scalar(localtime).")\n# This file MUST be valid perl (as it is 'required')\n# Note user and password are obfuscated, NOT encrypted.\n\n";
print $fh q{%config = (} . "\n";
# Doing simple obfuscation of user and password
my $k = '5Jv@sI9^bl@D*j5H3@:7g4H[2]d%Ks314aNuGeX;';
my $x = substr($k, 0, length($user));
my $u = $user ^ $x;
my $up = unpack('H*', $u);
print $fh "\tuser => '$up',\n";
$x = substr($k, 0, length($password));
$u = $password ^ $x;
$up = unpack('H*', $u);
print $fh "\tpassword => '$up',\n";
print $fh ");\n1;\n#--< End of File >--#\n";
close $fh;
unless ($ENV{PERL_MM_USE_DEFAULT} || $ENV{AUTOMATED_TESTING} || !-t STDIN)
{
print "\tuser => '$user' (obfuscated),\n";
print "\tpassword => '$password' (obfuscated),\n";
print "\nFinished configuration\n";
}
#####################################################################
# DO NOT REMOVE THE FOLLOWING LINE, IT IS NEEDED TO LOAD THIS LIBRARY
1;
#---< End of File >---#
Makefile.PL view on Meta::CPAN
Type 'make install' to install ARS::Simple.
";
}
exit 0;
sub makeTestConfig
{
my ($server, $user, $password);
my ($i, $u, $p) = ('', $ENV{USERNAME}, '');
if(-e './t/config.cache')
{
do './t/config.cache';
$i = &CCACHE::server;
$u = &CCACHE::user;
$p = &CCACHE::password;
}
print "=== ARS::Simple 'make test' configuration. ===
Test on your own dev system where you know the user you select below
is in the administrator group.
Please enter the following information. This information will be
recorded in ./t/config.cache. YOU SHOULD REMOVE this file once
you have finished testing as the data is in plain text.
Makefile.PL view on Meta::CPAN
production Remedy ARS server.
";
$server = prompt("The Remedy server hostname (or IP Address)", $i);
if ($server eq '') { $server = $i if ($i ne ''); }
$user = prompt("Remedy user with admin", $u);
if($user eq '') { $user = $u if ($u ne ''); }
$password = prompt("Password", $p);;
if($password eq '') { $password = $p if ($p ne ''); }
open (FD, '>', './t/config.cache') || die "open of './t/config.cache' failed: $!";
print FD "package CCACHE;\n";
print FD "\# enter your remedy server, username and password below.\n\n";
print FD qq{sub server { '$server' ; }\n};
print FD qq{sub user { '$user' ; }\n};
print FD qq{sub password { '$password' ; }\n};
print FD "1;\n";
close(FD);
}
examples/generate_fid_hash.pl view on Meta::CPAN
# and add it to the clipboard for easy pasting into your code
use warnings;
use strict;
use ARS::Simple;
use Win32::Clipboard;
my $CLIP = Win32::Clipboard();
my $ars = ARS::Simple->new({
server => 'dev_machine',
user => 'greg',
password => 'password',
});
print "Enter the name of the Remedy form: ";
my $form = <STDIN>;
chomp $form;
#----------
my $sql = qq{select
f.fieldName,
f.fieldID,
examples/get_data_by_label.pl view on Meta::CPAN
use strict;
use warnings FATAL => 'all';
use ARS::Simple;
use Data::Dumper;
# Dump detail of all User form records
my $ars = ARS::Simple->new({
server => 'dev_machine',
user => 'greg',
password => 'password',
});
%fid = (
'CreateDate' => 3, # System RO type=AR_DATA_TYPE_TIME
'LastModifiedBy' => 5, # System RO type=AR_DATA_TYPE_CHAR 254
'ModifiedDate' => 6, # System RO type=AR_DATA_TYPE_TIME
'RequestID' => 1, # System RO type=AR_DATA_TYPE_CHAR 15
'Creator' => 2, # Required type=AR_DATA_TYPE_CHAR 254
'FullName' => 8, # Required type=AR_DATA_TYPE_CHAR 254
'FullTextLicenseType' => 110, # Required type=AR_DATA_TYPE_ENUM
examples/get_list.pl view on Meta::CPAN
use strict;
use warnings FATAL => 'all';
use ARS::Simple;
use Data::Dumper;
# Get the Entry-Id of all User form records
my $ars = ARS::Simple->new({
server => 'dev_machine',
user => 'greg',
password => 'password',
});
my $eids = $ars->get_list({ form => 'User', query => '1=1', });
print Dumper($eids), "\n";
html/Simple.html view on Meta::CPAN
<h1 id="SYNOPSIS">SYNOPSIS</h1>
<p>A simple interface to Remedy ARSystem utilising the ARSperl API interface:</p>
<pre><code> <span class="keyword">use</span> <span class="variable">ARS::Simple</span><span class="operator">;</span>
<span class="keyword">my</span> <span class="variable">$ar</span> <span class="operator">=</span> <span class="variable">ARS::Simple</span><span class="operator">-></span><span class="variable">new</span><span class="operator">(</span><span class...
<span class="string">server</span> <span class="operator">=></span> <span class="string">'my_remedy_server'</span><span class="operator">,</span>
<span class="string">user</span> <span class="operator">=></span> <span class="string">'admin'</span><span class="operator">,</span>
<span class="string">password</span> <span class="operator">=></span> <span class="string">'admin'</span><span class="operator">,</span>
<span class="operator">}</span><span class="operator">);</span>
<span class="comment"># Get the Entry-ID/Request-ID for all User's with Login starting with 'g'</span>
<span class="comment"># Here $eid is any array reference of entry-id/request-id values</span>
<span class="keyword">my</span> <span class="variable">$eid</span> <span class="operator">=</span> <span class="variable">$ar</span><span class="operator">-></span><span class="variable">get_list</span><span class="operator">(</span><span class="...
<span class="string">form</span> <span class="operator">=></span> <span class="string">'User'</span><span class="operator">,</span>
<span class="string">query</span> <span class="operator">=></span> <span class="string">qq{'Login' LIKE "g%"}</span><span class="operator">,</span>
<span class="operator">}</span><span class="operator">);</span>
<span class="keyword">print</span> <span class="variable">Data::Dumper</span><span class="operator">-></span><span class="variable">Dump</span><span class="operator">(</span><span class="operator">[</span><span class="variable">$eid</span><span c...
html/Simple.html view on Meta::CPAN
<dt id="server">server</dt>
<dd>
<p>The name (or possibly IP Address) of the Remedy ARSystem server you wish to connect to.</p>
</dd>
<dt id="user">user</dt>
<dd>
<p>The user you wish to connect as (this is often a user with administrator privilages). Note that while this is a required argument, it may be supplied via the configuration file to avoid lots of scripts with the user (and password) in them (less to...
</dd>
<dt id="password">password</dt>
<dd>
<p>The password to the user you wish to connect as. This may come from the configuration file if set.</p>
</dd>
</dl>
<p>There are a number of optional arguments, they are:</p>
<dl>
<dt id="max_returns">max_returns</dt>
<dd>
html/Simple.html view on Meta::CPAN
</dl>
<p>Sample invocation with ALL parameters:</p>
<pre><code> <span class="keyword">use</span> <span class="variable">ARS::Simple</span><span class="operator">;</span>
<span class="keyword">use</span> <span class="variable">File::Log</span><span class="operator">;</span>
<span class="keyword">my</span> <span class="variable">$log</span> <span class="operator">=</span> <span class="variable">File::Log</span><span class="operator">-></span><span class="variable">new</span><span class="operator">();</span>
<span class="keyword">my</span> <span class="variable">$ars</span> <span class="operator">=</span> <span class="variable">ARS::Simple</span><span class="operator">-></span><span class="variable">new</span><span class="operator">(</span><span clas...
<span class="string">server</span> <span class="operator">=></span> <span class="string">'my_server'</span><span class="operator">,</span>
<span class="string">user</span> <span class="operator">=></span> <span class="string">'some_admin'</span><span class="operator">,</span>
<span class="string">password</span> <span class="operator">=></span> <span class="string">'password_for_some_admin'</span><span class="operator">,</span>
<span class="string">log</span> <span class="operator">=></span> <span class="variable">$log</span><span class="operator">,</span>
<span class="string">max_returns</span> <span class="operator">=></span> <span class="number">0</span><span class="operator">,</span> <span class="comment"># allow unlimited returns</span>
<span class="string">reset_limit</span> <span class="operator">=></span> <span class="number">3000</span><span class="operator">,</span> <span class="comment"># reset to a suitable limit after each call using max_returns</span>
<span class="string">ars_debug</span> <span class="operator">=></span> <span class="number">1</span><span class="operator">,</span> <span class="comment"># get a whole lot of debugging information (you real should not need)</span>
<span class="operator">}</span><span class="operator">);</span>
</code></pre>
<h2 id="get_list">get_list</h2>
<p>Method to return an array reference of Entry-Id values for a form. Arguments are passed as an hash reference, with two required parameters, eg:</p>
lib/ARS/Simple.pm view on Meta::CPAN
my $x = substr($k, 0, length($s));
my $u = $s ^ $x;
$self->{persistant}{user} = $u;
}
else
{
croak "No user defined, quitting\n";
}
}
if ($args->{password})
{
$self->{persistant}{password} = $args->{password};
}
else
{
if (defined $config{password})
{
my $s = pack('H*', $config{password});
my $x = substr($k, 0, length($s));
my $u = $s ^ $x;
$self->{persistant}{password} = $u;
}
else
{
croak "No password defined, quitting\n";
}
}
$user = $self->{persistant}{user};
$pword = $self->{persistant}{password};
# Handle the other passed arguments
$self->{server} = $args->{server} if $args->{server};
$self->{log} = $args->{log} if $args->{log};
$self->{max_returns} = $args->{max_returns} if defined $args->{max_returns};
$self->{reset_limit} = $args->{reset_limit} if defined $args->{reset_limit};
if ($args->{ars_debug})
{
$ARS::DEBUGGING = 1;
lib/ARS/Simple.pm view on Meta::CPAN
## 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);
lib/ARS/Simple.pm view on Meta::CPAN
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:
lib/ARS/Simple.pm view on Meta::CPAN
=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
lib/ARS/Simple.pm view on Meta::CPAN
=item server
The name (or possibly IP Address) of the Remedy ARSystem server you
wish to connect to.
=item user
The user you wish to connect as (this is often a user with administrator
privilages). Note that while this is a required argument, it may be supplied
via the configuration file to avoid lots of scripts with the user (and password)
in them (less to change, not on display so safer).
=item password
The password to the user you wish to connect as. This may come from the configuration
file if set.
=back
There are a number of optional arguments, they are:
=over 4
=item max_returns
lib/ARS/Simple.pm view on Meta::CPAN
=back
Sample invocation with ALL parameters:
use ARS::Simple;
use File::Log;
my $log = File::Log->new();
my $ars = ARS::Simple->new({
server => 'my_server',
user => 'some_admin',
password => 'password_for_some_admin',
log => $log,
max_returns => 0, # allow unlimited returns
reset_limit => 3000, # reset to a suitable limit after each call using max_returns
ars_debug => 1, # get a whole lot of debugging information (you real should not need)
});
=head2 get_list
Method to return an array reference of Entry-Id values for a form.
Arguments are passed as an hash reference, with two required parameters, eg:
lib/ARS/Simple.pm view on Meta::CPAN
=head2 DESTROY
Log out from ARSystem
=head1 ARSperl Programer's Manual
see http://arsperl.sourceforge.net/manual/toc.html
=head1 Default User/Password
The default user and password to use can be configured during install
by the Config.PL script. This creates a configuration file Simple.cfg
which is stored with Simple.pm. Unless specified in the call to the
new method, the use and password from Simple.cfg will be used. This
has the advantage of a single place of change and removes the user and
password from scripts.
Note that the use and password are obfuscated and B<not> encrypted in
the Simple.cfg file.
=head1 TODO
Add in the tools below.
Add in further methods to make life easier and your code more readable
=head1 TOOLS
t/01-connect.t view on Meta::CPAN
}
}
plan( skip_all => "Automated testing") if ($ENV{PERL_MM_USE_DEFAULT} || $ENV{AUTOMATED_TESTING});
diag( "Testing against server: " . CCACHE::server());
my $ars = ARS::Simple->new({
server => CCACHE::server(),
user => CCACHE::user(),
password => CCACHE::password(),
});
ok(defined($ars), 'connected to Remedy ARSystem');
t/config.cache view on Meta::CPAN
package CCACHE;
# enter your remedy server, username and password below.
sub server { 'devserver' ; }
sub user { 'greg' ; }
sub password { 'password' ; }
1;