• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.core.BetaApi;
22 import com.google.api.gax.core.BackgroundResource;
23 import com.google.api.gax.paging.AbstractFixedSizeCollection;
24 import com.google.api.gax.paging.AbstractPage;
25 import com.google.api.gax.paging.AbstractPagedListResponse;
26 import com.google.api.gax.rpc.PageContext;
27 import com.google.api.gax.rpc.UnaryCallable;
28 import com.google.cloud.talent.v4beta1.stub.CompanyServiceStub;
29 import com.google.cloud.talent.v4beta1.stub.CompanyServiceStubSettings;
30 import com.google.common.util.concurrent.MoreExecutors;
31 import com.google.protobuf.Empty;
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  *   ProjectName parent = ProjectName.of("[PROJECT]");
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 @BetaApi
128 @Generated("by gapic-generator-java")
129 public class CompanyServiceClient implements BackgroundResource {
130   private final CompanyServiceSettings settings;
131   private final CompanyServiceStub stub;
132 
133   /** Constructs an instance of CompanyServiceClient with default settings. */
create()134   public static final CompanyServiceClient create() throws IOException {
135     return create(CompanyServiceSettings.newBuilder().build());
136   }
137 
138   /**
139    * Constructs an instance of CompanyServiceClient, using the given settings. The channels are
140    * created based on the settings passed in, or defaults for any settings that are not set.
141    */
create(CompanyServiceSettings settings)142   public static final CompanyServiceClient create(CompanyServiceSettings settings)
143       throws IOException {
144     return new CompanyServiceClient(settings);
145   }
146 
147   /**
148    * Constructs an instance of CompanyServiceClient, using the given stub for making calls. This is
149    * for advanced usage - prefer using create(CompanyServiceSettings).
150    */
create(CompanyServiceStub stub)151   public static final CompanyServiceClient create(CompanyServiceStub stub) {
152     return new CompanyServiceClient(stub);
153   }
154 
155   /**
156    * Constructs an instance of CompanyServiceClient, using the given settings. This is protected so
157    * that it is easy to make a subclass, but otherwise, the static factory methods should be
158    * preferred.
159    */
CompanyServiceClient(CompanyServiceSettings settings)160   protected CompanyServiceClient(CompanyServiceSettings settings) throws IOException {
161     this.settings = settings;
162     this.stub = ((CompanyServiceStubSettings) settings.getStubSettings()).createStub();
163   }
164 
CompanyServiceClient(CompanyServiceStub stub)165   protected CompanyServiceClient(CompanyServiceStub stub) {
166     this.settings = null;
167     this.stub = stub;
168   }
169 
getSettings()170   public final CompanyServiceSettings getSettings() {
171     return settings;
172   }
173 
getStub()174   public CompanyServiceStub getStub() {
175     return stub;
176   }
177 
178   // AUTO-GENERATED DOCUMENTATION AND METHOD.
179   /**
180    * Creates a new company entity.
181    *
182    * <p>Sample code:
183    *
184    * <pre>{@code
185    * // This snippet has been automatically generated and should be regarded as a code template only.
186    * // It will require modifications to work:
187    * // - It may require correct/in-range values for request initialization.
188    * // - It may require specifying regional endpoints when creating the service client as shown in
189    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
190    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
191    *   ProjectName parent = ProjectName.of("[PROJECT]");
192    *   Company company = Company.newBuilder().build();
193    *   Company response = companyServiceClient.createCompany(parent, company);
194    * }
195    * }</pre>
196    *
197    * @param parent Required. Resource name of the tenant under which the company is created.
198    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
199    *     "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant is created, for
200    *     example, "projects/foo".
201    * @param company Required. The company to be created.
202    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
203    */
createCompany(ProjectName parent, Company company)204   public final Company createCompany(ProjectName parent, Company company) {
205     CreateCompanyRequest request =
206         CreateCompanyRequest.newBuilder()
207             .setParent(parent == null ? null : parent.toString())
208             .setCompany(company)
209             .build();
210     return createCompany(request);
211   }
212 
213   // AUTO-GENERATED DOCUMENTATION AND METHOD.
214   /**
215    * Creates a new company entity.
216    *
217    * <p>Sample code:
218    *
219    * <pre>{@code
220    * // This snippet has been automatically generated and should be regarded as a code template only.
221    * // It will require modifications to work:
222    * // - It may require correct/in-range values for request initialization.
223    * // - It may require specifying regional endpoints when creating the service client as shown in
224    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
225    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
226    *   TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
227    *   Company company = Company.newBuilder().build();
228    *   Company response = companyServiceClient.createCompany(parent, company);
229    * }
230    * }</pre>
231    *
232    * @param parent Required. Resource name of the tenant under which the company is created.
233    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
234    *     "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant is created, for
235    *     example, "projects/foo".
236    * @param company Required. The company to be created.
237    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
238    */
createCompany(TenantName parent, Company company)239   public final Company createCompany(TenantName parent, Company company) {
240     CreateCompanyRequest request =
241         CreateCompanyRequest.newBuilder()
242             .setParent(parent == null ? null : parent.toString())
243             .setCompany(company)
244             .build();
245     return createCompany(request);
246   }
247 
248   // AUTO-GENERATED DOCUMENTATION AND METHOD.
249   /**
250    * Creates a new company entity.
251    *
252    * <p>Sample code:
253    *
254    * <pre>{@code
255    * // This snippet has been automatically generated and should be regarded as a code template only.
256    * // It will require modifications to work:
257    * // - It may require correct/in-range values for request initialization.
258    * // - It may require specifying regional endpoints when creating the service client as shown in
259    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
260    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
261    *   String parent = TenantName.of("[PROJECT]", "[TENANT]").toString();
262    *   Company company = Company.newBuilder().build();
263    *   Company response = companyServiceClient.createCompany(parent, company);
264    * }
265    * }</pre>
266    *
267    * @param parent Required. Resource name of the tenant under which the company is created.
268    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
269    *     "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant is created, for
270    *     example, "projects/foo".
271    * @param company Required. The company to be created.
272    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
273    */
createCompany(String parent, Company company)274   public final Company createCompany(String parent, Company company) {
275     CreateCompanyRequest request =
276         CreateCompanyRequest.newBuilder().setParent(parent).setCompany(company).build();
277     return createCompany(request);
278   }
279 
280   // AUTO-GENERATED DOCUMENTATION AND METHOD.
281   /**
282    * Creates a new company entity.
283    *
284    * <p>Sample code:
285    *
286    * <pre>{@code
287    * // This snippet has been automatically generated and should be regarded as a code template only.
288    * // It will require modifications to work:
289    * // - It may require correct/in-range values for request initialization.
290    * // - It may require specifying regional endpoints when creating the service client as shown in
291    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
292    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
293    *   CreateCompanyRequest request =
294    *       CreateCompanyRequest.newBuilder()
295    *           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
296    *           .setCompany(Company.newBuilder().build())
297    *           .build();
298    *   Company response = companyServiceClient.createCompany(request);
299    * }
300    * }</pre>
301    *
302    * @param request The request object containing all of the parameters for the API call.
303    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
304    */
createCompany(CreateCompanyRequest request)305   public final Company createCompany(CreateCompanyRequest request) {
306     return createCompanyCallable().call(request);
307   }
308 
309   // AUTO-GENERATED DOCUMENTATION AND METHOD.
310   /**
311    * Creates a new company entity.
312    *
313    * <p>Sample code:
314    *
315    * <pre>{@code
316    * // This snippet has been automatically generated and should be regarded as a code template only.
317    * // It will require modifications to work:
318    * // - It may require correct/in-range values for request initialization.
319    * // - It may require specifying regional endpoints when creating the service client as shown in
320    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
321    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
322    *   CreateCompanyRequest request =
323    *       CreateCompanyRequest.newBuilder()
324    *           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
325    *           .setCompany(Company.newBuilder().build())
326    *           .build();
327    *   ApiFuture<Company> future = companyServiceClient.createCompanyCallable().futureCall(request);
328    *   // Do something.
329    *   Company response = future.get();
330    * }
331    * }</pre>
332    */
createCompanyCallable()333   public final UnaryCallable<CreateCompanyRequest, Company> createCompanyCallable() {
334     return stub.createCompanyCallable();
335   }
336 
337   // AUTO-GENERATED DOCUMENTATION AND METHOD.
338   /**
339    * Retrieves specified company.
340    *
341    * <p>Sample code:
342    *
343    * <pre>{@code
344    * // This snippet has been automatically generated and should be regarded as a code template only.
345    * // It will require modifications to work:
346    * // - It may require correct/in-range values for request initialization.
347    * // - It may require specifying regional endpoints when creating the service client as shown in
348    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
349    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
350    *   CompanyName name =
351    *       CompanyName.ofProjectTenantCompanyName("[PROJECT]", "[TENANT]", "[COMPANY]");
352    *   Company response = companyServiceClient.getCompany(name);
353    * }
354    * }</pre>
355    *
356    * @param name Required. The resource name of the company to be retrieved.
357    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for
358    *     example, "projects/api-test-project/tenants/foo/companies/bar".
359    *     <p>If tenant id is unspecified, the default tenant is used, for example,
360    *     "projects/api-test-project/companies/bar".
361    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
362    */
getCompany(CompanyName name)363   public final Company getCompany(CompanyName name) {
364     GetCompanyRequest request =
365         GetCompanyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
366     return getCompany(request);
367   }
368 
369   // AUTO-GENERATED DOCUMENTATION AND METHOD.
370   /**
371    * Retrieves specified company.
372    *
373    * <p>Sample code:
374    *
375    * <pre>{@code
376    * // This snippet has been automatically generated and should be regarded as a code template only.
377    * // It will require modifications to work:
378    * // - It may require correct/in-range values for request initialization.
379    * // - It may require specifying regional endpoints when creating the service client as shown in
380    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
381    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
382    *   String name =
383    *       CompanyName.ofProjectTenantCompanyName("[PROJECT]", "[TENANT]", "[COMPANY]").toString();
384    *   Company response = companyServiceClient.getCompany(name);
385    * }
386    * }</pre>
387    *
388    * @param name Required. The resource name of the company to be retrieved.
389    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for
390    *     example, "projects/api-test-project/tenants/foo/companies/bar".
391    *     <p>If tenant id is unspecified, the default tenant is used, for example,
392    *     "projects/api-test-project/companies/bar".
393    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
394    */
getCompany(String name)395   public final Company getCompany(String name) {
396     GetCompanyRequest request = GetCompanyRequest.newBuilder().setName(name).build();
397     return getCompany(request);
398   }
399 
400   // AUTO-GENERATED DOCUMENTATION AND METHOD.
401   /**
402    * Retrieves specified company.
403    *
404    * <p>Sample code:
405    *
406    * <pre>{@code
407    * // This snippet has been automatically generated and should be regarded as a code template only.
408    * // It will require modifications to work:
409    * // - It may require correct/in-range values for request initialization.
410    * // - It may require specifying regional endpoints when creating the service client as shown in
411    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
412    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
413    *   GetCompanyRequest request =
414    *       GetCompanyRequest.newBuilder()
415    *           .setName(
416    *               CompanyName.ofProjectTenantCompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")
417    *                   .toString())
418    *           .build();
419    *   Company response = companyServiceClient.getCompany(request);
420    * }
421    * }</pre>
422    *
423    * @param request The request object containing all of the parameters for the API call.
424    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
425    */
getCompany(GetCompanyRequest request)426   public final Company getCompany(GetCompanyRequest request) {
427     return getCompanyCallable().call(request);
428   }
429 
430   // AUTO-GENERATED DOCUMENTATION AND METHOD.
431   /**
432    * Retrieves specified company.
433    *
434    * <p>Sample code:
435    *
436    * <pre>{@code
437    * // This snippet has been automatically generated and should be regarded as a code template only.
438    * // It will require modifications to work:
439    * // - It may require correct/in-range values for request initialization.
440    * // - It may require specifying regional endpoints when creating the service client as shown in
441    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
442    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
443    *   GetCompanyRequest request =
444    *       GetCompanyRequest.newBuilder()
445    *           .setName(
446    *               CompanyName.ofProjectTenantCompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")
447    *                   .toString())
448    *           .build();
449    *   ApiFuture<Company> future = companyServiceClient.getCompanyCallable().futureCall(request);
450    *   // Do something.
451    *   Company response = future.get();
452    * }
453    * }</pre>
454    */
getCompanyCallable()455   public final UnaryCallable<GetCompanyRequest, Company> getCompanyCallable() {
456     return stub.getCompanyCallable();
457   }
458 
459   // AUTO-GENERATED DOCUMENTATION AND METHOD.
460   /**
461    * Updates specified company.
462    *
463    * <p>Sample code:
464    *
465    * <pre>{@code
466    * // This snippet has been automatically generated and should be regarded as a code template only.
467    * // It will require modifications to work:
468    * // - It may require correct/in-range values for request initialization.
469    * // - It may require specifying regional endpoints when creating the service client as shown in
470    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
471    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
472    *   Company company = Company.newBuilder().build();
473    *   Company response = companyServiceClient.updateCompany(company);
474    * }
475    * }</pre>
476    *
477    * @param company Required. The company resource to replace the current resource in the system.
478    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
479    */
updateCompany(Company company)480   public final Company updateCompany(Company company) {
481     UpdateCompanyRequest request = UpdateCompanyRequest.newBuilder().setCompany(company).build();
482     return updateCompany(request);
483   }
484 
485   // AUTO-GENERATED DOCUMENTATION AND METHOD.
486   /**
487    * Updates specified company.
488    *
489    * <p>Sample code:
490    *
491    * <pre>{@code
492    * // This snippet has been automatically generated and should be regarded as a code template only.
493    * // It will require modifications to work:
494    * // - It may require correct/in-range values for request initialization.
495    * // - It may require specifying regional endpoints when creating the service client as shown in
496    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
497    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
498    *   UpdateCompanyRequest request =
499    *       UpdateCompanyRequest.newBuilder()
500    *           .setCompany(Company.newBuilder().build())
501    *           .setUpdateMask(FieldMask.newBuilder().build())
502    *           .build();
503    *   Company response = companyServiceClient.updateCompany(request);
504    * }
505    * }</pre>
506    *
507    * @param request The request object containing all of the parameters for the API call.
508    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
509    */
updateCompany(UpdateCompanyRequest request)510   public final Company updateCompany(UpdateCompanyRequest request) {
511     return updateCompanyCallable().call(request);
512   }
513 
514   // AUTO-GENERATED DOCUMENTATION AND METHOD.
515   /**
516    * Updates specified company.
517    *
518    * <p>Sample code:
519    *
520    * <pre>{@code
521    * // This snippet has been automatically generated and should be regarded as a code template only.
522    * // It will require modifications to work:
523    * // - It may require correct/in-range values for request initialization.
524    * // - It may require specifying regional endpoints when creating the service client as shown in
525    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
526    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
527    *   UpdateCompanyRequest request =
528    *       UpdateCompanyRequest.newBuilder()
529    *           .setCompany(Company.newBuilder().build())
530    *           .setUpdateMask(FieldMask.newBuilder().build())
531    *           .build();
532    *   ApiFuture<Company> future = companyServiceClient.updateCompanyCallable().futureCall(request);
533    *   // Do something.
534    *   Company response = future.get();
535    * }
536    * }</pre>
537    */
updateCompanyCallable()538   public final UnaryCallable<UpdateCompanyRequest, Company> updateCompanyCallable() {
539     return stub.updateCompanyCallable();
540   }
541 
542   // AUTO-GENERATED DOCUMENTATION AND METHOD.
543   /**
544    * Deletes specified company. Prerequisite: The company has no jobs associated with it.
545    *
546    * <p>Sample code:
547    *
548    * <pre>{@code
549    * // This snippet has been automatically generated and should be regarded as a code template only.
550    * // It will require modifications to work:
551    * // - It may require correct/in-range values for request initialization.
552    * // - It may require specifying regional endpoints when creating the service client as shown in
553    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
554    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
555    *   CompanyName name =
556    *       CompanyName.ofProjectTenantCompanyName("[PROJECT]", "[TENANT]", "[COMPANY]");
557    *   companyServiceClient.deleteCompany(name);
558    * }
559    * }</pre>
560    *
561    * @param name Required. The resource name of the company to be deleted.
562    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for
563    *     example, "projects/foo/tenants/bar/companies/baz".
564    *     <p>If tenant id is unspecified, the default tenant is used, for example,
565    *     "projects/foo/companies/bar".
566    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
567    */
deleteCompany(CompanyName name)568   public final void deleteCompany(CompanyName name) {
569     DeleteCompanyRequest request =
570         DeleteCompanyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
571     deleteCompany(request);
572   }
573 
574   // AUTO-GENERATED DOCUMENTATION AND METHOD.
575   /**
576    * Deletes specified company. Prerequisite: The company has no jobs associated with it.
577    *
578    * <p>Sample code:
579    *
580    * <pre>{@code
581    * // This snippet has been automatically generated and should be regarded as a code template only.
582    * // It will require modifications to work:
583    * // - It may require correct/in-range values for request initialization.
584    * // - It may require specifying regional endpoints when creating the service client as shown in
585    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
586    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
587    *   String name =
588    *       CompanyName.ofProjectTenantCompanyName("[PROJECT]", "[TENANT]", "[COMPANY]").toString();
589    *   companyServiceClient.deleteCompany(name);
590    * }
591    * }</pre>
592    *
593    * @param name Required. The resource name of the company to be deleted.
594    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for
595    *     example, "projects/foo/tenants/bar/companies/baz".
596    *     <p>If tenant id is unspecified, the default tenant is used, for example,
597    *     "projects/foo/companies/bar".
598    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
599    */
deleteCompany(String name)600   public final void deleteCompany(String name) {
601     DeleteCompanyRequest request = DeleteCompanyRequest.newBuilder().setName(name).build();
602     deleteCompany(request);
603   }
604 
605   // AUTO-GENERATED DOCUMENTATION AND METHOD.
606   /**
607    * Deletes specified company. Prerequisite: The company has no jobs associated with it.
608    *
609    * <p>Sample code:
610    *
611    * <pre>{@code
612    * // This snippet has been automatically generated and should be regarded as a code template only.
613    * // It will require modifications to work:
614    * // - It may require correct/in-range values for request initialization.
615    * // - It may require specifying regional endpoints when creating the service client as shown in
616    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
617    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
618    *   DeleteCompanyRequest request =
619    *       DeleteCompanyRequest.newBuilder()
620    *           .setName(
621    *               CompanyName.ofProjectTenantCompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")
622    *                   .toString())
623    *           .build();
624    *   companyServiceClient.deleteCompany(request);
625    * }
626    * }</pre>
627    *
628    * @param request The request object containing all of the parameters for the API call.
629    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
630    */
deleteCompany(DeleteCompanyRequest request)631   public final void deleteCompany(DeleteCompanyRequest request) {
632     deleteCompanyCallable().call(request);
633   }
634 
635   // AUTO-GENERATED DOCUMENTATION AND METHOD.
636   /**
637    * Deletes specified company. Prerequisite: The company has no jobs associated with it.
638    *
639    * <p>Sample code:
640    *
641    * <pre>{@code
642    * // This snippet has been automatically generated and should be regarded as a code template only.
643    * // It will require modifications to work:
644    * // - It may require correct/in-range values for request initialization.
645    * // - It may require specifying regional endpoints when creating the service client as shown in
646    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
647    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
648    *   DeleteCompanyRequest request =
649    *       DeleteCompanyRequest.newBuilder()
650    *           .setName(
651    *               CompanyName.ofProjectTenantCompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")
652    *                   .toString())
653    *           .build();
654    *   ApiFuture<Empty> future = companyServiceClient.deleteCompanyCallable().futureCall(request);
655    *   // Do something.
656    *   future.get();
657    * }
658    * }</pre>
659    */
deleteCompanyCallable()660   public final UnaryCallable<DeleteCompanyRequest, Empty> deleteCompanyCallable() {
661     return stub.deleteCompanyCallable();
662   }
663 
664   // AUTO-GENERATED DOCUMENTATION AND METHOD.
665   /**
666    * Lists all companies associated with the project.
667    *
668    * <p>Sample code:
669    *
670    * <pre>{@code
671    * // This snippet has been automatically generated and should be regarded as a code template only.
672    * // It will require modifications to work:
673    * // - It may require correct/in-range values for request initialization.
674    * // - It may require specifying regional endpoints when creating the service client as shown in
675    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
676    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
677    *   ProjectName parent = ProjectName.of("[PROJECT]");
678    *   for (Company element : companyServiceClient.listCompanies(parent).iterateAll()) {
679    *     // doThingsWith(element);
680    *   }
681    * }
682    * }</pre>
683    *
684    * @param parent Required. Resource name of the tenant under which the company is created.
685    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
686    *     "projects/foo/tenant/bar".
687    *     <p>If tenant id is unspecified, the default tenant will be used, for example,
688    *     "projects/foo".
689    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
690    */
listCompanies(ProjectName parent)691   public final ListCompaniesPagedResponse listCompanies(ProjectName parent) {
692     ListCompaniesRequest request =
693         ListCompaniesRequest.newBuilder()
694             .setParent(parent == null ? null : parent.toString())
695             .build();
696     return listCompanies(request);
697   }
698 
699   // AUTO-GENERATED DOCUMENTATION AND METHOD.
700   /**
701    * Lists all companies associated with the project.
702    *
703    * <p>Sample code:
704    *
705    * <pre>{@code
706    * // This snippet has been automatically generated and should be regarded as a code template only.
707    * // It will require modifications to work:
708    * // - It may require correct/in-range values for request initialization.
709    * // - It may require specifying regional endpoints when creating the service client as shown in
710    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
711    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
712    *   TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
713    *   for (Company element : companyServiceClient.listCompanies(parent).iterateAll()) {
714    *     // doThingsWith(element);
715    *   }
716    * }
717    * }</pre>
718    *
719    * @param parent Required. Resource name of the tenant under which the company is created.
720    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
721    *     "projects/foo/tenant/bar".
722    *     <p>If tenant id is unspecified, the default tenant will be used, for example,
723    *     "projects/foo".
724    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
725    */
listCompanies(TenantName parent)726   public final ListCompaniesPagedResponse listCompanies(TenantName parent) {
727     ListCompaniesRequest request =
728         ListCompaniesRequest.newBuilder()
729             .setParent(parent == null ? null : parent.toString())
730             .build();
731     return listCompanies(request);
732   }
733 
734   // AUTO-GENERATED DOCUMENTATION AND METHOD.
735   /**
736    * Lists all companies associated with the project.
737    *
738    * <p>Sample code:
739    *
740    * <pre>{@code
741    * // This snippet has been automatically generated and should be regarded as a code template only.
742    * // It will require modifications to work:
743    * // - It may require correct/in-range values for request initialization.
744    * // - It may require specifying regional endpoints when creating the service client as shown in
745    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
746    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
747    *   String parent = TenantName.of("[PROJECT]", "[TENANT]").toString();
748    *   for (Company element : companyServiceClient.listCompanies(parent).iterateAll()) {
749    *     // doThingsWith(element);
750    *   }
751    * }
752    * }</pre>
753    *
754    * @param parent Required. Resource name of the tenant under which the company is created.
755    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
756    *     "projects/foo/tenant/bar".
757    *     <p>If tenant id is unspecified, the default tenant will be used, for example,
758    *     "projects/foo".
759    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
760    */
listCompanies(String parent)761   public final ListCompaniesPagedResponse listCompanies(String parent) {
762     ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent).build();
763     return listCompanies(request);
764   }
765 
766   // AUTO-GENERATED DOCUMENTATION AND METHOD.
767   /**
768    * Lists all companies associated with the project.
769    *
770    * <p>Sample code:
771    *
772    * <pre>{@code
773    * // This snippet has been automatically generated and should be regarded as a code template only.
774    * // It will require modifications to work:
775    * // - It may require correct/in-range values for request initialization.
776    * // - It may require specifying regional endpoints when creating the service client as shown in
777    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
778    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
779    *   ListCompaniesRequest request =
780    *       ListCompaniesRequest.newBuilder()
781    *           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
782    *           .setPageToken("pageToken873572522")
783    *           .setPageSize(883849137)
784    *           .setRequireOpenJobs(true)
785    *           .build();
786    *   for (Company element : companyServiceClient.listCompanies(request).iterateAll()) {
787    *     // doThingsWith(element);
788    *   }
789    * }
790    * }</pre>
791    *
792    * @param request The request object containing all of the parameters for the API call.
793    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
794    */
listCompanies(ListCompaniesRequest request)795   public final ListCompaniesPagedResponse listCompanies(ListCompaniesRequest request) {
796     return listCompaniesPagedCallable().call(request);
797   }
798 
799   // AUTO-GENERATED DOCUMENTATION AND METHOD.
800   /**
801    * Lists all companies associated with the project.
802    *
803    * <p>Sample code:
804    *
805    * <pre>{@code
806    * // This snippet has been automatically generated and should be regarded as a code template only.
807    * // It will require modifications to work:
808    * // - It may require correct/in-range values for request initialization.
809    * // - It may require specifying regional endpoints when creating the service client as shown in
810    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
811    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
812    *   ListCompaniesRequest request =
813    *       ListCompaniesRequest.newBuilder()
814    *           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
815    *           .setPageToken("pageToken873572522")
816    *           .setPageSize(883849137)
817    *           .setRequireOpenJobs(true)
818    *           .build();
819    *   ApiFuture<Company> future =
820    *       companyServiceClient.listCompaniesPagedCallable().futureCall(request);
821    *   // Do something.
822    *   for (Company element : future.get().iterateAll()) {
823    *     // doThingsWith(element);
824    *   }
825    * }
826    * }</pre>
827    */
828   public final UnaryCallable<ListCompaniesRequest, ListCompaniesPagedResponse>
listCompaniesPagedCallable()829       listCompaniesPagedCallable() {
830     return stub.listCompaniesPagedCallable();
831   }
832 
833   // AUTO-GENERATED DOCUMENTATION AND METHOD.
834   /**
835    * Lists all companies associated with the project.
836    *
837    * <p>Sample code:
838    *
839    * <pre>{@code
840    * // This snippet has been automatically generated and should be regarded as a code template only.
841    * // It will require modifications to work:
842    * // - It may require correct/in-range values for request initialization.
843    * // - It may require specifying regional endpoints when creating the service client as shown in
844    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
845    * try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
846    *   ListCompaniesRequest request =
847    *       ListCompaniesRequest.newBuilder()
848    *           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
849    *           .setPageToken("pageToken873572522")
850    *           .setPageSize(883849137)
851    *           .setRequireOpenJobs(true)
852    *           .build();
853    *   while (true) {
854    *     ListCompaniesResponse response = companyServiceClient.listCompaniesCallable().call(request);
855    *     for (Company element : response.getCompaniesList()) {
856    *       // doThingsWith(element);
857    *     }
858    *     String nextPageToken = response.getNextPageToken();
859    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
860    *       request = request.toBuilder().setPageToken(nextPageToken).build();
861    *     } else {
862    *       break;
863    *     }
864    *   }
865    * }
866    * }</pre>
867    */
listCompaniesCallable()868   public final UnaryCallable<ListCompaniesRequest, ListCompaniesResponse> listCompaniesCallable() {
869     return stub.listCompaniesCallable();
870   }
871 
872   @Override
close()873   public final void close() {
874     stub.close();
875   }
876 
877   @Override
shutdown()878   public void shutdown() {
879     stub.shutdown();
880   }
881 
882   @Override
isShutdown()883   public boolean isShutdown() {
884     return stub.isShutdown();
885   }
886 
887   @Override
isTerminated()888   public boolean isTerminated() {
889     return stub.isTerminated();
890   }
891 
892   @Override
shutdownNow()893   public void shutdownNow() {
894     stub.shutdownNow();
895   }
896 
897   @Override
awaitTermination(long duration, TimeUnit unit)898   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
899     return stub.awaitTermination(duration, unit);
900   }
901 
902   public static class ListCompaniesPagedResponse
903       extends AbstractPagedListResponse<
904           ListCompaniesRequest,
905           ListCompaniesResponse,
906           Company,
907           ListCompaniesPage,
908           ListCompaniesFixedSizeCollection> {
909 
createAsync( PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, ApiFuture<ListCompaniesResponse> futureResponse)910     public static ApiFuture<ListCompaniesPagedResponse> createAsync(
911         PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context,
912         ApiFuture<ListCompaniesResponse> futureResponse) {
913       ApiFuture<ListCompaniesPage> futurePage =
914           ListCompaniesPage.createEmptyPage().createPageAsync(context, futureResponse);
915       return ApiFutures.transform(
916           futurePage,
917           input -> new ListCompaniesPagedResponse(input),
918           MoreExecutors.directExecutor());
919     }
920 
ListCompaniesPagedResponse(ListCompaniesPage page)921     private ListCompaniesPagedResponse(ListCompaniesPage page) {
922       super(page, ListCompaniesFixedSizeCollection.createEmptyCollection());
923     }
924   }
925 
926   public static class ListCompaniesPage
927       extends AbstractPage<
928           ListCompaniesRequest, ListCompaniesResponse, Company, ListCompaniesPage> {
929 
ListCompaniesPage( PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, ListCompaniesResponse response)930     private ListCompaniesPage(
931         PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context,
932         ListCompaniesResponse response) {
933       super(context, response);
934     }
935 
createEmptyPage()936     private static ListCompaniesPage createEmptyPage() {
937       return new ListCompaniesPage(null, null);
938     }
939 
940     @Override
createPage( PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, ListCompaniesResponse response)941     protected ListCompaniesPage createPage(
942         PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context,
943         ListCompaniesResponse response) {
944       return new ListCompaniesPage(context, response);
945     }
946 
947     @Override
createPageAsync( PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context, ApiFuture<ListCompaniesResponse> futureResponse)948     public ApiFuture<ListCompaniesPage> createPageAsync(
949         PageContext<ListCompaniesRequest, ListCompaniesResponse, Company> context,
950         ApiFuture<ListCompaniesResponse> futureResponse) {
951       return super.createPageAsync(context, futureResponse);
952     }
953   }
954 
955   public static class ListCompaniesFixedSizeCollection
956       extends AbstractFixedSizeCollection<
957           ListCompaniesRequest,
958           ListCompaniesResponse,
959           Company,
960           ListCompaniesPage,
961           ListCompaniesFixedSizeCollection> {
962 
ListCompaniesFixedSizeCollection(List<ListCompaniesPage> pages, int collectionSize)963     private ListCompaniesFixedSizeCollection(List<ListCompaniesPage> pages, int collectionSize) {
964       super(pages, collectionSize);
965     }
966 
createEmptyCollection()967     private static ListCompaniesFixedSizeCollection createEmptyCollection() {
968       return new ListCompaniesFixedSizeCollection(null, 0);
969     }
970 
971     @Override
createCollection( List<ListCompaniesPage> pages, int collectionSize)972     protected ListCompaniesFixedSizeCollection createCollection(
973         List<ListCompaniesPage> pages, int collectionSize) {
974       return new ListCompaniesFixedSizeCollection(pages, collectionSize);
975     }
976   }
977 }
978