use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class Discovery method getCollection.
/**
* Get collection details.
*
* @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Collection}
*/
public ServiceCall<Collection> getCollection(GetCollectionOptions getCollectionOptions) {
Validator.notNull(getCollectionOptions, "getCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { getCollectionOptions.environmentId(), getCollectionOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class Discovery method updateCollection.
/**
* Update a collection.
*
* @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Collection}
*/
public ServiceCall<Collection> updateCollection(UpdateCollectionOptions updateCollectionOptions) {
Validator.notNull(updateCollectionOptions, "updateCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { updateCollectionOptions.environmentId(), updateCollectionOptions.collectionId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (updateCollectionOptions.name() != null) {
contentJson.addProperty("name", updateCollectionOptions.name());
}
if (updateCollectionOptions.description() != null) {
contentJson.addProperty("description", updateCollectionOptions.description());
}
if (updateCollectionOptions.configurationId() != null) {
contentJson.addProperty("configuration_id", updateCollectionOptions.configurationId());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class Discovery method listExpansions.
/**
* List current expansions.
*
* Returns the current expansion list for the specified collection. If an expansion list is not specified, an object
* with empty expansion arrays is returned.
*
* @param listExpansionsOptions the {@link ListExpansionsOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Expansions}
*/
public ServiceCall<Expansions> listExpansions(ListExpansionsOptions listExpansionsOptions) {
Validator.notNull(listExpansionsOptions, "listExpansionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "expansions" };
String[] pathParameters = { listExpansionsOptions.environmentId(), listExpansionsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Expansions.class));
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method createCollectionIsSuccessful.
@Test
public void createCollectionIsSuccessful() {
Configuration createConfigResponse = createTestConfig();
String uniqueCollectionName = uniqueName + "-collection";
String uniqueCollectionDescription = "Description of " + uniqueCollectionName;
CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).configurationId(createConfigResponse.getConfigurationId()).description(uniqueCollectionDescription);
Collection createResponse = createCollection(createCollectionBuilder.build());
assertEquals(createConfigResponse.getConfigurationId(), createResponse.getConfigurationId());
assertEquals(uniqueCollectionName, createResponse.getName());
assertEquals(uniqueCollectionDescription, createResponse.getDescription());
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection 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());
}
Aggregations