use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method listfieldsCollectionIsSuccessful.
// no updateCollection yet?
@Test
public void listfieldsCollectionIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(listfieldsCollResp));
ListCollectionFieldsOptions getRequest = new ListCollectionFieldsOptions.Builder(environmentId, collectionId).build();
ListCollectionFieldsResponse response = discoveryService.listCollectionFields(getRequest).execute();
RecordedRequest request = server.takeRequest();
assertEquals(COLL3_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(listfieldsCollResp, response);
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.
the class Discovery method listCollectionFields.
/**
* List unique fields.
*
* Gets a list of the unique fields (and their types) stored in the index.
*
* @param listCollectionFieldsOptions the {@link ListCollectionFieldsOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse}
*/
public ServiceCall<ListCollectionFieldsResponse> listCollectionFields(ListCollectionFieldsOptions listCollectionFieldsOptions) {
Validator.notNull(listCollectionFieldsOptions, "listCollectionFieldsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "fields" };
String[] pathParameters = { listCollectionFieldsOptions.environmentId(), listCollectionFieldsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class));
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method getCollectionFieldsIsSuccessful.
@Ignore
@Test
public void getCollectionFieldsIsSuccessful() {
Collection collection = createTestCollection();
String collectionId = collection.getCollectionId();
createTestDocument("test_document", collectionId);
ListCollectionFieldsOptions getOptions = new ListCollectionFieldsOptions.Builder(environmentId, collectionId).build();
ListCollectionFieldsResponse getResponse = discovery.listCollectionFields(getOptions).execute();
assertFalse(getResponse.getFields().isEmpty());
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method listFieldsIsSuccessful.
@Test
public void listFieldsIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(listFieldsResp));
ListFieldsOptions.Builder builder = new ListFieldsOptions.Builder(environmentId, new ArrayList<>(Arrays.asList(collectionId)));
ListCollectionFieldsResponse response = discoveryService.listFields(builder.build()).execute();
RecordedRequest request = server.takeRequest();
assertEquals(FIELD_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(listFieldsResp, response);
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.
the class Discovery method listFields.
/**
* List fields in specified collections.
*
* Gets a list of the unique fields (and their types) stored in the indexes of the specified collections.
*
* @param listFieldsOptions the {@link ListFieldsOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse}
*/
public ServiceCall<ListCollectionFieldsResponse> listFields(ListFieldsOptions listFieldsOptions) {
Validator.notNull(listFieldsOptions, "listFieldsOptions cannot be null");
String[] pathSegments = { "v1/environments", "fields" };
String[] pathParameters = { listFieldsOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ","));
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class));
}
Aggregations