Search in sources :

Example 16 with Discovery

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) ComponentSettingsResponse(com.ibm.watson.discovery.v2.model.ComponentSettingsResponse) HashMap(java.util.HashMap)

Example 17 with Discovery

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) CollectionDetails(com.ibm.watson.discovery.v2.model.CollectionDetails)

Example 18 with Discovery

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);
}
Also used : ProjectDetails(com.ibm.watson.discovery.v2.model.ProjectDetails) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap)

Example 19 with Discovery

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) ListProjectsResponse(com.ibm.watson.discovery.v2.model.ListProjectsResponse)

Example 20 with Discovery

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Completions(com.ibm.watson.discovery.v2.model.Completions)

Aggregations

RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)26 HashMap (java.util.HashMap)24 JsonObject (com.google.gson.JsonObject)9 DocumentAccepted (com.ibm.watson.discovery.v2.model.DocumentAccepted)4 MultipartBody (okhttp3.MultipartBody)4 CollectionDetails (com.ibm.watson.discovery.v2.model.CollectionDetails)3 Enrichment (com.ibm.watson.discovery.v2.model.Enrichment)3 ProjectDetails (com.ibm.watson.discovery.v2.model.ProjectDetails)3 TrainingQuery (com.ibm.watson.discovery.v2.model.TrainingQuery)3 AddDocumentOptions (com.ibm.watson.discovery.v2.model.AddDocumentOptions)2 QueryNoticesResponse (com.ibm.watson.discovery.v2.model.QueryNoticesResponse)2 QueryResponse (com.ibm.watson.discovery.v2.model.QueryResponse)2 Authenticator (com.ibm.cloud.sdk.core.security.Authenticator)1 BearerTokenAuthenticator (com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator)1 IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)1 Discovery (com.ibm.watson.discovery.v2.Discovery)1 AnalyzedDocument (com.ibm.watson.discovery.v2.model.AnalyzedDocument)1 Completions (com.ibm.watson.discovery.v2.model.Completions)1 ComponentSettingsResponse (com.ibm.watson.discovery.v2.model.ComponentSettingsResponse)1 DeleteDocumentOptions (com.ibm.watson.discovery.v2.model.DeleteDocumentOptions)1