3434package com .google .gcloud .pubsub .spi .v1 ;
3535
3636import com .google .api .gax .grpc .ApiCallable ;
37- import com .google .api .gax .grpc .ApiCallable .BundlableApiCallableInfo ;
38- import com .google .api .gax .grpc .BundlerFactory ;
3937import com .google .api .gax .protobuf .PathTemplate ;
4038import com .google .protobuf .Empty ;
4139import com .google .pubsub .v1 .DeleteTopicRequest ;
@@ -80,23 +78,9 @@ public class PublisherApi implements AutoCloseable {
8078 listTopicSubscriptionsIterableCallable ;
8179 private final ApiCallable <DeleteTopicRequest , Empty > deleteTopicCallable ;
8280
83- /**
84- * A PathTemplate representing the fully-qualified path to represent
85- * a project resource.
86- *
87- * <!-- manual edit -->
88- * <!-- end manual edit -->
89- */
9081 private static final PathTemplate PROJECT_PATH_TEMPLATE =
9182 PathTemplate .create ("projects/{project}" );
9283
93- /**
94- * A PathTemplate representing the fully-qualified path to represent
95- * a topic resource.
96- *
97- * <!-- manual edit -->
98- * <!-- end manual edit -->
99- */
10084 private static final PathTemplate TOPIC_PATH_TEMPLATE =
10185 PathTemplate .create ("projects/{project}/topics/{topic}" );
10286
@@ -161,8 +145,8 @@ public static final String parseTopicFromTopicName(String topicName) {
161145 * <!-- manual edit -->
162146 * <!-- end manual edit -->
163147 */
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 ());
166150 }
167151
168152 /**
@@ -188,22 +172,20 @@ public static final PublisherApi create(PublisherSettings settings) throws IOExc
188172 protected PublisherApi (PublisherSettings settings ) throws IOException {
189173 this .channel = settings .getChannel ();
190174
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 ());
199179 }
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 );
204186 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 );
207189
208190 if (settings .shouldAutoCloseChannel ()) {
209191 closeables .add (
@@ -231,6 +213,7 @@ public void close() throws IOException {
231213 * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
232214 * signs (`%`). It must be between 3 and 255 characters in length, and it
233215 * must not start with `"goog"`.
216+ * @throws ApiException if the remote call fails
234217 */
235218 public final Topic createTopic (String name ) {
236219 Topic request = Topic .newBuilder ().setName (name ).build ();
@@ -246,6 +229,7 @@ public final Topic createTopic(String name) {
246229 * <!-- end manual edit -->
247230 *
248231 * @param request The request object containing all of the parameters for the API call.
232+ * @throws ApiException if the remote call fails
249233 */
250234 private Topic createTopic (Topic request ) {
251235 return createTopicCallable ().call (request );
@@ -257,6 +241,7 @@ private Topic createTopic(Topic request) {
257241 *
258242 * <!-- manual edit -->
259243 * <!-- end manual edit -->
244+ * @throws ApiException if the remote call fails
260245 */
261246 public final ApiCallable <Topic , Topic > createTopicCallable () {
262247 return createTopicCallable ;
@@ -275,6 +260,7 @@ public final ApiCallable<Topic, Topic> createTopicCallable() {
275260 *
276261 * @param topic The messages in the request will be published on this topic.
277262 * @param messages The messages to publish.
263+ * @throws ApiException if the remote call fails
278264 */
279265 public final PublishResponse publish (String topic , List <PubsubMessage > messages ) {
280266 PublishRequest request =
@@ -293,6 +279,7 @@ public final PublishResponse publish(String topic, List<PubsubMessage> messages)
293279 * <!-- end manual edit -->
294280 *
295281 * @param request The request object containing all of the parameters for the API call.
282+ * @throws ApiException if the remote call fails
296283 */
297284 public PublishResponse publish (PublishRequest request ) {
298285 return publishCallable ().call (request );
@@ -306,6 +293,7 @@ public PublishResponse publish(PublishRequest request) {
306293 *
307294 * <!-- manual edit -->
308295 * <!-- end manual edit -->
296+ * @throws ApiException if the remote call fails
309297 */
310298 public final ApiCallable <PublishRequest , PublishResponse > publishCallable () {
311299 return publishCallable ;
@@ -321,6 +309,7 @@ public final ApiCallable<PublishRequest, PublishResponse> publishCallable() {
321309 * <!-- end manual edit -->
322310 *
323311 * @param topic The name of the topic to get.
312+ * @throws ApiException if the remote call fails
324313 */
325314 public final Topic getTopic (String topic ) {
326315 GetTopicRequest request = GetTopicRequest .newBuilder ().setTopic (topic ).build ();
@@ -336,6 +325,7 @@ public final Topic getTopic(String topic) {
336325 * <!-- end manual edit -->
337326 *
338327 * @param request The request object containing all of the parameters for the API call.
328+ * @throws ApiException if the remote call fails
339329 */
340330 private Topic getTopic (GetTopicRequest request ) {
341331 return getTopicCallable ().call (request );
@@ -347,6 +337,7 @@ private Topic getTopic(GetTopicRequest request) {
347337 *
348338 * <!-- manual edit -->
349339 * <!-- end manual edit -->
340+ * @throws ApiException if the remote call fails
350341 */
351342 public final ApiCallable <GetTopicRequest , Topic > getTopicCallable () {
352343 return getTopicCallable ;
@@ -360,6 +351,9 @@ public final ApiCallable<GetTopicRequest, Topic> getTopicCallable() {
360351 *
361352 * <!-- manual edit -->
362353 * <!-- 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
363357 */
364358 public final Iterable <Topic > listTopics (String project ) {
365359 ListTopicsRequest request = ListTopicsRequest .newBuilder ().setProject (project ).build ();
@@ -374,6 +368,7 @@ public final Iterable<Topic> listTopics(String project) {
374368 * <!-- end manual edit -->
375369 *
376370 * @param request The request object containing all of the parameters for the API call.
371+ * @throws ApiException if the remote call fails
377372 */
378373 public final Iterable <Topic > listTopics (ListTopicsRequest request ) {
379374 return listTopicsIterableCallable ().call (request );
@@ -385,6 +380,7 @@ public final Iterable<Topic> listTopics(ListTopicsRequest request) {
385380 *
386381 * <!-- manual edit -->
387382 * <!-- end manual edit -->
383+ * @throws ApiException if the remote call fails
388384 */
389385 public final ApiCallable <ListTopicsRequest , Iterable <Topic >> listTopicsIterableCallable () {
390386 return listTopicsIterableCallable ;
@@ -396,6 +392,7 @@ public final ApiCallable<ListTopicsRequest, Iterable<Topic>> listTopicsIterableC
396392 *
397393 * <!-- manual edit -->
398394 * <!-- end manual edit -->
395+ * @throws ApiException if the remote call fails
399396 */
400397 public final ApiCallable <ListTopicsRequest , ListTopicsResponse > listTopicsCallable () {
401398 return listTopicsCallable ;
@@ -409,6 +406,9 @@ public final ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallab
409406 *
410407 * <!-- manual edit -->
411408 * <!-- 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
412412 */
413413 public final Iterable <String > listTopicSubscriptions (String topic ) {
414414 ListTopicSubscriptionsRequest request =
@@ -424,6 +424,7 @@ public final Iterable<String> listTopicSubscriptions(String topic) {
424424 * <!-- end manual edit -->
425425 *
426426 * @param request The request object containing all of the parameters for the API call.
427+ * @throws ApiException if the remote call fails
427428 */
428429 public final Iterable <String > listTopicSubscriptions (ListTopicSubscriptionsRequest request ) {
429430 return listTopicSubscriptionsIterableCallable ().call (request );
@@ -435,6 +436,7 @@ public final Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsReque
435436 *
436437 * <!-- manual edit -->
437438 * <!-- end manual edit -->
439+ * @throws ApiException if the remote call fails
438440 */
439441 public final ApiCallable <ListTopicSubscriptionsRequest , Iterable <String >>
440442 listTopicSubscriptionsIterableCallable () {
@@ -447,6 +449,7 @@ public final Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsReque
447449 *
448450 * <!-- manual edit -->
449451 * <!-- end manual edit -->
452+ * @throws ApiException if the remote call fails
450453 */
451454 public final ApiCallable <ListTopicSubscriptionsRequest , ListTopicSubscriptionsResponse >
452455 listTopicSubscriptionsCallable () {
@@ -467,6 +470,7 @@ public final Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsReque
467470 * <!-- end manual edit -->
468471 *
469472 * @param topic Name of the topic to delete.
473+ * @throws ApiException if the remote call fails
470474 */
471475 public final void deleteTopic (String topic ) {
472476 DeleteTopicRequest request = DeleteTopicRequest .newBuilder ().setTopic (topic ).build ();
@@ -486,6 +490,7 @@ public final void deleteTopic(String topic) {
486490 * <!-- end manual edit -->
487491 *
488492 * @param request The request object containing all of the parameters for the API call.
493+ * @throws ApiException if the remote call fails
489494 */
490495 private void deleteTopic (DeleteTopicRequest request ) {
491496 deleteTopicCallable ().call (request );
@@ -501,6 +506,7 @@ private void deleteTopic(DeleteTopicRequest request) {
501506 *
502507 * <!-- manual edit -->
503508 * <!-- end manual edit -->
509+ * @throws ApiException if the remote call fails
504510 */
505511 public final ApiCallable <DeleteTopicRequest , Empty > deleteTopicCallable () {
506512 return deleteTopicCallable ;
0 commit comments