- NAME
- VERSION
- SYNOPSIS
- METHODS
  - new
  - get_list
  - get_SQL
  - get_data_by_label
  - get_fields
  - set_max_entries
- PRIVATE METHODS
  - _init
  - _load_qualifier
  - DESTROY
  - _check_initialised
  - _reset_max_entries
- TODO
- TOOLS
- AUTHOR
- BUGS
- SUPPORT
- ACKNOWLEDGEMENTS
- LICENSE AND COPYRIGHT

# NAME

ARS::Simple - The great new ARS::Simple!

# VERSION

Version 0.01

# SYNOPSIS

A simple interface to Remedy ARSystem utilising the ARSperl API interface:

     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 $eid = $ar->get_list({
         form  => 'User',
         query => qq{'Login' LIKE "g%"},
         });
     print Data::Dumper->Dump([$eid], ['eid']), "\n";

     # Get data from a form, based on a query (as you would use in the User Tool)
     my %lfid = ();
     my $form  = 'User';
     my $query = qq('FID' = "value");
     my $data = $ar->get_data_by_label({
     form  => $form,
     query => $query,
     lfid  => { label1, fid1, label2, fid2, ...},
     });

# METHODS

## new

Constructor for ARS::Simple. There are three required arguments:

server

  The name (or possibly IP Address) of the Remedy ARSystem server you wish to connect to.

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).

password

  The password to the user you wish to connect as. This may come from the configuration file if set.

There are a number of optional arguments, they are:

max_returns

  Set a limit on how many items may be returned from certain calls. Setting this value to 0 sets unlimited returns. This parameter can also be set on individual calls. Note: This is a system wide configuration change and requires administrator privilages on user.

  Note: You should not use a value less than the default system value for this field or you may impact normal operation of your system

  Example usage:

       reset_limit => 0, # unlimited returns

reset_limit

  Once max_returns is used, reset_limit, if set will return the server to nominated max_returns limit (eg 3000), thereby limiting the possible impact on the system of having max_returns set to a high value (eg 0).

  Example usage:

       reset_limit => 3000, # max returns back to a suitable maximum of 3000

ars_debug

  Turn on, if true (1), the ARSperl debugging output. Not something you would normally use.

log

  Pass a object to use to log erros/information to a log file. The log object is expected to have methods exp and msg as per the File::Log object.

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)
         });

## 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:

     # Get theEntry-Id's for all records in the 'User' form.
     my $eids = $ars->get_list({ form => 'User', query => '1 = 1' });

The query parameter can be the same format as you would use in the 'User Tool' to query a form, however we recommend the use of field ID's (FID) rather than the default field name as they may change. I prefer to define a hash of the forms lables and FID's so that can be used to better document your code, eg

     my %user = ( UserID => 101, UserName => 102 );

the a query could be something like

     my $query = qq{ '$user{UserID}' LIKE "g%" };
     my $eids = $ars->get_list({ form => 'User', query => $query });

## get_SQL

Run direct SQL on your server, there is only one required argument, the sql, you may optionally set the max_returns value.

The names of the fields can be found from the Admin Tool, under the database tab for a form. This will be the name of the field used in the database view of the Remedy form. Note you do need to replace spaces with and underscore '_' character.

Example method call:

     my $data = $ars->get_SQL({
         sql => q{select Login_name, Full_Name from User_X where Login_name like 'g%' order by Login_name},
         max_returns => 0,
         });

The return is a hash reference with two keys, numMatches and rows, example:

     $data = {
         numMatches = > 2,
         rows => [
            'greg', 'Greg George',
            'geoff', 'Geoffery Wallace',
         ]
     };

## get_data_by_label

Query a form and get the data back as a hash reference where the keys are the Entry-Id's for the records matched by the query and the value is a hash reference to the fields you requested where the keys are the field names you used and the value are the values.

     my $form  = 'form';
     my $query = qq('FID' = "value");
     my $data = $ar->get_data_by_label({
         form  => $form,
         query => $query,
         lfid  => { label1, fid1, label2, fid2, ...},
         });

     $data = {
         eID1, {Label1 => value1, Label2 => value2, ...},
         eID2, {Label1 => value1, Label2 => value2, ...},
         ...
         };

## get_fields

get_fields has a required argument, the form you require the field details for. The returned hash reference is the result of a call to ars_GetFieldTable, the keys are the field names and the values are the field ids (fid).

## set_max_entries

This requires that the 'user' has administrator access. This allows the overriding of the system wide maximum rows returned setting AR_SERVER_INFO_MAX_ENTRIES, setting this to zero (0) will allow unlimited returns.

Beware of setting this to a small value, it is system wide and could have a major impact on your system

# PRIVATE METHODS

## _init

Initialisation for new

## _load_qualifier

## DESTROY

Log out from ARSystem

## _check_initialised

Check to insure that there is a connection to Remedy ARSystem. Returns true if connected.

## _reset_max_entries

If set, returns the the system wide AR_SERVER_INFO_MAX_ENTRIES back to a suitable value (eg 3000). This required the 'user' has administrator access

# TODO

Add in the tools below.

Add in further methods to make life easier and your code more readable

# TOOLS

NOT DONE YET

The lfid array used by the get_data_by_label() method required that a hash is defined which describes the field lables (names) you want to use mapped to the field ID (FID). The encluded script will construct such a hash for all relavent fields. You might like to edit this down to only those fields you really need thereby reducing the amount of data returned.

There is a win32 version of this which copies the data to your clipboard, to make your life easier.

# AUTHOR

Greg George, `<gng at cpan.org>`

# BUGS

Please report any bugs or feature requests to `bug-ars-simple at rt.cpan.org`, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ARS-Simple. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

# SUPPORT

You can find documentation for this module with the perldoc command.

        perldoc ARS::Simple

You can also look for information at:

- RT: CPAN's request tracker (report bugs here)

  http://rt.cpan.org/NoAuth/Bugs.html?Dist=ARS-Simple

- AnnoCPAN: Annotated CPAN documentation

  http://annocpan.org/dist/ARS-Simple

- CPAN Ratings

  http://cpanratings.perl.org/d/ARS-Simple

- Search CPAN

  http://search.cpan.org/dist/ARS-Simple/

# ACKNOWLEDGEMENTS

This module relies on the ARSperl module and the fantastic effort by Jeff.C.Murphy and J.W.Murphy to write keep ARSperl current over so many years.

     See http://arsperl.sourceforge.net/ for more details.
     and https://metacpan.org/release/ARSperl

Remedy Corporation (long since gone) for making the ARSystem C API available thereby allowing ARSperl and this module possible

# LICENSE AND COPYRIGHT

Copyright 2013 Greg George.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.