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.v1; 18 19 import static com.google.cloud.vision.v1.ProductSearchClient.ListProductSetsPagedResponse; 20 import static com.google.cloud.vision.v1.ProductSearchClient.ListProductsInProductSetPagedResponse; 21 import static com.google.cloud.vision.v1.ProductSearchClient.ListProductsPagedResponse; 22 import static com.google.cloud.vision.v1.ProductSearchClient.ListReferenceImagesPagedResponse; 23 24 import com.google.api.core.ApiFunction; 25 import com.google.api.core.BetaApi; 26 import com.google.api.gax.core.GoogleCredentialsProvider; 27 import com.google.api.gax.core.InstantiatingExecutorProvider; 28 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; 29 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 30 import com.google.api.gax.rpc.ApiClientHeaderProvider; 31 import com.google.api.gax.rpc.ClientContext; 32 import com.google.api.gax.rpc.ClientSettings; 33 import com.google.api.gax.rpc.OperationCallSettings; 34 import com.google.api.gax.rpc.PagedCallSettings; 35 import com.google.api.gax.rpc.TransportChannelProvider; 36 import com.google.api.gax.rpc.UnaryCallSettings; 37 import com.google.cloud.vision.v1.stub.ProductSearchStubSettings; 38 import com.google.longrunning.Operation; 39 import com.google.protobuf.Empty; 40 import java.io.IOException; 41 import java.util.List; 42 import javax.annotation.Generated; 43 44 // AUTO-GENERATED DOCUMENTATION AND CLASS. 45 /** 46 * Settings class to configure an instance of {@link ProductSearchClient}. 47 * 48 * <p>The default instance has everything set to sensible defaults: 49 * 50 * <ul> 51 * <li>The default service address (vision.googleapis.com) and default port (443) are used. 52 * <li>Credentials are acquired automatically through Application Default Credentials. 53 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 54 * </ul> 55 * 56 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 57 * build() is called, the tree of builders is called to create the complete settings object. 58 * 59 * <p>For example, to set the total timeout of createProductSet to 30 seconds: 60 * 61 * <pre>{@code 62 * // This snippet has been automatically generated and should be regarded as a code template only. 63 * // It will require modifications to work: 64 * // - It may require correct/in-range values for request initialization. 65 * // - It may require specifying regional endpoints when creating the service client as shown in 66 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 67 * ProductSearchSettings.Builder productSearchSettingsBuilder = ProductSearchSettings.newBuilder(); 68 * productSearchSettingsBuilder 69 * .createProductSetSettings() 70 * .setRetrySettings( 71 * productSearchSettingsBuilder 72 * .createProductSetSettings() 73 * .getRetrySettings() 74 * .toBuilder() 75 * .setTotalTimeout(Duration.ofSeconds(30)) 76 * .build()); 77 * ProductSearchSettings productSearchSettings = productSearchSettingsBuilder.build(); 78 * }</pre> 79 */ 80 @Generated("by gapic-generator-java") 81 public class ProductSearchSettings extends ClientSettings<ProductSearchSettings> { 82 83 /** Returns the object with the settings used for calls to createProductSet. */ createProductSetSettings()84 public UnaryCallSettings<CreateProductSetRequest, ProductSet> createProductSetSettings() { 85 return ((ProductSearchStubSettings) getStubSettings()).createProductSetSettings(); 86 } 87 88 /** Returns the object with the settings used for calls to listProductSets. */ 89 public PagedCallSettings< 90 ListProductSetsRequest, ListProductSetsResponse, ListProductSetsPagedResponse> listProductSetsSettings()91 listProductSetsSettings() { 92 return ((ProductSearchStubSettings) getStubSettings()).listProductSetsSettings(); 93 } 94 95 /** Returns the object with the settings used for calls to getProductSet. */ getProductSetSettings()96 public UnaryCallSettings<GetProductSetRequest, ProductSet> getProductSetSettings() { 97 return ((ProductSearchStubSettings) getStubSettings()).getProductSetSettings(); 98 } 99 100 /** Returns the object with the settings used for calls to updateProductSet. */ updateProductSetSettings()101 public UnaryCallSettings<UpdateProductSetRequest, ProductSet> updateProductSetSettings() { 102 return ((ProductSearchStubSettings) getStubSettings()).updateProductSetSettings(); 103 } 104 105 /** Returns the object with the settings used for calls to deleteProductSet. */ deleteProductSetSettings()106 public UnaryCallSettings<DeleteProductSetRequest, Empty> deleteProductSetSettings() { 107 return ((ProductSearchStubSettings) getStubSettings()).deleteProductSetSettings(); 108 } 109 110 /** Returns the object with the settings used for calls to createProduct. */ createProductSettings()111 public UnaryCallSettings<CreateProductRequest, Product> createProductSettings() { 112 return ((ProductSearchStubSettings) getStubSettings()).createProductSettings(); 113 } 114 115 /** Returns the object with the settings used for calls to listProducts. */ 116 public PagedCallSettings<ListProductsRequest, ListProductsResponse, ListProductsPagedResponse> listProductsSettings()117 listProductsSettings() { 118 return ((ProductSearchStubSettings) getStubSettings()).listProductsSettings(); 119 } 120 121 /** Returns the object with the settings used for calls to getProduct. */ getProductSettings()122 public UnaryCallSettings<GetProductRequest, Product> getProductSettings() { 123 return ((ProductSearchStubSettings) getStubSettings()).getProductSettings(); 124 } 125 126 /** Returns the object with the settings used for calls to updateProduct. */ updateProductSettings()127 public UnaryCallSettings<UpdateProductRequest, Product> updateProductSettings() { 128 return ((ProductSearchStubSettings) getStubSettings()).updateProductSettings(); 129 } 130 131 /** Returns the object with the settings used for calls to deleteProduct. */ deleteProductSettings()132 public UnaryCallSettings<DeleteProductRequest, Empty> deleteProductSettings() { 133 return ((ProductSearchStubSettings) getStubSettings()).deleteProductSettings(); 134 } 135 136 /** Returns the object with the settings used for calls to createReferenceImage. */ 137 public UnaryCallSettings<CreateReferenceImageRequest, ReferenceImage> createReferenceImageSettings()138 createReferenceImageSettings() { 139 return ((ProductSearchStubSettings) getStubSettings()).createReferenceImageSettings(); 140 } 141 142 /** Returns the object with the settings used for calls to deleteReferenceImage. */ deleteReferenceImageSettings()143 public UnaryCallSettings<DeleteReferenceImageRequest, Empty> deleteReferenceImageSettings() { 144 return ((ProductSearchStubSettings) getStubSettings()).deleteReferenceImageSettings(); 145 } 146 147 /** Returns the object with the settings used for calls to listReferenceImages. */ 148 public PagedCallSettings< 149 ListReferenceImagesRequest, ListReferenceImagesResponse, ListReferenceImagesPagedResponse> listReferenceImagesSettings()150 listReferenceImagesSettings() { 151 return ((ProductSearchStubSettings) getStubSettings()).listReferenceImagesSettings(); 152 } 153 154 /** Returns the object with the settings used for calls to getReferenceImage. */ getReferenceImageSettings()155 public UnaryCallSettings<GetReferenceImageRequest, ReferenceImage> getReferenceImageSettings() { 156 return ((ProductSearchStubSettings) getStubSettings()).getReferenceImageSettings(); 157 } 158 159 /** Returns the object with the settings used for calls to addProductToProductSet. */ addProductToProductSetSettings()160 public UnaryCallSettings<AddProductToProductSetRequest, Empty> addProductToProductSetSettings() { 161 return ((ProductSearchStubSettings) getStubSettings()).addProductToProductSetSettings(); 162 } 163 164 /** Returns the object with the settings used for calls to removeProductFromProductSet. */ 165 public UnaryCallSettings<RemoveProductFromProductSetRequest, Empty> removeProductFromProductSetSettings()166 removeProductFromProductSetSettings() { 167 return ((ProductSearchStubSettings) getStubSettings()).removeProductFromProductSetSettings(); 168 } 169 170 /** Returns the object with the settings used for calls to listProductsInProductSet. */ 171 public PagedCallSettings< 172 ListProductsInProductSetRequest, 173 ListProductsInProductSetResponse, 174 ListProductsInProductSetPagedResponse> listProductsInProductSetSettings()175 listProductsInProductSetSettings() { 176 return ((ProductSearchStubSettings) getStubSettings()).listProductsInProductSetSettings(); 177 } 178 179 /** Returns the object with the settings used for calls to importProductSets. */ importProductSetsSettings()180 public UnaryCallSettings<ImportProductSetsRequest, Operation> importProductSetsSettings() { 181 return ((ProductSearchStubSettings) getStubSettings()).importProductSetsSettings(); 182 } 183 184 /** Returns the object with the settings used for calls to importProductSets. */ 185 public OperationCallSettings< 186 ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> importProductSetsOperationSettings()187 importProductSetsOperationSettings() { 188 return ((ProductSearchStubSettings) getStubSettings()).importProductSetsOperationSettings(); 189 } 190 191 /** Returns the object with the settings used for calls to purgeProducts. */ purgeProductsSettings()192 public UnaryCallSettings<PurgeProductsRequest, Operation> purgeProductsSettings() { 193 return ((ProductSearchStubSettings) getStubSettings()).purgeProductsSettings(); 194 } 195 196 /** Returns the object with the settings used for calls to purgeProducts. */ 197 public OperationCallSettings<PurgeProductsRequest, Empty, BatchOperationMetadata> purgeProductsOperationSettings()198 purgeProductsOperationSettings() { 199 return ((ProductSearchStubSettings) getStubSettings()).purgeProductsOperationSettings(); 200 } 201 create(ProductSearchStubSettings stub)202 public static final ProductSearchSettings create(ProductSearchStubSettings stub) 203 throws IOException { 204 return new ProductSearchSettings.Builder(stub.toBuilder()).build(); 205 } 206 207 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()208 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 209 return ProductSearchStubSettings.defaultExecutorProviderBuilder(); 210 } 211 212 /** Returns the default service endpoint. */ getDefaultEndpoint()213 public static String getDefaultEndpoint() { 214 return ProductSearchStubSettings.getDefaultEndpoint(); 215 } 216 217 /** Returns the default service scopes. */ getDefaultServiceScopes()218 public static List<String> getDefaultServiceScopes() { 219 return ProductSearchStubSettings.getDefaultServiceScopes(); 220 } 221 222 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()223 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 224 return ProductSearchStubSettings.defaultCredentialsProviderBuilder(); 225 } 226 227 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()228 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 229 return ProductSearchStubSettings.defaultGrpcTransportProviderBuilder(); 230 } 231 232 /** Returns a builder for the default REST ChannelProvider for this service. */ 233 @BetaApi 234 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()235 defaultHttpJsonTransportProviderBuilder() { 236 return ProductSearchStubSettings.defaultHttpJsonTransportProviderBuilder(); 237 } 238 defaultTransportChannelProvider()239 public static TransportChannelProvider defaultTransportChannelProvider() { 240 return ProductSearchStubSettings.defaultTransportChannelProvider(); 241 } 242 243 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()244 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 245 return ProductSearchStubSettings.defaultApiClientHeaderProviderBuilder(); 246 } 247 248 /** Returns a new gRPC builder for this class. */ newBuilder()249 public static Builder newBuilder() { 250 return Builder.createDefault(); 251 } 252 253 /** Returns a new REST builder for this class. */ 254 @BetaApi newHttpJsonBuilder()255 public static Builder newHttpJsonBuilder() { 256 return Builder.createHttpJsonDefault(); 257 } 258 259 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)260 public static Builder newBuilder(ClientContext clientContext) { 261 return new Builder(clientContext); 262 } 263 264 /** Returns a builder containing all the values of this settings class. */ toBuilder()265 public Builder toBuilder() { 266 return new Builder(this); 267 } 268 ProductSearchSettings(Builder settingsBuilder)269 protected ProductSearchSettings(Builder settingsBuilder) throws IOException { 270 super(settingsBuilder); 271 } 272 273 /** Builder for ProductSearchSettings. */ 274 public static class Builder extends ClientSettings.Builder<ProductSearchSettings, Builder> { 275 Builder()276 protected Builder() throws IOException { 277 this(((ClientContext) null)); 278 } 279 Builder(ClientContext clientContext)280 protected Builder(ClientContext clientContext) { 281 super(ProductSearchStubSettings.newBuilder(clientContext)); 282 } 283 Builder(ProductSearchSettings settings)284 protected Builder(ProductSearchSettings settings) { 285 super(settings.getStubSettings().toBuilder()); 286 } 287 Builder(ProductSearchStubSettings.Builder stubSettings)288 protected Builder(ProductSearchStubSettings.Builder stubSettings) { 289 super(stubSettings); 290 } 291 createDefault()292 private static Builder createDefault() { 293 return new Builder(ProductSearchStubSettings.newBuilder()); 294 } 295 296 @BetaApi createHttpJsonDefault()297 private static Builder createHttpJsonDefault() { 298 return new Builder(ProductSearchStubSettings.newHttpJsonBuilder()); 299 } 300 getStubSettingsBuilder()301 public ProductSearchStubSettings.Builder getStubSettingsBuilder() { 302 return ((ProductSearchStubSettings.Builder) getStubSettings()); 303 } 304 305 /** 306 * Applies the given settings updater function to all of the unary API methods in this service. 307 * 308 * <p>Note: This method does not support applying settings to streaming methods. 309 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)310 public Builder applyToAllUnaryMethods( 311 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 312 super.applyToAllUnaryMethods( 313 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 314 return this; 315 } 316 317 /** Returns the builder for the settings used for calls to createProductSet. */ 318 public UnaryCallSettings.Builder<CreateProductSetRequest, ProductSet> createProductSetSettings()319 createProductSetSettings() { 320 return getStubSettingsBuilder().createProductSetSettings(); 321 } 322 323 /** Returns the builder for the settings used for calls to listProductSets. */ 324 public PagedCallSettings.Builder< 325 ListProductSetsRequest, ListProductSetsResponse, ListProductSetsPagedResponse> listProductSetsSettings()326 listProductSetsSettings() { 327 return getStubSettingsBuilder().listProductSetsSettings(); 328 } 329 330 /** Returns the builder for the settings used for calls to getProductSet. */ getProductSetSettings()331 public UnaryCallSettings.Builder<GetProductSetRequest, ProductSet> getProductSetSettings() { 332 return getStubSettingsBuilder().getProductSetSettings(); 333 } 334 335 /** Returns the builder for the settings used for calls to updateProductSet. */ 336 public UnaryCallSettings.Builder<UpdateProductSetRequest, ProductSet> updateProductSetSettings()337 updateProductSetSettings() { 338 return getStubSettingsBuilder().updateProductSetSettings(); 339 } 340 341 /** Returns the builder for the settings used for calls to deleteProductSet. */ deleteProductSetSettings()342 public UnaryCallSettings.Builder<DeleteProductSetRequest, Empty> deleteProductSetSettings() { 343 return getStubSettingsBuilder().deleteProductSetSettings(); 344 } 345 346 /** Returns the builder for the settings used for calls to createProduct. */ createProductSettings()347 public UnaryCallSettings.Builder<CreateProductRequest, Product> createProductSettings() { 348 return getStubSettingsBuilder().createProductSettings(); 349 } 350 351 /** Returns the builder for the settings used for calls to listProducts. */ 352 public PagedCallSettings.Builder< 353 ListProductsRequest, ListProductsResponse, ListProductsPagedResponse> listProductsSettings()354 listProductsSettings() { 355 return getStubSettingsBuilder().listProductsSettings(); 356 } 357 358 /** Returns the builder for the settings used for calls to getProduct. */ getProductSettings()359 public UnaryCallSettings.Builder<GetProductRequest, Product> getProductSettings() { 360 return getStubSettingsBuilder().getProductSettings(); 361 } 362 363 /** Returns the builder for the settings used for calls to updateProduct. */ updateProductSettings()364 public UnaryCallSettings.Builder<UpdateProductRequest, Product> updateProductSettings() { 365 return getStubSettingsBuilder().updateProductSettings(); 366 } 367 368 /** Returns the builder for the settings used for calls to deleteProduct. */ deleteProductSettings()369 public UnaryCallSettings.Builder<DeleteProductRequest, Empty> deleteProductSettings() { 370 return getStubSettingsBuilder().deleteProductSettings(); 371 } 372 373 /** Returns the builder for the settings used for calls to createReferenceImage. */ 374 public UnaryCallSettings.Builder<CreateReferenceImageRequest, ReferenceImage> createReferenceImageSettings()375 createReferenceImageSettings() { 376 return getStubSettingsBuilder().createReferenceImageSettings(); 377 } 378 379 /** Returns the builder for the settings used for calls to deleteReferenceImage. */ 380 public UnaryCallSettings.Builder<DeleteReferenceImageRequest, Empty> deleteReferenceImageSettings()381 deleteReferenceImageSettings() { 382 return getStubSettingsBuilder().deleteReferenceImageSettings(); 383 } 384 385 /** Returns the builder for the settings used for calls to listReferenceImages. */ 386 public PagedCallSettings.Builder< 387 ListReferenceImagesRequest, 388 ListReferenceImagesResponse, 389 ListReferenceImagesPagedResponse> listReferenceImagesSettings()390 listReferenceImagesSettings() { 391 return getStubSettingsBuilder().listReferenceImagesSettings(); 392 } 393 394 /** Returns the builder for the settings used for calls to getReferenceImage. */ 395 public UnaryCallSettings.Builder<GetReferenceImageRequest, ReferenceImage> getReferenceImageSettings()396 getReferenceImageSettings() { 397 return getStubSettingsBuilder().getReferenceImageSettings(); 398 } 399 400 /** Returns the builder for the settings used for calls to addProductToProductSet. */ 401 public UnaryCallSettings.Builder<AddProductToProductSetRequest, Empty> addProductToProductSetSettings()402 addProductToProductSetSettings() { 403 return getStubSettingsBuilder().addProductToProductSetSettings(); 404 } 405 406 /** Returns the builder for the settings used for calls to removeProductFromProductSet. */ 407 public UnaryCallSettings.Builder<RemoveProductFromProductSetRequest, Empty> removeProductFromProductSetSettings()408 removeProductFromProductSetSettings() { 409 return getStubSettingsBuilder().removeProductFromProductSetSettings(); 410 } 411 412 /** Returns the builder for the settings used for calls to listProductsInProductSet. */ 413 public PagedCallSettings.Builder< 414 ListProductsInProductSetRequest, 415 ListProductsInProductSetResponse, 416 ListProductsInProductSetPagedResponse> listProductsInProductSetSettings()417 listProductsInProductSetSettings() { 418 return getStubSettingsBuilder().listProductsInProductSetSettings(); 419 } 420 421 /** Returns the builder for the settings used for calls to importProductSets. */ 422 public UnaryCallSettings.Builder<ImportProductSetsRequest, Operation> importProductSetsSettings()423 importProductSetsSettings() { 424 return getStubSettingsBuilder().importProductSetsSettings(); 425 } 426 427 /** Returns the builder for the settings used for calls to importProductSets. */ 428 public OperationCallSettings.Builder< 429 ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> importProductSetsOperationSettings()430 importProductSetsOperationSettings() { 431 return getStubSettingsBuilder().importProductSetsOperationSettings(); 432 } 433 434 /** Returns the builder for the settings used for calls to purgeProducts. */ purgeProductsSettings()435 public UnaryCallSettings.Builder<PurgeProductsRequest, Operation> purgeProductsSettings() { 436 return getStubSettingsBuilder().purgeProductsSettings(); 437 } 438 439 /** Returns the builder for the settings used for calls to purgeProducts. */ 440 public OperationCallSettings.Builder<PurgeProductsRequest, Empty, BatchOperationMetadata> purgeProductsOperationSettings()441 purgeProductsOperationSettings() { 442 return getStubSettingsBuilder().purgeProductsOperationSettings(); 443 } 444 445 @Override build()446 public ProductSearchSettings build() throws IOException { 447 return new ProductSearchSettings(this); 448 } 449 } 450 } 451