Package com.mindee

Class MindeeClient


  • public class MindeeClient
    extends Object
    Main entrypoint for Mindee operations.
    • Constructor Detail

      • MindeeClient

        public MindeeClient()
        Create a default MindeeClient. You'll need to set the API key in the environment for this approach to work properly.
      • MindeeClient

        public MindeeClient​(String apiKey)
        Create a default MindeeClient.
        Parameters:
        apiKey - The api key to use.
      • MindeeClient

        public MindeeClient​(MindeeApi mindeeApi)
        Create a MindeeClient using a MindeeApi.
        Parameters:
        mindeeApi - The MindeeApi implementation to be used by the created MindeeClient.
      • MindeeClient

        public MindeeClient​(PdfOperation pdfOperation,
                            MindeeApi mindeeApi)
        Create a MindeeClient.
        Parameters:
        pdfOperation - The PdfOperation implementation to be used by the created MindeeClient.
        mindeeApi - The MindeeApi implementation to be used by the created MindeeClient.
    • Method Detail

      • parseQueued

        public <T extends InferenceAsyncPredictResponse<T> parseQueued​(Class<T> type,
                                                                         String jobId)
        Parse a document from an async queue.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference;
        jobId - ID of the job.
        Returns:
        A valid prediction.
      • enqueue

        public <T extends InferenceAsyncPredictResponse<T> enqueue​(Class<T> type,
                                                                     URL sourceUrl,
                                                                     PredictOptions predictOptions)
                                                              throws IOException
        Send a remote file to an async queue.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        sourceUrl - A URL to a remote file.
        predictOptions - Prediction options for the enqueuing.
        Returns:
        an instance of AsyncPredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • executeWorkflow

        public WorkflowResponse<GeneratedV1> executeWorkflow​(String workflowId,
                                                             LocalInputSource localInputSource,
                                                             WorkflowOptions workflowOptions)
                                                      throws IOException
        Send a local file to a workflow execution.
        Parameters:
        workflowId - ID of the workflow to send the document to.
        localInputSource - A local input source file.
        workflowOptions - Options for the workflow execution.
        Returns:
        A workflow response.
        Throws:
        IOException - Throws if the file can't be accessed.
      • executeWorkflow

        public WorkflowResponse<GeneratedV1> executeWorkflow​(String workflowId,
                                                             LocalInputSource localInputSource)
                                                      throws IOException
        Send a local file to a workflow execution.
        Parameters:
        workflowId - ID of the workflow to send the document to.
        localInputSource - A local input source file.
        Returns:
        A workflow response.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends InferencePredictResponse<T> parse​(Class<T> type,
                                                              LocalInputSource localInputSource)
                                                       throws IOException
        Send a local file to a Standard prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends InferencePredictResponse<T> parse​(Class<T> type,
                                                              LocalInputSource localInputSource,
                                                              PredictOptions predictOptions)
                                                       throws IOException
        Send a local file to a Standard prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        predictOptions - Prediction options for the enqueuing.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends InferencePredictResponse<T> parse​(Class<T> type,
                                                              LocalInputSource localInputSource,
                                                              PageOptions pageOptions)
                                                       throws IOException
        Send a local file to a Standard prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        pageOptions - Page options for PDF documents.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends InferencePredictResponse<T> parse​(Class<T> type,
                                                              LocalInputSource localInputSource,
                                                              PredictOptions predictOptions,
                                                              PageOptions pageOptions)
                                                       throws IOException
        Send a local file to a Standard prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        predictOptions - Prediction options for the enqueuing.
        pageOptions - Page options for PDF documents.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends InferencePredictResponse<T> parse​(Class<T> type,
                                                              URL urlInputSource)
                                                       throws IOException
        Send a remote file to a Standard prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        urlInputSource - A URL to a remote file.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends InferencePredictResponse<T> parse​(Class<T> type,
                                                              URL urlInputSource,
                                                              PredictOptions predictOptions)
                                                       throws IOException
        Send a remote file to a Standard prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        urlInputSource - A URL to a remote file.
        predictOptions - Prediction options for the enqueuing.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public PredictResponse<CustomV1> parse​(LocalInputSource localInputSource,
                                               Endpoint endpoint,
                                               PageOptions pageOptions)
                                        throws IOException
        Send a local file to a Custom prediction API and parse the results.
        Parameters:
        localInputSource - A local input source file.
        endpoint - Custom endpoint to send the document to.
        pageOptions - Page options for PDF documents.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public PredictResponse<CustomV1> parse​(URL documentUrl,
                                               Endpoint endpoint)
                                        throws IOException
        Send a remote file to a Custom prediction API and parse the results.
        Parameters:
        documentUrl - A URL to a remote file.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • enqueue

        public <T extends GeneratedV1AsyncPredictResponse<T> enqueue​(Class<T> type,
                                                                       Endpoint endpoint,
                                                                       LocalInputSource localInputSource)
                                                                throws IOException
        Send a local file to a Generated prediction async API queue.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of AsyncPredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • enqueue

        public <T extends GeneratedV1AsyncPredictResponse<T> enqueue​(Class<T> type,
                                                                       Endpoint endpoint,
                                                                       LocalInputSource localInputSource,
                                                                       PredictOptions predictOptions,
                                                                       PageOptions pageOptions)
                                                                throws IOException
        Send a local file to a Generated prediction async API queue.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        predictOptions - Prediction options for the enqueuing.
        pageOptions - Page options for PDF documents.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of AsyncPredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • enqueue

        public <T extends GeneratedV1AsyncPredictResponse<T> enqueue​(Class<T> type,
                                                                       Endpoint endpoint,
                                                                       URL sourceUrl)
                                                                throws IOException
        Send a remote file to a Generated prediction async API queue.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        endpoint - Custom endpoint to send the document to.
        sourceUrl - A URL to a remote file.
        Returns:
        an instance of AsyncPredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • enqueue

        public <T extends GeneratedV1AsyncPredictResponse<T> enqueue​(Class<T> type,
                                                                       Endpoint endpoint,
                                                                       URL sourceUrl,
                                                                       PredictOptions predictOptions)
                                                                throws IOException
        Send a remote file to a Generated prediction async API queue.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        sourceUrl - A URL to a remote file.
        predictOptions - Prediction options for the enqueuing.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends GeneratedV1PredictResponse<T> parse​(Class<T> type,
                                                                Endpoint endpoint,
                                                                LocalInputSource localInputSource)
                                                         throws IOException
        Send a local file to a Generated prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends GeneratedV1PredictResponse<T> parse​(Class<T> type,
                                                                Endpoint endpoint,
                                                                LocalInputSource localInputSource,
                                                                PredictOptions predictOptions)
                                                         throws IOException
        Send a local file to a Generated prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        predictOptions - Prediction options for the enqueuing.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends GeneratedV1PredictResponse<T> parse​(Class<T> type,
                                                                Endpoint endpoint,
                                                                LocalInputSource localInputSource,
                                                                PageOptions pageOptions)
                                                         throws IOException
        Send a local file to a Generated prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        pageOptions - Page options for PDF documents.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends GeneratedV1PredictResponse<T> parse​(Class<T> type,
                                                                Endpoint endpoint,
                                                                LocalInputSource localInputSource,
                                                                PredictOptions predictOptions,
                                                                PageOptions pageOptions)
                                                         throws IOException
        Send a local file to a Standard prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localInputSource - A local input source file.
        predictOptions - Prediction options for the enqueuing.
        pageOptions - Page options for PDF documents.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends GeneratedV1PredictResponse<T> parse​(Class<T> type,
                                                                Endpoint endpoint,
                                                                URL documentUrl)
                                                         throws IOException
        Send a remote file to a Generated prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        endpoint - Custom endpoint to send the document to.
        documentUrl - A URL to a remote file.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parse

        public <T extends GeneratedV1PredictResponse<T> parse​(Class<T> type,
                                                                Endpoint endpoint,
                                                                URL documentUrl,
                                                                PredictOptions predictOptions)
                                                         throws IOException
        Send a remote file to a Generated prediction API and parse the results.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        documentUrl - A URL to a remote file.
        predictOptions - Prediction options for the enqueuing.
        endpoint - Custom endpoint to send the document to.
        Returns:
        an instance of PredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.
      • parseQueued

        public <T extends GeneratedV1AsyncPredictResponse<T> parseQueued​(Class<T> type,
                                                                           Endpoint endpoint,
                                                                           String jobId)
        Parse a document from a Generated prediction API async queue.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        endpoint - Custom endpoint to send the document to.
        jobId - ID of the job.
        Returns:
        an instance of AsyncPredictResponse.
      • loadPrediction

        public <T extends InferenceAsyncPredictResponse<T> loadPrediction​(Class<T> type,
                                                                            LocalResponse localResponse)
                                                                     throws IOException
        Load a local prediction. Typically used when wanting to load from a webhook callback. However, any kind of Mindee response may be loaded.
        Type Parameters:
        T - Type of inference.
        Parameters:
        type - Type of inference.
        localResponse - A loaded local response.
        Returns:
        an instance of AsyncPredictResponse.
        Throws:
        IOException - Throws if the file can't be accessed.