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.talent.v4.stub; 18 19 import static com.google.cloud.talent.v4.JobServiceClient.ListJobsPagedResponse; 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.grpc.ProtoOperationTransformers; 31 import com.google.api.gax.httpjson.GaxHttpJsonProperties; 32 import com.google.api.gax.httpjson.HttpJsonTransportChannel; 33 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 34 import com.google.api.gax.longrunning.OperationSnapshot; 35 import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; 36 import com.google.api.gax.retrying.RetrySettings; 37 import com.google.api.gax.rpc.ApiCallContext; 38 import com.google.api.gax.rpc.ApiClientHeaderProvider; 39 import com.google.api.gax.rpc.ClientContext; 40 import com.google.api.gax.rpc.OperationCallSettings; 41 import com.google.api.gax.rpc.PageContext; 42 import com.google.api.gax.rpc.PagedCallSettings; 43 import com.google.api.gax.rpc.PagedListDescriptor; 44 import com.google.api.gax.rpc.PagedListResponseFactory; 45 import com.google.api.gax.rpc.StatusCode; 46 import com.google.api.gax.rpc.StubSettings; 47 import com.google.api.gax.rpc.TransportChannelProvider; 48 import com.google.api.gax.rpc.UnaryCallSettings; 49 import com.google.api.gax.rpc.UnaryCallable; 50 import com.google.cloud.talent.v4.BatchCreateJobsRequest; 51 import com.google.cloud.talent.v4.BatchCreateJobsResponse; 52 import com.google.cloud.talent.v4.BatchDeleteJobsRequest; 53 import com.google.cloud.talent.v4.BatchDeleteJobsResponse; 54 import com.google.cloud.talent.v4.BatchOperationMetadata; 55 import com.google.cloud.talent.v4.BatchUpdateJobsRequest; 56 import com.google.cloud.talent.v4.BatchUpdateJobsResponse; 57 import com.google.cloud.talent.v4.CreateJobRequest; 58 import com.google.cloud.talent.v4.DeleteJobRequest; 59 import com.google.cloud.talent.v4.GetJobRequest; 60 import com.google.cloud.talent.v4.Job; 61 import com.google.cloud.talent.v4.ListJobsRequest; 62 import com.google.cloud.talent.v4.ListJobsResponse; 63 import com.google.cloud.talent.v4.SearchJobsRequest; 64 import com.google.cloud.talent.v4.SearchJobsResponse; 65 import com.google.cloud.talent.v4.UpdateJobRequest; 66 import com.google.common.collect.ImmutableList; 67 import com.google.common.collect.ImmutableMap; 68 import com.google.common.collect.ImmutableSet; 69 import com.google.common.collect.Lists; 70 import com.google.longrunning.Operation; 71 import com.google.protobuf.Empty; 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 JobServiceStub}. 80 * 81 * <p>The default instance has everything set to sensible defaults: 82 * 83 * <ul> 84 * <li>The default service address (jobs.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 createJob 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 * JobServiceStubSettings.Builder jobServiceSettingsBuilder = JobServiceStubSettings.newBuilder(); 101 * jobServiceSettingsBuilder 102 * .createJobSettings() 103 * .setRetrySettings( 104 * jobServiceSettingsBuilder 105 * .createJobSettings() 106 * .getRetrySettings() 107 * .toBuilder() 108 * .setTotalTimeout(Duration.ofSeconds(30)) 109 * .build()); 110 * JobServiceStubSettings jobServiceSettings = jobServiceSettingsBuilder.build(); 111 * }</pre> 112 */ 113 @Generated("by gapic-generator-java") 114 public class JobServiceStubSettings extends StubSettings<JobServiceStubSettings> { 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/jobs") 120 .build(); 121 122 private final UnaryCallSettings<CreateJobRequest, Job> createJobSettings; 123 private final UnaryCallSettings<BatchCreateJobsRequest, Operation> batchCreateJobsSettings; 124 private final OperationCallSettings< 125 BatchCreateJobsRequest, BatchCreateJobsResponse, BatchOperationMetadata> 126 batchCreateJobsOperationSettings; 127 private final UnaryCallSettings<GetJobRequest, Job> getJobSettings; 128 private final UnaryCallSettings<UpdateJobRequest, Job> updateJobSettings; 129 private final UnaryCallSettings<BatchUpdateJobsRequest, Operation> batchUpdateJobsSettings; 130 private final OperationCallSettings< 131 BatchUpdateJobsRequest, BatchUpdateJobsResponse, BatchOperationMetadata> 132 batchUpdateJobsOperationSettings; 133 private final UnaryCallSettings<DeleteJobRequest, Empty> deleteJobSettings; 134 private final UnaryCallSettings<BatchDeleteJobsRequest, Operation> batchDeleteJobsSettings; 135 private final OperationCallSettings< 136 BatchDeleteJobsRequest, BatchDeleteJobsResponse, BatchOperationMetadata> 137 batchDeleteJobsOperationSettings; 138 private final PagedCallSettings<ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> 139 listJobsSettings; 140 private final UnaryCallSettings<SearchJobsRequest, SearchJobsResponse> searchJobsSettings; 141 private final UnaryCallSettings<SearchJobsRequest, SearchJobsResponse> searchJobsForAlertSettings; 142 143 private static final PagedListDescriptor<ListJobsRequest, ListJobsResponse, Job> 144 LIST_JOBS_PAGE_STR_DESC = 145 new PagedListDescriptor<ListJobsRequest, ListJobsResponse, Job>() { 146 @Override 147 public String emptyToken() { 148 return ""; 149 } 150 151 @Override 152 public ListJobsRequest injectToken(ListJobsRequest payload, String token) { 153 return ListJobsRequest.newBuilder(payload).setPageToken(token).build(); 154 } 155 156 @Override 157 public ListJobsRequest injectPageSize(ListJobsRequest payload, int pageSize) { 158 return ListJobsRequest.newBuilder(payload).setPageSize(pageSize).build(); 159 } 160 161 @Override 162 public Integer extractPageSize(ListJobsRequest payload) { 163 return payload.getPageSize(); 164 } 165 166 @Override 167 public String extractNextToken(ListJobsResponse payload) { 168 return payload.getNextPageToken(); 169 } 170 171 @Override 172 public Iterable<Job> extractResources(ListJobsResponse payload) { 173 return payload.getJobsList() == null 174 ? ImmutableList.<Job>of() 175 : payload.getJobsList(); 176 } 177 }; 178 179 private static final PagedListResponseFactory< 180 ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> 181 LIST_JOBS_PAGE_STR_FACT = 182 new PagedListResponseFactory<ListJobsRequest, ListJobsResponse, ListJobsPagedResponse>() { 183 @Override 184 public ApiFuture<ListJobsPagedResponse> getFuturePagedResponse( 185 UnaryCallable<ListJobsRequest, ListJobsResponse> callable, 186 ListJobsRequest request, 187 ApiCallContext context, 188 ApiFuture<ListJobsResponse> futureResponse) { 189 PageContext<ListJobsRequest, ListJobsResponse, Job> pageContext = 190 PageContext.create(callable, LIST_JOBS_PAGE_STR_DESC, request, context); 191 return ListJobsPagedResponse.createAsync(pageContext, futureResponse); 192 } 193 }; 194 195 /** Returns the object with the settings used for calls to createJob. */ createJobSettings()196 public UnaryCallSettings<CreateJobRequest, Job> createJobSettings() { 197 return createJobSettings; 198 } 199 200 /** Returns the object with the settings used for calls to batchCreateJobs. */ batchCreateJobsSettings()201 public UnaryCallSettings<BatchCreateJobsRequest, Operation> batchCreateJobsSettings() { 202 return batchCreateJobsSettings; 203 } 204 205 /** Returns the object with the settings used for calls to batchCreateJobs. */ 206 public OperationCallSettings< 207 BatchCreateJobsRequest, BatchCreateJobsResponse, BatchOperationMetadata> batchCreateJobsOperationSettings()208 batchCreateJobsOperationSettings() { 209 return batchCreateJobsOperationSettings; 210 } 211 212 /** Returns the object with the settings used for calls to getJob. */ getJobSettings()213 public UnaryCallSettings<GetJobRequest, Job> getJobSettings() { 214 return getJobSettings; 215 } 216 217 /** Returns the object with the settings used for calls to updateJob. */ updateJobSettings()218 public UnaryCallSettings<UpdateJobRequest, Job> updateJobSettings() { 219 return updateJobSettings; 220 } 221 222 /** Returns the object with the settings used for calls to batchUpdateJobs. */ batchUpdateJobsSettings()223 public UnaryCallSettings<BatchUpdateJobsRequest, Operation> batchUpdateJobsSettings() { 224 return batchUpdateJobsSettings; 225 } 226 227 /** Returns the object with the settings used for calls to batchUpdateJobs. */ 228 public OperationCallSettings< 229 BatchUpdateJobsRequest, BatchUpdateJobsResponse, BatchOperationMetadata> batchUpdateJobsOperationSettings()230 batchUpdateJobsOperationSettings() { 231 return batchUpdateJobsOperationSettings; 232 } 233 234 /** Returns the object with the settings used for calls to deleteJob. */ deleteJobSettings()235 public UnaryCallSettings<DeleteJobRequest, Empty> deleteJobSettings() { 236 return deleteJobSettings; 237 } 238 239 /** Returns the object with the settings used for calls to batchDeleteJobs. */ batchDeleteJobsSettings()240 public UnaryCallSettings<BatchDeleteJobsRequest, Operation> batchDeleteJobsSettings() { 241 return batchDeleteJobsSettings; 242 } 243 244 /** Returns the object with the settings used for calls to batchDeleteJobs. */ 245 public OperationCallSettings< 246 BatchDeleteJobsRequest, BatchDeleteJobsResponse, BatchOperationMetadata> batchDeleteJobsOperationSettings()247 batchDeleteJobsOperationSettings() { 248 return batchDeleteJobsOperationSettings; 249 } 250 251 /** Returns the object with the settings used for calls to listJobs. */ 252 public PagedCallSettings<ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> listJobsSettings()253 listJobsSettings() { 254 return listJobsSettings; 255 } 256 257 /** Returns the object with the settings used for calls to searchJobs. */ searchJobsSettings()258 public UnaryCallSettings<SearchJobsRequest, SearchJobsResponse> searchJobsSettings() { 259 return searchJobsSettings; 260 } 261 262 /** Returns the object with the settings used for calls to searchJobsForAlert. */ searchJobsForAlertSettings()263 public UnaryCallSettings<SearchJobsRequest, SearchJobsResponse> searchJobsForAlertSettings() { 264 return searchJobsForAlertSettings; 265 } 266 createStub()267 public JobServiceStub createStub() throws IOException { 268 if (getTransportChannelProvider() 269 .getTransportName() 270 .equals(GrpcTransportChannel.getGrpcTransportName())) { 271 return GrpcJobServiceStub.create(this); 272 } 273 if (getTransportChannelProvider() 274 .getTransportName() 275 .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { 276 return HttpJsonJobServiceStub.create(this); 277 } 278 throw new UnsupportedOperationException( 279 String.format( 280 "Transport not supported: %s", getTransportChannelProvider().getTransportName())); 281 } 282 283 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()284 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 285 return InstantiatingExecutorProvider.newBuilder(); 286 } 287 288 /** Returns the default service endpoint. */ getDefaultEndpoint()289 public static String getDefaultEndpoint() { 290 return "jobs.googleapis.com:443"; 291 } 292 293 /** Returns the default mTLS service endpoint. */ getDefaultMtlsEndpoint()294 public static String getDefaultMtlsEndpoint() { 295 return "jobs.mtls.googleapis.com:443"; 296 } 297 298 /** Returns the default service scopes. */ getDefaultServiceScopes()299 public static List<String> getDefaultServiceScopes() { 300 return DEFAULT_SERVICE_SCOPES; 301 } 302 303 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()304 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 305 return GoogleCredentialsProvider.newBuilder() 306 .setScopesToApply(DEFAULT_SERVICE_SCOPES) 307 .setUseJwtAccessWithScope(true); 308 } 309 310 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()311 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 312 return InstantiatingGrpcChannelProvider.newBuilder() 313 .setMaxInboundMessageSize(Integer.MAX_VALUE); 314 } 315 316 /** Returns a builder for the default REST ChannelProvider for this service. */ 317 @BetaApi 318 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()319 defaultHttpJsonTransportProviderBuilder() { 320 return InstantiatingHttpJsonChannelProvider.newBuilder(); 321 } 322 defaultTransportChannelProvider()323 public static TransportChannelProvider defaultTransportChannelProvider() { 324 return defaultGrpcTransportProviderBuilder().build(); 325 } 326 327 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultGrpcApiClientHeaderProviderBuilder()328 public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { 329 return ApiClientHeaderProvider.newBuilder() 330 .setGeneratedLibToken( 331 "gapic", GaxProperties.getLibraryVersion(JobServiceStubSettings.class)) 332 .setTransportToken( 333 GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); 334 } 335 336 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultHttpJsonApiClientHeaderProviderBuilder()337 public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { 338 return ApiClientHeaderProvider.newBuilder() 339 .setGeneratedLibToken( 340 "gapic", GaxProperties.getLibraryVersion(JobServiceStubSettings.class)) 341 .setTransportToken( 342 GaxHttpJsonProperties.getHttpJsonTokenName(), 343 GaxHttpJsonProperties.getHttpJsonVersion()); 344 } 345 defaultApiClientHeaderProviderBuilder()346 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 347 return JobServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); 348 } 349 350 /** Returns a new gRPC builder for this class. */ newBuilder()351 public static Builder newBuilder() { 352 return Builder.createDefault(); 353 } 354 355 /** Returns a new REST builder for this class. */ newHttpJsonBuilder()356 public static Builder newHttpJsonBuilder() { 357 return Builder.createHttpJsonDefault(); 358 } 359 360 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)361 public static Builder newBuilder(ClientContext clientContext) { 362 return new Builder(clientContext); 363 } 364 365 /** Returns a builder containing all the values of this settings class. */ toBuilder()366 public Builder toBuilder() { 367 return new Builder(this); 368 } 369 JobServiceStubSettings(Builder settingsBuilder)370 protected JobServiceStubSettings(Builder settingsBuilder) throws IOException { 371 super(settingsBuilder); 372 373 createJobSettings = settingsBuilder.createJobSettings().build(); 374 batchCreateJobsSettings = settingsBuilder.batchCreateJobsSettings().build(); 375 batchCreateJobsOperationSettings = settingsBuilder.batchCreateJobsOperationSettings().build(); 376 getJobSettings = settingsBuilder.getJobSettings().build(); 377 updateJobSettings = settingsBuilder.updateJobSettings().build(); 378 batchUpdateJobsSettings = settingsBuilder.batchUpdateJobsSettings().build(); 379 batchUpdateJobsOperationSettings = settingsBuilder.batchUpdateJobsOperationSettings().build(); 380 deleteJobSettings = settingsBuilder.deleteJobSettings().build(); 381 batchDeleteJobsSettings = settingsBuilder.batchDeleteJobsSettings().build(); 382 batchDeleteJobsOperationSettings = settingsBuilder.batchDeleteJobsOperationSettings().build(); 383 listJobsSettings = settingsBuilder.listJobsSettings().build(); 384 searchJobsSettings = settingsBuilder.searchJobsSettings().build(); 385 searchJobsForAlertSettings = settingsBuilder.searchJobsForAlertSettings().build(); 386 } 387 388 /** Builder for JobServiceStubSettings. */ 389 public static class Builder extends StubSettings.Builder<JobServiceStubSettings, Builder> { 390 private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders; 391 private final UnaryCallSettings.Builder<CreateJobRequest, Job> createJobSettings; 392 private final UnaryCallSettings.Builder<BatchCreateJobsRequest, Operation> 393 batchCreateJobsSettings; 394 private final OperationCallSettings.Builder< 395 BatchCreateJobsRequest, BatchCreateJobsResponse, BatchOperationMetadata> 396 batchCreateJobsOperationSettings; 397 private final UnaryCallSettings.Builder<GetJobRequest, Job> getJobSettings; 398 private final UnaryCallSettings.Builder<UpdateJobRequest, Job> updateJobSettings; 399 private final UnaryCallSettings.Builder<BatchUpdateJobsRequest, Operation> 400 batchUpdateJobsSettings; 401 private final OperationCallSettings.Builder< 402 BatchUpdateJobsRequest, BatchUpdateJobsResponse, BatchOperationMetadata> 403 batchUpdateJobsOperationSettings; 404 private final UnaryCallSettings.Builder<DeleteJobRequest, Empty> deleteJobSettings; 405 private final UnaryCallSettings.Builder<BatchDeleteJobsRequest, Operation> 406 batchDeleteJobsSettings; 407 private final OperationCallSettings.Builder< 408 BatchDeleteJobsRequest, BatchDeleteJobsResponse, BatchOperationMetadata> 409 batchDeleteJobsOperationSettings; 410 private final PagedCallSettings.Builder< 411 ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> 412 listJobsSettings; 413 private final UnaryCallSettings.Builder<SearchJobsRequest, SearchJobsResponse> 414 searchJobsSettings; 415 private final UnaryCallSettings.Builder<SearchJobsRequest, SearchJobsResponse> 416 searchJobsForAlertSettings; 417 private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>> 418 RETRYABLE_CODE_DEFINITIONS; 419 420 static { 421 ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions = 422 ImmutableMap.builder(); 423 definitions.put( 424 "no_retry_3_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList())); 425 definitions.put( 426 "retry_policy_2_codes", 427 ImmutableSet.copyOf( 428 Lists.<StatusCode.Code>newArrayList( 429 StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); 430 definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList())); 431 RETRYABLE_CODE_DEFINITIONS = definitions.build(); 432 } 433 434 private static final ImmutableMap<String, RetrySettings> RETRY_PARAM_DEFINITIONS; 435 436 static { 437 ImmutableMap.Builder<String, RetrySettings> definitions = ImmutableMap.builder(); 438 RetrySettings settings = null; 439 settings = 440 RetrySettings.newBuilder() 441 .setInitialRpcTimeout(Duration.ofMillis(30000L)) 442 .setRpcTimeoutMultiplier(1.0) 443 .setMaxRpcTimeout(Duration.ofMillis(30000L)) 444 .setTotalTimeout(Duration.ofMillis(30000L)) 445 .build(); 446 definitions.put("no_retry_3_params", settings); 447 settings = 448 RetrySettings.newBuilder() 449 .setInitialRetryDelay(Duration.ofMillis(100L)) 450 .setRetryDelayMultiplier(1.3) 451 .setMaxRetryDelay(Duration.ofMillis(60000L)) 452 .setInitialRpcTimeout(Duration.ofMillis(30000L)) 453 .setRpcTimeoutMultiplier(1.0) 454 .setMaxRpcTimeout(Duration.ofMillis(30000L)) 455 .setTotalTimeout(Duration.ofMillis(30000L)) 456 .build(); 457 definitions.put("retry_policy_2_params", settings); 458 settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); 459 definitions.put("no_retry_params", settings); 460 RETRY_PARAM_DEFINITIONS = definitions.build(); 461 } 462 Builder()463 protected Builder() { 464 this(((ClientContext) null)); 465 } 466 Builder(ClientContext clientContext)467 protected Builder(ClientContext clientContext) { 468 super(clientContext); 469 470 createJobSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 471 batchCreateJobsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 472 batchCreateJobsOperationSettings = OperationCallSettings.newBuilder(); 473 getJobSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 474 updateJobSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 475 batchUpdateJobsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 476 batchUpdateJobsOperationSettings = OperationCallSettings.newBuilder(); 477 deleteJobSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 478 batchDeleteJobsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 479 batchDeleteJobsOperationSettings = OperationCallSettings.newBuilder(); 480 listJobsSettings = PagedCallSettings.newBuilder(LIST_JOBS_PAGE_STR_FACT); 481 searchJobsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 482 searchJobsForAlertSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); 483 484 unaryMethodSettingsBuilders = 485 ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( 486 createJobSettings, 487 batchCreateJobsSettings, 488 getJobSettings, 489 updateJobSettings, 490 batchUpdateJobsSettings, 491 deleteJobSettings, 492 batchDeleteJobsSettings, 493 listJobsSettings, 494 searchJobsSettings, 495 searchJobsForAlertSettings); 496 initDefaults(this); 497 } 498 Builder(JobServiceStubSettings settings)499 protected Builder(JobServiceStubSettings settings) { 500 super(settings); 501 502 createJobSettings = settings.createJobSettings.toBuilder(); 503 batchCreateJobsSettings = settings.batchCreateJobsSettings.toBuilder(); 504 batchCreateJobsOperationSettings = settings.batchCreateJobsOperationSettings.toBuilder(); 505 getJobSettings = settings.getJobSettings.toBuilder(); 506 updateJobSettings = settings.updateJobSettings.toBuilder(); 507 batchUpdateJobsSettings = settings.batchUpdateJobsSettings.toBuilder(); 508 batchUpdateJobsOperationSettings = settings.batchUpdateJobsOperationSettings.toBuilder(); 509 deleteJobSettings = settings.deleteJobSettings.toBuilder(); 510 batchDeleteJobsSettings = settings.batchDeleteJobsSettings.toBuilder(); 511 batchDeleteJobsOperationSettings = settings.batchDeleteJobsOperationSettings.toBuilder(); 512 listJobsSettings = settings.listJobsSettings.toBuilder(); 513 searchJobsSettings = settings.searchJobsSettings.toBuilder(); 514 searchJobsForAlertSettings = settings.searchJobsForAlertSettings.toBuilder(); 515 516 unaryMethodSettingsBuilders = 517 ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( 518 createJobSettings, 519 batchCreateJobsSettings, 520 getJobSettings, 521 updateJobSettings, 522 batchUpdateJobsSettings, 523 deleteJobSettings, 524 batchDeleteJobsSettings, 525 listJobsSettings, 526 searchJobsSettings, 527 searchJobsForAlertSettings); 528 } 529 createDefault()530 private static Builder createDefault() { 531 Builder builder = new Builder(((ClientContext) null)); 532 533 builder.setTransportChannelProvider(defaultTransportChannelProvider()); 534 builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); 535 builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); 536 builder.setEndpoint(getDefaultEndpoint()); 537 builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); 538 builder.setSwitchToMtlsEndpointAllowed(true); 539 540 return initDefaults(builder); 541 } 542 createHttpJsonDefault()543 private static Builder createHttpJsonDefault() { 544 Builder builder = new Builder(((ClientContext) null)); 545 546 builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); 547 builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); 548 builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); 549 builder.setEndpoint(getDefaultEndpoint()); 550 builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); 551 builder.setSwitchToMtlsEndpointAllowed(true); 552 553 return initDefaults(builder); 554 } 555 initDefaults(Builder builder)556 private static Builder initDefaults(Builder builder) { 557 builder 558 .createJobSettings() 559 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 560 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")); 561 562 builder 563 .batchCreateJobsSettings() 564 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 565 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")); 566 567 builder 568 .getJobSettings() 569 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) 570 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); 571 572 builder 573 .updateJobSettings() 574 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 575 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")); 576 577 builder 578 .batchUpdateJobsSettings() 579 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 580 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")); 581 582 builder 583 .deleteJobSettings() 584 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) 585 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); 586 587 builder 588 .batchDeleteJobsSettings() 589 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 590 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")); 591 592 builder 593 .listJobsSettings() 594 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) 595 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); 596 597 builder 598 .searchJobsSettings() 599 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 600 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")); 601 602 builder 603 .searchJobsForAlertSettings() 604 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) 605 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); 606 607 builder 608 .batchCreateJobsOperationSettings() 609 .setInitialCallSettings( 610 UnaryCallSettings 611 .<BatchCreateJobsRequest, OperationSnapshot>newUnaryCallSettingsBuilder() 612 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 613 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")) 614 .build()) 615 .setResponseTransformer( 616 ProtoOperationTransformers.ResponseTransformer.create(BatchCreateJobsResponse.class)) 617 .setMetadataTransformer( 618 ProtoOperationTransformers.MetadataTransformer.create(BatchOperationMetadata.class)) 619 .setPollingAlgorithm( 620 OperationTimedPollAlgorithm.create( 621 RetrySettings.newBuilder() 622 .setInitialRetryDelay(Duration.ofMillis(5000L)) 623 .setRetryDelayMultiplier(1.5) 624 .setMaxRetryDelay(Duration.ofMillis(45000L)) 625 .setInitialRpcTimeout(Duration.ZERO) 626 .setRpcTimeoutMultiplier(1.0) 627 .setMaxRpcTimeout(Duration.ZERO) 628 .setTotalTimeout(Duration.ofMillis(300000L)) 629 .build())); 630 631 builder 632 .batchUpdateJobsOperationSettings() 633 .setInitialCallSettings( 634 UnaryCallSettings 635 .<BatchUpdateJobsRequest, OperationSnapshot>newUnaryCallSettingsBuilder() 636 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 637 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")) 638 .build()) 639 .setResponseTransformer( 640 ProtoOperationTransformers.ResponseTransformer.create(BatchUpdateJobsResponse.class)) 641 .setMetadataTransformer( 642 ProtoOperationTransformers.MetadataTransformer.create(BatchOperationMetadata.class)) 643 .setPollingAlgorithm( 644 OperationTimedPollAlgorithm.create( 645 RetrySettings.newBuilder() 646 .setInitialRetryDelay(Duration.ofMillis(5000L)) 647 .setRetryDelayMultiplier(1.5) 648 .setMaxRetryDelay(Duration.ofMillis(45000L)) 649 .setInitialRpcTimeout(Duration.ZERO) 650 .setRpcTimeoutMultiplier(1.0) 651 .setMaxRpcTimeout(Duration.ZERO) 652 .setTotalTimeout(Duration.ofMillis(300000L)) 653 .build())); 654 655 builder 656 .batchDeleteJobsOperationSettings() 657 .setInitialCallSettings( 658 UnaryCallSettings 659 .<BatchDeleteJobsRequest, OperationSnapshot>newUnaryCallSettingsBuilder() 660 .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes")) 661 .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params")) 662 .build()) 663 .setResponseTransformer( 664 ProtoOperationTransformers.ResponseTransformer.create(BatchDeleteJobsResponse.class)) 665 .setMetadataTransformer( 666 ProtoOperationTransformers.MetadataTransformer.create(BatchOperationMetadata.class)) 667 .setPollingAlgorithm( 668 OperationTimedPollAlgorithm.create( 669 RetrySettings.newBuilder() 670 .setInitialRetryDelay(Duration.ofMillis(5000L)) 671 .setRetryDelayMultiplier(1.5) 672 .setMaxRetryDelay(Duration.ofMillis(45000L)) 673 .setInitialRpcTimeout(Duration.ZERO) 674 .setRpcTimeoutMultiplier(1.0) 675 .setMaxRpcTimeout(Duration.ZERO) 676 .setTotalTimeout(Duration.ofMillis(300000L)) 677 .build())); 678 679 return builder; 680 } 681 682 /** 683 * Applies the given settings updater function to all of the unary API methods in this service. 684 * 685 * <p>Note: This method does not support applying settings to streaming methods. 686 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)687 public Builder applyToAllUnaryMethods( 688 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 689 super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); 690 return this; 691 } 692 unaryMethodSettingsBuilders()693 public ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders() { 694 return unaryMethodSettingsBuilders; 695 } 696 697 /** Returns the builder for the settings used for calls to createJob. */ createJobSettings()698 public UnaryCallSettings.Builder<CreateJobRequest, Job> createJobSettings() { 699 return createJobSettings; 700 } 701 702 /** Returns the builder for the settings used for calls to batchCreateJobs. */ batchCreateJobsSettings()703 public UnaryCallSettings.Builder<BatchCreateJobsRequest, Operation> batchCreateJobsSettings() { 704 return batchCreateJobsSettings; 705 } 706 707 /** Returns the builder for the settings used for calls to batchCreateJobs. */ 708 @BetaApi( 709 "The surface for use by generated code is not stable yet and may change in the future.") 710 public OperationCallSettings.Builder< 711 BatchCreateJobsRequest, BatchCreateJobsResponse, BatchOperationMetadata> batchCreateJobsOperationSettings()712 batchCreateJobsOperationSettings() { 713 return batchCreateJobsOperationSettings; 714 } 715 716 /** Returns the builder for the settings used for calls to getJob. */ getJobSettings()717 public UnaryCallSettings.Builder<GetJobRequest, Job> getJobSettings() { 718 return getJobSettings; 719 } 720 721 /** Returns the builder for the settings used for calls to updateJob. */ updateJobSettings()722 public UnaryCallSettings.Builder<UpdateJobRequest, Job> updateJobSettings() { 723 return updateJobSettings; 724 } 725 726 /** Returns the builder for the settings used for calls to batchUpdateJobs. */ batchUpdateJobsSettings()727 public UnaryCallSettings.Builder<BatchUpdateJobsRequest, Operation> batchUpdateJobsSettings() { 728 return batchUpdateJobsSettings; 729 } 730 731 /** Returns the builder for the settings used for calls to batchUpdateJobs. */ 732 @BetaApi( 733 "The surface for use by generated code is not stable yet and may change in the future.") 734 public OperationCallSettings.Builder< 735 BatchUpdateJobsRequest, BatchUpdateJobsResponse, BatchOperationMetadata> batchUpdateJobsOperationSettings()736 batchUpdateJobsOperationSettings() { 737 return batchUpdateJobsOperationSettings; 738 } 739 740 /** Returns the builder for the settings used for calls to deleteJob. */ deleteJobSettings()741 public UnaryCallSettings.Builder<DeleteJobRequest, Empty> deleteJobSettings() { 742 return deleteJobSettings; 743 } 744 745 /** Returns the builder for the settings used for calls to batchDeleteJobs. */ batchDeleteJobsSettings()746 public UnaryCallSettings.Builder<BatchDeleteJobsRequest, Operation> batchDeleteJobsSettings() { 747 return batchDeleteJobsSettings; 748 } 749 750 /** Returns the builder for the settings used for calls to batchDeleteJobs. */ 751 @BetaApi( 752 "The surface for use by generated code is not stable yet and may change in the future.") 753 public OperationCallSettings.Builder< 754 BatchDeleteJobsRequest, BatchDeleteJobsResponse, BatchOperationMetadata> batchDeleteJobsOperationSettings()755 batchDeleteJobsOperationSettings() { 756 return batchDeleteJobsOperationSettings; 757 } 758 759 /** Returns the builder for the settings used for calls to listJobs. */ 760 public PagedCallSettings.Builder<ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> listJobsSettings()761 listJobsSettings() { 762 return listJobsSettings; 763 } 764 765 /** Returns the builder for the settings used for calls to searchJobs. */ searchJobsSettings()766 public UnaryCallSettings.Builder<SearchJobsRequest, SearchJobsResponse> searchJobsSettings() { 767 return searchJobsSettings; 768 } 769 770 /** Returns the builder for the settings used for calls to searchJobsForAlert. */ 771 public UnaryCallSettings.Builder<SearchJobsRequest, SearchJobsResponse> searchJobsForAlertSettings()772 searchJobsForAlertSettings() { 773 return searchJobsForAlertSettings; 774 } 775 776 @Override build()777 public JobServiceStubSettings build() throws IOException { 778 return new JobServiceStubSettings(this); 779 } 780 } 781 } 782