NAME
    Labkey::Query

SYNOPSIS
            use Labkey::Query;
            my $results = Labkey::Query::selectRows(
                    -baseUrl => 'http://labkey.com:8080/labkey/',
                    -containerPath => 'myFolder/',
                    -schemaName => 'lists',
                    -queryName => 'mid_tags',
            );

ABSTRACT
    For interacting with data in LabKey Server

DESCRIPTION
    This module is designed to simplify querying and manipulating data in
    LabKey Server. It should more or less replicate the javascript APIs of
    the same names.

    After the module is installed, if you need to login with a specific user
    you will need to create a .netrc file in the home directory of the user
    running the perl script. Documentation on .netrc can be found here:
    https://www.labkey.org/wiki/home/Documentation/page.view?name=netrc

    In API versions 0.08 and later, you can specify the param
    '-loginAsGuest' which will query the server without any credentials. The
    server must permit guest to that folder for this to work though.

SEE ALSO
    The LabKey client APIs are described in greater detail here:
    https://www.labkey.org/wiki/home/Documentation/page.view?name=viewAPIs

    Support questions should be directed to the LabKey forum:
    https://www.labkey.org/announcements/home/Server/Forum/list.view?

AUTHOR
    Ben Bimber

COPYRIGHT
    Copyright (c) 2010 Ben Bimber

    Licensed under the Apache License, Version 2.0:
    http://www.apache.org/licenses/LICENSE-2.0

selectRows()
    selectRows() can be used to query data from LabKey server

    The following are the minimum required params:

            my $results = Labkey::Query::selectRows(
                    -baseUrl => 'http://labkey.com:8080/labkey/',
                    -containerPath => 'myFolder/',
                    -schemaName => 'lists',
                    -queryName => 'mid_tags',
            );

    The following are optional:

            -viewName => 'view1',
            -filterArray => [
                    ['file_active', 'eq', 1], 
                    ['species', 'neq', 'zebra']
            ], #allows filters to be applied to the query similar to the labkey Javascript API.
            -parameters => [
                    ['enddate', '2011/01/01'], 
                    ['totalDays', 15]
            ], #allows parameters to be applied to the query similar to the labkey Javascript API.  
            -maxRows => 10  #the max number of rows returned
            -sort => 'ColumnA,ColumnB'      #sort order used for this query
            -offset => 100  #the offset used when running the query
            -columns => 'ColumnA,ColumnB'  #A comma-delimited list of column names to include in the results.
            -containerFilterName => 'currentAndSubfolders'
            -debug => 1,    #will result in a more verbose output
            -loginAsGuest => #will not attempt to lookup credentials in netrc
            -netrcFile => optional. the location of a file to use in place of a .netrc file.  see also the environment variable LABKEY_NETRC.
            -requiredVersion => 9.1 #if 8.3 is selected, it will use Labkey's pre-9.1 format for returning the data.  9.1 is the default.  See documentation of LABKEY.Query.ExtendedSelectRowsResults for more detail here:
                    https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.Query.html
            -useragent => an instance of LWP::UserAgent (if not provided, a new instance will be created)
            -timeout => timeout in seconds (used when creating a new LWP::UserAgent)

    NOTE:

    - In version 1.0 and later of the perl API, the default result format is
    9.1. This is different from the LabKey JS, which defaults to the earlier
    format for legacy purposes. - The environment variable 'LABKEY_URL' can
    be used instead of supplying a '-baseUrl' param - The environment
    variable 'LABKEY_NETRC' can be used to specify an alternate location of
    a netrc file, if not in the user's home directory.

insertRows()
    insertRows() can be used to insert records into a LabKey table

    The following are the minimum required params:

            my $insert = Labkey::Query::insertRows(
                    -baseUrl => 'http://labkey.com:8080/labkey/',
                    -containerPath => 'myFolder/',
                    -schemaName => 'lists',
                    -queryName => 'backup',
                    -rows => [{
                            "JobName" => 'jobName', 
                            "Status" => $status, 
                            "Log" => $log, 
                            "Date" => $date
                    }],
            );

    The following are optional:

            -debug => 1,  #will result in a more verbose output 
            -loginAsGuest => #will not attempt to lookup credentials in netrc
            -netrcFile => optional. the location of a file to use in place of a .netrc file.  see also the environment variable LABKEY_NETRC.
            -useragent => an instance of LWP::UserAgent (if not provided, a new instance will be created)
            -timeout => timeout in seconds (used when creating a new LWP::UserAgent)

    NOTE: - The environment variable 'LABKEY_URL' can be used instead of
    supplying a '-baseUrl' param - The environment variable 'LABKEY_NETRC'
    can be used to specify an alternate location of a netrc file, if not in
    the user's home directory

updateRows()
    updateRows() can be used to update records in a LabKey table

    The following are the minimum required params:

            my $update = Labkey::Query::updateRows(
                    -baseUrl => 'http://labkey.com:8080/labkey/',
                    -containerPath => 'myFolder/',
                    -schemaName => 'lists',
                    -queryName => 'backup',
                    -rows => [{
                            "JobName" => 'jobName', 
                            "Status" => $status, 
                            "Log" => $log, 
                            "Date" => $date
                    }],
            );

    The following are optional:

            -debug => 1,  #will result in a more verbose output
            -loginAsGuest => #will not attempt to lookup credentials in netrc
            -netrcFile => optional. the location of a file to use in place of a .netrc file.  see also the environment variable LABKEY_NETRC.
            -useragent => an instance of LWP::UserAgent (if not provided, a new instance will be created)
            -timeout => timeout in seconds (used when creating a new LWP::UserAgent)

    NOTE: - The environment variable 'LABKEY_URL' can be used instead of
    supplying a '-baseUrl' param - The environment variable 'LABKEY_NETRC'
    can be used to specify an alternate location of a netrc file, if not in
    the user's home directory

deleteRows()
    deleteRows() can be used to delete records in a LabKey table

    The following are the minimum required params:

            my $update = Labkey::Query::deleteRows(
                    -baseUrl => 'http://labkey.com:8080/labkey/',
                    -containerPath => 'myFolder/',
                    -schemaName => 'lists',
                    -queryName => 'backup',
                    -rows => [{
                            "Key" => '12', 
                    }],
            );

    The following are optional:

            -debug => 1,  #will result in a more verbose output
            -loginAsGuest => #will not attempt to lookup credentials in netrc
            -netrcFile => optional. the location of a file to use in place of a .netrc file.  see also the environment variable LABKEY_NETRC.
            -useragent => an instance of LWP::UserAgent (if not provided, a new instance will be created)
            -timeout => timeout in seconds (used when creating a new LWP::UserAgent)

    NOTE: - The environment variable 'LABKEY_URL' can be used instead of
    supplying a '-baseUrl' param - The environment variable 'LABKEY_NETRC'
    can be used to specify an alternate location of a netrc file, if not in
    the user's home directory

executeSql()
    executeSql() can be used to execute arbitrary SQL

    The following are the minimum required params:

            my $result = Labkey::Query::executeSql(
                    -baseUrl => 'http://labkey.com:8080/labkey/',
                    -containerPath => 'myFolder/',
                    -schemaName => 'study',
                    -sql => 'select MyDataset.foo, MyDataset.bar from MyDataset',
            );

    The following are optional:

            -maxRows => 10  #the max number of rows returned
            -sort => 'ColumnA,ColumnB'      #sort order used for this query
            -offset => 100  #the offset used when running the query
            -containerFilterName => 'currentAndSubfolders'
            -debug => 1,  #will result in a more verbose output
            -loginAsGuest => #will not attempt to lookup credentials in netrc
            -netrcFile => optional. the location of a file to use in place of a .netrc file.  see also the environment variable LABKEY_NETRC.
            -useragent => an instance of LWP::UserAgent (if not provided, a new instance will be created)
            -timeout => timeout in seconds (used when creating a new LWP::UserAgent)

    NOTE: - The environment variable 'LABKEY_URL' can be used instead of
    supplying a '-baseUrl' param - The environment variable 'LABKEY_NETRC'
    can be used to specify an alternate location of a netrc file, if not in
    the user's home directory

