• 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.TenantServiceStub;
29 import com.google.cloud.talent.v4beta1.stub.TenantServiceStubSettings;
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 tenant 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 (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
51  *   ProjectName parent = ProjectName.of("[PROJECT]");
52  *   Tenant tenant = Tenant.newBuilder().build();
53  *   Tenant response = tenantServiceClient.createTenant(parent, tenant);
54  * }
55  * }</pre>
56  *
57  * <p>Note: close() needs to be called on the TenantServiceClient 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 TenantServiceSettings 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  * TenantServiceSettings tenantServiceSettings =
92  *     TenantServiceSettings.newBuilder()
93  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
94  *         .build();
95  * TenantServiceClient tenantServiceClient = TenantServiceClient.create(tenantServiceSettings);
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  * TenantServiceSettings tenantServiceSettings =
107  *     TenantServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
108  * TenantServiceClient tenantServiceClient = TenantServiceClient.create(tenantServiceSettings);
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  * TenantServiceSettings tenantServiceSettings =
121  *     TenantServiceSettings.newHttpJsonBuilder().build();
122  * TenantServiceClient tenantServiceClient = TenantServiceClient.create(tenantServiceSettings);
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 TenantServiceClient implements BackgroundResource {
130   private final TenantServiceSettings settings;
131   private final TenantServiceStub stub;
132 
133   /** Constructs an instance of TenantServiceClient with default settings. */
create()134   public static final TenantServiceClient create() throws IOException {
135     return create(TenantServiceSettings.newBuilder().build());
136   }
137 
138   /**
139    * Constructs an instance of TenantServiceClient, 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(TenantServiceSettings settings)142   public static final TenantServiceClient create(TenantServiceSettings settings)
143       throws IOException {
144     return new TenantServiceClient(settings);
145   }
146 
147   /**
148    * Constructs an instance of TenantServiceClient, using the given stub for making calls. This is
149    * for advanced usage - prefer using create(TenantServiceSettings).
150    */
create(TenantServiceStub stub)151   public static final TenantServiceClient create(TenantServiceStub stub) {
152     return new TenantServiceClient(stub);
153   }
154 
155   /**
156    * Constructs an instance of TenantServiceClient, 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    */
TenantServiceClient(TenantServiceSettings settings)160   protected TenantServiceClient(TenantServiceSettings settings) throws IOException {
161     this.settings = settings;
162     this.stub = ((TenantServiceStubSettings) settings.getStubSettings()).createStub();
163   }
164 
TenantServiceClient(TenantServiceStub stub)165   protected TenantServiceClient(TenantServiceStub stub) {
166     this.settings = null;
167     this.stub = stub;
168   }
169 
getSettings()170   public final TenantServiceSettings getSettings() {
171     return settings;
172   }
173 
getStub()174   public TenantServiceStub getStub() {
175     return stub;
176   }
177 
178   // AUTO-GENERATED DOCUMENTATION AND METHOD.
179   /**
180    * Creates a new tenant 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 (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
191    *   ProjectName parent = ProjectName.of("[PROJECT]");
192    *   Tenant tenant = Tenant.newBuilder().build();
193    *   Tenant response = tenantServiceClient.createTenant(parent, tenant);
194    * }
195    * }</pre>
196    *
197    * @param parent Required. Resource name of the project under which the tenant is created.
198    *     <p>The format is "projects/{project_id}", for example, "projects/foo".
199    * @param tenant Required. The tenant to be created.
200    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
201    */
createTenant(ProjectName parent, Tenant tenant)202   public final Tenant createTenant(ProjectName parent, Tenant tenant) {
203     CreateTenantRequest request =
204         CreateTenantRequest.newBuilder()
205             .setParent(parent == null ? null : parent.toString())
206             .setTenant(tenant)
207             .build();
208     return createTenant(request);
209   }
210 
211   // AUTO-GENERATED DOCUMENTATION AND METHOD.
212   /**
213    * Creates a new tenant 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 (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
224    *   String parent = ProjectName.of("[PROJECT]").toString();
225    *   Tenant tenant = Tenant.newBuilder().build();
226    *   Tenant response = tenantServiceClient.createTenant(parent, tenant);
227    * }
228    * }</pre>
229    *
230    * @param parent Required. Resource name of the project under which the tenant is created.
231    *     <p>The format is "projects/{project_id}", for example, "projects/foo".
232    * @param tenant Required. The tenant to be created.
233    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
234    */
createTenant(String parent, Tenant tenant)235   public final Tenant createTenant(String parent, Tenant tenant) {
236     CreateTenantRequest request =
237         CreateTenantRequest.newBuilder().setParent(parent).setTenant(tenant).build();
238     return createTenant(request);
239   }
240 
241   // AUTO-GENERATED DOCUMENTATION AND METHOD.
242   /**
243    * Creates a new tenant entity.
244    *
245    * <p>Sample code:
246    *
247    * <pre>{@code
248    * // This snippet has been automatically generated and should be regarded as a code template only.
249    * // It will require modifications to work:
250    * // - It may require correct/in-range values for request initialization.
251    * // - It may require specifying regional endpoints when creating the service client as shown in
252    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
253    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
254    *   CreateTenantRequest request =
255    *       CreateTenantRequest.newBuilder()
256    *           .setParent(ProjectName.of("[PROJECT]").toString())
257    *           .setTenant(Tenant.newBuilder().build())
258    *           .build();
259    *   Tenant response = tenantServiceClient.createTenant(request);
260    * }
261    * }</pre>
262    *
263    * @param request The request object containing all of the parameters for the API call.
264    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
265    */
createTenant(CreateTenantRequest request)266   public final Tenant createTenant(CreateTenantRequest request) {
267     return createTenantCallable().call(request);
268   }
269 
270   // AUTO-GENERATED DOCUMENTATION AND METHOD.
271   /**
272    * Creates a new tenant entity.
273    *
274    * <p>Sample code:
275    *
276    * <pre>{@code
277    * // This snippet has been automatically generated and should be regarded as a code template only.
278    * // It will require modifications to work:
279    * // - It may require correct/in-range values for request initialization.
280    * // - It may require specifying regional endpoints when creating the service client as shown in
281    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
282    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
283    *   CreateTenantRequest request =
284    *       CreateTenantRequest.newBuilder()
285    *           .setParent(ProjectName.of("[PROJECT]").toString())
286    *           .setTenant(Tenant.newBuilder().build())
287    *           .build();
288    *   ApiFuture<Tenant> future = tenantServiceClient.createTenantCallable().futureCall(request);
289    *   // Do something.
290    *   Tenant response = future.get();
291    * }
292    * }</pre>
293    */
createTenantCallable()294   public final UnaryCallable<CreateTenantRequest, Tenant> createTenantCallable() {
295     return stub.createTenantCallable();
296   }
297 
298   // AUTO-GENERATED DOCUMENTATION AND METHOD.
299   /**
300    * Retrieves specified tenant.
301    *
302    * <p>Sample code:
303    *
304    * <pre>{@code
305    * // This snippet has been automatically generated and should be regarded as a code template only.
306    * // It will require modifications to work:
307    * // - It may require correct/in-range values for request initialization.
308    * // - It may require specifying regional endpoints when creating the service client as shown in
309    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
310    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
311    *   TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
312    *   Tenant response = tenantServiceClient.getTenant(name);
313    * }
314    * }</pre>
315    *
316    * @param name Required. The resource name of the tenant to be retrieved.
317    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
318    *     "projects/foo/tenants/bar".
319    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
320    */
getTenant(TenantName name)321   public final Tenant getTenant(TenantName name) {
322     GetTenantRequest request =
323         GetTenantRequest.newBuilder().setName(name == null ? null : name.toString()).build();
324     return getTenant(request);
325   }
326 
327   // AUTO-GENERATED DOCUMENTATION AND METHOD.
328   /**
329    * Retrieves specified tenant.
330    *
331    * <p>Sample code:
332    *
333    * <pre>{@code
334    * // This snippet has been automatically generated and should be regarded as a code template only.
335    * // It will require modifications to work:
336    * // - It may require correct/in-range values for request initialization.
337    * // - It may require specifying regional endpoints when creating the service client as shown in
338    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
339    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
340    *   String name = TenantName.of("[PROJECT]", "[TENANT]").toString();
341    *   Tenant response = tenantServiceClient.getTenant(name);
342    * }
343    * }</pre>
344    *
345    * @param name Required. The resource name of the tenant to be retrieved.
346    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
347    *     "projects/foo/tenants/bar".
348    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
349    */
getTenant(String name)350   public final Tenant getTenant(String name) {
351     GetTenantRequest request = GetTenantRequest.newBuilder().setName(name).build();
352     return getTenant(request);
353   }
354 
355   // AUTO-GENERATED DOCUMENTATION AND METHOD.
356   /**
357    * Retrieves specified tenant.
358    *
359    * <p>Sample code:
360    *
361    * <pre>{@code
362    * // This snippet has been automatically generated and should be regarded as a code template only.
363    * // It will require modifications to work:
364    * // - It may require correct/in-range values for request initialization.
365    * // - It may require specifying regional endpoints when creating the service client as shown in
366    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
367    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
368    *   GetTenantRequest request =
369    *       GetTenantRequest.newBuilder()
370    *           .setName(TenantName.of("[PROJECT]", "[TENANT]").toString())
371    *           .build();
372    *   Tenant response = tenantServiceClient.getTenant(request);
373    * }
374    * }</pre>
375    *
376    * @param request The request object containing all of the parameters for the API call.
377    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
378    */
getTenant(GetTenantRequest request)379   public final Tenant getTenant(GetTenantRequest request) {
380     return getTenantCallable().call(request);
381   }
382 
383   // AUTO-GENERATED DOCUMENTATION AND METHOD.
384   /**
385    * Retrieves specified tenant.
386    *
387    * <p>Sample code:
388    *
389    * <pre>{@code
390    * // This snippet has been automatically generated and should be regarded as a code template only.
391    * // It will require modifications to work:
392    * // - It may require correct/in-range values for request initialization.
393    * // - It may require specifying regional endpoints when creating the service client as shown in
394    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
395    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
396    *   GetTenantRequest request =
397    *       GetTenantRequest.newBuilder()
398    *           .setName(TenantName.of("[PROJECT]", "[TENANT]").toString())
399    *           .build();
400    *   ApiFuture<Tenant> future = tenantServiceClient.getTenantCallable().futureCall(request);
401    *   // Do something.
402    *   Tenant response = future.get();
403    * }
404    * }</pre>
405    */
getTenantCallable()406   public final UnaryCallable<GetTenantRequest, Tenant> getTenantCallable() {
407     return stub.getTenantCallable();
408   }
409 
410   // AUTO-GENERATED DOCUMENTATION AND METHOD.
411   /**
412    * Updates specified tenant.
413    *
414    * <p>Sample code:
415    *
416    * <pre>{@code
417    * // This snippet has been automatically generated and should be regarded as a code template only.
418    * // It will require modifications to work:
419    * // - It may require correct/in-range values for request initialization.
420    * // - It may require specifying regional endpoints when creating the service client as shown in
421    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
422    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
423    *   Tenant tenant = Tenant.newBuilder().build();
424    *   Tenant response = tenantServiceClient.updateTenant(tenant);
425    * }
426    * }</pre>
427    *
428    * @param tenant Required. The tenant resource to replace the current resource in the system.
429    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
430    */
updateTenant(Tenant tenant)431   public final Tenant updateTenant(Tenant tenant) {
432     UpdateTenantRequest request = UpdateTenantRequest.newBuilder().setTenant(tenant).build();
433     return updateTenant(request);
434   }
435 
436   // AUTO-GENERATED DOCUMENTATION AND METHOD.
437   /**
438    * Updates specified tenant.
439    *
440    * <p>Sample code:
441    *
442    * <pre>{@code
443    * // This snippet has been automatically generated and should be regarded as a code template only.
444    * // It will require modifications to work:
445    * // - It may require correct/in-range values for request initialization.
446    * // - It may require specifying regional endpoints when creating the service client as shown in
447    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
448    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
449    *   UpdateTenantRequest request =
450    *       UpdateTenantRequest.newBuilder()
451    *           .setTenant(Tenant.newBuilder().build())
452    *           .setUpdateMask(FieldMask.newBuilder().build())
453    *           .build();
454    *   Tenant response = tenantServiceClient.updateTenant(request);
455    * }
456    * }</pre>
457    *
458    * @param request The request object containing all of the parameters for the API call.
459    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
460    */
updateTenant(UpdateTenantRequest request)461   public final Tenant updateTenant(UpdateTenantRequest request) {
462     return updateTenantCallable().call(request);
463   }
464 
465   // AUTO-GENERATED DOCUMENTATION AND METHOD.
466   /**
467    * Updates specified tenant.
468    *
469    * <p>Sample code:
470    *
471    * <pre>{@code
472    * // This snippet has been automatically generated and should be regarded as a code template only.
473    * // It will require modifications to work:
474    * // - It may require correct/in-range values for request initialization.
475    * // - It may require specifying regional endpoints when creating the service client as shown in
476    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
477    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
478    *   UpdateTenantRequest request =
479    *       UpdateTenantRequest.newBuilder()
480    *           .setTenant(Tenant.newBuilder().build())
481    *           .setUpdateMask(FieldMask.newBuilder().build())
482    *           .build();
483    *   ApiFuture<Tenant> future = tenantServiceClient.updateTenantCallable().futureCall(request);
484    *   // Do something.
485    *   Tenant response = future.get();
486    * }
487    * }</pre>
488    */
updateTenantCallable()489   public final UnaryCallable<UpdateTenantRequest, Tenant> updateTenantCallable() {
490     return stub.updateTenantCallable();
491   }
492 
493   // AUTO-GENERATED DOCUMENTATION AND METHOD.
494   /**
495    * Deletes specified tenant.
496    *
497    * <p>Sample code:
498    *
499    * <pre>{@code
500    * // This snippet has been automatically generated and should be regarded as a code template only.
501    * // It will require modifications to work:
502    * // - It may require correct/in-range values for request initialization.
503    * // - It may require specifying regional endpoints when creating the service client as shown in
504    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
505    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
506    *   TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
507    *   tenantServiceClient.deleteTenant(name);
508    * }
509    * }</pre>
510    *
511    * @param name Required. The resource name of the tenant to be deleted.
512    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
513    *     "projects/foo/tenants/bar".
514    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
515    */
deleteTenant(TenantName name)516   public final void deleteTenant(TenantName name) {
517     DeleteTenantRequest request =
518         DeleteTenantRequest.newBuilder().setName(name == null ? null : name.toString()).build();
519     deleteTenant(request);
520   }
521 
522   // AUTO-GENERATED DOCUMENTATION AND METHOD.
523   /**
524    * Deletes specified tenant.
525    *
526    * <p>Sample code:
527    *
528    * <pre>{@code
529    * // This snippet has been automatically generated and should be regarded as a code template only.
530    * // It will require modifications to work:
531    * // - It may require correct/in-range values for request initialization.
532    * // - It may require specifying regional endpoints when creating the service client as shown in
533    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
534    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
535    *   String name = TenantName.of("[PROJECT]", "[TENANT]").toString();
536    *   tenantServiceClient.deleteTenant(name);
537    * }
538    * }</pre>
539    *
540    * @param name Required. The resource name of the tenant to be deleted.
541    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
542    *     "projects/foo/tenants/bar".
543    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
544    */
deleteTenant(String name)545   public final void deleteTenant(String name) {
546     DeleteTenantRequest request = DeleteTenantRequest.newBuilder().setName(name).build();
547     deleteTenant(request);
548   }
549 
550   // AUTO-GENERATED DOCUMENTATION AND METHOD.
551   /**
552    * Deletes specified tenant.
553    *
554    * <p>Sample code:
555    *
556    * <pre>{@code
557    * // This snippet has been automatically generated and should be regarded as a code template only.
558    * // It will require modifications to work:
559    * // - It may require correct/in-range values for request initialization.
560    * // - It may require specifying regional endpoints when creating the service client as shown in
561    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
562    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
563    *   DeleteTenantRequest request =
564    *       DeleteTenantRequest.newBuilder()
565    *           .setName(TenantName.of("[PROJECT]", "[TENANT]").toString())
566    *           .build();
567    *   tenantServiceClient.deleteTenant(request);
568    * }
569    * }</pre>
570    *
571    * @param request The request object containing all of the parameters for the API call.
572    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
573    */
deleteTenant(DeleteTenantRequest request)574   public final void deleteTenant(DeleteTenantRequest request) {
575     deleteTenantCallable().call(request);
576   }
577 
578   // AUTO-GENERATED DOCUMENTATION AND METHOD.
579   /**
580    * Deletes specified tenant.
581    *
582    * <p>Sample code:
583    *
584    * <pre>{@code
585    * // This snippet has been automatically generated and should be regarded as a code template only.
586    * // It will require modifications to work:
587    * // - It may require correct/in-range values for request initialization.
588    * // - It may require specifying regional endpoints when creating the service client as shown in
589    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
590    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
591    *   DeleteTenantRequest request =
592    *       DeleteTenantRequest.newBuilder()
593    *           .setName(TenantName.of("[PROJECT]", "[TENANT]").toString())
594    *           .build();
595    *   ApiFuture<Empty> future = tenantServiceClient.deleteTenantCallable().futureCall(request);
596    *   // Do something.
597    *   future.get();
598    * }
599    * }</pre>
600    */
deleteTenantCallable()601   public final UnaryCallable<DeleteTenantRequest, Empty> deleteTenantCallable() {
602     return stub.deleteTenantCallable();
603   }
604 
605   // AUTO-GENERATED DOCUMENTATION AND METHOD.
606   /**
607    * Lists all tenants associated with the project.
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 (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
618    *   ProjectName parent = ProjectName.of("[PROJECT]");
619    *   for (Tenant element : tenantServiceClient.listTenants(parent).iterateAll()) {
620    *     // doThingsWith(element);
621    *   }
622    * }
623    * }</pre>
624    *
625    * @param parent Required. Resource name of the project under which the tenant is created.
626    *     <p>The format is "projects/{project_id}", for example, "projects/foo".
627    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
628    */
listTenants(ProjectName parent)629   public final ListTenantsPagedResponse listTenants(ProjectName parent) {
630     ListTenantsRequest request =
631         ListTenantsRequest.newBuilder()
632             .setParent(parent == null ? null : parent.toString())
633             .build();
634     return listTenants(request);
635   }
636 
637   // AUTO-GENERATED DOCUMENTATION AND METHOD.
638   /**
639    * Lists all tenants associated with the project.
640    *
641    * <p>Sample code:
642    *
643    * <pre>{@code
644    * // This snippet has been automatically generated and should be regarded as a code template only.
645    * // It will require modifications to work:
646    * // - It may require correct/in-range values for request initialization.
647    * // - It may require specifying regional endpoints when creating the service client as shown in
648    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
649    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
650    *   String parent = ProjectName.of("[PROJECT]").toString();
651    *   for (Tenant element : tenantServiceClient.listTenants(parent).iterateAll()) {
652    *     // doThingsWith(element);
653    *   }
654    * }
655    * }</pre>
656    *
657    * @param parent Required. Resource name of the project under which the tenant is created.
658    *     <p>The format is "projects/{project_id}", for example, "projects/foo".
659    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
660    */
listTenants(String parent)661   public final ListTenantsPagedResponse listTenants(String parent) {
662     ListTenantsRequest request = ListTenantsRequest.newBuilder().setParent(parent).build();
663     return listTenants(request);
664   }
665 
666   // AUTO-GENERATED DOCUMENTATION AND METHOD.
667   /**
668    * Lists all tenants associated with the project.
669    *
670    * <p>Sample code:
671    *
672    * <pre>{@code
673    * // This snippet has been automatically generated and should be regarded as a code template only.
674    * // It will require modifications to work:
675    * // - It may require correct/in-range values for request initialization.
676    * // - It may require specifying regional endpoints when creating the service client as shown in
677    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
678    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
679    *   ListTenantsRequest request =
680    *       ListTenantsRequest.newBuilder()
681    *           .setParent(ProjectName.of("[PROJECT]").toString())
682    *           .setPageToken("pageToken873572522")
683    *           .setPageSize(883849137)
684    *           .build();
685    *   for (Tenant element : tenantServiceClient.listTenants(request).iterateAll()) {
686    *     // doThingsWith(element);
687    *   }
688    * }
689    * }</pre>
690    *
691    * @param request The request object containing all of the parameters for the API call.
692    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
693    */
listTenants(ListTenantsRequest request)694   public final ListTenantsPagedResponse listTenants(ListTenantsRequest request) {
695     return listTenantsPagedCallable().call(request);
696   }
697 
698   // AUTO-GENERATED DOCUMENTATION AND METHOD.
699   /**
700    * Lists all tenants associated with the project.
701    *
702    * <p>Sample code:
703    *
704    * <pre>{@code
705    * // This snippet has been automatically generated and should be regarded as a code template only.
706    * // It will require modifications to work:
707    * // - It may require correct/in-range values for request initialization.
708    * // - It may require specifying regional endpoints when creating the service client as shown in
709    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
710    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
711    *   ListTenantsRequest request =
712    *       ListTenantsRequest.newBuilder()
713    *           .setParent(ProjectName.of("[PROJECT]").toString())
714    *           .setPageToken("pageToken873572522")
715    *           .setPageSize(883849137)
716    *           .build();
717    *   ApiFuture<Tenant> future = tenantServiceClient.listTenantsPagedCallable().futureCall(request);
718    *   // Do something.
719    *   for (Tenant element : future.get().iterateAll()) {
720    *     // doThingsWith(element);
721    *   }
722    * }
723    * }</pre>
724    */
725   public final UnaryCallable<ListTenantsRequest, ListTenantsPagedResponse>
listTenantsPagedCallable()726       listTenantsPagedCallable() {
727     return stub.listTenantsPagedCallable();
728   }
729 
730   // AUTO-GENERATED DOCUMENTATION AND METHOD.
731   /**
732    * Lists all tenants associated with the project.
733    *
734    * <p>Sample code:
735    *
736    * <pre>{@code
737    * // This snippet has been automatically generated and should be regarded as a code template only.
738    * // It will require modifications to work:
739    * // - It may require correct/in-range values for request initialization.
740    * // - It may require specifying regional endpoints when creating the service client as shown in
741    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
742    * try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
743    *   ListTenantsRequest request =
744    *       ListTenantsRequest.newBuilder()
745    *           .setParent(ProjectName.of("[PROJECT]").toString())
746    *           .setPageToken("pageToken873572522")
747    *           .setPageSize(883849137)
748    *           .build();
749    *   while (true) {
750    *     ListTenantsResponse response = tenantServiceClient.listTenantsCallable().call(request);
751    *     for (Tenant element : response.getTenantsList()) {
752    *       // doThingsWith(element);
753    *     }
754    *     String nextPageToken = response.getNextPageToken();
755    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
756    *       request = request.toBuilder().setPageToken(nextPageToken).build();
757    *     } else {
758    *       break;
759    *     }
760    *   }
761    * }
762    * }</pre>
763    */
listTenantsCallable()764   public final UnaryCallable<ListTenantsRequest, ListTenantsResponse> listTenantsCallable() {
765     return stub.listTenantsCallable();
766   }
767 
768   @Override
close()769   public final void close() {
770     stub.close();
771   }
772 
773   @Override
shutdown()774   public void shutdown() {
775     stub.shutdown();
776   }
777 
778   @Override
isShutdown()779   public boolean isShutdown() {
780     return stub.isShutdown();
781   }
782 
783   @Override
isTerminated()784   public boolean isTerminated() {
785     return stub.isTerminated();
786   }
787 
788   @Override
shutdownNow()789   public void shutdownNow() {
790     stub.shutdownNow();
791   }
792 
793   @Override
awaitTermination(long duration, TimeUnit unit)794   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
795     return stub.awaitTermination(duration, unit);
796   }
797 
798   public static class ListTenantsPagedResponse
799       extends AbstractPagedListResponse<
800           ListTenantsRequest,
801           ListTenantsResponse,
802           Tenant,
803           ListTenantsPage,
804           ListTenantsFixedSizeCollection> {
805 
createAsync( PageContext<ListTenantsRequest, ListTenantsResponse, Tenant> context, ApiFuture<ListTenantsResponse> futureResponse)806     public static ApiFuture<ListTenantsPagedResponse> createAsync(
807         PageContext<ListTenantsRequest, ListTenantsResponse, Tenant> context,
808         ApiFuture<ListTenantsResponse> futureResponse) {
809       ApiFuture<ListTenantsPage> futurePage =
810           ListTenantsPage.createEmptyPage().createPageAsync(context, futureResponse);
811       return ApiFutures.transform(
812           futurePage, input -> new ListTenantsPagedResponse(input), MoreExecutors.directExecutor());
813     }
814 
ListTenantsPagedResponse(ListTenantsPage page)815     private ListTenantsPagedResponse(ListTenantsPage page) {
816       super(page, ListTenantsFixedSizeCollection.createEmptyCollection());
817     }
818   }
819 
820   public static class ListTenantsPage
821       extends AbstractPage<ListTenantsRequest, ListTenantsResponse, Tenant, ListTenantsPage> {
822 
ListTenantsPage( PageContext<ListTenantsRequest, ListTenantsResponse, Tenant> context, ListTenantsResponse response)823     private ListTenantsPage(
824         PageContext<ListTenantsRequest, ListTenantsResponse, Tenant> context,
825         ListTenantsResponse response) {
826       super(context, response);
827     }
828 
createEmptyPage()829     private static ListTenantsPage createEmptyPage() {
830       return new ListTenantsPage(null, null);
831     }
832 
833     @Override
createPage( PageContext<ListTenantsRequest, ListTenantsResponse, Tenant> context, ListTenantsResponse response)834     protected ListTenantsPage createPage(
835         PageContext<ListTenantsRequest, ListTenantsResponse, Tenant> context,
836         ListTenantsResponse response) {
837       return new ListTenantsPage(context, response);
838     }
839 
840     @Override
createPageAsync( PageContext<ListTenantsRequest, ListTenantsResponse, Tenant> context, ApiFuture<ListTenantsResponse> futureResponse)841     public ApiFuture<ListTenantsPage> createPageAsync(
842         PageContext<ListTenantsRequest, ListTenantsResponse, Tenant> context,
843         ApiFuture<ListTenantsResponse> futureResponse) {
844       return super.createPageAsync(context, futureResponse);
845     }
846   }
847 
848   public static class ListTenantsFixedSizeCollection
849       extends AbstractFixedSizeCollection<
850           ListTenantsRequest,
851           ListTenantsResponse,
852           Tenant,
853           ListTenantsPage,
854           ListTenantsFixedSizeCollection> {
855 
ListTenantsFixedSizeCollection(List<ListTenantsPage> pages, int collectionSize)856     private ListTenantsFixedSizeCollection(List<ListTenantsPage> pages, int collectionSize) {
857       super(pages, collectionSize);
858     }
859 
createEmptyCollection()860     private static ListTenantsFixedSizeCollection createEmptyCollection() {
861       return new ListTenantsFixedSizeCollection(null, 0);
862     }
863 
864     @Override
createCollection( List<ListTenantsPage> pages, int collectionSize)865     protected ListTenantsFixedSizeCollection createCollection(
866         List<ListTenantsPage> pages, int collectionSize) {
867       return new ListTenantsFixedSizeCollection(pages, collectionSize);
868     }
869   }
870 }
871