public class BoaClient extends Object implements AutoCloseable
To use this class, first construct an object by either using the default
constructor (to use the standard API domain/path) or providing the
domain/path to the API. Then call login(java.lang.String username, java.lang.String password)
with your Boa username and password to log into the remote API.
When finished with the object, close()
must be called to log out of
the remote API. The class is also AutoCloseable
for use in a
try-with-resources block.
Example usage:
try (final BoaClient client = new BoaClient()) { client.login("user", "pass"); // print all available input datasets for (final InputHandle d : client.getDatasets()) System.out.println(d); // print info about the last job submitted System.out.println("Last job submitted: " + client.getLastJob()); }
Constructor and Description |
---|
BoaClient()
Create a new Boa API client, using the standard domain/path.
|
BoaClient(String domain,
String path)
Create a new Boa API client by providing the domain/path to the API.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Logs out of the Boa API.
|
InputHandle |
getDataset(String name)
Given the name of an input dataset, returns a handle (if one exists, otherwise
null ). |
String[] |
getDatasetNames()
Returns an array of available input dataset names.
|
List<InputHandle> |
getDatasets()
Returns a list of available input datasets.
|
JobHandle |
getJob(int id)
Returns a specific job.
|
int |
getJobCount()
Returns the number of jobs for the user.
|
int |
getJobCount(boolean pub)
Returns the number of public (or all) jobs for the user.
|
List<JobHandle> |
getJobList()
Returns a list of the most recent jobs.
|
List<JobHandle> |
getJobList(boolean pub)
Returns a list of the most recent public (or all) jobs.
|
List<JobHandle> |
getJobList(boolean pub,
int offset,
int length)
Returns a list of the most recent public (or all) jobs, based on an offset and length.
|
List<JobHandle> |
getJobList(int offset,
int length)
Returns a list of the most recent jobs, based on an offset and length.
|
JobHandle |
getLastJob()
Returns the most recent job.
|
void |
login(String username,
String password)
Method to log into the remote API.
|
JobHandle |
query(String query)
Submits a new query to Boa to query the latest (testing) dataset and returns a handle to the new job.
|
JobHandle |
query(String query,
InputHandle dataset)
Submits a new query to Boa to query the specified and returns a handle to the new job.
|
void |
resetDatasetCache()
Resets the internal dataset cache.
|
public BoaClient()
public void login(String username, String password) throws LoginException
username
- the Boa username to use to log inpassword
- the password for the userLoginException
- if the login failed for any reasonpublic void close() throws BoaException
close
in interface AutoCloseable
BoaException
- if the logout fails for any reasonpublic void resetDatasetCache()
public List<InputHandle> getDatasets() throws BoaException, NotLoggedInException
resetDatasetCache()
).Map
where keys are dataset IDs and values are their namesBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic String[] getDatasetNames() throws BoaException, NotLoggedInException
resetDatasetCache()
).Map
where keys are dataset IDs and values are their namesBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic InputHandle getDataset(String name) throws BoaException, NotLoggedInException
null
).
Since datasets rarely change, the results may be up to 1 day old. The cache can be reset
(see resetDatasetCache()
).name
- the name of the input dataset to return a handle forInputHandle
for the specified dataset nameBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic JobHandle getJob(int id) throws BoaException, NotLoggedInException
id
- the jobs idJobHandle
for the jobBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic JobHandle getLastJob() throws BoaException, NotLoggedInException
JobHandle
for the latest job, or null
if no jobs existBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic List<JobHandle> getJobList() throws BoaException, NotLoggedInException
JobHandle
s for the most recent jobsBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic List<JobHandle> getJobList(int offset, int length) throws BoaException, NotLoggedInException
offset
- the starting offsetlength
- the number of jobs (at most) to returnJobHandle
s for the jobs starting at the offset and containing at most length jobsBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic List<JobHandle> getJobList(boolean pub) throws BoaException, NotLoggedInException
pub
- if true, only return public jobs otherwise return all jobsJobHandle
s for the most recent jobsBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic List<JobHandle> getJobList(boolean pub, int offset, int length) throws BoaException, NotLoggedInException
pub
- if true, only return public jobs otherwise return all jobsoffset
- the starting offsetlength
- the number of jobs (at most) to returnJobHandle
s for the jobs starting at the offset and containing at most length jobsBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic int getJobCount() throws BoaException, NotLoggedInException
BoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic int getJobCount(boolean pub) throws BoaException, NotLoggedInException
pub
- if true, return count of only public jobs otherwise return count of all jobsBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic JobHandle query(String query, InputHandle dataset) throws BoaException, NotLoggedInException
query
- the query source codedataset
- the input dataset to queryJobHandle
for the new jobBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the APIpublic JobHandle query(String query) throws BoaException, NotLoggedInException
query
- the query source codeJobHandle
for the new jobBoaException
- if there was a problem reading from the serverNotLoggedInException
- if not already logged in to the API