Search in sources :

Example 6 with Workspace

use of com.ibm.watson.developer_cloud.assistant.v1.model.Workspace 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 7 with Workspace

use of com.ibm.watson.developer_cloud.assistant.v1.model.Workspace 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 8 with Workspace

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

the class Assistant method listEntities.

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

Example 9 with Workspace

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

the class Assistant method getWorkspace.

/**
 * Get information about a workspace.
 *
 * Get information about a workspace, optionally including all workspace content. With **export**=`false`, this
 * operation is limited to 6000 requests per 5 minutes. With **export**=`true`, the limit is 20 requests per 30
 * minutes. For more information, see **Rate limiting**.
 *
 * @param getWorkspaceOptions the {@link GetWorkspaceOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link WorkspaceExport}
 */
public ServiceCall<WorkspaceExport> getWorkspace(GetWorkspaceOptions getWorkspaceOptions) {
    Validator.notNull(getWorkspaceOptions, "getWorkspaceOptions cannot be null");
    String[] pathSegments = { "v1/workspaces" };
    String[] pathParameters = { getWorkspaceOptions.workspaceId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    if (getWorkspaceOptions.export() != null) {
        builder.query("export", String.valueOf(getWorkspaceOptions.export()));
    }
    if (getWorkspaceOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(getWorkspaceOptions.includeAudit()));
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceExport.class));
}
Also used : WorkspaceExport(com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceExport) RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder)

Example 10 with Workspace

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

the class Assistant method listLogs.

/**
 * List log events in a workspace.
 *
 * List the events from the log of a specific workspace. If **cursor** is not specified, this operation is limited to
 * 40 requests per 30 minutes. If **cursor** is specified, the limit is 120 requests per minute. For more information,
 * see **Rate limiting**.
 *
 * @param listLogsOptions the {@link ListLogsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link LogCollection}
 */
public ServiceCall<LogCollection> listLogs(ListLogsOptions listLogsOptions) {
    Validator.notNull(listLogsOptions, "listLogsOptions cannot be null");
    String[] pathSegments = { "v1/workspaces", "logs" };
    String[] pathParameters = { listLogsOptions.workspaceId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    if (listLogsOptions.sort() != null) {
        builder.query("sort", listLogsOptions.sort());
    }
    if (listLogsOptions.filter() != null) {
        builder.query("filter", listLogsOptions.filter());
    }
    if (listLogsOptions.pageLimit() != null) {
        builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit()));
    }
    if (listLogsOptions.cursor() != null) {
        builder.query("cursor", listLogsOptions.cursor());
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LogCollection.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) LogCollection(com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection)

Aggregations

RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)11 Test (org.junit.Test)9 Workspace (com.ibm.watson.developer_cloud.assistant.v1.model.Workspace)6 Workspace (com.ibm.watson.developer_cloud.conversation.v1.model.Workspace)6 NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)6 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)6 JsonObject (com.google.gson.JsonObject)5 CreateWorkspaceOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateWorkspaceOptions)3 DeleteWorkspaceOptions (com.ibm.watson.developer_cloud.assistant.v1.model.DeleteWorkspaceOptions)3 CreateWorkspaceOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateWorkspaceOptions)3 DeleteWorkspaceOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteWorkspaceOptions)3 HashMap (java.util.HashMap)3 Counterexample (com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample)2 CreateCounterexample (com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample)2 CreateEntity (com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntity)2 CreateIntent (com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntent)2 GetWorkspaceOptions (com.ibm.watson.developer_cloud.assistant.v1.model.GetWorkspaceOptions)2 MessageOptions (com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions)2 WorkspaceExport (com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceExport)2 CreateCounterexample (com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample)2