use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class Discovery method createStopwordList.
/**
* Create stopword list.
*
* <p>Upload a custom stopword list to use with the specified collection.
*
* @param createStopwordListOptions the {@link CreateStopwordListOptions} containing the options
* for the call
* @return a {@link ServiceCall} with a result of type {@link TokenDictStatusResponse}
*/
public ServiceCall<TokenDictStatusResponse> createStopwordList(CreateStopwordListOptions createStopwordListOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createStopwordListOptions, "createStopwordListOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", createStopwordListOptions.environmentId());
pathParamsMap.put("collection_id", createStopwordListOptions.collectionId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/stopwords", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createStopwordList");
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));
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
okhttp3.RequestBody stopwordFileBody = RequestUtils.inputStreamBody(createStopwordListOptions.stopwordFile(), "application/octet-stream");
multipartBuilder.addFormDataPart("stopword_file", createStopwordListOptions.stopwordFilename(), stopwordFileBody);
builder.body(multipartBuilder.build());
ResponseConverter<TokenDictStatusResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<TokenDictStatusResponse>() {
}.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 getTokenizationDictionaryStatus.
/**
* Get tokenization dictionary status.
*
* <p>Returns the current status of the tokenization dictionary for the specified collection.
*
* @param getTokenizationDictionaryStatusOptions the {@link
* GetTokenizationDictionaryStatusOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link TokenDictStatusResponse}
*/
public ServiceCall<TokenDictStatusResponse> getTokenizationDictionaryStatus(GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getTokenizationDictionaryStatusOptions, "getTokenizationDictionaryStatusOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", getTokenizationDictionaryStatusOptions.environmentId());
pathParamsMap.put("collection_id", getTokenizationDictionaryStatusOptions.collectionId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTokenizationDictionaryStatus");
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<TokenDictStatusResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<TokenDictStatusResponse>() {
}.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 deleteCollection.
/**
* Delete a collection.
*
* @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link DeleteCollectionResponse}
*/
public ServiceCall<DeleteCollectionResponse> deleteCollection(DeleteCollectionOptions deleteCollectionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteCollectionOptions, "deleteCollectionOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", deleteCollectionOptions.environmentId());
pathParamsMap.put("collection_id", deleteCollectionOptions.collectionId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/collections/{collection_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteCollection");
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<DeleteCollectionResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DeleteCollectionResponse>() {
}.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 createCredentials.
/**
* Create credentials.
*
* <p>Creates a set of credentials to connect to a remote source. Created credentials are used in
* a configuration to associate a collection with the remote source.
*
* <p>**Note:** All credentials are sent over an encrypted connection and encrypted at rest.
*
* @param createCredentialsOptions the {@link CreateCredentialsOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link Credentials}
*/
public ServiceCall<Credentials> createCredentials(CreateCredentialsOptions createCredentialsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createCredentialsOptions, "createCredentialsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", createCredentialsOptions.environmentId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/credentials", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createCredentials");
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 (createCredentialsOptions.sourceType() != null) {
contentJson.addProperty("source_type", createCredentialsOptions.sourceType());
}
if (createCredentialsOptions.credentialDetails() != null) {
contentJson.add("credential_details", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createCredentialsOptions.credentialDetails()));
}
if (createCredentialsOptions.status() != null) {
contentJson.add("status", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createCredentialsOptions.status()));
}
builder.bodyJson(contentJson);
ResponseConverter<Credentials> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Credentials>() {
}.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 listCollectionFields.
/**
* List collection fields.
*
* <p>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 result of type {@link ListCollectionFieldsResponse}
*/
public ServiceCall<ListCollectionFieldsResponse> listCollectionFields(ListCollectionFieldsOptions listCollectionFieldsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listCollectionFieldsOptions, "listCollectionFieldsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", listCollectionFieldsOptions.environmentId());
pathParamsMap.put("collection_id", listCollectionFieldsOptions.collectionId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/collections/{collection_id}/fields", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollectionFields");
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<ListCollectionFieldsResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ListCollectionFieldsResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations