Search in sources :

Example 6 with WorkspaceCollection

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

the class Conversation method listWorkspaces.

/**
 * List workspaces.
 *
 * List the workspaces associated with a Conversation service instance.
 *
 * @param listWorkspacesOptions the {@link ListWorkspacesOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection}
 */
public ServiceCall<WorkspaceCollection> listWorkspaces(ListWorkspacesOptions listWorkspacesOptions) {
    String[] pathSegments = { "v1/workspaces" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    builder.query(VERSION, versionDate);
    if (listWorkspacesOptions != null) {
        if (listWorkspacesOptions.pageLimit() != null) {
            builder.query("page_limit", String.valueOf(listWorkspacesOptions.pageLimit()));
        }
        if (listWorkspacesOptions.includeCount() != null) {
            builder.query("include_count", String.valueOf(listWorkspacesOptions.includeCount()));
        }
        if (listWorkspacesOptions.sort() != null) {
            builder.query("sort", listWorkspacesOptions.sort());
        }
        if (listWorkspacesOptions.cursor() != null) {
            builder.query("cursor", listWorkspacesOptions.cursor());
        }
        if (listWorkspacesOptions.includeAudit() != null) {
            builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit()));
        }
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceCollection.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) WorkspaceCollection(com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceCollection)

Example 7 with WorkspaceCollection

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

the class Assistant method listWorkspaces.

/**
 * List workspaces.
 *
 * List the workspaces associated with an Assistant service instance. This operation is limited to 500 requests per 30
 * minutes. For more information, see **Rate limiting**.
 *
 * @param listWorkspacesOptions the {@link ListWorkspacesOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection}
 */
public ServiceCall<WorkspaceCollection> listWorkspaces(ListWorkspacesOptions listWorkspacesOptions) {
    String[] pathSegments = { "v1/workspaces" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    builder.query(VERSION, versionDate);
    if (listWorkspacesOptions != null) {
        if (listWorkspacesOptions.pageLimit() != null) {
            builder.query("page_limit", String.valueOf(listWorkspacesOptions.pageLimit()));
        }
        if (listWorkspacesOptions.includeCount() != null) {
            builder.query("include_count", String.valueOf(listWorkspacesOptions.includeCount()));
        }
        if (listWorkspacesOptions.sort() != null) {
            builder.query("sort", listWorkspacesOptions.sort());
        }
        if (listWorkspacesOptions.cursor() != null) {
            builder.query("cursor", listWorkspacesOptions.cursor());
        }
        if (listWorkspacesOptions.includeAudit() != null) {
            builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit()));
        }
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceCollection.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) WorkspaceCollection(com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceCollection)

Example 8 with WorkspaceCollection

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

the class Assistant method listWorkspaces.

/**
 * List workspaces.
 *
 * <p>List the workspaces associated with a Watson Assistant service instance.
 *
 * @param listWorkspacesOptions the {@link ListWorkspacesOptions} containing the options for the
 *     call
 * @return a {@link ServiceCall} with a result of type {@link WorkspaceCollection}
 */
public ServiceCall<WorkspaceCollection> listWorkspaces(ListWorkspacesOptions listWorkspacesOptions) {
    if (listWorkspacesOptions == null) {
        listWorkspacesOptions = new ListWorkspacesOptions.Builder().build();
    }
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listWorkspaces");
    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 (listWorkspacesOptions.pageLimit() != null) {
        builder.query("page_limit", String.valueOf(listWorkspacesOptions.pageLimit()));
    }
    if (listWorkspacesOptions.includeCount() != null) {
        builder.query("include_count", String.valueOf(listWorkspacesOptions.includeCount()));
    }
    if (listWorkspacesOptions.sort() != null) {
        builder.query("sort", String.valueOf(listWorkspacesOptions.sort()));
    }
    if (listWorkspacesOptions.cursor() != null) {
        builder.query("cursor", String.valueOf(listWorkspacesOptions.cursor()));
    }
    if (listWorkspacesOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit()));
    }
    ResponseConverter<WorkspaceCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<WorkspaceCollection>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) WorkspaceCollection(com.ibm.watson.assistant.v1.model.WorkspaceCollection)

Aggregations

Test (org.junit.Test)4 WorkspaceCollection (com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceCollection)3 WorkspaceCollection (com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceCollection)3 WorkspaceCollection (com.ibm.watson.assistant.v1.model.WorkspaceCollection)2 ListWorkspacesOptions (com.ibm.watson.developer_cloud.assistant.v1.model.ListWorkspacesOptions)2 ListWorkspacesOptions (com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions)2 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 ListWorkspacesOptions (com.ibm.watson.assistant.v1.model.ListWorkspacesOptions)1 Workspace (com.ibm.watson.developer_cloud.assistant.v1.model.Workspace)1 Workspace (com.ibm.watson.developer_cloud.conversation.v1.model.Workspace)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.testng.annotations.Test)1