listLogE
* Sample code:
*
* try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
- * .build();
- * for (MonitoredResourceDescriptor element : loggingServiceV2Api.listMonitoredResourceDescriptors(request)) {
+ * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder().build();
+ * for (MonitoredResourceDescriptor element : loggingServiceV2Api.listMonitoredResourceDescriptors(request).iterateAllElements()) {
* // doThingsWith(element);
* }
* }
@@ -532,8 +540,10 @@ public final ApiCallable listLogE
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final PageAccessor listMonitoredResourceDescriptors(
- ListMonitoredResourceDescriptorsRequest request) {
+ public final PagedListResponse<
+ ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
+ MonitoredResourceDescriptor>
+ listMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest request) {
return listMonitoredResourceDescriptorsPagedCallable().call(request);
}
@@ -544,18 +554,20 @@ public final PageAccessor listMonitoredResourceDesc
* Sample code:
*
* try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
- * .build();
- * ListenableFuture<PageAccessor<MonitoredResourceDescriptor>> future = loggingServiceV2Api.listMonitoredResourceDescriptorsPagedCallable().futureCall(request);
+ * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder().build();
+ * ListenableFuture<PagedListResponse<ListMonitoredResourceDescriptorsRequest,ListMonitoredResourceDescriptorsResponse,MonitoredResourceDescriptor>> future = loggingServiceV2Api.listMonitoredResourceDescriptorsPagedCallable().futureCall(request);
* // Do something
- * for (MonitoredResourceDescriptor element : future.get()) {
+ * for (MonitoredResourceDescriptor element : future.get().iterateAllElements()) {
* // doThingsWith(element);
* }
* }
*
*/
public final ApiCallable<
- ListMonitoredResourceDescriptorsRequest, PageAccessor>
+ ListMonitoredResourceDescriptorsRequest,
+ PagedListResponse<
+ ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
+ MonitoredResourceDescriptor>>
listMonitoredResourceDescriptorsPagedCallable() {
return listMonitoredResourceDescriptorsPagedCallable;
}
@@ -567,8 +579,7 @@ public final PageAccessor listMonitoredResourceDesc
* Sample code:
*
* try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
- * .build();
+ * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder().build();
* while (true) {
* ListMonitoredResourceDescriptorsResponse response = loggingServiceV2Api.listMonitoredResourceDescriptorsCallable().call(request);
* for (MonitoredResourceDescriptor element : response.getResourceDescriptorsList()) {
diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java
index 0e0f4da5e345..360c5970b0c0 100644
--- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java
+++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java
@@ -219,6 +219,17 @@ public ListLogEntriesRequest injectToken(ListLogEntriesRequest payload, Object t
return ListLogEntriesRequest.newBuilder(payload).setPageToken((String) token).build();
}
+ @Override
+ public ListLogEntriesRequest injectPageSize(
+ ListLogEntriesRequest payload, int pageSize) {
+ return ListLogEntriesRequest.newBuilder(payload).setPageSize(pageSize).build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListLogEntriesRequest payload) {
+ return payload.getPageSize();
+ }
+
@Override
public Object extractNextToken(ListLogEntriesResponse payload) {
return payload.getNextPageToken();
@@ -250,6 +261,19 @@ public ListMonitoredResourceDescriptorsRequest injectToken(
.build();
}
+ @Override
+ public ListMonitoredResourceDescriptorsRequest injectPageSize(
+ ListMonitoredResourceDescriptorsRequest payload, int pageSize) {
+ return ListMonitoredResourceDescriptorsRequest.newBuilder(payload)
+ .setPageSize(pageSize)
+ .build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListMonitoredResourceDescriptorsRequest payload) {
+ return payload.getPageSize();
+ }
+
@Override
public Object extractNextToken(ListMonitoredResourceDescriptorsResponse payload) {
return payload.getNextPageToken();
diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java
index 8d76a2579dba..5a1b16237a76 100644
--- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java
+++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java
@@ -13,7 +13,7 @@
*/
package com.google.cloud.logging.spi.v2;
-import com.google.api.gax.core.PageAccessor;
+import com.google.api.gax.core.PagedListResponse;
import com.google.api.gax.grpc.ApiCallable;
import com.google.api.gax.protobuf.PathTemplate;
import com.google.logging.v2.CreateLogMetricRequest;
@@ -91,7 +91,9 @@ public class MetricsServiceV2Api implements AutoCloseable {
private final List closeables = new ArrayList<>();
private final ApiCallable listLogMetricsCallable;
- private final ApiCallable>
+ private final ApiCallable<
+ ListLogMetricsRequest,
+ PagedListResponse>
listLogMetricsPagedCallable;
private final ApiCallable getLogMetricCallable;
private final ApiCallable createLogMetricCallable;
@@ -219,7 +221,7 @@ public void close() throws IOException {
*
* try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
* String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
- * for (LogMetric element : metricsServiceV2Api.listLogMetrics(formattedParent)) {
+ * for (LogMetric element : metricsServiceV2Api.listLogMetrics(formattedParent).iterateAllElements()) {
* // doThingsWith(element);
* }
* }
@@ -229,7 +231,8 @@ public void close() throws IOException {
* Example: `"projects/my-project-id"`.
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final PageAccessor listLogMetrics(String parent) {
+ public final PagedListResponse
+ listLogMetrics(String parent) {
PARENT_PATH_TEMPLATE.validate(parent, "listLogMetrics");
ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder().setParent(parent).build();
return listLogMetrics(request);
@@ -246,7 +249,7 @@ public final PageAccessor listLogMetrics(String parent) {
* ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder()
* .setParent(formattedParent)
* .build();
- * for (LogMetric element : metricsServiceV2Api.listLogMetrics(request)) {
+ * for (LogMetric element : metricsServiceV2Api.listLogMetrics(request).iterateAllElements()) {
* // doThingsWith(element);
* }
* }
@@ -255,7 +258,8 @@ public final PageAccessor listLogMetrics(String parent) {
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final PageAccessor listLogMetrics(ListLogMetricsRequest request) {
+ public final PagedListResponse
+ listLogMetrics(ListLogMetricsRequest request) {
return listLogMetricsPagedCallable().call(request);
}
@@ -270,15 +274,17 @@ public final PageAccessor listLogMetrics(ListLogMetricsRequest reques
* ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder()
* .setParent(formattedParent)
* .build();
- * ListenableFuture<PageAccessor<LogMetric>> future = metricsServiceV2Api.listLogMetricsPagedCallable().futureCall(request);
+ * ListenableFuture<PagedListResponse<ListLogMetricsRequest,ListLogMetricsResponse,LogMetric>> future = metricsServiceV2Api.listLogMetricsPagedCallable().futureCall(request);
* // Do something
- * for (LogMetric element : future.get()) {
+ * for (LogMetric element : future.get().iterateAllElements()) {
* // doThingsWith(element);
* }
* }
*
*/
- public final ApiCallable>
+ public final ApiCallable<
+ ListLogMetricsRequest,
+ PagedListResponse>
listLogMetricsPagedCallable() {
return listLogMetricsPagedCallable;
}
diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java
index 9667eca31176..e48680230dcf 100644
--- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java
+++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java
@@ -217,6 +217,17 @@ public ListLogMetricsRequest injectToken(ListLogMetricsRequest payload, Object t
return ListLogMetricsRequest.newBuilder(payload).setPageToken((String) token).build();
}
+ @Override
+ public ListLogMetricsRequest injectPageSize(
+ ListLogMetricsRequest payload, int pageSize) {
+ return ListLogMetricsRequest.newBuilder(payload).setPageSize(pageSize).build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListLogMetricsRequest payload) {
+ return payload.getPageSize();
+ }
+
@Override
public Object extractNextToken(ListLogMetricsResponse payload) {
return payload.getNextPageToken();
diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/package-info.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/package-info.java
index d683ce334a24..e16b370463dc 100644
--- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/package-info.java
+++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/package-info.java
@@ -17,6 +17,22 @@
*
* The interfaces provided are listed below, along with a usage sample
*
+ * ===================
+ * LoggingServiceV2Api
+ * ===================
+ *
+ * Service Description: Service for ingesting and querying logs.
+ *
+ * Sample for LoggingServiceV2Api:
+ *
+ *
+ * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
+ * String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
+ * loggingServiceV2Api.deleteLog(formattedLogName);
+ * }
+ *
+ *
+ *
* ==================
* ConfigServiceV2Api
* ==================
@@ -50,21 +66,5 @@
*
*
*
- * ===================
- * LoggingServiceV2Api
- * ===================
- *
- * Service Description: Service for ingesting and querying logs.
- *
- * Sample for LoggingServiceV2Api:
- *
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
- * loggingServiceV2Api.deleteLog(formattedLogName);
- * }
- *
- *
- *
*/
package com.google.cloud.logging.spi.v2;
diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/testing/LocalLoggingHelper.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/testing/LocalLoggingHelper.java
index 21c6a7bbecfa..015b31ac6e1c 100644
--- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/testing/LocalLoggingHelper.java
+++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/testing/LocalLoggingHelper.java
@@ -49,7 +49,7 @@ public LocalLoggingHelper(String addressString) {
NettyServerBuilder.forAddress(address)
.flowControlWindow(FLOW_CONTROL_WINDOW)
.channelType(LocalServerChannel.class);
- builder.addService(LoggingServiceV2Grpc.bindService(loggingImpl));
+ builder.addService(loggingImpl.bindService());
server = builder.build();
}
/**
diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/testing/LocalLoggingImpl.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/testing/LocalLoggingImpl.java
index 81e09944f935..044af5d1b257 100644
--- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/testing/LocalLoggingImpl.java
+++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/testing/LocalLoggingImpl.java
@@ -33,7 +33,7 @@
import java.util.List;
import java.util.Map;
-public class LocalLoggingImpl implements LoggingServiceV2Grpc.LoggingServiceV2 {
+public class LocalLoggingImpl extends LoggingServiceV2Grpc.LoggingServiceV2ImplBase {
private Map> logs = new HashMap<>();
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Test.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Test.java
new file mode 100644
index 000000000000..4ea8363a0dd8
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Test.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.api.gax.core.PagedListResponse;
+import com.google.api.gax.testing.MockGrpcService;
+import com.google.api.gax.testing.MockServiceHelper;
+import com.google.common.collect.Lists;
+import com.google.logging.v2.CreateSinkRequest;
+import com.google.logging.v2.DeleteSinkRequest;
+import com.google.logging.v2.GetSinkRequest;
+import com.google.logging.v2.ListSinksRequest;
+import com.google.logging.v2.ListSinksResponse;
+import com.google.logging.v2.LogSink;
+import com.google.logging.v2.UpdateSinkRequest;
+import com.google.protobuf.Empty;
+import com.google.protobuf.GeneratedMessageV3;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@javax.annotation.Generated("by GAPIC")
+public class ConfigServiceV2Test {
+ private static MockLoggingServiceV2 mockLoggingServiceV2;
+ private static MockConfigServiceV2 mockConfigServiceV2;
+ private static MockMetricsServiceV2 mockMetricsServiceV2;
+ private static MockServiceHelper serviceHelper;
+ private ConfigServiceV2Api api;
+
+ @BeforeClass
+ public static void startStaticServer() {
+ mockLoggingServiceV2 = new MockLoggingServiceV2();
+ mockConfigServiceV2 = new MockConfigServiceV2();
+ mockMetricsServiceV2 = new MockMetricsServiceV2();
+ serviceHelper =
+ new MockServiceHelper(
+ "in-process-1",
+ Arrays.asList(
+ mockLoggingServiceV2, mockConfigServiceV2, mockMetricsServiceV2));
+ serviceHelper.start();
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ serviceHelper.stop();
+ }
+
+ @Before
+ public void setUp() throws IOException {
+ serviceHelper.reset();
+ ConfigServiceV2Settings settings =
+ ConfigServiceV2Settings.defaultBuilder()
+ .provideChannelWith(serviceHelper.createChannel(), true)
+ .build();
+ api = ConfigServiceV2Api.create(settings);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ api.close();
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void listSinksTest() {
+ String nextPageToken = "";
+ LogSink sinksElement = LogSink.newBuilder().build();
+ List sinks = Arrays.asList(sinksElement);
+ ListSinksResponse expectedResponse =
+ ListSinksResponse.newBuilder().setNextPageToken(nextPageToken).addAllSinks(sinks).build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockConfigServiceV2.setResponses(expectedResponses);
+
+ String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
+
+ PagedListResponse pagedListResponse =
+ api.listSinks(formattedParent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAllElements());
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
+
+ List actualRequests = mockConfigServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ ListSinksRequest actualRequest = (ListSinksRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedParent, actualRequest.getParent());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void getSinkTest() {
+ String name = "name3373707";
+ String destination = "destination-1429847026";
+ String filter = "filter-1274492040";
+ LogSink expectedResponse =
+ LogSink.newBuilder().setName(name).setDestination(destination).setFilter(filter).build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockConfigServiceV2.setResponses(expectedResponses);
+
+ String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
+
+ LogSink actualResponse = api.getSink(formattedSinkName);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockConfigServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ GetSinkRequest actualRequest = (GetSinkRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedSinkName, actualRequest.getSinkName());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void createSinkTest() {
+ String name = "name3373707";
+ String destination = "destination-1429847026";
+ String filter = "filter-1274492040";
+ LogSink expectedResponse =
+ LogSink.newBuilder().setName(name).setDestination(destination).setFilter(filter).build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockConfigServiceV2.setResponses(expectedResponses);
+
+ String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
+ LogSink sink = LogSink.newBuilder().build();
+
+ LogSink actualResponse = api.createSink(formattedParent, sink);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockConfigServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ CreateSinkRequest actualRequest = (CreateSinkRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedParent, actualRequest.getParent());
+ Assert.assertEquals(sink, actualRequest.getSink());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void updateSinkTest() {
+ String name = "name3373707";
+ String destination = "destination-1429847026";
+ String filter = "filter-1274492040";
+ LogSink expectedResponse =
+ LogSink.newBuilder().setName(name).setDestination(destination).setFilter(filter).build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockConfigServiceV2.setResponses(expectedResponses);
+
+ String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
+ LogSink sink = LogSink.newBuilder().build();
+
+ LogSink actualResponse = api.updateSink(formattedSinkName, sink);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockConfigServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ UpdateSinkRequest actualRequest = (UpdateSinkRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedSinkName, actualRequest.getSinkName());
+ Assert.assertEquals(sink, actualRequest.getSink());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void deleteSinkTest() {
+ Empty expectedResponse = Empty.newBuilder().build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockConfigServiceV2.setResponses(expectedResponses);
+
+ String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
+
+ api.deleteSink(formattedSinkName);
+
+ List actualRequests = mockConfigServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ DeleteSinkRequest actualRequest = (DeleteSinkRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedSinkName, actualRequest.getSinkName());
+ }
+}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2ApiTest.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2ApiTest.java
deleted file mode 100644
index a463cc1c69a3..000000000000
--- a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2ApiTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2015 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.cloud.logging.spi.v2;
-
-import com.google.api.MonitoredResource;
-import com.google.api.gax.core.PageAccessor;
-import com.google.cloud.logging.spi.v2.testing.LocalLoggingHelper;
-import com.google.common.collect.Iterables;
-import com.google.logging.v2.LogEntry;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class LoggingServiceV2ApiTest {
- private static LocalLoggingHelper loggingHelper;
- private LoggingServiceV2Api loggingApi;
-
- @BeforeClass
- public static void startStaticServer() {
- loggingHelper = new LocalLoggingHelper("in-process-1");
- loggingHelper.start();
- }
-
- @AfterClass
- public static void stopServer() {
- loggingHelper.shutdownNow();
- }
-
- @Before
- public void setUp() throws IOException {
- loggingHelper.reset();
- LoggingServiceV2Settings settings = LoggingServiceV2Settings.defaultBuilder()
- .provideChannelWith(loggingHelper.createChannel(), true)
- .build();
- loggingApi = LoggingServiceV2Api.create(settings);
- }
-
- @After
- public void tearDown() throws Exception {
- loggingApi.close();
- }
-
- @Test
- public void testWriteLog() {
- String logName = LoggingServiceV2Api.formatLogName("my-project", "my-log");
- MonitoredResource resource = MonitoredResource.newBuilder().build();
- List entries = new ArrayList<>();
- entries.add(LogEntry.newBuilder().setLogName(logName).setTextPayload("foobar").build());
- loggingApi.writeLogEntries(logName, resource, Collections.emptyMap(), entries);
- }
-
- @Test
- public void testListLog() {
- String logName = LoggingServiceV2Api.formatLogName("my-project", "my-log");
- MonitoredResource resource = MonitoredResource.newBuilder().build();
- List entries = new ArrayList<>();
- entries.add(LogEntry.newBuilder().setLogName(logName).setTextPayload("foobar").build());
- loggingApi.writeLogEntries(logName, resource, Collections.emptyMap(), entries);
-
- PageAccessor gotEntries =
- loggingApi.listLogEntries(Collections.singletonList("my-project"), "", "");
- Assert.assertTrue(Iterables.elementsEqual(entries, gotEntries));
- }
-
- @Test
- public void testListNoLog() {
- PageAccessor entries =
- loggingApi.listLogEntries(Collections.singletonList("my-project"), "", "");
- Assert.assertTrue(Iterables.isEmpty(entries));
- }
-
- @Test
- public void testDeleteLog() {
- String logName = LoggingServiceV2Api.formatLogName("my-project", "my-log");
- MonitoredResource resource = MonitoredResource.newBuilder().build();
- List entries = new ArrayList<>();
- entries.add(LogEntry.newBuilder().setLogName(logName).setTextPayload("foobar").build());
- loggingApi.writeLogEntries(logName, resource, Collections.emptyMap(), entries);
-
- loggingApi.deleteLog(logName);
-
- PageAccessor gotEntries =
- loggingApi.listLogEntries(Collections.singletonList("my-project"), "", "");
- Assert.assertTrue(Iterables.isEmpty(gotEntries));
- }
-}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Test.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Test.java
new file mode 100644
index 000000000000..24e7dcd5d64e
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Test.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.api.MonitoredResource;
+import com.google.api.gax.core.PagedListResponse;
+import com.google.api.gax.testing.MockGrpcService;
+import com.google.api.gax.testing.MockServiceHelper;
+import com.google.common.collect.Lists;
+import com.google.logging.v2.DeleteLogRequest;
+import com.google.logging.v2.ListLogEntriesRequest;
+import com.google.logging.v2.ListLogEntriesResponse;
+import com.google.logging.v2.LogEntry;
+import com.google.logging.v2.WriteLogEntriesRequest;
+import com.google.logging.v2.WriteLogEntriesResponse;
+import com.google.protobuf.Empty;
+import com.google.protobuf.GeneratedMessageV3;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@javax.annotation.Generated("by GAPIC")
+public class LoggingServiceV2Test {
+ private static MockLoggingServiceV2 mockLoggingServiceV2;
+ private static MockConfigServiceV2 mockConfigServiceV2;
+ private static MockMetricsServiceV2 mockMetricsServiceV2;
+ private static MockServiceHelper serviceHelper;
+ private LoggingServiceV2Api api;
+
+ @BeforeClass
+ public static void startStaticServer() {
+ mockLoggingServiceV2 = new MockLoggingServiceV2();
+ mockConfigServiceV2 = new MockConfigServiceV2();
+ mockMetricsServiceV2 = new MockMetricsServiceV2();
+ serviceHelper =
+ new MockServiceHelper(
+ "in-process-1",
+ Arrays.asList(
+ mockLoggingServiceV2, mockConfigServiceV2, mockMetricsServiceV2));
+ serviceHelper.start();
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ serviceHelper.stop();
+ }
+
+ @Before
+ public void setUp() throws IOException {
+ serviceHelper.reset();
+ LoggingServiceV2Settings settings =
+ LoggingServiceV2Settings.defaultBuilder()
+ .provideChannelWith(serviceHelper.createChannel(), true)
+ .build();
+ api = LoggingServiceV2Api.create(settings);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ api.close();
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void deleteLogTest() {
+ Empty expectedResponse = Empty.newBuilder().build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockLoggingServiceV2.setResponses(expectedResponses);
+
+ String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
+
+ api.deleteLog(formattedLogName);
+
+ List actualRequests = mockLoggingServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ DeleteLogRequest actualRequest = (DeleteLogRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedLogName, actualRequest.getLogName());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void writeLogEntriesTest() {
+ WriteLogEntriesResponse expectedResponse = WriteLogEntriesResponse.newBuilder().build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockLoggingServiceV2.setResponses(expectedResponses);
+
+ String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
+ MonitoredResource resource = MonitoredResource.newBuilder().build();
+ Map labels = new HashMap<>();
+ List entries = new ArrayList<>();
+
+ WriteLogEntriesResponse actualResponse =
+ api.writeLogEntries(formattedLogName, resource, labels, entries);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockLoggingServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ WriteLogEntriesRequest actualRequest = (WriteLogEntriesRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedLogName, actualRequest.getLogName());
+ Assert.assertEquals(resource, actualRequest.getResource());
+ Assert.assertEquals(labels, actualRequest.getLabels());
+ Assert.assertEquals(entries, actualRequest.getEntriesList());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void listLogEntriesTest() {
+ String nextPageToken = "";
+ LogEntry entriesElement = LogEntry.newBuilder().build();
+ List entries = Arrays.asList(entriesElement);
+ ListLogEntriesResponse expectedResponse =
+ ListLogEntriesResponse.newBuilder()
+ .setNextPageToken(nextPageToken)
+ .addAllEntries(entries)
+ .build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockLoggingServiceV2.setResponses(expectedResponses);
+
+ List projectIds = new ArrayList<>();
+ String filter = "filter-1274492040";
+ String orderBy = "orderBy1234304744";
+
+ PagedListResponse pagedListResponse =
+ api.listLogEntries(projectIds, filter, orderBy);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAllElements());
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getEntriesList().get(0), resources.get(0));
+
+ List actualRequests = mockLoggingServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ ListLogEntriesRequest actualRequest = (ListLogEntriesRequest) actualRequests.get(0);
+
+ Assert.assertEquals(projectIds, actualRequest.getProjectIdsList());
+ Assert.assertEquals(filter, actualRequest.getFilter());
+ Assert.assertEquals(orderBy, actualRequest.getOrderBy());
+ }
+}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Test.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Test.java
new file mode 100644
index 000000000000..a497c5570804
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Test.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.api.gax.core.PagedListResponse;
+import com.google.api.gax.testing.MockGrpcService;
+import com.google.api.gax.testing.MockServiceHelper;
+import com.google.common.collect.Lists;
+import com.google.logging.v2.CreateLogMetricRequest;
+import com.google.logging.v2.DeleteLogMetricRequest;
+import com.google.logging.v2.GetLogMetricRequest;
+import com.google.logging.v2.ListLogMetricsRequest;
+import com.google.logging.v2.ListLogMetricsResponse;
+import com.google.logging.v2.LogMetric;
+import com.google.logging.v2.UpdateLogMetricRequest;
+import com.google.protobuf.Empty;
+import com.google.protobuf.GeneratedMessageV3;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@javax.annotation.Generated("by GAPIC")
+public class MetricsServiceV2Test {
+ private static MockLoggingServiceV2 mockLoggingServiceV2;
+ private static MockConfigServiceV2 mockConfigServiceV2;
+ private static MockMetricsServiceV2 mockMetricsServiceV2;
+ private static MockServiceHelper serviceHelper;
+ private MetricsServiceV2Api api;
+
+ @BeforeClass
+ public static void startStaticServer() {
+ mockLoggingServiceV2 = new MockLoggingServiceV2();
+ mockConfigServiceV2 = new MockConfigServiceV2();
+ mockMetricsServiceV2 = new MockMetricsServiceV2();
+ serviceHelper =
+ new MockServiceHelper(
+ "in-process-1",
+ Arrays.asList(
+ mockLoggingServiceV2, mockConfigServiceV2, mockMetricsServiceV2));
+ serviceHelper.start();
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ serviceHelper.stop();
+ }
+
+ @Before
+ public void setUp() throws IOException {
+ serviceHelper.reset();
+ MetricsServiceV2Settings settings =
+ MetricsServiceV2Settings.defaultBuilder()
+ .provideChannelWith(serviceHelper.createChannel(), true)
+ .build();
+ api = MetricsServiceV2Api.create(settings);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ api.close();
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void listLogMetricsTest() {
+ String nextPageToken = "";
+ LogMetric metricsElement = LogMetric.newBuilder().build();
+ List metrics = Arrays.asList(metricsElement);
+ ListLogMetricsResponse expectedResponse =
+ ListLogMetricsResponse.newBuilder()
+ .setNextPageToken(nextPageToken)
+ .addAllMetrics(metrics)
+ .build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockMetricsServiceV2.setResponses(expectedResponses);
+
+ String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
+
+ PagedListResponse pagedListResponse =
+ api.listLogMetrics(formattedParent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAllElements());
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getMetricsList().get(0), resources.get(0));
+
+ List actualRequests = mockMetricsServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ ListLogMetricsRequest actualRequest = (ListLogMetricsRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedParent, actualRequest.getParent());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void getLogMetricTest() {
+ String name = "name3373707";
+ String description = "description-1724546052";
+ String filter = "filter-1274492040";
+ LogMetric expectedResponse =
+ LogMetric.newBuilder().setName(name).setDescription(description).setFilter(filter).build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockMetricsServiceV2.setResponses(expectedResponses);
+
+ String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
+
+ LogMetric actualResponse = api.getLogMetric(formattedMetricName);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockMetricsServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ GetLogMetricRequest actualRequest = (GetLogMetricRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedMetricName, actualRequest.getMetricName());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void createLogMetricTest() {
+ String name = "name3373707";
+ String description = "description-1724546052";
+ String filter = "filter-1274492040";
+ LogMetric expectedResponse =
+ LogMetric.newBuilder().setName(name).setDescription(description).setFilter(filter).build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockMetricsServiceV2.setResponses(expectedResponses);
+
+ String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
+ LogMetric metric = LogMetric.newBuilder().build();
+
+ LogMetric actualResponse = api.createLogMetric(formattedParent, metric);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockMetricsServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ CreateLogMetricRequest actualRequest = (CreateLogMetricRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedParent, actualRequest.getParent());
+ Assert.assertEquals(metric, actualRequest.getMetric());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void updateLogMetricTest() {
+ String name = "name3373707";
+ String description = "description-1724546052";
+ String filter = "filter-1274492040";
+ LogMetric expectedResponse =
+ LogMetric.newBuilder().setName(name).setDescription(description).setFilter(filter).build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockMetricsServiceV2.setResponses(expectedResponses);
+
+ String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
+ LogMetric metric = LogMetric.newBuilder().build();
+
+ LogMetric actualResponse = api.updateLogMetric(formattedMetricName, metric);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockMetricsServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ UpdateLogMetricRequest actualRequest = (UpdateLogMetricRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedMetricName, actualRequest.getMetricName());
+ Assert.assertEquals(metric, actualRequest.getMetric());
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void deleteLogMetricTest() {
+ Empty expectedResponse = Empty.newBuilder().build();
+ List expectedResponses = new ArrayList<>();
+ expectedResponses.add(expectedResponse);
+ mockMetricsServiceV2.setResponses(expectedResponses);
+
+ String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
+
+ api.deleteLogMetric(formattedMetricName);
+
+ List actualRequests = mockMetricsServiceV2.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ DeleteLogMetricRequest actualRequest = (DeleteLogMetricRequest) actualRequests.get(0);
+
+ Assert.assertEquals(formattedMetricName, actualRequest.getMetricName());
+ }
+}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockConfigServiceV2.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockConfigServiceV2.java
new file mode 100644
index 000000000000..faf30424ebd5
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockConfigServiceV2.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.api.gax.testing.MockGrpcService;
+import com.google.protobuf.GeneratedMessageV3;
+import io.grpc.ServerServiceDefinition;
+import java.util.List;
+
+@javax.annotation.Generated("by GAPIC")
+public class MockConfigServiceV2 implements MockGrpcService {
+ private MockConfigServiceV2Impl serviceImpl;
+
+ public MockConfigServiceV2() {
+ serviceImpl = new MockConfigServiceV2Impl();
+ }
+
+ @Override
+ public List getRequests() {
+ return serviceImpl.getRequests();
+ }
+
+ @Override
+ public void setResponses(List responses) {
+ serviceImpl.setResponses(responses);
+ }
+
+ @Override
+ public ServerServiceDefinition getServiceDefinition() {
+ return serviceImpl.bindService();
+ }
+
+ @Override
+ public void reset() {
+ serviceImpl.reset();
+ }
+}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockConfigServiceV2Impl.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockConfigServiceV2Impl.java
new file mode 100644
index 000000000000..8e5d22e40c69
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockConfigServiceV2Impl.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.common.collect.Lists;
+import com.google.logging.v2.ConfigServiceV2Grpc.ConfigServiceV2ImplBase;
+import com.google.logging.v2.CreateSinkRequest;
+import com.google.logging.v2.DeleteSinkRequest;
+import com.google.logging.v2.GetSinkRequest;
+import com.google.logging.v2.ListSinksRequest;
+import com.google.logging.v2.ListSinksResponse;
+import com.google.logging.v2.LogSink;
+import com.google.logging.v2.UpdateSinkRequest;
+import com.google.protobuf.Empty;
+import com.google.protobuf.GeneratedMessageV3;
+import io.grpc.stub.StreamObserver;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+
+@javax.annotation.Generated("by GAPIC")
+public class MockConfigServiceV2Impl extends ConfigServiceV2ImplBase {
+ private ArrayList requests;
+ private Queue responses;
+
+ public MockConfigServiceV2Impl() {
+ requests = new ArrayList<>();
+ responses = new LinkedList<>();
+ }
+
+ public List getRequests() {
+ return requests;
+ }
+
+ public void setResponses(List responses) {
+ this.responses = Lists.newLinkedList(responses);
+ }
+
+ public void reset() {
+ requests = new ArrayList<>();
+ responses = new LinkedList<>();
+ }
+
+ @Override
+ public void listSinks(
+ ListSinksRequest request, StreamObserver responseObserver) {
+ ListSinksResponse response = (ListSinksResponse) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void getSink(GetSinkRequest request, StreamObserver responseObserver) {
+ LogSink response = (LogSink) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void createSink(CreateSinkRequest request, StreamObserver responseObserver) {
+ LogSink response = (LogSink) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void updateSink(UpdateSinkRequest request, StreamObserver responseObserver) {
+ LogSink response = (LogSink) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void deleteSink(DeleteSinkRequest request, StreamObserver responseObserver) {
+ Empty response = (Empty) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockLoggingServiceV2.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockLoggingServiceV2.java
new file mode 100644
index 000000000000..236addeff7a9
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockLoggingServiceV2.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.api.gax.testing.MockGrpcService;
+import com.google.protobuf.GeneratedMessageV3;
+import io.grpc.ServerServiceDefinition;
+import java.util.List;
+
+@javax.annotation.Generated("by GAPIC")
+public class MockLoggingServiceV2 implements MockGrpcService {
+ private MockLoggingServiceV2Impl serviceImpl;
+
+ public MockLoggingServiceV2() {
+ serviceImpl = new MockLoggingServiceV2Impl();
+ }
+
+ @Override
+ public List getRequests() {
+ return serviceImpl.getRequests();
+ }
+
+ @Override
+ public void setResponses(List responses) {
+ serviceImpl.setResponses(responses);
+ }
+
+ @Override
+ public ServerServiceDefinition getServiceDefinition() {
+ return serviceImpl.bindService();
+ }
+
+ @Override
+ public void reset() {
+ serviceImpl.reset();
+ }
+}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockLoggingServiceV2Impl.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockLoggingServiceV2Impl.java
new file mode 100644
index 000000000000..2964cfc0ed91
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockLoggingServiceV2Impl.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.common.collect.Lists;
+import com.google.logging.v2.DeleteLogRequest;
+import com.google.logging.v2.ListLogEntriesRequest;
+import com.google.logging.v2.ListLogEntriesResponse;
+import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest;
+import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
+import com.google.logging.v2.LoggingServiceV2Grpc.LoggingServiceV2ImplBase;
+import com.google.logging.v2.WriteLogEntriesRequest;
+import com.google.logging.v2.WriteLogEntriesResponse;
+import com.google.protobuf.Empty;
+import com.google.protobuf.GeneratedMessageV3;
+import io.grpc.stub.StreamObserver;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+
+@javax.annotation.Generated("by GAPIC")
+public class MockLoggingServiceV2Impl extends LoggingServiceV2ImplBase {
+ private ArrayList requests;
+ private Queue responses;
+
+ public MockLoggingServiceV2Impl() {
+ requests = new ArrayList<>();
+ responses = new LinkedList<>();
+ }
+
+ public List getRequests() {
+ return requests;
+ }
+
+ public void setResponses(List responses) {
+ this.responses = Lists.newLinkedList(responses);
+ }
+
+ public void reset() {
+ requests = new ArrayList<>();
+ responses = new LinkedList<>();
+ }
+
+ @Override
+ public void deleteLog(DeleteLogRequest request, StreamObserver responseObserver) {
+ Empty response = (Empty) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void writeLogEntries(
+ WriteLogEntriesRequest request, StreamObserver responseObserver) {
+ WriteLogEntriesResponse response = (WriteLogEntriesResponse) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void listLogEntries(
+ ListLogEntriesRequest request, StreamObserver responseObserver) {
+ ListLogEntriesResponse response = (ListLogEntriesResponse) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void listMonitoredResourceDescriptors(
+ ListMonitoredResourceDescriptorsRequest request,
+ StreamObserver responseObserver) {
+ ListMonitoredResourceDescriptorsResponse response =
+ (ListMonitoredResourceDescriptorsResponse) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockMetricsServiceV2.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockMetricsServiceV2.java
new file mode 100644
index 000000000000..8b0ea5526094
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockMetricsServiceV2.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.api.gax.testing.MockGrpcService;
+import com.google.protobuf.GeneratedMessageV3;
+import io.grpc.ServerServiceDefinition;
+import java.util.List;
+
+@javax.annotation.Generated("by GAPIC")
+public class MockMetricsServiceV2 implements MockGrpcService {
+ private MockMetricsServiceV2Impl serviceImpl;
+
+ public MockMetricsServiceV2() {
+ serviceImpl = new MockMetricsServiceV2Impl();
+ }
+
+ @Override
+ public List getRequests() {
+ return serviceImpl.getRequests();
+ }
+
+ @Override
+ public void setResponses(List responses) {
+ serviceImpl.setResponses(responses);
+ }
+
+ @Override
+ public ServerServiceDefinition getServiceDefinition() {
+ return serviceImpl.bindService();
+ }
+
+ @Override
+ public void reset() {
+ serviceImpl.reset();
+ }
+}
diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockMetricsServiceV2Impl.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockMetricsServiceV2Impl.java
new file mode 100644
index 000000000000..99a44483ee00
--- /dev/null
+++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MockMetricsServiceV2Impl.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.cloud.logging.spi.v2;
+
+import com.google.common.collect.Lists;
+import com.google.logging.v2.CreateLogMetricRequest;
+import com.google.logging.v2.DeleteLogMetricRequest;
+import com.google.logging.v2.GetLogMetricRequest;
+import com.google.logging.v2.ListLogMetricsRequest;
+import com.google.logging.v2.ListLogMetricsResponse;
+import com.google.logging.v2.LogMetric;
+import com.google.logging.v2.MetricsServiceV2Grpc.MetricsServiceV2ImplBase;
+import com.google.logging.v2.UpdateLogMetricRequest;
+import com.google.protobuf.Empty;
+import com.google.protobuf.GeneratedMessageV3;
+import io.grpc.stub.StreamObserver;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+
+@javax.annotation.Generated("by GAPIC")
+public class MockMetricsServiceV2Impl extends MetricsServiceV2ImplBase {
+ private ArrayList requests;
+ private Queue responses;
+
+ public MockMetricsServiceV2Impl() {
+ requests = new ArrayList<>();
+ responses = new LinkedList<>();
+ }
+
+ public List getRequests() {
+ return requests;
+ }
+
+ public void setResponses(List responses) {
+ this.responses = Lists.newLinkedList(responses);
+ }
+
+ public void reset() {
+ requests = new ArrayList<>();
+ responses = new LinkedList<>();
+ }
+
+ @Override
+ public void listLogMetrics(
+ ListLogMetricsRequest request, StreamObserver responseObserver) {
+ ListLogMetricsResponse response = (ListLogMetricsResponse) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void getLogMetric(
+ GetLogMetricRequest request, StreamObserver responseObserver) {
+ LogMetric response = (LogMetric) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void createLogMetric(
+ CreateLogMetricRequest request, StreamObserver responseObserver) {
+ LogMetric response = (LogMetric) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void updateLogMetric(
+ UpdateLogMetricRequest request, StreamObserver responseObserver) {
+ LogMetric response = (LogMetric) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void deleteLogMetric(
+ DeleteLogMetricRequest request, StreamObserver responseObserver) {
+ Empty response = (Empty) responses.remove();
+ requests.add(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ }
+}
diff --git a/google-cloud-monitoring/pom.xml b/google-cloud-monitoring/pom.xml
index 8ff98bf15c44..3570d2adb35b 100644
--- a/google-cloud-monitoring/pom.xml
+++ b/google-cloud-monitoring/pom.xml
@@ -20,7 +20,7 @@
io.netty
netty-tcnative-boringssl-static
- 1.1.33.Fork17
+ 1.1.33.Fork19
${project.groupId}
@@ -30,17 +30,12 @@
com.google.api.grpc
grpc-google-monitoring-v3
- 0.0.7
+ 0.1.0
io.grpc
grpc-all
- 0.15.0
-
-
- com.google.auto.value
- auto-value
- 1.1
+ 1.0.1
${project.groupId}
diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceApi.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceApi.java
index b0e44057ca58..78608f7f1c0d 100644
--- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceApi.java
+++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceApi.java
@@ -14,7 +14,7 @@
package com.google.cloud.monitoring.spi.v3;
import com.google.api.MonitoredResource;
-import com.google.api.gax.core.PageAccessor;
+import com.google.api.gax.core.PagedListResponse;
import com.google.api.gax.grpc.ApiCallable;
import com.google.api.gax.protobuf.PathTemplate;
import com.google.monitoring.v3.CreateGroupRequest;
@@ -106,14 +106,18 @@ public class GroupServiceApi implements AutoCloseable {
private final List closeables = new ArrayList<>();
private final ApiCallable listGroupsCallable;
- private final ApiCallable> listGroupsPagedCallable;
+ private final ApiCallable<
+ ListGroupsRequest, PagedListResponse>
+ listGroupsPagedCallable;
private final ApiCallable