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.v4beta1.stub; 18 19 import static com.google.cloud.talent.v4beta1.JobServiceClient.ListJobsPagedResponse; 20 import static com.google.cloud.talent.v4beta1.JobServiceClient.SearchJobsForAlertPagedResponse; 21 import static com.google.cloud.talent.v4beta1.JobServiceClient.SearchJobsPagedResponse; 22 23 import com.google.api.core.BetaApi; 24 import com.google.api.gax.core.BackgroundResource; 25 import com.google.api.gax.core.BackgroundResourceAggregation; 26 import com.google.api.gax.grpc.GrpcCallSettings; 27 import com.google.api.gax.grpc.GrpcStubCallableFactory; 28 import com.google.api.gax.rpc.ClientContext; 29 import com.google.api.gax.rpc.OperationCallable; 30 import com.google.api.gax.rpc.UnaryCallable; 31 import com.google.cloud.talent.v4beta1.BatchCreateJobsRequest; 32 import com.google.cloud.talent.v4beta1.BatchDeleteJobsRequest; 33 import com.google.cloud.talent.v4beta1.BatchOperationMetadata; 34 import com.google.cloud.talent.v4beta1.BatchUpdateJobsRequest; 35 import com.google.cloud.talent.v4beta1.CreateJobRequest; 36 import com.google.cloud.talent.v4beta1.DeleteJobRequest; 37 import com.google.cloud.talent.v4beta1.GetJobRequest; 38 import com.google.cloud.talent.v4beta1.Job; 39 import com.google.cloud.talent.v4beta1.JobOperationResult; 40 import com.google.cloud.talent.v4beta1.ListJobsRequest; 41 import com.google.cloud.talent.v4beta1.ListJobsResponse; 42 import com.google.cloud.talent.v4beta1.SearchJobsRequest; 43 import com.google.cloud.talent.v4beta1.SearchJobsResponse; 44 import com.google.cloud.talent.v4beta1.UpdateJobRequest; 45 import com.google.common.collect.ImmutableMap; 46 import com.google.longrunning.Operation; 47 import com.google.longrunning.stub.GrpcOperationsStub; 48 import com.google.protobuf.Empty; 49 import io.grpc.MethodDescriptor; 50 import io.grpc.protobuf.ProtoUtils; 51 import java.io.IOException; 52 import java.util.concurrent.TimeUnit; 53 import javax.annotation.Generated; 54 55 // AUTO-GENERATED DOCUMENTATION AND CLASS. 56 /** 57 * gRPC stub implementation for the JobService service API. 58 * 59 * <p>This class is for advanced usage and reflects the underlying API directly. 60 */ 61 @BetaApi 62 @Generated("by gapic-generator-java") 63 public class GrpcJobServiceStub extends JobServiceStub { 64 private static final MethodDescriptor<CreateJobRequest, Job> createJobMethodDescriptor = 65 MethodDescriptor.<CreateJobRequest, Job>newBuilder() 66 .setType(MethodDescriptor.MethodType.UNARY) 67 .setFullMethodName("google.cloud.talent.v4beta1.JobService/CreateJob") 68 .setRequestMarshaller(ProtoUtils.marshaller(CreateJobRequest.getDefaultInstance())) 69 .setResponseMarshaller(ProtoUtils.marshaller(Job.getDefaultInstance())) 70 .build(); 71 72 private static final MethodDescriptor<BatchCreateJobsRequest, Operation> 73 batchCreateJobsMethodDescriptor = 74 MethodDescriptor.<BatchCreateJobsRequest, Operation>newBuilder() 75 .setType(MethodDescriptor.MethodType.UNARY) 76 .setFullMethodName("google.cloud.talent.v4beta1.JobService/BatchCreateJobs") 77 .setRequestMarshaller( 78 ProtoUtils.marshaller(BatchCreateJobsRequest.getDefaultInstance())) 79 .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) 80 .build(); 81 82 private static final MethodDescriptor<GetJobRequest, Job> getJobMethodDescriptor = 83 MethodDescriptor.<GetJobRequest, Job>newBuilder() 84 .setType(MethodDescriptor.MethodType.UNARY) 85 .setFullMethodName("google.cloud.talent.v4beta1.JobService/GetJob") 86 .setRequestMarshaller(ProtoUtils.marshaller(GetJobRequest.getDefaultInstance())) 87 .setResponseMarshaller(ProtoUtils.marshaller(Job.getDefaultInstance())) 88 .build(); 89 90 private static final MethodDescriptor<UpdateJobRequest, Job> updateJobMethodDescriptor = 91 MethodDescriptor.<UpdateJobRequest, Job>newBuilder() 92 .setType(MethodDescriptor.MethodType.UNARY) 93 .setFullMethodName("google.cloud.talent.v4beta1.JobService/UpdateJob") 94 .setRequestMarshaller(ProtoUtils.marshaller(UpdateJobRequest.getDefaultInstance())) 95 .setResponseMarshaller(ProtoUtils.marshaller(Job.getDefaultInstance())) 96 .build(); 97 98 private static final MethodDescriptor<BatchUpdateJobsRequest, Operation> 99 batchUpdateJobsMethodDescriptor = 100 MethodDescriptor.<BatchUpdateJobsRequest, Operation>newBuilder() 101 .setType(MethodDescriptor.MethodType.UNARY) 102 .setFullMethodName("google.cloud.talent.v4beta1.JobService/BatchUpdateJobs") 103 .setRequestMarshaller( 104 ProtoUtils.marshaller(BatchUpdateJobsRequest.getDefaultInstance())) 105 .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) 106 .build(); 107 108 private static final MethodDescriptor<DeleteJobRequest, Empty> deleteJobMethodDescriptor = 109 MethodDescriptor.<DeleteJobRequest, Empty>newBuilder() 110 .setType(MethodDescriptor.MethodType.UNARY) 111 .setFullMethodName("google.cloud.talent.v4beta1.JobService/DeleteJob") 112 .setRequestMarshaller(ProtoUtils.marshaller(DeleteJobRequest.getDefaultInstance())) 113 .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) 114 .build(); 115 116 private static final MethodDescriptor<BatchDeleteJobsRequest, Empty> 117 batchDeleteJobsMethodDescriptor = 118 MethodDescriptor.<BatchDeleteJobsRequest, Empty>newBuilder() 119 .setType(MethodDescriptor.MethodType.UNARY) 120 .setFullMethodName("google.cloud.talent.v4beta1.JobService/BatchDeleteJobs") 121 .setRequestMarshaller( 122 ProtoUtils.marshaller(BatchDeleteJobsRequest.getDefaultInstance())) 123 .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) 124 .build(); 125 126 private static final MethodDescriptor<ListJobsRequest, ListJobsResponse> 127 listJobsMethodDescriptor = 128 MethodDescriptor.<ListJobsRequest, ListJobsResponse>newBuilder() 129 .setType(MethodDescriptor.MethodType.UNARY) 130 .setFullMethodName("google.cloud.talent.v4beta1.JobService/ListJobs") 131 .setRequestMarshaller(ProtoUtils.marshaller(ListJobsRequest.getDefaultInstance())) 132 .setResponseMarshaller(ProtoUtils.marshaller(ListJobsResponse.getDefaultInstance())) 133 .build(); 134 135 private static final MethodDescriptor<SearchJobsRequest, SearchJobsResponse> 136 searchJobsMethodDescriptor = 137 MethodDescriptor.<SearchJobsRequest, SearchJobsResponse>newBuilder() 138 .setType(MethodDescriptor.MethodType.UNARY) 139 .setFullMethodName("google.cloud.talent.v4beta1.JobService/SearchJobs") 140 .setRequestMarshaller(ProtoUtils.marshaller(SearchJobsRequest.getDefaultInstance())) 141 .setResponseMarshaller(ProtoUtils.marshaller(SearchJobsResponse.getDefaultInstance())) 142 .build(); 143 144 private static final MethodDescriptor<SearchJobsRequest, SearchJobsResponse> 145 searchJobsForAlertMethodDescriptor = 146 MethodDescriptor.<SearchJobsRequest, SearchJobsResponse>newBuilder() 147 .setType(MethodDescriptor.MethodType.UNARY) 148 .setFullMethodName("google.cloud.talent.v4beta1.JobService/SearchJobsForAlert") 149 .setRequestMarshaller(ProtoUtils.marshaller(SearchJobsRequest.getDefaultInstance())) 150 .setResponseMarshaller(ProtoUtils.marshaller(SearchJobsResponse.getDefaultInstance())) 151 .build(); 152 153 private final UnaryCallable<CreateJobRequest, Job> createJobCallable; 154 private final UnaryCallable<BatchCreateJobsRequest, Operation> batchCreateJobsCallable; 155 private final OperationCallable< 156 BatchCreateJobsRequest, JobOperationResult, BatchOperationMetadata> 157 batchCreateJobsOperationCallable; 158 private final UnaryCallable<GetJobRequest, Job> getJobCallable; 159 private final UnaryCallable<UpdateJobRequest, Job> updateJobCallable; 160 private final UnaryCallable<BatchUpdateJobsRequest, Operation> batchUpdateJobsCallable; 161 private final OperationCallable< 162 BatchUpdateJobsRequest, JobOperationResult, BatchOperationMetadata> 163 batchUpdateJobsOperationCallable; 164 private final UnaryCallable<DeleteJobRequest, Empty> deleteJobCallable; 165 private final UnaryCallable<BatchDeleteJobsRequest, Empty> batchDeleteJobsCallable; 166 private final UnaryCallable<ListJobsRequest, ListJobsResponse> listJobsCallable; 167 private final UnaryCallable<ListJobsRequest, ListJobsPagedResponse> listJobsPagedCallable; 168 private final UnaryCallable<SearchJobsRequest, SearchJobsResponse> searchJobsCallable; 169 private final UnaryCallable<SearchJobsRequest, SearchJobsPagedResponse> searchJobsPagedCallable; 170 private final UnaryCallable<SearchJobsRequest, SearchJobsResponse> searchJobsForAlertCallable; 171 private final UnaryCallable<SearchJobsRequest, SearchJobsForAlertPagedResponse> 172 searchJobsForAlertPagedCallable; 173 174 private final BackgroundResource backgroundResources; 175 private final GrpcOperationsStub operationsStub; 176 private final GrpcStubCallableFactory callableFactory; 177 create(JobServiceStubSettings settings)178 public static final GrpcJobServiceStub create(JobServiceStubSettings settings) 179 throws IOException { 180 return new GrpcJobServiceStub(settings, ClientContext.create(settings)); 181 } 182 create(ClientContext clientContext)183 public static final GrpcJobServiceStub create(ClientContext clientContext) throws IOException { 184 return new GrpcJobServiceStub(JobServiceStubSettings.newBuilder().build(), clientContext); 185 } 186 create( ClientContext clientContext, GrpcStubCallableFactory callableFactory)187 public static final GrpcJobServiceStub create( 188 ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { 189 return new GrpcJobServiceStub( 190 JobServiceStubSettings.newBuilder().build(), clientContext, callableFactory); 191 } 192 193 /** 194 * Constructs an instance of GrpcJobServiceStub, using the given settings. This is protected so 195 * that it is easy to make a subclass, but otherwise, the static factory methods should be 196 * preferred. 197 */ GrpcJobServiceStub(JobServiceStubSettings settings, ClientContext clientContext)198 protected GrpcJobServiceStub(JobServiceStubSettings settings, ClientContext clientContext) 199 throws IOException { 200 this(settings, clientContext, new GrpcJobServiceCallableFactory()); 201 } 202 203 /** 204 * Constructs an instance of GrpcJobServiceStub, using the given settings. This is protected so 205 * that it is easy to make a subclass, but otherwise, the static factory methods should be 206 * preferred. 207 */ GrpcJobServiceStub( JobServiceStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory)208 protected GrpcJobServiceStub( 209 JobServiceStubSettings settings, 210 ClientContext clientContext, 211 GrpcStubCallableFactory callableFactory) 212 throws IOException { 213 this.callableFactory = callableFactory; 214 this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); 215 216 GrpcCallSettings<CreateJobRequest, Job> createJobTransportSettings = 217 GrpcCallSettings.<CreateJobRequest, Job>newBuilder() 218 .setMethodDescriptor(createJobMethodDescriptor) 219 .setParamsExtractor( 220 request -> { 221 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 222 params.put("parent", String.valueOf(request.getParent())); 223 return params.build(); 224 }) 225 .build(); 226 GrpcCallSettings<BatchCreateJobsRequest, Operation> batchCreateJobsTransportSettings = 227 GrpcCallSettings.<BatchCreateJobsRequest, Operation>newBuilder() 228 .setMethodDescriptor(batchCreateJobsMethodDescriptor) 229 .setParamsExtractor( 230 request -> { 231 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 232 params.put("parent", String.valueOf(request.getParent())); 233 return params.build(); 234 }) 235 .build(); 236 GrpcCallSettings<GetJobRequest, Job> getJobTransportSettings = 237 GrpcCallSettings.<GetJobRequest, Job>newBuilder() 238 .setMethodDescriptor(getJobMethodDescriptor) 239 .setParamsExtractor( 240 request -> { 241 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 242 params.put("name", String.valueOf(request.getName())); 243 return params.build(); 244 }) 245 .build(); 246 GrpcCallSettings<UpdateJobRequest, Job> updateJobTransportSettings = 247 GrpcCallSettings.<UpdateJobRequest, Job>newBuilder() 248 .setMethodDescriptor(updateJobMethodDescriptor) 249 .setParamsExtractor( 250 request -> { 251 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 252 params.put("job.name", String.valueOf(request.getJob().getName())); 253 return params.build(); 254 }) 255 .build(); 256 GrpcCallSettings<BatchUpdateJobsRequest, Operation> batchUpdateJobsTransportSettings = 257 GrpcCallSettings.<BatchUpdateJobsRequest, Operation>newBuilder() 258 .setMethodDescriptor(batchUpdateJobsMethodDescriptor) 259 .setParamsExtractor( 260 request -> { 261 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 262 params.put("parent", String.valueOf(request.getParent())); 263 return params.build(); 264 }) 265 .build(); 266 GrpcCallSettings<DeleteJobRequest, Empty> deleteJobTransportSettings = 267 GrpcCallSettings.<DeleteJobRequest, Empty>newBuilder() 268 .setMethodDescriptor(deleteJobMethodDescriptor) 269 .setParamsExtractor( 270 request -> { 271 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 272 params.put("name", String.valueOf(request.getName())); 273 return params.build(); 274 }) 275 .build(); 276 GrpcCallSettings<BatchDeleteJobsRequest, Empty> batchDeleteJobsTransportSettings = 277 GrpcCallSettings.<BatchDeleteJobsRequest, Empty>newBuilder() 278 .setMethodDescriptor(batchDeleteJobsMethodDescriptor) 279 .setParamsExtractor( 280 request -> { 281 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 282 params.put("parent", String.valueOf(request.getParent())); 283 return params.build(); 284 }) 285 .build(); 286 GrpcCallSettings<ListJobsRequest, ListJobsResponse> listJobsTransportSettings = 287 GrpcCallSettings.<ListJobsRequest, ListJobsResponse>newBuilder() 288 .setMethodDescriptor(listJobsMethodDescriptor) 289 .setParamsExtractor( 290 request -> { 291 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 292 params.put("parent", String.valueOf(request.getParent())); 293 return params.build(); 294 }) 295 .build(); 296 GrpcCallSettings<SearchJobsRequest, SearchJobsResponse> searchJobsTransportSettings = 297 GrpcCallSettings.<SearchJobsRequest, SearchJobsResponse>newBuilder() 298 .setMethodDescriptor(searchJobsMethodDescriptor) 299 .setParamsExtractor( 300 request -> { 301 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 302 params.put("parent", String.valueOf(request.getParent())); 303 return params.build(); 304 }) 305 .build(); 306 GrpcCallSettings<SearchJobsRequest, SearchJobsResponse> searchJobsForAlertTransportSettings = 307 GrpcCallSettings.<SearchJobsRequest, SearchJobsResponse>newBuilder() 308 .setMethodDescriptor(searchJobsForAlertMethodDescriptor) 309 .setParamsExtractor( 310 request -> { 311 ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); 312 params.put("parent", String.valueOf(request.getParent())); 313 return params.build(); 314 }) 315 .build(); 316 317 this.createJobCallable = 318 callableFactory.createUnaryCallable( 319 createJobTransportSettings, settings.createJobSettings(), clientContext); 320 this.batchCreateJobsCallable = 321 callableFactory.createUnaryCallable( 322 batchCreateJobsTransportSettings, settings.batchCreateJobsSettings(), clientContext); 323 this.batchCreateJobsOperationCallable = 324 callableFactory.createOperationCallable( 325 batchCreateJobsTransportSettings, 326 settings.batchCreateJobsOperationSettings(), 327 clientContext, 328 operationsStub); 329 this.getJobCallable = 330 callableFactory.createUnaryCallable( 331 getJobTransportSettings, settings.getJobSettings(), clientContext); 332 this.updateJobCallable = 333 callableFactory.createUnaryCallable( 334 updateJobTransportSettings, settings.updateJobSettings(), clientContext); 335 this.batchUpdateJobsCallable = 336 callableFactory.createUnaryCallable( 337 batchUpdateJobsTransportSettings, settings.batchUpdateJobsSettings(), clientContext); 338 this.batchUpdateJobsOperationCallable = 339 callableFactory.createOperationCallable( 340 batchUpdateJobsTransportSettings, 341 settings.batchUpdateJobsOperationSettings(), 342 clientContext, 343 operationsStub); 344 this.deleteJobCallable = 345 callableFactory.createUnaryCallable( 346 deleteJobTransportSettings, settings.deleteJobSettings(), clientContext); 347 this.batchDeleteJobsCallable = 348 callableFactory.createUnaryCallable( 349 batchDeleteJobsTransportSettings, settings.batchDeleteJobsSettings(), clientContext); 350 this.listJobsCallable = 351 callableFactory.createUnaryCallable( 352 listJobsTransportSettings, settings.listJobsSettings(), clientContext); 353 this.listJobsPagedCallable = 354 callableFactory.createPagedCallable( 355 listJobsTransportSettings, settings.listJobsSettings(), clientContext); 356 this.searchJobsCallable = 357 callableFactory.createUnaryCallable( 358 searchJobsTransportSettings, settings.searchJobsSettings(), clientContext); 359 this.searchJobsPagedCallable = 360 callableFactory.createPagedCallable( 361 searchJobsTransportSettings, settings.searchJobsSettings(), clientContext); 362 this.searchJobsForAlertCallable = 363 callableFactory.createUnaryCallable( 364 searchJobsForAlertTransportSettings, 365 settings.searchJobsForAlertSettings(), 366 clientContext); 367 this.searchJobsForAlertPagedCallable = 368 callableFactory.createPagedCallable( 369 searchJobsForAlertTransportSettings, 370 settings.searchJobsForAlertSettings(), 371 clientContext); 372 373 this.backgroundResources = 374 new BackgroundResourceAggregation(clientContext.getBackgroundResources()); 375 } 376 getOperationsStub()377 public GrpcOperationsStub getOperationsStub() { 378 return operationsStub; 379 } 380 381 @Override createJobCallable()382 public UnaryCallable<CreateJobRequest, Job> createJobCallable() { 383 return createJobCallable; 384 } 385 386 @Override batchCreateJobsCallable()387 public UnaryCallable<BatchCreateJobsRequest, Operation> batchCreateJobsCallable() { 388 return batchCreateJobsCallable; 389 } 390 391 @Override 392 public OperationCallable<BatchCreateJobsRequest, JobOperationResult, BatchOperationMetadata> batchCreateJobsOperationCallable()393 batchCreateJobsOperationCallable() { 394 return batchCreateJobsOperationCallable; 395 } 396 397 @Override getJobCallable()398 public UnaryCallable<GetJobRequest, Job> getJobCallable() { 399 return getJobCallable; 400 } 401 402 @Override updateJobCallable()403 public UnaryCallable<UpdateJobRequest, Job> updateJobCallable() { 404 return updateJobCallable; 405 } 406 407 @Override batchUpdateJobsCallable()408 public UnaryCallable<BatchUpdateJobsRequest, Operation> batchUpdateJobsCallable() { 409 return batchUpdateJobsCallable; 410 } 411 412 @Override 413 public OperationCallable<BatchUpdateJobsRequest, JobOperationResult, BatchOperationMetadata> batchUpdateJobsOperationCallable()414 batchUpdateJobsOperationCallable() { 415 return batchUpdateJobsOperationCallable; 416 } 417 418 @Override deleteJobCallable()419 public UnaryCallable<DeleteJobRequest, Empty> deleteJobCallable() { 420 return deleteJobCallable; 421 } 422 423 @Override batchDeleteJobsCallable()424 public UnaryCallable<BatchDeleteJobsRequest, Empty> batchDeleteJobsCallable() { 425 return batchDeleteJobsCallable; 426 } 427 428 @Override listJobsCallable()429 public UnaryCallable<ListJobsRequest, ListJobsResponse> listJobsCallable() { 430 return listJobsCallable; 431 } 432 433 @Override listJobsPagedCallable()434 public UnaryCallable<ListJobsRequest, ListJobsPagedResponse> listJobsPagedCallable() { 435 return listJobsPagedCallable; 436 } 437 438 @Override searchJobsCallable()439 public UnaryCallable<SearchJobsRequest, SearchJobsResponse> searchJobsCallable() { 440 return searchJobsCallable; 441 } 442 443 @Override searchJobsPagedCallable()444 public UnaryCallable<SearchJobsRequest, SearchJobsPagedResponse> searchJobsPagedCallable() { 445 return searchJobsPagedCallable; 446 } 447 448 @Override searchJobsForAlertCallable()449 public UnaryCallable<SearchJobsRequest, SearchJobsResponse> searchJobsForAlertCallable() { 450 return searchJobsForAlertCallable; 451 } 452 453 @Override 454 public UnaryCallable<SearchJobsRequest, SearchJobsForAlertPagedResponse> searchJobsForAlertPagedCallable()455 searchJobsForAlertPagedCallable() { 456 return searchJobsForAlertPagedCallable; 457 } 458 459 @Override close()460 public final void close() { 461 try { 462 backgroundResources.close(); 463 } catch (RuntimeException e) { 464 throw e; 465 } catch (Exception e) { 466 throw new IllegalStateException("Failed to close resource", e); 467 } 468 } 469 470 @Override shutdown()471 public void shutdown() { 472 backgroundResources.shutdown(); 473 } 474 475 @Override isShutdown()476 public boolean isShutdown() { 477 return backgroundResources.isShutdown(); 478 } 479 480 @Override isTerminated()481 public boolean isTerminated() { 482 return backgroundResources.isTerminated(); 483 } 484 485 @Override shutdownNow()486 public void shutdownNow() { 487 backgroundResources.shutdownNow(); 488 } 489 490 @Override awaitTermination(long duration, TimeUnit unit)491 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 492 return backgroundResources.awaitTermination(duration, unit); 493 } 494 } 495