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.v1p4beta1; 18 19 import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductSetsPagedResponse; 20 import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductsInProductSetPagedResponse; 21 import static com.google.cloud.vision.v1p4beta1.ProductSearchClient.ListProductsPagedResponse; 22 import static com.google.cloud.vision.v1p4beta1.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.v1p4beta1.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 @BetaApi 81 @Generated("by gapic-generator-java") 82 public class ProductSearchSettings extends ClientSettings<ProductSearchSettings> { 83 84 /** Returns the object with the settings used for calls to createProductSet. */ createProductSetSettings()85 public UnaryCallSettings<CreateProductSetRequest, ProductSet> createProductSetSettings() { 86 return ((ProductSearchStubSettings) getStubSettings()).createProductSetSettings(); 87 } 88 89 /** Returns the object with the settings used for calls to listProductSets. */ 90 public PagedCallSettings< 91 ListProductSetsRequest, ListProductSetsResponse, ListProductSetsPagedResponse> listProductSetsSettings()92 listProductSetsSettings() { 93 return ((ProductSearchStubSettings) getStubSettings()).listProductSetsSettings(); 94 } 95 96 /** Returns the object with the settings used for calls to getProductSet. */ getProductSetSettings()97 public UnaryCallSettings<GetProductSetRequest, ProductSet> getProductSetSettings() { 98 return ((ProductSearchStubSettings) getStubSettings()).getProductSetSettings(); 99 } 100 101 /** Returns the object with the settings used for calls to updateProductSet. */ updateProductSetSettings()102 public UnaryCallSettings<UpdateProductSetRequest, ProductSet> updateProductSetSettings() { 103 return ((ProductSearchStubSettings) getStubSettings()).updateProductSetSettings(); 104 } 105 106 /** Returns the object with the settings used for calls to deleteProductSet. */ deleteProductSetSettings()107 public UnaryCallSettings<DeleteProductSetRequest, Empty> deleteProductSetSettings() { 108 return ((ProductSearchStubSettings) getStubSettings()).deleteProductSetSettings(); 109 } 110 111 /** Returns the object with the settings used for calls to createProduct. */ createProductSettings()112 public UnaryCallSettings<CreateProductRequest, Product> createProductSettings() { 113 return ((ProductSearchStubSettings) getStubSettings()).createProductSettings(); 114 } 115 116 /** Returns the object with the settings used for calls to listProducts. */ 117 public PagedCallSettings<ListProductsRequest, ListProductsResponse, ListProductsPagedResponse> listProductsSettings()118 listProductsSettings() { 119 return ((ProductSearchStubSettings) getStubSettings()).listProductsSettings(); 120 } 121 122 /** Returns the object with the settings used for calls to getProduct. */ getProductSettings()123 public UnaryCallSettings<GetProductRequest, Product> getProductSettings() { 124 return ((ProductSearchStubSettings) getStubSettings()).getProductSettings(); 125 } 126 127 /** Returns the object with the settings used for calls to updateProduct. */ updateProductSettings()128 public UnaryCallSettings<UpdateProductRequest, Product> updateProductSettings() { 129 return ((ProductSearchStubSettings) getStubSettings()).updateProductSettings(); 130 } 131 132 /** Returns the object with the settings used for calls to deleteProduct. */ deleteProductSettings()133 public UnaryCallSettings<DeleteProductRequest, Empty> deleteProductSettings() { 134 return ((ProductSearchStubSettings) getStubSettings()).deleteProductSettings(); 135 } 136 137 /** Returns the object with the settings used for calls to createReferenceImage. */ 138 public UnaryCallSettings<CreateReferenceImageRequest, ReferenceImage> createReferenceImageSettings()139 createReferenceImageSettings() { 140 return ((ProductSearchStubSettings) getStubSettings()).createReferenceImageSettings(); 141 } 142 143 /** Returns the object with the settings used for calls to deleteReferenceImage. */ deleteReferenceImageSettings()144 public UnaryCallSettings<DeleteReferenceImageRequest, Empty> deleteReferenceImageSettings() { 145 return ((ProductSearchStubSettings) getStubSettings()).deleteReferenceImageSettings(); 146 } 147 148 /** Returns the object with the settings used for calls to listReferenceImages. */ 149 public PagedCallSettings< 150 ListReferenceImagesRequest, ListReferenceImagesResponse, ListReferenceImagesPagedResponse> listReferenceImagesSettings()151 listReferenceImagesSettings() { 152 return ((ProductSearchStubSettings) getStubSettings()).listReferenceImagesSettings(); 153 } 154 155 /** Returns the object with the settings used for calls to getReferenceImage. */ getReferenceImageSettings()156 public UnaryCallSettings<GetReferenceImageRequest, ReferenceImage> getReferenceImageSettings() { 157 return ((ProductSearchStubSettings) getStubSettings()).getReferenceImageSettings(); 158 } 159 160 /** Returns the object with the settings used for calls to addProductToProductSet. */ addProductToProductSetSettings()161 public UnaryCallSettings<AddProductToProductSetRequest, Empty> addProductToProductSetSettings() { 162 return ((ProductSearchStubSettings) getStubSettings()).addProductToProductSetSettings(); 163 } 164 165 /** Returns the object with the settings used for calls to removeProductFromProductSet. */ 166 public UnaryCallSettings<RemoveProductFromProductSetRequest, Empty> removeProductFromProductSetSettings()167 removeProductFromProductSetSettings() { 168 return ((ProductSearchStubSettings) getStubSettings()).removeProductFromProductSetSettings(); 169 } 170 171 /** Returns the object with the settings used for calls to listProductsInProductSet. */ 172 public PagedCallSettings< 173 ListProductsInProductSetRequest, 174 ListProductsInProductSetResponse, 175 ListProductsInProductSetPagedResponse> listProductsInProductSetSettings()176 listProductsInProductSetSettings() { 177 return ((ProductSearchStubSettings) getStubSettings()).listProductsInProductSetSettings(); 178 } 179 180 /** Returns the object with the settings used for calls to importProductSets. */ importProductSetsSettings()181 public UnaryCallSettings<ImportProductSetsRequest, Operation> importProductSetsSettings() { 182 return ((ProductSearchStubSettings) getStubSettings()).importProductSetsSettings(); 183 } 184 185 /** Returns the object with the settings used for calls to importProductSets. */ 186 public OperationCallSettings< 187 ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> importProductSetsOperationSettings()188 importProductSetsOperationSettings() { 189 return ((ProductSearchStubSettings) getStubSettings()).importProductSetsOperationSettings(); 190 } 191 192 /** Returns the object with the settings used for calls to purgeProducts. */ purgeProductsSettings()193 public UnaryCallSettings<PurgeProductsRequest, Operation> purgeProductsSettings() { 194 return ((ProductSearchStubSettings) getStubSettings()).purgeProductsSettings(); 195 } 196 197 /** Returns the object with the settings used for calls to purgeProducts. */ 198 public OperationCallSettings<PurgeProductsRequest, Empty, BatchOperationMetadata> purgeProductsOperationSettings()199 purgeProductsOperationSettings() { 200 return ((ProductSearchStubSettings) getStubSettings()).purgeProductsOperationSettings(); 201 } 202 create(ProductSearchStubSettings stub)203 public static final ProductSearchSettings create(ProductSearchStubSettings stub) 204 throws IOException { 205 return new ProductSearchSettings.Builder(stub.toBuilder()).build(); 206 } 207 208 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()209 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 210 return ProductSearchStubSettings.defaultExecutorProviderBuilder(); 211 } 212 213 /** Returns the default service endpoint. */ getDefaultEndpoint()214 public static String getDefaultEndpoint() { 215 return ProductSearchStubSettings.getDefaultEndpoint(); 216 } 217 218 /** Returns the default service scopes. */ getDefaultServiceScopes()219 public static List<String> getDefaultServiceScopes() { 220 return ProductSearchStubSettings.getDefaultServiceScopes(); 221 } 222 223 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()224 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 225 return ProductSearchStubSettings.defaultCredentialsProviderBuilder(); 226 } 227 228 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()229 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 230 return ProductSearchStubSettings.defaultGrpcTransportProviderBuilder(); 231 } 232 233 /** Returns a builder for the default REST ChannelProvider for this service. */ 234 @BetaApi 235 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()236 defaultHttpJsonTransportProviderBuilder() { 237 return ProductSearchStubSettings.defaultHttpJsonTransportProviderBuilder(); 238 } 239 defaultTransportChannelProvider()240 public static TransportChannelProvider defaultTransportChannelProvider() { 241 return ProductSearchStubSettings.defaultTransportChannelProvider(); 242 } 243 244 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()245 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 246 return ProductSearchStubSettings.defaultApiClientHeaderProviderBuilder(); 247 } 248 249 /** Returns a new gRPC builder for this class. */ newBuilder()250 public static Builder newBuilder() { 251 return Builder.createDefault(); 252 } 253 254 /** Returns a new REST builder for this class. */ 255 @BetaApi newHttpJsonBuilder()256 public static Builder newHttpJsonBuilder() { 257 return Builder.createHttpJsonDefault(); 258 } 259 260 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)261 public static Builder newBuilder(ClientContext clientContext) { 262 return new Builder(clientContext); 263 } 264 265 /** Returns a builder containing all the values of this settings class. */ toBuilder()266 public Builder toBuilder() { 267 return new Builder(this); 268 } 269 ProductSearchSettings(Builder settingsBuilder)270 protected ProductSearchSettings(Builder settingsBuilder) throws IOException { 271 super(settingsBuilder); 272 } 273 274 /** Builder for ProductSearchSettings. */ 275 public static class Builder extends ClientSettings.Builder<ProductSearchSettings, Builder> { 276 Builder()277 protected Builder() throws IOException { 278 this(((ClientContext) null)); 279 } 280 Builder(ClientContext clientContext)281 protected Builder(ClientContext clientContext) { 282 super(ProductSearchStubSettings.newBuilder(clientContext)); 283 } 284 Builder(ProductSearchSettings settings)285 protected Builder(ProductSearchSettings settings) { 286 super(settings.getStubSettings().toBuilder()); 287 } 288 Builder(ProductSearchStubSettings.Builder stubSettings)289 protected Builder(ProductSearchStubSettings.Builder stubSettings) { 290 super(stubSettings); 291 } 292 createDefault()293 private static Builder createDefault() { 294 return new Builder(ProductSearchStubSettings.newBuilder()); 295 } 296 297 @BetaApi createHttpJsonDefault()298 private static Builder createHttpJsonDefault() { 299 return new Builder(ProductSearchStubSettings.newHttpJsonBuilder()); 300 } 301 getStubSettingsBuilder()302 public ProductSearchStubSettings.Builder getStubSettingsBuilder() { 303 return ((ProductSearchStubSettings.Builder) getStubSettings()); 304 } 305 306 /** 307 * Applies the given settings updater function to all of the unary API methods in this service. 308 * 309 * <p>Note: This method does not support applying settings to streaming methods. 310 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)311 public Builder applyToAllUnaryMethods( 312 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 313 super.applyToAllUnaryMethods( 314 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 315 return this; 316 } 317 318 /** Returns the builder for the settings used for calls to createProductSet. */ 319 public UnaryCallSettings.Builder<CreateProductSetRequest, ProductSet> createProductSetSettings()320 createProductSetSettings() { 321 return getStubSettingsBuilder().createProductSetSettings(); 322 } 323 324 /** Returns the builder for the settings used for calls to listProductSets. */ 325 public PagedCallSettings.Builder< 326 ListProductSetsRequest, ListProductSetsResponse, ListProductSetsPagedResponse> listProductSetsSettings()327 listProductSetsSettings() { 328 return getStubSettingsBuilder().listProductSetsSettings(); 329 } 330 331 /** Returns the builder for the settings used for calls to getProductSet. */ getProductSetSettings()332 public UnaryCallSettings.Builder<GetProductSetRequest, ProductSet> getProductSetSettings() { 333 return getStubSettingsBuilder().getProductSetSettings(); 334 } 335 336 /** Returns the builder for the settings used for calls to updateProductSet. */ 337 public UnaryCallSettings.Builder<UpdateProductSetRequest, ProductSet> updateProductSetSettings()338 updateProductSetSettings() { 339 return getStubSettingsBuilder().updateProductSetSettings(); 340 } 341 342 /** Returns the builder for the settings used for calls to deleteProductSet. */ deleteProductSetSettings()343 public UnaryCallSettings.Builder<DeleteProductSetRequest, Empty> deleteProductSetSettings() { 344 return getStubSettingsBuilder().deleteProductSetSettings(); 345 } 346 347 /** Returns the builder for the settings used for calls to createProduct. */ createProductSettings()348 public UnaryCallSettings.Builder<CreateProductRequest, Product> createProductSettings() { 349 return getStubSettingsBuilder().createProductSettings(); 350 } 351 352 /** Returns the builder for the settings used for calls to listProducts. */ 353 public PagedCallSettings.Builder< 354 ListProductsRequest, ListProductsResponse, ListProductsPagedResponse> listProductsSettings()355 listProductsSettings() { 356 return getStubSettingsBuilder().listProductsSettings(); 357 } 358 359 /** Returns the builder for the settings used for calls to getProduct. */ getProductSettings()360 public UnaryCallSettings.Builder<GetProductRequest, Product> getProductSettings() { 361 return getStubSettingsBuilder().getProductSettings(); 362 } 363 364 /** Returns the builder for the settings used for calls to updateProduct. */ updateProductSettings()365 public UnaryCallSettings.Builder<UpdateProductRequest, Product> updateProductSettings() { 366 return getStubSettingsBuilder().updateProductSettings(); 367 } 368 369 /** Returns the builder for the settings used for calls to deleteProduct. */ deleteProductSettings()370 public UnaryCallSettings.Builder<DeleteProductRequest, Empty> deleteProductSettings() { 371 return getStubSettingsBuilder().deleteProductSettings(); 372 } 373 374 /** Returns the builder for the settings used for calls to createReferenceImage. */ 375 public UnaryCallSettings.Builder<CreateReferenceImageRequest, ReferenceImage> createReferenceImageSettings()376 createReferenceImageSettings() { 377 return getStubSettingsBuilder().createReferenceImageSettings(); 378 } 379 380 /** Returns the builder for the settings used for calls to deleteReferenceImage. */ 381 public UnaryCallSettings.Builder<DeleteReferenceImageRequest, Empty> deleteReferenceImageSettings()382 deleteReferenceImageSettings() { 383 return getStubSettingsBuilder().deleteReferenceImageSettings(); 384 } 385 386 /** Returns the builder for the settings used for calls to listReferenceImages. */ 387 public PagedCallSettings.Builder< 388 ListReferenceImagesRequest, 389 ListReferenceImagesResponse, 390 ListReferenceImagesPagedResponse> listReferenceImagesSettings()391 listReferenceImagesSettings() { 392 return getStubSettingsBuilder().listReferenceImagesSettings(); 393 } 394 395 /** Returns the builder for the settings used for calls to getReferenceImage. */ 396 public UnaryCallSettings.Builder<GetReferenceImageRequest, ReferenceImage> getReferenceImageSettings()397 getReferenceImageSettings() { 398 return getStubSettingsBuilder().getReferenceImageSettings(); 399 } 400 401 /** Returns the builder for the settings used for calls to addProductToProductSet. */ 402 public UnaryCallSettings.Builder<AddProductToProductSetRequest, Empty> addProductToProductSetSettings()403 addProductToProductSetSettings() { 404 return getStubSettingsBuilder().addProductToProductSetSettings(); 405 } 406 407 /** Returns the builder for the settings used for calls to removeProductFromProductSet. */ 408 public UnaryCallSettings.Builder<RemoveProductFromProductSetRequest, Empty> removeProductFromProductSetSettings()409 removeProductFromProductSetSettings() { 410 return getStubSettingsBuilder().removeProductFromProductSetSettings(); 411 } 412 413 /** Returns the builder for the settings used for calls to listProductsInProductSet. */ 414 public PagedCallSettings.Builder< 415 ListProductsInProductSetRequest, 416 ListProductsInProductSetResponse, 417 ListProductsInProductSetPagedResponse> listProductsInProductSetSettings()418 listProductsInProductSetSettings() { 419 return getStubSettingsBuilder().listProductsInProductSetSettings(); 420 } 421 422 /** Returns the builder for the settings used for calls to importProductSets. */ 423 public UnaryCallSettings.Builder<ImportProductSetsRequest, Operation> importProductSetsSettings()424 importProductSetsSettings() { 425 return getStubSettingsBuilder().importProductSetsSettings(); 426 } 427 428 /** Returns the builder for the settings used for calls to importProductSets. */ 429 public OperationCallSettings.Builder< 430 ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> importProductSetsOperationSettings()431 importProductSetsOperationSettings() { 432 return getStubSettingsBuilder().importProductSetsOperationSettings(); 433 } 434 435 /** Returns the builder for the settings used for calls to purgeProducts. */ purgeProductsSettings()436 public UnaryCallSettings.Builder<PurgeProductsRequest, Operation> purgeProductsSettings() { 437 return getStubSettingsBuilder().purgeProductsSettings(); 438 } 439 440 /** Returns the builder for the settings used for calls to purgeProducts. */ 441 public OperationCallSettings.Builder<PurgeProductsRequest, Empty, BatchOperationMetadata> purgeProductsOperationSettings()442 purgeProductsOperationSettings() { 443 return getStubSettingsBuilder().purgeProductsOperationSettings(); 444 } 445 446 @Override build()447 public ProductSearchSettings build() throws IOException { 448 return new ProductSearchSettings(this); 449 } 450 } 451 } 452