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.vision.v1p3beta1; 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.httpjson.longrunning.OperationsClient; 24 import com.google.api.gax.longrunning.OperationFuture; 25 import com.google.api.gax.paging.AbstractFixedSizeCollection; 26 import com.google.api.gax.paging.AbstractPage; 27 import com.google.api.gax.paging.AbstractPagedListResponse; 28 import com.google.api.gax.rpc.OperationCallable; 29 import com.google.api.gax.rpc.PageContext; 30 import com.google.api.gax.rpc.UnaryCallable; 31 import com.google.cloud.vision.v1p3beta1.stub.ProductSearchStub; 32 import com.google.cloud.vision.v1p3beta1.stub.ProductSearchStubSettings; 33 import com.google.common.util.concurrent.MoreExecutors; 34 import com.google.longrunning.Operation; 35 import com.google.protobuf.Empty; 36 import com.google.protobuf.FieldMask; 37 import java.io.IOException; 38 import java.util.List; 39 import java.util.concurrent.TimeUnit; 40 import javax.annotation.Generated; 41 42 // AUTO-GENERATED DOCUMENTATION AND CLASS. 43 /** 44 * Service Description: Manages Products and ProductSets of reference images for use in product 45 * search. It uses the following resource model: 46 * 47 * <p>- The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] 48 * resources, named `projects/*/locations/*/productSets/*`, which acts as a way to put 49 * different products into groups to limit identification. 50 * 51 * <p>In parallel, 52 * 53 * <p>- The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, 54 * named `projects/*/locations/*/products/*` 55 * 56 * <p>- Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of 57 * [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named 58 * `projects/*/locations/*/products/*/referenceImages/*` 59 * 60 * <p>This class provides the ability to make remote calls to the backing service through method 61 * calls that map to API methods. Sample code to get started: 62 * 63 * <pre>{@code 64 * // This snippet has been automatically generated and should be regarded as a code template only. 65 * // It will require modifications to work: 66 * // - It may require correct/in-range values for request initialization. 67 * // - It may require specifying regional endpoints when creating the service client as shown in 68 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 69 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 70 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 71 * ProductSet productSet = ProductSet.newBuilder().build(); 72 * String productSetId = "productSetId1003042158"; 73 * ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); 74 * } 75 * }</pre> 76 * 77 * <p>Note: close() needs to be called on the ProductSearchClient object to clean up resources such 78 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 79 * 80 * <p>The surface of this class includes several types of Java methods for each of the API's 81 * methods: 82 * 83 * <ol> 84 * <li>A "flattened" method. With this type of method, the fields of the request type have been 85 * converted into function parameters. It may be the case that not all fields are available as 86 * parameters, and not every API method will have a flattened method entry point. 87 * <li>A "request object" method. This type of method only takes one parameter, a request object, 88 * which must be constructed before the call. Not every API method will have a request object 89 * method. 90 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 91 * callable object, which can be used to initiate calls to the service. 92 * </ol> 93 * 94 * <p>See the individual methods for example code. 95 * 96 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 97 * these names, this class includes a format method for each type of name, and additionally a parse 98 * method to extract the individual identifiers contained within names that are returned. 99 * 100 * <p>This class can be customized by passing in a custom instance of ProductSearchSettings to 101 * create(). For example: 102 * 103 * <p>To customize credentials: 104 * 105 * <pre>{@code 106 * // This snippet has been automatically generated and should be regarded as a code template only. 107 * // It will require modifications to work: 108 * // - It may require correct/in-range values for request initialization. 109 * // - It may require specifying regional endpoints when creating the service client as shown in 110 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 111 * ProductSearchSettings productSearchSettings = 112 * ProductSearchSettings.newBuilder() 113 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 114 * .build(); 115 * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); 116 * }</pre> 117 * 118 * <p>To customize the endpoint: 119 * 120 * <pre>{@code 121 * // This snippet has been automatically generated and should be regarded as a code template only. 122 * // It will require modifications to work: 123 * // - It may require correct/in-range values for request initialization. 124 * // - It may require specifying regional endpoints when creating the service client as shown in 125 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 126 * ProductSearchSettings productSearchSettings = 127 * ProductSearchSettings.newBuilder().setEndpoint(myEndpoint).build(); 128 * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); 129 * }</pre> 130 * 131 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 132 * the wire: 133 * 134 * <pre>{@code 135 * // This snippet has been automatically generated and should be regarded as a code template only. 136 * // It will require modifications to work: 137 * // - It may require correct/in-range values for request initialization. 138 * // - It may require specifying regional endpoints when creating the service client as shown in 139 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 140 * ProductSearchSettings productSearchSettings = 141 * ProductSearchSettings.newHttpJsonBuilder().build(); 142 * ProductSearchClient productSearchClient = ProductSearchClient.create(productSearchSettings); 143 * }</pre> 144 * 145 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 146 */ 147 @BetaApi 148 @Generated("by gapic-generator-java") 149 public class ProductSearchClient implements BackgroundResource { 150 private final ProductSearchSettings settings; 151 private final ProductSearchStub stub; 152 private final OperationsClient httpJsonOperationsClient; 153 private final com.google.longrunning.OperationsClient operationsClient; 154 155 /** Constructs an instance of ProductSearchClient with default settings. */ create()156 public static final ProductSearchClient create() throws IOException { 157 return create(ProductSearchSettings.newBuilder().build()); 158 } 159 160 /** 161 * Constructs an instance of ProductSearchClient, using the given settings. The channels are 162 * created based on the settings passed in, or defaults for any settings that are not set. 163 */ create(ProductSearchSettings settings)164 public static final ProductSearchClient create(ProductSearchSettings settings) 165 throws IOException { 166 return new ProductSearchClient(settings); 167 } 168 169 /** 170 * Constructs an instance of ProductSearchClient, using the given stub for making calls. This is 171 * for advanced usage - prefer using create(ProductSearchSettings). 172 */ create(ProductSearchStub stub)173 public static final ProductSearchClient create(ProductSearchStub stub) { 174 return new ProductSearchClient(stub); 175 } 176 177 /** 178 * Constructs an instance of ProductSearchClient, using the given settings. This is protected so 179 * that it is easy to make a subclass, but otherwise, the static factory methods should be 180 * preferred. 181 */ ProductSearchClient(ProductSearchSettings settings)182 protected ProductSearchClient(ProductSearchSettings settings) throws IOException { 183 this.settings = settings; 184 this.stub = ((ProductSearchStubSettings) settings.getStubSettings()).createStub(); 185 this.operationsClient = 186 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 187 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 188 } 189 ProductSearchClient(ProductSearchStub stub)190 protected ProductSearchClient(ProductSearchStub stub) { 191 this.settings = null; 192 this.stub = stub; 193 this.operationsClient = 194 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 195 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 196 } 197 getSettings()198 public final ProductSearchSettings getSettings() { 199 return settings; 200 } 201 getStub()202 public ProductSearchStub getStub() { 203 return stub; 204 } 205 206 /** 207 * Returns the OperationsClient that can be used to query the status of a long-running operation 208 * returned by another API method call. 209 */ getOperationsClient()210 public final com.google.longrunning.OperationsClient getOperationsClient() { 211 return operationsClient; 212 } 213 214 /** 215 * Returns the OperationsClient that can be used to query the status of a long-running operation 216 * returned by another API method call. 217 */ 218 @BetaApi getHttpJsonOperationsClient()219 public final OperationsClient getHttpJsonOperationsClient() { 220 return httpJsonOperationsClient; 221 } 222 223 // AUTO-GENERATED DOCUMENTATION AND METHOD. 224 /** 225 * Creates and returns a new ProductSet resource. 226 * 227 * <p>Possible errors: 228 * 229 * <ul> 230 * <li>Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters. 231 * </ul> 232 * 233 * <p>Sample code: 234 * 235 * <pre>{@code 236 * // This snippet has been automatically generated and should be regarded as a code template only. 237 * // It will require modifications to work: 238 * // - It may require correct/in-range values for request initialization. 239 * // - It may require specifying regional endpoints when creating the service client as shown in 240 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 241 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 242 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 243 * ProductSet productSet = ProductSet.newBuilder().build(); 244 * String productSetId = "productSetId1003042158"; 245 * ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); 246 * } 247 * }</pre> 248 * 249 * @param parent Required. The project in which the ProductSet should be created. 250 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID`. 251 * @param productSet Required. The ProductSet to create. 252 * @param productSetId A user-supplied resource id for this ProductSet. If set, the server will 253 * attempt to use this value as the resource id. If it is already in use, an error is returned 254 * with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the 255 * character `/`. 256 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 257 */ createProductSet( LocationName parent, ProductSet productSet, String productSetId)258 public final ProductSet createProductSet( 259 LocationName parent, ProductSet productSet, String productSetId) { 260 CreateProductSetRequest request = 261 CreateProductSetRequest.newBuilder() 262 .setParent(parent == null ? null : parent.toString()) 263 .setProductSet(productSet) 264 .setProductSetId(productSetId) 265 .build(); 266 return createProductSet(request); 267 } 268 269 // AUTO-GENERATED DOCUMENTATION AND METHOD. 270 /** 271 * Creates and returns a new ProductSet resource. 272 * 273 * <p>Possible errors: 274 * 275 * <ul> 276 * <li>Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters. 277 * </ul> 278 * 279 * <p>Sample code: 280 * 281 * <pre>{@code 282 * // This snippet has been automatically generated and should be regarded as a code template only. 283 * // It will require modifications to work: 284 * // - It may require correct/in-range values for request initialization. 285 * // - It may require specifying regional endpoints when creating the service client as shown in 286 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 287 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 288 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 289 * ProductSet productSet = ProductSet.newBuilder().build(); 290 * String productSetId = "productSetId1003042158"; 291 * ProductSet response = productSearchClient.createProductSet(parent, productSet, productSetId); 292 * } 293 * }</pre> 294 * 295 * @param parent Required. The project in which the ProductSet should be created. 296 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID`. 297 * @param productSet Required. The ProductSet to create. 298 * @param productSetId A user-supplied resource id for this ProductSet. If set, the server will 299 * attempt to use this value as the resource id. If it is already in use, an error is returned 300 * with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the 301 * character `/`. 302 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 303 */ createProductSet( String parent, ProductSet productSet, String productSetId)304 public final ProductSet createProductSet( 305 String parent, ProductSet productSet, String productSetId) { 306 CreateProductSetRequest request = 307 CreateProductSetRequest.newBuilder() 308 .setParent(parent) 309 .setProductSet(productSet) 310 .setProductSetId(productSetId) 311 .build(); 312 return createProductSet(request); 313 } 314 315 // AUTO-GENERATED DOCUMENTATION AND METHOD. 316 /** 317 * Creates and returns a new ProductSet resource. 318 * 319 * <p>Possible errors: 320 * 321 * <ul> 322 * <li>Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters. 323 * </ul> 324 * 325 * <p>Sample code: 326 * 327 * <pre>{@code 328 * // This snippet has been automatically generated and should be regarded as a code template only. 329 * // It will require modifications to work: 330 * // - It may require correct/in-range values for request initialization. 331 * // - It may require specifying regional endpoints when creating the service client as shown in 332 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 333 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 334 * CreateProductSetRequest request = 335 * CreateProductSetRequest.newBuilder() 336 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 337 * .setProductSet(ProductSet.newBuilder().build()) 338 * .setProductSetId("productSetId1003042158") 339 * .build(); 340 * ProductSet response = productSearchClient.createProductSet(request); 341 * } 342 * }</pre> 343 * 344 * @param request The request object containing all of the parameters for the API call. 345 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 346 */ createProductSet(CreateProductSetRequest request)347 public final ProductSet createProductSet(CreateProductSetRequest request) { 348 return createProductSetCallable().call(request); 349 } 350 351 // AUTO-GENERATED DOCUMENTATION AND METHOD. 352 /** 353 * Creates and returns a new ProductSet resource. 354 * 355 * <p>Possible errors: 356 * 357 * <ul> 358 * <li>Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters. 359 * </ul> 360 * 361 * <p>Sample code: 362 * 363 * <pre>{@code 364 * // This snippet has been automatically generated and should be regarded as a code template only. 365 * // It will require modifications to work: 366 * // - It may require correct/in-range values for request initialization. 367 * // - It may require specifying regional endpoints when creating the service client as shown in 368 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 369 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 370 * CreateProductSetRequest request = 371 * CreateProductSetRequest.newBuilder() 372 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 373 * .setProductSet(ProductSet.newBuilder().build()) 374 * .setProductSetId("productSetId1003042158") 375 * .build(); 376 * ApiFuture<ProductSet> future = 377 * productSearchClient.createProductSetCallable().futureCall(request); 378 * // Do something. 379 * ProductSet response = future.get(); 380 * } 381 * }</pre> 382 */ createProductSetCallable()383 public final UnaryCallable<CreateProductSetRequest, ProductSet> createProductSetCallable() { 384 return stub.createProductSetCallable(); 385 } 386 387 // AUTO-GENERATED DOCUMENTATION AND METHOD. 388 /** 389 * Lists ProductSets in an unspecified order. 390 * 391 * <p>Possible errors: 392 * 393 * <ul> 394 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1. 395 * </ul> 396 * 397 * <p>Sample code: 398 * 399 * <pre>{@code 400 * // This snippet has been automatically generated and should be regarded as a code template only. 401 * // It will require modifications to work: 402 * // - It may require correct/in-range values for request initialization. 403 * // - It may require specifying regional endpoints when creating the service client as shown in 404 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 405 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 406 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 407 * for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) { 408 * // doThingsWith(element); 409 * } 410 * } 411 * }</pre> 412 * 413 * @param parent Required. The project from which ProductSets should be listed. 414 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID`. 415 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 416 */ listProductSets(LocationName parent)417 public final ListProductSetsPagedResponse listProductSets(LocationName parent) { 418 ListProductSetsRequest request = 419 ListProductSetsRequest.newBuilder() 420 .setParent(parent == null ? null : parent.toString()) 421 .build(); 422 return listProductSets(request); 423 } 424 425 // AUTO-GENERATED DOCUMENTATION AND METHOD. 426 /** 427 * Lists ProductSets in an unspecified order. 428 * 429 * <p>Possible errors: 430 * 431 * <ul> 432 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1. 433 * </ul> 434 * 435 * <p>Sample code: 436 * 437 * <pre>{@code 438 * // This snippet has been automatically generated and should be regarded as a code template only. 439 * // It will require modifications to work: 440 * // - It may require correct/in-range values for request initialization. 441 * // - It may require specifying regional endpoints when creating the service client as shown in 442 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 443 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 444 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 445 * for (ProductSet element : productSearchClient.listProductSets(parent).iterateAll()) { 446 * // doThingsWith(element); 447 * } 448 * } 449 * }</pre> 450 * 451 * @param parent Required. The project from which ProductSets should be listed. 452 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID`. 453 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 454 */ listProductSets(String parent)455 public final ListProductSetsPagedResponse listProductSets(String parent) { 456 ListProductSetsRequest request = ListProductSetsRequest.newBuilder().setParent(parent).build(); 457 return listProductSets(request); 458 } 459 460 // AUTO-GENERATED DOCUMENTATION AND METHOD. 461 /** 462 * Lists ProductSets in an unspecified order. 463 * 464 * <p>Possible errors: 465 * 466 * <ul> 467 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1. 468 * </ul> 469 * 470 * <p>Sample code: 471 * 472 * <pre>{@code 473 * // This snippet has been automatically generated and should be regarded as a code template only. 474 * // It will require modifications to work: 475 * // - It may require correct/in-range values for request initialization. 476 * // - It may require specifying regional endpoints when creating the service client as shown in 477 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 478 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 479 * ListProductSetsRequest request = 480 * ListProductSetsRequest.newBuilder() 481 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 482 * .setPageSize(883849137) 483 * .setPageToken("pageToken873572522") 484 * .build(); 485 * for (ProductSet element : productSearchClient.listProductSets(request).iterateAll()) { 486 * // doThingsWith(element); 487 * } 488 * } 489 * }</pre> 490 * 491 * @param request The request object containing all of the parameters for the API call. 492 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 493 */ listProductSets(ListProductSetsRequest request)494 public final ListProductSetsPagedResponse listProductSets(ListProductSetsRequest request) { 495 return listProductSetsPagedCallable().call(request); 496 } 497 498 // AUTO-GENERATED DOCUMENTATION AND METHOD. 499 /** 500 * Lists ProductSets in an unspecified order. 501 * 502 * <p>Possible errors: 503 * 504 * <ul> 505 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1. 506 * </ul> 507 * 508 * <p>Sample code: 509 * 510 * <pre>{@code 511 * // This snippet has been automatically generated and should be regarded as a code template only. 512 * // It will require modifications to work: 513 * // - It may require correct/in-range values for request initialization. 514 * // - It may require specifying regional endpoints when creating the service client as shown in 515 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 516 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 517 * ListProductSetsRequest request = 518 * ListProductSetsRequest.newBuilder() 519 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 520 * .setPageSize(883849137) 521 * .setPageToken("pageToken873572522") 522 * .build(); 523 * ApiFuture<ProductSet> future = 524 * productSearchClient.listProductSetsPagedCallable().futureCall(request); 525 * // Do something. 526 * for (ProductSet element : future.get().iterateAll()) { 527 * // doThingsWith(element); 528 * } 529 * } 530 * }</pre> 531 */ 532 public final UnaryCallable<ListProductSetsRequest, ListProductSetsPagedResponse> listProductSetsPagedCallable()533 listProductSetsPagedCallable() { 534 return stub.listProductSetsPagedCallable(); 535 } 536 537 // AUTO-GENERATED DOCUMENTATION AND METHOD. 538 /** 539 * Lists ProductSets in an unspecified order. 540 * 541 * <p>Possible errors: 542 * 543 * <ul> 544 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1. 545 * </ul> 546 * 547 * <p>Sample code: 548 * 549 * <pre>{@code 550 * // This snippet has been automatically generated and should be regarded as a code template only. 551 * // It will require modifications to work: 552 * // - It may require correct/in-range values for request initialization. 553 * // - It may require specifying regional endpoints when creating the service client as shown in 554 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 555 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 556 * ListProductSetsRequest request = 557 * ListProductSetsRequest.newBuilder() 558 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 559 * .setPageSize(883849137) 560 * .setPageToken("pageToken873572522") 561 * .build(); 562 * while (true) { 563 * ListProductSetsResponse response = 564 * productSearchClient.listProductSetsCallable().call(request); 565 * for (ProductSet element : response.getProductSetsList()) { 566 * // doThingsWith(element); 567 * } 568 * String nextPageToken = response.getNextPageToken(); 569 * if (!Strings.isNullOrEmpty(nextPageToken)) { 570 * request = request.toBuilder().setPageToken(nextPageToken).build(); 571 * } else { 572 * break; 573 * } 574 * } 575 * } 576 * }</pre> 577 */ 578 public final UnaryCallable<ListProductSetsRequest, ListProductSetsResponse> listProductSetsCallable()579 listProductSetsCallable() { 580 return stub.listProductSetsCallable(); 581 } 582 583 // AUTO-GENERATED DOCUMENTATION AND METHOD. 584 /** 585 * Gets information associated with a ProductSet. 586 * 587 * <p>Possible errors: 588 * 589 * <ul> 590 * <li>Returns NOT_FOUND if the ProductSet does not exist. 591 * </ul> 592 * 593 * <p>Sample code: 594 * 595 * <pre>{@code 596 * // This snippet has been automatically generated and should be regarded as a code template only. 597 * // It will require modifications to work: 598 * // - It may require correct/in-range values for request initialization. 599 * // - It may require specifying regional endpoints when creating the service client as shown in 600 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 601 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 602 * ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); 603 * ProductSet response = productSearchClient.getProductSet(name); 604 * } 605 * }</pre> 606 * 607 * @param name Required. Resource name of the ProductSet to get. 608 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 609 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 610 */ getProductSet(ProductSetName name)611 public final ProductSet getProductSet(ProductSetName name) { 612 GetProductSetRequest request = 613 GetProductSetRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 614 return getProductSet(request); 615 } 616 617 // AUTO-GENERATED DOCUMENTATION AND METHOD. 618 /** 619 * Gets information associated with a ProductSet. 620 * 621 * <p>Possible errors: 622 * 623 * <ul> 624 * <li>Returns NOT_FOUND if the ProductSet does not exist. 625 * </ul> 626 * 627 * <p>Sample code: 628 * 629 * <pre>{@code 630 * // This snippet has been automatically generated and should be regarded as a code template only. 631 * // It will require modifications to work: 632 * // - It may require correct/in-range values for request initialization. 633 * // - It may require specifying regional endpoints when creating the service client as shown in 634 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 635 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 636 * String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); 637 * ProductSet response = productSearchClient.getProductSet(name); 638 * } 639 * }</pre> 640 * 641 * @param name Required. Resource name of the ProductSet to get. 642 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 643 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 644 */ getProductSet(String name)645 public final ProductSet getProductSet(String name) { 646 GetProductSetRequest request = GetProductSetRequest.newBuilder().setName(name).build(); 647 return getProductSet(request); 648 } 649 650 // AUTO-GENERATED DOCUMENTATION AND METHOD. 651 /** 652 * Gets information associated with a ProductSet. 653 * 654 * <p>Possible errors: 655 * 656 * <ul> 657 * <li>Returns NOT_FOUND if the ProductSet does not exist. 658 * </ul> 659 * 660 * <p>Sample code: 661 * 662 * <pre>{@code 663 * // This snippet has been automatically generated and should be regarded as a code template only. 664 * // It will require modifications to work: 665 * // - It may require correct/in-range values for request initialization. 666 * // - It may require specifying regional endpoints when creating the service client as shown in 667 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 668 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 669 * GetProductSetRequest request = 670 * GetProductSetRequest.newBuilder() 671 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 672 * .build(); 673 * ProductSet response = productSearchClient.getProductSet(request); 674 * } 675 * }</pre> 676 * 677 * @param request The request object containing all of the parameters for the API call. 678 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 679 */ getProductSet(GetProductSetRequest request)680 public final ProductSet getProductSet(GetProductSetRequest request) { 681 return getProductSetCallable().call(request); 682 } 683 684 // AUTO-GENERATED DOCUMENTATION AND METHOD. 685 /** 686 * Gets information associated with a ProductSet. 687 * 688 * <p>Possible errors: 689 * 690 * <ul> 691 * <li>Returns NOT_FOUND if the ProductSet does not exist. 692 * </ul> 693 * 694 * <p>Sample code: 695 * 696 * <pre>{@code 697 * // This snippet has been automatically generated and should be regarded as a code template only. 698 * // It will require modifications to work: 699 * // - It may require correct/in-range values for request initialization. 700 * // - It may require specifying regional endpoints when creating the service client as shown in 701 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 702 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 703 * GetProductSetRequest request = 704 * GetProductSetRequest.newBuilder() 705 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 706 * .build(); 707 * ApiFuture<ProductSet> future = 708 * productSearchClient.getProductSetCallable().futureCall(request); 709 * // Do something. 710 * ProductSet response = future.get(); 711 * } 712 * }</pre> 713 */ getProductSetCallable()714 public final UnaryCallable<GetProductSetRequest, ProductSet> getProductSetCallable() { 715 return stub.getProductSetCallable(); 716 } 717 718 // AUTO-GENERATED DOCUMENTATION AND METHOD. 719 /** 720 * Makes changes to a ProductSet resource. Only display_name can be updated currently. 721 * 722 * <p>Possible errors: 723 * 724 * <ul> 725 * <li>Returns NOT_FOUND if the ProductSet does not exist. 726 * <li>Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the 727 * request or longer than 4096 characters. 728 * </ul> 729 * 730 * <p>Sample code: 731 * 732 * <pre>{@code 733 * // This snippet has been automatically generated and should be regarded as a code template only. 734 * // It will require modifications to work: 735 * // - It may require correct/in-range values for request initialization. 736 * // - It may require specifying regional endpoints when creating the service client as shown in 737 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 738 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 739 * ProductSet productSet = ProductSet.newBuilder().build(); 740 * FieldMask updateMask = FieldMask.newBuilder().build(); 741 * ProductSet response = productSearchClient.updateProductSet(productSet, updateMask); 742 * } 743 * }</pre> 744 * 745 * @param productSet Required. The ProductSet resource which replaces the one on the server. 746 * @param updateMask The [FieldMask][google.protobuf.FieldMask] that specifies which fields to 747 * update. If update_mask isn't specified, all mutable fields are to be updated. Valid mask 748 * path is `display_name`. 749 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 750 */ updateProductSet(ProductSet productSet, FieldMask updateMask)751 public final ProductSet updateProductSet(ProductSet productSet, FieldMask updateMask) { 752 UpdateProductSetRequest request = 753 UpdateProductSetRequest.newBuilder() 754 .setProductSet(productSet) 755 .setUpdateMask(updateMask) 756 .build(); 757 return updateProductSet(request); 758 } 759 760 // AUTO-GENERATED DOCUMENTATION AND METHOD. 761 /** 762 * Makes changes to a ProductSet resource. Only display_name can be updated currently. 763 * 764 * <p>Possible errors: 765 * 766 * <ul> 767 * <li>Returns NOT_FOUND if the ProductSet does not exist. 768 * <li>Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the 769 * request or longer than 4096 characters. 770 * </ul> 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 (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 781 * UpdateProductSetRequest request = 782 * UpdateProductSetRequest.newBuilder() 783 * .setProductSet(ProductSet.newBuilder().build()) 784 * .setUpdateMask(FieldMask.newBuilder().build()) 785 * .build(); 786 * ProductSet response = productSearchClient.updateProductSet(request); 787 * } 788 * }</pre> 789 * 790 * @param request The request object containing all of the parameters for the API call. 791 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 792 */ updateProductSet(UpdateProductSetRequest request)793 public final ProductSet updateProductSet(UpdateProductSetRequest request) { 794 return updateProductSetCallable().call(request); 795 } 796 797 // AUTO-GENERATED DOCUMENTATION AND METHOD. 798 /** 799 * Makes changes to a ProductSet resource. Only display_name can be updated currently. 800 * 801 * <p>Possible errors: 802 * 803 * <ul> 804 * <li>Returns NOT_FOUND if the ProductSet does not exist. 805 * <li>Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the 806 * request or longer than 4096 characters. 807 * </ul> 808 * 809 * <p>Sample code: 810 * 811 * <pre>{@code 812 * // This snippet has been automatically generated and should be regarded as a code template only. 813 * // It will require modifications to work: 814 * // - It may require correct/in-range values for request initialization. 815 * // - It may require specifying regional endpoints when creating the service client as shown in 816 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 817 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 818 * UpdateProductSetRequest request = 819 * UpdateProductSetRequest.newBuilder() 820 * .setProductSet(ProductSet.newBuilder().build()) 821 * .setUpdateMask(FieldMask.newBuilder().build()) 822 * .build(); 823 * ApiFuture<ProductSet> future = 824 * productSearchClient.updateProductSetCallable().futureCall(request); 825 * // Do something. 826 * ProductSet response = future.get(); 827 * } 828 * }</pre> 829 */ updateProductSetCallable()830 public final UnaryCallable<UpdateProductSetRequest, ProductSet> updateProductSetCallable() { 831 return stub.updateProductSetCallable(); 832 } 833 834 // AUTO-GENERATED DOCUMENTATION AND METHOD. 835 /** 836 * Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be 837 * deleted. 838 * 839 * <p>The actual image files are not deleted from Google Cloud Storage. 840 * 841 * <p>Possible errors: 842 * 843 * <ul> 844 * <li>Returns NOT_FOUND if the ProductSet does not exist. 845 * </ul> 846 * 847 * <p>Sample code: 848 * 849 * <pre>{@code 850 * // This snippet has been automatically generated and should be regarded as a code template only. 851 * // It will require modifications to work: 852 * // - It may require correct/in-range values for request initialization. 853 * // - It may require specifying regional endpoints when creating the service client as shown in 854 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 855 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 856 * ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); 857 * productSearchClient.deleteProductSet(name); 858 * } 859 * }</pre> 860 * 861 * @param name Required. Resource name of the ProductSet to delete. 862 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 863 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 864 */ deleteProductSet(ProductSetName name)865 public final void deleteProductSet(ProductSetName name) { 866 DeleteProductSetRequest request = 867 DeleteProductSetRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 868 deleteProductSet(request); 869 } 870 871 // AUTO-GENERATED DOCUMENTATION AND METHOD. 872 /** 873 * Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be 874 * deleted. 875 * 876 * <p>The actual image files are not deleted from Google Cloud Storage. 877 * 878 * <p>Possible errors: 879 * 880 * <ul> 881 * <li>Returns NOT_FOUND if the ProductSet does not exist. 882 * </ul> 883 * 884 * <p>Sample code: 885 * 886 * <pre>{@code 887 * // This snippet has been automatically generated and should be regarded as a code template only. 888 * // It will require modifications to work: 889 * // - It may require correct/in-range values for request initialization. 890 * // - It may require specifying regional endpoints when creating the service client as shown in 891 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 892 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 893 * String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); 894 * productSearchClient.deleteProductSet(name); 895 * } 896 * }</pre> 897 * 898 * @param name Required. Resource name of the ProductSet to delete. 899 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 900 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 901 */ deleteProductSet(String name)902 public final void deleteProductSet(String name) { 903 DeleteProductSetRequest request = DeleteProductSetRequest.newBuilder().setName(name).build(); 904 deleteProductSet(request); 905 } 906 907 // AUTO-GENERATED DOCUMENTATION AND METHOD. 908 /** 909 * Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be 910 * deleted. 911 * 912 * <p>The actual image files are not deleted from Google Cloud Storage. 913 * 914 * <p>Possible errors: 915 * 916 * <ul> 917 * <li>Returns NOT_FOUND if the ProductSet does not exist. 918 * </ul> 919 * 920 * <p>Sample code: 921 * 922 * <pre>{@code 923 * // This snippet has been automatically generated and should be regarded as a code template only. 924 * // It will require modifications to work: 925 * // - It may require correct/in-range values for request initialization. 926 * // - It may require specifying regional endpoints when creating the service client as shown in 927 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 928 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 929 * DeleteProductSetRequest request = 930 * DeleteProductSetRequest.newBuilder() 931 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 932 * .build(); 933 * productSearchClient.deleteProductSet(request); 934 * } 935 * }</pre> 936 * 937 * @param request The request object containing all of the parameters for the API call. 938 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 939 */ deleteProductSet(DeleteProductSetRequest request)940 public final void deleteProductSet(DeleteProductSetRequest request) { 941 deleteProductSetCallable().call(request); 942 } 943 944 // AUTO-GENERATED DOCUMENTATION AND METHOD. 945 /** 946 * Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be 947 * deleted. 948 * 949 * <p>The actual image files are not deleted from Google Cloud Storage. 950 * 951 * <p>Possible errors: 952 * 953 * <ul> 954 * <li>Returns NOT_FOUND if the ProductSet does not exist. 955 * </ul> 956 * 957 * <p>Sample code: 958 * 959 * <pre>{@code 960 * // This snippet has been automatically generated and should be regarded as a code template only. 961 * // It will require modifications to work: 962 * // - It may require correct/in-range values for request initialization. 963 * // - It may require specifying regional endpoints when creating the service client as shown in 964 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 965 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 966 * DeleteProductSetRequest request = 967 * DeleteProductSetRequest.newBuilder() 968 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 969 * .build(); 970 * ApiFuture<Empty> future = productSearchClient.deleteProductSetCallable().futureCall(request); 971 * // Do something. 972 * future.get(); 973 * } 974 * }</pre> 975 */ deleteProductSetCallable()976 public final UnaryCallable<DeleteProductSetRequest, Empty> deleteProductSetCallable() { 977 return stub.deleteProductSetCallable(); 978 } 979 980 // AUTO-GENERATED DOCUMENTATION AND METHOD. 981 /** 982 * Creates and returns a new product resource. 983 * 984 * <p>Possible errors: 985 * 986 * <ul> 987 * <li>Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. 988 * <li>Returns INVALID_ARGUMENT if description is longer than 4096 characters. 989 * <li>Returns INVALID_ARGUMENT if product_category is missing or invalid. 990 * </ul> 991 * 992 * <p>Sample code: 993 * 994 * <pre>{@code 995 * // This snippet has been automatically generated and should be regarded as a code template only. 996 * // It will require modifications to work: 997 * // - It may require correct/in-range values for request initialization. 998 * // - It may require specifying regional endpoints when creating the service client as shown in 999 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1000 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1001 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 1002 * Product product = Product.newBuilder().build(); 1003 * String productId = "productId-1051830678"; 1004 * Product response = productSearchClient.createProduct(parent, product, productId); 1005 * } 1006 * }</pre> 1007 * 1008 * @param parent Required. The project in which the Product should be created. 1009 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID`. 1010 * @param product Required. The product to create. 1011 * @param productId A user-supplied resource id for this Product. If set, the server will attempt 1012 * to use this value as the resource id. If it is already in use, an error is returned with 1013 * code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character 1014 * `/`. 1015 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1016 */ createProduct(LocationName parent, Product product, String productId)1017 public final Product createProduct(LocationName parent, Product product, String productId) { 1018 CreateProductRequest request = 1019 CreateProductRequest.newBuilder() 1020 .setParent(parent == null ? null : parent.toString()) 1021 .setProduct(product) 1022 .setProductId(productId) 1023 .build(); 1024 return createProduct(request); 1025 } 1026 1027 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1028 /** 1029 * Creates and returns a new product resource. 1030 * 1031 * <p>Possible errors: 1032 * 1033 * <ul> 1034 * <li>Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. 1035 * <li>Returns INVALID_ARGUMENT if description is longer than 4096 characters. 1036 * <li>Returns INVALID_ARGUMENT if product_category is missing or invalid. 1037 * </ul> 1038 * 1039 * <p>Sample code: 1040 * 1041 * <pre>{@code 1042 * // This snippet has been automatically generated and should be regarded as a code template only. 1043 * // It will require modifications to work: 1044 * // - It may require correct/in-range values for request initialization. 1045 * // - It may require specifying regional endpoints when creating the service client as shown in 1046 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1047 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1048 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 1049 * Product product = Product.newBuilder().build(); 1050 * String productId = "productId-1051830678"; 1051 * Product response = productSearchClient.createProduct(parent, product, productId); 1052 * } 1053 * }</pre> 1054 * 1055 * @param parent Required. The project in which the Product should be created. 1056 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID`. 1057 * @param product Required. The product to create. 1058 * @param productId A user-supplied resource id for this Product. If set, the server will attempt 1059 * to use this value as the resource id. If it is already in use, an error is returned with 1060 * code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character 1061 * `/`. 1062 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1063 */ createProduct(String parent, Product product, String productId)1064 public final Product createProduct(String parent, Product product, String productId) { 1065 CreateProductRequest request = 1066 CreateProductRequest.newBuilder() 1067 .setParent(parent) 1068 .setProduct(product) 1069 .setProductId(productId) 1070 .build(); 1071 return createProduct(request); 1072 } 1073 1074 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1075 /** 1076 * Creates and returns a new product resource. 1077 * 1078 * <p>Possible errors: 1079 * 1080 * <ul> 1081 * <li>Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. 1082 * <li>Returns INVALID_ARGUMENT if description is longer than 4096 characters. 1083 * <li>Returns INVALID_ARGUMENT if product_category is missing or invalid. 1084 * </ul> 1085 * 1086 * <p>Sample code: 1087 * 1088 * <pre>{@code 1089 * // This snippet has been automatically generated and should be regarded as a code template only. 1090 * // It will require modifications to work: 1091 * // - It may require correct/in-range values for request initialization. 1092 * // - It may require specifying regional endpoints when creating the service client as shown in 1093 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1094 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1095 * CreateProductRequest request = 1096 * CreateProductRequest.newBuilder() 1097 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1098 * .setProduct(Product.newBuilder().build()) 1099 * .setProductId("productId-1051830678") 1100 * .build(); 1101 * Product response = productSearchClient.createProduct(request); 1102 * } 1103 * }</pre> 1104 * 1105 * @param request The request object containing all of the parameters for the API call. 1106 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1107 */ createProduct(CreateProductRequest request)1108 public final Product createProduct(CreateProductRequest request) { 1109 return createProductCallable().call(request); 1110 } 1111 1112 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1113 /** 1114 * Creates and returns a new product resource. 1115 * 1116 * <p>Possible errors: 1117 * 1118 * <ul> 1119 * <li>Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. 1120 * <li>Returns INVALID_ARGUMENT if description is longer than 4096 characters. 1121 * <li>Returns INVALID_ARGUMENT if product_category is missing or invalid. 1122 * </ul> 1123 * 1124 * <p>Sample code: 1125 * 1126 * <pre>{@code 1127 * // This snippet has been automatically generated and should be regarded as a code template only. 1128 * // It will require modifications to work: 1129 * // - It may require correct/in-range values for request initialization. 1130 * // - It may require specifying regional endpoints when creating the service client as shown in 1131 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1132 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1133 * CreateProductRequest request = 1134 * CreateProductRequest.newBuilder() 1135 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1136 * .setProduct(Product.newBuilder().build()) 1137 * .setProductId("productId-1051830678") 1138 * .build(); 1139 * ApiFuture<Product> future = productSearchClient.createProductCallable().futureCall(request); 1140 * // Do something. 1141 * Product response = future.get(); 1142 * } 1143 * }</pre> 1144 */ createProductCallable()1145 public final UnaryCallable<CreateProductRequest, Product> createProductCallable() { 1146 return stub.createProductCallable(); 1147 } 1148 1149 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1150 /** 1151 * Lists products in an unspecified order. 1152 * 1153 * <p>Possible errors: 1154 * 1155 * <ul> 1156 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 1157 * </ul> 1158 * 1159 * <p>Sample code: 1160 * 1161 * <pre>{@code 1162 * // This snippet has been automatically generated and should be regarded as a code template only. 1163 * // It will require modifications to work: 1164 * // - It may require correct/in-range values for request initialization. 1165 * // - It may require specifying regional endpoints when creating the service client as shown in 1166 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1167 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1168 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 1169 * for (Product element : productSearchClient.listProducts(parent).iterateAll()) { 1170 * // doThingsWith(element); 1171 * } 1172 * } 1173 * }</pre> 1174 * 1175 * @param parent Required. The project OR ProductSet from which Products should be listed. 1176 * <p>Format: `projects/PROJECT_ID/locations/LOC_ID` 1177 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1178 */ listProducts(LocationName parent)1179 public final ListProductsPagedResponse listProducts(LocationName parent) { 1180 ListProductsRequest request = 1181 ListProductsRequest.newBuilder() 1182 .setParent(parent == null ? null : parent.toString()) 1183 .build(); 1184 return listProducts(request); 1185 } 1186 1187 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1188 /** 1189 * Lists products in an unspecified order. 1190 * 1191 * <p>Possible errors: 1192 * 1193 * <ul> 1194 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 1195 * </ul> 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 (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1206 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 1207 * for (Product element : productSearchClient.listProducts(parent).iterateAll()) { 1208 * // doThingsWith(element); 1209 * } 1210 * } 1211 * }</pre> 1212 * 1213 * @param parent Required. The project OR ProductSet from which Products should be listed. 1214 * <p>Format: `projects/PROJECT_ID/locations/LOC_ID` 1215 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1216 */ listProducts(String parent)1217 public final ListProductsPagedResponse listProducts(String parent) { 1218 ListProductsRequest request = ListProductsRequest.newBuilder().setParent(parent).build(); 1219 return listProducts(request); 1220 } 1221 1222 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1223 /** 1224 * Lists products in an unspecified order. 1225 * 1226 * <p>Possible errors: 1227 * 1228 * <ul> 1229 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 1230 * </ul> 1231 * 1232 * <p>Sample code: 1233 * 1234 * <pre>{@code 1235 * // This snippet has been automatically generated and should be regarded as a code template only. 1236 * // It will require modifications to work: 1237 * // - It may require correct/in-range values for request initialization. 1238 * // - It may require specifying regional endpoints when creating the service client as shown in 1239 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1240 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1241 * ListProductsRequest request = 1242 * ListProductsRequest.newBuilder() 1243 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1244 * .setPageSize(883849137) 1245 * .setPageToken("pageToken873572522") 1246 * .build(); 1247 * for (Product element : productSearchClient.listProducts(request).iterateAll()) { 1248 * // doThingsWith(element); 1249 * } 1250 * } 1251 * }</pre> 1252 * 1253 * @param request The request object containing all of the parameters for the API call. 1254 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1255 */ listProducts(ListProductsRequest request)1256 public final ListProductsPagedResponse listProducts(ListProductsRequest request) { 1257 return listProductsPagedCallable().call(request); 1258 } 1259 1260 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1261 /** 1262 * Lists products in an unspecified order. 1263 * 1264 * <p>Possible errors: 1265 * 1266 * <ul> 1267 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 1268 * </ul> 1269 * 1270 * <p>Sample code: 1271 * 1272 * <pre>{@code 1273 * // This snippet has been automatically generated and should be regarded as a code template only. 1274 * // It will require modifications to work: 1275 * // - It may require correct/in-range values for request initialization. 1276 * // - It may require specifying regional endpoints when creating the service client as shown in 1277 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1278 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1279 * ListProductsRequest request = 1280 * ListProductsRequest.newBuilder() 1281 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1282 * .setPageSize(883849137) 1283 * .setPageToken("pageToken873572522") 1284 * .build(); 1285 * ApiFuture<Product> future = 1286 * productSearchClient.listProductsPagedCallable().futureCall(request); 1287 * // Do something. 1288 * for (Product element : future.get().iterateAll()) { 1289 * // doThingsWith(element); 1290 * } 1291 * } 1292 * }</pre> 1293 */ 1294 public final UnaryCallable<ListProductsRequest, ListProductsPagedResponse> listProductsPagedCallable()1295 listProductsPagedCallable() { 1296 return stub.listProductsPagedCallable(); 1297 } 1298 1299 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1300 /** 1301 * Lists products in an unspecified order. 1302 * 1303 * <p>Possible errors: 1304 * 1305 * <ul> 1306 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 1307 * </ul> 1308 * 1309 * <p>Sample code: 1310 * 1311 * <pre>{@code 1312 * // This snippet has been automatically generated and should be regarded as a code template only. 1313 * // It will require modifications to work: 1314 * // - It may require correct/in-range values for request initialization. 1315 * // - It may require specifying regional endpoints when creating the service client as shown in 1316 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1317 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1318 * ListProductsRequest request = 1319 * ListProductsRequest.newBuilder() 1320 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1321 * .setPageSize(883849137) 1322 * .setPageToken("pageToken873572522") 1323 * .build(); 1324 * while (true) { 1325 * ListProductsResponse response = productSearchClient.listProductsCallable().call(request); 1326 * for (Product element : response.getProductsList()) { 1327 * // doThingsWith(element); 1328 * } 1329 * String nextPageToken = response.getNextPageToken(); 1330 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1331 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1332 * } else { 1333 * break; 1334 * } 1335 * } 1336 * } 1337 * }</pre> 1338 */ listProductsCallable()1339 public final UnaryCallable<ListProductsRequest, ListProductsResponse> listProductsCallable() { 1340 return stub.listProductsCallable(); 1341 } 1342 1343 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1344 /** 1345 * Gets information associated with a Product. 1346 * 1347 * <p>Possible errors: 1348 * 1349 * <ul> 1350 * <li>Returns NOT_FOUND if the Product does not exist. 1351 * </ul> 1352 * 1353 * <p>Sample code: 1354 * 1355 * <pre>{@code 1356 * // This snippet has been automatically generated and should be regarded as a code template only. 1357 * // It will require modifications to work: 1358 * // - It may require correct/in-range values for request initialization. 1359 * // - It may require specifying regional endpoints when creating the service client as shown in 1360 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1361 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1362 * ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); 1363 * Product response = productSearchClient.getProduct(name); 1364 * } 1365 * }</pre> 1366 * 1367 * @param name Required. Resource name of the Product to get. 1368 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 1369 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1370 */ getProduct(ProductName name)1371 public final Product getProduct(ProductName name) { 1372 GetProductRequest request = 1373 GetProductRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 1374 return getProduct(request); 1375 } 1376 1377 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1378 /** 1379 * Gets information associated with a Product. 1380 * 1381 * <p>Possible errors: 1382 * 1383 * <ul> 1384 * <li>Returns NOT_FOUND if the Product does not exist. 1385 * </ul> 1386 * 1387 * <p>Sample code: 1388 * 1389 * <pre>{@code 1390 * // This snippet has been automatically generated and should be regarded as a code template only. 1391 * // It will require modifications to work: 1392 * // - It may require correct/in-range values for request initialization. 1393 * // - It may require specifying regional endpoints when creating the service client as shown in 1394 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1395 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1396 * String name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); 1397 * Product response = productSearchClient.getProduct(name); 1398 * } 1399 * }</pre> 1400 * 1401 * @param name Required. Resource name of the Product to get. 1402 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 1403 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1404 */ getProduct(String name)1405 public final Product getProduct(String name) { 1406 GetProductRequest request = GetProductRequest.newBuilder().setName(name).build(); 1407 return getProduct(request); 1408 } 1409 1410 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1411 /** 1412 * Gets information associated with a Product. 1413 * 1414 * <p>Possible errors: 1415 * 1416 * <ul> 1417 * <li>Returns NOT_FOUND if the Product does not exist. 1418 * </ul> 1419 * 1420 * <p>Sample code: 1421 * 1422 * <pre>{@code 1423 * // This snippet has been automatically generated and should be regarded as a code template only. 1424 * // It will require modifications to work: 1425 * // - It may require correct/in-range values for request initialization. 1426 * // - It may require specifying regional endpoints when creating the service client as shown in 1427 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1428 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1429 * GetProductRequest request = 1430 * GetProductRequest.newBuilder() 1431 * .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 1432 * .build(); 1433 * Product response = productSearchClient.getProduct(request); 1434 * } 1435 * }</pre> 1436 * 1437 * @param request The request object containing all of the parameters for the API call. 1438 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1439 */ getProduct(GetProductRequest request)1440 public final Product getProduct(GetProductRequest request) { 1441 return getProductCallable().call(request); 1442 } 1443 1444 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1445 /** 1446 * Gets information associated with a Product. 1447 * 1448 * <p>Possible errors: 1449 * 1450 * <ul> 1451 * <li>Returns NOT_FOUND if the Product does not exist. 1452 * </ul> 1453 * 1454 * <p>Sample code: 1455 * 1456 * <pre>{@code 1457 * // This snippet has been automatically generated and should be regarded as a code template only. 1458 * // It will require modifications to work: 1459 * // - It may require correct/in-range values for request initialization. 1460 * // - It may require specifying regional endpoints when creating the service client as shown in 1461 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1462 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1463 * GetProductRequest request = 1464 * GetProductRequest.newBuilder() 1465 * .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 1466 * .build(); 1467 * ApiFuture<Product> future = productSearchClient.getProductCallable().futureCall(request); 1468 * // Do something. 1469 * Product response = future.get(); 1470 * } 1471 * }</pre> 1472 */ getProductCallable()1473 public final UnaryCallable<GetProductRequest, Product> getProductCallable() { 1474 return stub.getProductCallable(); 1475 } 1476 1477 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1478 /** 1479 * Makes changes to a Product resource. Only display_name, description and labels can be updated 1480 * right now. 1481 * 1482 * <p>If labels are updated, the change will not be reflected in queries until the next index 1483 * time. 1484 * 1485 * <p>Possible errors: 1486 * 1487 * <ul> 1488 * <li>Returns NOT_FOUND if the Product does not exist. 1489 * <li>Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from 1490 * the request or longer than 4096 characters. 1491 * <li>Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 1492 * characters. 1493 * <li>Returns INVALID_ARGUMENT if product_category is present in update_mask. 1494 * </ul> 1495 * 1496 * <p>Sample code: 1497 * 1498 * <pre>{@code 1499 * // This snippet has been automatically generated and should be regarded as a code template only. 1500 * // It will require modifications to work: 1501 * // - It may require correct/in-range values for request initialization. 1502 * // - It may require specifying regional endpoints when creating the service client as shown in 1503 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1504 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1505 * Product product = Product.newBuilder().build(); 1506 * FieldMask updateMask = FieldMask.newBuilder().build(); 1507 * Product response = productSearchClient.updateProduct(product, updateMask); 1508 * } 1509 * }</pre> 1510 * 1511 * @param product Required. The Product resource which replaces the one on the server. 1512 * product.name is immutable. 1513 * @param updateMask The [FieldMask][google.protobuf.FieldMask] that specifies which fields to 1514 * update. If update_mask isn't specified, all mutable fields are to be updated. Valid mask 1515 * paths include `product_labels`, `display_name`, and `description`. 1516 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1517 */ updateProduct(Product product, FieldMask updateMask)1518 public final Product updateProduct(Product product, FieldMask updateMask) { 1519 UpdateProductRequest request = 1520 UpdateProductRequest.newBuilder().setProduct(product).setUpdateMask(updateMask).build(); 1521 return updateProduct(request); 1522 } 1523 1524 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1525 /** 1526 * Makes changes to a Product resource. Only display_name, description and labels can be updated 1527 * right now. 1528 * 1529 * <p>If labels are updated, the change will not be reflected in queries until the next index 1530 * time. 1531 * 1532 * <p>Possible errors: 1533 * 1534 * <ul> 1535 * <li>Returns NOT_FOUND if the Product does not exist. 1536 * <li>Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from 1537 * the request or longer than 4096 characters. 1538 * <li>Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 1539 * characters. 1540 * <li>Returns INVALID_ARGUMENT if product_category is present in update_mask. 1541 * </ul> 1542 * 1543 * <p>Sample code: 1544 * 1545 * <pre>{@code 1546 * // This snippet has been automatically generated and should be regarded as a code template only. 1547 * // It will require modifications to work: 1548 * // - It may require correct/in-range values for request initialization. 1549 * // - It may require specifying regional endpoints when creating the service client as shown in 1550 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1551 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1552 * UpdateProductRequest request = 1553 * UpdateProductRequest.newBuilder() 1554 * .setProduct(Product.newBuilder().build()) 1555 * .setUpdateMask(FieldMask.newBuilder().build()) 1556 * .build(); 1557 * Product response = productSearchClient.updateProduct(request); 1558 * } 1559 * }</pre> 1560 * 1561 * @param request The request object containing all of the parameters for the API call. 1562 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1563 */ updateProduct(UpdateProductRequest request)1564 public final Product updateProduct(UpdateProductRequest request) { 1565 return updateProductCallable().call(request); 1566 } 1567 1568 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1569 /** 1570 * Makes changes to a Product resource. Only display_name, description and labels can be updated 1571 * right now. 1572 * 1573 * <p>If labels are updated, the change will not be reflected in queries until the next index 1574 * time. 1575 * 1576 * <p>Possible errors: 1577 * 1578 * <ul> 1579 * <li>Returns NOT_FOUND if the Product does not exist. 1580 * <li>Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from 1581 * the request or longer than 4096 characters. 1582 * <li>Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 1583 * characters. 1584 * <li>Returns INVALID_ARGUMENT if product_category is present in update_mask. 1585 * </ul> 1586 * 1587 * <p>Sample code: 1588 * 1589 * <pre>{@code 1590 * // This snippet has been automatically generated and should be regarded as a code template only. 1591 * // It will require modifications to work: 1592 * // - It may require correct/in-range values for request initialization. 1593 * // - It may require specifying regional endpoints when creating the service client as shown in 1594 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1595 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1596 * UpdateProductRequest request = 1597 * UpdateProductRequest.newBuilder() 1598 * .setProduct(Product.newBuilder().build()) 1599 * .setUpdateMask(FieldMask.newBuilder().build()) 1600 * .build(); 1601 * ApiFuture<Product> future = productSearchClient.updateProductCallable().futureCall(request); 1602 * // Do something. 1603 * Product response = future.get(); 1604 * } 1605 * }</pre> 1606 */ updateProductCallable()1607 public final UnaryCallable<UpdateProductRequest, Product> updateProductCallable() { 1608 return stub.updateProductCallable(); 1609 } 1610 1611 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1612 /** 1613 * Permanently deletes a product and its reference images. 1614 * 1615 * <p>Metadata of the product and all its images will be deleted right away, but search queries 1616 * against ProductSets containing the product may still work until all related caches are 1617 * refreshed. 1618 * 1619 * <p>Possible errors: 1620 * 1621 * <ul> 1622 * <li>Returns NOT_FOUND if the product does not exist. 1623 * </ul> 1624 * 1625 * <p>Sample code: 1626 * 1627 * <pre>{@code 1628 * // This snippet has been automatically generated and should be regarded as a code template only. 1629 * // It will require modifications to work: 1630 * // - It may require correct/in-range values for request initialization. 1631 * // - It may require specifying regional endpoints when creating the service client as shown in 1632 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1633 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1634 * ProductName name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); 1635 * productSearchClient.deleteProduct(name); 1636 * } 1637 * }</pre> 1638 * 1639 * @param name Required. Resource name of product to delete. 1640 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 1641 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1642 */ deleteProduct(ProductName name)1643 public final void deleteProduct(ProductName name) { 1644 DeleteProductRequest request = 1645 DeleteProductRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 1646 deleteProduct(request); 1647 } 1648 1649 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1650 /** 1651 * Permanently deletes a product and its reference images. 1652 * 1653 * <p>Metadata of the product and all its images will be deleted right away, but search queries 1654 * against ProductSets containing the product may still work until all related caches are 1655 * refreshed. 1656 * 1657 * <p>Possible errors: 1658 * 1659 * <ul> 1660 * <li>Returns NOT_FOUND if the product does not exist. 1661 * </ul> 1662 * 1663 * <p>Sample code: 1664 * 1665 * <pre>{@code 1666 * // This snippet has been automatically generated and should be regarded as a code template only. 1667 * // It will require modifications to work: 1668 * // - It may require correct/in-range values for request initialization. 1669 * // - It may require specifying regional endpoints when creating the service client as shown in 1670 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1671 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1672 * String name = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); 1673 * productSearchClient.deleteProduct(name); 1674 * } 1675 * }</pre> 1676 * 1677 * @param name Required. Resource name of product to delete. 1678 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 1679 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1680 */ deleteProduct(String name)1681 public final void deleteProduct(String name) { 1682 DeleteProductRequest request = DeleteProductRequest.newBuilder().setName(name).build(); 1683 deleteProduct(request); 1684 } 1685 1686 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1687 /** 1688 * Permanently deletes a product and its reference images. 1689 * 1690 * <p>Metadata of the product and all its images will be deleted right away, but search queries 1691 * against ProductSets containing the product may still work until all related caches are 1692 * refreshed. 1693 * 1694 * <p>Possible errors: 1695 * 1696 * <ul> 1697 * <li>Returns NOT_FOUND if the product does not exist. 1698 * </ul> 1699 * 1700 * <p>Sample code: 1701 * 1702 * <pre>{@code 1703 * // This snippet has been automatically generated and should be regarded as a code template only. 1704 * // It will require modifications to work: 1705 * // - It may require correct/in-range values for request initialization. 1706 * // - It may require specifying regional endpoints when creating the service client as shown in 1707 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1708 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1709 * DeleteProductRequest request = 1710 * DeleteProductRequest.newBuilder() 1711 * .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 1712 * .build(); 1713 * productSearchClient.deleteProduct(request); 1714 * } 1715 * }</pre> 1716 * 1717 * @param request The request object containing all of the parameters for the API call. 1718 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1719 */ deleteProduct(DeleteProductRequest request)1720 public final void deleteProduct(DeleteProductRequest request) { 1721 deleteProductCallable().call(request); 1722 } 1723 1724 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1725 /** 1726 * Permanently deletes a product and its reference images. 1727 * 1728 * <p>Metadata of the product and all its images will be deleted right away, but search queries 1729 * against ProductSets containing the product may still work until all related caches are 1730 * refreshed. 1731 * 1732 * <p>Possible errors: 1733 * 1734 * <ul> 1735 * <li>Returns NOT_FOUND if the product does not exist. 1736 * </ul> 1737 * 1738 * <p>Sample code: 1739 * 1740 * <pre>{@code 1741 * // This snippet has been automatically generated and should be regarded as a code template only. 1742 * // It will require modifications to work: 1743 * // - It may require correct/in-range values for request initialization. 1744 * // - It may require specifying regional endpoints when creating the service client as shown in 1745 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1746 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1747 * DeleteProductRequest request = 1748 * DeleteProductRequest.newBuilder() 1749 * .setName(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 1750 * .build(); 1751 * ApiFuture<Empty> future = productSearchClient.deleteProductCallable().futureCall(request); 1752 * // Do something. 1753 * future.get(); 1754 * } 1755 * }</pre> 1756 */ deleteProductCallable()1757 public final UnaryCallable<DeleteProductRequest, Empty> deleteProductCallable() { 1758 return stub.deleteProductCallable(); 1759 } 1760 1761 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1762 /** 1763 * Creates and returns a new ReferenceImage resource. 1764 * 1765 * <p>The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will 1766 * try to detect regions of interest in the image that are compatible with the product_category on 1767 * the parent product. If it is specified, detection is ALWAYS skipped. The system converts 1768 * polygons into non-rotated rectangles. 1769 * 1770 * <p>Note that the pipeline will resize the image if the image resolution is too large to process 1771 * (above 50MP). 1772 * 1773 * <p>Possible errors: 1774 * 1775 * <ul> 1776 * <li>Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. 1777 * <li>Returns INVALID_ARGUMENT if the product does not exist. 1778 * <li>Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with 1779 * the parent product's product_category is detected. 1780 * <li>Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. 1781 * </ul> 1782 * 1783 * <p>Sample code: 1784 * 1785 * <pre>{@code 1786 * // This snippet has been automatically generated and should be regarded as a code template only. 1787 * // It will require modifications to work: 1788 * // - It may require correct/in-range values for request initialization. 1789 * // - It may require specifying regional endpoints when creating the service client as shown in 1790 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1791 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1792 * ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); 1793 * ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); 1794 * String referenceImageId = "referenceImageId1224107531"; 1795 * ReferenceImage response = 1796 * productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId); 1797 * } 1798 * }</pre> 1799 * 1800 * @param parent Required. Resource name of the product in which to create the reference image. 1801 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. 1802 * @param referenceImage Required. The reference image to create. If an image ID is specified, it 1803 * is ignored. 1804 * @param referenceImageId A user-supplied resource id for the ReferenceImage to be added. If set, 1805 * the server will attempt to use this value as the resource id. If it is already in use, an 1806 * error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot 1807 * contain the character `/`. 1808 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1809 */ createReferenceImage( ProductName parent, ReferenceImage referenceImage, String referenceImageId)1810 public final ReferenceImage createReferenceImage( 1811 ProductName parent, ReferenceImage referenceImage, String referenceImageId) { 1812 CreateReferenceImageRequest request = 1813 CreateReferenceImageRequest.newBuilder() 1814 .setParent(parent == null ? null : parent.toString()) 1815 .setReferenceImage(referenceImage) 1816 .setReferenceImageId(referenceImageId) 1817 .build(); 1818 return createReferenceImage(request); 1819 } 1820 1821 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1822 /** 1823 * Creates and returns a new ReferenceImage resource. 1824 * 1825 * <p>The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will 1826 * try to detect regions of interest in the image that are compatible with the product_category on 1827 * the parent product. If it is specified, detection is ALWAYS skipped. The system converts 1828 * polygons into non-rotated rectangles. 1829 * 1830 * <p>Note that the pipeline will resize the image if the image resolution is too large to process 1831 * (above 50MP). 1832 * 1833 * <p>Possible errors: 1834 * 1835 * <ul> 1836 * <li>Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. 1837 * <li>Returns INVALID_ARGUMENT if the product does not exist. 1838 * <li>Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with 1839 * the parent product's product_category is detected. 1840 * <li>Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. 1841 * </ul> 1842 * 1843 * <p>Sample code: 1844 * 1845 * <pre>{@code 1846 * // This snippet has been automatically generated and should be regarded as a code template only. 1847 * // It will require modifications to work: 1848 * // - It may require correct/in-range values for request initialization. 1849 * // - It may require specifying regional endpoints when creating the service client as shown in 1850 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1851 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1852 * String parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); 1853 * ReferenceImage referenceImage = ReferenceImage.newBuilder().build(); 1854 * String referenceImageId = "referenceImageId1224107531"; 1855 * ReferenceImage response = 1856 * productSearchClient.createReferenceImage(parent, referenceImage, referenceImageId); 1857 * } 1858 * }</pre> 1859 * 1860 * @param parent Required. Resource name of the product in which to create the reference image. 1861 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. 1862 * @param referenceImage Required. The reference image to create. If an image ID is specified, it 1863 * is ignored. 1864 * @param referenceImageId A user-supplied resource id for the ReferenceImage to be added. If set, 1865 * the server will attempt to use this value as the resource id. If it is already in use, an 1866 * error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot 1867 * contain the character `/`. 1868 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1869 */ createReferenceImage( String parent, ReferenceImage referenceImage, String referenceImageId)1870 public final ReferenceImage createReferenceImage( 1871 String parent, ReferenceImage referenceImage, String referenceImageId) { 1872 CreateReferenceImageRequest request = 1873 CreateReferenceImageRequest.newBuilder() 1874 .setParent(parent) 1875 .setReferenceImage(referenceImage) 1876 .setReferenceImageId(referenceImageId) 1877 .build(); 1878 return createReferenceImage(request); 1879 } 1880 1881 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1882 /** 1883 * Creates and returns a new ReferenceImage resource. 1884 * 1885 * <p>The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will 1886 * try to detect regions of interest in the image that are compatible with the product_category on 1887 * the parent product. If it is specified, detection is ALWAYS skipped. The system converts 1888 * polygons into non-rotated rectangles. 1889 * 1890 * <p>Note that the pipeline will resize the image if the image resolution is too large to process 1891 * (above 50MP). 1892 * 1893 * <p>Possible errors: 1894 * 1895 * <ul> 1896 * <li>Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. 1897 * <li>Returns INVALID_ARGUMENT if the product does not exist. 1898 * <li>Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with 1899 * the parent product's product_category is detected. 1900 * <li>Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. 1901 * </ul> 1902 * 1903 * <p>Sample code: 1904 * 1905 * <pre>{@code 1906 * // This snippet has been automatically generated and should be regarded as a code template only. 1907 * // It will require modifications to work: 1908 * // - It may require correct/in-range values for request initialization. 1909 * // - It may require specifying regional endpoints when creating the service client as shown in 1910 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1911 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1912 * CreateReferenceImageRequest request = 1913 * CreateReferenceImageRequest.newBuilder() 1914 * .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 1915 * .setReferenceImage(ReferenceImage.newBuilder().build()) 1916 * .setReferenceImageId("referenceImageId1224107531") 1917 * .build(); 1918 * ReferenceImage response = productSearchClient.createReferenceImage(request); 1919 * } 1920 * }</pre> 1921 * 1922 * @param request The request object containing all of the parameters for the API call. 1923 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1924 */ createReferenceImage(CreateReferenceImageRequest request)1925 public final ReferenceImage createReferenceImage(CreateReferenceImageRequest request) { 1926 return createReferenceImageCallable().call(request); 1927 } 1928 1929 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1930 /** 1931 * Creates and returns a new ReferenceImage resource. 1932 * 1933 * <p>The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will 1934 * try to detect regions of interest in the image that are compatible with the product_category on 1935 * the parent product. If it is specified, detection is ALWAYS skipped. The system converts 1936 * polygons into non-rotated rectangles. 1937 * 1938 * <p>Note that the pipeline will resize the image if the image resolution is too large to process 1939 * (above 50MP). 1940 * 1941 * <p>Possible errors: 1942 * 1943 * <ul> 1944 * <li>Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. 1945 * <li>Returns INVALID_ARGUMENT if the product does not exist. 1946 * <li>Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with 1947 * the parent product's product_category is detected. 1948 * <li>Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. 1949 * </ul> 1950 * 1951 * <p>Sample code: 1952 * 1953 * <pre>{@code 1954 * // This snippet has been automatically generated and should be regarded as a code template only. 1955 * // It will require modifications to work: 1956 * // - It may require correct/in-range values for request initialization. 1957 * // - It may require specifying regional endpoints when creating the service client as shown in 1958 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1959 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 1960 * CreateReferenceImageRequest request = 1961 * CreateReferenceImageRequest.newBuilder() 1962 * .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 1963 * .setReferenceImage(ReferenceImage.newBuilder().build()) 1964 * .setReferenceImageId("referenceImageId1224107531") 1965 * .build(); 1966 * ApiFuture<ReferenceImage> future = 1967 * productSearchClient.createReferenceImageCallable().futureCall(request); 1968 * // Do something. 1969 * ReferenceImage response = future.get(); 1970 * } 1971 * }</pre> 1972 */ 1973 public final UnaryCallable<CreateReferenceImageRequest, ReferenceImage> createReferenceImageCallable()1974 createReferenceImageCallable() { 1975 return stub.createReferenceImageCallable(); 1976 } 1977 1978 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1979 /** 1980 * Permanently deletes a reference image. 1981 * 1982 * <p>The image metadata will be deleted right away, but search queries against ProductSets 1983 * containing the image may still work until all related caches are refreshed. 1984 * 1985 * <p>The actual image files are not deleted from Google Cloud Storage. 1986 * 1987 * <p>Possible errors: 1988 * 1989 * <ul> 1990 * <li>Returns NOT_FOUND if the reference image does not exist. 1991 * </ul> 1992 * 1993 * <p>Sample code: 1994 * 1995 * <pre>{@code 1996 * // This snippet has been automatically generated and should be regarded as a code template only. 1997 * // It will require modifications to work: 1998 * // - It may require correct/in-range values for request initialization. 1999 * // - It may require specifying regional endpoints when creating the service client as shown in 2000 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2001 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2002 * ReferenceImageName name = 2003 * ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); 2004 * productSearchClient.deleteReferenceImage(name); 2005 * } 2006 * }</pre> 2007 * 2008 * @param name Required. The resource name of the reference image to delete. 2009 * <p>Format is: 2010 * <p>`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` 2011 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2012 */ deleteReferenceImage(ReferenceImageName name)2013 public final void deleteReferenceImage(ReferenceImageName name) { 2014 DeleteReferenceImageRequest request = 2015 DeleteReferenceImageRequest.newBuilder() 2016 .setName(name == null ? null : name.toString()) 2017 .build(); 2018 deleteReferenceImage(request); 2019 } 2020 2021 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2022 /** 2023 * Permanently deletes a reference image. 2024 * 2025 * <p>The image metadata will be deleted right away, but search queries against ProductSets 2026 * containing the image may still work until all related caches are refreshed. 2027 * 2028 * <p>The actual image files are not deleted from Google Cloud Storage. 2029 * 2030 * <p>Possible errors: 2031 * 2032 * <ul> 2033 * <li>Returns NOT_FOUND if the reference image does not exist. 2034 * </ul> 2035 * 2036 * <p>Sample code: 2037 * 2038 * <pre>{@code 2039 * // This snippet has been automatically generated and should be regarded as a code template only. 2040 * // It will require modifications to work: 2041 * // - It may require correct/in-range values for request initialization. 2042 * // - It may require specifying regional endpoints when creating the service client as shown in 2043 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2044 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2045 * String name = 2046 * ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") 2047 * .toString(); 2048 * productSearchClient.deleteReferenceImage(name); 2049 * } 2050 * }</pre> 2051 * 2052 * @param name Required. The resource name of the reference image to delete. 2053 * <p>Format is: 2054 * <p>`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` 2055 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2056 */ deleteReferenceImage(String name)2057 public final void deleteReferenceImage(String name) { 2058 DeleteReferenceImageRequest request = 2059 DeleteReferenceImageRequest.newBuilder().setName(name).build(); 2060 deleteReferenceImage(request); 2061 } 2062 2063 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2064 /** 2065 * Permanently deletes a reference image. 2066 * 2067 * <p>The image metadata will be deleted right away, but search queries against ProductSets 2068 * containing the image may still work until all related caches are refreshed. 2069 * 2070 * <p>The actual image files are not deleted from Google Cloud Storage. 2071 * 2072 * <p>Possible errors: 2073 * 2074 * <ul> 2075 * <li>Returns NOT_FOUND if the reference image does not exist. 2076 * </ul> 2077 * 2078 * <p>Sample code: 2079 * 2080 * <pre>{@code 2081 * // This snippet has been automatically generated and should be regarded as a code template only. 2082 * // It will require modifications to work: 2083 * // - It may require correct/in-range values for request initialization. 2084 * // - It may require specifying regional endpoints when creating the service client as shown in 2085 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2086 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2087 * DeleteReferenceImageRequest request = 2088 * DeleteReferenceImageRequest.newBuilder() 2089 * .setName( 2090 * ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") 2091 * .toString()) 2092 * .build(); 2093 * productSearchClient.deleteReferenceImage(request); 2094 * } 2095 * }</pre> 2096 * 2097 * @param request The request object containing all of the parameters for the API call. 2098 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2099 */ deleteReferenceImage(DeleteReferenceImageRequest request)2100 public final void deleteReferenceImage(DeleteReferenceImageRequest request) { 2101 deleteReferenceImageCallable().call(request); 2102 } 2103 2104 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2105 /** 2106 * Permanently deletes a reference image. 2107 * 2108 * <p>The image metadata will be deleted right away, but search queries against ProductSets 2109 * containing the image may still work until all related caches are refreshed. 2110 * 2111 * <p>The actual image files are not deleted from Google Cloud Storage. 2112 * 2113 * <p>Possible errors: 2114 * 2115 * <ul> 2116 * <li>Returns NOT_FOUND if the reference image does not exist. 2117 * </ul> 2118 * 2119 * <p>Sample code: 2120 * 2121 * <pre>{@code 2122 * // This snippet has been automatically generated and should be regarded as a code template only. 2123 * // It will require modifications to work: 2124 * // - It may require correct/in-range values for request initialization. 2125 * // - It may require specifying regional endpoints when creating the service client as shown in 2126 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2127 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2128 * DeleteReferenceImageRequest request = 2129 * DeleteReferenceImageRequest.newBuilder() 2130 * .setName( 2131 * ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") 2132 * .toString()) 2133 * .build(); 2134 * ApiFuture<Empty> future = 2135 * productSearchClient.deleteReferenceImageCallable().futureCall(request); 2136 * // Do something. 2137 * future.get(); 2138 * } 2139 * }</pre> 2140 */ deleteReferenceImageCallable()2141 public final UnaryCallable<DeleteReferenceImageRequest, Empty> deleteReferenceImageCallable() { 2142 return stub.deleteReferenceImageCallable(); 2143 } 2144 2145 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2146 /** 2147 * Lists reference images. 2148 * 2149 * <p>Possible errors: 2150 * 2151 * <ul> 2152 * <li>Returns NOT_FOUND if the parent product does not exist. 2153 * <li>Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1. 2154 * </ul> 2155 * 2156 * <p>Sample code: 2157 * 2158 * <pre>{@code 2159 * // This snippet has been automatically generated and should be regarded as a code template only. 2160 * // It will require modifications to work: 2161 * // - It may require correct/in-range values for request initialization. 2162 * // - It may require specifying regional endpoints when creating the service client as shown in 2163 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2164 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2165 * ProductName parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); 2166 * for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) { 2167 * // doThingsWith(element); 2168 * } 2169 * } 2170 * }</pre> 2171 * 2172 * @param parent Required. Resource name of the product containing the reference images. 2173 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. 2174 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2175 */ listReferenceImages(ProductName parent)2176 public final ListReferenceImagesPagedResponse listReferenceImages(ProductName parent) { 2177 ListReferenceImagesRequest request = 2178 ListReferenceImagesRequest.newBuilder() 2179 .setParent(parent == null ? null : parent.toString()) 2180 .build(); 2181 return listReferenceImages(request); 2182 } 2183 2184 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2185 /** 2186 * Lists reference images. 2187 * 2188 * <p>Possible errors: 2189 * 2190 * <ul> 2191 * <li>Returns NOT_FOUND if the parent product does not exist. 2192 * <li>Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1. 2193 * </ul> 2194 * 2195 * <p>Sample code: 2196 * 2197 * <pre>{@code 2198 * // This snippet has been automatically generated and should be regarded as a code template only. 2199 * // It will require modifications to work: 2200 * // - It may require correct/in-range values for request initialization. 2201 * // - It may require specifying regional endpoints when creating the service client as shown in 2202 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2203 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2204 * String parent = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); 2205 * for (ReferenceImage element : productSearchClient.listReferenceImages(parent).iterateAll()) { 2206 * // doThingsWith(element); 2207 * } 2208 * } 2209 * }</pre> 2210 * 2211 * @param parent Required. Resource name of the product containing the reference images. 2212 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. 2213 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2214 */ listReferenceImages(String parent)2215 public final ListReferenceImagesPagedResponse listReferenceImages(String parent) { 2216 ListReferenceImagesRequest request = 2217 ListReferenceImagesRequest.newBuilder().setParent(parent).build(); 2218 return listReferenceImages(request); 2219 } 2220 2221 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2222 /** 2223 * Lists reference images. 2224 * 2225 * <p>Possible errors: 2226 * 2227 * <ul> 2228 * <li>Returns NOT_FOUND if the parent product does not exist. 2229 * <li>Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1. 2230 * </ul> 2231 * 2232 * <p>Sample code: 2233 * 2234 * <pre>{@code 2235 * // This snippet has been automatically generated and should be regarded as a code template only. 2236 * // It will require modifications to work: 2237 * // - It may require correct/in-range values for request initialization. 2238 * // - It may require specifying regional endpoints when creating the service client as shown in 2239 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2240 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2241 * ListReferenceImagesRequest request = 2242 * ListReferenceImagesRequest.newBuilder() 2243 * .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 2244 * .setPageSize(883849137) 2245 * .setPageToken("pageToken873572522") 2246 * .build(); 2247 * for (ReferenceImage element : productSearchClient.listReferenceImages(request).iterateAll()) { 2248 * // doThingsWith(element); 2249 * } 2250 * } 2251 * }</pre> 2252 * 2253 * @param request The request object containing all of the parameters for the API call. 2254 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2255 */ listReferenceImages( ListReferenceImagesRequest request)2256 public final ListReferenceImagesPagedResponse listReferenceImages( 2257 ListReferenceImagesRequest request) { 2258 return listReferenceImagesPagedCallable().call(request); 2259 } 2260 2261 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2262 /** 2263 * Lists reference images. 2264 * 2265 * <p>Possible errors: 2266 * 2267 * <ul> 2268 * <li>Returns NOT_FOUND if the parent product does not exist. 2269 * <li>Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1. 2270 * </ul> 2271 * 2272 * <p>Sample code: 2273 * 2274 * <pre>{@code 2275 * // This snippet has been automatically generated and should be regarded as a code template only. 2276 * // It will require modifications to work: 2277 * // - It may require correct/in-range values for request initialization. 2278 * // - It may require specifying regional endpoints when creating the service client as shown in 2279 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2280 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2281 * ListReferenceImagesRequest request = 2282 * ListReferenceImagesRequest.newBuilder() 2283 * .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 2284 * .setPageSize(883849137) 2285 * .setPageToken("pageToken873572522") 2286 * .build(); 2287 * ApiFuture<ReferenceImage> future = 2288 * productSearchClient.listReferenceImagesPagedCallable().futureCall(request); 2289 * // Do something. 2290 * for (ReferenceImage element : future.get().iterateAll()) { 2291 * // doThingsWith(element); 2292 * } 2293 * } 2294 * }</pre> 2295 */ 2296 public final UnaryCallable<ListReferenceImagesRequest, ListReferenceImagesPagedResponse> listReferenceImagesPagedCallable()2297 listReferenceImagesPagedCallable() { 2298 return stub.listReferenceImagesPagedCallable(); 2299 } 2300 2301 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2302 /** 2303 * Lists reference images. 2304 * 2305 * <p>Possible errors: 2306 * 2307 * <ul> 2308 * <li>Returns NOT_FOUND if the parent product does not exist. 2309 * <li>Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1. 2310 * </ul> 2311 * 2312 * <p>Sample code: 2313 * 2314 * <pre>{@code 2315 * // This snippet has been automatically generated and should be regarded as a code template only. 2316 * // It will require modifications to work: 2317 * // - It may require correct/in-range values for request initialization. 2318 * // - It may require specifying regional endpoints when creating the service client as shown in 2319 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2320 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2321 * ListReferenceImagesRequest request = 2322 * ListReferenceImagesRequest.newBuilder() 2323 * .setParent(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 2324 * .setPageSize(883849137) 2325 * .setPageToken("pageToken873572522") 2326 * .build(); 2327 * while (true) { 2328 * ListReferenceImagesResponse response = 2329 * productSearchClient.listReferenceImagesCallable().call(request); 2330 * for (ReferenceImage element : response.getReferenceImagesList()) { 2331 * // doThingsWith(element); 2332 * } 2333 * String nextPageToken = response.getNextPageToken(); 2334 * if (!Strings.isNullOrEmpty(nextPageToken)) { 2335 * request = request.toBuilder().setPageToken(nextPageToken).build(); 2336 * } else { 2337 * break; 2338 * } 2339 * } 2340 * } 2341 * }</pre> 2342 */ 2343 public final UnaryCallable<ListReferenceImagesRequest, ListReferenceImagesResponse> listReferenceImagesCallable()2344 listReferenceImagesCallable() { 2345 return stub.listReferenceImagesCallable(); 2346 } 2347 2348 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2349 /** 2350 * Gets information associated with a ReferenceImage. 2351 * 2352 * <p>Possible errors: 2353 * 2354 * <ul> 2355 * <li>Returns NOT_FOUND if the specified image does not exist. 2356 * </ul> 2357 * 2358 * <p>Sample code: 2359 * 2360 * <pre>{@code 2361 * // This snippet has been automatically generated and should be regarded as a code template only. 2362 * // It will require modifications to work: 2363 * // - It may require correct/in-range values for request initialization. 2364 * // - It may require specifying regional endpoints when creating the service client as shown in 2365 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2366 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2367 * ReferenceImageName name = 2368 * ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]"); 2369 * ReferenceImage response = productSearchClient.getReferenceImage(name); 2370 * } 2371 * }</pre> 2372 * 2373 * @param name Required. The resource name of the ReferenceImage to get. 2374 * <p>Format is: 2375 * <p>`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. 2376 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2377 */ getReferenceImage(ReferenceImageName name)2378 public final ReferenceImage getReferenceImage(ReferenceImageName name) { 2379 GetReferenceImageRequest request = 2380 GetReferenceImageRequest.newBuilder() 2381 .setName(name == null ? null : name.toString()) 2382 .build(); 2383 return getReferenceImage(request); 2384 } 2385 2386 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2387 /** 2388 * Gets information associated with a ReferenceImage. 2389 * 2390 * <p>Possible errors: 2391 * 2392 * <ul> 2393 * <li>Returns NOT_FOUND if the specified image does not exist. 2394 * </ul> 2395 * 2396 * <p>Sample code: 2397 * 2398 * <pre>{@code 2399 * // This snippet has been automatically generated and should be regarded as a code template only. 2400 * // It will require modifications to work: 2401 * // - It may require correct/in-range values for request initialization. 2402 * // - It may require specifying regional endpoints when creating the service client as shown in 2403 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2404 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2405 * String name = 2406 * ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") 2407 * .toString(); 2408 * ReferenceImage response = productSearchClient.getReferenceImage(name); 2409 * } 2410 * }</pre> 2411 * 2412 * @param name Required. The resource name of the ReferenceImage to get. 2413 * <p>Format is: 2414 * <p>`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. 2415 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2416 */ getReferenceImage(String name)2417 public final ReferenceImage getReferenceImage(String name) { 2418 GetReferenceImageRequest request = GetReferenceImageRequest.newBuilder().setName(name).build(); 2419 return getReferenceImage(request); 2420 } 2421 2422 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2423 /** 2424 * Gets information associated with a ReferenceImage. 2425 * 2426 * <p>Possible errors: 2427 * 2428 * <ul> 2429 * <li>Returns NOT_FOUND if the specified image does not exist. 2430 * </ul> 2431 * 2432 * <p>Sample code: 2433 * 2434 * <pre>{@code 2435 * // This snippet has been automatically generated and should be regarded as a code template only. 2436 * // It will require modifications to work: 2437 * // - It may require correct/in-range values for request initialization. 2438 * // - It may require specifying regional endpoints when creating the service client as shown in 2439 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2440 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2441 * GetReferenceImageRequest request = 2442 * GetReferenceImageRequest.newBuilder() 2443 * .setName( 2444 * ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") 2445 * .toString()) 2446 * .build(); 2447 * ReferenceImage response = productSearchClient.getReferenceImage(request); 2448 * } 2449 * }</pre> 2450 * 2451 * @param request The request object containing all of the parameters for the API call. 2452 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2453 */ getReferenceImage(GetReferenceImageRequest request)2454 public final ReferenceImage getReferenceImage(GetReferenceImageRequest request) { 2455 return getReferenceImageCallable().call(request); 2456 } 2457 2458 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2459 /** 2460 * Gets information associated with a ReferenceImage. 2461 * 2462 * <p>Possible errors: 2463 * 2464 * <ul> 2465 * <li>Returns NOT_FOUND if the specified image does not exist. 2466 * </ul> 2467 * 2468 * <p>Sample code: 2469 * 2470 * <pre>{@code 2471 * // This snippet has been automatically generated and should be regarded as a code template only. 2472 * // It will require modifications to work: 2473 * // - It may require correct/in-range values for request initialization. 2474 * // - It may require specifying regional endpoints when creating the service client as shown in 2475 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2476 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2477 * GetReferenceImageRequest request = 2478 * GetReferenceImageRequest.newBuilder() 2479 * .setName( 2480 * ReferenceImageName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]", "[REFERENCE_IMAGE]") 2481 * .toString()) 2482 * .build(); 2483 * ApiFuture<ReferenceImage> future = 2484 * productSearchClient.getReferenceImageCallable().futureCall(request); 2485 * // Do something. 2486 * ReferenceImage response = future.get(); 2487 * } 2488 * }</pre> 2489 */ getReferenceImageCallable()2490 public final UnaryCallable<GetReferenceImageRequest, ReferenceImage> getReferenceImageCallable() { 2491 return stub.getReferenceImageCallable(); 2492 } 2493 2494 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2495 /** 2496 * Adds a Product to the specified ProductSet. If the Product is already present, no change is 2497 * made. 2498 * 2499 * <p>One Product can be added to at most 100 ProductSets. 2500 * 2501 * <p>Possible errors: 2502 * 2503 * <ul> 2504 * <li>Returns NOT_FOUND if the Product or the ProductSet doesn't exist. 2505 * </ul> 2506 * 2507 * <p>Sample code: 2508 * 2509 * <pre>{@code 2510 * // This snippet has been automatically generated and should be regarded as a code template only. 2511 * // It will require modifications to work: 2512 * // - It may require correct/in-range values for request initialization. 2513 * // - It may require specifying regional endpoints when creating the service client as shown in 2514 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2515 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2516 * ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); 2517 * ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); 2518 * productSearchClient.addProductToProductSet(name, product); 2519 * } 2520 * }</pre> 2521 * 2522 * @param name Required. The resource name for the ProductSet to modify. 2523 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2524 * @param product Required. The resource name for the Product to be added to this ProductSet. 2525 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 2526 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2527 */ addProductToProductSet(ProductSetName name, ProductName product)2528 public final void addProductToProductSet(ProductSetName name, ProductName product) { 2529 AddProductToProductSetRequest request = 2530 AddProductToProductSetRequest.newBuilder() 2531 .setName(name == null ? null : name.toString()) 2532 .setProduct(product == null ? null : product.toString()) 2533 .build(); 2534 addProductToProductSet(request); 2535 } 2536 2537 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2538 /** 2539 * Adds a Product to the specified ProductSet. If the Product is already present, no change is 2540 * made. 2541 * 2542 * <p>One Product can be added to at most 100 ProductSets. 2543 * 2544 * <p>Possible errors: 2545 * 2546 * <ul> 2547 * <li>Returns NOT_FOUND if the Product or the ProductSet doesn't exist. 2548 * </ul> 2549 * 2550 * <p>Sample code: 2551 * 2552 * <pre>{@code 2553 * // This snippet has been automatically generated and should be regarded as a code template only. 2554 * // It will require modifications to work: 2555 * // - It may require correct/in-range values for request initialization. 2556 * // - It may require specifying regional endpoints when creating the service client as shown in 2557 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2558 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2559 * ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); 2560 * String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); 2561 * productSearchClient.addProductToProductSet(name, product); 2562 * } 2563 * }</pre> 2564 * 2565 * @param name Required. The resource name for the ProductSet to modify. 2566 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2567 * @param product Required. The resource name for the Product to be added to this ProductSet. 2568 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 2569 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2570 */ addProductToProductSet(ProductSetName name, String product)2571 public final void addProductToProductSet(ProductSetName name, String product) { 2572 AddProductToProductSetRequest request = 2573 AddProductToProductSetRequest.newBuilder() 2574 .setName(name == null ? null : name.toString()) 2575 .setProduct(product) 2576 .build(); 2577 addProductToProductSet(request); 2578 } 2579 2580 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2581 /** 2582 * Adds a Product to the specified ProductSet. If the Product is already present, no change is 2583 * made. 2584 * 2585 * <p>One Product can be added to at most 100 ProductSets. 2586 * 2587 * <p>Possible errors: 2588 * 2589 * <ul> 2590 * <li>Returns NOT_FOUND if the Product or the ProductSet doesn't exist. 2591 * </ul> 2592 * 2593 * <p>Sample code: 2594 * 2595 * <pre>{@code 2596 * // This snippet has been automatically generated and should be regarded as a code template only. 2597 * // It will require modifications to work: 2598 * // - It may require correct/in-range values for request initialization. 2599 * // - It may require specifying regional endpoints when creating the service client as shown in 2600 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2601 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2602 * String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); 2603 * ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); 2604 * productSearchClient.addProductToProductSet(name, product); 2605 * } 2606 * }</pre> 2607 * 2608 * @param name Required. The resource name for the ProductSet to modify. 2609 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2610 * @param product Required. The resource name for the Product to be added to this ProductSet. 2611 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 2612 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2613 */ addProductToProductSet(String name, ProductName product)2614 public final void addProductToProductSet(String name, ProductName product) { 2615 AddProductToProductSetRequest request = 2616 AddProductToProductSetRequest.newBuilder() 2617 .setName(name) 2618 .setProduct(product == null ? null : product.toString()) 2619 .build(); 2620 addProductToProductSet(request); 2621 } 2622 2623 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2624 /** 2625 * Adds a Product to the specified ProductSet. If the Product is already present, no change is 2626 * made. 2627 * 2628 * <p>One Product can be added to at most 100 ProductSets. 2629 * 2630 * <p>Possible errors: 2631 * 2632 * <ul> 2633 * <li>Returns NOT_FOUND if the Product or the ProductSet doesn't exist. 2634 * </ul> 2635 * 2636 * <p>Sample code: 2637 * 2638 * <pre>{@code 2639 * // This snippet has been automatically generated and should be regarded as a code template only. 2640 * // It will require modifications to work: 2641 * // - It may require correct/in-range values for request initialization. 2642 * // - It may require specifying regional endpoints when creating the service client as shown in 2643 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2644 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2645 * String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); 2646 * String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); 2647 * productSearchClient.addProductToProductSet(name, product); 2648 * } 2649 * }</pre> 2650 * 2651 * @param name Required. The resource name for the ProductSet to modify. 2652 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2653 * @param product Required. The resource name for the Product to be added to this ProductSet. 2654 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 2655 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2656 */ addProductToProductSet(String name, String product)2657 public final void addProductToProductSet(String name, String product) { 2658 AddProductToProductSetRequest request = 2659 AddProductToProductSetRequest.newBuilder().setName(name).setProduct(product).build(); 2660 addProductToProductSet(request); 2661 } 2662 2663 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2664 /** 2665 * Adds a Product to the specified ProductSet. If the Product is already present, no change is 2666 * made. 2667 * 2668 * <p>One Product can be added to at most 100 ProductSets. 2669 * 2670 * <p>Possible errors: 2671 * 2672 * <ul> 2673 * <li>Returns NOT_FOUND if the Product or the ProductSet doesn't exist. 2674 * </ul> 2675 * 2676 * <p>Sample code: 2677 * 2678 * <pre>{@code 2679 * // This snippet has been automatically generated and should be regarded as a code template only. 2680 * // It will require modifications to work: 2681 * // - It may require correct/in-range values for request initialization. 2682 * // - It may require specifying regional endpoints when creating the service client as shown in 2683 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2684 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2685 * AddProductToProductSetRequest request = 2686 * AddProductToProductSetRequest.newBuilder() 2687 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 2688 * .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 2689 * .build(); 2690 * productSearchClient.addProductToProductSet(request); 2691 * } 2692 * }</pre> 2693 * 2694 * @param request The request object containing all of the parameters for the API call. 2695 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2696 */ addProductToProductSet(AddProductToProductSetRequest request)2697 public final void addProductToProductSet(AddProductToProductSetRequest request) { 2698 addProductToProductSetCallable().call(request); 2699 } 2700 2701 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2702 /** 2703 * Adds a Product to the specified ProductSet. If the Product is already present, no change is 2704 * made. 2705 * 2706 * <p>One Product can be added to at most 100 ProductSets. 2707 * 2708 * <p>Possible errors: 2709 * 2710 * <ul> 2711 * <li>Returns NOT_FOUND if the Product or the ProductSet doesn't exist. 2712 * </ul> 2713 * 2714 * <p>Sample code: 2715 * 2716 * <pre>{@code 2717 * // This snippet has been automatically generated and should be regarded as a code template only. 2718 * // It will require modifications to work: 2719 * // - It may require correct/in-range values for request initialization. 2720 * // - It may require specifying regional endpoints when creating the service client as shown in 2721 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2722 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2723 * AddProductToProductSetRequest request = 2724 * AddProductToProductSetRequest.newBuilder() 2725 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 2726 * .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 2727 * .build(); 2728 * ApiFuture<Empty> future = 2729 * productSearchClient.addProductToProductSetCallable().futureCall(request); 2730 * // Do something. 2731 * future.get(); 2732 * } 2733 * }</pre> 2734 */ 2735 public final UnaryCallable<AddProductToProductSetRequest, Empty> addProductToProductSetCallable()2736 addProductToProductSetCallable() { 2737 return stub.addProductToProductSetCallable(); 2738 } 2739 2740 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2741 /** 2742 * Removes a Product from the specified ProductSet. 2743 * 2744 * <p>Possible errors: 2745 * 2746 * <ul> 2747 * <li>Returns NOT_FOUND If the Product is not found under the ProductSet. 2748 * </ul> 2749 * 2750 * <p>Sample code: 2751 * 2752 * <pre>{@code 2753 * // This snippet has been automatically generated and should be regarded as a code template only. 2754 * // It will require modifications to work: 2755 * // - It may require correct/in-range values for request initialization. 2756 * // - It may require specifying regional endpoints when creating the service client as shown in 2757 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2758 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2759 * ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); 2760 * ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); 2761 * productSearchClient.removeProductFromProductSet(name, product); 2762 * } 2763 * }</pre> 2764 * 2765 * @param name Required. The resource name for the ProductSet to modify. 2766 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2767 * @param product Required. The resource name for the Product to be removed from this ProductSet. 2768 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 2769 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2770 */ removeProductFromProductSet(ProductSetName name, ProductName product)2771 public final void removeProductFromProductSet(ProductSetName name, ProductName product) { 2772 RemoveProductFromProductSetRequest request = 2773 RemoveProductFromProductSetRequest.newBuilder() 2774 .setName(name == null ? null : name.toString()) 2775 .setProduct(product == null ? null : product.toString()) 2776 .build(); 2777 removeProductFromProductSet(request); 2778 } 2779 2780 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2781 /** 2782 * Removes a Product from the specified ProductSet. 2783 * 2784 * <p>Possible errors: 2785 * 2786 * <ul> 2787 * <li>Returns NOT_FOUND If the Product is not found under the ProductSet. 2788 * </ul> 2789 * 2790 * <p>Sample code: 2791 * 2792 * <pre>{@code 2793 * // This snippet has been automatically generated and should be regarded as a code template only. 2794 * // It will require modifications to work: 2795 * // - It may require correct/in-range values for request initialization. 2796 * // - It may require specifying regional endpoints when creating the service client as shown in 2797 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2798 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2799 * ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); 2800 * String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); 2801 * productSearchClient.removeProductFromProductSet(name, product); 2802 * } 2803 * }</pre> 2804 * 2805 * @param name Required. The resource name for the ProductSet to modify. 2806 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2807 * @param product Required. The resource name for the Product to be removed from this ProductSet. 2808 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 2809 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2810 */ removeProductFromProductSet(ProductSetName name, String product)2811 public final void removeProductFromProductSet(ProductSetName name, String product) { 2812 RemoveProductFromProductSetRequest request = 2813 RemoveProductFromProductSetRequest.newBuilder() 2814 .setName(name == null ? null : name.toString()) 2815 .setProduct(product) 2816 .build(); 2817 removeProductFromProductSet(request); 2818 } 2819 2820 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2821 /** 2822 * Removes a Product from the specified ProductSet. 2823 * 2824 * <p>Possible errors: 2825 * 2826 * <ul> 2827 * <li>Returns NOT_FOUND If the Product is not found under the ProductSet. 2828 * </ul> 2829 * 2830 * <p>Sample code: 2831 * 2832 * <pre>{@code 2833 * // This snippet has been automatically generated and should be regarded as a code template only. 2834 * // It will require modifications to work: 2835 * // - It may require correct/in-range values for request initialization. 2836 * // - It may require specifying regional endpoints when creating the service client as shown in 2837 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2838 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2839 * String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); 2840 * ProductName product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]"); 2841 * productSearchClient.removeProductFromProductSet(name, product); 2842 * } 2843 * }</pre> 2844 * 2845 * @param name Required. The resource name for the ProductSet to modify. 2846 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2847 * @param product Required. The resource name for the Product to be removed from this ProductSet. 2848 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 2849 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2850 */ removeProductFromProductSet(String name, ProductName product)2851 public final void removeProductFromProductSet(String name, ProductName product) { 2852 RemoveProductFromProductSetRequest request = 2853 RemoveProductFromProductSetRequest.newBuilder() 2854 .setName(name) 2855 .setProduct(product == null ? null : product.toString()) 2856 .build(); 2857 removeProductFromProductSet(request); 2858 } 2859 2860 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2861 /** 2862 * Removes a Product from the specified ProductSet. 2863 * 2864 * <p>Possible errors: 2865 * 2866 * <ul> 2867 * <li>Returns NOT_FOUND If the Product is not found under the ProductSet. 2868 * </ul> 2869 * 2870 * <p>Sample code: 2871 * 2872 * <pre>{@code 2873 * // This snippet has been automatically generated and should be regarded as a code template only. 2874 * // It will require modifications to work: 2875 * // - It may require correct/in-range values for request initialization. 2876 * // - It may require specifying regional endpoints when creating the service client as shown in 2877 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2878 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2879 * String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); 2880 * String product = ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString(); 2881 * productSearchClient.removeProductFromProductSet(name, product); 2882 * } 2883 * }</pre> 2884 * 2885 * @param name Required. The resource name for the ProductSet to modify. 2886 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2887 * @param product Required. The resource name for the Product to be removed from this ProductSet. 2888 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` 2889 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2890 */ removeProductFromProductSet(String name, String product)2891 public final void removeProductFromProductSet(String name, String product) { 2892 RemoveProductFromProductSetRequest request = 2893 RemoveProductFromProductSetRequest.newBuilder().setName(name).setProduct(product).build(); 2894 removeProductFromProductSet(request); 2895 } 2896 2897 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2898 /** 2899 * Removes a Product from the specified ProductSet. 2900 * 2901 * <p>Possible errors: 2902 * 2903 * <ul> 2904 * <li>Returns NOT_FOUND If the Product is not found under the ProductSet. 2905 * </ul> 2906 * 2907 * <p>Sample code: 2908 * 2909 * <pre>{@code 2910 * // This snippet has been automatically generated and should be regarded as a code template only. 2911 * // It will require modifications to work: 2912 * // - It may require correct/in-range values for request initialization. 2913 * // - It may require specifying regional endpoints when creating the service client as shown in 2914 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2915 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2916 * RemoveProductFromProductSetRequest request = 2917 * RemoveProductFromProductSetRequest.newBuilder() 2918 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 2919 * .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 2920 * .build(); 2921 * productSearchClient.removeProductFromProductSet(request); 2922 * } 2923 * }</pre> 2924 * 2925 * @param request The request object containing all of the parameters for the API call. 2926 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2927 */ removeProductFromProductSet(RemoveProductFromProductSetRequest request)2928 public final void removeProductFromProductSet(RemoveProductFromProductSetRequest request) { 2929 removeProductFromProductSetCallable().call(request); 2930 } 2931 2932 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2933 /** 2934 * Removes a Product from the specified ProductSet. 2935 * 2936 * <p>Possible errors: 2937 * 2938 * <ul> 2939 * <li>Returns NOT_FOUND If the Product is not found under the ProductSet. 2940 * </ul> 2941 * 2942 * <p>Sample code: 2943 * 2944 * <pre>{@code 2945 * // This snippet has been automatically generated and should be regarded as a code template only. 2946 * // It will require modifications to work: 2947 * // - It may require correct/in-range values for request initialization. 2948 * // - It may require specifying regional endpoints when creating the service client as shown in 2949 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2950 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2951 * RemoveProductFromProductSetRequest request = 2952 * RemoveProductFromProductSetRequest.newBuilder() 2953 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 2954 * .setProduct(ProductName.of("[PROJECT]", "[LOCATION]", "[PRODUCT]").toString()) 2955 * .build(); 2956 * ApiFuture<Empty> future = 2957 * productSearchClient.removeProductFromProductSetCallable().futureCall(request); 2958 * // Do something. 2959 * future.get(); 2960 * } 2961 * }</pre> 2962 */ 2963 public final UnaryCallable<RemoveProductFromProductSetRequest, Empty> removeProductFromProductSetCallable()2964 removeProductFromProductSetCallable() { 2965 return stub.removeProductFromProductSetCallable(); 2966 } 2967 2968 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2969 /** 2970 * Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, 2971 * the products field of the response will be empty. 2972 * 2973 * <p>Possible errors: 2974 * 2975 * <ul> 2976 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 2977 * </ul> 2978 * 2979 * <p>Sample code: 2980 * 2981 * <pre>{@code 2982 * // This snippet has been automatically generated and should be regarded as a code template only. 2983 * // It will require modifications to work: 2984 * // - It may require correct/in-range values for request initialization. 2985 * // - It may require specifying regional endpoints when creating the service client as shown in 2986 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2987 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 2988 * ProductSetName name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]"); 2989 * for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) { 2990 * // doThingsWith(element); 2991 * } 2992 * } 2993 * }</pre> 2994 * 2995 * @param name Required. The ProductSet resource for which to retrieve Products. 2996 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 2997 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2998 */ listProductsInProductSet(ProductSetName name)2999 public final ListProductsInProductSetPagedResponse listProductsInProductSet(ProductSetName name) { 3000 ListProductsInProductSetRequest request = 3001 ListProductsInProductSetRequest.newBuilder() 3002 .setName(name == null ? null : name.toString()) 3003 .build(); 3004 return listProductsInProductSet(request); 3005 } 3006 3007 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3008 /** 3009 * Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, 3010 * the products field of the response will be empty. 3011 * 3012 * <p>Possible errors: 3013 * 3014 * <ul> 3015 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 3016 * </ul> 3017 * 3018 * <p>Sample code: 3019 * 3020 * <pre>{@code 3021 * // This snippet has been automatically generated and should be regarded as a code template only. 3022 * // It will require modifications to work: 3023 * // - It may require correct/in-range values for request initialization. 3024 * // - It may require specifying regional endpoints when creating the service client as shown in 3025 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3026 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3027 * String name = ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString(); 3028 * for (Product element : productSearchClient.listProductsInProductSet(name).iterateAll()) { 3029 * // doThingsWith(element); 3030 * } 3031 * } 3032 * }</pre> 3033 * 3034 * @param name Required. The ProductSet resource for which to retrieve Products. 3035 * <p>Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` 3036 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 3037 */ listProductsInProductSet(String name)3038 public final ListProductsInProductSetPagedResponse listProductsInProductSet(String name) { 3039 ListProductsInProductSetRequest request = 3040 ListProductsInProductSetRequest.newBuilder().setName(name).build(); 3041 return listProductsInProductSet(request); 3042 } 3043 3044 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3045 /** 3046 * Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, 3047 * the products field of the response will be empty. 3048 * 3049 * <p>Possible errors: 3050 * 3051 * <ul> 3052 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 3053 * </ul> 3054 * 3055 * <p>Sample code: 3056 * 3057 * <pre>{@code 3058 * // This snippet has been automatically generated and should be regarded as a code template only. 3059 * // It will require modifications to work: 3060 * // - It may require correct/in-range values for request initialization. 3061 * // - It may require specifying regional endpoints when creating the service client as shown in 3062 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3063 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3064 * ListProductsInProductSetRequest request = 3065 * ListProductsInProductSetRequest.newBuilder() 3066 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 3067 * .setPageSize(883849137) 3068 * .setPageToken("pageToken873572522") 3069 * .build(); 3070 * for (Product element : productSearchClient.listProductsInProductSet(request).iterateAll()) { 3071 * // doThingsWith(element); 3072 * } 3073 * } 3074 * }</pre> 3075 * 3076 * @param request The request object containing all of the parameters for the API call. 3077 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 3078 */ listProductsInProductSet( ListProductsInProductSetRequest request)3079 public final ListProductsInProductSetPagedResponse listProductsInProductSet( 3080 ListProductsInProductSetRequest request) { 3081 return listProductsInProductSetPagedCallable().call(request); 3082 } 3083 3084 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3085 /** 3086 * Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, 3087 * the products field of the response will be empty. 3088 * 3089 * <p>Possible errors: 3090 * 3091 * <ul> 3092 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 3093 * </ul> 3094 * 3095 * <p>Sample code: 3096 * 3097 * <pre>{@code 3098 * // This snippet has been automatically generated and should be regarded as a code template only. 3099 * // It will require modifications to work: 3100 * // - It may require correct/in-range values for request initialization. 3101 * // - It may require specifying regional endpoints when creating the service client as shown in 3102 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3103 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3104 * ListProductsInProductSetRequest request = 3105 * ListProductsInProductSetRequest.newBuilder() 3106 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 3107 * .setPageSize(883849137) 3108 * .setPageToken("pageToken873572522") 3109 * .build(); 3110 * ApiFuture<Product> future = 3111 * productSearchClient.listProductsInProductSetPagedCallable().futureCall(request); 3112 * // Do something. 3113 * for (Product element : future.get().iterateAll()) { 3114 * // doThingsWith(element); 3115 * } 3116 * } 3117 * }</pre> 3118 */ 3119 public final UnaryCallable<ListProductsInProductSetRequest, ListProductsInProductSetPagedResponse> listProductsInProductSetPagedCallable()3120 listProductsInProductSetPagedCallable() { 3121 return stub.listProductsInProductSetPagedCallable(); 3122 } 3123 3124 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3125 /** 3126 * Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, 3127 * the products field of the response will be empty. 3128 * 3129 * <p>Possible errors: 3130 * 3131 * <ul> 3132 * <li>Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. 3133 * </ul> 3134 * 3135 * <p>Sample code: 3136 * 3137 * <pre>{@code 3138 * // This snippet has been automatically generated and should be regarded as a code template only. 3139 * // It will require modifications to work: 3140 * // - It may require correct/in-range values for request initialization. 3141 * // - It may require specifying regional endpoints when creating the service client as shown in 3142 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3143 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3144 * ListProductsInProductSetRequest request = 3145 * ListProductsInProductSetRequest.newBuilder() 3146 * .setName(ProductSetName.of("[PROJECT]", "[LOCATION]", "[PRODUCT_SET]").toString()) 3147 * .setPageSize(883849137) 3148 * .setPageToken("pageToken873572522") 3149 * .build(); 3150 * while (true) { 3151 * ListProductsInProductSetResponse response = 3152 * productSearchClient.listProductsInProductSetCallable().call(request); 3153 * for (Product element : response.getProductsList()) { 3154 * // doThingsWith(element); 3155 * } 3156 * String nextPageToken = response.getNextPageToken(); 3157 * if (!Strings.isNullOrEmpty(nextPageToken)) { 3158 * request = request.toBuilder().setPageToken(nextPageToken).build(); 3159 * } else { 3160 * break; 3161 * } 3162 * } 3163 * } 3164 * }</pre> 3165 */ 3166 public final UnaryCallable<ListProductsInProductSetRequest, ListProductsInProductSetResponse> listProductsInProductSetCallable()3167 listProductsInProductSetCallable() { 3168 return stub.listProductsInProductSetCallable(); 3169 } 3170 3171 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3172 /** 3173 * Asynchronous API that imports a list of reference images to specified product sets based on a 3174 * list of image information. 3175 * 3176 * <p>The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep 3177 * track of the progress and results of the request. `Operation.metadata` contains 3178 * `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. 3179 * (results) 3180 * 3181 * <p>The input source of this method is a csv file on Google Cloud Storage. For the format of the 3182 * csv file please see 3183 * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. 3184 * 3185 * <p>Sample code: 3186 * 3187 * <pre>{@code 3188 * // This snippet has been automatically generated and should be regarded as a code template only. 3189 * // It will require modifications to work: 3190 * // - It may require correct/in-range values for request initialization. 3191 * // - It may require specifying regional endpoints when creating the service client as shown in 3192 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3193 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3194 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 3195 * ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); 3196 * ImportProductSetsResponse response = 3197 * productSearchClient.importProductSetsAsync(parent, inputConfig).get(); 3198 * } 3199 * }</pre> 3200 * 3201 * @param parent Required. The project in which the ProductSets should be imported. 3202 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID`. 3203 * @param inputConfig Required. The input content for the list of requests. 3204 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 3205 */ 3206 public final OperationFuture<ImportProductSetsResponse, BatchOperationMetadata> importProductSetsAsync(LocationName parent, ImportProductSetsInputConfig inputConfig)3207 importProductSetsAsync(LocationName parent, ImportProductSetsInputConfig inputConfig) { 3208 ImportProductSetsRequest request = 3209 ImportProductSetsRequest.newBuilder() 3210 .setParent(parent == null ? null : parent.toString()) 3211 .setInputConfig(inputConfig) 3212 .build(); 3213 return importProductSetsAsync(request); 3214 } 3215 3216 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3217 /** 3218 * Asynchronous API that imports a list of reference images to specified product sets based on a 3219 * list of image information. 3220 * 3221 * <p>The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep 3222 * track of the progress and results of the request. `Operation.metadata` contains 3223 * `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. 3224 * (results) 3225 * 3226 * <p>The input source of this method is a csv file on Google Cloud Storage. For the format of the 3227 * csv file please see 3228 * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. 3229 * 3230 * <p>Sample code: 3231 * 3232 * <pre>{@code 3233 * // This snippet has been automatically generated and should be regarded as a code template only. 3234 * // It will require modifications to work: 3235 * // - It may require correct/in-range values for request initialization. 3236 * // - It may require specifying regional endpoints when creating the service client as shown in 3237 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3238 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3239 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 3240 * ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().build(); 3241 * ImportProductSetsResponse response = 3242 * productSearchClient.importProductSetsAsync(parent, inputConfig).get(); 3243 * } 3244 * }</pre> 3245 * 3246 * @param parent Required. The project in which the ProductSets should be imported. 3247 * <p>Format is `projects/PROJECT_ID/locations/LOC_ID`. 3248 * @param inputConfig Required. The input content for the list of requests. 3249 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 3250 */ 3251 public final OperationFuture<ImportProductSetsResponse, BatchOperationMetadata> importProductSetsAsync(String parent, ImportProductSetsInputConfig inputConfig)3252 importProductSetsAsync(String parent, ImportProductSetsInputConfig inputConfig) { 3253 ImportProductSetsRequest request = 3254 ImportProductSetsRequest.newBuilder().setParent(parent).setInputConfig(inputConfig).build(); 3255 return importProductSetsAsync(request); 3256 } 3257 3258 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3259 /** 3260 * Asynchronous API that imports a list of reference images to specified product sets based on a 3261 * list of image information. 3262 * 3263 * <p>The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep 3264 * track of the progress and results of the request. `Operation.metadata` contains 3265 * `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. 3266 * (results) 3267 * 3268 * <p>The input source of this method is a csv file on Google Cloud Storage. For the format of the 3269 * csv file please see 3270 * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. 3271 * 3272 * <p>Sample code: 3273 * 3274 * <pre>{@code 3275 * // This snippet has been automatically generated and should be regarded as a code template only. 3276 * // It will require modifications to work: 3277 * // - It may require correct/in-range values for request initialization. 3278 * // - It may require specifying regional endpoints when creating the service client as shown in 3279 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3280 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3281 * ImportProductSetsRequest request = 3282 * ImportProductSetsRequest.newBuilder() 3283 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 3284 * .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) 3285 * .build(); 3286 * ImportProductSetsResponse response = 3287 * productSearchClient.importProductSetsAsync(request).get(); 3288 * } 3289 * }</pre> 3290 * 3291 * @param request The request object containing all of the parameters for the API call. 3292 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 3293 */ 3294 public final OperationFuture<ImportProductSetsResponse, BatchOperationMetadata> importProductSetsAsync(ImportProductSetsRequest request)3295 importProductSetsAsync(ImportProductSetsRequest request) { 3296 return importProductSetsOperationCallable().futureCall(request); 3297 } 3298 3299 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3300 /** 3301 * Asynchronous API that imports a list of reference images to specified product sets based on a 3302 * list of image information. 3303 * 3304 * <p>The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep 3305 * track of the progress and results of the request. `Operation.metadata` contains 3306 * `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. 3307 * (results) 3308 * 3309 * <p>The input source of this method is a csv file on Google Cloud Storage. For the format of the 3310 * csv file please see 3311 * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. 3312 * 3313 * <p>Sample code: 3314 * 3315 * <pre>{@code 3316 * // This snippet has been automatically generated and should be regarded as a code template only. 3317 * // It will require modifications to work: 3318 * // - It may require correct/in-range values for request initialization. 3319 * // - It may require specifying regional endpoints when creating the service client as shown in 3320 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3321 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3322 * ImportProductSetsRequest request = 3323 * ImportProductSetsRequest.newBuilder() 3324 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 3325 * .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) 3326 * .build(); 3327 * OperationFuture<ImportProductSetsResponse, BatchOperationMetadata> future = 3328 * productSearchClient.importProductSetsOperationCallable().futureCall(request); 3329 * // Do something. 3330 * ImportProductSetsResponse response = future.get(); 3331 * } 3332 * }</pre> 3333 */ 3334 public final OperationCallable< 3335 ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> importProductSetsOperationCallable()3336 importProductSetsOperationCallable() { 3337 return stub.importProductSetsOperationCallable(); 3338 } 3339 3340 // AUTO-GENERATED DOCUMENTATION AND METHOD. 3341 /** 3342 * Asynchronous API that imports a list of reference images to specified product sets based on a 3343 * list of image information. 3344 * 3345 * <p>The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep 3346 * track of the progress and results of the request. `Operation.metadata` contains 3347 * `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. 3348 * (results) 3349 * 3350 * <p>The input source of this method is a csv file on Google Cloud Storage. For the format of the 3351 * csv file please see 3352 * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. 3353 * 3354 * <p>Sample code: 3355 * 3356 * <pre>{@code 3357 * // This snippet has been automatically generated and should be regarded as a code template only. 3358 * // It will require modifications to work: 3359 * // - It may require correct/in-range values for request initialization. 3360 * // - It may require specifying regional endpoints when creating the service client as shown in 3361 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 3362 * try (ProductSearchClient productSearchClient = ProductSearchClient.create()) { 3363 * ImportProductSetsRequest request = 3364 * ImportProductSetsRequest.newBuilder() 3365 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 3366 * .setInputConfig(ImportProductSetsInputConfig.newBuilder().build()) 3367 * .build(); 3368 * ApiFuture<Operation> future = 3369 * productSearchClient.importProductSetsCallable().futureCall(request); 3370 * // Do something. 3371 * Operation response = future.get(); 3372 * } 3373 * }</pre> 3374 */ importProductSetsCallable()3375 public final UnaryCallable<ImportProductSetsRequest, Operation> importProductSetsCallable() { 3376 return stub.importProductSetsCallable(); 3377 } 3378 3379 @Override close()3380 public final void close() { 3381 stub.close(); 3382 } 3383 3384 @Override shutdown()3385 public void shutdown() { 3386 stub.shutdown(); 3387 } 3388 3389 @Override isShutdown()3390 public boolean isShutdown() { 3391 return stub.isShutdown(); 3392 } 3393 3394 @Override isTerminated()3395 public boolean isTerminated() { 3396 return stub.isTerminated(); 3397 } 3398 3399 @Override shutdownNow()3400 public void shutdownNow() { 3401 stub.shutdownNow(); 3402 } 3403 3404 @Override awaitTermination(long duration, TimeUnit unit)3405 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 3406 return stub.awaitTermination(duration, unit); 3407 } 3408 3409 public static class ListProductSetsPagedResponse 3410 extends AbstractPagedListResponse< 3411 ListProductSetsRequest, 3412 ListProductSetsResponse, 3413 ProductSet, 3414 ListProductSetsPage, 3415 ListProductSetsFixedSizeCollection> { 3416 createAsync( PageContext<ListProductSetsRequest, ListProductSetsResponse, ProductSet> context, ApiFuture<ListProductSetsResponse> futureResponse)3417 public static ApiFuture<ListProductSetsPagedResponse> createAsync( 3418 PageContext<ListProductSetsRequest, ListProductSetsResponse, ProductSet> context, 3419 ApiFuture<ListProductSetsResponse> futureResponse) { 3420 ApiFuture<ListProductSetsPage> futurePage = 3421 ListProductSetsPage.createEmptyPage().createPageAsync(context, futureResponse); 3422 return ApiFutures.transform( 3423 futurePage, 3424 input -> new ListProductSetsPagedResponse(input), 3425 MoreExecutors.directExecutor()); 3426 } 3427 ListProductSetsPagedResponse(ListProductSetsPage page)3428 private ListProductSetsPagedResponse(ListProductSetsPage page) { 3429 super(page, ListProductSetsFixedSizeCollection.createEmptyCollection()); 3430 } 3431 } 3432 3433 public static class ListProductSetsPage 3434 extends AbstractPage< 3435 ListProductSetsRequest, ListProductSetsResponse, ProductSet, ListProductSetsPage> { 3436 ListProductSetsPage( PageContext<ListProductSetsRequest, ListProductSetsResponse, ProductSet> context, ListProductSetsResponse response)3437 private ListProductSetsPage( 3438 PageContext<ListProductSetsRequest, ListProductSetsResponse, ProductSet> context, 3439 ListProductSetsResponse response) { 3440 super(context, response); 3441 } 3442 createEmptyPage()3443 private static ListProductSetsPage createEmptyPage() { 3444 return new ListProductSetsPage(null, null); 3445 } 3446 3447 @Override createPage( PageContext<ListProductSetsRequest, ListProductSetsResponse, ProductSet> context, ListProductSetsResponse response)3448 protected ListProductSetsPage createPage( 3449 PageContext<ListProductSetsRequest, ListProductSetsResponse, ProductSet> context, 3450 ListProductSetsResponse response) { 3451 return new ListProductSetsPage(context, response); 3452 } 3453 3454 @Override createPageAsync( PageContext<ListProductSetsRequest, ListProductSetsResponse, ProductSet> context, ApiFuture<ListProductSetsResponse> futureResponse)3455 public ApiFuture<ListProductSetsPage> createPageAsync( 3456 PageContext<ListProductSetsRequest, ListProductSetsResponse, ProductSet> context, 3457 ApiFuture<ListProductSetsResponse> futureResponse) { 3458 return super.createPageAsync(context, futureResponse); 3459 } 3460 } 3461 3462 public static class ListProductSetsFixedSizeCollection 3463 extends AbstractFixedSizeCollection< 3464 ListProductSetsRequest, 3465 ListProductSetsResponse, 3466 ProductSet, 3467 ListProductSetsPage, 3468 ListProductSetsFixedSizeCollection> { 3469 ListProductSetsFixedSizeCollection( List<ListProductSetsPage> pages, int collectionSize)3470 private ListProductSetsFixedSizeCollection( 3471 List<ListProductSetsPage> pages, int collectionSize) { 3472 super(pages, collectionSize); 3473 } 3474 createEmptyCollection()3475 private static ListProductSetsFixedSizeCollection createEmptyCollection() { 3476 return new ListProductSetsFixedSizeCollection(null, 0); 3477 } 3478 3479 @Override createCollection( List<ListProductSetsPage> pages, int collectionSize)3480 protected ListProductSetsFixedSizeCollection createCollection( 3481 List<ListProductSetsPage> pages, int collectionSize) { 3482 return new ListProductSetsFixedSizeCollection(pages, collectionSize); 3483 } 3484 } 3485 3486 public static class ListProductsPagedResponse 3487 extends AbstractPagedListResponse< 3488 ListProductsRequest, 3489 ListProductsResponse, 3490 Product, 3491 ListProductsPage, 3492 ListProductsFixedSizeCollection> { 3493 createAsync( PageContext<ListProductsRequest, ListProductsResponse, Product> context, ApiFuture<ListProductsResponse> futureResponse)3494 public static ApiFuture<ListProductsPagedResponse> createAsync( 3495 PageContext<ListProductsRequest, ListProductsResponse, Product> context, 3496 ApiFuture<ListProductsResponse> futureResponse) { 3497 ApiFuture<ListProductsPage> futurePage = 3498 ListProductsPage.createEmptyPage().createPageAsync(context, futureResponse); 3499 return ApiFutures.transform( 3500 futurePage, 3501 input -> new ListProductsPagedResponse(input), 3502 MoreExecutors.directExecutor()); 3503 } 3504 ListProductsPagedResponse(ListProductsPage page)3505 private ListProductsPagedResponse(ListProductsPage page) { 3506 super(page, ListProductsFixedSizeCollection.createEmptyCollection()); 3507 } 3508 } 3509 3510 public static class ListProductsPage 3511 extends AbstractPage<ListProductsRequest, ListProductsResponse, Product, ListProductsPage> { 3512 ListProductsPage( PageContext<ListProductsRequest, ListProductsResponse, Product> context, ListProductsResponse response)3513 private ListProductsPage( 3514 PageContext<ListProductsRequest, ListProductsResponse, Product> context, 3515 ListProductsResponse response) { 3516 super(context, response); 3517 } 3518 createEmptyPage()3519 private static ListProductsPage createEmptyPage() { 3520 return new ListProductsPage(null, null); 3521 } 3522 3523 @Override createPage( PageContext<ListProductsRequest, ListProductsResponse, Product> context, ListProductsResponse response)3524 protected ListProductsPage createPage( 3525 PageContext<ListProductsRequest, ListProductsResponse, Product> context, 3526 ListProductsResponse response) { 3527 return new ListProductsPage(context, response); 3528 } 3529 3530 @Override createPageAsync( PageContext<ListProductsRequest, ListProductsResponse, Product> context, ApiFuture<ListProductsResponse> futureResponse)3531 public ApiFuture<ListProductsPage> createPageAsync( 3532 PageContext<ListProductsRequest, ListProductsResponse, Product> context, 3533 ApiFuture<ListProductsResponse> futureResponse) { 3534 return super.createPageAsync(context, futureResponse); 3535 } 3536 } 3537 3538 public static class ListProductsFixedSizeCollection 3539 extends AbstractFixedSizeCollection< 3540 ListProductsRequest, 3541 ListProductsResponse, 3542 Product, 3543 ListProductsPage, 3544 ListProductsFixedSizeCollection> { 3545 ListProductsFixedSizeCollection(List<ListProductsPage> pages, int collectionSize)3546 private ListProductsFixedSizeCollection(List<ListProductsPage> pages, int collectionSize) { 3547 super(pages, collectionSize); 3548 } 3549 createEmptyCollection()3550 private static ListProductsFixedSizeCollection createEmptyCollection() { 3551 return new ListProductsFixedSizeCollection(null, 0); 3552 } 3553 3554 @Override createCollection( List<ListProductsPage> pages, int collectionSize)3555 protected ListProductsFixedSizeCollection createCollection( 3556 List<ListProductsPage> pages, int collectionSize) { 3557 return new ListProductsFixedSizeCollection(pages, collectionSize); 3558 } 3559 } 3560 3561 public static class ListReferenceImagesPagedResponse 3562 extends AbstractPagedListResponse< 3563 ListReferenceImagesRequest, 3564 ListReferenceImagesResponse, 3565 ReferenceImage, 3566 ListReferenceImagesPage, 3567 ListReferenceImagesFixedSizeCollection> { 3568 createAsync( PageContext<ListReferenceImagesRequest, ListReferenceImagesResponse, ReferenceImage> context, ApiFuture<ListReferenceImagesResponse> futureResponse)3569 public static ApiFuture<ListReferenceImagesPagedResponse> createAsync( 3570 PageContext<ListReferenceImagesRequest, ListReferenceImagesResponse, ReferenceImage> 3571 context, 3572 ApiFuture<ListReferenceImagesResponse> futureResponse) { 3573 ApiFuture<ListReferenceImagesPage> futurePage = 3574 ListReferenceImagesPage.createEmptyPage().createPageAsync(context, futureResponse); 3575 return ApiFutures.transform( 3576 futurePage, 3577 input -> new ListReferenceImagesPagedResponse(input), 3578 MoreExecutors.directExecutor()); 3579 } 3580 ListReferenceImagesPagedResponse(ListReferenceImagesPage page)3581 private ListReferenceImagesPagedResponse(ListReferenceImagesPage page) { 3582 super(page, ListReferenceImagesFixedSizeCollection.createEmptyCollection()); 3583 } 3584 } 3585 3586 public static class ListReferenceImagesPage 3587 extends AbstractPage< 3588 ListReferenceImagesRequest, 3589 ListReferenceImagesResponse, 3590 ReferenceImage, 3591 ListReferenceImagesPage> { 3592 ListReferenceImagesPage( PageContext<ListReferenceImagesRequest, ListReferenceImagesResponse, ReferenceImage> context, ListReferenceImagesResponse response)3593 private ListReferenceImagesPage( 3594 PageContext<ListReferenceImagesRequest, ListReferenceImagesResponse, ReferenceImage> 3595 context, 3596 ListReferenceImagesResponse response) { 3597 super(context, response); 3598 } 3599 createEmptyPage()3600 private static ListReferenceImagesPage createEmptyPage() { 3601 return new ListReferenceImagesPage(null, null); 3602 } 3603 3604 @Override createPage( PageContext<ListReferenceImagesRequest, ListReferenceImagesResponse, ReferenceImage> context, ListReferenceImagesResponse response)3605 protected ListReferenceImagesPage createPage( 3606 PageContext<ListReferenceImagesRequest, ListReferenceImagesResponse, ReferenceImage> 3607 context, 3608 ListReferenceImagesResponse response) { 3609 return new ListReferenceImagesPage(context, response); 3610 } 3611 3612 @Override createPageAsync( PageContext<ListReferenceImagesRequest, ListReferenceImagesResponse, ReferenceImage> context, ApiFuture<ListReferenceImagesResponse> futureResponse)3613 public ApiFuture<ListReferenceImagesPage> createPageAsync( 3614 PageContext<ListReferenceImagesRequest, ListReferenceImagesResponse, ReferenceImage> 3615 context, 3616 ApiFuture<ListReferenceImagesResponse> futureResponse) { 3617 return super.createPageAsync(context, futureResponse); 3618 } 3619 } 3620 3621 public static class ListReferenceImagesFixedSizeCollection 3622 extends AbstractFixedSizeCollection< 3623 ListReferenceImagesRequest, 3624 ListReferenceImagesResponse, 3625 ReferenceImage, 3626 ListReferenceImagesPage, 3627 ListReferenceImagesFixedSizeCollection> { 3628 ListReferenceImagesFixedSizeCollection( List<ListReferenceImagesPage> pages, int collectionSize)3629 private ListReferenceImagesFixedSizeCollection( 3630 List<ListReferenceImagesPage> pages, int collectionSize) { 3631 super(pages, collectionSize); 3632 } 3633 createEmptyCollection()3634 private static ListReferenceImagesFixedSizeCollection createEmptyCollection() { 3635 return new ListReferenceImagesFixedSizeCollection(null, 0); 3636 } 3637 3638 @Override createCollection( List<ListReferenceImagesPage> pages, int collectionSize)3639 protected ListReferenceImagesFixedSizeCollection createCollection( 3640 List<ListReferenceImagesPage> pages, int collectionSize) { 3641 return new ListReferenceImagesFixedSizeCollection(pages, collectionSize); 3642 } 3643 } 3644 3645 public static class ListProductsInProductSetPagedResponse 3646 extends AbstractPagedListResponse< 3647 ListProductsInProductSetRequest, 3648 ListProductsInProductSetResponse, 3649 Product, 3650 ListProductsInProductSetPage, 3651 ListProductsInProductSetFixedSizeCollection> { 3652 createAsync( PageContext<ListProductsInProductSetRequest, ListProductsInProductSetResponse, Product> context, ApiFuture<ListProductsInProductSetResponse> futureResponse)3653 public static ApiFuture<ListProductsInProductSetPagedResponse> createAsync( 3654 PageContext<ListProductsInProductSetRequest, ListProductsInProductSetResponse, Product> 3655 context, 3656 ApiFuture<ListProductsInProductSetResponse> futureResponse) { 3657 ApiFuture<ListProductsInProductSetPage> futurePage = 3658 ListProductsInProductSetPage.createEmptyPage().createPageAsync(context, futureResponse); 3659 return ApiFutures.transform( 3660 futurePage, 3661 input -> new ListProductsInProductSetPagedResponse(input), 3662 MoreExecutors.directExecutor()); 3663 } 3664 ListProductsInProductSetPagedResponse(ListProductsInProductSetPage page)3665 private ListProductsInProductSetPagedResponse(ListProductsInProductSetPage page) { 3666 super(page, ListProductsInProductSetFixedSizeCollection.createEmptyCollection()); 3667 } 3668 } 3669 3670 public static class ListProductsInProductSetPage 3671 extends AbstractPage< 3672 ListProductsInProductSetRequest, 3673 ListProductsInProductSetResponse, 3674 Product, 3675 ListProductsInProductSetPage> { 3676 ListProductsInProductSetPage( PageContext<ListProductsInProductSetRequest, ListProductsInProductSetResponse, Product> context, ListProductsInProductSetResponse response)3677 private ListProductsInProductSetPage( 3678 PageContext<ListProductsInProductSetRequest, ListProductsInProductSetResponse, Product> 3679 context, 3680 ListProductsInProductSetResponse response) { 3681 super(context, response); 3682 } 3683 createEmptyPage()3684 private static ListProductsInProductSetPage createEmptyPage() { 3685 return new ListProductsInProductSetPage(null, null); 3686 } 3687 3688 @Override createPage( PageContext<ListProductsInProductSetRequest, ListProductsInProductSetResponse, Product> context, ListProductsInProductSetResponse response)3689 protected ListProductsInProductSetPage createPage( 3690 PageContext<ListProductsInProductSetRequest, ListProductsInProductSetResponse, Product> 3691 context, 3692 ListProductsInProductSetResponse response) { 3693 return new ListProductsInProductSetPage(context, response); 3694 } 3695 3696 @Override createPageAsync( PageContext<ListProductsInProductSetRequest, ListProductsInProductSetResponse, Product> context, ApiFuture<ListProductsInProductSetResponse> futureResponse)3697 public ApiFuture<ListProductsInProductSetPage> createPageAsync( 3698 PageContext<ListProductsInProductSetRequest, ListProductsInProductSetResponse, Product> 3699 context, 3700 ApiFuture<ListProductsInProductSetResponse> futureResponse) { 3701 return super.createPageAsync(context, futureResponse); 3702 } 3703 } 3704 3705 public static class ListProductsInProductSetFixedSizeCollection 3706 extends AbstractFixedSizeCollection< 3707 ListProductsInProductSetRequest, 3708 ListProductsInProductSetResponse, 3709 Product, 3710 ListProductsInProductSetPage, 3711 ListProductsInProductSetFixedSizeCollection> { 3712 ListProductsInProductSetFixedSizeCollection( List<ListProductsInProductSetPage> pages, int collectionSize)3713 private ListProductsInProductSetFixedSizeCollection( 3714 List<ListProductsInProductSetPage> pages, int collectionSize) { 3715 super(pages, collectionSize); 3716 } 3717 createEmptyCollection()3718 private static ListProductsInProductSetFixedSizeCollection createEmptyCollection() { 3719 return new ListProductsInProductSetFixedSizeCollection(null, 0); 3720 } 3721 3722 @Override createCollection( List<ListProductsInProductSetPage> pages, int collectionSize)3723 protected ListProductsInProductSetFixedSizeCollection createCollection( 3724 List<ListProductsInProductSetPage> pages, int collectionSize) { 3725 return new ListProductsInProductSetFixedSizeCollection(pages, collectionSize); 3726 } 3727 } 3728 } 3729