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