From b42165e31c870f44e3c5728b4b4c377ca55a903f Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 16 Feb 2021 10:22:02 -0800 Subject: [PATCH] docs: generate sample code in the Java microgenerator (#498) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/128acacc-8b90-47cc-a3cd-e13068edfb12/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 356341083 Source-Link: https://github.com/googleapis/googleapis/commit/8d8c008e56f1af31d57f75561e0f1848ffb29eeb --- .../pubsublite/v1/AdminServiceClient.java | 614 ++++++++++++++++++ .../pubsublite/v1/CursorServiceClient.java | 131 ++++ .../v1/PartitionAssignmentServiceClient.java | 26 + .../pubsublite/v1/PublisherServiceClient.java | 24 + .../v1/SubscriberServiceClient.java | 24 + .../v1/TopicStatsServiceClient.java | 71 ++ .../cloud/pubsublite/v1/package-info.java | 71 ++ synth.metadata | 4 +- 8 files changed, 963 insertions(+), 2 deletions(-) diff --git a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/AdminServiceClient.java b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/AdminServiceClient.java index 00fa9027a..e1eef0ce4 100644 --- a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/AdminServiceClient.java +++ b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/AdminServiceClient.java @@ -65,6 +65,15 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+ *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ *   Topic topic = Topic.newBuilder().build();
+ *   String topicId = "topicId-1139259734";
+ *   Topic response = adminServiceClient.createTopic(parent, topic, topicId);
+ * }
+ * }
+ * *

Note: close() needs to be called on the AdminServiceClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -167,6 +176,17 @@ public AdminServiceStub getStub() { /** * Creates a new topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   Topic topic = Topic.newBuilder().build();
+   *   String topicId = "topicId-1139259734";
+   *   Topic response = adminServiceClient.createTopic(parent, topic, topicId);
+   * }
+   * }
+ * * @param parent Required. The parent location in which to create the topic. Structured like * `projects/{project_number}/locations/{location}`. * @param topic Required. Configuration of the topic to create. Its `name` field is ignored. @@ -189,6 +209,17 @@ public final Topic createTopic(LocationName parent, Topic topic, String topicId) /** * Creates a new topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   Topic topic = Topic.newBuilder().build();
+   *   String topicId = "topicId-1139259734";
+   *   Topic response = adminServiceClient.createTopic(parent, topic, topicId);
+   * }
+   * }
+ * * @param parent Required. The parent location in which to create the topic. Structured like * `projects/{project_number}/locations/{location}`. * @param topic Required. Configuration of the topic to create. Its `name` field is ignored. @@ -211,6 +242,20 @@ public final Topic createTopic(String parent, Topic topic, String topicId) { /** * Creates a new topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   CreateTopicRequest request =
+   *       CreateTopicRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setTopic(Topic.newBuilder().build())
+   *           .setTopicId("topicId-1139259734")
+   *           .build();
+   *   Topic response = adminServiceClient.createTopic(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -223,6 +268,20 @@ public final Topic createTopic(CreateTopicRequest request) { * Creates a new topic. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   CreateTopicRequest request =
+   *       CreateTopicRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setTopic(Topic.newBuilder().build())
+   *           .setTopicId("topicId-1139259734")
+   *           .build();
+   *   ApiFuture future = adminServiceClient.createTopicCallable().futureCall(request);
+   *   // Do something.
+   *   Topic response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createTopicCallable() { return stub.createTopicCallable(); @@ -232,6 +291,15 @@ public final UnaryCallable createTopicCallable() { /** * Returns the topic configuration. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   TopicName name = TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]");
+   *   Topic response = adminServiceClient.getTopic(name);
+   * }
+   * }
+ * * @param name Required. The name of the topic whose configuration to return. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -245,6 +313,15 @@ public final Topic getTopic(TopicName name) { /** * Returns the topic configuration. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String name = TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString();
+   *   Topic response = adminServiceClient.getTopic(name);
+   * }
+   * }
+ * * @param name Required. The name of the topic whose configuration to return. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -257,6 +334,18 @@ public final Topic getTopic(String name) { /** * Returns the topic configuration. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   GetTopicRequest request =
+   *       GetTopicRequest.newBuilder()
+   *           .setName(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .build();
+   *   Topic response = adminServiceClient.getTopic(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -269,6 +358,18 @@ public final Topic getTopic(GetTopicRequest request) { * Returns the topic configuration. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   GetTopicRequest request =
+   *       GetTopicRequest.newBuilder()
+   *           .setName(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .build();
+   *   ApiFuture future = adminServiceClient.getTopicCallable().futureCall(request);
+   *   // Do something.
+   *   Topic response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getTopicCallable() { return stub.getTopicCallable(); @@ -278,6 +379,15 @@ public final UnaryCallable getTopicCallable() { /** * Returns the partition information for the requested topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   TopicName name = TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]");
+   *   TopicPartitions response = adminServiceClient.getTopicPartitions(name);
+   * }
+   * }
+ * * @param name Required. The topic whose partition information to return. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -293,6 +403,15 @@ public final TopicPartitions getTopicPartitions(TopicName name) { /** * Returns the partition information for the requested topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String name = TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString();
+   *   TopicPartitions response = adminServiceClient.getTopicPartitions(name);
+   * }
+   * }
+ * * @param name Required. The topic whose partition information to return. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -306,6 +425,18 @@ public final TopicPartitions getTopicPartitions(String name) { /** * Returns the partition information for the requested topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   GetTopicPartitionsRequest request =
+   *       GetTopicPartitionsRequest.newBuilder()
+   *           .setName(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .build();
+   *   TopicPartitions response = adminServiceClient.getTopicPartitions(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -318,6 +449,19 @@ public final TopicPartitions getTopicPartitions(GetTopicPartitionsRequest reques * Returns the partition information for the requested topic. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   GetTopicPartitionsRequest request =
+   *       GetTopicPartitionsRequest.newBuilder()
+   *           .setName(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       adminServiceClient.getTopicPartitionsCallable().futureCall(request);
+   *   // Do something.
+   *   TopicPartitions response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getTopicPartitionsCallable() { @@ -328,6 +472,17 @@ public final TopicPartitions getTopicPartitions(GetTopicPartitionsRequest reques /** * Returns the list of topics for the given project. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (Topic element : adminServiceClient.listTopics(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent whose topics are to be listed. Structured like * `projects/{project_number}/locations/{location}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -342,6 +497,17 @@ public final ListTopicsPagedResponse listTopics(LocationName parent) { /** * Returns the list of topics for the given project. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   for (Topic element : adminServiceClient.listTopics(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent whose topics are to be listed. Structured like * `projects/{project_number}/locations/{location}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -355,6 +521,22 @@ public final ListTopicsPagedResponse listTopics(String parent) { /** * Returns the list of topics for the given project. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   ListTopicsRequest request =
+   *       ListTopicsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Topic element : adminServiceClient.listTopics(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -367,6 +549,22 @@ public final ListTopicsPagedResponse listTopics(ListTopicsRequest request) { * Returns the list of topics for the given project. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   ListTopicsRequest request =
+   *       ListTopicsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future = adminServiceClient.listTopicsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Topic element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listTopicsPagedCallable() { return stub.listTopicsPagedCallable(); @@ -377,6 +575,23 @@ public final UnaryCallable listTopic * Returns the list of topics for the given project. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   while (true) {
+   *     ListTopicsResponse response = adminServiceClient.listTopicsCallable().call(request);
+   *     for (Topic element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listTopicsCallable() { return stub.listTopicsCallable(); @@ -386,6 +601,16 @@ public final UnaryCallable listTopicsCall /** * Updates properties of the specified topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   Topic topic = Topic.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Topic response = adminServiceClient.updateTopic(topic, updateMask);
+   * }
+   * }
+ * * @param topic Required. The topic to update. Its `name` field must be populated. * @param updateMask Required. A mask specifying the topic fields to change. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -400,6 +625,19 @@ public final Topic updateTopic(Topic topic, FieldMask updateMask) { /** * Updates properties of the specified topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   UpdateTopicRequest request =
+   *       UpdateTopicRequest.newBuilder()
+   *           .setTopic(Topic.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Topic response = adminServiceClient.updateTopic(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -412,6 +650,19 @@ public final Topic updateTopic(UpdateTopicRequest request) { * Updates properties of the specified topic. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   UpdateTopicRequest request =
+   *       UpdateTopicRequest.newBuilder()
+   *           .setTopic(Topic.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = adminServiceClient.updateTopicCallable().futureCall(request);
+   *   // Do something.
+   *   Topic response = future.get();
+   * }
+   * }
*/ public final UnaryCallable updateTopicCallable() { return stub.updateTopicCallable(); @@ -421,6 +672,15 @@ public final UnaryCallable updateTopicCallable() { /** * Deletes the specified topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   TopicName name = TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]");
+   *   adminServiceClient.deleteTopic(name);
+   * }
+   * }
+ * * @param name Required. The name of the topic to delete. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -434,6 +694,15 @@ public final void deleteTopic(TopicName name) { /** * Deletes the specified topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String name = TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString();
+   *   adminServiceClient.deleteTopic(name);
+   * }
+   * }
+ * * @param name Required. The name of the topic to delete. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -446,6 +715,18 @@ public final void deleteTopic(String name) { /** * Deletes the specified topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   DeleteTopicRequest request =
+   *       DeleteTopicRequest.newBuilder()
+   *           .setName(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .build();
+   *   adminServiceClient.deleteTopic(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -458,6 +739,18 @@ public final void deleteTopic(DeleteTopicRequest request) { * Deletes the specified topic. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   DeleteTopicRequest request =
+   *       DeleteTopicRequest.newBuilder()
+   *           .setName(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .build();
+   *   ApiFuture future = adminServiceClient.deleteTopicCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteTopicCallable() { return stub.deleteTopicCallable(); @@ -467,6 +760,17 @@ public final UnaryCallable deleteTopicCallable() { /** * Lists the subscriptions attached to the specified topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   TopicName name = TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]");
+   *   for (String element : adminServiceClient.listTopicSubscriptions(name).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param name Required. The name of the topic whose subscriptions to list. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -482,6 +786,17 @@ public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions(TopicNam /** * Lists the subscriptions attached to the specified topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String name = TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString();
+   *   for (String element : adminServiceClient.listTopicSubscriptions(name).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param name Required. The name of the topic whose subscriptions to list. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -495,6 +810,22 @@ public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions(String n /** * Lists the subscriptions attached to the specified topic. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   ListTopicSubscriptionsRequest request =
+   *       ListTopicSubscriptionsRequest.newBuilder()
+   *           .setName(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (String element : adminServiceClient.listTopicSubscriptions(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -508,6 +839,23 @@ public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions( * Lists the subscriptions attached to the specified topic. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   ListTopicSubscriptionsRequest request =
+   *       ListTopicSubscriptionsRequest.newBuilder()
+   *           .setName(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       adminServiceClient.listTopicSubscriptionsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (String element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listTopicSubscriptionsPagedCallable() { @@ -519,6 +867,24 @@ public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions( * Lists the subscriptions attached to the specified topic. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   while (true) {
+   *     ListTopicSubscriptionsResponse response =
+   *         adminServiceClient.listTopicSubscriptionsCallable().call(request);
+   *     for (String element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listTopicSubscriptionsCallable() { @@ -529,6 +895,18 @@ public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions( /** * Creates a new subscription. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   Subscription subscription = Subscription.newBuilder().build();
+   *   String subscriptionId = "subscriptionId1478790936";
+   *   Subscription response =
+   *       adminServiceClient.createSubscription(parent, subscription, subscriptionId);
+   * }
+   * }
+ * * @param parent Required. The parent location in which to create the subscription. Structured * like `projects/{project_number}/locations/{location}`. * @param subscription Required. Configuration of the subscription to create. Its `name` field is @@ -553,6 +931,18 @@ public final Subscription createSubscription( /** * Creates a new subscription. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   Subscription subscription = Subscription.newBuilder().build();
+   *   String subscriptionId = "subscriptionId1478790936";
+   *   Subscription response =
+   *       adminServiceClient.createSubscription(parent, subscription, subscriptionId);
+   * }
+   * }
+ * * @param parent Required. The parent location in which to create the subscription. Structured * like `projects/{project_number}/locations/{location}`. * @param subscription Required. Configuration of the subscription to create. Its `name` field is @@ -577,6 +967,20 @@ public final Subscription createSubscription( /** * Creates a new subscription. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   CreateSubscriptionRequest request =
+   *       CreateSubscriptionRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setSubscription(Subscription.newBuilder().build())
+   *           .setSubscriptionId("subscriptionId1478790936")
+   *           .build();
+   *   Subscription response = adminServiceClient.createSubscription(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -589,6 +993,21 @@ public final Subscription createSubscription(CreateSubscriptionRequest request) * Creates a new subscription. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   CreateSubscriptionRequest request =
+   *       CreateSubscriptionRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setSubscription(Subscription.newBuilder().build())
+   *           .setSubscriptionId("subscriptionId1478790936")
+   *           .build();
+   *   ApiFuture future =
+   *       adminServiceClient.createSubscriptionCallable().futureCall(request);
+   *   // Do something.
+   *   Subscription response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createSubscriptionCallable() { return stub.createSubscriptionCallable(); @@ -598,6 +1017,15 @@ public final UnaryCallable createSubscr /** * Returns the subscription configuration. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   SubscriptionName name = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
+   *   Subscription response = adminServiceClient.getSubscription(name);
+   * }
+   * }
+ * * @param name Required. The name of the subscription whose configuration to return. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -611,6 +1039,15 @@ public final Subscription getSubscription(SubscriptionName name) { /** * Returns the subscription configuration. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String name = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString();
+   *   Subscription response = adminServiceClient.getSubscription(name);
+   * }
+   * }
+ * * @param name Required. The name of the subscription whose configuration to return. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -623,6 +1060,18 @@ public final Subscription getSubscription(String name) { /** * Returns the subscription configuration. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   GetSubscriptionRequest request =
+   *       GetSubscriptionRequest.newBuilder()
+   *           .setName(SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
+   *           .build();
+   *   Subscription response = adminServiceClient.getSubscription(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -635,6 +1084,19 @@ public final Subscription getSubscription(GetSubscriptionRequest request) { * Returns the subscription configuration. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   GetSubscriptionRequest request =
+   *       GetSubscriptionRequest.newBuilder()
+   *           .setName(SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       adminServiceClient.getSubscriptionCallable().futureCall(request);
+   *   // Do something.
+   *   Subscription response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getSubscriptionCallable() { return stub.getSubscriptionCallable(); @@ -644,6 +1106,17 @@ public final UnaryCallable getSubscription /** * Returns the list of subscriptions for the given project. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (Subscription element : adminServiceClient.listSubscriptions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent whose subscriptions are to be listed. Structured like * `projects/{project_number}/locations/{location}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -660,6 +1133,17 @@ public final ListSubscriptionsPagedResponse listSubscriptions(LocationName paren /** * Returns the list of subscriptions for the given project. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   for (Subscription element : adminServiceClient.listSubscriptions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent whose subscriptions are to be listed. Structured like * `projects/{project_number}/locations/{location}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -674,6 +1158,22 @@ public final ListSubscriptionsPagedResponse listSubscriptions(String parent) { /** * Returns the list of subscriptions for the given project. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   ListSubscriptionsRequest request =
+   *       ListSubscriptionsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Subscription element : adminServiceClient.listSubscriptions(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -686,6 +1186,23 @@ public final ListSubscriptionsPagedResponse listSubscriptions(ListSubscriptionsR * Returns the list of subscriptions for the given project. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   ListSubscriptionsRequest request =
+   *       ListSubscriptionsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       adminServiceClient.listSubscriptionsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Subscription element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listSubscriptionsPagedCallable() { @@ -697,6 +1214,24 @@ public final ListSubscriptionsPagedResponse listSubscriptions(ListSubscriptionsR * Returns the list of subscriptions for the given project. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   while (true) {
+   *     ListSubscriptionsResponse response =
+   *         adminServiceClient.listSubscriptionsCallable().call(request);
+   *     for (Subscription element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listSubscriptionsCallable() { @@ -707,6 +1242,16 @@ public final ListSubscriptionsPagedResponse listSubscriptions(ListSubscriptionsR /** * Updates properties of the specified subscription. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   Subscription subscription = Subscription.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Subscription response = adminServiceClient.updateSubscription(subscription, updateMask);
+   * }
+   * }
+ * * @param subscription Required. The subscription to update. Its `name` field must be populated. * Topic field must not be populated. * @param updateMask Required. A mask specifying the subscription fields to change. @@ -725,6 +1270,19 @@ public final Subscription updateSubscription(Subscription subscription, FieldMas /** * Updates properties of the specified subscription. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   UpdateSubscriptionRequest request =
+   *       UpdateSubscriptionRequest.newBuilder()
+   *           .setSubscription(Subscription.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Subscription response = adminServiceClient.updateSubscription(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -737,6 +1295,20 @@ public final Subscription updateSubscription(UpdateSubscriptionRequest request) * Updates properties of the specified subscription. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   UpdateSubscriptionRequest request =
+   *       UpdateSubscriptionRequest.newBuilder()
+   *           .setSubscription(Subscription.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       adminServiceClient.updateSubscriptionCallable().futureCall(request);
+   *   // Do something.
+   *   Subscription response = future.get();
+   * }
+   * }
*/ public final UnaryCallable updateSubscriptionCallable() { return stub.updateSubscriptionCallable(); @@ -746,6 +1318,15 @@ public final UnaryCallable updateSubscr /** * Deletes the specified subscription. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   SubscriptionName name = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
+   *   adminServiceClient.deleteSubscription(name);
+   * }
+   * }
+ * * @param name Required. The name of the subscription to delete. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -761,6 +1342,15 @@ public final void deleteSubscription(SubscriptionName name) { /** * Deletes the specified subscription. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   String name = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString();
+   *   adminServiceClient.deleteSubscription(name);
+   * }
+   * }
+ * * @param name Required. The name of the subscription to delete. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -774,6 +1364,18 @@ public final void deleteSubscription(String name) { /** * Deletes the specified subscription. * + *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   DeleteSubscriptionRequest request =
+   *       DeleteSubscriptionRequest.newBuilder()
+   *           .setName(SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
+   *           .build();
+   *   adminServiceClient.deleteSubscription(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -786,6 +1388,18 @@ public final void deleteSubscription(DeleteSubscriptionRequest request) { * Deletes the specified subscription. * *

Sample code: + * + *

{@code
+   * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+   *   DeleteSubscriptionRequest request =
+   *       DeleteSubscriptionRequest.newBuilder()
+   *           .setName(SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
+   *           .build();
+   *   ApiFuture future = adminServiceClient.deleteSubscriptionCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteSubscriptionCallable() { return stub.deleteSubscriptionCallable(); diff --git a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/CursorServiceClient.java b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/CursorServiceClient.java index 32c67fd42..5524aa5cc 100644 --- a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/CursorServiceClient.java +++ b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/CursorServiceClient.java @@ -52,6 +52,18 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+ *   CommitCursorRequest request =
+ *       CommitCursorRequest.newBuilder()
+ *           .setSubscription("subscription341203229")
+ *           .setPartition(-1799810326)
+ *           .setCursor(Cursor.newBuilder().build())
+ *           .build();
+ *   CommitCursorResponse response = cursorServiceClient.commitCursor(request);
+ * }
+ * }
+ * *

Note: close() needs to be called on the CursorServiceClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -156,6 +168,18 @@ public CursorServiceStub getStub() { * Establishes a stream with the server for managing committed cursors. * *

Sample code: + * + *

{@code
+   * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+   *   BidiStream bidiStream =
+   *       cursorServiceClient.streamingCommitCursorCallable().call();
+   *   StreamingCommitCursorRequest request = StreamingCommitCursorRequest.newBuilder().build();
+   *   bidiStream.send(request);
+   *   for (StreamingCommitCursorResponse response : bidiStream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
*/ public final BidiStreamingCallable streamingCommitCursorCallable() { @@ -166,6 +190,20 @@ public CursorServiceStub getStub() { /** * Updates the committed cursor. * + *

Sample code: + * + *

{@code
+   * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+   *   CommitCursorRequest request =
+   *       CommitCursorRequest.newBuilder()
+   *           .setSubscription("subscription341203229")
+   *           .setPartition(-1799810326)
+   *           .setCursor(Cursor.newBuilder().build())
+   *           .build();
+   *   CommitCursorResponse response = cursorServiceClient.commitCursor(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -178,6 +216,21 @@ public final CommitCursorResponse commitCursor(CommitCursorRequest request) { * Updates the committed cursor. * *

Sample code: + * + *

{@code
+   * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+   *   CommitCursorRequest request =
+   *       CommitCursorRequest.newBuilder()
+   *           .setSubscription("subscription341203229")
+   *           .setPartition(-1799810326)
+   *           .setCursor(Cursor.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       cursorServiceClient.commitCursorCallable().futureCall(request);
+   *   // Do something.
+   *   CommitCursorResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable commitCursorCallable() { return stub.commitCursorCallable(); @@ -187,6 +240,18 @@ public final UnaryCallable commitCurs /** * Returns all committed cursor information for a subscription. * + *

Sample code: + * + *

{@code
+   * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+   *   SubscriptionName parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
+   *   for (PartitionCursor element :
+   *       cursorServiceClient.listPartitionCursors(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The subscription for which to retrieve cursors. Structured like * `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -203,6 +268,18 @@ public final ListPartitionCursorsPagedResponse listPartitionCursors(Subscription /** * Returns all committed cursor information for a subscription. * + *

Sample code: + * + *

{@code
+   * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+   *   String parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString();
+   *   for (PartitionCursor element :
+   *       cursorServiceClient.listPartitionCursors(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The subscription for which to retrieve cursors. Structured like * `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -217,6 +294,24 @@ public final ListPartitionCursorsPagedResponse listPartitionCursors(String paren /** * Returns all committed cursor information for a subscription. * + *

Sample code: + * + *

{@code
+   * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+   *   ListPartitionCursorsRequest request =
+   *       ListPartitionCursorsRequest.newBuilder()
+   *           .setParent(
+   *               SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (PartitionCursor element :
+   *       cursorServiceClient.listPartitionCursors(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -230,6 +325,24 @@ public final ListPartitionCursorsPagedResponse listPartitionCursors( * Returns all committed cursor information for a subscription. * *

Sample code: + * + *

{@code
+   * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+   *   ListPartitionCursorsRequest request =
+   *       ListPartitionCursorsRequest.newBuilder()
+   *           .setParent(
+   *               SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       cursorServiceClient.listPartitionCursorsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (PartitionCursor element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listPartitionCursorsPagedCallable() { @@ -241,6 +354,24 @@ public final ListPartitionCursorsPagedResponse listPartitionCursors( * Returns all committed cursor information for a subscription. * *

Sample code: + * + *

{@code
+   * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+   *   while (true) {
+   *     ListPartitionCursorsResponse response =
+   *         cursorServiceClient.listPartitionCursorsCallable().call(request);
+   *     for (PartitionCursor element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listPartitionCursorsCallable() { diff --git a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/PartitionAssignmentServiceClient.java b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/PartitionAssignmentServiceClient.java index fe1b16efc..38ccb0d04 100644 --- a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/PartitionAssignmentServiceClient.java +++ b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/PartitionAssignmentServiceClient.java @@ -35,6 +35,19 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (PartitionAssignmentServiceClient partitionAssignmentServiceClient =
+ *     PartitionAssignmentServiceClient.create()) {
+ *   BidiStream bidiStream =
+ *       partitionAssignmentServiceClient.assignPartitionsCallable().call();
+ *   PartitionAssignmentRequest request = PartitionAssignmentRequest.newBuilder().build();
+ *   bidiStream.send(request);
+ *   for (PartitionAssignment response : bidiStream) {
+ *     // Do something when a response is received.
+ *   }
+ * }
+ * }
+ * *

Note: close() needs to be called on the PartitionAssignmentServiceClient object to clean up * resources such as threads. In the example above, try-with-resources is used, which automatically * calls close(). @@ -149,6 +162,19 @@ public PartitionAssignmentServiceStub getStub() { * reflect the new assignment. * *

Sample code: + * + *

{@code
+   * try (PartitionAssignmentServiceClient partitionAssignmentServiceClient =
+   *     PartitionAssignmentServiceClient.create()) {
+   *   BidiStream bidiStream =
+   *       partitionAssignmentServiceClient.assignPartitionsCallable().call();
+   *   PartitionAssignmentRequest request = PartitionAssignmentRequest.newBuilder().build();
+   *   bidiStream.send(request);
+   *   for (PartitionAssignment response : bidiStream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
*/ public final BidiStreamingCallable assignPartitionsCallable() { diff --git a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/PublisherServiceClient.java b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/PublisherServiceClient.java index cf6d8acd2..43b65cb37 100644 --- a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/PublisherServiceClient.java +++ b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/PublisherServiceClient.java @@ -37,6 +37,18 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (PublisherServiceClient publisherServiceClient = PublisherServiceClient.create()) {
+ *   BidiStream bidiStream =
+ *       publisherServiceClient.publishCallable().call();
+ *   PublishRequest request = PublishRequest.newBuilder().build();
+ *   bidiStream.send(request);
+ *   for (PublishResponse response : bidiStream) {
+ *     // Do something when a response is received.
+ *   }
+ * }
+ * }
+ * *

Note: close() needs to be called on the PublisherServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -149,6 +161,18 @@ public PublisherServiceStub getStub() { * stream. * *

Sample code: + * + *

{@code
+   * try (PublisherServiceClient publisherServiceClient = PublisherServiceClient.create()) {
+   *   BidiStream bidiStream =
+   *       publisherServiceClient.publishCallable().call();
+   *   PublishRequest request = PublishRequest.newBuilder().build();
+   *   bidiStream.send(request);
+   *   for (PublishResponse response : bidiStream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
*/ public final BidiStreamingCallable publishCallable() { return stub.publishCallable(); diff --git a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/SubscriberServiceClient.java b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/SubscriberServiceClient.java index 7319e5224..ab4ea922b 100644 --- a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/SubscriberServiceClient.java +++ b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/SubscriberServiceClient.java @@ -35,6 +35,18 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (SubscriberServiceClient subscriberServiceClient = SubscriberServiceClient.create()) {
+ *   BidiStream bidiStream =
+ *       subscriberServiceClient.subscribeCallable().call();
+ *   SubscribeRequest request = SubscribeRequest.newBuilder().build();
+ *   bidiStream.send(request);
+ *   for (SubscribeResponse response : bidiStream) {
+ *     // Do something when a response is received.
+ *   }
+ * }
+ * }
+ * *

Note: close() needs to be called on the SubscriberServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -142,6 +154,18 @@ public SubscriberServiceStub getStub() { * Establishes a stream with the server for receiving messages. * *

Sample code: + * + *

{@code
+   * try (SubscriberServiceClient subscriberServiceClient = SubscriberServiceClient.create()) {
+   *   BidiStream bidiStream =
+   *       subscriberServiceClient.subscribeCallable().call();
+   *   SubscribeRequest request = SubscribeRequest.newBuilder().build();
+   *   bidiStream.send(request);
+   *   for (SubscribeResponse response : bidiStream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
*/ public final BidiStreamingCallable subscribeCallable() { return stub.subscribeCallable(); diff --git a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/TopicStatsServiceClient.java b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/TopicStatsServiceClient.java index 7e600b09d..63cd12a6d 100644 --- a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/TopicStatsServiceClient.java +++ b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/TopicStatsServiceClient.java @@ -36,6 +36,19 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (TopicStatsServiceClient topicStatsServiceClient = TopicStatsServiceClient.create()) {
+ *   ComputeMessageStatsRequest request =
+ *       ComputeMessageStatsRequest.newBuilder()
+ *           .setTopic(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+ *           .setPartition(-1799810326)
+ *           .setStartCursor(Cursor.newBuilder().build())
+ *           .setEndCursor(Cursor.newBuilder().build())
+ *           .build();
+ *   ComputeMessageStatsResponse response = topicStatsServiceClient.computeMessageStats(request);
+ * }
+ * }
+ * *

Note: close() needs to be called on the TopicStatsServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -142,6 +155,21 @@ public TopicStatsServiceStub getStub() { /** * Compute statistics about a range of messages in a given topic and partition. * + *

Sample code: + * + *

{@code
+   * try (TopicStatsServiceClient topicStatsServiceClient = TopicStatsServiceClient.create()) {
+   *   ComputeMessageStatsRequest request =
+   *       ComputeMessageStatsRequest.newBuilder()
+   *           .setTopic(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .setPartition(-1799810326)
+   *           .setStartCursor(Cursor.newBuilder().build())
+   *           .setEndCursor(Cursor.newBuilder().build())
+   *           .build();
+   *   ComputeMessageStatsResponse response = topicStatsServiceClient.computeMessageStats(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -154,6 +182,22 @@ public final ComputeMessageStatsResponse computeMessageStats(ComputeMessageStats * Compute statistics about a range of messages in a given topic and partition. * *

Sample code: + * + *

{@code
+   * try (TopicStatsServiceClient topicStatsServiceClient = TopicStatsServiceClient.create()) {
+   *   ComputeMessageStatsRequest request =
+   *       ComputeMessageStatsRequest.newBuilder()
+   *           .setTopic(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .setPartition(-1799810326)
+   *           .setStartCursor(Cursor.newBuilder().build())
+   *           .setEndCursor(Cursor.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       topicStatsServiceClient.computeMessageStatsCallable().futureCall(request);
+   *   // Do something.
+   *   ComputeMessageStatsResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable computeMessageStatsCallable() { @@ -167,6 +211,19 @@ public final ComputeMessageStatsResponse computeMessageStats(ComputeMessageStats * the offset of any message whose publish has already been acknowledged. It is 0 if there have * never been messages on the partition. * + *

Sample code: + * + *

{@code
+   * try (TopicStatsServiceClient topicStatsServiceClient = TopicStatsServiceClient.create()) {
+   *   ComputeHeadCursorRequest request =
+   *       ComputeHeadCursorRequest.newBuilder()
+   *           .setTopic(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .setPartition(-1799810326)
+   *           .build();
+   *   ComputeHeadCursorResponse response = topicStatsServiceClient.computeHeadCursor(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -182,6 +239,20 @@ public final ComputeHeadCursorResponse computeHeadCursor(ComputeHeadCursorReques * never been messages on the partition. * *

Sample code: + * + *

{@code
+   * try (TopicStatsServiceClient topicStatsServiceClient = TopicStatsServiceClient.create()) {
+   *   ComputeHeadCursorRequest request =
+   *       ComputeHeadCursorRequest.newBuilder()
+   *           .setTopic(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+   *           .setPartition(-1799810326)
+   *           .build();
+   *   ApiFuture future =
+   *       topicStatsServiceClient.computeHeadCursorCallable().futureCall(request);
+   *   // Do something.
+   *   ComputeHeadCursorResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable computeHeadCursorCallable() { diff --git a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/package-info.java b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/package-info.java index 26324b124..00ab484c0 100644 --- a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/package-info.java +++ b/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/package-info.java @@ -24,6 +24,15 @@ * *

Sample for AdminServiceClient: * + *

{@code
+ * try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
+ *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ *   Topic topic = Topic.newBuilder().build();
+ *   String topicId = "topicId-1139259734";
+ *   Topic response = adminServiceClient.createTopic(parent, topic, topicId);
+ * }
+ * }
+ * *

======================= CursorServiceClient ======================= * *

Service Description: The service that a subscriber client application uses to manage committed @@ -32,6 +41,18 @@ * *

Sample for CursorServiceClient: * + *

{@code
+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
+ *   CommitCursorRequest request =
+ *       CommitCursorRequest.newBuilder()
+ *           .setSubscription("subscription341203229")
+ *           .setPartition(-1799810326)
+ *           .setCursor(Cursor.newBuilder().build())
+ *           .build();
+ *   CommitCursorResponse response = cursorServiceClient.commitCursor(request);
+ * }
+ * }
+ * *

======================= PublisherServiceClient ======================= * *

Service Description: The service that a publisher client application uses to publish messages @@ -41,6 +62,18 @@ * *

Sample for PublisherServiceClient: * + *

{@code
+ * try (PublisherServiceClient publisherServiceClient = PublisherServiceClient.create()) {
+ *   BidiStream bidiStream =
+ *       publisherServiceClient.publishCallable().call();
+ *   PublishRequest request = PublishRequest.newBuilder().build();
+ *   bidiStream.send(request);
+ *   for (PublishResponse response : bidiStream) {
+ *     // Do something when a response is received.
+ *   }
+ * }
+ * }
+ * *

======================= SubscriberServiceClient ======================= * *

Service Description: The service that a subscriber client application uses to receive messages @@ -48,6 +81,18 @@ * *

Sample for SubscriberServiceClient: * + *

{@code
+ * try (SubscriberServiceClient subscriberServiceClient = SubscriberServiceClient.create()) {
+ *   BidiStream bidiStream =
+ *       subscriberServiceClient.subscribeCallable().call();
+ *   SubscribeRequest request = SubscribeRequest.newBuilder().build();
+ *   bidiStream.send(request);
+ *   for (SubscribeResponse response : bidiStream) {
+ *     // Do something when a response is received.
+ *   }
+ * }
+ * }
+ * *

======================= PartitionAssignmentServiceClient ======================= * *

Service Description: The service that a subscriber client application uses to determine which @@ -55,11 +100,37 @@ * *

Sample for PartitionAssignmentServiceClient: * + *

{@code
+ * try (PartitionAssignmentServiceClient partitionAssignmentServiceClient =
+ *     PartitionAssignmentServiceClient.create()) {
+ *   BidiStream bidiStream =
+ *       partitionAssignmentServiceClient.assignPartitionsCallable().call();
+ *   PartitionAssignmentRequest request = PartitionAssignmentRequest.newBuilder().build();
+ *   bidiStream.send(request);
+ *   for (PartitionAssignment response : bidiStream) {
+ *     // Do something when a response is received.
+ *   }
+ * }
+ * }
+ * *

======================= TopicStatsServiceClient ======================= * *

Service Description: This service allows users to get stats about messages in their topic. * *

Sample for TopicStatsServiceClient: + * + *

{@code
+ * try (TopicStatsServiceClient topicStatsServiceClient = TopicStatsServiceClient.create()) {
+ *   ComputeMessageStatsRequest request =
+ *       ComputeMessageStatsRequest.newBuilder()
+ *           .setTopic(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
+ *           .setPartition(-1799810326)
+ *           .setStartCursor(Cursor.newBuilder().build())
+ *           .setEndCursor(Cursor.newBuilder().build())
+ *           .build();
+ *   ComputeMessageStatsResponse response = topicStatsServiceClient.computeMessageStats(request);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.pubsublite.v1; diff --git a/synth.metadata b/synth.metadata index 5f0365a28..f433d0a83 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {