Search in sources :

Example 6 with ListIntentsOptions

use of com.ibm.watson.assistant.v1.model.ListIntentsOptions in project java-sdk by watson-developer-cloud.

the class Assistant method listIntents.

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

Aggregations

NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)4 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)4 Test (org.junit.Test)4 IntentCollection (com.ibm.watson.assistant.v1.model.IntentCollection)2 CreateIntentOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntentOptions)2 DeleteIntentOptions (com.ibm.watson.developer_cloud.assistant.v1.model.DeleteIntentOptions)2 IntentCollection (com.ibm.watson.developer_cloud.assistant.v1.model.IntentCollection)2 ListIntentsOptions (com.ibm.watson.developer_cloud.assistant.v1.model.ListIntentsOptions)2 CreateIntentOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntentOptions)2 DeleteIntentOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteIntentOptions)2 IntentCollection (com.ibm.watson.developer_cloud.conversation.v1.model.IntentCollection)2 ListIntentsOptions (com.ibm.watson.developer_cloud.conversation.v1.model.ListIntentsOptions)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 ListIntentsOptions (com.ibm.watson.assistant.v1.model.ListIntentsOptions)1 CreateExample (com.ibm.watson.developer_cloud.assistant.v1.model.CreateExample)1 IntentExport (com.ibm.watson.developer_cloud.assistant.v1.model.IntentExport)1 CreateExample (com.ibm.watson.developer_cloud.conversation.v1.model.CreateExample)1 IntentExport (com.ibm.watson.developer_cloud.conversation.v1.model.IntentExport)1