Search in sources :

Example 96 with RequestBuilder

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

the class Assistant method listAllLogs.

/**
 * List log events in all workspaces.
 *
 * <p>List the events from the logs of all workspaces in the service instance.
 *
 * @param listAllLogsOptions the {@link ListAllLogsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link LogCollection}
 */
public ServiceCall<LogCollection> listAllLogs(ListAllLogsOptions listAllLogsOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(listAllLogsOptions, "listAllLogsOptions cannot be null");
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/logs"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listAllLogs");
    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("filter", String.valueOf(listAllLogsOptions.filter()));
    if (listAllLogsOptions.sort() != null) {
        builder.query("sort", String.valueOf(listAllLogsOptions.sort()));
    }
    if (listAllLogsOptions.pageLimit() != null) {
        builder.query("page_limit", String.valueOf(listAllLogsOptions.pageLimit()));
    }
    if (listAllLogsOptions.cursor() != null) {
        builder.query("cursor", String.valueOf(listAllLogsOptions.cursor()));
    }
    ResponseConverter<LogCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<LogCollection>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) LogCollection(com.ibm.watson.assistant.v1.model.LogCollection)

Example 97 with RequestBuilder

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

the class Assistant method createCounterexample.

/**
 * Create counterexample.
 *
 * <p>Add a new counterexample to a workspace. Counterexamples are examples that have been marked
 * as irrelevant input.
 *
 * <p>If you want to add multiple counterexamples with a single API call, consider using the
 * **[Update workspace](#update-workspace)** method instead.
 *
 * @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the
 *     options for the call
 * @return a {@link ServiceCall} with a result of type {@link Counterexample}
 */
public ServiceCall<Counterexample> createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(createCounterexampleOptions, "createCounterexampleOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", createCounterexampleOptions.workspaceId());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createCounterexample");
    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 (createCounterexampleOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(createCounterexampleOptions.includeAudit()));
    }
    final JsonObject contentJson = new JsonObject();
    contentJson.addProperty("text", createCounterexampleOptions.text());
    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 98 with RequestBuilder

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

the class Assistant method deleteWorkspace.

/**
 * Delete workspace.
 *
 * <p>Delete a workspace from the service instance.
 *
 * @param deleteWorkspaceOptions the {@link DeleteWorkspaceOptions} containing the options for the
 *     call
 * @return a {@link ServiceCall} with a void result
 */
public ServiceCall<Void> deleteWorkspace(DeleteWorkspaceOptions deleteWorkspaceOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(deleteWorkspaceOptions, "deleteWorkspaceOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", deleteWorkspaceOptions.workspaceId());
    RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteWorkspace");
    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 99 with RequestBuilder

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

the class Assistant method updateValue.

/**
 * Update entity value.
 *
 * <p>Update an existing entity value with new or modified data. You must provide component
 * objects defining the content of the updated entity value.
 *
 * <p>If you want to update multiple entity values with a single API call, consider using the
 * **[Update entity](#update-entity)** method instead.
 *
 * @param updateValueOptions the {@link UpdateValueOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link Value}
 */
public ServiceCall<Value> updateValue(UpdateValueOptions updateValueOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(updateValueOptions, "updateValueOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", updateValueOptions.workspaceId());
    pathParamsMap.put("entity", updateValueOptions.entity());
    pathParamsMap.put("value", updateValueOptions.value());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateValue");
    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 (updateValueOptions.append() != null) {
        builder.query("append", String.valueOf(updateValueOptions.append()));
    }
    if (updateValueOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(updateValueOptions.includeAudit()));
    }
    final JsonObject contentJson = new JsonObject();
    if (updateValueOptions.newValue() != null) {
        contentJson.addProperty("value", updateValueOptions.newValue());
    }
    if (updateValueOptions.newMetadata() != null) {
        contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newMetadata()));
    }
    if (updateValueOptions.newType() != null) {
        contentJson.addProperty("type", updateValueOptions.newType());
    }
    if (updateValueOptions.newSynonyms() != null) {
        contentJson.add("synonyms", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newSynonyms()));
    }
    if (updateValueOptions.newPatterns() != null) {
        contentJson.add("patterns", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newPatterns()));
    }
    builder.bodyJson(contentJson);
    ResponseConverter<Value> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Value>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Value(com.ibm.watson.assistant.v1.model.Value) JsonObject(com.google.gson.JsonObject)

Example 100 with RequestBuilder

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

the class Assistant method deleteDialogNode.

/**
 * Delete dialog node.
 *
 * <p>Delete a dialog node from a workspace.
 *
 * @param deleteDialogNodeOptions the {@link DeleteDialogNodeOptions} containing the options for
 *     the call
 * @return a {@link ServiceCall} with a void result
 */
public ServiceCall<Void> deleteDialogNode(DeleteDialogNodeOptions deleteDialogNodeOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDialogNodeOptions, "deleteDialogNodeOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", deleteDialogNodeOptions.workspaceId());
    pathParamsMap.put("dialog_node", deleteDialogNodeOptions.dialogNode());
    RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteDialogNode");
    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)

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