Skip to content

Commit deee5a3

Browse files
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
1 parent 4fe00dd commit deee5a3

File tree

66 files changed

+1555
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1555
-486
lines changed

google-cloud-core/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,22 @@
101101
<dependency>
102102
<groupId>com.google.protobuf</groupId>
103103
<artifactId>protobuf-java</artifactId>
104-
<version>3.0.0-beta-3</version>
104+
<version>3.0.0</version>
105105
</dependency>
106106
<dependency>
107107
<groupId>com.google.api</groupId>
108108
<artifactId>gax</artifactId>
109-
<version>0.0.16</version>
109+
<version>0.0.18</version>
110110
</dependency>
111111
<dependency>
112112
<groupId>com.google.api.grpc</groupId>
113113
<artifactId>grpc-google-common-protos</artifactId>
114-
<version>0.0.9</version>
114+
<version>0.1.0</version>
115115
</dependency>
116116
<dependency>
117117
<groupId>com.google.api.grpc</groupId>
118118
<artifactId>grpc-google-iam-v1</artifactId>
119-
<version>0.0.9</version>
119+
<version>0.1.0</version>
120120
</dependency>
121121
</dependencies>
122122
</project>

google-cloud-errorreporting/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
<dependency>
3131
<groupId>com.google.api.grpc</groupId>
3232
<artifactId>grpc-google-devtools-clouderrorreporting-v1beta1</artifactId>
33-
<version>0.0.7</version>
33+
<version>0.1.0</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>io.grpc</groupId>
3737
<artifactId>grpc-all</artifactId>
38-
<version>0.15.0</version>
38+
<version>1.0.1</version>
3939
</dependency>
4040
<dependency>
4141
<groupId>com.google.auto.value</groupId>

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceApi.java

+29-18
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
package com.google.cloud.errorreporting.spi.v1beta1;
1515

16-
import com.google.api.gax.core.PageAccessor;
16+
import com.google.api.gax.core.PagedListResponse;
1717
import com.google.api.gax.grpc.ApiCallable;
1818
import com.google.api.gax.protobuf.PathTemplate;
1919
import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsRequest;
@@ -93,10 +93,14 @@ public class ErrorStatsServiceApi implements AutoCloseable {
9393
private final List<AutoCloseable> closeables = new ArrayList<>();
9494

9595
private final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGroupStatsCallable;
96-
private final ApiCallable<ListGroupStatsRequest, PageAccessor<ErrorGroupStats>>
96+
private final ApiCallable<
97+
ListGroupStatsRequest,
98+
PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>>
9799
listGroupStatsPagedCallable;
98100
private final ApiCallable<ListEventsRequest, ListEventsResponse> listEventsCallable;
99-
private final ApiCallable<ListEventsRequest, PageAccessor<ErrorEvent>> listEventsPagedCallable;
101+
private final ApiCallable<
102+
ListEventsRequest, PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent>>
103+
listEventsPagedCallable;
100104
private final ApiCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable;
101105

102106
public final ErrorStatsServiceSettings getSettings() {
@@ -190,7 +194,7 @@ public void close() throws IOException {
190194
* try (ErrorStatsServiceApi errorStatsServiceApi = ErrorStatsServiceApi.create()) {
191195
* String formattedProjectName = ErrorStatsServiceApi.formatProjectName("[PROJECT]");
192196
* QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
193-
* for (ErrorGroupStats element : errorStatsServiceApi.listGroupStats(formattedProjectName, timeRange)) {
197+
* for (ErrorGroupStats element : errorStatsServiceApi.listGroupStats(formattedProjectName, timeRange).iterateAllElements()) {
194198
* // doThingsWith(element);
195199
* }
196200
* }
@@ -208,8 +212,8 @@ public void close() throws IOException {
208212
* higher response times or in returning incomplete results.
209213
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
210214
*/
211-
public final PageAccessor<ErrorGroupStats> listGroupStats(
212-
String projectName, QueryTimeRange timeRange) {
215+
public final PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
216+
listGroupStats(String projectName, QueryTimeRange timeRange) {
213217
PROJECT_PATH_TEMPLATE.validate(projectName, "listGroupStats");
214218
ListGroupStatsRequest request =
215219
ListGroupStatsRequest.newBuilder()
@@ -232,7 +236,7 @@ public final PageAccessor<ErrorGroupStats> listGroupStats(
232236
* .setProjectName(formattedProjectName)
233237
* .setTimeRange(timeRange)
234238
* .build();
235-
* for (ErrorGroupStats element : errorStatsServiceApi.listGroupStats(request)) {
239+
* for (ErrorGroupStats element : errorStatsServiceApi.listGroupStats(request).iterateAllElements()) {
236240
* // doThingsWith(element);
237241
* }
238242
* }
@@ -241,7 +245,8 @@ public final PageAccessor<ErrorGroupStats> listGroupStats(
241245
* @param request The request object containing all of the parameters for the API call.
242246
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
243247
*/
244-
public final PageAccessor<ErrorGroupStats> listGroupStats(ListGroupStatsRequest request) {
248+
public final PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
249+
listGroupStats(ListGroupStatsRequest request) {
245250
return listGroupStatsPagedCallable().call(request);
246251
}
247252

@@ -258,15 +263,17 @@ public final PageAccessor<ErrorGroupStats> listGroupStats(ListGroupStatsRequest
258263
* .setProjectName(formattedProjectName)
259264
* .setTimeRange(timeRange)
260265
* .build();
261-
* ListenableFuture&lt;PageAccessor&lt;ErrorGroupStats&gt;&gt; future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request);
266+
* ListenableFuture&lt;PagedListResponse&lt;ListGroupStatsRequest,ListGroupStatsResponse,ErrorGroupStats&gt;&gt; future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request);
262267
* // Do something
263-
* for (ErrorGroupStats element : future.get()) {
268+
* for (ErrorGroupStats element : future.get().iterateAllElements()) {
264269
* // doThingsWith(element);
265270
* }
266271
* }
267272
* </code></pre>
268273
*/
269-
public final ApiCallable<ListGroupStatsRequest, PageAccessor<ErrorGroupStats>>
274+
public final ApiCallable<
275+
ListGroupStatsRequest,
276+
PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>>
270277
listGroupStatsPagedCallable() {
271278
return listGroupStatsPagedCallable;
272279
}
@@ -312,7 +319,7 @@ public final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGrou
312319
* try (ErrorStatsServiceApi errorStatsServiceApi = ErrorStatsServiceApi.create()) {
313320
* String formattedProjectName = ErrorStatsServiceApi.formatProjectName("[PROJECT]");
314321
* String groupId = "";
315-
* for (ErrorEvent element : errorStatsServiceApi.listEvents(formattedProjectName, groupId)) {
322+
* for (ErrorEvent element : errorStatsServiceApi.listEvents(formattedProjectName, groupId).iterateAllElements()) {
316323
* // doThingsWith(element);
317324
* }
318325
* }
@@ -325,7 +332,8 @@ public final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGrou
325332
* @param groupId [Required] The group for which events shall be returned.
326333
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
327334
*/
328-
public final PageAccessor<ErrorEvent> listEvents(String projectName, String groupId) {
335+
public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> listEvents(
336+
String projectName, String groupId) {
329337
PROJECT_PATH_TEMPLATE.validate(projectName, "listEvents");
330338
ListEventsRequest request =
331339
ListEventsRequest.newBuilder().setProjectName(projectName).setGroupId(groupId).build();
@@ -345,7 +353,7 @@ public final PageAccessor<ErrorEvent> listEvents(String projectName, String grou
345353
* .setProjectName(formattedProjectName)
346354
* .setGroupId(groupId)
347355
* .build();
348-
* for (ErrorEvent element : errorStatsServiceApi.listEvents(request)) {
356+
* for (ErrorEvent element : errorStatsServiceApi.listEvents(request).iterateAllElements()) {
349357
* // doThingsWith(element);
350358
* }
351359
* }
@@ -354,7 +362,8 @@ public final PageAccessor<ErrorEvent> listEvents(String projectName, String grou
354362
* @param request The request object containing all of the parameters for the API call.
355363
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
356364
*/
357-
public final PageAccessor<ErrorEvent> listEvents(ListEventsRequest request) {
365+
public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> listEvents(
366+
ListEventsRequest request) {
358367
return listEventsPagedCallable().call(request);
359368
}
360369

@@ -371,15 +380,17 @@ public final PageAccessor<ErrorEvent> listEvents(ListEventsRequest request) {
371380
* .setProjectName(formattedProjectName)
372381
* .setGroupId(groupId)
373382
* .build();
374-
* ListenableFuture&lt;PageAccessor&lt;ErrorEvent&gt;&gt; future = errorStatsServiceApi.listEventsPagedCallable().futureCall(request);
383+
* ListenableFuture&lt;PagedListResponse&lt;ListEventsRequest,ListEventsResponse,ErrorEvent&gt;&gt; future = errorStatsServiceApi.listEventsPagedCallable().futureCall(request);
375384
* // Do something
376-
* for (ErrorEvent element : future.get()) {
385+
* for (ErrorEvent element : future.get().iterateAllElements()) {
377386
* // doThingsWith(element);
378387
* }
379388
* }
380389
* </code></pre>
381390
*/
382-
public final ApiCallable<ListEventsRequest, PageAccessor<ErrorEvent>> listEventsPagedCallable() {
391+
public final ApiCallable<
392+
ListEventsRequest, PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent>>
393+
listEventsPagedCallable() {
383394
return listEventsPagedCallable;
384395
}
385396

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceSettings.java

+21
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ public ListGroupStatsRequest injectToken(ListGroupStatsRequest payload, Object t
198198
return ListGroupStatsRequest.newBuilder(payload).setPageToken((String) token).build();
199199
}
200200

201+
@Override
202+
public ListGroupStatsRequest injectPageSize(
203+
ListGroupStatsRequest payload, int pageSize) {
204+
return ListGroupStatsRequest.newBuilder(payload).setPageSize(pageSize).build();
205+
}
206+
207+
@Override
208+
public Integer extractPageSize(ListGroupStatsRequest payload) {
209+
return payload.getPageSize();
210+
}
211+
201212
@Override
202213
public Object extractNextToken(ListGroupStatsResponse payload) {
203214
return payload.getNextPageToken();
@@ -222,6 +233,16 @@ public ListEventsRequest injectToken(ListEventsRequest payload, Object token) {
222233
return ListEventsRequest.newBuilder(payload).setPageToken((String) token).build();
223234
}
224235

236+
@Override
237+
public ListEventsRequest injectPageSize(ListEventsRequest payload, int pageSize) {
238+
return ListEventsRequest.newBuilder(payload).setPageSize(pageSize).build();
239+
}
240+
241+
@Override
242+
public Integer extractPageSize(ListEventsRequest payload) {
243+
return payload.getPageSize();
244+
}
245+
225246
@Override
226247
public Object extractNextToken(ListEventsResponse payload) {
227248
return payload.getNextPageToken();

google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

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

17-
import com.google.api.gax.core.PageAccessor;
17+
import com.google.api.gax.core.PagedListResponse;
1818
import com.google.api.gax.testing.MockGrpcService;
1919
import com.google.api.gax.testing.MockServiceHelper;
2020
import com.google.common.collect.Lists;
2121
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup;
2222
import com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest;
2323
import com.google.devtools.clouderrorreporting.v1beta1.UpdateGroupRequest;
24-
import com.google.protobuf.GeneratedMessage;
24+
import com.google.protobuf.GeneratedMessageV3;
2525
import java.io.IOException;
2626
import java.util.ArrayList;
2727
import java.util.Arrays;
@@ -80,7 +80,7 @@ public void getGroupTest() {
8080
String name = "name3373707";
8181
String groupId = "groupId506361563";
8282
ErrorGroup expectedResponse = ErrorGroup.newBuilder().setName(name).setGroupId(groupId).build();
83-
List<GeneratedMessage> expectedResponses = new ArrayList<>();
83+
List<GeneratedMessageV3> expectedResponses = new ArrayList<>();
8484
expectedResponses.add(expectedResponse);
8585
mockErrorGroupService.setResponses(expectedResponses);
8686

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

92-
List<GeneratedMessage> actualRequests = mockErrorGroupService.getRequests();
92+
List<GeneratedMessageV3> actualRequests = mockErrorGroupService.getRequests();
9393
Assert.assertEquals(1, actualRequests.size());
9494
GetGroupRequest actualRequest = (GetGroupRequest) actualRequests.get(0);
9595

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

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

114-
List<GeneratedMessage> actualRequests = mockErrorGroupService.getRequests();
114+
List<GeneratedMessageV3> actualRequests = mockErrorGroupService.getRequests();
115115
Assert.assertEquals(1, actualRequests.size());
116116
UpdateGroupRequest actualRequest = (UpdateGroupRequest) actualRequests.get(0);
117117

google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceTest.java

+18-21
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

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

17-
import com.google.api.gax.core.PageAccessor;
17+
import com.google.api.gax.core.PagedListResponse;
1818
import com.google.api.gax.testing.MockGrpcService;
1919
import com.google.api.gax.testing.MockServiceHelper;
2020
import com.google.common.collect.Lists;
@@ -27,7 +27,7 @@
2727
import com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest;
2828
import com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse;
2929
import com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange;
30-
import com.google.protobuf.GeneratedMessage;
30+
import com.google.protobuf.GeneratedMessageV3;
3131
import java.io.IOException;
3232
import java.util.ArrayList;
3333
import java.util.Arrays;
@@ -83,31 +83,29 @@ public void tearDown() throws Exception {
8383
@Test
8484
@SuppressWarnings("all")
8585
public void listGroupStatsTest() {
86+
String nextPageToken = "";
8687
ErrorGroupStats errorGroupStatsElement = ErrorGroupStats.newBuilder().build();
8788
List<ErrorGroupStats> errorGroupStats = Arrays.asList(errorGroupStatsElement);
88-
String nextPageToken = "nextPageToken-1530815211";
8989
ListGroupStatsResponse expectedResponse =
9090
ListGroupStatsResponse.newBuilder()
91-
.addAllErrorGroupStats(errorGroupStats)
9291
.setNextPageToken(nextPageToken)
92+
.addAllErrorGroupStats(errorGroupStats)
9393
.build();
94-
List<GeneratedMessage> expectedResponses = new ArrayList<>();
94+
List<GeneratedMessageV3> expectedResponses = new ArrayList<>();
9595
expectedResponses.add(expectedResponse);
9696
mockErrorStatsService.setResponses(expectedResponses);
9797

9898
String formattedProjectName = ErrorStatsServiceApi.formatProjectName("[PROJECT]");
9999
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
100100

101-
PageAccessor<ErrorGroupStats> pageAccessor =
102-
api.listGroupStats(formattedProjectName, timeRange);
101+
PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
102+
pagedListResponse = api.listGroupStats(formattedProjectName, timeRange);
103103

104-
// PageAccessor will not make actual request until it is being used.
105-
// Add all the pages here in order to make grpc requests.
106-
List<ErrorGroupStats> resources = Lists.newArrayList(pageAccessor.getPageValues());
104+
List<ErrorGroupStats> resources = Lists.newArrayList(pagedListResponse.iterateAllElements());
107105
Assert.assertEquals(1, resources.size());
108106
Assert.assertEquals(expectedResponse.getErrorGroupStatsList().get(0), resources.get(0));
109107

110-
List<GeneratedMessage> actualRequests = mockErrorStatsService.getRequests();
108+
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
111109
Assert.assertEquals(1, actualRequests.size());
112110
ListGroupStatsRequest actualRequest = (ListGroupStatsRequest) actualRequests.get(0);
113111

@@ -118,30 +116,29 @@ public void listGroupStatsTest() {
118116
@Test
119117
@SuppressWarnings("all")
120118
public void listEventsTest() {
119+
String nextPageToken = "";
121120
ErrorEvent errorEventsElement = ErrorEvent.newBuilder().build();
122121
List<ErrorEvent> errorEvents = Arrays.asList(errorEventsElement);
123-
String nextPageToken = "nextPageToken-1530815211";
124122
ListEventsResponse expectedResponse =
125123
ListEventsResponse.newBuilder()
126-
.addAllErrorEvents(errorEvents)
127124
.setNextPageToken(nextPageToken)
125+
.addAllErrorEvents(errorEvents)
128126
.build();
129-
List<GeneratedMessage> expectedResponses = new ArrayList<>();
127+
List<GeneratedMessageV3> expectedResponses = new ArrayList<>();
130128
expectedResponses.add(expectedResponse);
131129
mockErrorStatsService.setResponses(expectedResponses);
132130

133131
String formattedProjectName = ErrorStatsServiceApi.formatProjectName("[PROJECT]");
134132
String groupId = "groupId506361563";
135133

136-
PageAccessor<ErrorEvent> pageAccessor = api.listEvents(formattedProjectName, groupId);
134+
PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> pagedListResponse =
135+
api.listEvents(formattedProjectName, groupId);
137136

138-
// PageAccessor will not make actual request until it is being used.
139-
// Add all the pages here in order to make grpc requests.
140-
List<ErrorEvent> resources = Lists.newArrayList(pageAccessor.getPageValues());
137+
List<ErrorEvent> resources = Lists.newArrayList(pagedListResponse.iterateAllElements());
141138
Assert.assertEquals(1, resources.size());
142139
Assert.assertEquals(expectedResponse.getErrorEventsList().get(0), resources.get(0));
143140

144-
List<GeneratedMessage> actualRequests = mockErrorStatsService.getRequests();
141+
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
145142
Assert.assertEquals(1, actualRequests.size());
146143
ListEventsRequest actualRequest = (ListEventsRequest) actualRequests.get(0);
147144

@@ -153,7 +150,7 @@ public void listEventsTest() {
153150
@SuppressWarnings("all")
154151
public void deleteEventsTest() {
155152
DeleteEventsResponse expectedResponse = DeleteEventsResponse.newBuilder().build();
156-
List<GeneratedMessage> expectedResponses = new ArrayList<>();
153+
List<GeneratedMessageV3> expectedResponses = new ArrayList<>();
157154
expectedResponses.add(expectedResponse);
158155
mockErrorStatsService.setResponses(expectedResponses);
159156

@@ -162,7 +159,7 @@ public void deleteEventsTest() {
162159
DeleteEventsResponse actualResponse = api.deleteEvents(formattedProjectName);
163160
Assert.assertEquals(expectedResponse, actualResponse);
164161

165-
List<GeneratedMessage> actualRequests = mockErrorStatsService.getRequests();
162+
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
166163
Assert.assertEquals(1, actualRequests.size());
167164
DeleteEventsRequest actualRequest = (DeleteEventsRequest) actualRequests.get(0);
168165

0 commit comments

Comments
 (0)