Class LHClient


  • public class LHClient
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      LHClient​(LHClientConfig config)
      Creates a client given a client config
      LHClient​(java.util.Properties props)
      Creates a client given a properties object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deleteExternalEventDef​(java.lang.String name)
      Delete san external event definition given its name
      void deleteTaskDef​(java.lang.String name)
      Deletes a task definition given its name
      void deleteUserTaskDef​(java.lang.String userTaskDefName)
      Deletes a user task definition given a name
      void deleteWfRun​(java.lang.String wfRunId)
      Deletes a workflow run given its id
      void deleteWfSpec​(java.lang.String name, int version)
      Deletes a workflow specification given its name and version
      io.littlehorse.sdk.common.proto.ExternalEventPb getExternalEvent​(java.lang.String wfRunId, java.lang.String externalEventName, java.lang.String guid)
      Returns an emitted external event for a specific workflow run
      io.littlehorse.sdk.common.proto.ExternalEventDefPb getExternalEventDef​(java.lang.String name)
      Gets a external event
      io.littlehorse.sdk.common.proto.LHPublicApiGrpc.LHPublicApiBlockingStub getGrpcClient()
      Returns the underline RPC client
      io.littlehorse.sdk.common.proto.NodeRunPb getNodeRun​(java.lang.String wfRunId, int threadRunNumber, int position)
      Returns a NodeRun given a workflow, thread run number and position in the ThreadRun
      io.littlehorse.sdk.common.proto.TaskDefPb getTaskDef​(java.lang.String name)
      Gets a task definition given the name
      io.littlehorse.sdk.common.proto.TaskRunPb getTaskRun​(io.littlehorse.sdk.common.proto.TaskRunIdPb id)
      Returns a TaskRun given an id
      io.littlehorse.sdk.common.proto.UserTaskRunPb getUserTaskRun​(io.littlehorse.sdk.common.proto.UserTaskRunIdPb id)
      Returns a UserTaskRun given an id
      io.littlehorse.sdk.common.proto.VariablePb getVariable​(java.lang.String wfRunId, int threadRunNumber, java.lang.String name)
      Returns a passed variable to a thread
      io.littlehorse.sdk.common.proto.WfRunPb getWfRun​(java.lang.String id)
      Gets a workflow run given an id
      io.littlehorse.sdk.common.proto.WfSpecPb getWfSpec​(java.lang.String name)
      Gets the workflow specification for a given workflow name
      io.littlehorse.sdk.common.proto.WfSpecPb getWfSpec​(java.lang.String name, java.lang.Integer version)
      Gets the workflow specification for a given workflow name and version
      io.littlehorse.sdk.common.proto.ExternalEventPb putExternalEvent​(io.littlehorse.sdk.common.proto.PutExternalEventPb req)
      Emits an external event to the server
      io.littlehorse.sdk.common.proto.ExternalEventDefPb putExternalEventDef​(io.littlehorse.sdk.common.proto.PutExternalEventDefPb req)
      Creates a new external event definition.
      io.littlehorse.sdk.common.proto.ExternalEventDefPb putExternalEventDef​(io.littlehorse.sdk.common.proto.PutExternalEventDefPb req, boolean swallowAlreadyExists)
      Creates a new external event definition
      io.littlehorse.sdk.common.proto.TaskDefPb putTaskDef​(io.littlehorse.sdk.common.proto.PutTaskDefPb req)
      Creates a task definition.
      io.littlehorse.sdk.common.proto.TaskDefPb putTaskDef​(io.littlehorse.sdk.common.proto.PutTaskDefPb req, boolean swallowAlreadyExists)
      Creates a task definition
      io.littlehorse.sdk.common.proto.UserTaskDefPb putUserTaskDef​(io.littlehorse.sdk.common.proto.PutUserTaskDefPb req)
      Creates a user task definition.
      io.littlehorse.sdk.common.proto.UserTaskDefPb putUserTaskDef​(io.littlehorse.sdk.common.proto.PutUserTaskDefPb req, boolean swallowAlreadyExists)
      Creates a user task definition
      io.littlehorse.sdk.common.proto.WfSpecPb putWfSpec​(io.littlehorse.sdk.common.proto.PutWfSpecPb req)
      Creates a new workflow specification.
      void resumeWfRun​(java.lang.String wfRunId, int threadRunNumber)
      Resume a thread execution.
      java.lang.String runWf​(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 parameters
      void stopWfRun​(java.lang.String wfRunId, int threadRunNumber)
      Halts a thread for a given workflow run.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.LHApiError
        Returns 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.LHApiError
        Gets 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.LHApiError
        Gets 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.LHApiError
        Gets 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.LHApiError
        Gets the workflow specification for a given workflow name and version
        Parameters:
        name - Workflow name
        version - 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.LHApiError
        Returns 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.LHApiError
        Returns 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.LHApiError
        Returns a NodeRun given a workflow, thread run number and position in the ThreadRun
        Parameters:
        wfRunId - workflow run identification
        threadRunNumber - number of the relevant thread
        position - 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.LHApiError
        Returns a passed variable to a thread
        Parameters:
        wfRunId - workflow run identification
        threadRunNumber - number of the subsequent thread
        name - 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.LHApiError
        Returns an emitted external event for a specific workflow run
        Parameters:
        wfRunId - workflow run identification
        externalEventName - name of the external event
        guid - 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.LHApiError
        Gets 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.LHApiError
        Returns a list of ids which match the input parameters
        Parameters:
        workflowName - Name to search for
        version - Version to search for
        status - Status of WfRuns to search for (STARTING, RUNNING, COMPLETED, HALTING, HALTED, ERROR)
        earliestStart - Only shows WfRuns more recent than this configuration
        latestStart - 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.LHApiError
        Makes 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 name
        wfSpecVersion - workflow version. This is optional, pass null for the server to decide
        wfRunId - workflow run id. This is optional, pass null for the server to decide
        args - 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.LHApiError
        Emits 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.LHApiError
        Creates 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.LHApiError
        Creates a new external event definition
        Parameters:
        req - put external event definition request
        swallowAlreadyExists - 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.LHApiError
        Creates 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.LHApiError
        Creates a task definition
        Parameters:
        req - request
        swallowAlreadyExists - 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.LHApiError
        Creates 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.LHApiError
        Creates a user task definition
        Parameters:
        req - request
        swallowAlreadyExists - 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.LHApiError
        Creates 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.LHApiError
        Halts a thread for a given workflow run. Move the tread to RUNNING to HALTED
        Parameters:
        wfRunId - workflow run identification
        threadRunNumber - 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.LHApiError
        Resume a thread execution. Move the thread form HALTED to RUNNING
        Parameters:
        wfRunId - workflow run identification
        threadRunNumber - 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.LHApiError
        Deletes 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.LHApiError
        Deletes 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.LHApiError
        Deletes 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.LHApiError
        Delete 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.LHApiError
        Deletes a workflow specification given its name and version
        Parameters:
        name - of the specification
        version - of the specification
        Throws:
        io.littlehorse.sdk.common.exception.LHApiError - If there is an error when connecting to the server