Skip to content

Commit 201eda8

Browse files
shinfanmziccard
authored andcommitted
Update spi classes with GAX 0.0.21 (#1326)
1 parent 0221851 commit 201eda8

File tree

65 files changed

+2083
-2002
lines changed

Some content is hidden

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

65 files changed

+2083
-2002
lines changed

google-cloud-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<dependency>
107107
<groupId>com.google.api</groupId>
108108
<artifactId>gax</artifactId>
109-
<version>0.0.18</version>
109+
<version>0.0.21</version>
110110
</dependency>
111111
<dependency>
112112
<groupId>com.google.api.grpc</groupId>

google-cloud-core/src/main/java/com/google/cloud/GrpcServiceOptions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import com.google.api.gax.core.ConnectionSettings;
2222
import com.google.api.gax.core.RetrySettings;
23-
import com.google.api.gax.grpc.ApiCallSettings;
23+
import com.google.api.gax.grpc.UnaryCallSettings;
2424
import com.google.auth.oauth2.GoogleCredentials;
2525
import com.google.cloud.spi.ServiceRpcFactory;
2626
import com.google.common.annotations.VisibleForTesting;
@@ -226,7 +226,7 @@ protected ExecutorFactory<ScheduledExecutorService> executorFactory() {
226226
/**
227227
* Returns a builder for API call settings.
228228
*/
229-
protected ApiCallSettings.Builder apiCallSettings() {
229+
protected UnaryCallSettings.Builder apiCallSettings() {
230230
// todo(mziccard): specify timeout these settings:
231231
// retryParams().retryMaxAttempts(), retryParams().retryMinAttempts()
232232
final RetrySettings.Builder builder = RetrySettings.newBuilder()
@@ -237,7 +237,7 @@ protected ApiCallSettings.Builder apiCallSettings() {
237237
.setInitialRetryDelay(Duration.millis(retryParams().initialRetryDelayMillis()))
238238
.setRetryDelayMultiplier(retryParams().retryDelayBackoffFactor())
239239
.setMaxRetryDelay(Duration.millis(retryParams().maxRetryDelayMillis()));
240-
return ApiCallSettings.newBuilder().setRetrySettingsBuilder(builder);
240+
return UnaryCallSettings.newBuilder().setRetrySettingsBuilder(builder);
241241
}
242242

243243
/**

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

Lines changed: 9 additions & 9 deletions
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.grpc.ApiCallable;
16+
import com.google.api.gax.grpc.UnaryCallable;
1717
import com.google.api.gax.protobuf.PathTemplate;
1818
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup;
1919
import com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest;
@@ -54,8 +54,8 @@
5454
* <li> A "request object" method. This type of method only takes one parameter, a request object,
5555
* which must be constructed before the call. Not every API method will have a request object
5656
* method.
57-
* <li> A "callable" method. This type of method takes no parameters and returns an immutable
58-
* ApiCallable object, which can be used to initiate calls to the service.
57+
* <li> A "callable" method. This type of method takes no parameters and returns an immutable API
58+
* callable object, which can be used to initiate calls to the service.
5959
* </ol>
6060
*
6161
* <p>See the individual methods for example code.
@@ -83,8 +83,8 @@ public class ErrorGroupServiceApi implements AutoCloseable {
8383
private final ScheduledExecutorService executor;
8484
private final List<AutoCloseable> closeables = new ArrayList<>();
8585

86-
private final ApiCallable<GetGroupRequest, ErrorGroup> getGroupCallable;
87-
private final ApiCallable<UpdateGroupRequest, ErrorGroup> updateGroupCallable;
86+
private final UnaryCallable<GetGroupRequest, ErrorGroup> getGroupCallable;
87+
private final UnaryCallable<UpdateGroupRequest, ErrorGroup> updateGroupCallable;
8888

8989
private static final PathTemplate GROUP_PATH_TEMPLATE =
9090
PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}");
@@ -130,9 +130,9 @@ protected ErrorGroupServiceApi(ErrorGroupServiceSettings settings) throws IOExce
130130
this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
131131

132132
this.getGroupCallable =
133-
ApiCallable.create(settings.getGroupSettings(), this.channel, this.executor);
133+
UnaryCallable.create(settings.getGroupSettings(), this.channel, this.executor);
134134
this.updateGroupCallable =
135-
ApiCallable.create(settings.updateGroupSettings(), this.channel, this.executor);
135+
UnaryCallable.create(settings.updateGroupSettings(), this.channel, this.executor);
136136

137137
if (settings.getChannelProvider().shouldAutoClose()) {
138138
closeables.add(
@@ -226,7 +226,7 @@ private final ErrorGroup getGroup(GetGroupRequest request) {
226226
* }
227227
* </code></pre>
228228
*/
229-
public final ApiCallable<GetGroupRequest, ErrorGroup> getGroupCallable() {
229+
public final UnaryCallable<GetGroupRequest, ErrorGroup> getGroupCallable() {
230230
return getGroupCallable;
231231
}
232232

@@ -292,7 +292,7 @@ private final ErrorGroup updateGroup(UpdateGroupRequest request) {
292292
* }
293293
* </code></pre>
294294
*/
295-
public final ApiCallable<UpdateGroupRequest, ErrorGroup> updateGroupCallable() {
295+
public final UnaryCallable<UpdateGroupRequest, ErrorGroup> updateGroupCallable() {
296296
return updateGroupCallable;
297297
}
298298

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
import com.google.api.gax.core.ConnectionSettings;
1717
import com.google.api.gax.core.RetrySettings;
18-
import com.google.api.gax.grpc.ApiCallSettings;
1918
import com.google.api.gax.grpc.ServiceApiSettings;
2019
import com.google.api.gax.grpc.SimpleCallSettings;
20+
import com.google.api.gax.grpc.UnaryCallSettings;
2121
import com.google.auth.Credentials;
2222
import com.google.common.collect.ImmutableList;
2323
import com.google.common.collect.ImmutableMap;
@@ -74,14 +74,6 @@ public class ErrorGroupServiceSettings extends ServiceApiSettings {
7474
private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
7575
ImmutableList.<String>builder().add("https://www.googleapis.com/auth/cloud-platform").build();
7676

77-
/** The default connection settings of the service. */
78-
public static final ConnectionSettings DEFAULT_CONNECTION_SETTINGS =
79-
ConnectionSettings.newBuilder()
80-
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
81-
.setPort(DEFAULT_SERVICE_PORT)
82-
.provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
83-
.build();
84-
8577
private final SimpleCallSettings<GetGroupRequest, ErrorGroup> getGroupSettings;
8678
private final SimpleCallSettings<UpdateGroupRequest, ErrorGroup> updateGroupSettings;
8779

@@ -140,7 +132,7 @@ private ErrorGroupServiceSettings(Builder settingsBuilder) throws IOException {
140132

141133
/** Builder for ErrorGroupServiceSettings. */
142134
public static class Builder extends ServiceApiSettings.Builder {
143-
private final ImmutableList<ApiCallSettings.Builder> methodSettingsBuilders;
135+
private final ImmutableList<UnaryCallSettings.Builder> unaryMethodSettingsBuilders;
144136

145137
private final SimpleCallSettings.Builder<GetGroupRequest, ErrorGroup> getGroupSettings;
146138
private final SimpleCallSettings.Builder<UpdateGroupRequest, ErrorGroup> updateGroupSettings;
@@ -177,15 +169,15 @@ public static class Builder extends ServiceApiSettings.Builder {
177169
}
178170

179171
private Builder() {
180-
super(DEFAULT_CONNECTION_SETTINGS);
172+
super(s_getDefaultConnectionSettingsBuilder().build());
181173

182174
getGroupSettings = SimpleCallSettings.newBuilder(ErrorGroupServiceGrpc.METHOD_GET_GROUP);
183175

184176
updateGroupSettings =
185177
SimpleCallSettings.newBuilder(ErrorGroupServiceGrpc.METHOD_UPDATE_GROUP);
186178

187-
methodSettingsBuilders =
188-
ImmutableList.<ApiCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
179+
unaryMethodSettingsBuilders =
180+
ImmutableList.<UnaryCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
189181
}
190182

191183
private static Builder createDefault() {
@@ -210,13 +202,20 @@ private Builder(ErrorGroupServiceSettings settings) {
210202
getGroupSettings = settings.getGroupSettings.toBuilder();
211203
updateGroupSettings = settings.updateGroupSettings.toBuilder();
212204

213-
methodSettingsBuilders =
214-
ImmutableList.<ApiCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
205+
unaryMethodSettingsBuilders =
206+
ImmutableList.<UnaryCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
207+
}
208+
209+
private static ConnectionSettings.Builder s_getDefaultConnectionSettingsBuilder() {
210+
return ConnectionSettings.newBuilder()
211+
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
212+
.setPort(DEFAULT_SERVICE_PORT)
213+
.provideCredentialsWith(DEFAULT_SERVICE_SCOPES);
215214
}
216215

217216
@Override
218-
protected ConnectionSettings getDefaultConnectionSettings() {
219-
return DEFAULT_CONNECTION_SETTINGS;
217+
protected ConnectionSettings.Builder getDefaultConnectionSettingsBuilder() {
218+
return s_getDefaultConnectionSettingsBuilder();
220219
}
221220

222221
@Override
@@ -262,11 +261,14 @@ public Builder setClientLibHeader(String name, String version) {
262261
}
263262

264263
/**
265-
* Applies the given settings to all of the API methods in this service. Only values that are
266-
* non-null will be applied, so this method is not capable of un-setting any values.
264+
* Applies the given settings to all of the unary API methods in this service. Only values that
265+
* are non-null will be applied, so this method is not capable of un-setting any values.
266+
*
267+
* <p>Note: This method does not support applying settings to streaming methods.
267268
*/
268-
public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception {
269-
super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings);
269+
public Builder applyToAllApiMethods(UnaryCallSettings.Builder apiCallSettings)
270+
throws Exception {
271+
super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings);
270272
return this;
271273
}
272274

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

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
*/
1414
package com.google.cloud.errorreporting.spi.v1beta1;
1515

16-
import com.google.api.gax.core.PagedListResponse;
17-
import com.google.api.gax.grpc.ApiCallable;
16+
import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListEventsPagedResponse;
17+
import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse;
18+
19+
import com.google.api.gax.grpc.UnaryCallable;
1820
import com.google.api.gax.protobuf.PathTemplate;
1921
import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsRequest;
2022
import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsResponse;
21-
import com.google.devtools.clouderrorreporting.v1beta1.ErrorEvent;
22-
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats;
2323
import com.google.devtools.clouderrorreporting.v1beta1.ListEventsRequest;
2424
import com.google.devtools.clouderrorreporting.v1beta1.ListEventsResponse;
2525
import com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest;
@@ -62,8 +62,8 @@
6262
* <li> A "request object" method. This type of method only takes one parameter, a request object,
6363
* which must be constructed before the call. Not every API method will have a request object
6464
* method.
65-
* <li> A "callable" method. This type of method takes no parameters and returns an immutable
66-
* ApiCallable object, which can be used to initiate calls to the service.
65+
* <li> A "callable" method. This type of method takes no parameters and returns an immutable API
66+
* callable object, which can be used to initiate calls to the service.
6767
* </ol>
6868
*
6969
* <p>See the individual methods for example code.
@@ -91,16 +91,12 @@ public class ErrorStatsServiceApi implements AutoCloseable {
9191
private final ScheduledExecutorService executor;
9292
private final List<AutoCloseable> closeables = new ArrayList<>();
9393

94-
private final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGroupStatsCallable;
95-
private final ApiCallable<
96-
ListGroupStatsRequest,
97-
PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>>
94+
private final UnaryCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGroupStatsCallable;
95+
private final UnaryCallable<ListGroupStatsRequest, ListGroupStatsPagedResponse>
9896
listGroupStatsPagedCallable;
99-
private final ApiCallable<ListEventsRequest, ListEventsResponse> listEventsCallable;
100-
private final ApiCallable<
101-
ListEventsRequest, PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent>>
102-
listEventsPagedCallable;
103-
private final ApiCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable;
97+
private final UnaryCallable<ListEventsRequest, ListEventsResponse> listEventsCallable;
98+
private final UnaryCallable<ListEventsRequest, ListEventsPagedResponse> listEventsPagedCallable;
99+
private final UnaryCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable;
104100

105101
private static final PathTemplate PROJECT_PATH_TEMPLATE =
106102
PathTemplate.createWithoutUrlEncoding("projects/{project}");
@@ -139,16 +135,17 @@ protected ErrorStatsServiceApi(ErrorStatsServiceSettings settings) throws IOExce
139135
this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
140136

141137
this.listGroupStatsCallable =
142-
ApiCallable.create(settings.listGroupStatsSettings(), this.channel, this.executor);
138+
UnaryCallable.create(settings.listGroupStatsSettings(), this.channel, this.executor);
143139
this.listGroupStatsPagedCallable =
144-
ApiCallable.createPagedVariant(
140+
UnaryCallable.createPagedVariant(
145141
settings.listGroupStatsSettings(), this.channel, this.executor);
146142
this.listEventsCallable =
147-
ApiCallable.create(settings.listEventsSettings(), this.channel, this.executor);
143+
UnaryCallable.create(settings.listEventsSettings(), this.channel, this.executor);
148144
this.listEventsPagedCallable =
149-
ApiCallable.createPagedVariant(settings.listEventsSettings(), this.channel, this.executor);
145+
UnaryCallable.createPagedVariant(
146+
settings.listEventsSettings(), this.channel, this.executor);
150147
this.deleteEventsCallable =
151-
ApiCallable.create(settings.deleteEventsSettings(), this.channel, this.executor);
148+
UnaryCallable.create(settings.deleteEventsSettings(), this.channel, this.executor);
152149

153150
if (settings.getChannelProvider().shouldAutoClose()) {
154151
closeables.add(
@@ -195,13 +192,14 @@ public final ErrorStatsServiceSettings getSettings() {
195192
* href="https://support.google.com/cloud/answer/6158840"&gt;Google Cloud Platform project
196193
* ID&lt;/a&gt;.
197194
* <p>Example: &lt;code&gt;projects/my-project-123&lt;/code&gt;.
198-
* @param timeRange [Required] List data for the given time range. The service is tuned for
199-
* retrieving data up to (approximately) 'now'. Retrieving data for arbitrary time periods in
200-
* the past can result in higher response times or in returning incomplete results.
195+
* @param timeRange [Required] List data for the given time range. Only
196+
* &lt;code&gt;ErrorGroupStats&lt;/code&gt; with a non-zero count in the given time range are
197+
* returned, unless the request contains an explicit group_id list. If a group_id list is
198+
* given, also &lt;code&gt;ErrorGroupStats&lt;/code&gt; with zero occurrences are returned.
201199
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
202200
*/
203-
public final PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
204-
listGroupStats(String projectName, QueryTimeRange timeRange) {
201+
public final ListGroupStatsPagedResponse listGroupStats(
202+
String projectName, QueryTimeRange timeRange) {
205203
PROJECT_PATH_TEMPLATE.validate(projectName, "listGroupStats");
206204
ListGroupStatsRequest request =
207205
ListGroupStatsRequest.newBuilder()
@@ -234,8 +232,7 @@ public final ErrorStatsServiceSettings getSettings() {
234232
* @param request The request object containing all of the parameters for the API call.
235233
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
236234
*/
237-
public final PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
238-
listGroupStats(ListGroupStatsRequest request) {
235+
public final ListGroupStatsPagedResponse listGroupStats(ListGroupStatsRequest request) {
239236
return listGroupStatsPagedCallable().call(request);
240237
}
241238

@@ -253,17 +250,15 @@ public final ErrorStatsServiceSettings getSettings() {
253250
* .setProjectName(formattedProjectName)
254251
* .setTimeRange(timeRange)
255252
* .build();
256-
* ListenableFuture&lt;PagedListResponse&lt;ListGroupStatsRequest,ListGroupStatsResponse,ErrorGroupStats&gt;&gt; future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request);
253+
* ListenableFuture&lt;ListGroupStatsPagedResponse&gt; future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request);
257254
* // Do something
258255
* for (ErrorGroupStats element : future.get().iterateAllElements()) {
259256
* // doThingsWith(element);
260257
* }
261258
* }
262259
* </code></pre>
263260
*/
264-
public final ApiCallable<
265-
ListGroupStatsRequest,
266-
PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>>
261+
public final UnaryCallable<ListGroupStatsRequest, ListGroupStatsPagedResponse>
267262
listGroupStatsPagedCallable() {
268263
return listGroupStatsPagedCallable;
269264
}
@@ -297,7 +292,8 @@ public final ErrorStatsServiceSettings getSettings() {
297292
* }
298293
* </code></pre>
299294
*/
300-
public final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGroupStatsCallable() {
295+
public final UnaryCallable<ListGroupStatsRequest, ListGroupStatsResponse>
296+
listGroupStatsCallable() {
301297
return listGroupStatsCallable;
302298
}
303299

@@ -323,8 +319,7 @@ public final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGrou
323319
* @param groupId [Required] The group for which events shall be returned.
324320
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
325321
*/
326-
public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> listEvents(
327-
String projectName, String groupId) {
322+
public final ListEventsPagedResponse listEvents(String projectName, String groupId) {
328323
PROJECT_PATH_TEMPLATE.validate(projectName, "listEvents");
329324
ListEventsRequest request =
330325
ListEventsRequest.newBuilder().setProjectName(projectName).setGroupId(groupId).build();
@@ -354,8 +349,7 @@ public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent
354349
* @param request The request object containing all of the parameters for the API call.
355350
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
356351
*/
357-
public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> listEvents(
358-
ListEventsRequest request) {
352+
public final ListEventsPagedResponse listEvents(ListEventsRequest request) {
359353
return listEventsPagedCallable().call(request);
360354
}
361355

@@ -373,17 +367,15 @@ public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent
373367
* .setProjectName(formattedProjectName)
374368
* .setGroupId(groupId)
375369
* .build();
376-
* ListenableFuture&lt;PagedListResponse&lt;ListEventsRequest,ListEventsResponse,ErrorEvent&gt;&gt; future = errorStatsServiceApi.listEventsPagedCallable().futureCall(request);
370+
* ListenableFuture&lt;ListEventsPagedResponse&gt; future = errorStatsServiceApi.listEventsPagedCallable().futureCall(request);
377371
* // Do something
378372
* for (ErrorEvent element : future.get().iterateAllElements()) {
379373
* // doThingsWith(element);
380374
* }
381375
* }
382376
* </code></pre>
383377
*/
384-
public final ApiCallable<
385-
ListEventsRequest, PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent>>
386-
listEventsPagedCallable() {
378+
public final UnaryCallable<ListEventsRequest, ListEventsPagedResponse> listEventsPagedCallable() {
387379
return listEventsPagedCallable;
388380
}
389381

@@ -416,7 +408,7 @@ public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent
416408
* }
417409
* </code></pre>
418410
*/
419-
public final ApiCallable<ListEventsRequest, ListEventsResponse> listEventsCallable() {
411+
public final UnaryCallable<ListEventsRequest, ListEventsResponse> listEventsCallable() {
420412
return listEventsCallable;
421413
}
422414

@@ -486,7 +478,7 @@ private final DeleteEventsResponse deleteEvents(DeleteEventsRequest request) {
486478
* }
487479
* </code></pre>
488480
*/
489-
public final ApiCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable() {
481+
public final UnaryCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable() {
490482
return deleteEventsCallable;
491483
}
492484

0 commit comments

Comments
 (0)