Package io.littlehorse.sdk.client
Class LHClient
- java.lang.Object
-
- io.littlehorse.sdk.client.LHClient
-
public class LHClient extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description LHClient(LHClientConfig config)Creates a client given a client configLHClient(java.util.Properties props)Creates a client given a properties object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteExternalEventDef(java.lang.String name)Delete san external event definition given its namevoiddeleteTaskDef(java.lang.String name)Deletes a task definition given its namevoiddeleteUserTaskDef(java.lang.String userTaskDefName)Deletes a user task definition given a namevoiddeleteWfRun(java.lang.String wfRunId)Deletes a workflow run given its idvoiddeleteWfSpec(java.lang.String name, int version)Deletes a workflow specification given its name and versionio.littlehorse.sdk.common.proto.ExternalEventPbgetExternalEvent(java.lang.String wfRunId, java.lang.String externalEventName, java.lang.String guid)Returns an emitted external event for a specific workflow runio.littlehorse.sdk.common.proto.ExternalEventDefPbgetExternalEventDef(java.lang.String name)Gets a external eventio.littlehorse.sdk.common.proto.LHPublicApiGrpc.LHPublicApiBlockingStubgetGrpcClient()Returns the underline RPC clientio.littlehorse.sdk.common.proto.NodeRunPbgetNodeRun(java.lang.String wfRunId, int threadRunNumber, int position)Returns a NodeRun given a workflow, thread run number and position in the ThreadRunio.littlehorse.sdk.common.proto.TaskDefPbgetTaskDef(java.lang.String name)Gets a task definition given the nameio.littlehorse.sdk.common.proto.TaskRunPbgetTaskRun(io.littlehorse.sdk.common.proto.TaskRunIdPb id)Returns a TaskRun given an idio.littlehorse.sdk.common.proto.UserTaskRunPbgetUserTaskRun(io.littlehorse.sdk.common.proto.UserTaskRunIdPb id)Returns a UserTaskRun given an idio.littlehorse.sdk.common.proto.VariablePbgetVariable(java.lang.String wfRunId, int threadRunNumber, java.lang.String name)Returns a passed variable to a threadio.littlehorse.sdk.common.proto.WfRunPbgetWfRun(java.lang.String id)Gets a workflow run given an idio.littlehorse.sdk.common.proto.WfSpecPbgetWfSpec(java.lang.String name)Gets the workflow specification for a given workflow nameio.littlehorse.sdk.common.proto.WfSpecPbgetWfSpec(java.lang.String name, java.lang.Integer version)Gets the workflow specification for a given workflow name and versionio.littlehorse.sdk.common.proto.ExternalEventPbputExternalEvent(io.littlehorse.sdk.common.proto.PutExternalEventPb req)Emits an external event to the serverio.littlehorse.sdk.common.proto.ExternalEventDefPbputExternalEventDef(io.littlehorse.sdk.common.proto.PutExternalEventDefPb req)Creates a new external event definition.io.littlehorse.sdk.common.proto.ExternalEventDefPbputExternalEventDef(io.littlehorse.sdk.common.proto.PutExternalEventDefPb req, boolean swallowAlreadyExists)Creates a new external event definitionio.littlehorse.sdk.common.proto.TaskDefPbputTaskDef(io.littlehorse.sdk.common.proto.PutTaskDefPb req)Creates a task definition.io.littlehorse.sdk.common.proto.TaskDefPbputTaskDef(io.littlehorse.sdk.common.proto.PutTaskDefPb req, boolean swallowAlreadyExists)Creates a task definitionio.littlehorse.sdk.common.proto.UserTaskDefPbputUserTaskDef(io.littlehorse.sdk.common.proto.PutUserTaskDefPb req)Creates a user task definition.io.littlehorse.sdk.common.proto.UserTaskDefPbputUserTaskDef(io.littlehorse.sdk.common.proto.PutUserTaskDefPb req, boolean swallowAlreadyExists)Creates a user task definitionio.littlehorse.sdk.common.proto.WfSpecPbputWfSpec(io.littlehorse.sdk.common.proto.PutWfSpecPb req)Creates a new workflow specification.voidresumeWfRun(java.lang.String wfRunId, int threadRunNumber)Resume a thread execution.java.lang.StringrunWf(java.lang.String wfSpecName, java.lang.Integer wfSpecVersion, java.lang.String wfRunId, io.littlehorse.sdk.common.util.Arg... args)Makes a request to the server to execute a workflow specification.java.util.List<io.littlehorse.sdk.common.proto.WfRunIdPb>searchWfRun(java.lang.String workflowName, int version, io.littlehorse.sdk.common.proto.LHStatusPb status, java.util.Date earliestStart, java.util.Date latestStart)Returns a list of ids which match the input parametersvoidstopWfRun(java.lang.String wfRunId, int threadRunNumber)Halts a thread for a given workflow run.
-
-
-
Constructor Detail
-
LHClient
public LHClient(java.util.Properties props)
Creates a client given a properties object- Parameters:
props- settings
-
LHClient
public LHClient(LHClientConfig config)
Creates a client given a client config- Parameters:
config- existing client config
-
-
Method Detail
-
getGrpcClient
public io.littlehorse.sdk.common.proto.LHPublicApiGrpc.LHPublicApiBlockingStub getGrpcClient() throws io.littlehorse.sdk.common.exception.LHApiErrorReturns the underline RPC client- Returns:
- A blocking stub
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If it could not connect to the API
-
getExternalEventDef
public io.littlehorse.sdk.common.proto.ExternalEventDefPb getExternalEventDef(java.lang.String name) throws io.littlehorse.sdk.common.exception.LHApiErrorGets a external event- Parameters:
name- External event name- Returns:
- A external event definition, or null if it does not exist
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If it could not connect to the API
-
getTaskDef
public io.littlehorse.sdk.common.proto.TaskDefPb getTaskDef(java.lang.String name) throws io.littlehorse.sdk.common.exception.LHApiErrorGets a task definition given the name- Parameters:
name- Name of the task- Returns:
- A task definition, or null if it does not exist
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if it failed contacting to the API
-
getWfSpec
public io.littlehorse.sdk.common.proto.WfSpecPb getWfSpec(java.lang.String name) throws io.littlehorse.sdk.common.exception.LHApiErrorGets the workflow specification for a given workflow name- Parameters:
name- Workflow name- Returns:
- A workflow specification with the workflow's data and status, or null if the spec does not exist
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if it failed contacting to the API
-
getWfSpec
public io.littlehorse.sdk.common.proto.WfSpecPb getWfSpec(java.lang.String name, java.lang.Integer version) throws io.littlehorse.sdk.common.exception.LHApiErrorGets the workflow specification for a given workflow name and version- Parameters:
name- Workflow nameversion- Version of the registered workflow- Returns:
- A workflow specification with the workflow's data and status, or null if the spec does not exist
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if it failed contacting to the API
-
getTaskRun
public io.littlehorse.sdk.common.proto.TaskRunPb getTaskRun(io.littlehorse.sdk.common.proto.TaskRunIdPb id) throws io.littlehorse.sdk.common.exception.LHApiErrorReturns a TaskRun given an id- Parameters:
id- of the UserTaskRun- Returns:
- The TaskRun if it exists, or null if it does not exist.
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if it failed contacting to the API
-
getUserTaskRun
public io.littlehorse.sdk.common.proto.UserTaskRunPb getUserTaskRun(io.littlehorse.sdk.common.proto.UserTaskRunIdPb id) throws io.littlehorse.sdk.common.exception.LHApiErrorReturns a UserTaskRun given an id- Parameters:
id- of the UserTaskRun- Returns:
- The UserTaskRun if exists, else null.
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if it failed contacting to the API
-
getNodeRun
public io.littlehorse.sdk.common.proto.NodeRunPb getNodeRun(java.lang.String wfRunId, int threadRunNumber, int position) throws io.littlehorse.sdk.common.exception.LHApiErrorReturns a NodeRun given a workflow, thread run number and position in the ThreadRun- Parameters:
wfRunId- workflow run identificationthreadRunNumber- number of the relevant threadposition- in the thread- Returns:
- null if the NodeRun does not exist, or the NodeRun's data otherwise
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if it failed contacting to the API
-
getVariable
public io.littlehorse.sdk.common.proto.VariablePb getVariable(java.lang.String wfRunId, int threadRunNumber, java.lang.String name) throws io.littlehorse.sdk.common.exception.LHApiErrorReturns a passed variable to a thread- Parameters:
wfRunId- workflow run identificationthreadRunNumber- number of the subsequent threadname- of the variable- Returns:
- The variable's data if it does exist, or null otherwise
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if it failed contacting to the API
-
getExternalEvent
public io.littlehorse.sdk.common.proto.ExternalEventPb getExternalEvent(java.lang.String wfRunId, java.lang.String externalEventName, java.lang.String guid) throws io.littlehorse.sdk.common.exception.LHApiErrorReturns an emitted external event for a specific workflow run- Parameters:
wfRunId- workflow run identificationexternalEventName- name of the external eventguid- external event's global unique identifier- Returns:
- The external event's data if it does exist, or null otherwise
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if it failed contacting to the API
-
getWfRun
public io.littlehorse.sdk.common.proto.WfRunPb getWfRun(java.lang.String id) throws io.littlehorse.sdk.common.exception.LHApiErrorGets a workflow run given an id- Parameters:
id- of the workflow run- Returns:
- A workflow run if it does exist, null otherwise
- Throws:
io.littlehorse.sdk.common.exception.LHApiError
-
searchWfRun
public java.util.List<io.littlehorse.sdk.common.proto.WfRunIdPb> searchWfRun(java.lang.String workflowName, int version, io.littlehorse.sdk.common.proto.LHStatusPb status, java.util.Date earliestStart, java.util.Date latestStart) throws io.littlehorse.sdk.common.exception.LHApiErrorReturns a list of ids which match the input parameters- Parameters:
workflowName- Name to search forversion- Version to search forstatus- Status of WfRuns to search for (STARTING, RUNNING, COMPLETED, HALTING, HALTED, ERROR)earliestStart- Only shows WfRuns more recent than this configurationlatestStart- Only shows WfRuns less recent than this configuration- Returns:
- A list of workflow ids
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
runWf
public java.lang.String runWf(java.lang.String wfSpecName, java.lang.Integer wfSpecVersion, java.lang.String wfRunId, io.littlehorse.sdk.common.util.Arg... args) throws io.littlehorse.sdk.common.exception.LHApiErrorMakes a request to the server to execute a workflow specification. The execution of the WfRun is asynchronous; the RunWf request only blocks until the first step of the WfRun is *scheduled*.- Parameters:
wfSpecName- workflow namewfSpecVersion- workflow version. This is optional, pass null for the server to decidewfRunId- workflow run id. This is optional, pass null for the server to decideargs- list of variables. This is optional- Returns:
- The workflow run identification
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
putExternalEvent
public io.littlehorse.sdk.common.proto.ExternalEventPb putExternalEvent(io.littlehorse.sdk.common.proto.PutExternalEventPb req) throws io.littlehorse.sdk.common.exception.LHApiErrorEmits an external event to the server- Parameters:
req- put external event request- Returns:
- An external event when successful
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
putExternalEventDef
public io.littlehorse.sdk.common.proto.ExternalEventDefPb putExternalEventDef(io.littlehorse.sdk.common.proto.PutExternalEventDefPb req) throws io.littlehorse.sdk.common.exception.LHApiErrorCreates a new external event definition. It throws and error if already exists- Parameters:
req- put external event definition request- Returns:
- The definition's data when successful
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
putExternalEventDef
public io.littlehorse.sdk.common.proto.ExternalEventDefPb putExternalEventDef(io.littlehorse.sdk.common.proto.PutExternalEventDefPb req, boolean swallowAlreadyExists) throws io.littlehorse.sdk.common.exception.LHApiErrorCreates a new external event definition- Parameters:
req- put external event definition requestswallowAlreadyExists- this flag defines if whether or not to throw an error if it already exist- Returns:
- The definition's data when successful
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
putTaskDef
public io.littlehorse.sdk.common.proto.TaskDefPb putTaskDef(io.littlehorse.sdk.common.proto.PutTaskDefPb req) throws io.littlehorse.sdk.common.exception.LHApiErrorCreates a task definition. It throws and error if already exists- Parameters:
req- request- Returns:
- Task definition's data
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
putTaskDef
public io.littlehorse.sdk.common.proto.TaskDefPb putTaskDef(io.littlehorse.sdk.common.proto.PutTaskDefPb req, boolean swallowAlreadyExists) throws io.littlehorse.sdk.common.exception.LHApiErrorCreates a task definition- Parameters:
req- requestswallowAlreadyExists- this flag defines if whether or not to throw an error if it already exist- Returns:
- Task definition's data
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
putUserTaskDef
public io.littlehorse.sdk.common.proto.UserTaskDefPb putUserTaskDef(io.littlehorse.sdk.common.proto.PutUserTaskDefPb req) throws io.littlehorse.sdk.common.exception.LHApiErrorCreates a user task definition. It throws and error if already exists- Parameters:
req- request- Returns:
- User task definition
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
putUserTaskDef
public io.littlehorse.sdk.common.proto.UserTaskDefPb putUserTaskDef(io.littlehorse.sdk.common.proto.PutUserTaskDefPb req, boolean swallowAlreadyExists) throws io.littlehorse.sdk.common.exception.LHApiErrorCreates a user task definition- Parameters:
req- requestswallowAlreadyExists- this flag defines if whether or not to throw an error if it already exist- Returns:
- User task definition
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
putWfSpec
public io.littlehorse.sdk.common.proto.WfSpecPb putWfSpec(io.littlehorse.sdk.common.proto.PutWfSpecPb req) throws io.littlehorse.sdk.common.exception.LHApiErrorCreates a new workflow specification. Increments the version of the workflow if already exists.- Parameters:
req- request- Returns:
- WfSpec's data
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
stopWfRun
public void stopWfRun(java.lang.String wfRunId, int threadRunNumber) throws io.littlehorse.sdk.common.exception.LHApiErrorHalts a thread for a given workflow run. Move the tread to RUNNING to HALTED- Parameters:
wfRunId- workflow run identificationthreadRunNumber- number of the subsequent thread- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
resumeWfRun
public void resumeWfRun(java.lang.String wfRunId, int threadRunNumber) throws io.littlehorse.sdk.common.exception.LHApiErrorResume a thread execution. Move the thread form HALTED to RUNNING- Parameters:
wfRunId- workflow run identificationthreadRunNumber- number of the subsequent thread- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
deleteUserTaskDef
public void deleteUserTaskDef(java.lang.String userTaskDefName) throws io.littlehorse.sdk.common.exception.LHApiErrorDeletes a user task definition given a name- Parameters:
userTaskDefName- name of the task to be deleted- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
deleteWfRun
public void deleteWfRun(java.lang.String wfRunId) throws io.littlehorse.sdk.common.exception.LHApiErrorDeletes a workflow run given its id- Parameters:
wfRunId- id of the workflow run to be deleted- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
deleteTaskDef
public void deleteTaskDef(java.lang.String name) throws io.littlehorse.sdk.common.exception.LHApiErrorDeletes a task definition given its name- Parameters:
name- of the task definition to be deleted- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
deleteExternalEventDef
public void deleteExternalEventDef(java.lang.String name) throws io.littlehorse.sdk.common.exception.LHApiErrorDelete san external event definition given its name- Parameters:
name- of the external event definition to be deleted- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
deleteWfSpec
public void deleteWfSpec(java.lang.String name, int version) throws io.littlehorse.sdk.common.exception.LHApiErrorDeletes a workflow specification given its name and version- Parameters:
name- of the specificationversion- of the specification- Throws:
io.littlehorse.sdk.common.exception.LHApiError- If there is an error when connecting to the server
-
-