Search in sources :

Example 91 with RequestBuilder

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

the class Assistant method deleteUserData.

/**
 * Delete labeled data.
 *
 * <p>Deletes all data associated with a specified customer ID. The method has no effect if no
 * data is associated with the customer ID.
 *
 * <p>You associate a customer ID with data by passing the `X-Watson-Metadata` header with a
 * request that passes data. For more information about personal data and customer IDs, see
 * [Information
 * security](https://cloud.ibm.com/docs/assistant?topic=assistant-information-security#information-security).
 *
 * <p>**Note:** This operation is intended only for deleting data associated with a single
 * specific customer, not for deleting data associated with multiple customers or for any other
 * purpose. For more information, see [Labeling and deleting data in Watson
 * Assistant](https://cloud.ibm.com/docs/assistant?topic=assistant-information-security#information-security-gdpr-wa).
 *
 * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the
 *     call
 * @return a {@link ServiceCall} with a void result
 */
public ServiceCall<Void> deleteUserData(DeleteUserDataOptions deleteUserDataOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null");
    RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/user_data"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteUserData");
    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("customer_id", String.valueOf(deleteUserDataOptions.customerId()));
    ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder)

Example 92 with RequestBuilder

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

the class Assistant method listValues.

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

Example 93 with RequestBuilder

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

the class Assistant method updateDialogNode.

/**
 * Update dialog node.
 *
 * <p>Update an existing dialog node with new or modified data.
 *
 * <p>If you want to update multiple dialog nodes with a single API call, consider using the
 * **[Update workspace](#update-workspace)** method instead.
 *
 * @param updateDialogNodeOptions the {@link UpdateDialogNodeOptions} containing the options for
 *     the call
 * @return a {@link ServiceCall} with a result of type {@link DialogNode}
 */
public ServiceCall<DialogNode> updateDialogNode(UpdateDialogNodeOptions updateDialogNodeOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(updateDialogNodeOptions, "updateDialogNodeOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("workspace_id", updateDialogNodeOptions.workspaceId());
    pathParamsMap.put("dialog_node", updateDialogNodeOptions.dialogNode());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateDialogNode");
    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 (updateDialogNodeOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(updateDialogNodeOptions.includeAudit()));
    }
    final JsonObject contentJson = new JsonObject();
    if (updateDialogNodeOptions.newDialogNode() != null) {
        contentJson.addProperty("dialog_node", updateDialogNodeOptions.newDialogNode());
    }
    if (updateDialogNodeOptions.newDescription() != null) {
        contentJson.addProperty("description", updateDialogNodeOptions.newDescription());
    }
    if (updateDialogNodeOptions.newConditions() != null) {
        contentJson.addProperty("conditions", updateDialogNodeOptions.newConditions());
    }
    if (updateDialogNodeOptions.newParent() != null) {
        contentJson.addProperty("parent", updateDialogNodeOptions.newParent());
    }
    if (updateDialogNodeOptions.newPreviousSibling() != null) {
        contentJson.addProperty("previous_sibling", updateDialogNodeOptions.newPreviousSibling());
    }
    if (updateDialogNodeOptions.newOutput() != null) {
        contentJson.add("output", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newOutput()));
    }
    if (updateDialogNodeOptions.newContext() != null) {
        contentJson.add("context", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newContext()));
    }
    if (updateDialogNodeOptions.newMetadata() != null) {
        contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newMetadata()));
    }
    if (updateDialogNodeOptions.newNextStep() != null) {
        contentJson.add("next_step", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newNextStep()));
    }
    if (updateDialogNodeOptions.newTitle() != null) {
        contentJson.addProperty("title", updateDialogNodeOptions.newTitle());
    }
    if (updateDialogNodeOptions.newType() != null) {
        contentJson.addProperty("type", updateDialogNodeOptions.newType());
    }
    if (updateDialogNodeOptions.newEventName() != null) {
        contentJson.addProperty("event_name", updateDialogNodeOptions.newEventName());
    }
    if (updateDialogNodeOptions.newVariable() != null) {
        contentJson.addProperty("variable", updateDialogNodeOptions.newVariable());
    }
    if (updateDialogNodeOptions.newActions() != null) {
        contentJson.add("actions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newActions()));
    }
    if (updateDialogNodeOptions.newDigressIn() != null) {
        contentJson.addProperty("digress_in", updateDialogNodeOptions.newDigressIn());
    }
    if (updateDialogNodeOptions.newDigressOut() != null) {
        contentJson.addProperty("digress_out", updateDialogNodeOptions.newDigressOut());
    }
    if (updateDialogNodeOptions.newDigressOutSlots() != null) {
        contentJson.addProperty("digress_out_slots", updateDialogNodeOptions.newDigressOutSlots());
    }
    if (updateDialogNodeOptions.newUserLabel() != null) {
        contentJson.addProperty("user_label", updateDialogNodeOptions.newUserLabel());
    }
    if (updateDialogNodeOptions.newDisambiguationOptOut() != null) {
        contentJson.addProperty("disambiguation_opt_out", updateDialogNodeOptions.newDisambiguationOptOut());
    }
    builder.bodyJson(contentJson);
    ResponseConverter<DialogNode> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DialogNode>() {
    }.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) DialogNode(com.ibm.watson.assistant.v1.model.DialogNode)

Example 94 with RequestBuilder

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

the class Assistant method updateEntity.

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

Example 95 with RequestBuilder

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

the class Assistant method deleteEntity.

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