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 static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductSetsPagedResponse; 20 import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsInProductSetPagedResponse; 21 import static com.google.cloud.vision.v1p3beta1.ProductSearchClient.ListProductsPagedResponse; 22 import static com.google.cloud.vision.v1p3beta1.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.v1p3beta1.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 create(ProductSearchStubSettings stub)192 public static final ProductSearchSettings create(ProductSearchStubSettings stub) 193 throws IOException { 194 return new ProductSearchSettings.Builder(stub.toBuilder()).build(); 195 } 196 197 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()198 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 199 return ProductSearchStubSettings.defaultExecutorProviderBuilder(); 200 } 201 202 /** Returns the default service endpoint. */ getDefaultEndpoint()203 public static String getDefaultEndpoint() { 204 return ProductSearchStubSettings.getDefaultEndpoint(); 205 } 206 207 /** Returns the default service scopes. */ getDefaultServiceScopes()208 public static List<String> getDefaultServiceScopes() { 209 return ProductSearchStubSettings.getDefaultServiceScopes(); 210 } 211 212 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()213 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 214 return ProductSearchStubSettings.defaultCredentialsProviderBuilder(); 215 } 216 217 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()218 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 219 return ProductSearchStubSettings.defaultGrpcTransportProviderBuilder(); 220 } 221 222 /** Returns a builder for the default REST ChannelProvider for this service. */ 223 @BetaApi 224 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()225 defaultHttpJsonTransportProviderBuilder() { 226 return ProductSearchStubSettings.defaultHttpJsonTransportProviderBuilder(); 227 } 228 defaultTransportChannelProvider()229 public static TransportChannelProvider defaultTransportChannelProvider() { 230 return ProductSearchStubSettings.defaultTransportChannelProvider(); 231 } 232 233 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()234 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 235 return ProductSearchStubSettings.defaultApiClientHeaderProviderBuilder(); 236 } 237 238 /** Returns a new gRPC builder for this class. */ newBuilder()239 public static Builder newBuilder() { 240 return Builder.createDefault(); 241 } 242 243 /** Returns a new REST builder for this class. */ 244 @BetaApi newHttpJsonBuilder()245 public static Builder newHttpJsonBuilder() { 246 return Builder.createHttpJsonDefault(); 247 } 248 249 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)250 public static Builder newBuilder(ClientContext clientContext) { 251 return new Builder(clientContext); 252 } 253 254 /** Returns a builder containing all the values of this settings class. */ toBuilder()255 public Builder toBuilder() { 256 return new Builder(this); 257 } 258 ProductSearchSettings(Builder settingsBuilder)259 protected ProductSearchSettings(Builder settingsBuilder) throws IOException { 260 super(settingsBuilder); 261 } 262 263 /** Builder for ProductSearchSettings. */ 264 public static class Builder extends ClientSettings.Builder<ProductSearchSettings, Builder> { 265 Builder()266 protected Builder() throws IOException { 267 this(((ClientContext) null)); 268 } 269 Builder(ClientContext clientContext)270 protected Builder(ClientContext clientContext) { 271 super(ProductSearchStubSettings.newBuilder(clientContext)); 272 } 273 Builder(ProductSearchSettings settings)274 protected Builder(ProductSearchSettings settings) { 275 super(settings.getStubSettings().toBuilder()); 276 } 277 Builder(ProductSearchStubSettings.Builder stubSettings)278 protected Builder(ProductSearchStubSettings.Builder stubSettings) { 279 super(stubSettings); 280 } 281 createDefault()282 private static Builder createDefault() { 283 return new Builder(ProductSearchStubSettings.newBuilder()); 284 } 285 286 @BetaApi createHttpJsonDefault()287 private static Builder createHttpJsonDefault() { 288 return new Builder(ProductSearchStubSettings.newHttpJsonBuilder()); 289 } 290 getStubSettingsBuilder()291 public ProductSearchStubSettings.Builder getStubSettingsBuilder() { 292 return ((ProductSearchStubSettings.Builder) getStubSettings()); 293 } 294 295 /** 296 * Applies the given settings updater function to all of the unary API methods in this service. 297 * 298 * <p>Note: This method does not support applying settings to streaming methods. 299 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)300 public Builder applyToAllUnaryMethods( 301 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 302 super.applyToAllUnaryMethods( 303 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 304 return this; 305 } 306 307 /** Returns the builder for the settings used for calls to createProductSet. */ 308 public UnaryCallSettings.Builder<CreateProductSetRequest, ProductSet> createProductSetSettings()309 createProductSetSettings() { 310 return getStubSettingsBuilder().createProductSetSettings(); 311 } 312 313 /** Returns the builder for the settings used for calls to listProductSets. */ 314 public PagedCallSettings.Builder< 315 ListProductSetsRequest, ListProductSetsResponse, ListProductSetsPagedResponse> listProductSetsSettings()316 listProductSetsSettings() { 317 return getStubSettingsBuilder().listProductSetsSettings(); 318 } 319 320 /** Returns the builder for the settings used for calls to getProductSet. */ getProductSetSettings()321 public UnaryCallSettings.Builder<GetProductSetRequest, ProductSet> getProductSetSettings() { 322 return getStubSettingsBuilder().getProductSetSettings(); 323 } 324 325 /** Returns the builder for the settings used for calls to updateProductSet. */ 326 public UnaryCallSettings.Builder<UpdateProductSetRequest, ProductSet> updateProductSetSettings()327 updateProductSetSettings() { 328 return getStubSettingsBuilder().updateProductSetSettings(); 329 } 330 331 /** Returns the builder for the settings used for calls to deleteProductSet. */ deleteProductSetSettings()332 public UnaryCallSettings.Builder<DeleteProductSetRequest, Empty> deleteProductSetSettings() { 333 return getStubSettingsBuilder().deleteProductSetSettings(); 334 } 335 336 /** Returns the builder for the settings used for calls to createProduct. */ createProductSettings()337 public UnaryCallSettings.Builder<CreateProductRequest, Product> createProductSettings() { 338 return getStubSettingsBuilder().createProductSettings(); 339 } 340 341 /** Returns the builder for the settings used for calls to listProducts. */ 342 public PagedCallSettings.Builder< 343 ListProductsRequest, ListProductsResponse, ListProductsPagedResponse> listProductsSettings()344 listProductsSettings() { 345 return getStubSettingsBuilder().listProductsSettings(); 346 } 347 348 /** Returns the builder for the settings used for calls to getProduct. */ getProductSettings()349 public UnaryCallSettings.Builder<GetProductRequest, Product> getProductSettings() { 350 return getStubSettingsBuilder().getProductSettings(); 351 } 352 353 /** Returns the builder for the settings used for calls to updateProduct. */ updateProductSettings()354 public UnaryCallSettings.Builder<UpdateProductRequest, Product> updateProductSettings() { 355 return getStubSettingsBuilder().updateProductSettings(); 356 } 357 358 /** Returns the builder for the settings used for calls to deleteProduct. */ deleteProductSettings()359 public UnaryCallSettings.Builder<DeleteProductRequest, Empty> deleteProductSettings() { 360 return getStubSettingsBuilder().deleteProductSettings(); 361 } 362 363 /** Returns the builder for the settings used for calls to createReferenceImage. */ 364 public UnaryCallSettings.Builder<CreateReferenceImageRequest, ReferenceImage> createReferenceImageSettings()365 createReferenceImageSettings() { 366 return getStubSettingsBuilder().createReferenceImageSettings(); 367 } 368 369 /** Returns the builder for the settings used for calls to deleteReferenceImage. */ 370 public UnaryCallSettings.Builder<DeleteReferenceImageRequest, Empty> deleteReferenceImageSettings()371 deleteReferenceImageSettings() { 372 return getStubSettingsBuilder().deleteReferenceImageSettings(); 373 } 374 375 /** Returns the builder for the settings used for calls to listReferenceImages. */ 376 public PagedCallSettings.Builder< 377 ListReferenceImagesRequest, 378 ListReferenceImagesResponse, 379 ListReferenceImagesPagedResponse> listReferenceImagesSettings()380 listReferenceImagesSettings() { 381 return getStubSettingsBuilder().listReferenceImagesSettings(); 382 } 383 384 /** Returns the builder for the settings used for calls to getReferenceImage. */ 385 public UnaryCallSettings.Builder<GetReferenceImageRequest, ReferenceImage> getReferenceImageSettings()386 getReferenceImageSettings() { 387 return getStubSettingsBuilder().getReferenceImageSettings(); 388 } 389 390 /** Returns the builder for the settings used for calls to addProductToProductSet. */ 391 public UnaryCallSettings.Builder<AddProductToProductSetRequest, Empty> addProductToProductSetSettings()392 addProductToProductSetSettings() { 393 return getStubSettingsBuilder().addProductToProductSetSettings(); 394 } 395 396 /** Returns the builder for the settings used for calls to removeProductFromProductSet. */ 397 public UnaryCallSettings.Builder<RemoveProductFromProductSetRequest, Empty> removeProductFromProductSetSettings()398 removeProductFromProductSetSettings() { 399 return getStubSettingsBuilder().removeProductFromProductSetSettings(); 400 } 401 402 /** Returns the builder for the settings used for calls to listProductsInProductSet. */ 403 public PagedCallSettings.Builder< 404 ListProductsInProductSetRequest, 405 ListProductsInProductSetResponse, 406 ListProductsInProductSetPagedResponse> listProductsInProductSetSettings()407 listProductsInProductSetSettings() { 408 return getStubSettingsBuilder().listProductsInProductSetSettings(); 409 } 410 411 /** Returns the builder for the settings used for calls to importProductSets. */ 412 public UnaryCallSettings.Builder<ImportProductSetsRequest, Operation> importProductSetsSettings()413 importProductSetsSettings() { 414 return getStubSettingsBuilder().importProductSetsSettings(); 415 } 416 417 /** Returns the builder for the settings used for calls to importProductSets. */ 418 public OperationCallSettings.Builder< 419 ImportProductSetsRequest, ImportProductSetsResponse, BatchOperationMetadata> importProductSetsOperationSettings()420 importProductSetsOperationSettings() { 421 return getStubSettingsBuilder().importProductSetsOperationSettings(); 422 } 423 424 @Override build()425 public ProductSearchSettings build() throws IOException { 426 return new ProductSearchSettings(this); 427 } 428 } 429 } 430