Skip to content

Commit dd88e23

Browse files
committed
Update spi classes with GAX 0.0.19
- Add grpc streaming support - Rename ApiCallable to UnaryApiCallable - Rename ApiCallSettings to UnaryApiCallSettings
1 parent 8c9aca4 commit dd88e23

55 files changed

Lines changed: 1870 additions & 980 deletions

File tree

Some content is hidden

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

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.19</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.UnaryApiCallSettings;
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 UnaryApiCallSettings.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 UnaryApiCallSettings.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.UnaryApiCallable;
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 UnaryApiCallable<GetGroupRequest, ErrorGroup> getGroupCallable;
87+
private final UnaryApiCallable<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+
UnaryApiCallable.create(settings.getGroupSettings(), this.channel, this.executor);
134134
this.updateGroupCallable =
135-
ApiCallable.create(settings.updateGroupSettings(), this.channel, this.executor);
135+
UnaryApiCallable.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 UnaryApiCallable<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 UnaryApiCallable<UpdateGroupRequest, ErrorGroup> updateGroupCallable() {
296296
return updateGroupCallable;
297297
}
298298

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

Lines changed: 13 additions & 10 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.UnaryApiCallSettings;
2121
import com.google.auth.Credentials;
2222
import com.google.common.collect.ImmutableList;
2323
import com.google.common.collect.ImmutableMap;
@@ -140,7 +140,7 @@ private ErrorGroupServiceSettings(Builder settingsBuilder) throws IOException {
140140

141141
/** Builder for ErrorGroupServiceSettings. */
142142
public static class Builder extends ServiceApiSettings.Builder {
143-
private final ImmutableList<ApiCallSettings.Builder> methodSettingsBuilders;
143+
private final ImmutableList<UnaryApiCallSettings.Builder> unaryMethodSettingsBuilders;
144144

145145
private final SimpleCallSettings.Builder<GetGroupRequest, ErrorGroup> getGroupSettings;
146146
private final SimpleCallSettings.Builder<UpdateGroupRequest, ErrorGroup> updateGroupSettings;
@@ -184,8 +184,8 @@ private Builder() {
184184
updateGroupSettings =
185185
SimpleCallSettings.newBuilder(ErrorGroupServiceGrpc.METHOD_UPDATE_GROUP);
186186

187-
methodSettingsBuilders =
188-
ImmutableList.<ApiCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
187+
unaryMethodSettingsBuilders =
188+
ImmutableList.<UnaryApiCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
189189
}
190190

191191
private static Builder createDefault() {
@@ -210,8 +210,8 @@ private Builder(ErrorGroupServiceSettings settings) {
210210
getGroupSettings = settings.getGroupSettings.toBuilder();
211211
updateGroupSettings = settings.updateGroupSettings.toBuilder();
212212

213-
methodSettingsBuilders =
214-
ImmutableList.<ApiCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
213+
unaryMethodSettingsBuilders =
214+
ImmutableList.<UnaryApiCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
215215
}
216216

217217
@Override
@@ -262,11 +262,14 @@ public Builder setClientLibHeader(String name, String version) {
262262
}
263263

264264
/**
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.
265+
* Applies the given settings to all of the unary API methods in this service. Only values that
266+
* are non-null will be applied, so this method is not capable of un-setting any values.
267+
*
268+
* <p>Note: This method does not support applying settings to streaming methods.
267269
*/
268-
public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception {
269-
super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings);
270+
public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings)
271+
throws Exception {
272+
super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings);
270273
return this;
271274
}
272275

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

Lines changed: 35 additions & 40 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.UnaryApiCallable;
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,14 @@ 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 UnaryApiCallable<ListGroupStatsRequest, ListGroupStatsResponse>
95+
listGroupStatsCallable;
96+
private final UnaryApiCallable<ListGroupStatsRequest, ListGroupStatsPagedResponse>
9897
listGroupStatsPagedCallable;
99-
private final ApiCallable<ListEventsRequest, ListEventsResponse> listEventsCallable;
100-
private final ApiCallable<
101-
ListEventsRequest, PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent>>
98+
private final UnaryApiCallable<ListEventsRequest, ListEventsResponse> listEventsCallable;
99+
private final UnaryApiCallable<ListEventsRequest, ListEventsPagedResponse>
102100
listEventsPagedCallable;
103-
private final ApiCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable;
101+
private final UnaryApiCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable;
104102

105103
private static final PathTemplate PROJECT_PATH_TEMPLATE =
106104
PathTemplate.createWithoutUrlEncoding("projects/{project}");
@@ -139,16 +137,17 @@ protected ErrorStatsServiceApi(ErrorStatsServiceSettings settings) throws IOExce
139137
this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
140138

141139
this.listGroupStatsCallable =
142-
ApiCallable.create(settings.listGroupStatsSettings(), this.channel, this.executor);
140+
UnaryApiCallable.create(settings.listGroupStatsSettings(), this.channel, this.executor);
143141
this.listGroupStatsPagedCallable =
144-
ApiCallable.createPagedVariant(
142+
UnaryApiCallable.createPagedVariant(
145143
settings.listGroupStatsSettings(), this.channel, this.executor);
146144
this.listEventsCallable =
147-
ApiCallable.create(settings.listEventsSettings(), this.channel, this.executor);
145+
UnaryApiCallable.create(settings.listEventsSettings(), this.channel, this.executor);
148146
this.listEventsPagedCallable =
149-
ApiCallable.createPagedVariant(settings.listEventsSettings(), this.channel, this.executor);
147+
UnaryApiCallable.createPagedVariant(
148+
settings.listEventsSettings(), this.channel, this.executor);
150149
this.deleteEventsCallable =
151-
ApiCallable.create(settings.deleteEventsSettings(), this.channel, this.executor);
150+
UnaryApiCallable.create(settings.deleteEventsSettings(), this.channel, this.executor);
152151

153152
if (settings.getChannelProvider().shouldAutoClose()) {
154153
closeables.add(
@@ -195,13 +194,14 @@ public final ErrorStatsServiceSettings getSettings() {
195194
* href="https://support.google.com/cloud/answer/6158840"&gt;Google Cloud Platform project
196195
* ID&lt;/a&gt;.
197196
* <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.
197+
* @param timeRange [Required] List data for the given time range. Only
198+
* &lt;code&gt;ErrorGroupStats&lt;/code&gt; with a non-zero count in the given time range are
199+
* returned, unless the request contains an explicit group_id list. If a group_id list is
200+
* given, also &lt;code&gt;ErrorGroupStats&lt;/code&gt; with zero occurrences are returned.
201201
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
202202
*/
203-
public final PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
204-
listGroupStats(String projectName, QueryTimeRange timeRange) {
203+
public final ListGroupStatsPagedResponse listGroupStats(
204+
String projectName, QueryTimeRange timeRange) {
205205
PROJECT_PATH_TEMPLATE.validate(projectName, "listGroupStats");
206206
ListGroupStatsRequest request =
207207
ListGroupStatsRequest.newBuilder()
@@ -234,8 +234,7 @@ public final ErrorStatsServiceSettings getSettings() {
234234
* @param request The request object containing all of the parameters for the API call.
235235
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
236236
*/
237-
public final PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>
238-
listGroupStats(ListGroupStatsRequest request) {
237+
public final ListGroupStatsPagedResponse listGroupStats(ListGroupStatsRequest request) {
239238
return listGroupStatsPagedCallable().call(request);
240239
}
241240

@@ -253,17 +252,15 @@ public final ErrorStatsServiceSettings getSettings() {
253252
* .setProjectName(formattedProjectName)
254253
* .setTimeRange(timeRange)
255254
* .build();
256-
* ListenableFuture&lt;PagedListResponse&lt;ListGroupStatsRequest,ListGroupStatsResponse,ErrorGroupStats&gt;&gt; future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request);
255+
* ListenableFuture&lt;ListGroupStatsPagedResponse&gt; future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request);
257256
* // Do something
258257
* for (ErrorGroupStats element : future.get().iterateAllElements()) {
259258
* // doThingsWith(element);
260259
* }
261260
* }
262261
* </code></pre>
263262
*/
264-
public final ApiCallable<
265-
ListGroupStatsRequest,
266-
PagedListResponse<ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>>
263+
public final UnaryApiCallable<ListGroupStatsRequest, ListGroupStatsPagedResponse>
267264
listGroupStatsPagedCallable() {
268265
return listGroupStatsPagedCallable;
269266
}
@@ -297,7 +294,8 @@ public final ErrorStatsServiceSettings getSettings() {
297294
* }
298295
* </code></pre>
299296
*/
300-
public final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGroupStatsCallable() {
297+
public final UnaryApiCallable<ListGroupStatsRequest, ListGroupStatsResponse>
298+
listGroupStatsCallable() {
301299
return listGroupStatsCallable;
302300
}
303301

@@ -323,8 +321,7 @@ public final ApiCallable<ListGroupStatsRequest, ListGroupStatsResponse> listGrou
323321
* @param groupId [Required] The group for which events shall be returned.
324322
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
325323
*/
326-
public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> listEvents(
327-
String projectName, String groupId) {
324+
public final ListEventsPagedResponse listEvents(String projectName, String groupId) {
328325
PROJECT_PATH_TEMPLATE.validate(projectName, "listEvents");
329326
ListEventsRequest request =
330327
ListEventsRequest.newBuilder().setProjectName(projectName).setGroupId(groupId).build();
@@ -354,8 +351,7 @@ public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent
354351
* @param request The request object containing all of the parameters for the API call.
355352
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
356353
*/
357-
public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent> listEvents(
358-
ListEventsRequest request) {
354+
public final ListEventsPagedResponse listEvents(ListEventsRequest request) {
359355
return listEventsPagedCallable().call(request);
360356
}
361357

@@ -373,16 +369,15 @@ public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent
373369
* .setProjectName(formattedProjectName)
374370
* .setGroupId(groupId)
375371
* .build();
376-
* ListenableFuture&lt;PagedListResponse&lt;ListEventsRequest,ListEventsResponse,ErrorEvent&gt;&gt; future = errorStatsServiceApi.listEventsPagedCallable().futureCall(request);
372+
* ListenableFuture&lt;ListEventsPagedResponse&gt; future = errorStatsServiceApi.listEventsPagedCallable().futureCall(request);
377373
* // Do something
378374
* for (ErrorEvent element : future.get().iterateAllElements()) {
379375
* // doThingsWith(element);
380376
* }
381377
* }
382378
* </code></pre>
383379
*/
384-
public final ApiCallable<
385-
ListEventsRequest, PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent>>
380+
public final UnaryApiCallable<ListEventsRequest, ListEventsPagedResponse>
386381
listEventsPagedCallable() {
387382
return listEventsPagedCallable;
388383
}
@@ -416,7 +411,7 @@ public final PagedListResponse<ListEventsRequest, ListEventsResponse, ErrorEvent
416411
* }
417412
* </code></pre>
418413
*/
419-
public final ApiCallable<ListEventsRequest, ListEventsResponse> listEventsCallable() {
414+
public final UnaryApiCallable<ListEventsRequest, ListEventsResponse> listEventsCallable() {
420415
return listEventsCallable;
421416
}
422417

@@ -486,7 +481,7 @@ private final DeleteEventsResponse deleteEvents(DeleteEventsRequest request) {
486481
* }
487482
* </code></pre>
488483
*/
489-
public final ApiCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable() {
484+
public final UnaryApiCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable() {
490485
return deleteEventsCallable;
491486
}
492487

0 commit comments

Comments
 (0)