Skip to content

Commit

Permalink
Update grpc, protobuf, datastore and gax dependencies, regenerate SPI…
Browse files Browse the repository at this point in the history
… classes (#1273)

* Regenerating SPI classes
* Updating grpc to 1.0.1 and protobuf to 3.0.0
* Converting PageAccessor to PagedListResponse
* Adding auto-generated tests for logging
* Removing some unused imports
* Updating datastore proto dependency
* Removing unnecessary auto-value dependency
* Using correct version of netty-tcnative-boringssl-static
  • Loading branch information
garrettjonesgoogle authored and mziccard committed Sep 28, 2016
1 parent 007c153 commit d2470fb
Show file tree
Hide file tree
Showing 82 changed files with 1,783 additions and 670 deletions.
8 changes: 4 additions & 4 deletions google-cloud-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.0.0-beta-3</version>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>0.0.16</version>
<version>0.0.18</version>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<version>0.0.9</version>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-iam-v1</artifactId>
<version>0.0.9</version>
<version>0.1.0</version>
</dependency>
</dependencies>
</project>
4 changes: 2 additions & 2 deletions google-cloud-datastore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<dependency>
<groupId>com.google.cloud.datastore</groupId>
<artifactId>datastore-v1-protos</artifactId>
<version>1.0.1</version>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud.datastore</groupId>
<artifactId>datastore-v1-proto-client</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
11 changes: 3 additions & 8 deletions google-cloud-errorreporting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>1.1.33.Fork17</version>
<version>1.1.33.Fork19</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand All @@ -30,17 +30,12 @@
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-devtools-clouderrorreporting-v1beta1</artifactId>
<version>0.0.7</version>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-all</artifactId>
<version>0.15.0</version>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.1</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package com.google.cloud.errorreporting.spi.v1beta1;

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.devtools.clouderrorreporting.v1beta1.DeleteEventsRequest;
Expand Down Expand Up @@ -93,10 +93,14 @@ public class ErrorStatsServiceApi implements AutoCloseable {
private final List<AutoCloseable> closeables = new ArrayList<>();

private final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGroupStatsCallable;
private final ApiCallable<ListGroupStatsRequest, PageAccessor<ErrorGroupStats>>
private final ApiCallable<
ListGroupStatsRequest,
PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>>
listGroupStatsPagedCallable;
private final ApiCallable<ListEventsRequest, ListEventsResponse> listEventsCallable;
private final ApiCallable<ListEventsRequest, PageAccessor<ErrorEvent>> listEventsPagedCallable;
private final ApiCallable<
ListEventsRequest, PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent>>
listEventsPagedCallable;
private final ApiCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable;

public final ErrorStatsServiceSettings getSettings() {
Expand Down Expand Up @@ -190,7 +194,7 @@ public void close() throws IOException {
* try (ErrorStatsServiceApi errorStatsServiceApi = ErrorStatsServiceApi.create()) {
* String formattedProjectName = ErrorStatsServiceApi.formatProjectName("[PROJECT]");
* QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
* for (ErrorGroupStats element : errorStatsServiceApi.listGroupStats(formattedProjectName, timeRange)) {
* for (ErrorGroupStats element : errorStatsServiceApi.listGroupStats(formattedProjectName, timeRange).iterateAllElements()) {
* // doThingsWith(element);
* }
* }
Expand All @@ -208,8 +212,8 @@ public void close() throws IOException {
* higher response times or in returning incomplete results.
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final PageAccessor<ErrorGroupStats> listGroupStats(
String projectName, QueryTimeRange timeRange) {
public final PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
listGroupStats(String projectName, QueryTimeRange timeRange) {
PROJECT_PATH_TEMPLATE.validate(projectName, "listGroupStats");
ListGroupStatsRequest request =
ListGroupStatsRequest.newBuilder()
Expand All @@ -232,7 +236,7 @@ public final PageAccessor<ErrorGroupStats> listGroupStats(
* .setProjectName(formattedProjectName)
* .setTimeRange(timeRange)
* .build();
* for (ErrorGroupStats element : errorStatsServiceApi.listGroupStats(request)) {
* for (ErrorGroupStats element : errorStatsServiceApi.listGroupStats(request).iterateAllElements()) {
* // doThingsWith(element);
* }
* }
Expand All @@ -241,7 +245,8 @@ public final PageAccessor<ErrorGroupStats> listGroupStats(
* @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<ErrorGroupStats> listGroupStats(ListGroupStatsRequest request) {
public final PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
listGroupStats(ListGroupStatsRequest request) {
return listGroupStatsPagedCallable().call(request);
}

Expand All @@ -258,15 +263,17 @@ public final PageAccessor<ErrorGroupStats> listGroupStats(ListGroupStatsRequest
* .setProjectName(formattedProjectName)
* .setTimeRange(timeRange)
* .build();
* ListenableFuture&lt;PageAccessor&lt;ErrorGroupStats&gt;&gt; future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request);
* ListenableFuture&lt;PagedListResponse&lt;ListGroupStatsRequest,ListGroupStatsResponse,ErrorGroupStats&gt;&gt; future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request);
* // Do something
* for (ErrorGroupStats element : future.get()) {
* for (ErrorGroupStats element : future.get().iterateAllElements()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*/
public final ApiCallable<ListGroupStatsRequest, PageAccessor<ErrorGroupStats>>
public final ApiCallable<
ListGroupStatsRequest,
PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>>
listGroupStatsPagedCallable() {
return listGroupStatsPagedCallable;
}
Expand Down Expand Up @@ -312,7 +319,7 @@ public final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGrou
* try (ErrorStatsServiceApi errorStatsServiceApi = ErrorStatsServiceApi.create()) {
* String formattedProjectName = ErrorStatsServiceApi.formatProjectName("[PROJECT]");
* String groupId = "";
* for (ErrorEvent element : errorStatsServiceApi.listEvents(formattedProjectName, groupId)) {
* for (ErrorEvent element : errorStatsServiceApi.listEvents(formattedProjectName, groupId).iterateAllElements()) {
* // doThingsWith(element);
* }
* }
Expand All @@ -325,7 +332,8 @@ public final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGrou
* @param groupId [Required] The group for which events shall be returned.
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final PageAccessor<ErrorEvent> listEvents(String projectName, String groupId) {
public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> listEvents(
String projectName, String groupId) {
PROJECT_PATH_TEMPLATE.validate(projectName, "listEvents");
ListEventsRequest request =
ListEventsRequest.newBuilder().setProjectName(projectName).setGroupId(groupId).build();
Expand All @@ -345,7 +353,7 @@ public final PageAccessor<ErrorEvent> listEvents(String projectName, String grou
* .setProjectName(formattedProjectName)
* .setGroupId(groupId)
* .build();
* for (ErrorEvent element : errorStatsServiceApi.listEvents(request)) {
* for (ErrorEvent element : errorStatsServiceApi.listEvents(request).iterateAllElements()) {
* // doThingsWith(element);
* }
* }
Expand All @@ -354,7 +362,8 @@ public final PageAccessor<ErrorEvent> listEvents(String projectName, String grou
* @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<ErrorEvent> listEvents(ListEventsRequest request) {
public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> listEvents(
ListEventsRequest request) {
return listEventsPagedCallable().call(request);
}

Expand All @@ -371,15 +380,17 @@ public final PageAccessor<ErrorEvent> listEvents(ListEventsRequest request) {
* .setProjectName(formattedProjectName)
* .setGroupId(groupId)
* .build();
* ListenableFuture&lt;PageAccessor&lt;ErrorEvent&gt;&gt; future = errorStatsServiceApi.listEventsPagedCallable().futureCall(request);
* ListenableFuture&lt;PagedListResponse&lt;ListEventsRequest,ListEventsResponse,ErrorEvent&gt;&gt; future = errorStatsServiceApi.listEventsPagedCallable().futureCall(request);
* // Do something
* for (ErrorEvent element : future.get()) {
* for (ErrorEvent element : future.get().iterateAllElements()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*/
public final ApiCallable<ListEventsRequest, PageAccessor<ErrorEvent>> listEventsPagedCallable() {
public final ApiCallable<
ListEventsRequest, PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent>>
listEventsPagedCallable() {
return listEventsPagedCallable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ public ListGroupStatsRequest injectToken(ListGroupStatsRequest payload, Object t
return ListGroupStatsRequest.newBuilder(payload).setPageToken((String) token).build();
}

@Override
public ListGroupStatsRequest injectPageSize(
ListGroupStatsRequest payload, int pageSize) {
return ListGroupStatsRequest.newBuilder(payload).setPageSize(pageSize).build();
}

@Override
public Integer extractPageSize(ListGroupStatsRequest payload) {
return payload.getPageSize();
}

@Override
public Object extractNextToken(ListGroupStatsResponse payload) {
return payload.getNextPageToken();
Expand All @@ -222,6 +233,16 @@ public ListEventsRequest injectToken(ListEventsRequest payload, Object token) {
return ListEventsRequest.newBuilder(payload).setPageToken((String) token).build();
}

@Override
public ListEventsRequest injectPageSize(ListEventsRequest payload, int pageSize) {
return ListEventsRequest.newBuilder(payload).setPageSize(pageSize).build();
}

@Override
public Integer extractPageSize(ListEventsRequest payload) {
return payload.getPageSize();
}

@Override
public Object extractNextToken(ListEventsResponse payload) {
return payload.getNextPageToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

package com.google.cloud.errorreporting.spi.v1beta1;

import com.google.api.gax.core.PageAccessor;
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.devtools.clouderrorreporting.v1beta1.ErrorGroup;
import com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest;
import com.google.devtools.clouderrorreporting.v1beta1.UpdateGroupRequest;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.GeneratedMessageV3;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -80,7 +80,7 @@ public void getGroupTest() {
String name = "name3373707";
String groupId = "groupId506361563";
ErrorGroup expectedResponse = ErrorGroup.newBuilder().setName(name).setGroupId(groupId).build();
List<GeneratedMessage> expectedResponses = new ArrayList<>();
List<GeneratedMessageV3> expectedResponses = new ArrayList<>();
expectedResponses.add(expectedResponse);
mockErrorGroupService.setResponses(expectedResponses);

Expand All @@ -89,7 +89,7 @@ public void getGroupTest() {
ErrorGroup actualResponse = api.getGroup(formattedGroupName);
Assert.assertEquals(expectedResponse, actualResponse);

List<GeneratedMessage> actualRequests = mockErrorGroupService.getRequests();
List<GeneratedMessageV3> actualRequests = mockErrorGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetGroupRequest actualRequest = (GetGroupRequest) actualRequests.get(0);

Expand All @@ -102,7 +102,7 @@ public void updateGroupTest() {
String name = "name3373707";
String groupId = "groupId506361563";
ErrorGroup expectedResponse = ErrorGroup.newBuilder().setName(name).setGroupId(groupId).build();
List<GeneratedMessage> expectedResponses = new ArrayList<>();
List<GeneratedMessageV3> expectedResponses = new ArrayList<>();
expectedResponses.add(expectedResponse);
mockErrorGroupService.setResponses(expectedResponses);

Expand All @@ -111,7 +111,7 @@ public void updateGroupTest() {
ErrorGroup actualResponse = api.updateGroup(group);
Assert.assertEquals(expectedResponse, actualResponse);

List<GeneratedMessage> actualRequests = mockErrorGroupService.getRequests();
List<GeneratedMessageV3> actualRequests = mockErrorGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateGroupRequest actualRequest = (UpdateGroupRequest) actualRequests.get(0);

Expand Down
Loading

0 comments on commit d2470fb

Please sign in to comment.