5252 * <p>This class provides the ability to make remote calls to the backing service through method
5353 * calls that map to API methods. Sample code to get started:
5454 *
55+ * <pre>{@code
56+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
57+ * CommitCursorRequest request =
58+ * CommitCursorRequest.newBuilder()
59+ * .setSubscription("subscription341203229")
60+ * .setPartition(-1799810326)
61+ * .setCursor(Cursor.newBuilder().build())
62+ * .build();
63+ * CommitCursorResponse response = cursorServiceClient.commitCursor(request);
64+ * }
65+ * }</pre>
66+ *
5567 * <p>Note: close() needs to be called on the CursorServiceClient object to clean up resources such
5668 * as threads. In the example above, try-with-resources is used, which automatically calls close().
5769 *
@@ -156,6 +168,18 @@ public CursorServiceStub getStub() {
156168 * Establishes a stream with the server for managing committed cursors.
157169 *
158170 * <p>Sample code:
171+ *
172+ * <pre>{@code
173+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
174+ * BidiStream<StreamingCommitCursorRequest, StreamingCommitCursorResponse> bidiStream =
175+ * cursorServiceClient.streamingCommitCursorCallable().call();
176+ * StreamingCommitCursorRequest request = StreamingCommitCursorRequest.newBuilder().build();
177+ * bidiStream.send(request);
178+ * for (StreamingCommitCursorResponse response : bidiStream) {
179+ * // Do something when a response is received.
180+ * }
181+ * }
182+ * }</pre>
159183 */
160184 public final BidiStreamingCallable <StreamingCommitCursorRequest , StreamingCommitCursorResponse >
161185 streamingCommitCursorCallable () {
@@ -166,6 +190,20 @@ public CursorServiceStub getStub() {
166190 /**
167191 * Updates the committed cursor.
168192 *
193+ * <p>Sample code:
194+ *
195+ * <pre>{@code
196+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
197+ * CommitCursorRequest request =
198+ * CommitCursorRequest.newBuilder()
199+ * .setSubscription("subscription341203229")
200+ * .setPartition(-1799810326)
201+ * .setCursor(Cursor.newBuilder().build())
202+ * .build();
203+ * CommitCursorResponse response = cursorServiceClient.commitCursor(request);
204+ * }
205+ * }</pre>
206+ *
169207 * @param request The request object containing all of the parameters for the API call.
170208 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
171209 */
@@ -178,6 +216,21 @@ public final CommitCursorResponse commitCursor(CommitCursorRequest request) {
178216 * Updates the committed cursor.
179217 *
180218 * <p>Sample code:
219+ *
220+ * <pre>{@code
221+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
222+ * CommitCursorRequest request =
223+ * CommitCursorRequest.newBuilder()
224+ * .setSubscription("subscription341203229")
225+ * .setPartition(-1799810326)
226+ * .setCursor(Cursor.newBuilder().build())
227+ * .build();
228+ * ApiFuture<CommitCursorResponse> future =
229+ * cursorServiceClient.commitCursorCallable().futureCall(request);
230+ * // Do something.
231+ * CommitCursorResponse response = future.get();
232+ * }
233+ * }</pre>
181234 */
182235 public final UnaryCallable <CommitCursorRequest , CommitCursorResponse > commitCursorCallable () {
183236 return stub .commitCursorCallable ();
@@ -187,6 +240,18 @@ public final UnaryCallable<CommitCursorRequest, CommitCursorResponse> commitCurs
187240 /**
188241 * Returns all committed cursor information for a subscription.
189242 *
243+ * <p>Sample code:
244+ *
245+ * <pre>{@code
246+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
247+ * SubscriptionName parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
248+ * for (PartitionCursor element :
249+ * cursorServiceClient.listPartitionCursors(parent).iterateAll()) {
250+ * // doThingsWith(element);
251+ * }
252+ * }
253+ * }</pre>
254+ *
190255 * @param parent Required. The subscription for which to retrieve cursors. Structured like
191256 * `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.
192257 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -203,6 +268,18 @@ public final ListPartitionCursorsPagedResponse listPartitionCursors(Subscription
203268 /**
204269 * Returns all committed cursor information for a subscription.
205270 *
271+ * <p>Sample code:
272+ *
273+ * <pre>{@code
274+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
275+ * String parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString();
276+ * for (PartitionCursor element :
277+ * cursorServiceClient.listPartitionCursors(parent).iterateAll()) {
278+ * // doThingsWith(element);
279+ * }
280+ * }
281+ * }</pre>
282+ *
206283 * @param parent Required. The subscription for which to retrieve cursors. Structured like
207284 * `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.
208285 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -217,6 +294,24 @@ public final ListPartitionCursorsPagedResponse listPartitionCursors(String paren
217294 /**
218295 * Returns all committed cursor information for a subscription.
219296 *
297+ * <p>Sample code:
298+ *
299+ * <pre>{@code
300+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
301+ * ListPartitionCursorsRequest request =
302+ * ListPartitionCursorsRequest.newBuilder()
303+ * .setParent(
304+ * SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
305+ * .setPageSize(883849137)
306+ * .setPageToken("pageToken873572522")
307+ * .build();
308+ * for (PartitionCursor element :
309+ * cursorServiceClient.listPartitionCursors(request).iterateAll()) {
310+ * // doThingsWith(element);
311+ * }
312+ * }
313+ * }</pre>
314+ *
220315 * @param request The request object containing all of the parameters for the API call.
221316 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
222317 */
@@ -230,6 +325,24 @@ public final ListPartitionCursorsPagedResponse listPartitionCursors(
230325 * Returns all committed cursor information for a subscription.
231326 *
232327 * <p>Sample code:
328+ *
329+ * <pre>{@code
330+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
331+ * ListPartitionCursorsRequest request =
332+ * ListPartitionCursorsRequest.newBuilder()
333+ * .setParent(
334+ * SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
335+ * .setPageSize(883849137)
336+ * .setPageToken("pageToken873572522")
337+ * .build();
338+ * ApiFuture<PartitionCursor> future =
339+ * cursorServiceClient.listPartitionCursorsPagedCallable().futureCall(request);
340+ * // Do something.
341+ * for (PartitionCursor element : future.get().iterateAll()) {
342+ * // doThingsWith(element);
343+ * }
344+ * }
345+ * }</pre>
233346 */
234347 public final UnaryCallable <ListPartitionCursorsRequest , ListPartitionCursorsPagedResponse >
235348 listPartitionCursorsPagedCallable () {
@@ -241,6 +354,24 @@ public final ListPartitionCursorsPagedResponse listPartitionCursors(
241354 * Returns all committed cursor information for a subscription.
242355 *
243356 * <p>Sample code:
357+ *
358+ * <pre>{@code
359+ * try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
360+ * while (true) {
361+ * ListPartitionCursorsResponse response =
362+ * cursorServiceClient.listPartitionCursorsCallable().call(request);
363+ * for (PartitionCursor element : response.getResponsesList()) {
364+ * // doThingsWith(element);
365+ * }
366+ * String nextPageToken = response.getNextPageToken();
367+ * if (!Strings.isNullOrEmpty(nextPageToken)) {
368+ * request = request.toBuilder().setPageToken(nextPageToken).build();
369+ * } else {
370+ * break;
371+ * }
372+ * }
373+ * }
374+ * }</pre>
244375 */
245376 public final UnaryCallable <ListPartitionCursorsRequest , ListPartitionCursorsResponse >
246377 listPartitionCursorsCallable () {
0 commit comments