use of com.ibm.watson.discovery.v2.Discovery in project java-sdk by watson-developer-cloud.
the class Discovery method getComponentSettings.
/**
* List component settings.
*
* <p>Returns default configuration settings for components.
*
* @param getComponentSettingsOptions the {@link GetComponentSettingsOptions} containing the
* options for the call
* @return a {@link ServiceCall} with a result of type {@link ComponentSettingsResponse}
*/
public ServiceCall<ComponentSettingsResponse> getComponentSettings(GetComponentSettingsOptions getComponentSettingsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getComponentSettingsOptions, "getComponentSettingsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("project_id", getComponentSettingsOptions.projectId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects/{project_id}/component_settings", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getComponentSettings");
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<ComponentSettingsResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ComponentSettingsResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v2.Discovery in project java-sdk by watson-developer-cloud.
the class Discovery method updateCollection.
/**
* Update a collection.
*
* <p>Updates the specified collection's name, description, and enrichments.
*
* @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link CollectionDetails}
*/
public ServiceCall<CollectionDetails> updateCollection(UpdateCollectionOptions updateCollectionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateCollectionOptions, "updateCollectionOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("project_id", updateCollectionOptions.projectId());
pathParamsMap.put("collection_id", updateCollectionOptions.collectionId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects/{project_id}/collections/{collection_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateCollection");
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 (updateCollectionOptions.name() != null) {
contentJson.addProperty("name", updateCollectionOptions.name());
}
if (updateCollectionOptions.description() != null) {
contentJson.addProperty("description", updateCollectionOptions.description());
}
if (updateCollectionOptions.enrichments() != null) {
contentJson.add("enrichments", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateCollectionOptions.enrichments()));
}
builder.bodyJson(contentJson);
ResponseConverter<CollectionDetails> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CollectionDetails>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v2.Discovery in project java-sdk by watson-developer-cloud.
the class Discovery method getProject.
/**
* Get project.
*
* <p>Get details on the specified project.
*
* @param getProjectOptions the {@link GetProjectOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ProjectDetails}
*/
public ServiceCall<ProjectDetails> getProject(GetProjectOptions getProjectOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getProjectOptions, "getProjectOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("project_id", getProjectOptions.projectId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects/{project_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getProject");
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<ProjectDetails> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ProjectDetails>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v2.Discovery in project java-sdk by watson-developer-cloud.
the class Discovery method listProjects.
/**
* List projects.
*
* <p>Lists existing projects for this instance.
*
* @param listProjectsOptions the {@link ListProjectsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ListProjectsResponse}
*/
public ServiceCall<ListProjectsResponse> listProjects(ListProjectsOptions listProjectsOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listProjects");
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<ListProjectsResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ListProjectsResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v2.Discovery in project java-sdk by watson-developer-cloud.
the class Discovery method getAutocompletion.
/**
* Get Autocomplete Suggestions.
*
* <p>Returns completion query suggestions for the specified prefix.
*
* @param getAutocompletionOptions the {@link GetAutocompletionOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link Completions}
*/
public ServiceCall<Completions> getAutocompletion(GetAutocompletionOptions getAutocompletionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getAutocompletionOptions, "getAutocompletionOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("project_id", getAutocompletionOptions.projectId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects/{project_id}/autocompletion", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getAutocompletion");
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));
builder.query("prefix", String.valueOf(getAutocompletionOptions.prefix()));
if (getAutocompletionOptions.collectionIds() != null) {
builder.query("collection_ids", RequestUtils.join(getAutocompletionOptions.collectionIds(), ","));
}
if (getAutocompletionOptions.field() != null) {
builder.query("field", String.valueOf(getAutocompletionOptions.field()));
}
if (getAutocompletionOptions.count() != null) {
builder.query("count", String.valueOf(getAutocompletionOptions.count()));
}
ResponseConverter<Completions> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Completions>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations