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; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.gax.core.BackgroundResource; 22 import com.google.api.gax.paging.AbstractFixedSizeCollection; 23 import com.google.api.gax.paging.AbstractPage; 24 import com.google.api.gax.paging.AbstractPagedListResponse; 25 import com.google.api.gax.rpc.PageContext; 26 import com.google.api.gax.rpc.UnaryCallable; 27 import com.google.cloud.talent.v4.stub.CompanyServiceStub; 28 import com.google.cloud.talent.v4.stub.CompanyServiceStubSettings; 29 import com.google.common.util.concurrent.MoreExecutors; 30 import com.google.protobuf.Empty; 31 import com.google.protobuf.FieldMask; 32 import java.io.IOException; 33 import java.util.List; 34 import java.util.concurrent.TimeUnit; 35 import javax.annotation.Generated; 36 37 // AUTO-GENERATED DOCUMENTATION AND CLASS. 38 /** 39 * Service Description: A service that handles company management, including CRUD and enumeration. 40 * 41 * <p>This class provides the ability to make remote calls to the backing service through method 42 * calls that map to API methods. Sample code to get started: 43 * 44 * <pre>{@code 45 * // This snippet has been automatically generated and should be regarded as a code template only. 46 * // It will require modifications to work: 47 * // - It may require correct/in-range values for request initialization. 48 * // - It may require specifying regional endpoints when creating the service client as shown in 49 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 50 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 51 * TenantName parent = TenantName.of("[PROJECT]", "[TENANT]"); 52 * Company company = Company.newBuilder().build(); 53 * Company response = companyServiceClient.createCompany(parent, company); 54 * } 55 * }</pre> 56 * 57 * <p>Note: close() needs to be called on the CompanyServiceClient object to clean up resources such 58 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 59 * 60 * <p>The surface of this class includes several types of Java methods for each of the API's 61 * methods: 62 * 63 * <ol> 64 * <li>A "flattened" method. With this type of method, the fields of the request type have been 65 * converted into function parameters. It may be the case that not all fields are available as 66 * parameters, and not every API method will have a flattened method entry point. 67 * <li>A "request object" method. This type of method only takes one parameter, a request object, 68 * which must be constructed before the call. Not every API method will have a request object 69 * method. 70 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 71 * callable object, which can be used to initiate calls to the service. 72 * </ol> 73 * 74 * <p>See the individual methods for example code. 75 * 76 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 77 * these names, this class includes a format method for each type of name, and additionally a parse 78 * method to extract the individual identifiers contained within names that are returned. 79 * 80 * <p>This class can be customized by passing in a custom instance of CompanyServiceSettings to 81 * create(). For example: 82 * 83 * <p>To customize credentials: 84 * 85 * <pre>{@code 86 * // This snippet has been automatically generated and should be regarded as a code template only. 87 * // It will require modifications to work: 88 * // - It may require correct/in-range values for request initialization. 89 * // - It may require specifying regional endpoints when creating the service client as shown in 90 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 91 * CompanyServiceSettings companyServiceSettings = 92 * CompanyServiceSettings.newBuilder() 93 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 94 * .build(); 95 * CompanyServiceClient companyServiceClient = CompanyServiceClient.create(companyServiceSettings); 96 * }</pre> 97 * 98 * <p>To customize the endpoint: 99 * 100 * <pre>{@code 101 * // This snippet has been automatically generated and should be regarded as a code template only. 102 * // It will require modifications to work: 103 * // - It may require correct/in-range values for request initialization. 104 * // - It may require specifying regional endpoints when creating the service client as shown in 105 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 106 * CompanyServiceSettings companyServiceSettings = 107 * CompanyServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); 108 * CompanyServiceClient companyServiceClient = CompanyServiceClient.create(companyServiceSettings); 109 * }</pre> 110 * 111 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 112 * the wire: 113 * 114 * <pre>{@code 115 * // This snippet has been automatically generated and should be regarded as a code template only. 116 * // It will require modifications to work: 117 * // - It may require correct/in-range values for request initialization. 118 * // - It may require specifying regional endpoints when creating the service client as shown in 119 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 120 * CompanyServiceSettings companyServiceSettings = 121 * CompanyServiceSettings.newHttpJsonBuilder().build(); 122 * CompanyServiceClient companyServiceClient = CompanyServiceClient.create(companyServiceSettings); 123 * }</pre> 124 * 125 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 126 */ 127 @Generated("by gapic-generator-java") 128 public class CompanyServiceClient implements BackgroundResource { 129 private final CompanyServiceSettings settings; 130 private final CompanyServiceStub stub; 131 132 /** Constructs an instance of CompanyServiceClient with default settings. */ create()133 public static final CompanyServiceClient create() throws IOException { 134 return create(CompanyServiceSettings.newBuilder().build()); 135 } 136 137 /** 138 * Constructs an instance of CompanyServiceClient, using the given settings. The channels are 139 * created based on the settings passed in, or defaults for any settings that are not set. 140 */ create(CompanyServiceSettings settings)141 public static final CompanyServiceClient create(CompanyServiceSettings settings) 142 throws IOException { 143 return new CompanyServiceClient(settings); 144 } 145 146 /** 147 * Constructs an instance of CompanyServiceClient, using the given stub for making calls. This is 148 * for advanced usage - prefer using create(CompanyServiceSettings). 149 */ create(CompanyServiceStub stub)150 public static final CompanyServiceClient create(CompanyServiceStub stub) { 151 return new CompanyServiceClient(stub); 152 } 153 154 /** 155 * Constructs an instance of CompanyServiceClient, using the given settings. This is protected so 156 * that it is easy to make a subclass, but otherwise, the static factory methods should be 157 * preferred. 158 */ CompanyServiceClient(CompanyServiceSettings settings)159 protected CompanyServiceClient(CompanyServiceSettings settings) throws IOException { 160 this.settings = settings; 161 this.stub = ((CompanyServiceStubSettings) settings.getStubSettings()).createStub(); 162 } 163 CompanyServiceClient(CompanyServiceStub stub)164 protected CompanyServiceClient(CompanyServiceStub stub) { 165 this.settings = null; 166 this.stub = stub; 167 } 168 getSettings()169 public final CompanyServiceSettings getSettings() { 170 return settings; 171 } 172 getStub()173 public CompanyServiceStub getStub() { 174 return stub; 175 } 176 177 // AUTO-GENERATED DOCUMENTATION AND METHOD. 178 /** 179 * Creates a new company entity. 180 * 181 * <p>Sample code: 182 * 183 * <pre>{@code 184 * // This snippet has been automatically generated and should be regarded as a code template only. 185 * // It will require modifications to work: 186 * // - It may require correct/in-range values for request initialization. 187 * // - It may require specifying regional endpoints when creating the service client as shown in 188 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 189 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 190 * TenantName parent = TenantName.of("[PROJECT]", "[TENANT]"); 191 * Company company = Company.newBuilder().build(); 192 * Company response = companyServiceClient.createCompany(parent, company); 193 * } 194 * }</pre> 195 * 196 * @param parent Required. Resource name of the tenant under which the company is created. 197 * <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example, 198 * "projects/foo/tenants/bar". 199 * @param company Required. The company to be created. 200 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 201 */ createCompany(TenantName parent, Company company)202 public final Company createCompany(TenantName parent, Company company) { 203 CreateCompanyRequest request = 204 CreateCompanyRequest.newBuilder() 205 .setParent(parent == null ? null : parent.toString()) 206 .setCompany(company) 207 .build(); 208 return createCompany(request); 209 } 210 211 // AUTO-GENERATED DOCUMENTATION AND METHOD. 212 /** 213 * Creates a new company entity. 214 * 215 * <p>Sample code: 216 * 217 * <pre>{@code 218 * // This snippet has been automatically generated and should be regarded as a code template only. 219 * // It will require modifications to work: 220 * // - It may require correct/in-range values for request initialization. 221 * // - It may require specifying regional endpoints when creating the service client as shown in 222 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 223 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 224 * String parent = TenantName.of("[PROJECT]", "[TENANT]").toString(); 225 * Company company = Company.newBuilder().build(); 226 * Company response = companyServiceClient.createCompany(parent, company); 227 * } 228 * }</pre> 229 * 230 * @param parent Required. Resource name of the tenant under which the company is created. 231 * <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example, 232 * "projects/foo/tenants/bar". 233 * @param company Required. The company to be created. 234 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 235 */ createCompany(String parent, Company company)236 public final Company createCompany(String parent, Company company) { 237 CreateCompanyRequest request = 238 CreateCompanyRequest.newBuilder().setParent(parent).setCompany(company).build(); 239 return createCompany(request); 240 } 241 242 // AUTO-GENERATED DOCUMENTATION AND METHOD. 243 /** 244 * Creates a new company entity. 245 * 246 * <p>Sample code: 247 * 248 * <pre>{@code 249 * // This snippet has been automatically generated and should be regarded as a code template only. 250 * // It will require modifications to work: 251 * // - It may require correct/in-range values for request initialization. 252 * // - It may require specifying regional endpoints when creating the service client as shown in 253 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 254 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 255 * CreateCompanyRequest request = 256 * CreateCompanyRequest.newBuilder() 257 * .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) 258 * .setCompany(Company.newBuilder().build()) 259 * .build(); 260 * Company response = companyServiceClient.createCompany(request); 261 * } 262 * }</pre> 263 * 264 * @param request The request object containing all of the parameters for the API call. 265 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 266 */ createCompany(CreateCompanyRequest request)267 public final Company createCompany(CreateCompanyRequest request) { 268 return createCompanyCallable().call(request); 269 } 270 271 // AUTO-GENERATED DOCUMENTATION AND METHOD. 272 /** 273 * Creates a new company entity. 274 * 275 * <p>Sample code: 276 * 277 * <pre>{@code 278 * // This snippet has been automatically generated and should be regarded as a code template only. 279 * // It will require modifications to work: 280 * // - It may require correct/in-range values for request initialization. 281 * // - It may require specifying regional endpoints when creating the service client as shown in 282 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 283 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 284 * CreateCompanyRequest request = 285 * CreateCompanyRequest.newBuilder() 286 * .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) 287 * .setCompany(Company.newBuilder().build()) 288 * .build(); 289 * ApiFuture<Company> future = companyServiceClient.createCompanyCallable().futureCall(request); 290 * // Do something. 291 * Company response = future.get(); 292 * } 293 * }</pre> 294 */ createCompanyCallable()295 public final UnaryCallable<CreateCompanyRequest, Company> createCompanyCallable() { 296 return stub.createCompanyCallable(); 297 } 298 299 // AUTO-GENERATED DOCUMENTATION AND METHOD. 300 /** 301 * Retrieves specified company. 302 * 303 * <p>Sample code: 304 * 305 * <pre>{@code 306 * // This snippet has been automatically generated and should be regarded as a code template only. 307 * // It will require modifications to work: 308 * // - It may require correct/in-range values for request initialization. 309 * // - It may require specifying regional endpoints when creating the service client as shown in 310 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 311 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 312 * CompanyName name = CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]"); 313 * Company response = companyServiceClient.getCompany(name); 314 * } 315 * }</pre> 316 * 317 * @param name Required. The resource name of the company to be retrieved. 318 * <p>The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for 319 * example, "projects/api-test-project/tenants/foo/companies/bar". 320 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 321 */ getCompany(CompanyName name)322 public final Company getCompany(CompanyName name) { 323 GetCompanyRequest request = 324 GetCompanyRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 325 return getCompany(request); 326 } 327 328 // AUTO-GENERATED DOCUMENTATION AND METHOD. 329 /** 330 * Retrieves specified company. 331 * 332 * <p>Sample code: 333 * 334 * <pre>{@code 335 * // This snippet has been automatically generated and should be regarded as a code template only. 336 * // It will require modifications to work: 337 * // - It may require correct/in-range values for request initialization. 338 * // - It may require specifying regional endpoints when creating the service client as shown in 339 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 340 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 341 * String name = CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString(); 342 * Company response = companyServiceClient.getCompany(name); 343 * } 344 * }</pre> 345 * 346 * @param name Required. The resource name of the company to be retrieved. 347 * <p>The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for 348 * example, "projects/api-test-project/tenants/foo/companies/bar". 349 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 350 */ getCompany(String name)351 public final Company getCompany(String name) { 352 GetCompanyRequest request = GetCompanyRequest.newBuilder().setName(name).build(); 353 return getCompany(request); 354 } 355 356 // AUTO-GENERATED DOCUMENTATION AND METHOD. 357 /** 358 * Retrieves specified company. 359 * 360 * <p>Sample code: 361 * 362 * <pre>{@code 363 * // This snippet has been automatically generated and should be regarded as a code template only. 364 * // It will require modifications to work: 365 * // - It may require correct/in-range values for request initialization. 366 * // - It may require specifying regional endpoints when creating the service client as shown in 367 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 368 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 369 * GetCompanyRequest request = 370 * GetCompanyRequest.newBuilder() 371 * .setName(CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString()) 372 * .build(); 373 * Company response = companyServiceClient.getCompany(request); 374 * } 375 * }</pre> 376 * 377 * @param request The request object containing all of the parameters for the API call. 378 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 379 */ getCompany(GetCompanyRequest request)380 public final Company getCompany(GetCompanyRequest request) { 381 return getCompanyCallable().call(request); 382 } 383 384 // AUTO-GENERATED DOCUMENTATION AND METHOD. 385 /** 386 * Retrieves specified company. 387 * 388 * <p>Sample code: 389 * 390 * <pre>{@code 391 * // This snippet has been automatically generated and should be regarded as a code template only. 392 * // It will require modifications to work: 393 * // - It may require correct/in-range values for request initialization. 394 * // - It may require specifying regional endpoints when creating the service client as shown in 395 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 396 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 397 * GetCompanyRequest request = 398 * GetCompanyRequest.newBuilder() 399 * .setName(CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString()) 400 * .build(); 401 * ApiFuture<Company> future = companyServiceClient.getCompanyCallable().futureCall(request); 402 * // Do something. 403 * Company response = future.get(); 404 * } 405 * }</pre> 406 */ getCompanyCallable()407 public final UnaryCallable<GetCompanyRequest, Company> getCompanyCallable() { 408 return stub.getCompanyCallable(); 409 } 410 411 // AUTO-GENERATED DOCUMENTATION AND METHOD. 412 /** 413 * Updates specified company. 414 * 415 * <p>Sample code: 416 * 417 * <pre>{@code 418 * // This snippet has been automatically generated and should be regarded as a code template only. 419 * // It will require modifications to work: 420 * // - It may require correct/in-range values for request initialization. 421 * // - It may require specifying regional endpoints when creating the service client as shown in 422 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 423 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 424 * Company company = Company.newBuilder().build(); 425 * FieldMask updateMask = FieldMask.newBuilder().build(); 426 * Company response = companyServiceClient.updateCompany(company, updateMask); 427 * } 428 * }</pre> 429 * 430 * @param company Required. The company resource to replace the current resource in the system. 431 * @param updateMask Strongly recommended for the best service experience. 432 * <p>If [update_mask][google.cloud.talent.v4.UpdateCompanyRequest.update_mask] is provided, 433 * only the specified fields in [company][google.cloud.talent.v4.UpdateCompanyRequest.company] 434 * are updated. Otherwise all the fields are updated. 435 * <p>A field mask to specify the company fields to be updated. Only top level fields of 436 * [Company][google.cloud.talent.v4.Company] are supported. 437 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 438 */ updateCompany(Company company, FieldMask updateMask)439 public final Company updateCompany(Company company, FieldMask updateMask) { 440 UpdateCompanyRequest request = 441 UpdateCompanyRequest.newBuilder().setCompany(company).setUpdateMask(updateMask).build(); 442 return updateCompany(request); 443 } 444 445 // AUTO-GENERATED DOCUMENTATION AND METHOD. 446 /** 447 * Updates specified company. 448 * 449 * <p>Sample code: 450 * 451 * <pre>{@code 452 * // This snippet has been automatically generated and should be regarded as a code template only. 453 * // It will require modifications to work: 454 * // - It may require correct/in-range values for request initialization. 455 * // - It may require specifying regional endpoints when creating the service client as shown in 456 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 457 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 458 * UpdateCompanyRequest request = 459 * UpdateCompanyRequest.newBuilder() 460 * .setCompany(Company.newBuilder().build()) 461 * .setUpdateMask(FieldMask.newBuilder().build()) 462 * .build(); 463 * Company response = companyServiceClient.updateCompany(request); 464 * } 465 * }</pre> 466 * 467 * @param request The request object containing all of the parameters for the API call. 468 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 469 */ updateCompany(UpdateCompanyRequest request)470 public final Company updateCompany(UpdateCompanyRequest request) { 471 return updateCompanyCallable().call(request); 472 } 473 474 // AUTO-GENERATED DOCUMENTATION AND METHOD. 475 /** 476 * Updates specified company. 477 * 478 * <p>Sample code: 479 * 480 * <pre>{@code 481 * // This snippet has been automatically generated and should be regarded as a code template only. 482 * // It will require modifications to work: 483 * // - It may require correct/in-range values for request initialization. 484 * // - It may require specifying regional endpoints when creating the service client as shown in 485 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 486 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 487 * UpdateCompanyRequest request = 488 * UpdateCompanyRequest.newBuilder() 489 * .setCompany(Company.newBuilder().build()) 490 * .setUpdateMask(FieldMask.newBuilder().build()) 491 * .build(); 492 * ApiFuture<Company> future = companyServiceClient.updateCompanyCallable().futureCall(request); 493 * // Do something. 494 * Company response = future.get(); 495 * } 496 * }</pre> 497 */ updateCompanyCallable()498 public final UnaryCallable<UpdateCompanyRequest, Company> updateCompanyCallable() { 499 return stub.updateCompanyCallable(); 500 } 501 502 // AUTO-GENERATED DOCUMENTATION AND METHOD. 503 /** 504 * Deletes specified company. Prerequisite: The company has no jobs associated with it. 505 * 506 * <p>Sample code: 507 * 508 * <pre>{@code 509 * // This snippet has been automatically generated and should be regarded as a code template only. 510 * // It will require modifications to work: 511 * // - It may require correct/in-range values for request initialization. 512 * // - It may require specifying regional endpoints when creating the service client as shown in 513 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 514 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 515 * CompanyName name = CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]"); 516 * companyServiceClient.deleteCompany(name); 517 * } 518 * }</pre> 519 * 520 * @param name Required. The resource name of the company to be deleted. 521 * <p>The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for 522 * example, "projects/foo/tenants/bar/companies/baz". 523 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 524 */ deleteCompany(CompanyName name)525 public final void deleteCompany(CompanyName name) { 526 DeleteCompanyRequest request = 527 DeleteCompanyRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 528 deleteCompany(request); 529 } 530 531 // AUTO-GENERATED DOCUMENTATION AND METHOD. 532 /** 533 * Deletes specified company. Prerequisite: The company has no jobs associated with it. 534 * 535 * <p>Sample code: 536 * 537 * <pre>{@code 538 * // This snippet has been automatically generated and should be regarded as a code template only. 539 * // It will require modifications to work: 540 * // - It may require correct/in-range values for request initialization. 541 * // - It may require specifying regional endpoints when creating the service client as shown in 542 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 543 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 544 * String name = CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString(); 545 * companyServiceClient.deleteCompany(name); 546 * } 547 * }</pre> 548 * 549 * @param name Required. The resource name of the company to be deleted. 550 * <p>The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for 551 * example, "projects/foo/tenants/bar/companies/baz". 552 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 553 */ deleteCompany(String name)554 public final void deleteCompany(String name) { 555 DeleteCompanyRequest request = DeleteCompanyRequest.newBuilder().setName(name).build(); 556 deleteCompany(request); 557 } 558 559 // AUTO-GENERATED DOCUMENTATION AND METHOD. 560 /** 561 * Deletes specified company. Prerequisite: The company has no jobs associated with it. 562 * 563 * <p>Sample code: 564 * 565 * <pre>{@code 566 * // This snippet has been automatically generated and should be regarded as a code template only. 567 * // It will require modifications to work: 568 * // - It may require correct/in-range values for request initialization. 569 * // - It may require specifying regional endpoints when creating the service client as shown in 570 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 571 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 572 * DeleteCompanyRequest request = 573 * DeleteCompanyRequest.newBuilder() 574 * .setName(CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString()) 575 * .build(); 576 * companyServiceClient.deleteCompany(request); 577 * } 578 * }</pre> 579 * 580 * @param request The request object containing all of the parameters for the API call. 581 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 582 */ deleteCompany(DeleteCompanyRequest request)583 public final void deleteCompany(DeleteCompanyRequest request) { 584 deleteCompanyCallable().call(request); 585 } 586 587 // AUTO-GENERATED DOCUMENTATION AND METHOD. 588 /** 589 * Deletes specified company. Prerequisite: The company has no jobs associated with it. 590 * 591 * <p>Sample code: 592 * 593 * <pre>{@code 594 * // This snippet has been automatically generated and should be regarded as a code template only. 595 * // It will require modifications to work: 596 * // - It may require correct/in-range values for request initialization. 597 * // - It may require specifying regional endpoints when creating the service client as shown in 598 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 599 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 600 * DeleteCompanyRequest request = 601 * DeleteCompanyRequest.newBuilder() 602 * .setName(CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString()) 603 * .build(); 604 * ApiFuture<Empty> future = companyServiceClient.deleteCompanyCallable().futureCall(request); 605 * // Do something. 606 * future.get(); 607 * } 608 * }</pre> 609 */ deleteCompanyCallable()610 public final UnaryCallable<DeleteCompanyRequest, Empty> deleteCompanyCallable() { 611 return stub.deleteCompanyCallable(); 612 } 613 614 // AUTO-GENERATED DOCUMENTATION AND METHOD. 615 /** 616 * Lists all companies associated with the project. 617 * 618 * <p>Sample code: 619 * 620 * <pre>{@code 621 * // This snippet has been automatically generated and should be regarded as a code template only. 622 * // It will require modifications to work: 623 * // - It may require correct/in-range values for request initialization. 624 * // - It may require specifying regional endpoints when creating the service client as shown in 625 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 626 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 627 * TenantName parent = TenantName.of("[PROJECT]", "[TENANT]"); 628 * for (Company element : companyServiceClient.listCompanies(parent).iterateAll()) { 629 * // doThingsWith(element); 630 * } 631 * } 632 * }</pre> 633 * 634 * @param parent Required. Resource name of the tenant under which the company is created. 635 * <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example, 636 * "projects/foo/tenants/bar". 637 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 638 */ listCompanies(TenantName parent)639 public final ListCompaniesPagedResponse listCompanies(TenantName parent) { 640 ListCompaniesRequest request = 641 ListCompaniesRequest.newBuilder() 642 .setParent(parent == null ? null : parent.toString()) 643 .build(); 644 return listCompanies(request); 645 } 646 647 // AUTO-GENERATED DOCUMENTATION AND METHOD. 648 /** 649 * Lists all companies associated with the project. 650 * 651 * <p>Sample code: 652 * 653 * <pre>{@code 654 * // This snippet has been automatically generated and should be regarded as a code template only. 655 * // It will require modifications to work: 656 * // - It may require correct/in-range values for request initialization. 657 * // - It may require specifying regional endpoints when creating the service client as shown in 658 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 659 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 660 * String parent = TenantName.of("[PROJECT]", "[TENANT]").toString(); 661 * for (Company element : companyServiceClient.listCompanies(parent).iterateAll()) { 662 * // doThingsWith(element); 663 * } 664 * } 665 * }</pre> 666 * 667 * @param parent Required. Resource name of the tenant under which the company is created. 668 * <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example, 669 * "projects/foo/tenants/bar". 670 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 671 */ listCompanies(String parent)672 public final ListCompaniesPagedResponse listCompanies(String parent) { 673 ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent).build(); 674 return listCompanies(request); 675 } 676 677 // AUTO-GENERATED DOCUMENTATION AND METHOD. 678 /** 679 * Lists all companies associated with the project. 680 * 681 * <p>Sample code: 682 * 683 * <pre>{@code 684 * // This snippet has been automatically generated and should be regarded as a code template only. 685 * // It will require modifications to work: 686 * // - It may require correct/in-range values for request initialization. 687 * // - It may require specifying regional endpoints when creating the service client as shown in 688 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 689 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 690 * ListCompaniesRequest request = 691 * ListCompaniesRequest.newBuilder() 692 * .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) 693 * .setPageToken("pageToken873572522") 694 * .setPageSize(883849137) 695 * .setRequireOpenJobs(true) 696 * .build(); 697 * for (Company element : companyServiceClient.listCompanies(request).iterateAll()) { 698 * // doThingsWith(element); 699 * } 700 * } 701 * }</pre> 702 * 703 * @param request The request object containing all of the parameters for the API call. 704 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 705 */ listCompanies(ListCompaniesRequest request)706 public final ListCompaniesPagedResponse listCompanies(ListCompaniesRequest request) { 707 return listCompaniesPagedCallable().call(request); 708 } 709 710 // AUTO-GENERATED DOCUMENTATION AND METHOD. 711 /** 712 * Lists all companies associated with the project. 713 * 714 * <p>Sample code: 715 * 716 * <pre>{@code 717 * // This snippet has been automatically generated and should be regarded as a code template only. 718 * // It will require modifications to work: 719 * // - It may require correct/in-range values for request initialization. 720 * // - It may require specifying regional endpoints when creating the service client as shown in 721 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 722 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 723 * ListCompaniesRequest request = 724 * ListCompaniesRequest.newBuilder() 725 * .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) 726 * .setPageToken("pageToken873572522") 727 * .setPageSize(883849137) 728 * .setRequireOpenJobs(true) 729 * .build(); 730 * ApiFuture<Company> future = 731 * companyServiceClient.listCompaniesPagedCallable().futureCall(request); 732 * // Do something. 733 * for (Company element : future.get().iterateAll()) { 734 * // doThingsWith(element); 735 * } 736 * } 737 * }</pre> 738 */ 739 public final UnaryCallable<ListCompaniesRequest, ListCompaniesPagedResponse> listCompaniesPagedCallable()740 listCompaniesPagedCallable() { 741 return stub.listCompaniesPagedCallable(); 742 } 743 744 // AUTO-GENERATED DOCUMENTATION AND METHOD. 745 /** 746 * Lists all companies associated with the project. 747 * 748 * <p>Sample code: 749 * 750 * <pre>{@code 751 * // This snippet has been automatically generated and should be regarded as a code template only. 752 * // It will require modifications to work: 753 * // - It may require correct/in-range values for request initialization. 754 * // - It may require specifying regional endpoints when creating the service client as shown in 755 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 756 * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { 757 * ListCompaniesRequest request = 758 * ListCompaniesRequest.newBuilder() 759 * .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) 760 * .setPageToken("pageToken873572522") 761 * .setPageSize(883849137) 762 * .setRequireOpenJobs(true) 763 * .build(); 764 * while (true) { 765 * ListCompaniesResponse response = companyServiceClient.listCompaniesCallable().call(request); 766 * for (Company element : response.getCompaniesList()) { 767 * // doThingsWith(element); 768 * } 769 * String nextPageToken = response.getNextPageToken(); 770 * if (!Strings.isNullOrEmpty(nextPageToken)) { 771 * request = request.toBuilder().setPageToken(nextPageToken).build(); 772 * } else { 773 * break; 774 * } 775 * } 776 * } 777 * }</pre> 778 */ listCompaniesCallable()779 public final UnaryCallable<ListCompaniesRequest, ListCompaniesResponse> listCompaniesCallable() { 780 return stub.listCompaniesCallable(); 781 } 782 783 @Override close()784 public final void close() { 785 stub.close(); 786 } 787 788 @Override shutdown()789 public void shutdown() { 790 stub.shutdown(); 791 } 792 793 @Override isShutdown()794 public boolean isShutdown() { 795 return stub.isShutdown(); 796 } 797 798 @Override isTerminated()799 public boolean isTerminated() { 800 return stub.isTerminated(); 801 } 802 803 @Override shutdownNow()804 public void shutdownNow() { 805 stub.shutdownNow(); 806 } 807 808 @Override awaitTermination(long duration, TimeUnit unit)809 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 810 return stub.awaitTermination(duration, unit); 811 } 812 813 public static class ListCompaniesPagedResponse 814 extends AbstractPagedListResponse< 815 ListCompaniesRequest, 816 ListCompaniesResponse, 817 Company, 818 ListCompaniesPage, 819 ListCompaniesFixedSizeCollection> { 820 createAsync( PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, ApiFuture<ListCompaniesResponse> futureResponse)821 public static ApiFuture<ListCompaniesPagedResponse> createAsync( 822 PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, 823 ApiFuture<ListCompaniesResponse> futureResponse) { 824 ApiFuture<ListCompaniesPage> futurePage = 825 ListCompaniesPage.createEmptyPage().createPageAsync(context, futureResponse); 826 return ApiFutures.transform( 827 futurePage, 828 input -> new ListCompaniesPagedResponse(input), 829 MoreExecutors.directExecutor()); 830 } 831 ListCompaniesPagedResponse(ListCompaniesPage page)832 private ListCompaniesPagedResponse(ListCompaniesPage page) { 833 super(page, ListCompaniesFixedSizeCollection.createEmptyCollection()); 834 } 835 } 836 837 public static class ListCompaniesPage 838 extends AbstractPage< 839 ListCompaniesRequest, ListCompaniesResponse, Company, ListCompaniesPage> { 840 ListCompaniesPage( PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, ListCompaniesResponse response)841 private ListCompaniesPage( 842 PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, 843 ListCompaniesResponse response) { 844 super(context, response); 845 } 846 createEmptyPage()847 private static ListCompaniesPage createEmptyPage() { 848 return new ListCompaniesPage(null, null); 849 } 850 851 @Override createPage( PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, ListCompaniesResponse response)852 protected ListCompaniesPage createPage( 853 PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, 854 ListCompaniesResponse response) { 855 return new ListCompaniesPage(context, response); 856 } 857 858 @Override createPageAsync( PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, ApiFuture<ListCompaniesResponse> futureResponse)859 public ApiFuture<ListCompaniesPage> createPageAsync( 860 PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, 861 ApiFuture<ListCompaniesResponse> futureResponse) { 862 return super.createPageAsync(context, futureResponse); 863 } 864 } 865 866 public static class ListCompaniesFixedSizeCollection 867 extends AbstractFixedSizeCollection< 868 ListCompaniesRequest, 869 ListCompaniesResponse, 870 Company, 871 ListCompaniesPage, 872 ListCompaniesFixedSizeCollection> { 873 ListCompaniesFixedSizeCollection(List<ListCompaniesPage> pages, int collectionSize)874 private ListCompaniesFixedSizeCollection(List<ListCompaniesPage> pages, int collectionSize) { 875 super(pages, collectionSize); 876 } 877 createEmptyCollection()878 private static ListCompaniesFixedSizeCollection createEmptyCollection() { 879 return new ListCompaniesFixedSizeCollection(null, 0); 880 } 881 882 @Override createCollection( List<ListCompaniesPage> pages, int collectionSize)883 protected ListCompaniesFixedSizeCollection createCollection( 884 List<ListCompaniesPage> pages, int collectionSize) { 885 return new ListCompaniesFixedSizeCollection(pages, collectionSize); 886 } 887 } 888 } 889