1111import com .mindee .v1 .parsing .common .ErrorDetails ;
1212import com .mindee .v1 .parsing .common .Inference ;
1313import com .mindee .v1 .parsing .common .PredictResponse ;
14- import com .mindee .v1 .parsing .common .WorkflowResponse ;
1514import java .io .IOException ;
1615import java .net .URISyntaxException ;
1716import java .net .URL ;
@@ -44,7 +43,7 @@ public final class MindeeHttpApiV1 extends MindeeApiV1 {
4443 private static final ObjectMapper mapper = JsonMapper .builder ().findAndAddModules ().build ();
4544 private final Function <Endpoint , String > buildProductPredicBasetUrl = this ::buildProductPredictBaseUrl ;
4645 private final Function <String , String > buildWorkflowPredictBaseUrl = this ::buildWorkflowPredictBaseUrl ;
47- private final Function < String , String > buildWorkflowExecutionBaseUrl = this :: buildWorkflowExecutionUrl ;
46+
4847 /**
4948 * The MindeeSetting needed to make the api call.
5049 */
@@ -74,14 +73,9 @@ public final class MindeeHttpApiV1 extends MindeeApiV1 {
7473 * Only needs to be set if the api calls need to be directed through internal URLs.
7574 */
7675 private final Function <Endpoint , String > documentUrlFromEndpoint ;
77- /**
78- * The function used to generate the Job status URL for workflow execution calls.
79- * Only needs to be set if the api calls need to be directed through internal URLs.
80- */
81- private final Function <String , String > workflowUrlFromId ;
8276
8377 public MindeeHttpApiV1 (MindeeSettings mindeeSettings ) {
84- this (mindeeSettings , null , null , null , null , null , null );
78+ this (mindeeSettings , null , null , null , null , null );
8579 }
8680
8781 @ Builder
@@ -91,7 +85,6 @@ private MindeeHttpApiV1(
9185 Function <Endpoint , String > urlFromEndpoint ,
9286 Function <Endpoint , String > asyncUrlFromEndpoint ,
9387 Function <Endpoint , String > documentUrlFromEndpoint ,
94- Function <String , String > workflowUrlFromEndpoint ,
9588 Function <String , String > asyncUrlFromWorkflow
9689 ) {
9790 this .mindeeSettings = mindeeSettings ;
@@ -128,12 +121,6 @@ private MindeeHttpApiV1(
128121 this .documentUrlFromEndpoint = this .buildProductPredicBasetUrl
129122 .andThen ((url ) -> url .concat ("/documents/queue/" ));
130123 }
131-
132- if (workflowUrlFromEndpoint != null ) {
133- this .workflowUrlFromId = workflowUrlFromEndpoint ;
134- } else {
135- this .workflowUrlFromId = this .buildWorkflowExecutionBaseUrl ;
136- }
137124 }
138125
139126 /**
@@ -260,41 +247,6 @@ public <DocT extends Inference> AsyncPredictResponse<DocT> predictAsyncPost(
260247 }
261248 }
262249
263- /**
264- * POST a prediction request for a workflow response.
265- */
266- public <DocT extends Inference > WorkflowResponse <DocT > executeWorkflowPost (
267- Class <DocT > documentClass ,
268- String workflowId ,
269- RequestParameters requestParameters
270- ) throws IOException {
271-
272- String url = workflowUrlFromId .apply (workflowId );
273- HttpPost post = buildHttpPost (url , requestParameters );
274-
275- JavaType parametricType = mapper
276- .getTypeFactory ()
277- .constructParametricType (WorkflowResponse .class , documentClass );
278- try (CloseableHttpClient httpClient = httpClientBuilder .build ()) {
279- return httpClient .execute (post , response -> {
280- HttpEntity responseEntity = response .getEntity ();
281- int statusCode = response .getCode ();
282- if (isInvalidStatusCode (statusCode )) {
283- throw getHttpError (parametricType , response );
284- }
285- if (responseEntity .getContentLength () == 0 ) {
286- throw new MindeeException ("Empty response from server." );
287- }
288- String rawResponse = readRawResponse (responseEntity );
289- WorkflowResponse <DocT > mappedResponse = mapper .readValue (rawResponse , parametricType );
290- mappedResponse .setRawResponse (rawResponse );
291- return mappedResponse ;
292- });
293- } catch (IOException err ) {
294- throw new MindeeException (err .getMessage (), err );
295- }
296- }
297-
298250 private <ResponseT extends ApiResponse > MindeeHttpExceptionV1 getHttpError (
299251 JavaType parametricType ,
300252 ClassicHttpResponse response
@@ -344,10 +296,6 @@ private String buildWorkflowPredictBaseUrl(String workflowId) {
344296 return this .mindeeSettings .getBaseUrl () + "/workflows/" + workflowId ;
345297 }
346298
347- private String buildWorkflowExecutionUrl (String workflowId ) {
348- return this .mindeeSettings .getBaseUrl () + "/workflows/" + workflowId + "/executions" ;
349- }
350-
351299 private HttpPost buildHttpPost (
352300 String url ,
353301 RequestParameters requestParameters
0 commit comments