use of com.ibm.watson.compare_comply.v1.model.BatchStatus in project java-sdk by watson-developer-cloud.
the class CompareComply method getBatch.
/**
* Get information about a specific batch-processing job.
*
* <p>Gets information about a batch-processing job with a specified ID.
*
* @param getBatchOptions the {@link GetBatchOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link BatchStatus}
*/
public ServiceCall<BatchStatus> getBatch(GetBatchOptions getBatchOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getBatchOptions, "getBatchOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("batch_id", getBatchOptions.batchId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/batches/{batch_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getBatch");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
ResponseConverter<BatchStatus> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<BatchStatus>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.compare_comply.v1.model.BatchStatus in project java-sdk by watson-developer-cloud.
the class CompareComplyServiceIT method testBatchOperations.
@Test
@Ignore
public void testBatchOperations() throws FileNotFoundException {
String bucketLocation = "us-south";
String inputBucketName = "compare-comply-integration-test-bucket-input";
String outputBucketName = "compare-comply-integration-test-bucket-output";
CreateBatchOptions createBatchOptions = new CreateBatchOptions.Builder().function(CreateBatchOptions.Function.ELEMENT_CLASSIFICATION).inputBucketLocation(bucketLocation).inputBucketName(inputBucketName).inputCredentialsFile(INPUT_CREDENTIALS_FILE).outputBucketLocation(bucketLocation).outputBucketName(outputBucketName).outputCredentialsFile(OUTPUT_CREDENTIALS_FILE).build();
BatchStatus createBatchResponse = service.createBatch(createBatchOptions).execute().getResult();
String batchId = createBatchResponse.getBatchId();
GetBatchOptions getBatchOptions = new GetBatchOptions.Builder().batchId(batchId).build();
BatchStatus getBatchResponse = service.getBatch(getBatchOptions).execute().getResult();
assertNotNull(getBatchResponse);
UpdateBatchOptions updateBatchOptions = new UpdateBatchOptions.Builder().batchId(batchId).action(UpdateBatchOptions.Action.RESCAN).build();
BatchStatus updateBatchResponse = service.updateBatch(updateBatchOptions).execute().getResult();
assertTrue(updateBatchResponse.getCreated().before(updateBatchResponse.getUpdated()));
Batches listBatchesResponse = service.listBatches().execute().getResult();
List<BatchStatus> batches = listBatchesResponse.getBatches();
boolean batchFound = false;
for (BatchStatus batch : batches) {
if (batch.getBatchId().equals(batchId)) {
batchFound = true;
break;
}
}
assertTrue(batchFound);
}
Aggregations