Search in sources :

Example 1 with LogCollection

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

the class Conversation method listLogs.

/**
 * List log events in a workspace.
 *
 * List log events in a specific workspace.
 *
 * @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.conversation.v1.model.LogCollection)

Example 2 with LogCollection

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

the class AssistantServiceIT method testListLogs.

/**
 * Test listLogs.
 */
@Test
public void testListLogs() {
    try {
        ListLogsOptions listOptions = new ListLogsOptions.Builder().workspaceId(workspaceId).build();
        LogCollection response = service.listLogs(listOptions).execute();
        assertNotNull(response);
        assertNotNull(response.getLogs());
        assertNotNull(response.getPagination());
        // nextUrl may be null
        if (response.getPagination().getNextUrl() == null) {
            assertNull(response.getPagination().getCursor());
        } else {
            assertNotNull(response.getPagination().getCursor());
        }
    } catch (Exception ex) {
        fail(ex.getMessage());
    }
}
Also used : ListLogsOptions(com.ibm.watson.developer_cloud.assistant.v1.model.ListLogsOptions) LogCollection(com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 3 with LogCollection

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

the class Assistant method listAllLogs.

/**
 * List log events in all workspaces.
 *
 * List the events from the logs of all workspaces in the service instance. 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 listAllLogsOptions the {@link ListAllLogsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link LogCollection}
 */
public ServiceCall<LogCollection> listAllLogs(ListAllLogsOptions listAllLogsOptions) {
    Validator.notNull(listAllLogsOptions, "listAllLogsOptions cannot be null");
    String[] pathSegments = { "v1/logs" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    builder.query(VERSION, versionDate);
    builder.query("filter", listAllLogsOptions.filter());
    if (listAllLogsOptions.sort() != null) {
        builder.query("sort", listAllLogsOptions.sort());
    }
    if (listAllLogsOptions.pageLimit() != null) {
        builder.query("page_limit", String.valueOf(listAllLogsOptions.pageLimit()));
    }
    if (listAllLogsOptions.cursor() != null) {
        builder.query("cursor", listAllLogsOptions.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)

Example 4 with LogCollection

use of com.ibm.watson.developer_cloud.conversation.v1.model.LogCollection 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)

Example 5 with LogCollection

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

the class AssistantServiceIT method testListLogsWithPaging.

/**
 * Test listLogs with pagination.
 */
@Test
@Ignore("To be run locally until we fix the Rate limitation issue")
public void testListLogsWithPaging() {
    try {
        ListLogsOptions.Builder listOptionsBuilder = new ListLogsOptions.Builder(workspaceId);
        listOptionsBuilder.sort("-request_timestamp");
        listOptionsBuilder.filter("request.intents:intent:off_topic");
        listOptionsBuilder.pageLimit(1L);
        LogCollection response = service.listLogs(listOptionsBuilder.build()).execute();
        assertNotNull(response);
        assertNotNull(response.getLogs());
        assertNotNull(response.getPagination());
        // Empirically -- no refresh_url in pagination of listLogs
        // assertNotNull(response.getPagination().getRefreshUrl());
        assertNotNull(response.getPagination().getNextUrl());
        assertNotNull(response.getPagination().getCursor());
        assertTrue(response.getLogs().size() == 1);
        LogExport logEntry1 = response.getLogs().get(0);
        String cursor = response.getPagination().getCursor();
        response = service.listLogs(listOptionsBuilder.cursor(cursor).build()).execute();
        assertNotNull(response.getLogs());
        assertTrue(response.getLogs().size() == 1);
        LogExport logEntry2 = response.getLogs().get(0);
        Date requestDate1 = isoDateFormat.parse(logEntry1.getRequestTimestamp());
        Date requestDate2 = isoDateFormat.parse(logEntry2.getRequestTimestamp());
        assertTrue(requestDate2.before(requestDate1));
    } catch (Exception ex) {
        fail(ex.getMessage());
    }
}
Also used : ListLogsOptions(com.ibm.watson.developer_cloud.assistant.v1.model.ListLogsOptions) LogCollection(com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection) LogExport(com.ibm.watson.developer_cloud.assistant.v1.model.LogExport) Date(java.util.Date) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

LogCollection (com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection)4 LogCollection (com.ibm.watson.developer_cloud.conversation.v1.model.LogCollection)4 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)4 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 ListLogsOptions (com.ibm.watson.developer_cloud.assistant.v1.model.ListLogsOptions)2 ListLogsOptions (com.ibm.watson.developer_cloud.conversation.v1.model.ListLogsOptions)2 Date (java.util.Date)2 Ignore (org.junit.Ignore)2 LogExport (com.ibm.watson.developer_cloud.assistant.v1.model.LogExport)1 LogExport (com.ibm.watson.developer_cloud.conversation.v1.model.LogExport)1