Search in sources :

Example 81 with RequestBuilder

use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.

the class Assistant method listExamples.

/**
 * List user input examples.
 *
 * <p>List the user input examples for an intent, optionally including contextual entity mentions.
 *
 * @param listExamplesOptions the {@link ListExamplesOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link ExampleCollection}
 */
public ServiceCall<ExampleCollection> listExamples(ListExamplesOptions listExamplesOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(listExamplesOptions, "listExamplesOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", listExamplesOptions.workspaceId());
    pathParamsMap.put("intent", listExamplesOptions.intent());
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}/examples", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listExamples");
    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));
    if (listExamplesOptions.pageLimit() != null) {
        builder.query("page_limit", String.valueOf(listExamplesOptions.pageLimit()));
    }
    if (listExamplesOptions.includeCount() != null) {
        builder.query("include_count", String.valueOf(listExamplesOptions.includeCount()));
    }
    if (listExamplesOptions.sort() != null) {
        builder.query("sort", String.valueOf(listExamplesOptions.sort()));
    }
    if (listExamplesOptions.cursor() != null) {
        builder.query("cursor", String.valueOf(listExamplesOptions.cursor()));
    }
    if (listExamplesOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(listExamplesOptions.includeAudit()));
    }
    ResponseConverter<ExampleCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ExampleCollection>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) ExampleCollection(com.ibm.watson.assistant.v1.model.ExampleCollection)

Example 82 with RequestBuilder

use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.

the class Assistant method deleteIntent.

/**
 * Delete intent.
 *
 * <p>Delete an intent from a workspace.
 *
 * @param deleteIntentOptions the {@link DeleteIntentOptions} containing the options for the call
 * @return a {@link ServiceCall} with a void result
 */
public ServiceCall<Void> deleteIntent(DeleteIntentOptions deleteIntentOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(deleteIntentOptions, "deleteIntentOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", deleteIntentOptions.workspaceId());
    pathParamsMap.put("intent", deleteIntentOptions.intent());
    RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteIntent");
    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<Void> responseConverter = ResponseConverterUtils.getVoid();
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap)

Example 83 with RequestBuilder

use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.

the class Assistant method deleteCounterexample.

/**
 * Delete counterexample.
 *
 * <p>Delete a counterexample from a workspace. Counterexamples are examples that have been marked
 * as irrelevant input.
 *
 * @param deleteCounterexampleOptions the {@link DeleteCounterexampleOptions} containing the
 *     options for the call
 * @return a {@link ServiceCall} with a void result
 */
public ServiceCall<Void> deleteCounterexample(DeleteCounterexampleOptions deleteCounterexampleOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(deleteCounterexampleOptions, "deleteCounterexampleOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", deleteCounterexampleOptions.workspaceId());
    pathParamsMap.put("text", deleteCounterexampleOptions.text());
    RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples/{text}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteCounterexample");
    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<Void> responseConverter = ResponseConverterUtils.getVoid();
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap)

Example 84 with RequestBuilder

use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.

the class Assistant method updateCounterexample.

/**
 * Update counterexample.
 *
 * <p>Update the text of a counterexample. Counterexamples are examples that have been marked as
 * irrelevant input.
 *
 * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the
 *     options for the call
 * @return a {@link ServiceCall} with a result of type {@link Counterexample}
 */
public ServiceCall<Counterexample> updateCounterexample(UpdateCounterexampleOptions updateCounterexampleOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(updateCounterexampleOptions, "updateCounterexampleOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", updateCounterexampleOptions.workspaceId());
    pathParamsMap.put("text", updateCounterexampleOptions.text());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples/{text}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateCounterexample");
    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));
    if (updateCounterexampleOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(updateCounterexampleOptions.includeAudit()));
    }
    final JsonObject contentJson = new JsonObject();
    if (updateCounterexampleOptions.newText() != null) {
        contentJson.addProperty("text", updateCounterexampleOptions.newText());
    }
    builder.bodyJson(contentJson);
    ResponseConverter<Counterexample> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Counterexample>() {
    }.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) Counterexample(com.ibm.watson.assistant.v1.model.Counterexample)

Example 85 with RequestBuilder

use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.

the class Assistant method createExample.

/**
 * Create user input example.
 *
 * <p>Add a new user input example to an intent.
 *
 * <p>If you want to add multiple examples with a single API call, consider using the **[Update
 * intent](#update-intent)** method instead.
 *
 * @param createExampleOptions the {@link CreateExampleOptions} containing the options for the
 *     call
 * @return a {@link ServiceCall} with a result of type {@link Example}
 */
public ServiceCall<Example> createExample(CreateExampleOptions createExampleOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(createExampleOptions, "createExampleOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", createExampleOptions.workspaceId());
    pathParamsMap.put("intent", createExampleOptions.intent());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}/examples", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createExample");
    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));
    if (createExampleOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(createExampleOptions.includeAudit()));
    }
    final JsonObject contentJson = new JsonObject();
    contentJson.addProperty("text", createExampleOptions.text());
    if (createExampleOptions.mentions() != null) {
        contentJson.add("mentions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createExampleOptions.mentions()));
    }
    builder.bodyJson(contentJson);
    ResponseConverter<Example> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Example>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Example(com.ibm.watson.assistant.v1.model.Example) JsonObject(com.google.gson.JsonObject)

Aggregations

RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)422 HashMap (java.util.HashMap)324 JsonObject (com.google.gson.JsonObject)111 MultipartBody (okhttp3.MultipartBody)30 InputStream (java.io.InputStream)27 DocumentResult (com.ibm.cloud.cloudant.v1.model.DocumentResult)12 Ok (com.ibm.cloud.cloudant.v1.model.Ok)8 MetricResponse (com.ibm.watson.discovery.v1.model.MetricResponse)4 DeleteModelResults (com.ibm.watson.natural_language_understanding.v1.model.DeleteModelResults)4 Collection (com.ibm.watson.visual_recognition.v4.model.Collection)4 DesignDocument (com.ibm.cloud.cloudant.v1.model.DesignDocument)3 ReplicationDocument (com.ibm.cloud.cloudant.v1.model.ReplicationDocument)3 TagsSubscriptionList (com.ibm.cloud.eventnotifications.event_notifications.v1.model.TagsSubscriptionList)3 Counterexample (com.ibm.watson.assistant.v1.model.Counterexample)3 DialogNode (com.ibm.watson.assistant.v1.model.DialogNode)3 Entity (com.ibm.watson.assistant.v1.model.Entity)3 Intent (com.ibm.watson.assistant.v1.model.Intent)3 Value (com.ibm.watson.assistant.v1.model.Value)3 DeleteCredentials (com.ibm.watson.discovery.v1.model.DeleteCredentials)3 TokenDictStatusResponse (com.ibm.watson.discovery.v1.model.TokenDictStatusResponse)3