Search in sources :

Example 56 with RequestBuilder

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

the class Assistant method listIntents.

/**
 * List intents.
 *
 * List the intents for a workspace. With **export**=`false`, this operation is limited to 2000 requests per 30
 * minutes. With **export**=`true`, the limit is 400 requests per 30 minutes. For more information, see **Rate
 * limiting**.
 *
 * @param listIntentsOptions the {@link ListIntentsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link IntentCollection}
 */
public ServiceCall<IntentCollection> listIntents(ListIntentsOptions listIntentsOptions) {
    Validator.notNull(listIntentsOptions, "listIntentsOptions cannot be null");
    String[] pathSegments = { "v1/workspaces", "intents" };
    String[] pathParameters = { listIntentsOptions.workspaceId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    if (listIntentsOptions.export() != null) {
        builder.query("export", String.valueOf(listIntentsOptions.export()));
    }
    if (listIntentsOptions.pageLimit() != null) {
        builder.query("page_limit", String.valueOf(listIntentsOptions.pageLimit()));
    }
    if (listIntentsOptions.includeCount() != null) {
        builder.query("include_count", String.valueOf(listIntentsOptions.includeCount()));
    }
    if (listIntentsOptions.sort() != null) {
        builder.query("sort", listIntentsOptions.sort());
    }
    if (listIntentsOptions.cursor() != null) {
        builder.query("cursor", listIntentsOptions.cursor());
    }
    if (listIntentsOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(listIntentsOptions.includeAudit()));
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IntentCollection.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) IntentCollection(com.ibm.watson.developer_cloud.assistant.v1.model.IntentCollection)

Example 57 with RequestBuilder

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

the class Assistant method createWorkspace.

/**
 * Create workspace.
 *
 * Create a workspace based on component objects. You must provide workspace components defining the content of the
 * new workspace. This operation is limited to 30 requests per 30 minutes. For more information, see **Rate
 * limiting**.
 *
 * @param createWorkspaceOptions the {@link CreateWorkspaceOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Workspace}
 */
public ServiceCall<Workspace> createWorkspace(CreateWorkspaceOptions createWorkspaceOptions) {
    String[] pathSegments = { "v1/workspaces" };
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    builder.query(VERSION, versionDate);
    if (createWorkspaceOptions != null) {
        final JsonObject contentJson = new JsonObject();
        if (createWorkspaceOptions.name() != null) {
            contentJson.addProperty("name", createWorkspaceOptions.name());
        }
        if (createWorkspaceOptions.description() != null) {
            contentJson.addProperty("description", createWorkspaceOptions.description());
        }
        if (createWorkspaceOptions.language() != null) {
            contentJson.addProperty("language", createWorkspaceOptions.language());
        }
        if (createWorkspaceOptions.intents() != null) {
            contentJson.add("intents", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.intents()));
        }
        if (createWorkspaceOptions.entities() != null) {
            contentJson.add("entities", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.entities()));
        }
        if (createWorkspaceOptions.dialogNodes() != null) {
            contentJson.add("dialog_nodes", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.dialogNodes()));
        }
        if (createWorkspaceOptions.counterexamples() != null) {
            contentJson.add("counterexamples", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.counterexamples()));
        }
        if (createWorkspaceOptions.metadata() != null) {
            contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.metadata()));
        }
        if (createWorkspaceOptions.learningOptOut() != null) {
            contentJson.addProperty("learning_opt_out", createWorkspaceOptions.learningOptOut());
        }
        builder.bodyJson(contentJson);
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Workspace.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) JsonObject(com.google.gson.JsonObject) Workspace(com.ibm.watson.developer_cloud.assistant.v1.model.Workspace)

Example 58 with RequestBuilder

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

the class Assistant method updateIntent.

/**
 * Update intent.
 *
 * Update an existing intent with new or modified data. You must provide component objects defining the content of the
 * updated intent. This operation is limited to 2000 requests per 30 minutes. For more information, see **Rate
 * limiting**.
 *
 * @param updateIntentOptions the {@link UpdateIntentOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Intent}
 */
public ServiceCall<Intent> updateIntent(UpdateIntentOptions updateIntentOptions) {
    Validator.notNull(updateIntentOptions, "updateIntentOptions cannot be null");
    String[] pathSegments = { "v1/workspaces", "intents" };
    String[] pathParameters = { updateIntentOptions.workspaceId(), updateIntentOptions.intent() };
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    final JsonObject contentJson = new JsonObject();
    if (updateIntentOptions.newIntent() != null) {
        contentJson.addProperty("intent", updateIntentOptions.newIntent());
    }
    if (updateIntentOptions.newExamples() != null) {
        contentJson.add("examples", GsonSingleton.getGson().toJsonTree(updateIntentOptions.newExamples()));
    }
    if (updateIntentOptions.newDescription() != null) {
        contentJson.addProperty("description", updateIntentOptions.newDescription());
    }
    builder.bodyJson(contentJson);
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Intent.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) JsonObject(com.google.gson.JsonObject) Intent(com.ibm.watson.developer_cloud.assistant.v1.model.Intent)

Example 59 with RequestBuilder

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

the class Assistant method updateEntity.

/**
 * Update entity.
 *
 * Update an existing entity with new or modified data. You must provide component objects defining the content of the
 * updated entity. This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate
 * limiting**.
 *
 * @param updateEntityOptions the {@link UpdateEntityOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Entity}
 */
public ServiceCall<Entity> updateEntity(UpdateEntityOptions updateEntityOptions) {
    Validator.notNull(updateEntityOptions, "updateEntityOptions cannot be null");
    String[] pathSegments = { "v1/workspaces", "entities" };
    String[] pathParameters = { updateEntityOptions.workspaceId(), updateEntityOptions.entity() };
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    final JsonObject contentJson = new JsonObject();
    if (updateEntityOptions.newFuzzyMatch() != null) {
        contentJson.addProperty("fuzzy_match", updateEntityOptions.newFuzzyMatch());
    }
    if (updateEntityOptions.newEntity() != null) {
        contentJson.addProperty("entity", updateEntityOptions.newEntity());
    }
    if (updateEntityOptions.newMetadata() != null) {
        contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateEntityOptions.newMetadata()));
    }
    if (updateEntityOptions.newValues() != null) {
        contentJson.add("values", GsonSingleton.getGson().toJsonTree(updateEntityOptions.newValues()));
    }
    if (updateEntityOptions.newDescription() != null) {
        contentJson.addProperty("description", updateEntityOptions.newDescription());
    }
    builder.bodyJson(contentJson);
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Entity.class));
}
Also used : Entity(com.ibm.watson.developer_cloud.assistant.v1.model.Entity) RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) JsonObject(com.google.gson.JsonObject)

Example 60 with RequestBuilder

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

the class Assistant method createSynonym.

/**
 * Add entity value synonym.
 *
 * Add a new synonym to an entity value. This operation is limited to 1000 requests per 30 minutes. For more
 * information, see **Rate limiting**.
 *
 * @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Synonym}
 */
public ServiceCall<Synonym> createSynonym(CreateSynonymOptions createSynonymOptions) {
    Validator.notNull(createSynonymOptions, "createSynonymOptions cannot be null");
    String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" };
    String[] pathParameters = { createSynonymOptions.workspaceId(), createSynonymOptions.entity(), createSynonymOptions.value() };
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    final JsonObject contentJson = new JsonObject();
    contentJson.addProperty("synonym", createSynonymOptions.synonym());
    builder.bodyJson(contentJson);
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) JsonObject(com.google.gson.JsonObject) Synonym(com.ibm.watson.developer_cloud.assistant.v1.model.Synonym)

Aggregations

RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)206 JsonObject (com.google.gson.JsonObject)60 MultipartBody (okhttp3.MultipartBody)10 RequestBody (okhttp3.RequestBody)10 Counterexample (com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample)3 DialogNode (com.ibm.watson.developer_cloud.assistant.v1.model.DialogNode)3 Example (com.ibm.watson.developer_cloud.assistant.v1.model.Example)3 Synonym (com.ibm.watson.developer_cloud.assistant.v1.model.Synonym)3 Counterexample (com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample)3 DialogNode (com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode)3 Example (com.ibm.watson.developer_cloud.conversation.v1.model.Example)3 Synonym (com.ibm.watson.developer_cloud.conversation.v1.model.Synonym)3 Collection (com.ibm.watson.developer_cloud.discovery.v1.model.Collection)3 Configuration (com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)3 Environment (com.ibm.watson.developer_cloud.discovery.v1.model.Environment)3 Entity (com.ibm.watson.developer_cloud.assistant.v1.model.Entity)2 Intent (com.ibm.watson.developer_cloud.assistant.v1.model.Intent)2 LogCollection (com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection)2 Value (com.ibm.watson.developer_cloud.assistant.v1.model.Value)2 Workspace (com.ibm.watson.developer_cloud.assistant.v1.model.Workspace)2