public final class APIConnection
extends java.lang.Object
Constructor and Description |
---|
APIConnection(java.lang.String host,
java.lang.String deploymentPath,
java.lang.String username,
java.lang.String password)
Creates a new connection to the given host
|
Modifier and Type | Method and Description |
---|---|
Category |
addCategory(long siteId,
java.lang.Long parentId,
java.lang.String name)
Enters a given category if possible
|
Site |
createSite(java.lang.String name,
int maxThreadsPerCategory,
int reduceMaxThreadsPerLevel)
Creates a new site with the specified number of threads per category
|
boolean |
deleteCategory(long siteId,
long categoryId,
boolean forceDeletion)
Deletes a category
|
boolean |
deleteSite(long siteId,
boolean forceDeletion)
Deletes a site
|
boolean |
deleteSite(java.lang.String name,
boolean forceDeletion)
Deletes a site
|
boolean |
deleteThread(long threadId)
Deletes a thread
|
Category |
enterCategory(long siteId,
java.lang.Long parentId,
java.lang.String name,
long threadId)
Enters a given category if possible
|
Category |
enterCategory(long siteId,
java.lang.Long parentId,
java.lang.String name,
long threadId,
boolean isBaseCategory)
Enters a given category if possible
|
Tuple |
enterSite(long siteId,
java.lang.String name,
java.lang.String location)
Enters a given site if possible.
|
void |
exitCategory(long siteId,
long threadId,
long categoryId,
int records,
RunState completionState,
java.lang.Long entryTime)
Exits a given category
|
void |
exitSite(long siteId,
long threadId)
Exits a given site
|
void |
exitSite(long siteId,
long threadId,
boolean wasError)
Exits a given site
|
void |
exitSite(long siteId,
long threadId,
boolean wasError,
java.lang.Long entryTime)
Exits a given site
|
Category |
getCategory(long id)
Returns the category with the specified id, or null if there is no such category
|
Category |
getCategory(long sitePk,
java.lang.Long parentId,
java.lang.String name)
Returns the category with the specified id, or null if there is no such category
|
Site |
getSite(long id)
Returns the site with the given id, or null if there is no site with the specified id
|
Site |
getSite(java.lang.String name)
Returns the site with the given name, or null if there is no site with the specified name
|
ExecutionThread |
getThread(long id)
Returns the thread with the given id, or null if there is no thread with the specified id
|
java.lang.Object |
issueRequest(java.lang.String type,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Issues a request to the api server
|
java.util.List<Category> |
listChildCategories(long categoryId)
Returns a list of all categories that are direct children (one level down) of the given category
|
java.util.List<Category> |
listRootCategories(long siteId)
Returns a list of all categories that are roots of the given site
|
java.util.List<Site> |
listSites()
Returns a list of all sites known
|
java.util.List<Category> |
listThreadCategories(long siteId,
long threadId)
Gets a list of categories the specified thread is currently in
|
java.util.List<ExecutionThread> |
listThreadsInCategory(long siteId,
long categoryId)
Gets a list of threads the specified category has running in it
|
java.util.List<ExecutionThread> |
listThreadsInSite(long siteId)
Gets a list of threads in the specified site
|
void |
resetCategory(long siteId,
long categoryId)
Resets a given category.
|
void |
resetCategory(long siteId,
long categoryId,
boolean fullReset)
Resets a given site.
|
void |
resetSite(long siteId)
Resets a given site.
|
void |
resetSite(long siteId,
boolean fullReset)
Resets a given site.
|
boolean |
setCategoryStatus(long siteId,
long categoryId,
RunState status)
Sets the status of the category without modifying the status of any parent of child
|
public APIConnection(java.lang.String host, java.lang.String deploymentPath, java.lang.String username, java.lang.String password)
host
- The host to connect to (including port if required)username
- The username used to authenticate to the serverpassword
- The password for authenticating to the serverjava.io.IOException
- If there was an error establishing the connectionAuthorizationException
- If the connection failed to authenticate@Nullable public java.lang.Object issueRequest(java.lang.String type, java.util.Map<java.lang.String,java.lang.Object> parameters)
type
- The type to issue (enterCategory, etc...)parameters
- The additional parameters to sendpublic Site getSite(long id)
id
- The id of the site to getpublic Site getSite(java.lang.String name)
name
- The name of the site to getpublic ExecutionThread getThread(long id)
id
- The id of the thread to getpublic Category getCategory(long id)
id
- The id of the categorypublic Category getCategory(long sitePk, java.lang.Long parentId, java.lang.String name)
sitePk
- The id of the site the category is part ofparentId
- The id of the parent category, or null if this is a top-level categoryname
- The name of the category@NotNull public java.util.List<Site> listSites()
@NotNull public java.util.List<Category> listRootCategories(long siteId)
siteId
- The id of the site to list roots for@NotNull public java.util.List<Category> listChildCategories(long categoryId)
categoryId
- The id of the category to list children forpublic Site createSite(java.lang.String name, int maxThreadsPerCategory, int reduceMaxThreadsPerLevel)
name
- The name of the sitemaxThreadsPerCategory
- The number of threads allowed in any given category (must be > 0)reduceMaxThreadsPerLevel
- The amount to reduce the maximum number of threads for each level down the tree we go (must be ≥ 0)public Tuple enterSite(long siteId, java.lang.String name, java.lang.String location)
siteId
- The id of the site to entername
- The name for the entering thread, or null for no namelocation
- The location of the thread, or null to let the server determine itpublic void exitSite(long siteId, long threadId)
siteId
- The id of the sitethreadId
- id of the thread exiting the sitepublic void exitSite(long siteId, long threadId, boolean wasError)
siteId
- The id of the sitethreadId
- id of the thread exiting the sitewasError
- True to indicate an error occurred, false if no errors occurredpublic void exitSite(long siteId, long threadId, boolean wasError, java.lang.Long entryTime)
siteId
- The id of the sitethreadId
- id of the thread exiting the sitewasError
- True to indicate an error occurred, false if no errors occurredentryTime
- The time the site was entered by the clientpublic boolean deleteSite(java.lang.String name, boolean forceDeletion)
name
- The name of the site to deleteforceDeletion
- True if deletion should be forced. Forced deletion means that the site will be deleted even if there are still active threads running
in the sitepublic boolean setCategoryStatus(long siteId, long categoryId, @NotNull RunState status)
siteId
- The id of the site the category is part ofcategoryId
- The id of the categorystatus
- The status to set the category topublic boolean deleteSite(long siteId, boolean forceDeletion)
siteId
- The id of the site to deleteforceDeletion
- True if deletion should be forced. Forced deletion means that the site will be deleted even if there are still active threads running
in the sitepublic boolean deleteThread(long threadId)
threadId
- The id of the thread to deletepublic boolean deleteCategory(long siteId, long categoryId, boolean forceDeletion)
siteId
- The id of the site the category is part ofcategoryId
- The id of the category to deleteforceDeletion
- True if deletion should be forced. Forced deletion means that the category will be deleted even if there are still active threads
running in the category@Nullable public Category enterCategory(long siteId, java.lang.Long parentId, java.lang.String name, long threadId)
siteId
- The id of the site the category is part ofparentId
- The id of the parent category, or null if this is a top level categoryname
- The name of the categorythreadId
- The id of the entering threadpublic Category enterCategory(long siteId, java.lang.Long parentId, java.lang.String name, long threadId, boolean isBaseCategory)
siteId
- The id of the site the category is part ofparentId
- The id of the parent category, or null if this is a top level categoryname
- The name of the categorythreadId
- The id of the entering threadisBaseCategory
- True if this category is known to be the lowest category in the tree, or rather that only a single thread should be allowed in this
category, regardless of other settings. This only affects the current thread. In other words, if one thread enters a category with this set, but another
attempts to enter without this set, the second thread can still be given access.public Category addCategory(long siteId, java.lang.Long parentId, java.lang.String name)
siteId
- The id of the site the category is part ofparentId
- The id of the parent category, or null if this is a top level categoryname
- The name of the categorypublic void exitCategory(long siteId, long threadId, long categoryId, int records, @NotNull RunState completionState, java.lang.Long entryTime)
siteId
- The id of the site the category is part ofthreadId
- The id of the exiting threadcategoryId
- The id of the category to exitrecords
- The number of records for this category. This only matters for leaf categories, as parents are computed from their childrencompletionState
- The state to return for completionentryTime
- The time the site was entered by the clientpublic void resetSite(long siteId)
siteId
- The id of the site to resetpublic void resetSite(long siteId, boolean fullReset)
siteId
- The id of the site to resetfullReset
- True if all values should be reset (including entry dates), false to only reset the main valuespublic void resetCategory(long siteId, long categoryId)
siteId
- The id of the site to resetcategoryId
- The id of the category to resetpublic void resetCategory(long siteId, long categoryId, boolean fullReset)
siteId
- The id of the site to resetcategoryId
- The id of the category to resetfullReset
- True if all values should be reset (including entry dates), false to only reset the main values@NotNull public java.util.List<Category> listThreadCategories(long siteId, long threadId)
siteId
- The id of the site the thread is running inthreadId
- The id of the thread@NotNull public java.util.List<ExecutionThread> listThreadsInCategory(long siteId, long categoryId)
siteId
- The id of the site the category is incategoryId
- The id of the category@NotNull public java.util.List<ExecutionThread> listThreadsInSite(long siteId)
siteId
- The id of the site the threads are running in