Search in sources :

Example 6 with BatchStatus

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) BatchStatus(com.ibm.watson.compare_comply.v1.model.BatchStatus)

Example 7 with BatchStatus

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);
}
Also used : UpdateBatchOptions(com.ibm.watson.compare_comply.v1.model.UpdateBatchOptions) BatchStatus(com.ibm.watson.compare_comply.v1.model.BatchStatus) Batches(com.ibm.watson.compare_comply.v1.model.Batches) CreateBatchOptions(com.ibm.watson.compare_comply.v1.model.CreateBatchOptions) GetBatchOptions(com.ibm.watson.compare_comply.v1.model.GetBatchOptions) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

BatchStatus (com.ibm.watson.compare_comply.v1.model.BatchStatus)7 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)3 MockResponse (okhttp3.mockwebserver.MockResponse)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 Test (org.testng.annotations.Test)3 CreateBatchOptions (com.ibm.watson.compare_comply.v1.model.CreateBatchOptions)2 GetBatchOptions (com.ibm.watson.compare_comply.v1.model.GetBatchOptions)2 UpdateBatchOptions (com.ibm.watson.compare_comply.v1.model.UpdateBatchOptions)2 HashMap (java.util.HashMap)2 Batches (com.ibm.watson.compare_comply.v1.model.Batches)1 MultipartBody (okhttp3.MultipartBody)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1