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