• 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.BetaApi;
20 import com.google.api.gax.core.BackgroundResource;
21 import com.google.api.gax.rpc.UnaryCallable;
22 import com.google.cloud.talent.v4beta1.stub.EventServiceStub;
23 import com.google.cloud.talent.v4beta1.stub.EventServiceStubSettings;
24 import java.io.IOException;
25 import java.util.concurrent.TimeUnit;
26 import javax.annotation.Generated;
27 
28 // AUTO-GENERATED DOCUMENTATION AND CLASS.
29 /**
30  * Service Description: A service handles client event report.
31  *
32  * <p>This class provides the ability to make remote calls to the backing service through method
33  * calls that map to API methods. Sample code to get started:
34  *
35  * <pre>{@code
36  * // This snippet has been automatically generated and should be regarded as a code template only.
37  * // It will require modifications to work:
38  * // - It may require correct/in-range values for request initialization.
39  * // - It may require specifying regional endpoints when creating the service client as shown in
40  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
41  * try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
42  *   ProjectName parent = ProjectName.of("[PROJECT]");
43  *   ClientEvent clientEvent = ClientEvent.newBuilder().build();
44  *   ClientEvent response = eventServiceClient.createClientEvent(parent, clientEvent);
45  * }
46  * }</pre>
47  *
48  * <p>Note: close() needs to be called on the EventServiceClient object to clean up resources such
49  * as threads. In the example above, try-with-resources is used, which automatically calls close().
50  *
51  * <p>The surface of this class includes several types of Java methods for each of the API's
52  * methods:
53  *
54  * <ol>
55  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
56  *       converted into function parameters. It may be the case that not all fields are available as
57  *       parameters, and not every API method will have a flattened method entry point.
58  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
59  *       which must be constructed before the call. Not every API method will have a request object
60  *       method.
61  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
62  *       callable object, which can be used to initiate calls to the service.
63  * </ol>
64  *
65  * <p>See the individual methods for example code.
66  *
67  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
68  * these names, this class includes a format method for each type of name, and additionally a parse
69  * method to extract the individual identifiers contained within names that are returned.
70  *
71  * <p>This class can be customized by passing in a custom instance of EventServiceSettings to
72  * create(). For example:
73  *
74  * <p>To customize credentials:
75  *
76  * <pre>{@code
77  * // This snippet has been automatically generated and should be regarded as a code template only.
78  * // It will require modifications to work:
79  * // - It may require correct/in-range values for request initialization.
80  * // - It may require specifying regional endpoints when creating the service client as shown in
81  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
82  * EventServiceSettings eventServiceSettings =
83  *     EventServiceSettings.newBuilder()
84  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
85  *         .build();
86  * EventServiceClient eventServiceClient = EventServiceClient.create(eventServiceSettings);
87  * }</pre>
88  *
89  * <p>To customize the endpoint:
90  *
91  * <pre>{@code
92  * // This snippet has been automatically generated and should be regarded as a code template only.
93  * // It will require modifications to work:
94  * // - It may require correct/in-range values for request initialization.
95  * // - It may require specifying regional endpoints when creating the service client as shown in
96  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
97  * EventServiceSettings eventServiceSettings =
98  *     EventServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
99  * EventServiceClient eventServiceClient = EventServiceClient.create(eventServiceSettings);
100  * }</pre>
101  *
102  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
103  * the wire:
104  *
105  * <pre>{@code
106  * // This snippet has been automatically generated and should be regarded as a code template only.
107  * // It will require modifications to work:
108  * // - It may require correct/in-range values for request initialization.
109  * // - It may require specifying regional endpoints when creating the service client as shown in
110  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
111  * EventServiceSettings eventServiceSettings = EventServiceSettings.newHttpJsonBuilder().build();
112  * EventServiceClient eventServiceClient = EventServiceClient.create(eventServiceSettings);
113  * }</pre>
114  *
115  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
116  */
117 @BetaApi
118 @Generated("by gapic-generator-java")
119 public class EventServiceClient implements BackgroundResource {
120   private final EventServiceSettings settings;
121   private final EventServiceStub stub;
122 
123   /** Constructs an instance of EventServiceClient with default settings. */
create()124   public static final EventServiceClient create() throws IOException {
125     return create(EventServiceSettings.newBuilder().build());
126   }
127 
128   /**
129    * Constructs an instance of EventServiceClient, using the given settings. The channels are
130    * created based on the settings passed in, or defaults for any settings that are not set.
131    */
create(EventServiceSettings settings)132   public static final EventServiceClient create(EventServiceSettings settings) throws IOException {
133     return new EventServiceClient(settings);
134   }
135 
136   /**
137    * Constructs an instance of EventServiceClient, using the given stub for making calls. This is
138    * for advanced usage - prefer using create(EventServiceSettings).
139    */
create(EventServiceStub stub)140   public static final EventServiceClient create(EventServiceStub stub) {
141     return new EventServiceClient(stub);
142   }
143 
144   /**
145    * Constructs an instance of EventServiceClient, using the given settings. This is protected so
146    * that it is easy to make a subclass, but otherwise, the static factory methods should be
147    * preferred.
148    */
EventServiceClient(EventServiceSettings settings)149   protected EventServiceClient(EventServiceSettings settings) throws IOException {
150     this.settings = settings;
151     this.stub = ((EventServiceStubSettings) settings.getStubSettings()).createStub();
152   }
153 
EventServiceClient(EventServiceStub stub)154   protected EventServiceClient(EventServiceStub stub) {
155     this.settings = null;
156     this.stub = stub;
157   }
158 
getSettings()159   public final EventServiceSettings getSettings() {
160     return settings;
161   }
162 
getStub()163   public EventServiceStub getStub() {
164     return stub;
165   }
166 
167   // AUTO-GENERATED DOCUMENTATION AND METHOD.
168   /**
169    * Report events issued when end user interacts with customer's application that uses Cloud Talent
170    * Solution. You may inspect the created events in [self service
171    * tools](https://console.cloud.google.com/talent-solution/overview). [Learn
172    * more](https://cloud.google.com/talent-solution/docs/management-tools) about self service tools.
173    *
174    * <p>Sample code:
175    *
176    * <pre>{@code
177    * // This snippet has been automatically generated and should be regarded as a code template only.
178    * // It will require modifications to work:
179    * // - It may require correct/in-range values for request initialization.
180    * // - It may require specifying regional endpoints when creating the service client as shown in
181    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
182    * try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
183    *   ProjectName parent = ProjectName.of("[PROJECT]");
184    *   ClientEvent clientEvent = ClientEvent.newBuilder().build();
185    *   ClientEvent response = eventServiceClient.createClientEvent(parent, clientEvent);
186    * }
187    * }</pre>
188    *
189    * @param parent Required. Resource name of the tenant under which the event is created.
190    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
191    *     "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant is created, for
192    *     example, "projects/foo".
193    * @param clientEvent Required. Events issued when end user interacts with customer's application
194    *     that uses Cloud Talent Solution.
195    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
196    */
createClientEvent(ProjectName parent, ClientEvent clientEvent)197   public final ClientEvent createClientEvent(ProjectName parent, ClientEvent clientEvent) {
198     CreateClientEventRequest request =
199         CreateClientEventRequest.newBuilder()
200             .setParent(parent == null ? null : parent.toString())
201             .setClientEvent(clientEvent)
202             .build();
203     return createClientEvent(request);
204   }
205 
206   // AUTO-GENERATED DOCUMENTATION AND METHOD.
207   /**
208    * Report events issued when end user interacts with customer's application that uses Cloud Talent
209    * Solution. You may inspect the created events in [self service
210    * tools](https://console.cloud.google.com/talent-solution/overview). [Learn
211    * more](https://cloud.google.com/talent-solution/docs/management-tools) about self service tools.
212    *
213    * <p>Sample code:
214    *
215    * <pre>{@code
216    * // This snippet has been automatically generated and should be regarded as a code template only.
217    * // It will require modifications to work:
218    * // - It may require correct/in-range values for request initialization.
219    * // - It may require specifying regional endpoints when creating the service client as shown in
220    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
221    * try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
222    *   TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
223    *   ClientEvent clientEvent = ClientEvent.newBuilder().build();
224    *   ClientEvent response = eventServiceClient.createClientEvent(parent, clientEvent);
225    * }
226    * }</pre>
227    *
228    * @param parent Required. Resource name of the tenant under which the event is created.
229    *     <p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
230    *     "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant is created, for
231    *     example, "projects/foo".
232    * @param clientEvent Required. Events issued when end user interacts with customer's application
233    *     that uses Cloud Talent Solution.
234    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
235    */
createClientEvent(TenantName parent, ClientEvent clientEvent)236   public final ClientEvent createClientEvent(TenantName parent, ClientEvent clientEvent) {
237     CreateClientEventRequest request =
238         CreateClientEventRequest.newBuilder()
239             .setParent(parent == null ? null : parent.toString())
240             .setClientEvent(clientEvent)
241             .build();
242     return createClientEvent(request);
243   }
244 
245   // AUTO-GENERATED DOCUMENTATION AND METHOD.
246   /**
247    * Report events issued when end user interacts with customer's application that uses Cloud Talent
248    * Solution. You may inspect the created events in [self service
249    * tools](https://console.cloud.google.com/talent-solution/overview). [Learn
250    * more](https://cloud.google.com/talent-solution/docs/management-tools) about self service tools.
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 (EventServiceClient eventServiceClient = EventServiceClient.create()) {
261    *   String parent = TenantName.of("[PROJECT]", "[TENANT]").toString();
262    *   ClientEvent clientEvent = ClientEvent.newBuilder().build();
263    *   ClientEvent response = eventServiceClient.createClientEvent(parent, clientEvent);
264    * }
265    * }</pre>
266    *
267    * @param parent Required. Resource name of the tenant under which the event 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 clientEvent Required. Events issued when end user interacts with customer's application
272    *     that uses Cloud Talent Solution.
273    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
274    */
createClientEvent(String parent, ClientEvent clientEvent)275   public final ClientEvent createClientEvent(String parent, ClientEvent clientEvent) {
276     CreateClientEventRequest request =
277         CreateClientEventRequest.newBuilder().setParent(parent).setClientEvent(clientEvent).build();
278     return createClientEvent(request);
279   }
280 
281   // AUTO-GENERATED DOCUMENTATION AND METHOD.
282   /**
283    * Report events issued when end user interacts with customer's application that uses Cloud Talent
284    * Solution. You may inspect the created events in [self service
285    * tools](https://console.cloud.google.com/talent-solution/overview). [Learn
286    * more](https://cloud.google.com/talent-solution/docs/management-tools) about self service tools.
287    *
288    * <p>Sample code:
289    *
290    * <pre>{@code
291    * // This snippet has been automatically generated and should be regarded as a code template only.
292    * // It will require modifications to work:
293    * // - It may require correct/in-range values for request initialization.
294    * // - It may require specifying regional endpoints when creating the service client as shown in
295    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
296    * try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
297    *   CreateClientEventRequest request =
298    *       CreateClientEventRequest.newBuilder()
299    *           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
300    *           .setClientEvent(ClientEvent.newBuilder().build())
301    *           .build();
302    *   ClientEvent response = eventServiceClient.createClientEvent(request);
303    * }
304    * }</pre>
305    *
306    * @param request The request object containing all of the parameters for the API call.
307    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
308    */
createClientEvent(CreateClientEventRequest request)309   public final ClientEvent createClientEvent(CreateClientEventRequest request) {
310     return createClientEventCallable().call(request);
311   }
312 
313   // AUTO-GENERATED DOCUMENTATION AND METHOD.
314   /**
315    * Report events issued when end user interacts with customer's application that uses Cloud Talent
316    * Solution. You may inspect the created events in [self service
317    * tools](https://console.cloud.google.com/talent-solution/overview). [Learn
318    * more](https://cloud.google.com/talent-solution/docs/management-tools) about self service tools.
319    *
320    * <p>Sample code:
321    *
322    * <pre>{@code
323    * // This snippet has been automatically generated and should be regarded as a code template only.
324    * // It will require modifications to work:
325    * // - It may require correct/in-range values for request initialization.
326    * // - It may require specifying regional endpoints when creating the service client as shown in
327    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
328    * try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
329    *   CreateClientEventRequest request =
330    *       CreateClientEventRequest.newBuilder()
331    *           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
332    *           .setClientEvent(ClientEvent.newBuilder().build())
333    *           .build();
334    *   ApiFuture<ClientEvent> future =
335    *       eventServiceClient.createClientEventCallable().futureCall(request);
336    *   // Do something.
337    *   ClientEvent response = future.get();
338    * }
339    * }</pre>
340    */
createClientEventCallable()341   public final UnaryCallable<CreateClientEventRequest, ClientEvent> createClientEventCallable() {
342     return stub.createClientEventCallable();
343   }
344 
345   @Override
close()346   public final void close() {
347     stub.close();
348   }
349 
350   @Override
shutdown()351   public void shutdown() {
352     stub.shutdown();
353   }
354 
355   @Override
isShutdown()356   public boolean isShutdown() {
357     return stub.isShutdown();
358   }
359 
360   @Override
isTerminated()361   public boolean isTerminated() {
362     return stub.isTerminated();
363   }
364 
365   @Override
shutdownNow()366   public void shutdownNow() {
367     stub.shutdownNow();
368   }
369 
370   @Override
awaitTermination(long duration, TimeUnit unit)371   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
372     return stub.awaitTermination(duration, unit);
373   }
374 }
375