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