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.retail.v2.stub; 18 19 import static com.google.cloud.retail.v2.CatalogServiceClient.ListCatalogsPagedResponse; 20 21 import com.google.api.core.ApiFunction; 22 import com.google.api.core.ApiFuture; 23 import com.google.api.core.BetaApi; 24 import com.google.api.gax.core.GaxProperties; 25 import com.google.api.gax.core.GoogleCredentialsProvider; 26 import com.google.api.gax.core.InstantiatingExecutorProvider; 27 import com.google.api.gax.grpc.GaxGrpcProperties; 28 import com.google.api.gax.grpc.GrpcTransportChannel; 29 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; 30 import com.google.api.gax.httpjson.GaxHttpJsonProperties; 31 import com.google.api.gax.httpjson.HttpJsonTransportChannel; 32 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 33 import com.google.api.gax.retrying.RetrySettings; 34 import com.google.api.gax.rpc.ApiCallContext; 35 import com.google.api.gax.rpc.ApiClientHeaderProvider; 36 import com.google.api.gax.rpc.ClientContext; 37 import com.google.api.gax.rpc.PageContext; 38 import com.google.api.gax.rpc.PagedCallSettings; 39 import com.google.api.gax.rpc.PagedListDescriptor; 40 import com.google.api.gax.rpc.PagedListResponseFactory; 41 import com.google.api.gax.rpc.StatusCode; 42 import com.google.api.gax.rpc.StubSettings; 43 import com.google.api.gax.rpc.TransportChannelProvider; 44 import com.google.api.gax.rpc.UnaryCallSettings; 45 import com.google.api.gax.rpc.UnaryCallable; 46 import com.google.cloud.retail.v2.AddCatalogAttributeRequest; 47 import com.google.cloud.retail.v2.AttributesConfig; 48 import com.google.cloud.retail.v2.Catalog; 49 import com.google.cloud.retail.v2.CompletionConfig; 50 import com.google.cloud.retail.v2.GetAttributesConfigRequest; 51 import com.google.cloud.retail.v2.GetCompletionConfigRequest; 52 import com.google.cloud.retail.v2.GetDefaultBranchRequest; 53 import com.google.cloud.retail.v2.GetDefaultBranchResponse; 54 import com.google.cloud.retail.v2.ListCatalogsRequest; 55 import com.google.cloud.retail.v2.ListCatalogsResponse; 56 import com.google.cloud.retail.v2.RemoveCatalogAttributeRequest; 57 import com.google.cloud.retail.v2.ReplaceCatalogAttributeRequest; 58 import com.google.cloud.retail.v2.SetDefaultBranchRequest; 59 import com.google.cloud.retail.v2.UpdateAttributesConfigRequest; 60 import com.google.cloud.retail.v2.UpdateCatalogRequest; 61 import com.google.cloud.retail.v2.UpdateCompletionConfigRequest; 62 import com.google.common.collect.ImmutableList; 63 import com.google.common.collect.ImmutableMap; 64 import com.google.common.collect.ImmutableSet; 65 import com.google.common.collect.Lists; 66 import com.google.protobuf.Empty; 67 import java.io.IOException; 68 import java.util.List; 69 import javax.annotation.Generated; 70 import org.threeten.bp.Duration; 71 72 // AUTO-GENERATED DOCUMENTATION AND CLASS. 73 /** 74 * Settings class to configure an instance of {@link CatalogServiceStub}. 75 * 76 * <p>The default instance has everything set to sensible defaults: 77 * 78 * <ul> 79 * <li>The default service address (retail.googleapis.com) and default port (443) are used. 80 * <li>Credentials are acquired automatically through Application Default Credentials. 81 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 82 * </ul> 83 * 84 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 85 * build() is called, the tree of builders is called to create the complete settings object. 86 * 87 * <p>For example, to set the total timeout of updateCatalog to 30 seconds: 88 * 89 * <pre>{@code 90 * // This snippet has been automatically generated and should be regarded as a code template only. 91 * // It will require modifications to work: 92 * // - It may require correct/in-range values for request initialization. 93 * // - It may require specifying regional endpoints when creating the service client as shown in 94 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 95 * CatalogServiceStubSettings.Builder catalogServiceSettingsBuilder = 96 * CatalogServiceStubSettings.newBuilder(); 97 * catalogServiceSettingsBuilder 98 * .updateCatalogSettings() 99 * .setRetrySettings( 100 * catalogServiceSettingsBuilder 101 * .updateCatalogSettings() 102 * .getRetrySettings() 103 * .toBuilder() 104 * .setTotalTimeout(Duration.ofSeconds(30)) 105 * .build()); 106 * CatalogServiceStubSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); 107 * }</pre> 108 */ 109 @Generated("by gapic-generator-java") 110 public class CatalogServiceStubSettings extends StubSettings<CatalogServiceStubSettings> { 111 /** The default scopes of the service. */ 112 private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES = 113 ImmutableList.<String>builder().add("https://www.googleapis.com/auth/cloud-platform").build(); 114 115 private final PagedCallSettings< 116 ListCatalogsRequest, ListCatalogsResponse, ListCatalogsPagedResponse> 117 listCatalogsSettings; 118 private final UnaryCallSettings<UpdateCatalogRequest, Catalog> updateCatalogSettings; 119 private final UnaryCallSettings<SetDefaultBranchRequest, Empty> setDefaultBranchSettings; 120 private final UnaryCallSettings<GetDefaultBranchRequest, GetDefaultBranchResponse> 121 getDefaultBranchSettings; 122 private final UnaryCallSettings<GetCompletionConfigRequest, CompletionConfig> 123 getCompletionConfigSettings; 124 private final UnaryCallSettings<UpdateCompletionConfigRequest, CompletionConfig> 125 updateCompletionConfigSettings; 126 private final UnaryCallSettings<GetAttributesConfigRequest, AttributesConfig> 127 getAttributesConfigSettings; 128 private final UnaryCallSettings<UpdateAttributesConfigRequest, AttributesConfig> 129 updateAttributesConfigSettings; 130 private final UnaryCallSettings<AddCatalogAttributeRequest, AttributesConfig> 131 addCatalogAttributeSettings; 132 private final UnaryCallSettings<RemoveCatalogAttributeRequest, AttributesConfig> 133 removeCatalogAttributeSettings; 134 private final UnaryCallSettings<ReplaceCatalogAttributeRequest, AttributesConfig> 135 replaceCatalogAttributeSettings; 136 137 private static final PagedListDescriptor<ListCatalogsRequest, ListCatalogsResponse, Catalog> 138 LIST_CATALOGS_PAGE_STR_DESC = 139 new PagedListDescriptor<ListCatalogsRequest, ListCatalogsResponse, Catalog>() { 140 @Override 141 public String emptyToken() { 142 return ""; 143 } 144 145 @Override 146 public ListCatalogsRequest injectToken(ListCatalogsRequest payload, String token) { 147 return ListCatalogsRequest.newBuilder(payload).setPageToken(token).build(); 148 } 149 150 @Override 151 public ListCatalogsRequest injectPageSize(ListCatalogsRequest payload, int pageSize) { 152 return ListCatalogsRequest.newBuilder(payload).setPageSize(pageSize).build(); 153 } 154 155 @Override 156 public Integer extractPageSize(ListCatalogsRequest payload) { 157 return payload.getPageSize(); 158 } 159 160 @Override 161 public String extractNextToken(ListCatalogsResponse payload) { 162 return payload.getNextPageToken(); 163 } 164 165 @Override 166 public Iterable<Catalog> extractResources(ListCatalogsResponse payload) { 167 return payload.getCatalogsList() == null 168 ? ImmutableList.<Catalog>of() 169 : payload.getCatalogsList(); 170 } 171 }; 172 173 private static final PagedListResponseFactory< 174 ListCatalogsRequest, ListCatalogsResponse, ListCatalogsPagedResponse> 175 LIST_CATALOGS_PAGE_STR_FACT = 176 new PagedListResponseFactory< 177 ListCatalogsRequest, ListCatalogsResponse, ListCatalogsPagedResponse>() { 178 @Override 179 public ApiFuture<ListCatalogsPagedResponse> getFuturePagedResponse( 180 UnaryCallable<ListCatalogsRequest, ListCatalogsResponse> callable, 181 ListCatalogsRequest request, 182 ApiCallContext context, 183 ApiFuture<ListCatalogsResponse> futureResponse) { 184 PageContext<ListCatalogsRequest, ListCatalogsResponse, Catalog> pageContext = 185 PageContext.create(callable, LIST_CATALOGS_PAGE_STR_DESC, request, context); 186 return ListCatalogsPagedResponse.createAsync(pageContext, futureResponse); 187 } 188 }; 189 190 /** Returns the object with the settings used for calls to listCatalogs. */ 191 public PagedCallSettings<ListCatalogsRequest, ListCatalogsResponse, ListCatalogsPagedResponse> listCatalogsSettings()192 listCatalogsSettings() { 193 return listCatalogsSettings; 194 } 195 196 /** Returns the object with the settings used for calls to updateCatalog. */ updateCatalogSettings()197 public UnaryCallSettings<UpdateCatalogRequest, Catalog> updateCatalogSettings() { 198 return updateCatalogSettings; 199 } 200 201 /** Returns the object with the settings used for calls to setDefaultBranch. */ setDefaultBranchSettings()202 public UnaryCallSettings<SetDefaultBranchRequest, Empty> setDefaultBranchSettings() { 203 return setDefaultBranchSettings; 204 } 205 206 /** Returns the object with the settings used for calls to getDefaultBranch. */ 207 public UnaryCallSettings<GetDefaultBranchRequest, GetDefaultBranchResponse> getDefaultBranchSettings()208 getDefaultBranchSettings() { 209 return getDefaultBranchSettings; 210 } 211 212 /** Returns the object with the settings used for calls to getCompletionConfig. */ 213 public UnaryCallSettings<GetCompletionConfigRequest, CompletionConfig> getCompletionConfigSettings()214 getCompletionConfigSettings() { 215 return getCompletionConfigSettings; 216 } 217 218 /** Returns the object with the settings used for calls to updateCompletionConfig. */ 219 public UnaryCallSettings<UpdateCompletionConfigRequest, CompletionConfig> updateCompletionConfigSettings()220 updateCompletionConfigSettings() { 221 return updateCompletionConfigSettings; 222 } 223 224 /** Returns the object with the settings used for calls to getAttributesConfig. */ 225 public UnaryCallSettings<GetAttributesConfigRequest, AttributesConfig> getAttributesConfigSettings()226 getAttributesConfigSettings() { 227 return getAttributesConfigSettings; 228 } 229 230 /** Returns the object with the settings used for calls to updateAttributesConfig. */ 231 public UnaryCallSettings<UpdateAttributesConfigRequest, AttributesConfig> updateAttributesConfigSettings()232 updateAttributesConfigSettings() { 233 return updateAttributesConfigSettings; 234 } 235 236 /** Returns the object with the settings used for calls to addCatalogAttribute. */ 237 public UnaryCallSettings<AddCatalogAttributeRequest, AttributesConfig> addCatalogAttributeSettings()238 addCatalogAttributeSettings() { 239 return addCatalogAttributeSettings; 240 } 241 242 /** Returns the object with the settings used for calls to removeCatalogAttribute. */ 243 public UnaryCallSettings<RemoveCatalogAttributeRequest, AttributesConfig> removeCatalogAttributeSettings()244 removeCatalogAttributeSettings() { 245 return removeCatalogAttributeSettings; 246 } 247 248 /** Returns the object with the settings used for calls to replaceCatalogAttribute. */ 249 public UnaryCallSettings<ReplaceCatalogAttributeRequest, AttributesConfig> replaceCatalogAttributeSettings()250 replaceCatalogAttributeSettings() { 251 return replaceCatalogAttributeSettings; 252 } 253 createStub()254 public CatalogServiceStub createStub() throws IOException { 255 if (getTransportChannelProvider() 256 .getTransportName() 257 .equals(GrpcTransportChannel.getGrpcTransportName())) { 258 return GrpcCatalogServiceStub.create(this); 259 } 260 if (getTransportChannelProvider() 261 .getTransportName() 262 .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { 263 return HttpJsonCatalogServiceStub.create(this); 264 } 265 throw new UnsupportedOperationException( 266 String.format( 267 "Transport not supported: %s", getTransportChannelProvider().getTransportName())); 268 } 269 270 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()271 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 272 return InstantiatingExecutorProvider.newBuilder(); 273 } 274 275 /** Returns the default service endpoint. */ getDefaultEndpoint()276 public static String getDefaultEndpoint() { 277 return "retail.googleapis.com:443"; 278 } 279 280 /** Returns the default mTLS service endpoint. */ getDefaultMtlsEndpoint()281 public static String getDefaultMtlsEndpoint() { 282 return "retail.mtls.googleapis.com:443"; 283 } 284 285 /** Returns the default service scopes. */ getDefaultServiceScopes()286 public static List<String> getDefaultServiceScopes() { 287 return DEFAULT_SERVICE_SCOPES; 288 } 289 290 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()291 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 292 return GoogleCredentialsProvider.newBuilder() 293 .setScopesToApply(DEFAULT_SERVICE_SCOPES) 294 .setUseJwtAccessWithScope(true); 295 } 296 297 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()298 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 299 return InstantiatingGrpcChannelProvider.newBuilder() 300 .setMaxInboundMessageSize(Integer.MAX_VALUE); 301 } 302 303 /** Returns a builder for the default REST ChannelProvider for this service. */ 304 @BetaApi 305 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()306 defaultHttpJsonTransportProviderBuilder() { 307 return InstantiatingHttpJsonChannelProvider.newBuilder(); 308 } 309 defaultTransportChannelProvider()310 public static TransportChannelProvider defaultTransportChannelProvider() { 311 return defaultGrpcTransportProviderBuilder().build(); 312 } 313 314 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultGrpcApiClientHeaderProviderBuilder()315 public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { 316 return ApiClientHeaderProvider.newBuilder() 317 .setGeneratedLibToken( 318 "gapic", GaxProperties.getLibraryVersion(CatalogServiceStubSettings.class)) 319 .setTransportToken( 320 GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); 321 } 322 323 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultHttpJsonApiClientHeaderProviderBuilder()324 public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { 325 return ApiClientHeaderProvider.newBuilder() 326 .setGeneratedLibToken( 327 "gapic", GaxProperties.getLibraryVersion(CatalogServiceStubSettings.class)) 328 .setTransportToken( 329 GaxHttpJsonProperties.getHttpJsonTokenName(), 330 GaxHttpJsonProperties.getHttpJsonVersion()); 331 } 332 defaultApiClientHeaderProviderBuilder()333 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 334 return CatalogServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); 335 } 336 337 /** Returns a new gRPC builder for this class. */ newBuilder()338 public static Builder newBuilder() { 339 return Builder.createDefault(); 340 } 341 342 /** Returns a new REST builder for this class. */ newHttpJsonBuilder()343 public static Builder newHttpJsonBuilder() { 344 return Builder.createHttpJsonDefault(); 345 } 346 347 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)348 public static Builder newBuilder(ClientContext clientContext) { 349 return new Builder(clientContext); 350 } 351 352 /** Returns a builder containing all the values of this settings class. */ toBuilder()353 public Builder toBuilder() { 354 return new Builder(this); 355 } 356 CatalogServiceStubSettings(Builder settingsBuilder)357 protected CatalogServiceStubSettings(Builder settingsBuilder) throws IOException { 358 super(settingsBuilder); 359 360 listCatalogsSettings = settingsBuilder.listCatalogsSettings().build(); 361 updateCatalogSettings = settingsBuilder.updateCatalogSettings().build(); 362 setDefaultBranchSettings = settingsBuilder.setDefaultBranchSettings().build(); 363 getDefaultBranchSettings = settingsBuilder.getDefaultBranchSettings().build(); 364 getCompletionConfigSettings = settingsBuilder.getCompletionConfigSettings().build(); 365 updateCompletionConfigSettings = settingsBuilder.updateCompletionConfigSettings().build(); 366 getAttributesConfigSettings = settingsBuilder.getAttributesConfigSettings().build(); 367 updateAttributesConfigSettings = settingsBuilder.updateAttributesConfigSettings().build(); 368 addCatalogAttributeSettings = settingsBuilder.addCatalogAttributeSettings().build(); 369 removeCatalogAttributeSettings = settingsBuilder.removeCatalogAttributeSettings().build(); 370 replaceCatalogAttributeSettings = settingsBuilder.replaceCatalogAttributeSettings().build(); 371 } 372 373 /** Builder for CatalogServiceStubSettings. */ 374 public static class Builder extends StubSettings.Builder<CatalogServiceStubSettings, Builder> { 375 private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders; 376 private final PagedCallSettings.Builder< 377 ListCatalogsRequest, ListCatalogsResponse, ListCatalogsPagedResponse> 378 listCatalogsSettings; 379 private final UnaryCallSettings.Builder<UpdateCatalogRequest, Catalog> updateCatalogSettings; 380 private final UnaryCallSettings.Builder<SetDefaultBranchRequest, Empty> 381 setDefaultBranchSettings; 382 private final UnaryCallSettings.Builder<GetDefaultBranchRequest, GetDefaultBranchResponse> 383 getDefaultBranchSettings; 384 private final UnaryCallSettings.Builder<GetCompletionConfigRequest, CompletionConfig> 385 getCompletionConfigSettings; 386 private final UnaryCallSettings.Builder<UpdateCompletionConfigRequest, CompletionConfig> 387 updateCompletionConfigSettings; 388 private final UnaryCallSettings.Builder<GetAttributesConfigRequest, AttributesConfig> 389 getAttributesConfigSettings; 390 private final UnaryCallSettings.Builder<UpdateAttributesConfigRequest, AttributesConfig> 391 updateAttributesConfigSettings; 392 private final UnaryCallSettings.Builder<AddCatalogAttributeRequest, AttributesConfig> 393 addCatalogAttributeSettings; 394 private final UnaryCallSettings.Builder<RemoveCatalogAttributeRequest, AttributesConfig> 395 removeCatalogAttributeSettings; 396 private final UnaryCallSettings.Builder<ReplaceCatalogAttributeRequest, AttributesConfig> 397 replaceCatalogAttributeSettings; 398 private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>> 399 RETRYABLE_CODE_DEFINITIONS; 400 401 static { 402 ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions = 403 ImmutableMap.builder(); 404 definitions.put( 405 "retry_policy_0_codes", 406 ImmutableSet.copyOf( 407 Lists.<StatusCode.Code>newArrayList( 408 StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); 409 RETRYABLE_CODE_DEFINITIONS = definitions.build(); 410 } 411 412 private static final ImmutableMap<String, RetrySettings> RETRY_PARAM_DEFINITIONS; 413 414 static { 415 ImmutableMap.Builder<String, RetrySettings> definitions = ImmutableMap.builder(); 416 RetrySettings settings = null; 417 settings = 418 RetrySettings.newBuilder() 419 .setInitialRetryDelay(Duration.ofMillis(100L)) 420 .setRetryDelayMultiplier(1.3) 421 .setMaxRetryDelay(Duration.ofMillis(5000L)) 422 .setInitialRpcTimeout(Duration.ofMillis(5000L)) 423 .setRpcTimeoutMultiplier(1.0) 424 .setMaxRpcTimeout(Duration.ofMillis(5000L)) 425 .setTotalTimeout(Duration.ofMillis(5000L)) 426 .build(); 427 definitions.put("retry_policy_0_params", settings); 428 RETRY_PARAM_DEFINITIONS = definitions.build(); 429 } 430 Builder()431 protected Builder() { 432 this(((ClientContext) null)); 433 } 434 Builder(ClientContext clientContext)435 protected Builder(ClientContext clientContext) { 436 super(clientContext); 437 438 listCatalogsSettings = PagedCallSettings.newBuilder(LIST_CATALOGS_PAGE_STR_FACT); 439 updateCatalogSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 440 setDefaultBranchSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 441 getDefaultBranchSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 442 getCompletionConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 443 updateCompletionConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 444 getAttributesConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 445 updateAttributesConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 446 addCatalogAttributeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 447 removeCatalogAttributeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 448 replaceCatalogAttributeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 449 450 unaryMethodSettingsBuilders = 451 ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( 452 listCatalogsSettings, 453 updateCatalogSettings, 454 setDefaultBranchSettings, 455 getDefaultBranchSettings, 456 getCompletionConfigSettings, 457 updateCompletionConfigSettings, 458 getAttributesConfigSettings, 459 updateAttributesConfigSettings, 460 addCatalogAttributeSettings, 461 removeCatalogAttributeSettings, 462 replaceCatalogAttributeSettings); 463 initDefaults(this); 464 } 465 Builder(CatalogServiceStubSettings settings)466 protected Builder(CatalogServiceStubSettings settings) { 467 super(settings); 468 469 listCatalogsSettings = settings.listCatalogsSettings.toBuilder(); 470 updateCatalogSettings = settings.updateCatalogSettings.toBuilder(); 471 setDefaultBranchSettings = settings.setDefaultBranchSettings.toBuilder(); 472 getDefaultBranchSettings = settings.getDefaultBranchSettings.toBuilder(); 473 getCompletionConfigSettings = settings.getCompletionConfigSettings.toBuilder(); 474 updateCompletionConfigSettings = settings.updateCompletionConfigSettings.toBuilder(); 475 getAttributesConfigSettings = settings.getAttributesConfigSettings.toBuilder(); 476 updateAttributesConfigSettings = settings.updateAttributesConfigSettings.toBuilder(); 477 addCatalogAttributeSettings = settings.addCatalogAttributeSettings.toBuilder(); 478 removeCatalogAttributeSettings = settings.removeCatalogAttributeSettings.toBuilder(); 479 replaceCatalogAttributeSettings = settings.replaceCatalogAttributeSettings.toBuilder(); 480 481 unaryMethodSettingsBuilders = 482 ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( 483 listCatalogsSettings, 484 updateCatalogSettings, 485 setDefaultBranchSettings, 486 getDefaultBranchSettings, 487 getCompletionConfigSettings, 488 updateCompletionConfigSettings, 489 getAttributesConfigSettings, 490 updateAttributesConfigSettings, 491 addCatalogAttributeSettings, 492 removeCatalogAttributeSettings, 493 replaceCatalogAttributeSettings); 494 } 495 createDefault()496 private static Builder createDefault() { 497 Builder builder = new Builder(((ClientContext) null)); 498 499 builder.setTransportChannelProvider(defaultTransportChannelProvider()); 500 builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); 501 builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); 502 builder.setEndpoint(getDefaultEndpoint()); 503 builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); 504 builder.setSwitchToMtlsEndpointAllowed(true); 505 506 return initDefaults(builder); 507 } 508 createHttpJsonDefault()509 private static Builder createHttpJsonDefault() { 510 Builder builder = new Builder(((ClientContext) null)); 511 512 builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); 513 builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); 514 builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); 515 builder.setEndpoint(getDefaultEndpoint()); 516 builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); 517 builder.setSwitchToMtlsEndpointAllowed(true); 518 519 return initDefaults(builder); 520 } 521 initDefaults(Builder builder)522 private static Builder initDefaults(Builder builder) { 523 builder 524 .listCatalogsSettings() 525 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 526 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 527 528 builder 529 .updateCatalogSettings() 530 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 531 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 532 533 builder 534 .setDefaultBranchSettings() 535 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 536 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 537 538 builder 539 .getDefaultBranchSettings() 540 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 541 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 542 543 builder 544 .getCompletionConfigSettings() 545 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 546 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 547 548 builder 549 .updateCompletionConfigSettings() 550 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 551 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 552 553 builder 554 .getAttributesConfigSettings() 555 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 556 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 557 558 builder 559 .updateAttributesConfigSettings() 560 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 561 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 562 563 builder 564 .addCatalogAttributeSettings() 565 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 566 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 567 568 builder 569 .removeCatalogAttributeSettings() 570 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 571 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 572 573 builder 574 .replaceCatalogAttributeSettings() 575 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) 576 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); 577 578 return builder; 579 } 580 581 /** 582 * Applies the given settings updater function to all of the unary API methods in this service. 583 * 584 * <p>Note: This method does not support applying settings to streaming methods. 585 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)586 public Builder applyToAllUnaryMethods( 587 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 588 super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); 589 return this; 590 } 591 unaryMethodSettingsBuilders()592 public ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders() { 593 return unaryMethodSettingsBuilders; 594 } 595 596 /** Returns the builder for the settings used for calls to listCatalogs. */ 597 public PagedCallSettings.Builder< 598 ListCatalogsRequest, ListCatalogsResponse, ListCatalogsPagedResponse> listCatalogsSettings()599 listCatalogsSettings() { 600 return listCatalogsSettings; 601 } 602 603 /** Returns the builder for the settings used for calls to updateCatalog. */ updateCatalogSettings()604 public UnaryCallSettings.Builder<UpdateCatalogRequest, Catalog> updateCatalogSettings() { 605 return updateCatalogSettings; 606 } 607 608 /** Returns the builder for the settings used for calls to setDefaultBranch. */ setDefaultBranchSettings()609 public UnaryCallSettings.Builder<SetDefaultBranchRequest, Empty> setDefaultBranchSettings() { 610 return setDefaultBranchSettings; 611 } 612 613 /** Returns the builder for the settings used for calls to getDefaultBranch. */ 614 public UnaryCallSettings.Builder<GetDefaultBranchRequest, GetDefaultBranchResponse> getDefaultBranchSettings()615 getDefaultBranchSettings() { 616 return getDefaultBranchSettings; 617 } 618 619 /** Returns the builder for the settings used for calls to getCompletionConfig. */ 620 public UnaryCallSettings.Builder<GetCompletionConfigRequest, CompletionConfig> getCompletionConfigSettings()621 getCompletionConfigSettings() { 622 return getCompletionConfigSettings; 623 } 624 625 /** Returns the builder for the settings used for calls to updateCompletionConfig. */ 626 public UnaryCallSettings.Builder<UpdateCompletionConfigRequest, CompletionConfig> updateCompletionConfigSettings()627 updateCompletionConfigSettings() { 628 return updateCompletionConfigSettings; 629 } 630 631 /** Returns the builder for the settings used for calls to getAttributesConfig. */ 632 public UnaryCallSettings.Builder<GetAttributesConfigRequest, AttributesConfig> getAttributesConfigSettings()633 getAttributesConfigSettings() { 634 return getAttributesConfigSettings; 635 } 636 637 /** Returns the builder for the settings used for calls to updateAttributesConfig. */ 638 public UnaryCallSettings.Builder<UpdateAttributesConfigRequest, AttributesConfig> updateAttributesConfigSettings()639 updateAttributesConfigSettings() { 640 return updateAttributesConfigSettings; 641 } 642 643 /** Returns the builder for the settings used for calls to addCatalogAttribute. */ 644 public UnaryCallSettings.Builder<AddCatalogAttributeRequest, AttributesConfig> addCatalogAttributeSettings()645 addCatalogAttributeSettings() { 646 return addCatalogAttributeSettings; 647 } 648 649 /** Returns the builder for the settings used for calls to removeCatalogAttribute. */ 650 public UnaryCallSettings.Builder<RemoveCatalogAttributeRequest, AttributesConfig> removeCatalogAttributeSettings()651 removeCatalogAttributeSettings() { 652 return removeCatalogAttributeSettings; 653 } 654 655 /** Returns the builder for the settings used for calls to replaceCatalogAttribute. */ 656 public UnaryCallSettings.Builder<ReplaceCatalogAttributeRequest, AttributesConfig> replaceCatalogAttributeSettings()657 replaceCatalogAttributeSettings() { 658 return replaceCatalogAttributeSettings; 659 } 660 661 @Override build()662 public CatalogServiceStubSettings build() throws IOException { 663 return new CatalogServiceStubSettings(this); 664 } 665 } 666 } 667