34
34
package com .google .gcloud .pubsub .spi .v1 ;
35
35
36
36
import com .google .api .gax .grpc .ApiCallable ;
37
- import com .google .api .gax .grpc .ApiCallable .BundlableApiCallableInfo ;
38
- import com .google .api .gax .grpc .BundlerFactory ;
39
37
import com .google .api .gax .protobuf .PathTemplate ;
40
38
import com .google .protobuf .Empty ;
41
39
import com .google .pubsub .v1 .DeleteTopicRequest ;
@@ -80,23 +78,9 @@ public class PublisherApi implements AutoCloseable {
80
78
listTopicSubscriptionsIterableCallable ;
81
79
private final ApiCallable <DeleteTopicRequest , Empty > deleteTopicCallable ;
82
80
83
- /**
84
- * A PathTemplate representing the fully-qualified path to represent
85
- * a project resource.
86
- *
87
- * <!-- manual edit -->
88
- * <!-- end manual edit -->
89
- */
90
81
private static final PathTemplate PROJECT_PATH_TEMPLATE =
91
82
PathTemplate .create ("projects/{project}" );
92
83
93
- /**
94
- * A PathTemplate representing the fully-qualified path to represent
95
- * a topic resource.
96
- *
97
- * <!-- manual edit -->
98
- * <!-- end manual edit -->
99
- */
100
84
private static final PathTemplate TOPIC_PATH_TEMPLATE =
101
85
PathTemplate .create ("projects/{project}/topics/{topic}" );
102
86
@@ -161,8 +145,8 @@ public static final String parseTopicFromTopicName(String topicName) {
161
145
* <!-- manual edit -->
162
146
* <!-- end manual edit -->
163
147
*/
164
- public static final PublisherApi create () throws IOException {
165
- return create (PublisherSettings .create ());
148
+ public static final PublisherApi defaultInstance () throws IOException {
149
+ return create (PublisherSettings .defaultInstance ());
166
150
}
167
151
168
152
/**
@@ -188,22 +172,20 @@ public static final PublisherApi create(PublisherSettings settings) throws IOExc
188
172
protected PublisherApi (PublisherSettings settings ) throws IOException {
189
173
this .channel = settings .getChannel ();
190
174
191
- this .createTopicCallable = settings .createTopicMethod ().build (settings );
192
- BundlableApiCallableInfo <PublishRequest , PublishResponse > bundlablePublish =
193
- settings .publishMethod ().buildBundlable (settings );
194
- this .publishCallable = bundlablePublish .getApiCallable ();
195
- BundlerFactory <PublishRequest , PublishResponse > publishBundlerFactory =
196
- bundlablePublish .getBundlerFactory ();
197
- if (publishBundlerFactory != null ) {
198
- this .closeables .add (publishBundlerFactory );
175
+ this .createTopicCallable = ApiCallable .create (settings .createTopicSettings (), settings );
176
+ this .publishCallable = ApiCallable .create (settings .publishSettings (), settings );
177
+ if (settings .publishSettings ().getBundlerFactory () != null ) {
178
+ closeables .add (settings .publishSettings ().getBundlerFactory ());
199
179
}
200
- this .getTopicCallable = settings .getTopicMethod ().build (settings );
201
- this .listTopicsCallable = settings .listTopicsMethod ().build (settings );
202
- this .listTopicsIterableCallable = settings .listTopicsMethod ().buildPageStreaming (settings );
203
- this .listTopicSubscriptionsCallable = settings .listTopicSubscriptionsMethod ().build (settings );
180
+ this .getTopicCallable = ApiCallable .create (settings .getTopicSettings (), settings );
181
+ this .listTopicsCallable = ApiCallable .create (settings .listTopicsSettings (), settings );
182
+ this .listTopicsIterableCallable =
183
+ ApiCallable .createIterable (settings .listTopicsSettings (), settings );
184
+ this .listTopicSubscriptionsCallable =
185
+ ApiCallable .create (settings .listTopicSubscriptionsSettings (), settings );
204
186
this .listTopicSubscriptionsIterableCallable =
205
- settings . listTopicSubscriptionsMethod (). buildPageStreaming ( settings );
206
- this .deleteTopicCallable = settings . deleteTopicMethod (). build ( settings );
187
+ ApiCallable . createIterable ( settings . listTopicSubscriptionsSettings (), settings );
188
+ this .deleteTopicCallable = ApiCallable . create ( settings . deleteTopicSettings (), settings );
207
189
208
190
if (settings .shouldAutoCloseChannel ()) {
209
191
closeables .add (
@@ -231,6 +213,7 @@ public void close() throws IOException {
231
213
* underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
232
214
* signs (`%`). It must be between 3 and 255 characters in length, and it
233
215
* must not start with `"goog"`.
216
+ * @throws ApiException if the remote call fails
234
217
*/
235
218
public final Topic createTopic (String name ) {
236
219
Topic request = Topic .newBuilder ().setName (name ).build ();
@@ -246,6 +229,7 @@ public final Topic createTopic(String name) {
246
229
* <!-- end manual edit -->
247
230
*
248
231
* @param request The request object containing all of the parameters for the API call.
232
+ * @throws ApiException if the remote call fails
249
233
*/
250
234
private Topic createTopic (Topic request ) {
251
235
return createTopicCallable ().call (request );
@@ -257,6 +241,7 @@ private Topic createTopic(Topic request) {
257
241
*
258
242
* <!-- manual edit -->
259
243
* <!-- end manual edit -->
244
+ * @throws ApiException if the remote call fails
260
245
*/
261
246
public final ApiCallable <Topic , Topic > createTopicCallable () {
262
247
return createTopicCallable ;
@@ -275,6 +260,7 @@ public final ApiCallable<Topic, Topic> createTopicCallable() {
275
260
*
276
261
* @param topic The messages in the request will be published on this topic.
277
262
* @param messages The messages to publish.
263
+ * @throws ApiException if the remote call fails
278
264
*/
279
265
public final PublishResponse publish (String topic , List <PubsubMessage > messages ) {
280
266
PublishRequest request =
@@ -293,6 +279,7 @@ public final PublishResponse publish(String topic, List<PubsubMessage> messages)
293
279
* <!-- end manual edit -->
294
280
*
295
281
* @param request The request object containing all of the parameters for the API call.
282
+ * @throws ApiException if the remote call fails
296
283
*/
297
284
public PublishResponse publish (PublishRequest request ) {
298
285
return publishCallable ().call (request );
@@ -306,6 +293,7 @@ public PublishResponse publish(PublishRequest request) {
306
293
*
307
294
* <!-- manual edit -->
308
295
* <!-- end manual edit -->
296
+ * @throws ApiException if the remote call fails
309
297
*/
310
298
public final ApiCallable <PublishRequest , PublishResponse > publishCallable () {
311
299
return publishCallable ;
@@ -321,6 +309,7 @@ public final ApiCallable<PublishRequest, PublishResponse> publishCallable() {
321
309
* <!-- end manual edit -->
322
310
*
323
311
* @param topic The name of the topic to get.
312
+ * @throws ApiException if the remote call fails
324
313
*/
325
314
public final Topic getTopic (String topic ) {
326
315
GetTopicRequest request = GetTopicRequest .newBuilder ().setTopic (topic ).build ();
@@ -336,6 +325,7 @@ public final Topic getTopic(String topic) {
336
325
* <!-- end manual edit -->
337
326
*
338
327
* @param request The request object containing all of the parameters for the API call.
328
+ * @throws ApiException if the remote call fails
339
329
*/
340
330
private Topic getTopic (GetTopicRequest request ) {
341
331
return getTopicCallable ().call (request );
@@ -347,6 +337,7 @@ private Topic getTopic(GetTopicRequest request) {
347
337
*
348
338
* <!-- manual edit -->
349
339
* <!-- end manual edit -->
340
+ * @throws ApiException if the remote call fails
350
341
*/
351
342
public final ApiCallable <GetTopicRequest , Topic > getTopicCallable () {
352
343
return getTopicCallable ;
@@ -360,6 +351,9 @@ public final ApiCallable<GetTopicRequest, Topic> getTopicCallable() {
360
351
*
361
352
* <!-- manual edit -->
362
353
* <!-- end manual edit -->
354
+ *
355
+ * @param project The name of the cloud project that topics belong to.
356
+ * @throws ApiException if the remote call fails
363
357
*/
364
358
public final Iterable <Topic > listTopics (String project ) {
365
359
ListTopicsRequest request = ListTopicsRequest .newBuilder ().setProject (project ).build ();
@@ -374,6 +368,7 @@ public final Iterable<Topic> listTopics(String project) {
374
368
* <!-- end manual edit -->
375
369
*
376
370
* @param request The request object containing all of the parameters for the API call.
371
+ * @throws ApiException if the remote call fails
377
372
*/
378
373
public final Iterable <Topic > listTopics (ListTopicsRequest request ) {
379
374
return listTopicsIterableCallable ().call (request );
@@ -385,6 +380,7 @@ public final Iterable<Topic> listTopics(ListTopicsRequest request) {
385
380
*
386
381
* <!-- manual edit -->
387
382
* <!-- end manual edit -->
383
+ * @throws ApiException if the remote call fails
388
384
*/
389
385
public final ApiCallable <ListTopicsRequest , Iterable <Topic >> listTopicsIterableCallable () {
390
386
return listTopicsIterableCallable ;
@@ -396,6 +392,7 @@ public final ApiCallable<ListTopicsRequest, Iterable<Topic>> listTopicsIterableC
396
392
*
397
393
* <!-- manual edit -->
398
394
* <!-- end manual edit -->
395
+ * @throws ApiException if the remote call fails
399
396
*/
400
397
public final ApiCallable <ListTopicsRequest , ListTopicsResponse > listTopicsCallable () {
401
398
return listTopicsCallable ;
@@ -409,6 +406,9 @@ public final ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallab
409
406
*
410
407
* <!-- manual edit -->
411
408
* <!-- end manual edit -->
409
+ *
410
+ * @param topic The name of the topic that subscriptions are attached to.
411
+ * @throws ApiException if the remote call fails
412
412
*/
413
413
public final Iterable <String > listTopicSubscriptions (String topic ) {
414
414
ListTopicSubscriptionsRequest request =
@@ -424,6 +424,7 @@ public final Iterable<String> listTopicSubscriptions(String topic) {
424
424
* <!-- end manual edit -->
425
425
*
426
426
* @param request The request object containing all of the parameters for the API call.
427
+ * @throws ApiException if the remote call fails
427
428
*/
428
429
public final Iterable <String > listTopicSubscriptions (ListTopicSubscriptionsRequest request ) {
429
430
return listTopicSubscriptionsIterableCallable ().call (request );
@@ -435,6 +436,7 @@ public final Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsReque
435
436
*
436
437
* <!-- manual edit -->
437
438
* <!-- end manual edit -->
439
+ * @throws ApiException if the remote call fails
438
440
*/
439
441
public final ApiCallable <ListTopicSubscriptionsRequest , Iterable <String >>
440
442
listTopicSubscriptionsIterableCallable () {
@@ -447,6 +449,7 @@ public final Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsReque
447
449
*
448
450
* <!-- manual edit -->
449
451
* <!-- end manual edit -->
452
+ * @throws ApiException if the remote call fails
450
453
*/
451
454
public final ApiCallable <ListTopicSubscriptionsRequest , ListTopicSubscriptionsResponse >
452
455
listTopicSubscriptionsCallable () {
@@ -467,6 +470,7 @@ public final Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsReque
467
470
* <!-- end manual edit -->
468
471
*
469
472
* @param topic Name of the topic to delete.
473
+ * @throws ApiException if the remote call fails
470
474
*/
471
475
public final void deleteTopic (String topic ) {
472
476
DeleteTopicRequest request = DeleteTopicRequest .newBuilder ().setTopic (topic ).build ();
@@ -486,6 +490,7 @@ public final void deleteTopic(String topic) {
486
490
* <!-- end manual edit -->
487
491
*
488
492
* @param request The request object containing all of the parameters for the API call.
493
+ * @throws ApiException if the remote call fails
489
494
*/
490
495
private void deleteTopic (DeleteTopicRequest request ) {
491
496
deleteTopicCallable ().call (request );
@@ -501,6 +506,7 @@ private void deleteTopic(DeleteTopicRequest request) {
501
506
*
502
507
* <!-- manual edit -->
503
508
* <!-- end manual edit -->
509
+ * @throws ApiException if the remote call fails
504
510
*/
505
511
public final ApiCallable <DeleteTopicRequest , Empty > deleteTopicCallable () {
506
512
return deleteTopicCallable ;
0 commit comments