use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method listfieldsCollectionIsSuccessful.
// no updateCollection yet?
/**
* Listfields collection is successful.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void listfieldsCollectionIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(listfieldsCollResp));
ListCollectionFieldsOptions getRequest = new ListCollectionFieldsOptions.Builder(environmentId, collectionId).build();
ListCollectionFieldsResponse response = discoveryService.listCollectionFields(getRequest).execute().getResult();
RecordedRequest request = server.takeRequest();
assertEquals(COLL3_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(listfieldsCollResp, response);
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class Discovery method createExpansions.
/**
* Create or update expansion list.
*
* <p>Create or replace the Expansion list for this collection. The maximum number of expanded
* terms per collection is `500`. The current expansion list is replaced with the uploaded
* content.
*
* @param createExpansionsOptions the {@link CreateExpansionsOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link Expansions}
*/
public ServiceCall<Expansions> createExpansions(CreateExpansionsOptions createExpansionsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createExpansionsOptions, "createExpansionsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", createExpansionsOptions.environmentId());
pathParamsMap.put("collection_id", createExpansionsOptions.collectionId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/collections/{collection_id}/expansions", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createExpansions");
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));
final JsonObject contentJson = new JsonObject();
contentJson.add("expansions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createExpansionsOptions.expansions()));
builder.bodyJson(contentJson);
ResponseConverter<Expansions> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Expansions>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.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 result of type {@link Collection}
*/
public ServiceCall<Collection> getCollection(GetCollectionOptions getCollectionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getCollectionOptions, "getCollectionOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", getCollectionOptions.environmentId());
pathParamsMap.put("collection_id", getCollectionOptions.collectionId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/collections/{collection_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getCollection");
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<Collection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Collection>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class Discovery method listTrainingData.
/**
* List training data.
*
* <p>Lists the training data for the specified collection.
*
* @param listTrainingDataOptions the {@link ListTrainingDataOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link TrainingDataSet}
*/
public ServiceCall<TrainingDataSet> listTrainingData(ListTrainingDataOptions listTrainingDataOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listTrainingDataOptions, "listTrainingDataOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", listTrainingDataOptions.environmentId());
pathParamsMap.put("collection_id", listTrainingDataOptions.collectionId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/collections/{collection_id}/training_data", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listTrainingData");
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<TrainingDataSet> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<TrainingDataSet>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class Discovery method createTokenizationDictionary.
/**
* Create tokenization dictionary.
*
* <p>Upload a custom tokenization dictionary to use with the specified collection.
*
* @param createTokenizationDictionaryOptions the {@link CreateTokenizationDictionaryOptions}
* containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link TokenDictStatusResponse}
*/
public ServiceCall<TokenDictStatusResponse> createTokenizationDictionary(CreateTokenizationDictionaryOptions createTokenizationDictionaryOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createTokenizationDictionaryOptions, "createTokenizationDictionaryOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", createTokenizationDictionaryOptions.environmentId());
pathParamsMap.put("collection_id", createTokenizationDictionaryOptions.collectionId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTokenizationDictionary");
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));
final JsonObject contentJson = new JsonObject();
if (createTokenizationDictionaryOptions.tokenizationRules() != null) {
contentJson.add("tokenization_rules", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createTokenizationDictionaryOptions.tokenizationRules()));
}
builder.bodyJson(contentJson);
ResponseConverter<TokenDictStatusResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<TokenDictStatusResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations