Search in sources :

Example 6 with GetIntentOptions

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

the class Assistant method getIntent.

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

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 Intent (com.ibm.watson.assistant.v1.model.Intent)2 CreateIntentOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntentOptions)2 DeleteIntentOptions (com.ibm.watson.developer_cloud.assistant.v1.model.DeleteIntentOptions)2 GetIntentOptions (com.ibm.watson.developer_cloud.assistant.v1.model.GetIntentOptions)2 CreateIntentOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntentOptions)2 DeleteIntentOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteIntentOptions)2 GetIntentOptions (com.ibm.watson.developer_cloud.conversation.v1.model.GetIntentOptions)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 CreateIntent (com.ibm.watson.assistant.v1.model.CreateIntent)1 GetIntentOptions (com.ibm.watson.assistant.v1.model.GetIntentOptions)1 RuntimeIntent (com.ibm.watson.assistant.v1.model.RuntimeIntent)1 CreateExample (com.ibm.watson.developer_cloud.assistant.v1.model.CreateExample)1 Example (com.ibm.watson.developer_cloud.assistant.v1.model.Example)1 IntentExport (com.ibm.watson.developer_cloud.assistant.v1.model.IntentExport)1 CreateExample (com.ibm.watson.developer_cloud.conversation.v1.model.CreateExample)1