|
16 | 16 |
|
17 | 17 | package com.google.cloud.servicedirectory.v1;
|
18 | 18 |
|
| 19 | +import com.google.api.core.ApiFuture; |
| 20 | +import com.google.api.core.ApiFutures; |
19 | 21 | import com.google.api.gax.core.BackgroundResource;
|
| 22 | +import com.google.api.gax.paging.AbstractFixedSizeCollection; |
| 23 | +import com.google.api.gax.paging.AbstractPage; |
| 24 | +import com.google.api.gax.paging.AbstractPagedListResponse; |
| 25 | +import com.google.api.gax.rpc.PageContext; |
20 | 26 | import com.google.api.gax.rpc.UnaryCallable;
|
| 27 | +import com.google.cloud.location.GetLocationRequest; |
| 28 | +import com.google.cloud.location.ListLocationsRequest; |
| 29 | +import com.google.cloud.location.ListLocationsResponse; |
| 30 | +import com.google.cloud.location.Location; |
21 | 31 | import com.google.cloud.servicedirectory.v1.stub.LookupServiceStub;
|
22 | 32 | import com.google.cloud.servicedirectory.v1.stub.LookupServiceStubSettings;
|
| 33 | +import com.google.common.util.concurrent.MoreExecutors; |
23 | 34 | import java.io.IOException;
|
| 35 | +import java.util.List; |
24 | 36 | import java.util.concurrent.TimeUnit;
|
25 | 37 | import javax.annotation.Generated;
|
26 | 38 |
|
@@ -234,6 +246,161 @@ public final ResolveServiceResponse resolveService(ResolveServiceRequest request
|
234 | 246 | return stub.resolveServiceCallable();
|
235 | 247 | }
|
236 | 248 |
|
| 249 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 250 | + /** |
| 251 | + * Lists information about the supported locations for this service. |
| 252 | + * |
| 253 | + * <p>Sample code: |
| 254 | + * |
| 255 | + * <pre>{@code |
| 256 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 257 | + * // It will require modifications to work: |
| 258 | + * // - It may require correct/in-range values for request initialization. |
| 259 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 260 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 261 | + * try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { |
| 262 | + * ListLocationsRequest request = |
| 263 | + * ListLocationsRequest.newBuilder() |
| 264 | + * .setName("name3373707") |
| 265 | + * .setFilter("filter-1274492040") |
| 266 | + * .setPageSize(883849137) |
| 267 | + * .setPageToken("pageToken873572522") |
| 268 | + * .build(); |
| 269 | + * for (Location element : lookupServiceClient.listLocations(request).iterateAll()) { |
| 270 | + * // doThingsWith(element); |
| 271 | + * } |
| 272 | + * } |
| 273 | + * }</pre> |
| 274 | + * |
| 275 | + * @param request The request object containing all of the parameters for the API call. |
| 276 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 277 | + */ |
| 278 | + public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { |
| 279 | + return listLocationsPagedCallable().call(request); |
| 280 | + } |
| 281 | + |
| 282 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 283 | + /** |
| 284 | + * Lists information about the supported locations for this service. |
| 285 | + * |
| 286 | + * <p>Sample code: |
| 287 | + * |
| 288 | + * <pre>{@code |
| 289 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 290 | + * // It will require modifications to work: |
| 291 | + * // - It may require correct/in-range values for request initialization. |
| 292 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 293 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 294 | + * try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { |
| 295 | + * ListLocationsRequest request = |
| 296 | + * ListLocationsRequest.newBuilder() |
| 297 | + * .setName("name3373707") |
| 298 | + * .setFilter("filter-1274492040") |
| 299 | + * .setPageSize(883849137) |
| 300 | + * .setPageToken("pageToken873572522") |
| 301 | + * .build(); |
| 302 | + * ApiFuture<Location> future = |
| 303 | + * lookupServiceClient.listLocationsPagedCallable().futureCall(request); |
| 304 | + * // Do something. |
| 305 | + * for (Location element : future.get().iterateAll()) { |
| 306 | + * // doThingsWith(element); |
| 307 | + * } |
| 308 | + * } |
| 309 | + * }</pre> |
| 310 | + */ |
| 311 | + public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse> |
| 312 | + listLocationsPagedCallable() { |
| 313 | + return stub.listLocationsPagedCallable(); |
| 314 | + } |
| 315 | + |
| 316 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 317 | + /** |
| 318 | + * Lists information about the supported locations for this service. |
| 319 | + * |
| 320 | + * <p>Sample code: |
| 321 | + * |
| 322 | + * <pre>{@code |
| 323 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 324 | + * // It will require modifications to work: |
| 325 | + * // - It may require correct/in-range values for request initialization. |
| 326 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 327 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 328 | + * try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { |
| 329 | + * ListLocationsRequest request = |
| 330 | + * ListLocationsRequest.newBuilder() |
| 331 | + * .setName("name3373707") |
| 332 | + * .setFilter("filter-1274492040") |
| 333 | + * .setPageSize(883849137) |
| 334 | + * .setPageToken("pageToken873572522") |
| 335 | + * .build(); |
| 336 | + * while (true) { |
| 337 | + * ListLocationsResponse response = lookupServiceClient.listLocationsCallable().call(request); |
| 338 | + * for (Location element : response.getLocationsList()) { |
| 339 | + * // doThingsWith(element); |
| 340 | + * } |
| 341 | + * String nextPageToken = response.getNextPageToken(); |
| 342 | + * if (!Strings.isNullOrEmpty(nextPageToken)) { |
| 343 | + * request = request.toBuilder().setPageToken(nextPageToken).build(); |
| 344 | + * } else { |
| 345 | + * break; |
| 346 | + * } |
| 347 | + * } |
| 348 | + * } |
| 349 | + * }</pre> |
| 350 | + */ |
| 351 | + public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() { |
| 352 | + return stub.listLocationsCallable(); |
| 353 | + } |
| 354 | + |
| 355 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 356 | + /** |
| 357 | + * Gets information about a location. |
| 358 | + * |
| 359 | + * <p>Sample code: |
| 360 | + * |
| 361 | + * <pre>{@code |
| 362 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 363 | + * // It will require modifications to work: |
| 364 | + * // - It may require correct/in-range values for request initialization. |
| 365 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 366 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 367 | + * try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { |
| 368 | + * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); |
| 369 | + * Location response = lookupServiceClient.getLocation(request); |
| 370 | + * } |
| 371 | + * }</pre> |
| 372 | + * |
| 373 | + * @param request The request object containing all of the parameters for the API call. |
| 374 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 375 | + */ |
| 376 | + public final Location getLocation(GetLocationRequest request) { |
| 377 | + return getLocationCallable().call(request); |
| 378 | + } |
| 379 | + |
| 380 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 381 | + /** |
| 382 | + * Gets information about a location. |
| 383 | + * |
| 384 | + * <p>Sample code: |
| 385 | + * |
| 386 | + * <pre>{@code |
| 387 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 388 | + * // It will require modifications to work: |
| 389 | + * // - It may require correct/in-range values for request initialization. |
| 390 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 391 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 392 | + * try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { |
| 393 | + * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); |
| 394 | + * ApiFuture<Location> future = lookupServiceClient.getLocationCallable().futureCall(request); |
| 395 | + * // Do something. |
| 396 | + * Location response = future.get(); |
| 397 | + * } |
| 398 | + * }</pre> |
| 399 | + */ |
| 400 | + public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() { |
| 401 | + return stub.getLocationCallable(); |
| 402 | + } |
| 403 | + |
237 | 404 | @Override
|
238 | 405 | public final void close() {
|
239 | 406 | stub.close();
|
@@ -263,4 +430,80 @@ public void shutdownNow() {
|
263 | 430 | public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
|
264 | 431 | return stub.awaitTermination(duration, unit);
|
265 | 432 | }
|
| 433 | + |
| 434 | + public static class ListLocationsPagedResponse |
| 435 | + extends AbstractPagedListResponse< |
| 436 | + ListLocationsRequest, |
| 437 | + ListLocationsResponse, |
| 438 | + Location, |
| 439 | + ListLocationsPage, |
| 440 | + ListLocationsFixedSizeCollection> { |
| 441 | + |
| 442 | + public static ApiFuture<ListLocationsPagedResponse> createAsync( |
| 443 | + PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, |
| 444 | + ApiFuture<ListLocationsResponse> futureResponse) { |
| 445 | + ApiFuture<ListLocationsPage> futurePage = |
| 446 | + ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); |
| 447 | + return ApiFutures.transform( |
| 448 | + futurePage, |
| 449 | + input -> new ListLocationsPagedResponse(input), |
| 450 | + MoreExecutors.directExecutor()); |
| 451 | + } |
| 452 | + |
| 453 | + private ListLocationsPagedResponse(ListLocationsPage page) { |
| 454 | + super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); |
| 455 | + } |
| 456 | + } |
| 457 | + |
| 458 | + public static class ListLocationsPage |
| 459 | + extends AbstractPage< |
| 460 | + ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { |
| 461 | + |
| 462 | + private ListLocationsPage( |
| 463 | + PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, |
| 464 | + ListLocationsResponse response) { |
| 465 | + super(context, response); |
| 466 | + } |
| 467 | + |
| 468 | + private static ListLocationsPage createEmptyPage() { |
| 469 | + return new ListLocationsPage(null, null); |
| 470 | + } |
| 471 | + |
| 472 | + @Override |
| 473 | + protected ListLocationsPage createPage( |
| 474 | + PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, |
| 475 | + ListLocationsResponse response) { |
| 476 | + return new ListLocationsPage(context, response); |
| 477 | + } |
| 478 | + |
| 479 | + @Override |
| 480 | + public ApiFuture<ListLocationsPage> createPageAsync( |
| 481 | + PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, |
| 482 | + ApiFuture<ListLocationsResponse> futureResponse) { |
| 483 | + return super.createPageAsync(context, futureResponse); |
| 484 | + } |
| 485 | + } |
| 486 | + |
| 487 | + public static class ListLocationsFixedSizeCollection |
| 488 | + extends AbstractFixedSizeCollection< |
| 489 | + ListLocationsRequest, |
| 490 | + ListLocationsResponse, |
| 491 | + Location, |
| 492 | + ListLocationsPage, |
| 493 | + ListLocationsFixedSizeCollection> { |
| 494 | + |
| 495 | + private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) { |
| 496 | + super(pages, collectionSize); |
| 497 | + } |
| 498 | + |
| 499 | + private static ListLocationsFixedSizeCollection createEmptyCollection() { |
| 500 | + return new ListLocationsFixedSizeCollection(null, 0); |
| 501 | + } |
| 502 | + |
| 503 | + @Override |
| 504 | + protected ListLocationsFixedSizeCollection createCollection( |
| 505 | + List<ListLocationsPage> pages, int collectionSize) { |
| 506 | + return new ListLocationsFixedSizeCollection(pages, collectionSize); |
| 507 | + } |
| 508 | + } |
266 | 509 | }
|
0 commit comments