1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.cloud.aiplatform.v1beta1; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.core.BetaApi; 22 import com.google.api.gax.core.BackgroundResource; 23 import com.google.api.gax.longrunning.OperationFuture; 24 import com.google.api.gax.paging.AbstractFixedSizeCollection; 25 import com.google.api.gax.paging.AbstractPage; 26 import com.google.api.gax.paging.AbstractPagedListResponse; 27 import com.google.api.gax.rpc.OperationCallable; 28 import com.google.api.gax.rpc.PageContext; 29 import com.google.api.gax.rpc.UnaryCallable; 30 import com.google.cloud.aiplatform.v1beta1.stub.IndexServiceStub; 31 import com.google.cloud.aiplatform.v1beta1.stub.IndexServiceStubSettings; 32 import com.google.cloud.location.GetLocationRequest; 33 import com.google.cloud.location.ListLocationsRequest; 34 import com.google.cloud.location.ListLocationsResponse; 35 import com.google.cloud.location.Location; 36 import com.google.common.util.concurrent.MoreExecutors; 37 import com.google.iam.v1.GetIamPolicyRequest; 38 import com.google.iam.v1.Policy; 39 import com.google.iam.v1.SetIamPolicyRequest; 40 import com.google.iam.v1.TestIamPermissionsRequest; 41 import com.google.iam.v1.TestIamPermissionsResponse; 42 import com.google.longrunning.Operation; 43 import com.google.longrunning.OperationsClient; 44 import com.google.protobuf.Empty; 45 import com.google.protobuf.FieldMask; 46 import java.io.IOException; 47 import java.util.List; 48 import java.util.concurrent.TimeUnit; 49 import javax.annotation.Generated; 50 51 // AUTO-GENERATED DOCUMENTATION AND CLASS. 52 /** 53 * Service Description: A service for creating and managing Vertex AI's Index resources. 54 * 55 * <p>This class provides the ability to make remote calls to the backing service through method 56 * calls that map to API methods. Sample code to get started: 57 * 58 * <pre>{@code 59 * // This snippet has been automatically generated and should be regarded as a code template only. 60 * // It will require modifications to work: 61 * // - It may require correct/in-range values for request initialization. 62 * // - It may require specifying regional endpoints when creating the service client as shown in 63 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 64 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 65 * IndexName name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]"); 66 * Index response = indexServiceClient.getIndex(name); 67 * } 68 * }</pre> 69 * 70 * <p>Note: close() needs to be called on the IndexServiceClient object to clean up resources such 71 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 72 * 73 * <p>The surface of this class includes several types of Java methods for each of the API's 74 * methods: 75 * 76 * <ol> 77 * <li>A "flattened" method. With this type of method, the fields of the request type have been 78 * converted into function parameters. It may be the case that not all fields are available as 79 * parameters, and not every API method will have a flattened method entry point. 80 * <li>A "request object" method. This type of method only takes one parameter, a request object, 81 * which must be constructed before the call. Not every API method will have a request object 82 * method. 83 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 84 * callable object, which can be used to initiate calls to the service. 85 * </ol> 86 * 87 * <p>See the individual methods for example code. 88 * 89 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 90 * these names, this class includes a format method for each type of name, and additionally a parse 91 * method to extract the individual identifiers contained within names that are returned. 92 * 93 * <p>This class can be customized by passing in a custom instance of IndexServiceSettings to 94 * create(). For example: 95 * 96 * <p>To customize credentials: 97 * 98 * <pre>{@code 99 * // This snippet has been automatically generated and should be regarded as a code template only. 100 * // It will require modifications to work: 101 * // - It may require correct/in-range values for request initialization. 102 * // - It may require specifying regional endpoints when creating the service client as shown in 103 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 104 * IndexServiceSettings indexServiceSettings = 105 * IndexServiceSettings.newBuilder() 106 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 107 * .build(); 108 * IndexServiceClient indexServiceClient = IndexServiceClient.create(indexServiceSettings); 109 * }</pre> 110 * 111 * <p>To customize the endpoint: 112 * 113 * <pre>{@code 114 * // This snippet has been automatically generated and should be regarded as a code template only. 115 * // It will require modifications to work: 116 * // - It may require correct/in-range values for request initialization. 117 * // - It may require specifying regional endpoints when creating the service client as shown in 118 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 119 * IndexServiceSettings indexServiceSettings = 120 * IndexServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); 121 * IndexServiceClient indexServiceClient = IndexServiceClient.create(indexServiceSettings); 122 * }</pre> 123 * 124 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 125 */ 126 @BetaApi 127 @Generated("by gapic-generator-java") 128 public class IndexServiceClient implements BackgroundResource { 129 private final IndexServiceSettings settings; 130 private final IndexServiceStub stub; 131 private final OperationsClient operationsClient; 132 133 /** Constructs an instance of IndexServiceClient with default settings. */ create()134 public static final IndexServiceClient create() throws IOException { 135 return create(IndexServiceSettings.newBuilder().build()); 136 } 137 138 /** 139 * Constructs an instance of IndexServiceClient, using the given settings. The channels are 140 * created based on the settings passed in, or defaults for any settings that are not set. 141 */ create(IndexServiceSettings settings)142 public static final IndexServiceClient create(IndexServiceSettings settings) throws IOException { 143 return new IndexServiceClient(settings); 144 } 145 146 /** 147 * Constructs an instance of IndexServiceClient, using the given stub for making calls. This is 148 * for advanced usage - prefer using create(IndexServiceSettings). 149 */ create(IndexServiceStub stub)150 public static final IndexServiceClient create(IndexServiceStub stub) { 151 return new IndexServiceClient(stub); 152 } 153 154 /** 155 * Constructs an instance of IndexServiceClient, using the given settings. This is protected so 156 * that it is easy to make a subclass, but otherwise, the static factory methods should be 157 * preferred. 158 */ IndexServiceClient(IndexServiceSettings settings)159 protected IndexServiceClient(IndexServiceSettings settings) throws IOException { 160 this.settings = settings; 161 this.stub = ((IndexServiceStubSettings) settings.getStubSettings()).createStub(); 162 this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); 163 } 164 IndexServiceClient(IndexServiceStub stub)165 protected IndexServiceClient(IndexServiceStub stub) { 166 this.settings = null; 167 this.stub = stub; 168 this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); 169 } 170 getSettings()171 public final IndexServiceSettings getSettings() { 172 return settings; 173 } 174 getStub()175 public IndexServiceStub getStub() { 176 return stub; 177 } 178 179 /** 180 * Returns the OperationsClient that can be used to query the status of a long-running operation 181 * returned by another API method call. 182 */ getOperationsClient()183 public final OperationsClient getOperationsClient() { 184 return operationsClient; 185 } 186 187 // AUTO-GENERATED DOCUMENTATION AND METHOD. 188 /** 189 * Creates an Index. 190 * 191 * <p>Sample code: 192 * 193 * <pre>{@code 194 * // This snippet has been automatically generated and should be regarded as a code template only. 195 * // It will require modifications to work: 196 * // - It may require correct/in-range values for request initialization. 197 * // - It may require specifying regional endpoints when creating the service client as shown in 198 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 199 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 200 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 201 * Index index = Index.newBuilder().build(); 202 * Index response = indexServiceClient.createIndexAsync(parent, index).get(); 203 * } 204 * }</pre> 205 * 206 * @param parent Required. The resource name of the Location to create the Index in. Format: 207 * `projects/{project}/locations/{location}` 208 * @param index Required. The Index to create. 209 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 210 */ createIndexAsync( LocationName parent, Index index)211 public final OperationFuture<Index, CreateIndexOperationMetadata> createIndexAsync( 212 LocationName parent, Index index) { 213 CreateIndexRequest request = 214 CreateIndexRequest.newBuilder() 215 .setParent(parent == null ? null : parent.toString()) 216 .setIndex(index) 217 .build(); 218 return createIndexAsync(request); 219 } 220 221 // AUTO-GENERATED DOCUMENTATION AND METHOD. 222 /** 223 * Creates an Index. 224 * 225 * <p>Sample code: 226 * 227 * <pre>{@code 228 * // This snippet has been automatically generated and should be regarded as a code template only. 229 * // It will require modifications to work: 230 * // - It may require correct/in-range values for request initialization. 231 * // - It may require specifying regional endpoints when creating the service client as shown in 232 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 233 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 234 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 235 * Index index = Index.newBuilder().build(); 236 * Index response = indexServiceClient.createIndexAsync(parent, index).get(); 237 * } 238 * }</pre> 239 * 240 * @param parent Required. The resource name of the Location to create the Index in. Format: 241 * `projects/{project}/locations/{location}` 242 * @param index Required. The Index to create. 243 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 244 */ createIndexAsync( String parent, Index index)245 public final OperationFuture<Index, CreateIndexOperationMetadata> createIndexAsync( 246 String parent, Index index) { 247 CreateIndexRequest request = 248 CreateIndexRequest.newBuilder().setParent(parent).setIndex(index).build(); 249 return createIndexAsync(request); 250 } 251 252 // AUTO-GENERATED DOCUMENTATION AND METHOD. 253 /** 254 * Creates an Index. 255 * 256 * <p>Sample code: 257 * 258 * <pre>{@code 259 * // This snippet has been automatically generated and should be regarded as a code template only. 260 * // It will require modifications to work: 261 * // - It may require correct/in-range values for request initialization. 262 * // - It may require specifying regional endpoints when creating the service client as shown in 263 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 264 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 265 * CreateIndexRequest request = 266 * CreateIndexRequest.newBuilder() 267 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 268 * .setIndex(Index.newBuilder().build()) 269 * .build(); 270 * Index response = indexServiceClient.createIndexAsync(request).get(); 271 * } 272 * }</pre> 273 * 274 * @param request The request object containing all of the parameters for the API call. 275 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 276 */ createIndexAsync( CreateIndexRequest request)277 public final OperationFuture<Index, CreateIndexOperationMetadata> createIndexAsync( 278 CreateIndexRequest request) { 279 return createIndexOperationCallable().futureCall(request); 280 } 281 282 // AUTO-GENERATED DOCUMENTATION AND METHOD. 283 /** 284 * Creates an Index. 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 (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 295 * CreateIndexRequest request = 296 * CreateIndexRequest.newBuilder() 297 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 298 * .setIndex(Index.newBuilder().build()) 299 * .build(); 300 * OperationFuture<Index, CreateIndexOperationMetadata> future = 301 * indexServiceClient.createIndexOperationCallable().futureCall(request); 302 * // Do something. 303 * Index response = future.get(); 304 * } 305 * }</pre> 306 */ 307 public final OperationCallable<CreateIndexRequest, Index, CreateIndexOperationMetadata> createIndexOperationCallable()308 createIndexOperationCallable() { 309 return stub.createIndexOperationCallable(); 310 } 311 312 // AUTO-GENERATED DOCUMENTATION AND METHOD. 313 /** 314 * Creates an Index. 315 * 316 * <p>Sample code: 317 * 318 * <pre>{@code 319 * // This snippet has been automatically generated and should be regarded as a code template only. 320 * // It will require modifications to work: 321 * // - It may require correct/in-range values for request initialization. 322 * // - It may require specifying regional endpoints when creating the service client as shown in 323 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 324 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 325 * CreateIndexRequest request = 326 * CreateIndexRequest.newBuilder() 327 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 328 * .setIndex(Index.newBuilder().build()) 329 * .build(); 330 * ApiFuture<Operation> future = indexServiceClient.createIndexCallable().futureCall(request); 331 * // Do something. 332 * Operation response = future.get(); 333 * } 334 * }</pre> 335 */ createIndexCallable()336 public final UnaryCallable<CreateIndexRequest, Operation> createIndexCallable() { 337 return stub.createIndexCallable(); 338 } 339 340 // AUTO-GENERATED DOCUMENTATION AND METHOD. 341 /** 342 * Gets an Index. 343 * 344 * <p>Sample code: 345 * 346 * <pre>{@code 347 * // This snippet has been automatically generated and should be regarded as a code template only. 348 * // It will require modifications to work: 349 * // - It may require correct/in-range values for request initialization. 350 * // - It may require specifying regional endpoints when creating the service client as shown in 351 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 352 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 353 * IndexName name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]"); 354 * Index response = indexServiceClient.getIndex(name); 355 * } 356 * }</pre> 357 * 358 * @param name Required. The name of the Index resource. Format: 359 * `projects/{project}/locations/{location}/indexes/{index}` 360 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 361 */ getIndex(IndexName name)362 public final Index getIndex(IndexName name) { 363 GetIndexRequest request = 364 GetIndexRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 365 return getIndex(request); 366 } 367 368 // AUTO-GENERATED DOCUMENTATION AND METHOD. 369 /** 370 * Gets an Index. 371 * 372 * <p>Sample code: 373 * 374 * <pre>{@code 375 * // This snippet has been automatically generated and should be regarded as a code template only. 376 * // It will require modifications to work: 377 * // - It may require correct/in-range values for request initialization. 378 * // - It may require specifying regional endpoints when creating the service client as shown in 379 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 380 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 381 * String name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString(); 382 * Index response = indexServiceClient.getIndex(name); 383 * } 384 * }</pre> 385 * 386 * @param name Required. The name of the Index resource. Format: 387 * `projects/{project}/locations/{location}/indexes/{index}` 388 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 389 */ getIndex(String name)390 public final Index getIndex(String name) { 391 GetIndexRequest request = GetIndexRequest.newBuilder().setName(name).build(); 392 return getIndex(request); 393 } 394 395 // AUTO-GENERATED DOCUMENTATION AND METHOD. 396 /** 397 * Gets an Index. 398 * 399 * <p>Sample code: 400 * 401 * <pre>{@code 402 * // This snippet has been automatically generated and should be regarded as a code template only. 403 * // It will require modifications to work: 404 * // - It may require correct/in-range values for request initialization. 405 * // - It may require specifying regional endpoints when creating the service client as shown in 406 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 407 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 408 * GetIndexRequest request = 409 * GetIndexRequest.newBuilder() 410 * .setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 411 * .build(); 412 * Index response = indexServiceClient.getIndex(request); 413 * } 414 * }</pre> 415 * 416 * @param request The request object containing all of the parameters for the API call. 417 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 418 */ getIndex(GetIndexRequest request)419 public final Index getIndex(GetIndexRequest request) { 420 return getIndexCallable().call(request); 421 } 422 423 // AUTO-GENERATED DOCUMENTATION AND METHOD. 424 /** 425 * Gets an Index. 426 * 427 * <p>Sample code: 428 * 429 * <pre>{@code 430 * // This snippet has been automatically generated and should be regarded as a code template only. 431 * // It will require modifications to work: 432 * // - It may require correct/in-range values for request initialization. 433 * // - It may require specifying regional endpoints when creating the service client as shown in 434 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 435 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 436 * GetIndexRequest request = 437 * GetIndexRequest.newBuilder() 438 * .setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 439 * .build(); 440 * ApiFuture<Index> future = indexServiceClient.getIndexCallable().futureCall(request); 441 * // Do something. 442 * Index response = future.get(); 443 * } 444 * }</pre> 445 */ getIndexCallable()446 public final UnaryCallable<GetIndexRequest, Index> getIndexCallable() { 447 return stub.getIndexCallable(); 448 } 449 450 // AUTO-GENERATED DOCUMENTATION AND METHOD. 451 /** 452 * Lists Indexes in a Location. 453 * 454 * <p>Sample code: 455 * 456 * <pre>{@code 457 * // This snippet has been automatically generated and should be regarded as a code template only. 458 * // It will require modifications to work: 459 * // - It may require correct/in-range values for request initialization. 460 * // - It may require specifying regional endpoints when creating the service client as shown in 461 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 462 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 463 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 464 * for (Index element : indexServiceClient.listIndexes(parent).iterateAll()) { 465 * // doThingsWith(element); 466 * } 467 * } 468 * }</pre> 469 * 470 * @param parent Required. The resource name of the Location from which to list the Indexes. 471 * Format: `projects/{project}/locations/{location}` 472 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 473 */ listIndexes(LocationName parent)474 public final ListIndexesPagedResponse listIndexes(LocationName parent) { 475 ListIndexesRequest request = 476 ListIndexesRequest.newBuilder() 477 .setParent(parent == null ? null : parent.toString()) 478 .build(); 479 return listIndexes(request); 480 } 481 482 // AUTO-GENERATED DOCUMENTATION AND METHOD. 483 /** 484 * Lists Indexes in a Location. 485 * 486 * <p>Sample code: 487 * 488 * <pre>{@code 489 * // This snippet has been automatically generated and should be regarded as a code template only. 490 * // It will require modifications to work: 491 * // - It may require correct/in-range values for request initialization. 492 * // - It may require specifying regional endpoints when creating the service client as shown in 493 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 494 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 495 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 496 * for (Index element : indexServiceClient.listIndexes(parent).iterateAll()) { 497 * // doThingsWith(element); 498 * } 499 * } 500 * }</pre> 501 * 502 * @param parent Required. The resource name of the Location from which to list the Indexes. 503 * Format: `projects/{project}/locations/{location}` 504 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 505 */ listIndexes(String parent)506 public final ListIndexesPagedResponse listIndexes(String parent) { 507 ListIndexesRequest request = ListIndexesRequest.newBuilder().setParent(parent).build(); 508 return listIndexes(request); 509 } 510 511 // AUTO-GENERATED DOCUMENTATION AND METHOD. 512 /** 513 * Lists Indexes in a Location. 514 * 515 * <p>Sample code: 516 * 517 * <pre>{@code 518 * // This snippet has been automatically generated and should be regarded as a code template only. 519 * // It will require modifications to work: 520 * // - It may require correct/in-range values for request initialization. 521 * // - It may require specifying regional endpoints when creating the service client as shown in 522 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 523 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 524 * ListIndexesRequest request = 525 * ListIndexesRequest.newBuilder() 526 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 527 * .setFilter("filter-1274492040") 528 * .setPageSize(883849137) 529 * .setPageToken("pageToken873572522") 530 * .setReadMask(FieldMask.newBuilder().build()) 531 * .build(); 532 * for (Index element : indexServiceClient.listIndexes(request).iterateAll()) { 533 * // doThingsWith(element); 534 * } 535 * } 536 * }</pre> 537 * 538 * @param request The request object containing all of the parameters for the API call. 539 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 540 */ listIndexes(ListIndexesRequest request)541 public final ListIndexesPagedResponse listIndexes(ListIndexesRequest request) { 542 return listIndexesPagedCallable().call(request); 543 } 544 545 // AUTO-GENERATED DOCUMENTATION AND METHOD. 546 /** 547 * Lists Indexes in a Location. 548 * 549 * <p>Sample code: 550 * 551 * <pre>{@code 552 * // This snippet has been automatically generated and should be regarded as a code template only. 553 * // It will require modifications to work: 554 * // - It may require correct/in-range values for request initialization. 555 * // - It may require specifying regional endpoints when creating the service client as shown in 556 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 557 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 558 * ListIndexesRequest request = 559 * ListIndexesRequest.newBuilder() 560 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 561 * .setFilter("filter-1274492040") 562 * .setPageSize(883849137) 563 * .setPageToken("pageToken873572522") 564 * .setReadMask(FieldMask.newBuilder().build()) 565 * .build(); 566 * ApiFuture<Index> future = indexServiceClient.listIndexesPagedCallable().futureCall(request); 567 * // Do something. 568 * for (Index element : future.get().iterateAll()) { 569 * // doThingsWith(element); 570 * } 571 * } 572 * }</pre> 573 */ 574 public final UnaryCallable<ListIndexesRequest, ListIndexesPagedResponse> listIndexesPagedCallable()575 listIndexesPagedCallable() { 576 return stub.listIndexesPagedCallable(); 577 } 578 579 // AUTO-GENERATED DOCUMENTATION AND METHOD. 580 /** 581 * Lists Indexes in a Location. 582 * 583 * <p>Sample code: 584 * 585 * <pre>{@code 586 * // This snippet has been automatically generated and should be regarded as a code template only. 587 * // It will require modifications to work: 588 * // - It may require correct/in-range values for request initialization. 589 * // - It may require specifying regional endpoints when creating the service client as shown in 590 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 591 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 592 * ListIndexesRequest request = 593 * ListIndexesRequest.newBuilder() 594 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 595 * .setFilter("filter-1274492040") 596 * .setPageSize(883849137) 597 * .setPageToken("pageToken873572522") 598 * .setReadMask(FieldMask.newBuilder().build()) 599 * .build(); 600 * while (true) { 601 * ListIndexesResponse response = indexServiceClient.listIndexesCallable().call(request); 602 * for (Index element : response.getIndexesList()) { 603 * // doThingsWith(element); 604 * } 605 * String nextPageToken = response.getNextPageToken(); 606 * if (!Strings.isNullOrEmpty(nextPageToken)) { 607 * request = request.toBuilder().setPageToken(nextPageToken).build(); 608 * } else { 609 * break; 610 * } 611 * } 612 * } 613 * }</pre> 614 */ listIndexesCallable()615 public final UnaryCallable<ListIndexesRequest, ListIndexesResponse> listIndexesCallable() { 616 return stub.listIndexesCallable(); 617 } 618 619 // AUTO-GENERATED DOCUMENTATION AND METHOD. 620 /** 621 * Updates an Index. 622 * 623 * <p>Sample code: 624 * 625 * <pre>{@code 626 * // This snippet has been automatically generated and should be regarded as a code template only. 627 * // It will require modifications to work: 628 * // - It may require correct/in-range values for request initialization. 629 * // - It may require specifying regional endpoints when creating the service client as shown in 630 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 631 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 632 * Index index = Index.newBuilder().build(); 633 * FieldMask updateMask = FieldMask.newBuilder().build(); 634 * Index response = indexServiceClient.updateIndexAsync(index, updateMask).get(); 635 * } 636 * }</pre> 637 * 638 * @param index Required. The Index which updates the resource on the server. 639 * @param updateMask The update mask applies to the resource. For the `FieldMask` definition, see 640 * [google.protobuf.FieldMask][google.protobuf.FieldMask]. 641 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 642 */ updateIndexAsync( Index index, FieldMask updateMask)643 public final OperationFuture<Index, UpdateIndexOperationMetadata> updateIndexAsync( 644 Index index, FieldMask updateMask) { 645 UpdateIndexRequest request = 646 UpdateIndexRequest.newBuilder().setIndex(index).setUpdateMask(updateMask).build(); 647 return updateIndexAsync(request); 648 } 649 650 // AUTO-GENERATED DOCUMENTATION AND METHOD. 651 /** 652 * Updates an Index. 653 * 654 * <p>Sample code: 655 * 656 * <pre>{@code 657 * // This snippet has been automatically generated and should be regarded as a code template only. 658 * // It will require modifications to work: 659 * // - It may require correct/in-range values for request initialization. 660 * // - It may require specifying regional endpoints when creating the service client as shown in 661 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 662 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 663 * UpdateIndexRequest request = 664 * UpdateIndexRequest.newBuilder() 665 * .setIndex(Index.newBuilder().build()) 666 * .setUpdateMask(FieldMask.newBuilder().build()) 667 * .build(); 668 * Index response = indexServiceClient.updateIndexAsync(request).get(); 669 * } 670 * }</pre> 671 * 672 * @param request The request object containing all of the parameters for the API call. 673 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 674 */ updateIndexAsync( UpdateIndexRequest request)675 public final OperationFuture<Index, UpdateIndexOperationMetadata> updateIndexAsync( 676 UpdateIndexRequest request) { 677 return updateIndexOperationCallable().futureCall(request); 678 } 679 680 // AUTO-GENERATED DOCUMENTATION AND METHOD. 681 /** 682 * Updates an Index. 683 * 684 * <p>Sample code: 685 * 686 * <pre>{@code 687 * // This snippet has been automatically generated and should be regarded as a code template only. 688 * // It will require modifications to work: 689 * // - It may require correct/in-range values for request initialization. 690 * // - It may require specifying regional endpoints when creating the service client as shown in 691 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 692 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 693 * UpdateIndexRequest request = 694 * UpdateIndexRequest.newBuilder() 695 * .setIndex(Index.newBuilder().build()) 696 * .setUpdateMask(FieldMask.newBuilder().build()) 697 * .build(); 698 * OperationFuture<Index, UpdateIndexOperationMetadata> future = 699 * indexServiceClient.updateIndexOperationCallable().futureCall(request); 700 * // Do something. 701 * Index response = future.get(); 702 * } 703 * }</pre> 704 */ 705 public final OperationCallable<UpdateIndexRequest, Index, UpdateIndexOperationMetadata> updateIndexOperationCallable()706 updateIndexOperationCallable() { 707 return stub.updateIndexOperationCallable(); 708 } 709 710 // AUTO-GENERATED DOCUMENTATION AND METHOD. 711 /** 712 * Updates an Index. 713 * 714 * <p>Sample code: 715 * 716 * <pre>{@code 717 * // This snippet has been automatically generated and should be regarded as a code template only. 718 * // It will require modifications to work: 719 * // - It may require correct/in-range values for request initialization. 720 * // - It may require specifying regional endpoints when creating the service client as shown in 721 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 722 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 723 * UpdateIndexRequest request = 724 * UpdateIndexRequest.newBuilder() 725 * .setIndex(Index.newBuilder().build()) 726 * .setUpdateMask(FieldMask.newBuilder().build()) 727 * .build(); 728 * ApiFuture<Operation> future = indexServiceClient.updateIndexCallable().futureCall(request); 729 * // Do something. 730 * Operation response = future.get(); 731 * } 732 * }</pre> 733 */ updateIndexCallable()734 public final UnaryCallable<UpdateIndexRequest, Operation> updateIndexCallable() { 735 return stub.updateIndexCallable(); 736 } 737 738 // AUTO-GENERATED DOCUMENTATION AND METHOD. 739 /** 740 * Deletes an Index. An Index can only be deleted when all its 741 * [DeployedIndexes][google.cloud.aiplatform.v1beta1.Index.deployed_indexes] had been undeployed. 742 * 743 * <p>Sample code: 744 * 745 * <pre>{@code 746 * // This snippet has been automatically generated and should be regarded as a code template only. 747 * // It will require modifications to work: 748 * // - It may require correct/in-range values for request initialization. 749 * // - It may require specifying regional endpoints when creating the service client as shown in 750 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 751 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 752 * IndexName name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]"); 753 * indexServiceClient.deleteIndexAsync(name).get(); 754 * } 755 * }</pre> 756 * 757 * @param name Required. The name of the Index resource to be deleted. Format: 758 * `projects/{project}/locations/{location}/indexes/{index}` 759 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 760 */ deleteIndexAsync(IndexName name)761 public final OperationFuture<Empty, DeleteOperationMetadata> deleteIndexAsync(IndexName name) { 762 DeleteIndexRequest request = 763 DeleteIndexRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 764 return deleteIndexAsync(request); 765 } 766 767 // AUTO-GENERATED DOCUMENTATION AND METHOD. 768 /** 769 * Deletes an Index. An Index can only be deleted when all its 770 * [DeployedIndexes][google.cloud.aiplatform.v1beta1.Index.deployed_indexes] had been undeployed. 771 * 772 * <p>Sample code: 773 * 774 * <pre>{@code 775 * // This snippet has been automatically generated and should be regarded as a code template only. 776 * // It will require modifications to work: 777 * // - It may require correct/in-range values for request initialization. 778 * // - It may require specifying regional endpoints when creating the service client as shown in 779 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 780 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 781 * String name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString(); 782 * indexServiceClient.deleteIndexAsync(name).get(); 783 * } 784 * }</pre> 785 * 786 * @param name Required. The name of the Index resource to be deleted. Format: 787 * `projects/{project}/locations/{location}/indexes/{index}` 788 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 789 */ deleteIndexAsync(String name)790 public final OperationFuture<Empty, DeleteOperationMetadata> deleteIndexAsync(String name) { 791 DeleteIndexRequest request = DeleteIndexRequest.newBuilder().setName(name).build(); 792 return deleteIndexAsync(request); 793 } 794 795 // AUTO-GENERATED DOCUMENTATION AND METHOD. 796 /** 797 * Deletes an Index. An Index can only be deleted when all its 798 * [DeployedIndexes][google.cloud.aiplatform.v1beta1.Index.deployed_indexes] had been undeployed. 799 * 800 * <p>Sample code: 801 * 802 * <pre>{@code 803 * // This snippet has been automatically generated and should be regarded as a code template only. 804 * // It will require modifications to work: 805 * // - It may require correct/in-range values for request initialization. 806 * // - It may require specifying regional endpoints when creating the service client as shown in 807 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 808 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 809 * DeleteIndexRequest request = 810 * DeleteIndexRequest.newBuilder() 811 * .setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 812 * .build(); 813 * indexServiceClient.deleteIndexAsync(request).get(); 814 * } 815 * }</pre> 816 * 817 * @param request The request object containing all of the parameters for the API call. 818 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 819 */ deleteIndexAsync( DeleteIndexRequest request)820 public final OperationFuture<Empty, DeleteOperationMetadata> deleteIndexAsync( 821 DeleteIndexRequest request) { 822 return deleteIndexOperationCallable().futureCall(request); 823 } 824 825 // AUTO-GENERATED DOCUMENTATION AND METHOD. 826 /** 827 * Deletes an Index. An Index can only be deleted when all its 828 * [DeployedIndexes][google.cloud.aiplatform.v1beta1.Index.deployed_indexes] had been undeployed. 829 * 830 * <p>Sample code: 831 * 832 * <pre>{@code 833 * // This snippet has been automatically generated and should be regarded as a code template only. 834 * // It will require modifications to work: 835 * // - It may require correct/in-range values for request initialization. 836 * // - It may require specifying regional endpoints when creating the service client as shown in 837 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 838 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 839 * DeleteIndexRequest request = 840 * DeleteIndexRequest.newBuilder() 841 * .setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 842 * .build(); 843 * OperationFuture<Empty, DeleteOperationMetadata> future = 844 * indexServiceClient.deleteIndexOperationCallable().futureCall(request); 845 * // Do something. 846 * future.get(); 847 * } 848 * }</pre> 849 */ 850 public final OperationCallable<DeleteIndexRequest, Empty, DeleteOperationMetadata> deleteIndexOperationCallable()851 deleteIndexOperationCallable() { 852 return stub.deleteIndexOperationCallable(); 853 } 854 855 // AUTO-GENERATED DOCUMENTATION AND METHOD. 856 /** 857 * Deletes an Index. An Index can only be deleted when all its 858 * [DeployedIndexes][google.cloud.aiplatform.v1beta1.Index.deployed_indexes] had been undeployed. 859 * 860 * <p>Sample code: 861 * 862 * <pre>{@code 863 * // This snippet has been automatically generated and should be regarded as a code template only. 864 * // It will require modifications to work: 865 * // - It may require correct/in-range values for request initialization. 866 * // - It may require specifying regional endpoints when creating the service client as shown in 867 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 868 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 869 * DeleteIndexRequest request = 870 * DeleteIndexRequest.newBuilder() 871 * .setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 872 * .build(); 873 * ApiFuture<Operation> future = indexServiceClient.deleteIndexCallable().futureCall(request); 874 * // Do something. 875 * future.get(); 876 * } 877 * }</pre> 878 */ deleteIndexCallable()879 public final UnaryCallable<DeleteIndexRequest, Operation> deleteIndexCallable() { 880 return stub.deleteIndexCallable(); 881 } 882 883 // AUTO-GENERATED DOCUMENTATION AND METHOD. 884 /** 885 * Add/update Datapoints into an Index. 886 * 887 * <p>Sample code: 888 * 889 * <pre>{@code 890 * // This snippet has been automatically generated and should be regarded as a code template only. 891 * // It will require modifications to work: 892 * // - It may require correct/in-range values for request initialization. 893 * // - It may require specifying regional endpoints when creating the service client as shown in 894 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 895 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 896 * UpsertDatapointsRequest request = 897 * UpsertDatapointsRequest.newBuilder() 898 * .setIndex(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 899 * .addAllDatapoints(new ArrayList<IndexDatapoint>()) 900 * .build(); 901 * UpsertDatapointsResponse response = indexServiceClient.upsertDatapoints(request); 902 * } 903 * }</pre> 904 * 905 * @param request The request object containing all of the parameters for the API call. 906 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 907 */ upsertDatapoints(UpsertDatapointsRequest request)908 public final UpsertDatapointsResponse upsertDatapoints(UpsertDatapointsRequest request) { 909 return upsertDatapointsCallable().call(request); 910 } 911 912 // AUTO-GENERATED DOCUMENTATION AND METHOD. 913 /** 914 * Add/update Datapoints into an Index. 915 * 916 * <p>Sample code: 917 * 918 * <pre>{@code 919 * // This snippet has been automatically generated and should be regarded as a code template only. 920 * // It will require modifications to work: 921 * // - It may require correct/in-range values for request initialization. 922 * // - It may require specifying regional endpoints when creating the service client as shown in 923 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 924 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 925 * UpsertDatapointsRequest request = 926 * UpsertDatapointsRequest.newBuilder() 927 * .setIndex(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 928 * .addAllDatapoints(new ArrayList<IndexDatapoint>()) 929 * .build(); 930 * ApiFuture<UpsertDatapointsResponse> future = 931 * indexServiceClient.upsertDatapointsCallable().futureCall(request); 932 * // Do something. 933 * UpsertDatapointsResponse response = future.get(); 934 * } 935 * }</pre> 936 */ 937 public final UnaryCallable<UpsertDatapointsRequest, UpsertDatapointsResponse> upsertDatapointsCallable()938 upsertDatapointsCallable() { 939 return stub.upsertDatapointsCallable(); 940 } 941 942 // AUTO-GENERATED DOCUMENTATION AND METHOD. 943 /** 944 * Remove Datapoints from an Index. 945 * 946 * <p>Sample code: 947 * 948 * <pre>{@code 949 * // This snippet has been automatically generated and should be regarded as a code template only. 950 * // It will require modifications to work: 951 * // - It may require correct/in-range values for request initialization. 952 * // - It may require specifying regional endpoints when creating the service client as shown in 953 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 954 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 955 * RemoveDatapointsRequest request = 956 * RemoveDatapointsRequest.newBuilder() 957 * .setIndex(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 958 * .addAllDatapointIds(new ArrayList<String>()) 959 * .build(); 960 * RemoveDatapointsResponse response = indexServiceClient.removeDatapoints(request); 961 * } 962 * }</pre> 963 * 964 * @param request The request object containing all of the parameters for the API call. 965 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 966 */ removeDatapoints(RemoveDatapointsRequest request)967 public final RemoveDatapointsResponse removeDatapoints(RemoveDatapointsRequest request) { 968 return removeDatapointsCallable().call(request); 969 } 970 971 // AUTO-GENERATED DOCUMENTATION AND METHOD. 972 /** 973 * Remove Datapoints from an Index. 974 * 975 * <p>Sample code: 976 * 977 * <pre>{@code 978 * // This snippet has been automatically generated and should be regarded as a code template only. 979 * // It will require modifications to work: 980 * // - It may require correct/in-range values for request initialization. 981 * // - It may require specifying regional endpoints when creating the service client as shown in 982 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 983 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 984 * RemoveDatapointsRequest request = 985 * RemoveDatapointsRequest.newBuilder() 986 * .setIndex(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString()) 987 * .addAllDatapointIds(new ArrayList<String>()) 988 * .build(); 989 * ApiFuture<RemoveDatapointsResponse> future = 990 * indexServiceClient.removeDatapointsCallable().futureCall(request); 991 * // Do something. 992 * RemoveDatapointsResponse response = future.get(); 993 * } 994 * }</pre> 995 */ 996 public final UnaryCallable<RemoveDatapointsRequest, RemoveDatapointsResponse> removeDatapointsCallable()997 removeDatapointsCallable() { 998 return stub.removeDatapointsCallable(); 999 } 1000 1001 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1002 /** 1003 * Lists information about the supported locations for this service. 1004 * 1005 * <p>Sample code: 1006 * 1007 * <pre>{@code 1008 * // This snippet has been automatically generated and should be regarded as a code template only. 1009 * // It will require modifications to work: 1010 * // - It may require correct/in-range values for request initialization. 1011 * // - It may require specifying regional endpoints when creating the service client as shown in 1012 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1013 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1014 * ListLocationsRequest request = 1015 * ListLocationsRequest.newBuilder() 1016 * .setName("name3373707") 1017 * .setFilter("filter-1274492040") 1018 * .setPageSize(883849137) 1019 * .setPageToken("pageToken873572522") 1020 * .build(); 1021 * for (Location element : indexServiceClient.listLocations(request).iterateAll()) { 1022 * // doThingsWith(element); 1023 * } 1024 * } 1025 * }</pre> 1026 * 1027 * @param request The request object containing all of the parameters for the API call. 1028 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1029 */ listLocations(ListLocationsRequest request)1030 public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { 1031 return listLocationsPagedCallable().call(request); 1032 } 1033 1034 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1035 /** 1036 * Lists information about the supported locations for this service. 1037 * 1038 * <p>Sample code: 1039 * 1040 * <pre>{@code 1041 * // This snippet has been automatically generated and should be regarded as a code template only. 1042 * // It will require modifications to work: 1043 * // - It may require correct/in-range values for request initialization. 1044 * // - It may require specifying regional endpoints when creating the service client as shown in 1045 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1046 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1047 * ListLocationsRequest request = 1048 * ListLocationsRequest.newBuilder() 1049 * .setName("name3373707") 1050 * .setFilter("filter-1274492040") 1051 * .setPageSize(883849137) 1052 * .setPageToken("pageToken873572522") 1053 * .build(); 1054 * ApiFuture<Location> future = 1055 * indexServiceClient.listLocationsPagedCallable().futureCall(request); 1056 * // Do something. 1057 * for (Location element : future.get().iterateAll()) { 1058 * // doThingsWith(element); 1059 * } 1060 * } 1061 * }</pre> 1062 */ 1063 public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse> listLocationsPagedCallable()1064 listLocationsPagedCallable() { 1065 return stub.listLocationsPagedCallable(); 1066 } 1067 1068 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1069 /** 1070 * Lists information about the supported locations for this service. 1071 * 1072 * <p>Sample code: 1073 * 1074 * <pre>{@code 1075 * // This snippet has been automatically generated and should be regarded as a code template only. 1076 * // It will require modifications to work: 1077 * // - It may require correct/in-range values for request initialization. 1078 * // - It may require specifying regional endpoints when creating the service client as shown in 1079 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1080 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1081 * ListLocationsRequest request = 1082 * ListLocationsRequest.newBuilder() 1083 * .setName("name3373707") 1084 * .setFilter("filter-1274492040") 1085 * .setPageSize(883849137) 1086 * .setPageToken("pageToken873572522") 1087 * .build(); 1088 * while (true) { 1089 * ListLocationsResponse response = indexServiceClient.listLocationsCallable().call(request); 1090 * for (Location element : response.getLocationsList()) { 1091 * // doThingsWith(element); 1092 * } 1093 * String nextPageToken = response.getNextPageToken(); 1094 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1095 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1096 * } else { 1097 * break; 1098 * } 1099 * } 1100 * } 1101 * }</pre> 1102 */ listLocationsCallable()1103 public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() { 1104 return stub.listLocationsCallable(); 1105 } 1106 1107 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1108 /** 1109 * Gets information about a location. 1110 * 1111 * <p>Sample code: 1112 * 1113 * <pre>{@code 1114 * // This snippet has been automatically generated and should be regarded as a code template only. 1115 * // It will require modifications to work: 1116 * // - It may require correct/in-range values for request initialization. 1117 * // - It may require specifying regional endpoints when creating the service client as shown in 1118 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1119 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1120 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 1121 * Location response = indexServiceClient.getLocation(request); 1122 * } 1123 * }</pre> 1124 * 1125 * @param request The request object containing all of the parameters for the API call. 1126 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1127 */ getLocation(GetLocationRequest request)1128 public final Location getLocation(GetLocationRequest request) { 1129 return getLocationCallable().call(request); 1130 } 1131 1132 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1133 /** 1134 * Gets information about a location. 1135 * 1136 * <p>Sample code: 1137 * 1138 * <pre>{@code 1139 * // This snippet has been automatically generated and should be regarded as a code template only. 1140 * // It will require modifications to work: 1141 * // - It may require correct/in-range values for request initialization. 1142 * // - It may require specifying regional endpoints when creating the service client as shown in 1143 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1144 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1145 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 1146 * ApiFuture<Location> future = indexServiceClient.getLocationCallable().futureCall(request); 1147 * // Do something. 1148 * Location response = future.get(); 1149 * } 1150 * }</pre> 1151 */ getLocationCallable()1152 public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() { 1153 return stub.getLocationCallable(); 1154 } 1155 1156 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1157 /** 1158 * Sets the access control policy on the specified resource. Replacesany existing policy. 1159 * 1160 * <p>Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. 1161 * 1162 * <p>Sample code: 1163 * 1164 * <pre>{@code 1165 * // This snippet has been automatically generated and should be regarded as a code template only. 1166 * // It will require modifications to work: 1167 * // - It may require correct/in-range values for request initialization. 1168 * // - It may require specifying regional endpoints when creating the service client as shown in 1169 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1170 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1171 * SetIamPolicyRequest request = 1172 * SetIamPolicyRequest.newBuilder() 1173 * .setResource( 1174 * EndpointName.ofProjectLocationEndpointName( 1175 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1176 * .toString()) 1177 * .setPolicy(Policy.newBuilder().build()) 1178 * .setUpdateMask(FieldMask.newBuilder().build()) 1179 * .build(); 1180 * Policy response = indexServiceClient.setIamPolicy(request); 1181 * } 1182 * }</pre> 1183 * 1184 * @param request The request object containing all of the parameters for the API call. 1185 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1186 */ setIamPolicy(SetIamPolicyRequest request)1187 public final Policy setIamPolicy(SetIamPolicyRequest request) { 1188 return setIamPolicyCallable().call(request); 1189 } 1190 1191 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1192 /** 1193 * Sets the access control policy on the specified resource. Replacesany existing policy. 1194 * 1195 * <p>Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. 1196 * 1197 * <p>Sample code: 1198 * 1199 * <pre>{@code 1200 * // This snippet has been automatically generated and should be regarded as a code template only. 1201 * // It will require modifications to work: 1202 * // - It may require correct/in-range values for request initialization. 1203 * // - It may require specifying regional endpoints when creating the service client as shown in 1204 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1205 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1206 * SetIamPolicyRequest request = 1207 * SetIamPolicyRequest.newBuilder() 1208 * .setResource( 1209 * EndpointName.ofProjectLocationEndpointName( 1210 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1211 * .toString()) 1212 * .setPolicy(Policy.newBuilder().build()) 1213 * .setUpdateMask(FieldMask.newBuilder().build()) 1214 * .build(); 1215 * ApiFuture<Policy> future = indexServiceClient.setIamPolicyCallable().futureCall(request); 1216 * // Do something. 1217 * Policy response = future.get(); 1218 * } 1219 * }</pre> 1220 */ setIamPolicyCallable()1221 public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() { 1222 return stub.setIamPolicyCallable(); 1223 } 1224 1225 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1226 /** 1227 * Gets the access control policy for a resource. Returns an empty policyif the resource exists 1228 * and does not have a policy set. 1229 * 1230 * <p>Sample code: 1231 * 1232 * <pre>{@code 1233 * // This snippet has been automatically generated and should be regarded as a code template only. 1234 * // It will require modifications to work: 1235 * // - It may require correct/in-range values for request initialization. 1236 * // - It may require specifying regional endpoints when creating the service client as shown in 1237 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1238 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1239 * GetIamPolicyRequest request = 1240 * GetIamPolicyRequest.newBuilder() 1241 * .setResource( 1242 * EndpointName.ofProjectLocationEndpointName( 1243 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1244 * .toString()) 1245 * .setOptions(GetPolicyOptions.newBuilder().build()) 1246 * .build(); 1247 * Policy response = indexServiceClient.getIamPolicy(request); 1248 * } 1249 * }</pre> 1250 * 1251 * @param request The request object containing all of the parameters for the API call. 1252 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1253 */ getIamPolicy(GetIamPolicyRequest request)1254 public final Policy getIamPolicy(GetIamPolicyRequest request) { 1255 return getIamPolicyCallable().call(request); 1256 } 1257 1258 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1259 /** 1260 * Gets the access control policy for a resource. Returns an empty policyif the resource exists 1261 * and does not have a policy set. 1262 * 1263 * <p>Sample code: 1264 * 1265 * <pre>{@code 1266 * // This snippet has been automatically generated and should be regarded as a code template only. 1267 * // It will require modifications to work: 1268 * // - It may require correct/in-range values for request initialization. 1269 * // - It may require specifying regional endpoints when creating the service client as shown in 1270 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1271 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1272 * GetIamPolicyRequest request = 1273 * GetIamPolicyRequest.newBuilder() 1274 * .setResource( 1275 * EndpointName.ofProjectLocationEndpointName( 1276 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1277 * .toString()) 1278 * .setOptions(GetPolicyOptions.newBuilder().build()) 1279 * .build(); 1280 * ApiFuture<Policy> future = indexServiceClient.getIamPolicyCallable().futureCall(request); 1281 * // Do something. 1282 * Policy response = future.get(); 1283 * } 1284 * }</pre> 1285 */ getIamPolicyCallable()1286 public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() { 1287 return stub.getIamPolicyCallable(); 1288 } 1289 1290 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1291 /** 1292 * Returns permissions that a caller has on the specified resource. If theresource does not exist, 1293 * this will return an empty set ofpermissions, not a `NOT_FOUND` error. 1294 * 1295 * <p>Note: This operation is designed to be used for buildingpermission-aware UIs and 1296 * command-line tools, not for authorizationchecking. This operation may "fail open" without 1297 * warning. 1298 * 1299 * <p>Sample code: 1300 * 1301 * <pre>{@code 1302 * // This snippet has been automatically generated and should be regarded as a code template only. 1303 * // It will require modifications to work: 1304 * // - It may require correct/in-range values for request initialization. 1305 * // - It may require specifying regional endpoints when creating the service client as shown in 1306 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1307 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1308 * TestIamPermissionsRequest request = 1309 * TestIamPermissionsRequest.newBuilder() 1310 * .setResource( 1311 * EndpointName.ofProjectLocationEndpointName( 1312 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1313 * .toString()) 1314 * .addAllPermissions(new ArrayList<String>()) 1315 * .build(); 1316 * TestIamPermissionsResponse response = indexServiceClient.testIamPermissions(request); 1317 * } 1318 * }</pre> 1319 * 1320 * @param request The request object containing all of the parameters for the API call. 1321 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1322 */ testIamPermissions(TestIamPermissionsRequest request)1323 public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { 1324 return testIamPermissionsCallable().call(request); 1325 } 1326 1327 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1328 /** 1329 * Returns permissions that a caller has on the specified resource. If theresource does not exist, 1330 * this will return an empty set ofpermissions, not a `NOT_FOUND` error. 1331 * 1332 * <p>Note: This operation is designed to be used for buildingpermission-aware UIs and 1333 * command-line tools, not for authorizationchecking. This operation may "fail open" without 1334 * warning. 1335 * 1336 * <p>Sample code: 1337 * 1338 * <pre>{@code 1339 * // This snippet has been automatically generated and should be regarded as a code template only. 1340 * // It will require modifications to work: 1341 * // - It may require correct/in-range values for request initialization. 1342 * // - It may require specifying regional endpoints when creating the service client as shown in 1343 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1344 * try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) { 1345 * TestIamPermissionsRequest request = 1346 * TestIamPermissionsRequest.newBuilder() 1347 * .setResource( 1348 * EndpointName.ofProjectLocationEndpointName( 1349 * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") 1350 * .toString()) 1351 * .addAllPermissions(new ArrayList<String>()) 1352 * .build(); 1353 * ApiFuture<TestIamPermissionsResponse> future = 1354 * indexServiceClient.testIamPermissionsCallable().futureCall(request); 1355 * // Do something. 1356 * TestIamPermissionsResponse response = future.get(); 1357 * } 1358 * }</pre> 1359 */ 1360 public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsCallable()1361 testIamPermissionsCallable() { 1362 return stub.testIamPermissionsCallable(); 1363 } 1364 1365 @Override close()1366 public final void close() { 1367 stub.close(); 1368 } 1369 1370 @Override shutdown()1371 public void shutdown() { 1372 stub.shutdown(); 1373 } 1374 1375 @Override isShutdown()1376 public boolean isShutdown() { 1377 return stub.isShutdown(); 1378 } 1379 1380 @Override isTerminated()1381 public boolean isTerminated() { 1382 return stub.isTerminated(); 1383 } 1384 1385 @Override shutdownNow()1386 public void shutdownNow() { 1387 stub.shutdownNow(); 1388 } 1389 1390 @Override awaitTermination(long duration, TimeUnit unit)1391 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 1392 return stub.awaitTermination(duration, unit); 1393 } 1394 1395 public static class ListIndexesPagedResponse 1396 extends AbstractPagedListResponse< 1397 ListIndexesRequest, 1398 ListIndexesResponse, 1399 Index, 1400 ListIndexesPage, 1401 ListIndexesFixedSizeCollection> { 1402 createAsync( PageContext<ListIndexesRequest, ListIndexesResponse, Index> context, ApiFuture<ListIndexesResponse> futureResponse)1403 public static ApiFuture<ListIndexesPagedResponse> createAsync( 1404 PageContext<ListIndexesRequest, ListIndexesResponse, Index> context, 1405 ApiFuture<ListIndexesResponse> futureResponse) { 1406 ApiFuture<ListIndexesPage> futurePage = 1407 ListIndexesPage.createEmptyPage().createPageAsync(context, futureResponse); 1408 return ApiFutures.transform( 1409 futurePage, input -> new ListIndexesPagedResponse(input), MoreExecutors.directExecutor()); 1410 } 1411 ListIndexesPagedResponse(ListIndexesPage page)1412 private ListIndexesPagedResponse(ListIndexesPage page) { 1413 super(page, ListIndexesFixedSizeCollection.createEmptyCollection()); 1414 } 1415 } 1416 1417 public static class ListIndexesPage 1418 extends AbstractPage<ListIndexesRequest, ListIndexesResponse, Index, ListIndexesPage> { 1419 ListIndexesPage( PageContext<ListIndexesRequest, ListIndexesResponse, Index> context, ListIndexesResponse response)1420 private ListIndexesPage( 1421 PageContext<ListIndexesRequest, ListIndexesResponse, Index> context, 1422 ListIndexesResponse response) { 1423 super(context, response); 1424 } 1425 createEmptyPage()1426 private static ListIndexesPage createEmptyPage() { 1427 return new ListIndexesPage(null, null); 1428 } 1429 1430 @Override createPage( PageContext<ListIndexesRequest, ListIndexesResponse, Index> context, ListIndexesResponse response)1431 protected ListIndexesPage createPage( 1432 PageContext<ListIndexesRequest, ListIndexesResponse, Index> context, 1433 ListIndexesResponse response) { 1434 return new ListIndexesPage(context, response); 1435 } 1436 1437 @Override createPageAsync( PageContext<ListIndexesRequest, ListIndexesResponse, Index> context, ApiFuture<ListIndexesResponse> futureResponse)1438 public ApiFuture<ListIndexesPage> createPageAsync( 1439 PageContext<ListIndexesRequest, ListIndexesResponse, Index> context, 1440 ApiFuture<ListIndexesResponse> futureResponse) { 1441 return super.createPageAsync(context, futureResponse); 1442 } 1443 } 1444 1445 public static class ListIndexesFixedSizeCollection 1446 extends AbstractFixedSizeCollection< 1447 ListIndexesRequest, 1448 ListIndexesResponse, 1449 Index, 1450 ListIndexesPage, 1451 ListIndexesFixedSizeCollection> { 1452 ListIndexesFixedSizeCollection(List<ListIndexesPage> pages, int collectionSize)1453 private ListIndexesFixedSizeCollection(List<ListIndexesPage> pages, int collectionSize) { 1454 super(pages, collectionSize); 1455 } 1456 createEmptyCollection()1457 private static ListIndexesFixedSizeCollection createEmptyCollection() { 1458 return new ListIndexesFixedSizeCollection(null, 0); 1459 } 1460 1461 @Override createCollection( List<ListIndexesPage> pages, int collectionSize)1462 protected ListIndexesFixedSizeCollection createCollection( 1463 List<ListIndexesPage> pages, int collectionSize) { 1464 return new ListIndexesFixedSizeCollection(pages, collectionSize); 1465 } 1466 } 1467 1468 public static class ListLocationsPagedResponse 1469 extends AbstractPagedListResponse< 1470 ListLocationsRequest, 1471 ListLocationsResponse, 1472 Location, 1473 ListLocationsPage, 1474 ListLocationsFixedSizeCollection> { 1475 createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1476 public static ApiFuture<ListLocationsPagedResponse> createAsync( 1477 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1478 ApiFuture<ListLocationsResponse> futureResponse) { 1479 ApiFuture<ListLocationsPage> futurePage = 1480 ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); 1481 return ApiFutures.transform( 1482 futurePage, 1483 input -> new ListLocationsPagedResponse(input), 1484 MoreExecutors.directExecutor()); 1485 } 1486 ListLocationsPagedResponse(ListLocationsPage page)1487 private ListLocationsPagedResponse(ListLocationsPage page) { 1488 super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); 1489 } 1490 } 1491 1492 public static class ListLocationsPage 1493 extends AbstractPage< 1494 ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { 1495 ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1496 private ListLocationsPage( 1497 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1498 ListLocationsResponse response) { 1499 super(context, response); 1500 } 1501 createEmptyPage()1502 private static ListLocationsPage createEmptyPage() { 1503 return new ListLocationsPage(null, null); 1504 } 1505 1506 @Override createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1507 protected ListLocationsPage createPage( 1508 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1509 ListLocationsResponse response) { 1510 return new ListLocationsPage(context, response); 1511 } 1512 1513 @Override createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1514 public ApiFuture<ListLocationsPage> createPageAsync( 1515 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1516 ApiFuture<ListLocationsResponse> futureResponse) { 1517 return super.createPageAsync(context, futureResponse); 1518 } 1519 } 1520 1521 public static class ListLocationsFixedSizeCollection 1522 extends AbstractFixedSizeCollection< 1523 ListLocationsRequest, 1524 ListLocationsResponse, 1525 Location, 1526 ListLocationsPage, 1527 ListLocationsFixedSizeCollection> { 1528 ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1529 private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) { 1530 super(pages, collectionSize); 1531 } 1532 createEmptyCollection()1533 private static ListLocationsFixedSizeCollection createEmptyCollection() { 1534 return new ListLocationsFixedSizeCollection(null, 0); 1535 } 1536 1537 @Override createCollection( List<ListLocationsPage> pages, int collectionSize)1538 protected ListLocationsFixedSizeCollection createCollection( 1539 List<ListLocationsPage> pages, int collectionSize) { 1540 return new ListLocationsFixedSizeCollection(pages, collectionSize); 1541 } 1542 } 1543 } 1544