Skip to content

Commit 05379ab

Browse files
authored
✨ allow passing webhooks to the CLI (#342)
1 parent 38c579a commit 05379ab

7 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/main/java/com/mindee/v2/cli/BaseInferenceCommand.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.mindee.v2.MindeeClient;
77
import com.mindee.v2.parsing.CommonResponse;
88
import java.io.File;
9+
import java.util.List;
910
import java.util.concurrent.Callable;
1011
import picocli.CommandLine.Option;
1112
import picocli.CommandLine.Parameters;
@@ -28,6 +29,12 @@ public abstract class BaseInferenceCommand implements Callable<Integer> {
2829
@Option(names = { "-a", "--alias" }, description = "Alias for the file")
2930
protected String alias;
3031

32+
@Option(
33+
names = { "-w", "--webhook-id" },
34+
description = "Specify a webhook by ID. May be used multiple times."
35+
)
36+
private List<String> webhookIds;
37+
3138
/** Output format for the command. */
3239
public enum OutputType {
3340
summary,
@@ -45,6 +52,13 @@ public enum OutputType {
4552
)
4653
protected OutputType output;
4754

55+
/**
56+
* @return The properly formatted webhook IDs.
57+
*/
58+
protected String[] getWebhookIds() {
59+
return (webhookIds != null ? webhookIds.toArray(new String[0]) : new String[] {});
60+
}
61+
4862
/**
4963
* Executes the inference request and returns the product response.
5064
*

src/main/java/com/mindee/v2/cli/ClassificationCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected CommonResponse executeRequest(
2626
.enqueueAndGetResult(
2727
ClassificationResponse.class,
2828
inputSource,
29-
ClassificationParameters.builder(modelId).alias(alias).build()
29+
ClassificationParameters.builder(modelId).alias(alias).webhookIds(getWebhookIds()).build()
3030
);
3131
}
3232

src/main/java/com/mindee/v2/cli/CropCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected CommonResponse executeRequest(
2222
.enqueueAndGetResult(
2323
CropResponse.class,
2424
inputSource,
25-
CropParameters.builder(modelId).alias(alias).build()
25+
CropParameters.builder(modelId).alias(alias).webhookIds(getWebhookIds()).build()
2626
);
2727
}
2828

src/main/java/com/mindee/v2/cli/ExtractionCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ protected CommonResponse executeRequest(
6666
ExtractionParameters
6767
.builder(modelId)
6868
.alias(alias)
69+
.webhookIds(getWebhookIds())
6970
.rag(rag)
7071
.rawText(rawText)
7172
.confidence(confidence)

src/main/java/com/mindee/v2/cli/OcrCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected CommonResponse executeRequest(
2222
.enqueueAndGetResult(
2323
OcrResponse.class,
2424
inputSource,
25-
OcrParameters.builder(modelId).alias(alias).build()
25+
OcrParameters.builder(modelId).alias(alias).webhookIds(getWebhookIds()).build()
2626
);
2727
}
2828

src/main/java/com/mindee/v2/cli/SplitCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected CommonResponse executeRequest(
2222
.enqueueAndGetResult(
2323
SplitResponse.class,
2424
inputSource,
25-
SplitParameters.builder(modelId).alias(alias).build()
25+
SplitParameters.builder(modelId).alias(alias).webhookIds(getWebhookIds()).build()
2626
);
2727
}
2828

tests/test_v2_cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ run_test() {
2222
model_type="$2"
2323

2424
echo "--- Test $model_type ID: $model_id"
25-
SUMMARY_OUTPUT=$(./cli.sh "$model_type" -m "$model_id" "$TEST_FILE")
25+
SUMMARY_OUTPUT=$(./cli.sh "$model_type" -m "$model_id" -a "java-sdk-cli-${model_type}" "$TEST_FILE")
2626
echo "$SUMMARY_OUTPUT"
2727
echo ""
2828
echo ""

0 commit comments

Comments
 (0)