@Test public void testListLogEntriesAsync() throws ExecutionException, InterruptedException { String cursor = "cursor"; EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build(); List<LogEntry> entriesList = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2); ListLogEntriesResponse response = ListLogEntriesResponse.newBuilder() .setNextPageToken(cursor) .addAllEntries(Lists.transform(entriesList, LogEntry.toPbFunction(PROJECT))) .build(); ApiFuture<ListLogEntriesResponse> futureResponse = ApiFutures.immediateFuture(response); EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse); EasyMock.replay(loggingRpcMock); AsyncPage<LogEntry> page = logging.listLogEntriesAsync().get(); assertEquals(cursor, page.getNextPageToken()); assertArrayEquals(entriesList.toArray(), Iterables.toArray(page.getValues(), LogEntry.class)); }
bitField0_ = (bitField0_ & ~0x00000001); } else { ensureProjectIdsIsMutable(); projectIds_.addAll(other.projectIds_); onChanged(); bitField0_ = (bitField0_ & ~0x00000002); } else { ensureResourceNamesIsMutable(); resourceNames_.addAll(other.resourceNames_); onChanged(); onChanged(); onChanged(); setPageSize(other.getPageSize()); onChanged(); this.mergeUnknownFields(other.unknownFields); onChanged(); return this;
ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder() .addAllResourceNames(resourceNames) .setFilter(filter) .setOrderBy(orderBy) .build(); return listLogEntries(request);
static ListLogEntriesRequest listLogEntriesRequest( String projectId, Map<Option.OptionType, ?> options) { ListLogEntriesRequest.Builder builder = ListLogEntriesRequest.newBuilder(); builder.addProjectIds(projectId); Integer pageSize = PAGE_SIZE.get(options); if (pageSize != null) { builder.setPageSize(pageSize); } String pageToken = PAGE_TOKEN.get(options); if (pageToken != null) { builder.setPageToken(pageToken); } String orderBy = ORDER_BY.get(options); if (orderBy != null) { builder.setOrderBy(orderBy); } String filter = FILTER.get(options); if (filter != null) { builder.setFilter(filter); } return builder.build(); }
@Override public ListLogEntriesRequest injectToken(ListLogEntriesRequest payload, String token) { return ListLogEntriesRequest.newBuilder(payload).setPageToken(token).build(); }
@Override public ListLogEntriesRequest injectPageSize( ListLogEntriesRequest payload, int pageSize) { return ListLogEntriesRequest.newBuilder(payload).setPageSize(pageSize).build(); }
ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder() .addAllResourceNames(resourceNames) .setFilter(filter) .setOrderBy(orderBy) .build(); return listLogEntries(request);
logging = options.getService(); ListLogEntriesRequest request1 = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build(); ListLogEntriesRequest request2 = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).setPageToken(cursor1).build(); List<LogEntry> descriptorList1 = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2); List<LogEntry> descriptorList2 = ImmutableList.of(LOG_ENTRY1);
logging = options.getService(); ListLogEntriesRequest request1 = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build(); ListLogEntriesRequest request2 = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).setPageToken(cursor1).build(); List<LogEntry> descriptorList1 = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2); List<LogEntry> descriptorList2 = ImmutableList.of(LOG_ENTRY1);
@Test public void testListLogEntriesAsyncWithOptions() throws ExecutionException, InterruptedException { String cursor = "cursor"; EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder() .addProjectIds(PROJECT) .setOrderBy("timestamp desc") .setFilter("logName:syslog") .build(); List<LogEntry> entriesList = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2); ListLogEntriesResponse response = ListLogEntriesResponse.newBuilder() .setNextPageToken(cursor) .addAllEntries(Lists.transform(entriesList, LogEntry.toPbFunction(PROJECT))) .build(); ApiFuture<ListLogEntriesResponse> futureResponse = ApiFutures.immediateFuture(response); EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse); EasyMock.replay(loggingRpcMock); AsyncPage<LogEntry> page = logging .listLogEntriesAsync( EntryListOption.filter("logName:syslog"), EntryListOption.sortOrder(SortingField.TIMESTAMP, Logging.SortingOrder.DESCENDING)) .get(); assertEquals(cursor, page.getNextPageToken()); assertArrayEquals(entriesList.toArray(), Iterables.toArray(page.getValues(), LogEntry.class)); }
@Test public void testListLogEntriesWithOptions() { String cursor = "cursor"; EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder() .addProjectIds(PROJECT) .setOrderBy("timestamp desc") .setFilter("logName:syslog") .build(); List<LogEntry> entriesList = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2); ListLogEntriesResponse response = ListLogEntriesResponse.newBuilder() .setNextPageToken(cursor) .addAllEntries(Lists.transform(entriesList, LogEntry.toPbFunction(PROJECT))) .build(); ApiFuture<ListLogEntriesResponse> futureResponse = ApiFutures.immediateFuture(response); EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse); EasyMock.replay(loggingRpcMock); Page<LogEntry> page = logging.listLogEntries( EntryListOption.filter("logName:syslog"), EntryListOption.sortOrder(SortingField.TIMESTAMP, Logging.SortingOrder.DESCENDING)); assertEquals(cursor, page.getNextPageToken()); assertArrayEquals(entriesList.toArray(), Iterables.toArray(page.getValues(), LogEntry.class)); }
/** * * * <pre> * Deprecated. Use `resource_names` instead. One or more project identifiers * or project numbers from which to retrieve log entries. Example: * `"my-project-1A"`. If present, these project identifiers are converted to * resource name format and added to the list of resources in * `resource_names`. * </pre> * * <code>repeated string project_ids = 1 [deprecated = true];</code> */ @java.lang.Deprecated public Builder addProjectIds(java.lang.String value) { if (value == null) { throw new NullPointerException(); } ensureProjectIdsIsMutable(); projectIds_.add(value); onChanged(); return this; } /**
/** * * * <pre> * Deprecated. Use `resource_names` instead. One or more project identifiers * or project numbers from which to retrieve log entries. Example: * `"my-project-1A"`. If present, these project identifiers are converted to * resource name format and added to the list of resources in * `resource_names`. * </pre> * * <code>repeated string project_ids = 1 [deprecated = true];</code> */ @java.lang.Deprecated public Builder setProjectIds(int index, java.lang.String value) { if (value == null) { throw new NullPointerException(); } ensureProjectIdsIsMutable(); projectIds_.set(index, value); onChanged(); return this; } /**
/** * * * <pre> * Deprecated. Use `resource_names` instead. One or more project identifiers * or project numbers from which to retrieve log entries. Example: * `"my-project-1A"`. If present, these project identifiers are converted to * resource name format and added to the list of resources in * `resource_names`. * </pre> * * <code>repeated string project_ids = 1 [deprecated = true];</code> */ @java.lang.Deprecated public Builder addProjectIdsBytes(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); ensureProjectIdsIsMutable(); projectIds_.add(value); onChanged(); return this; }
@Test public void testListLogEntries() { String cursor = "cursor"; EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build(); List<LogEntry> entriesList = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2); ListLogEntriesResponse response = ListLogEntriesResponse.newBuilder() .setNextPageToken(cursor) .addAllEntries(Lists.transform(entriesList, LogEntry.toPbFunction(PROJECT))) .build(); ApiFuture<ListLogEntriesResponse> futureResponse = ApiFutures.immediateFuture(response); EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse); EasyMock.replay(loggingRpcMock); Page<LogEntry> page = logging.listLogEntries(); assertEquals(cursor, page.getNextPageToken()); assertArrayEquals(entriesList.toArray(), Iterables.toArray(page.getValues(), LogEntry.class)); }
/** * * * <pre> * Deprecated. Use `resource_names` instead. One or more project identifiers * or project numbers from which to retrieve log entries. Example: * `"my-project-1A"`. If present, these project identifiers are converted to * resource name format and added to the list of resources in * `resource_names`. * </pre> * * <code>repeated string project_ids = 1 [deprecated = true];</code> */ @java.lang.Deprecated public Builder addAllProjectIds(java.lang.Iterable<java.lang.String> values) { ensureProjectIdsIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll(values, projectIds_); onChanged(); return this; } /**
@Test public void testListLogEntriesEmpty() { String cursor = "cursor"; EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build(); List<LogEntry> entriesList = ImmutableList.of(); ListLogEntriesResponse response = ListLogEntriesResponse.newBuilder() .setNextPageToken(cursor) .addAllEntries(Lists.transform(entriesList, LogEntry.toPbFunction(PROJECT))) .build(); ApiFuture<ListLogEntriesResponse> futureResponse = ApiFutures.immediateFuture(response); EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse); EasyMock.replay(loggingRpcMock); Page<LogEntry> page = logging.listLogEntries(); assertEquals(cursor, page.getNextPageToken()); assertArrayEquals(entriesList.toArray(), Iterables.toArray(page.getValues(), LogEntry.class)); }
@Test public void testListLogEntriesAyncEmpty() throws ExecutionException, InterruptedException { String cursor = "cursor"; EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build(); List<LogEntry> entriesList = ImmutableList.of(); ListLogEntriesResponse response = ListLogEntriesResponse.newBuilder() .setNextPageToken(cursor) .addAllEntries(Lists.transform(entriesList, LogEntry.toPbFunction(PROJECT))) .build(); ApiFuture<ListLogEntriesResponse> futureResponse = ApiFutures.immediateFuture(response); EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse); EasyMock.replay(loggingRpcMock); AsyncPage<LogEntry> page = logging.listLogEntriesAsync().get(); assertEquals(cursor, page.getNextPageToken()); assertArrayEquals(entriesList.toArray(), Iterables.toArray(page.getValues(), LogEntry.class)); }
static ListLogEntriesRequest listLogEntriesRequest( String projectId, Map<Option.OptionType, ?> options) { ListLogEntriesRequest.Builder builder = ListLogEntriesRequest.newBuilder(); builder.addProjectIds(projectId); Integer pageSize = PAGE_SIZE.get(options); if (pageSize != null) { builder.setPageSize(pageSize); } String pageToken = PAGE_TOKEN.get(options); if (pageToken != null) { builder.setPageToken(pageToken); } String orderBy = ORDER_BY.get(options); if (orderBy != null) { builder.setOrderBy(orderBy); } String filter = FILTER.get(options); if (filter != null) { builder.setFilter(filter); } return builder.build(); }