• 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.dialogflow.cx.v3;
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.httpjson.longrunning.OperationsClient;
24 import com.google.api.gax.longrunning.OperationFuture;
25 import com.google.api.gax.paging.AbstractFixedSizeCollection;
26 import com.google.api.gax.paging.AbstractPage;
27 import com.google.api.gax.paging.AbstractPagedListResponse;
28 import com.google.api.gax.rpc.OperationCallable;
29 import com.google.api.gax.rpc.PageContext;
30 import com.google.api.gax.rpc.UnaryCallable;
31 import com.google.cloud.dialogflow.cx.v3.stub.AgentsStub;
32 import com.google.cloud.dialogflow.cx.v3.stub.AgentsStubSettings;
33 import com.google.cloud.location.GetLocationRequest;
34 import com.google.cloud.location.ListLocationsRequest;
35 import com.google.cloud.location.ListLocationsResponse;
36 import com.google.cloud.location.Location;
37 import com.google.common.util.concurrent.MoreExecutors;
38 import com.google.longrunning.Operation;
39 import com.google.protobuf.Empty;
40 import com.google.protobuf.FieldMask;
41 import com.google.protobuf.Struct;
42 import java.io.IOException;
43 import java.util.List;
44 import java.util.concurrent.TimeUnit;
45 import javax.annotation.Generated;
46 
47 // AUTO-GENERATED DOCUMENTATION AND CLASS.
48 /**
49  * Service Description: Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent].
50  *
51  * <p>This class provides the ability to make remote calls to the backing service through method
52  * calls that map to API methods. Sample code to get started:
53  *
54  * <pre>{@code
55  * // This snippet has been automatically generated and should be regarded as a code template only.
56  * // It will require modifications to work:
57  * // - It may require correct/in-range values for request initialization.
58  * // - It may require specifying regional endpoints when creating the service client as shown in
59  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
60  * try (AgentsClient agentsClient = AgentsClient.create()) {
61  *   AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
62  *   Agent response = agentsClient.getAgent(name);
63  * }
64  * }</pre>
65  *
66  * <p>Note: close() needs to be called on the AgentsClient object to clean up resources such as
67  * threads. In the example above, try-with-resources is used, which automatically calls close().
68  *
69  * <p>The surface of this class includes several types of Java methods for each of the API's
70  * methods:
71  *
72  * <ol>
73  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
74  *       converted into function parameters. It may be the case that not all fields are available as
75  *       parameters, and not every API method will have a flattened method entry point.
76  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
77  *       which must be constructed before the call. Not every API method will have a request object
78  *       method.
79  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
80  *       callable object, which can be used to initiate calls to the service.
81  * </ol>
82  *
83  * <p>See the individual methods for example code.
84  *
85  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
86  * these names, this class includes a format method for each type of name, and additionally a parse
87  * method to extract the individual identifiers contained within names that are returned.
88  *
89  * <p>This class can be customized by passing in a custom instance of AgentsSettings to create().
90  * For example:
91  *
92  * <p>To customize credentials:
93  *
94  * <pre>{@code
95  * // This snippet has been automatically generated and should be regarded as a code template only.
96  * // It will require modifications to work:
97  * // - It may require correct/in-range values for request initialization.
98  * // - It may require specifying regional endpoints when creating the service client as shown in
99  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
100  * AgentsSettings agentsSettings =
101  *     AgentsSettings.newBuilder()
102  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
103  *         .build();
104  * AgentsClient agentsClient = AgentsClient.create(agentsSettings);
105  * }</pre>
106  *
107  * <p>To customize the endpoint:
108  *
109  * <pre>{@code
110  * // This snippet has been automatically generated and should be regarded as a code template only.
111  * // It will require modifications to work:
112  * // - It may require correct/in-range values for request initialization.
113  * // - It may require specifying regional endpoints when creating the service client as shown in
114  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
115  * AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(myEndpoint).build();
116  * AgentsClient agentsClient = AgentsClient.create(agentsSettings);
117  * }</pre>
118  *
119  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
120  * the wire:
121  *
122  * <pre>{@code
123  * // This snippet has been automatically generated and should be regarded as a code template only.
124  * // It will require modifications to work:
125  * // - It may require correct/in-range values for request initialization.
126  * // - It may require specifying regional endpoints when creating the service client as shown in
127  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
128  * AgentsSettings agentsSettings = AgentsSettings.newHttpJsonBuilder().build();
129  * AgentsClient agentsClient = AgentsClient.create(agentsSettings);
130  * }</pre>
131  *
132  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
133  */
134 @Generated("by gapic-generator-java")
135 public class AgentsClient implements BackgroundResource {
136   private final AgentsSettings settings;
137   private final AgentsStub stub;
138   private final OperationsClient httpJsonOperationsClient;
139   private final com.google.longrunning.OperationsClient operationsClient;
140 
141   /** Constructs an instance of AgentsClient with default settings. */
create()142   public static final AgentsClient create() throws IOException {
143     return create(AgentsSettings.newBuilder().build());
144   }
145 
146   /**
147    * Constructs an instance of AgentsClient, using the given settings. The channels are created
148    * based on the settings passed in, or defaults for any settings that are not set.
149    */
create(AgentsSettings settings)150   public static final AgentsClient create(AgentsSettings settings) throws IOException {
151     return new AgentsClient(settings);
152   }
153 
154   /**
155    * Constructs an instance of AgentsClient, using the given stub for making calls. This is for
156    * advanced usage - prefer using create(AgentsSettings).
157    */
create(AgentsStub stub)158   public static final AgentsClient create(AgentsStub stub) {
159     return new AgentsClient(stub);
160   }
161 
162   /**
163    * Constructs an instance of AgentsClient, using the given settings. This is protected so that it
164    * is easy to make a subclass, but otherwise, the static factory methods should be preferred.
165    */
AgentsClient(AgentsSettings settings)166   protected AgentsClient(AgentsSettings settings) throws IOException {
167     this.settings = settings;
168     this.stub = ((AgentsStubSettings) settings.getStubSettings()).createStub();
169     this.operationsClient =
170         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
171     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
172   }
173 
AgentsClient(AgentsStub stub)174   protected AgentsClient(AgentsStub stub) {
175     this.settings = null;
176     this.stub = stub;
177     this.operationsClient =
178         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
179     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
180   }
181 
getSettings()182   public final AgentsSettings getSettings() {
183     return settings;
184   }
185 
getStub()186   public AgentsStub getStub() {
187     return stub;
188   }
189 
190   /**
191    * Returns the OperationsClient that can be used to query the status of a long-running operation
192    * returned by another API method call.
193    */
getOperationsClient()194   public final com.google.longrunning.OperationsClient getOperationsClient() {
195     return operationsClient;
196   }
197 
198   /**
199    * Returns the OperationsClient that can be used to query the status of a long-running operation
200    * returned by another API method call.
201    */
202   @BetaApi
getHttpJsonOperationsClient()203   public final OperationsClient getHttpJsonOperationsClient() {
204     return httpJsonOperationsClient;
205   }
206 
207   // AUTO-GENERATED DOCUMENTATION AND METHOD.
208   /**
209    * Returns the list of all agents in the specified location.
210    *
211    * <p>Sample code:
212    *
213    * <pre>{@code
214    * // This snippet has been automatically generated and should be regarded as a code template only.
215    * // It will require modifications to work:
216    * // - It may require correct/in-range values for request initialization.
217    * // - It may require specifying regional endpoints when creating the service client as shown in
218    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
219    * try (AgentsClient agentsClient = AgentsClient.create()) {
220    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
221    *   for (Agent element : agentsClient.listAgents(parent).iterateAll()) {
222    *     // doThingsWith(element);
223    *   }
224    * }
225    * }</pre>
226    *
227    * @param parent Required. The location to list all agents for. Format: `projects/&lt;Project
228    *     ID&gt;/locations/&lt;Location ID&gt;`.
229    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
230    */
listAgents(LocationName parent)231   public final ListAgentsPagedResponse listAgents(LocationName parent) {
232     ListAgentsRequest request =
233         ListAgentsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build();
234     return listAgents(request);
235   }
236 
237   // AUTO-GENERATED DOCUMENTATION AND METHOD.
238   /**
239    * Returns the list of all agents in the specified location.
240    *
241    * <p>Sample code:
242    *
243    * <pre>{@code
244    * // This snippet has been automatically generated and should be regarded as a code template only.
245    * // It will require modifications to work:
246    * // - It may require correct/in-range values for request initialization.
247    * // - It may require specifying regional endpoints when creating the service client as shown in
248    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
249    * try (AgentsClient agentsClient = AgentsClient.create()) {
250    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
251    *   for (Agent element : agentsClient.listAgents(parent).iterateAll()) {
252    *     // doThingsWith(element);
253    *   }
254    * }
255    * }</pre>
256    *
257    * @param parent Required. The location to list all agents for. Format: `projects/&lt;Project
258    *     ID&gt;/locations/&lt;Location ID&gt;`.
259    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
260    */
listAgents(String parent)261   public final ListAgentsPagedResponse listAgents(String parent) {
262     ListAgentsRequest request = ListAgentsRequest.newBuilder().setParent(parent).build();
263     return listAgents(request);
264   }
265 
266   // AUTO-GENERATED DOCUMENTATION AND METHOD.
267   /**
268    * Returns the list of all agents in the specified location.
269    *
270    * <p>Sample code:
271    *
272    * <pre>{@code
273    * // This snippet has been automatically generated and should be regarded as a code template only.
274    * // It will require modifications to work:
275    * // - It may require correct/in-range values for request initialization.
276    * // - It may require specifying regional endpoints when creating the service client as shown in
277    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
278    * try (AgentsClient agentsClient = AgentsClient.create()) {
279    *   ListAgentsRequest request =
280    *       ListAgentsRequest.newBuilder()
281    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
282    *           .setPageSize(883849137)
283    *           .setPageToken("pageToken873572522")
284    *           .build();
285    *   for (Agent element : agentsClient.listAgents(request).iterateAll()) {
286    *     // doThingsWith(element);
287    *   }
288    * }
289    * }</pre>
290    *
291    * @param request The request object containing all of the parameters for the API call.
292    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
293    */
listAgents(ListAgentsRequest request)294   public final ListAgentsPagedResponse listAgents(ListAgentsRequest request) {
295     return listAgentsPagedCallable().call(request);
296   }
297 
298   // AUTO-GENERATED DOCUMENTATION AND METHOD.
299   /**
300    * Returns the list of all agents in the specified location.
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 (AgentsClient agentsClient = AgentsClient.create()) {
311    *   ListAgentsRequest request =
312    *       ListAgentsRequest.newBuilder()
313    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
314    *           .setPageSize(883849137)
315    *           .setPageToken("pageToken873572522")
316    *           .build();
317    *   ApiFuture<Agent> future = agentsClient.listAgentsPagedCallable().futureCall(request);
318    *   // Do something.
319    *   for (Agent element : future.get().iterateAll()) {
320    *     // doThingsWith(element);
321    *   }
322    * }
323    * }</pre>
324    */
listAgentsPagedCallable()325   public final UnaryCallable<ListAgentsRequest, ListAgentsPagedResponse> listAgentsPagedCallable() {
326     return stub.listAgentsPagedCallable();
327   }
328 
329   // AUTO-GENERATED DOCUMENTATION AND METHOD.
330   /**
331    * Returns the list of all agents in the specified location.
332    *
333    * <p>Sample code:
334    *
335    * <pre>{@code
336    * // This snippet has been automatically generated and should be regarded as a code template only.
337    * // It will require modifications to work:
338    * // - It may require correct/in-range values for request initialization.
339    * // - It may require specifying regional endpoints when creating the service client as shown in
340    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
341    * try (AgentsClient agentsClient = AgentsClient.create()) {
342    *   ListAgentsRequest request =
343    *       ListAgentsRequest.newBuilder()
344    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
345    *           .setPageSize(883849137)
346    *           .setPageToken("pageToken873572522")
347    *           .build();
348    *   while (true) {
349    *     ListAgentsResponse response = agentsClient.listAgentsCallable().call(request);
350    *     for (Agent element : response.getAgentsList()) {
351    *       // doThingsWith(element);
352    *     }
353    *     String nextPageToken = response.getNextPageToken();
354    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
355    *       request = request.toBuilder().setPageToken(nextPageToken).build();
356    *     } else {
357    *       break;
358    *     }
359    *   }
360    * }
361    * }</pre>
362    */
listAgentsCallable()363   public final UnaryCallable<ListAgentsRequest, ListAgentsResponse> listAgentsCallable() {
364     return stub.listAgentsCallable();
365   }
366 
367   // AUTO-GENERATED DOCUMENTATION AND METHOD.
368   /**
369    * Retrieves the specified agent.
370    *
371    * <p>Sample code:
372    *
373    * <pre>{@code
374    * // This snippet has been automatically generated and should be regarded as a code template only.
375    * // It will require modifications to work:
376    * // - It may require correct/in-range values for request initialization.
377    * // - It may require specifying regional endpoints when creating the service client as shown in
378    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
379    * try (AgentsClient agentsClient = AgentsClient.create()) {
380    *   AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
381    *   Agent response = agentsClient.getAgent(name);
382    * }
383    * }</pre>
384    *
385    * @param name Required. The name of the agent. Format: `projects/&lt;Project
386    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;`.
387    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
388    */
getAgent(AgentName name)389   public final Agent getAgent(AgentName name) {
390     GetAgentRequest request =
391         GetAgentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
392     return getAgent(request);
393   }
394 
395   // AUTO-GENERATED DOCUMENTATION AND METHOD.
396   /**
397    * Retrieves the specified agent.
398    *
399    * <p>Sample code:
400    *
401    * <pre>{@code
402    * // This snippet has been automatically generated and should be regarded as a code template only.
403    * // It will require modifications to work:
404    * // - It may require correct/in-range values for request initialization.
405    * // - It may require specifying regional endpoints when creating the service client as shown in
406    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
407    * try (AgentsClient agentsClient = AgentsClient.create()) {
408    *   String name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
409    *   Agent response = agentsClient.getAgent(name);
410    * }
411    * }</pre>
412    *
413    * @param name Required. The name of the agent. Format: `projects/&lt;Project
414    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;`.
415    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
416    */
getAgent(String name)417   public final Agent getAgent(String name) {
418     GetAgentRequest request = GetAgentRequest.newBuilder().setName(name).build();
419     return getAgent(request);
420   }
421 
422   // AUTO-GENERATED DOCUMENTATION AND METHOD.
423   /**
424    * Retrieves the specified agent.
425    *
426    * <p>Sample code:
427    *
428    * <pre>{@code
429    * // This snippet has been automatically generated and should be regarded as a code template only.
430    * // It will require modifications to work:
431    * // - It may require correct/in-range values for request initialization.
432    * // - It may require specifying regional endpoints when creating the service client as shown in
433    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
434    * try (AgentsClient agentsClient = AgentsClient.create()) {
435    *   GetAgentRequest request =
436    *       GetAgentRequest.newBuilder()
437    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
438    *           .build();
439    *   Agent response = agentsClient.getAgent(request);
440    * }
441    * }</pre>
442    *
443    * @param request The request object containing all of the parameters for the API call.
444    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
445    */
getAgent(GetAgentRequest request)446   public final Agent getAgent(GetAgentRequest request) {
447     return getAgentCallable().call(request);
448   }
449 
450   // AUTO-GENERATED DOCUMENTATION AND METHOD.
451   /**
452    * Retrieves the specified agent.
453    *
454    * <p>Sample code:
455    *
456    * <pre>{@code
457    * // This snippet has been automatically generated and should be regarded as a code template only.
458    * // It will require modifications to work:
459    * // - It may require correct/in-range values for request initialization.
460    * // - It may require specifying regional endpoints when creating the service client as shown in
461    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
462    * try (AgentsClient agentsClient = AgentsClient.create()) {
463    *   GetAgentRequest request =
464    *       GetAgentRequest.newBuilder()
465    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
466    *           .build();
467    *   ApiFuture<Agent> future = agentsClient.getAgentCallable().futureCall(request);
468    *   // Do something.
469    *   Agent response = future.get();
470    * }
471    * }</pre>
472    */
getAgentCallable()473   public final UnaryCallable<GetAgentRequest, Agent> getAgentCallable() {
474     return stub.getAgentCallable();
475   }
476 
477   // AUTO-GENERATED DOCUMENTATION AND METHOD.
478   /**
479    * Creates an agent in the specified location.
480    *
481    * <p>Note: You should always train flows prior to sending them queries. See the [training
482    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
483    *
484    * <p>Sample code:
485    *
486    * <pre>{@code
487    * // This snippet has been automatically generated and should be regarded as a code template only.
488    * // It will require modifications to work:
489    * // - It may require correct/in-range values for request initialization.
490    * // - It may require specifying regional endpoints when creating the service client as shown in
491    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
492    * try (AgentsClient agentsClient = AgentsClient.create()) {
493    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
494    *   Agent agent = Agent.newBuilder().build();
495    *   Agent response = agentsClient.createAgent(parent, agent);
496    * }
497    * }</pre>
498    *
499    * @param parent Required. The location to create a agent for. Format: `projects/&lt;Project
500    *     ID&gt;/locations/&lt;Location ID&gt;`.
501    * @param agent Required. The agent to create.
502    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
503    */
createAgent(LocationName parent, Agent agent)504   public final Agent createAgent(LocationName parent, Agent agent) {
505     CreateAgentRequest request =
506         CreateAgentRequest.newBuilder()
507             .setParent(parent == null ? null : parent.toString())
508             .setAgent(agent)
509             .build();
510     return createAgent(request);
511   }
512 
513   // AUTO-GENERATED DOCUMENTATION AND METHOD.
514   /**
515    * Creates an agent in the specified location.
516    *
517    * <p>Note: You should always train flows prior to sending them queries. See the [training
518    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
519    *
520    * <p>Sample code:
521    *
522    * <pre>{@code
523    * // This snippet has been automatically generated and should be regarded as a code template only.
524    * // It will require modifications to work:
525    * // - It may require correct/in-range values for request initialization.
526    * // - It may require specifying regional endpoints when creating the service client as shown in
527    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
528    * try (AgentsClient agentsClient = AgentsClient.create()) {
529    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
530    *   Agent agent = Agent.newBuilder().build();
531    *   Agent response = agentsClient.createAgent(parent, agent);
532    * }
533    * }</pre>
534    *
535    * @param parent Required. The location to create a agent for. Format: `projects/&lt;Project
536    *     ID&gt;/locations/&lt;Location ID&gt;`.
537    * @param agent Required. The agent to create.
538    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
539    */
createAgent(String parent, Agent agent)540   public final Agent createAgent(String parent, Agent agent) {
541     CreateAgentRequest request =
542         CreateAgentRequest.newBuilder().setParent(parent).setAgent(agent).build();
543     return createAgent(request);
544   }
545 
546   // AUTO-GENERATED DOCUMENTATION AND METHOD.
547   /**
548    * Creates an agent in the specified location.
549    *
550    * <p>Note: You should always train flows prior to sending them queries. See the [training
551    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
552    *
553    * <p>Sample code:
554    *
555    * <pre>{@code
556    * // This snippet has been automatically generated and should be regarded as a code template only.
557    * // It will require modifications to work:
558    * // - It may require correct/in-range values for request initialization.
559    * // - It may require specifying regional endpoints when creating the service client as shown in
560    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
561    * try (AgentsClient agentsClient = AgentsClient.create()) {
562    *   CreateAgentRequest request =
563    *       CreateAgentRequest.newBuilder()
564    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
565    *           .setAgent(Agent.newBuilder().build())
566    *           .build();
567    *   Agent response = agentsClient.createAgent(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    */
createAgent(CreateAgentRequest request)574   public final Agent createAgent(CreateAgentRequest request) {
575     return createAgentCallable().call(request);
576   }
577 
578   // AUTO-GENERATED DOCUMENTATION AND METHOD.
579   /**
580    * Creates an agent in the specified location.
581    *
582    * <p>Note: You should always train flows prior to sending them queries. See the [training
583    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
584    *
585    * <p>Sample code:
586    *
587    * <pre>{@code
588    * // This snippet has been automatically generated and should be regarded as a code template only.
589    * // It will require modifications to work:
590    * // - It may require correct/in-range values for request initialization.
591    * // - It may require specifying regional endpoints when creating the service client as shown in
592    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
593    * try (AgentsClient agentsClient = AgentsClient.create()) {
594    *   CreateAgentRequest request =
595    *       CreateAgentRequest.newBuilder()
596    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
597    *           .setAgent(Agent.newBuilder().build())
598    *           .build();
599    *   ApiFuture<Agent> future = agentsClient.createAgentCallable().futureCall(request);
600    *   // Do something.
601    *   Agent response = future.get();
602    * }
603    * }</pre>
604    */
createAgentCallable()605   public final UnaryCallable<CreateAgentRequest, Agent> createAgentCallable() {
606     return stub.createAgentCallable();
607   }
608 
609   // AUTO-GENERATED DOCUMENTATION AND METHOD.
610   /**
611    * Updates the specified agent.
612    *
613    * <p>Note: You should always train flows prior to sending them queries. See the [training
614    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
615    *
616    * <p>Sample code:
617    *
618    * <pre>{@code
619    * // This snippet has been automatically generated and should be regarded as a code template only.
620    * // It will require modifications to work:
621    * // - It may require correct/in-range values for request initialization.
622    * // - It may require specifying regional endpoints when creating the service client as shown in
623    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
624    * try (AgentsClient agentsClient = AgentsClient.create()) {
625    *   Agent agent = Agent.newBuilder().build();
626    *   FieldMask updateMask = FieldMask.newBuilder().build();
627    *   Agent response = agentsClient.updateAgent(agent, updateMask);
628    * }
629    * }</pre>
630    *
631    * @param agent Required. The agent to update.
632    * @param updateMask The mask to control which fields get updated. If the mask is not present, all
633    *     fields will be updated.
634    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
635    */
updateAgent(Agent agent, FieldMask updateMask)636   public final Agent updateAgent(Agent agent, FieldMask updateMask) {
637     UpdateAgentRequest request =
638         UpdateAgentRequest.newBuilder().setAgent(agent).setUpdateMask(updateMask).build();
639     return updateAgent(request);
640   }
641 
642   // AUTO-GENERATED DOCUMENTATION AND METHOD.
643   /**
644    * Updates the specified agent.
645    *
646    * <p>Note: You should always train flows prior to sending them queries. See the [training
647    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
648    *
649    * <p>Sample code:
650    *
651    * <pre>{@code
652    * // This snippet has been automatically generated and should be regarded as a code template only.
653    * // It will require modifications to work:
654    * // - It may require correct/in-range values for request initialization.
655    * // - It may require specifying regional endpoints when creating the service client as shown in
656    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
657    * try (AgentsClient agentsClient = AgentsClient.create()) {
658    *   UpdateAgentRequest request =
659    *       UpdateAgentRequest.newBuilder()
660    *           .setAgent(Agent.newBuilder().build())
661    *           .setUpdateMask(FieldMask.newBuilder().build())
662    *           .build();
663    *   Agent response = agentsClient.updateAgent(request);
664    * }
665    * }</pre>
666    *
667    * @param request The request object containing all of the parameters for the API call.
668    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
669    */
updateAgent(UpdateAgentRequest request)670   public final Agent updateAgent(UpdateAgentRequest request) {
671     return updateAgentCallable().call(request);
672   }
673 
674   // AUTO-GENERATED DOCUMENTATION AND METHOD.
675   /**
676    * Updates the specified agent.
677    *
678    * <p>Note: You should always train flows prior to sending them queries. See the [training
679    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
680    *
681    * <p>Sample code:
682    *
683    * <pre>{@code
684    * // This snippet has been automatically generated and should be regarded as a code template only.
685    * // It will require modifications to work:
686    * // - It may require correct/in-range values for request initialization.
687    * // - It may require specifying regional endpoints when creating the service client as shown in
688    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
689    * try (AgentsClient agentsClient = AgentsClient.create()) {
690    *   UpdateAgentRequest request =
691    *       UpdateAgentRequest.newBuilder()
692    *           .setAgent(Agent.newBuilder().build())
693    *           .setUpdateMask(FieldMask.newBuilder().build())
694    *           .build();
695    *   ApiFuture<Agent> future = agentsClient.updateAgentCallable().futureCall(request);
696    *   // Do something.
697    *   Agent response = future.get();
698    * }
699    * }</pre>
700    */
updateAgentCallable()701   public final UnaryCallable<UpdateAgentRequest, Agent> updateAgentCallable() {
702     return stub.updateAgentCallable();
703   }
704 
705   // AUTO-GENERATED DOCUMENTATION AND METHOD.
706   /**
707    * Deletes the specified agent.
708    *
709    * <p>Sample code:
710    *
711    * <pre>{@code
712    * // This snippet has been automatically generated and should be regarded as a code template only.
713    * // It will require modifications to work:
714    * // - It may require correct/in-range values for request initialization.
715    * // - It may require specifying regional endpoints when creating the service client as shown in
716    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
717    * try (AgentsClient agentsClient = AgentsClient.create()) {
718    *   AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
719    *   agentsClient.deleteAgent(name);
720    * }
721    * }</pre>
722    *
723    * @param name Required. The name of the agent to delete. Format: `projects/&lt;Project
724    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;`.
725    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
726    */
deleteAgent(AgentName name)727   public final void deleteAgent(AgentName name) {
728     DeleteAgentRequest request =
729         DeleteAgentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
730     deleteAgent(request);
731   }
732 
733   // AUTO-GENERATED DOCUMENTATION AND METHOD.
734   /**
735    * Deletes the specified agent.
736    *
737    * <p>Sample code:
738    *
739    * <pre>{@code
740    * // This snippet has been automatically generated and should be regarded as a code template only.
741    * // It will require modifications to work:
742    * // - It may require correct/in-range values for request initialization.
743    * // - It may require specifying regional endpoints when creating the service client as shown in
744    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
745    * try (AgentsClient agentsClient = AgentsClient.create()) {
746    *   String name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
747    *   agentsClient.deleteAgent(name);
748    * }
749    * }</pre>
750    *
751    * @param name Required. The name of the agent to delete. Format: `projects/&lt;Project
752    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;`.
753    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
754    */
deleteAgent(String name)755   public final void deleteAgent(String name) {
756     DeleteAgentRequest request = DeleteAgentRequest.newBuilder().setName(name).build();
757     deleteAgent(request);
758   }
759 
760   // AUTO-GENERATED DOCUMENTATION AND METHOD.
761   /**
762    * Deletes the specified agent.
763    *
764    * <p>Sample code:
765    *
766    * <pre>{@code
767    * // This snippet has been automatically generated and should be regarded as a code template only.
768    * // It will require modifications to work:
769    * // - It may require correct/in-range values for request initialization.
770    * // - It may require specifying regional endpoints when creating the service client as shown in
771    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
772    * try (AgentsClient agentsClient = AgentsClient.create()) {
773    *   DeleteAgentRequest request =
774    *       DeleteAgentRequest.newBuilder()
775    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
776    *           .build();
777    *   agentsClient.deleteAgent(request);
778    * }
779    * }</pre>
780    *
781    * @param request The request object containing all of the parameters for the API call.
782    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
783    */
deleteAgent(DeleteAgentRequest request)784   public final void deleteAgent(DeleteAgentRequest request) {
785     deleteAgentCallable().call(request);
786   }
787 
788   // AUTO-GENERATED DOCUMENTATION AND METHOD.
789   /**
790    * Deletes the specified agent.
791    *
792    * <p>Sample code:
793    *
794    * <pre>{@code
795    * // This snippet has been automatically generated and should be regarded as a code template only.
796    * // It will require modifications to work:
797    * // - It may require correct/in-range values for request initialization.
798    * // - It may require specifying regional endpoints when creating the service client as shown in
799    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
800    * try (AgentsClient agentsClient = AgentsClient.create()) {
801    *   DeleteAgentRequest request =
802    *       DeleteAgentRequest.newBuilder()
803    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
804    *           .build();
805    *   ApiFuture<Empty> future = agentsClient.deleteAgentCallable().futureCall(request);
806    *   // Do something.
807    *   future.get();
808    * }
809    * }</pre>
810    */
deleteAgentCallable()811   public final UnaryCallable<DeleteAgentRequest, Empty> deleteAgentCallable() {
812     return stub.deleteAgentCallable();
813   }
814 
815   // AUTO-GENERATED DOCUMENTATION AND METHOD.
816   /**
817    * Exports the specified agent to a binary file.
818    *
819    * <p>This method is a [long-running
820    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
821    * returned `Operation` type has the following method-specific fields:
822    *
823    * <p>- `metadata`: An empty [Struct
824    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
825    * - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse]
826    *
827    * <p>Sample code:
828    *
829    * <pre>{@code
830    * // This snippet has been automatically generated and should be regarded as a code template only.
831    * // It will require modifications to work:
832    * // - It may require correct/in-range values for request initialization.
833    * // - It may require specifying regional endpoints when creating the service client as shown in
834    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
835    * try (AgentsClient agentsClient = AgentsClient.create()) {
836    *   ExportAgentRequest request =
837    *       ExportAgentRequest.newBuilder()
838    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
839    *           .setAgentUri("agentUri1469149223")
840    *           .setEnvironment(
841    *               EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
842    *                   .toString())
843    *           .build();
844    *   ExportAgentResponse response = agentsClient.exportAgentAsync(request).get();
845    * }
846    * }</pre>
847    *
848    * @param request The request object containing all of the parameters for the API call.
849    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
850    */
exportAgentAsync( ExportAgentRequest request)851   public final OperationFuture<ExportAgentResponse, Struct> exportAgentAsync(
852       ExportAgentRequest request) {
853     return exportAgentOperationCallable().futureCall(request);
854   }
855 
856   // AUTO-GENERATED DOCUMENTATION AND METHOD.
857   /**
858    * Exports the specified agent to a binary file.
859    *
860    * <p>This method is a [long-running
861    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
862    * returned `Operation` type has the following method-specific fields:
863    *
864    * <p>- `metadata`: An empty [Struct
865    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
866    * - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse]
867    *
868    * <p>Sample code:
869    *
870    * <pre>{@code
871    * // This snippet has been automatically generated and should be regarded as a code template only.
872    * // It will require modifications to work:
873    * // - It may require correct/in-range values for request initialization.
874    * // - It may require specifying regional endpoints when creating the service client as shown in
875    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
876    * try (AgentsClient agentsClient = AgentsClient.create()) {
877    *   ExportAgentRequest request =
878    *       ExportAgentRequest.newBuilder()
879    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
880    *           .setAgentUri("agentUri1469149223")
881    *           .setEnvironment(
882    *               EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
883    *                   .toString())
884    *           .build();
885    *   OperationFuture<ExportAgentResponse, Struct> future =
886    *       agentsClient.exportAgentOperationCallable().futureCall(request);
887    *   // Do something.
888    *   ExportAgentResponse response = future.get();
889    * }
890    * }</pre>
891    */
892   public final OperationCallable<ExportAgentRequest, ExportAgentResponse, Struct>
exportAgentOperationCallable()893       exportAgentOperationCallable() {
894     return stub.exportAgentOperationCallable();
895   }
896 
897   // AUTO-GENERATED DOCUMENTATION AND METHOD.
898   /**
899    * Exports the specified agent to a binary file.
900    *
901    * <p>This method is a [long-running
902    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
903    * returned `Operation` type has the following method-specific fields:
904    *
905    * <p>- `metadata`: An empty [Struct
906    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
907    * - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse]
908    *
909    * <p>Sample code:
910    *
911    * <pre>{@code
912    * // This snippet has been automatically generated and should be regarded as a code template only.
913    * // It will require modifications to work:
914    * // - It may require correct/in-range values for request initialization.
915    * // - It may require specifying regional endpoints when creating the service client as shown in
916    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
917    * try (AgentsClient agentsClient = AgentsClient.create()) {
918    *   ExportAgentRequest request =
919    *       ExportAgentRequest.newBuilder()
920    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
921    *           .setAgentUri("agentUri1469149223")
922    *           .setEnvironment(
923    *               EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
924    *                   .toString())
925    *           .build();
926    *   ApiFuture<Operation> future = agentsClient.exportAgentCallable().futureCall(request);
927    *   // Do something.
928    *   Operation response = future.get();
929    * }
930    * }</pre>
931    */
exportAgentCallable()932   public final UnaryCallable<ExportAgentRequest, Operation> exportAgentCallable() {
933     return stub.exportAgentCallable();
934   }
935 
936   // AUTO-GENERATED DOCUMENTATION AND METHOD.
937   /**
938    * Restores the specified agent from a binary file.
939    *
940    * <p>Replaces the current agent with a new one. Note that all existing resources in agent (e.g.
941    * intents, entity types, flows) will be removed.
942    *
943    * <p>This method is a [long-running
944    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
945    * returned `Operation` type has the following method-specific fields:
946    *
947    * <p>- `metadata`: An empty [Struct
948    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
949    * - `response`: An [Empty
950    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
951    *
952    * <p>Note: You should always train flows prior to sending them queries. See the [training
953    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
954    *
955    * <p>Sample code:
956    *
957    * <pre>{@code
958    * // This snippet has been automatically generated and should be regarded as a code template only.
959    * // It will require modifications to work:
960    * // - It may require correct/in-range values for request initialization.
961    * // - It may require specifying regional endpoints when creating the service client as shown in
962    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
963    * try (AgentsClient agentsClient = AgentsClient.create()) {
964    *   RestoreAgentRequest request =
965    *       RestoreAgentRequest.newBuilder()
966    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
967    *           .build();
968    *   agentsClient.restoreAgentAsync(request).get();
969    * }
970    * }</pre>
971    *
972    * @param request The request object containing all of the parameters for the API call.
973    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
974    */
restoreAgentAsync(RestoreAgentRequest request)975   public final OperationFuture<Empty, Struct> restoreAgentAsync(RestoreAgentRequest request) {
976     return restoreAgentOperationCallable().futureCall(request);
977   }
978 
979   // AUTO-GENERATED DOCUMENTATION AND METHOD.
980   /**
981    * Restores the specified agent from a binary file.
982    *
983    * <p>Replaces the current agent with a new one. Note that all existing resources in agent (e.g.
984    * intents, entity types, flows) will be removed.
985    *
986    * <p>This method is a [long-running
987    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
988    * returned `Operation` type has the following method-specific fields:
989    *
990    * <p>- `metadata`: An empty [Struct
991    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
992    * - `response`: An [Empty
993    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
994    *
995    * <p>Note: You should always train flows prior to sending them queries. See the [training
996    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
997    *
998    * <p>Sample code:
999    *
1000    * <pre>{@code
1001    * // This snippet has been automatically generated and should be regarded as a code template only.
1002    * // It will require modifications to work:
1003    * // - It may require correct/in-range values for request initialization.
1004    * // - It may require specifying regional endpoints when creating the service client as shown in
1005    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1006    * try (AgentsClient agentsClient = AgentsClient.create()) {
1007    *   RestoreAgentRequest request =
1008    *       RestoreAgentRequest.newBuilder()
1009    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
1010    *           .build();
1011    *   OperationFuture<Empty, Struct> future =
1012    *       agentsClient.restoreAgentOperationCallable().futureCall(request);
1013    *   // Do something.
1014    *   future.get();
1015    * }
1016    * }</pre>
1017    */
1018   public final OperationCallable<RestoreAgentRequest, Empty, Struct>
restoreAgentOperationCallable()1019       restoreAgentOperationCallable() {
1020     return stub.restoreAgentOperationCallable();
1021   }
1022 
1023   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1024   /**
1025    * Restores the specified agent from a binary file.
1026    *
1027    * <p>Replaces the current agent with a new one. Note that all existing resources in agent (e.g.
1028    * intents, entity types, flows) will be removed.
1029    *
1030    * <p>This method is a [long-running
1031    * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
1032    * returned `Operation` type has the following method-specific fields:
1033    *
1034    * <p>- `metadata`: An empty [Struct
1035    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
1036    * - `response`: An [Empty
1037    * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
1038    *
1039    * <p>Note: You should always train flows prior to sending them queries. See the [training
1040    * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
1041    *
1042    * <p>Sample code:
1043    *
1044    * <pre>{@code
1045    * // This snippet has been automatically generated and should be regarded as a code template only.
1046    * // It will require modifications to work:
1047    * // - It may require correct/in-range values for request initialization.
1048    * // - It may require specifying regional endpoints when creating the service client as shown in
1049    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1050    * try (AgentsClient agentsClient = AgentsClient.create()) {
1051    *   RestoreAgentRequest request =
1052    *       RestoreAgentRequest.newBuilder()
1053    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
1054    *           .build();
1055    *   ApiFuture<Operation> future = agentsClient.restoreAgentCallable().futureCall(request);
1056    *   // Do something.
1057    *   future.get();
1058    * }
1059    * }</pre>
1060    */
restoreAgentCallable()1061   public final UnaryCallable<RestoreAgentRequest, Operation> restoreAgentCallable() {
1062     return stub.restoreAgentCallable();
1063   }
1064 
1065   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1066   /**
1067    * Validates the specified agent and creates or updates validation results. The agent in draft
1068    * version is validated. Please call this API after the training is completed to get the complete
1069    * validation results.
1070    *
1071    * <p>Sample code:
1072    *
1073    * <pre>{@code
1074    * // This snippet has been automatically generated and should be regarded as a code template only.
1075    * // It will require modifications to work:
1076    * // - It may require correct/in-range values for request initialization.
1077    * // - It may require specifying regional endpoints when creating the service client as shown in
1078    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1079    * try (AgentsClient agentsClient = AgentsClient.create()) {
1080    *   ValidateAgentRequest request =
1081    *       ValidateAgentRequest.newBuilder()
1082    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
1083    *           .setLanguageCode("languageCode-2092349083")
1084    *           .build();
1085    *   AgentValidationResult response = agentsClient.validateAgent(request);
1086    * }
1087    * }</pre>
1088    *
1089    * @param request The request object containing all of the parameters for the API call.
1090    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1091    */
validateAgent(ValidateAgentRequest request)1092   public final AgentValidationResult validateAgent(ValidateAgentRequest request) {
1093     return validateAgentCallable().call(request);
1094   }
1095 
1096   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1097   /**
1098    * Validates the specified agent and creates or updates validation results. The agent in draft
1099    * version is validated. Please call this API after the training is completed to get the complete
1100    * validation results.
1101    *
1102    * <p>Sample code:
1103    *
1104    * <pre>{@code
1105    * // This snippet has been automatically generated and should be regarded as a code template only.
1106    * // It will require modifications to work:
1107    * // - It may require correct/in-range values for request initialization.
1108    * // - It may require specifying regional endpoints when creating the service client as shown in
1109    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1110    * try (AgentsClient agentsClient = AgentsClient.create()) {
1111    *   ValidateAgentRequest request =
1112    *       ValidateAgentRequest.newBuilder()
1113    *           .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
1114    *           .setLanguageCode("languageCode-2092349083")
1115    *           .build();
1116    *   ApiFuture<AgentValidationResult> future =
1117    *       agentsClient.validateAgentCallable().futureCall(request);
1118    *   // Do something.
1119    *   AgentValidationResult response = future.get();
1120    * }
1121    * }</pre>
1122    */
validateAgentCallable()1123   public final UnaryCallable<ValidateAgentRequest, AgentValidationResult> validateAgentCallable() {
1124     return stub.validateAgentCallable();
1125   }
1126 
1127   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1128   /**
1129    * Gets the latest agent validation result. Agent validation is performed when ValidateAgent is
1130    * called.
1131    *
1132    * <p>Sample code:
1133    *
1134    * <pre>{@code
1135    * // This snippet has been automatically generated and should be regarded as a code template only.
1136    * // It will require modifications to work:
1137    * // - It may require correct/in-range values for request initialization.
1138    * // - It may require specifying regional endpoints when creating the service client as shown in
1139    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1140    * try (AgentsClient agentsClient = AgentsClient.create()) {
1141    *   AgentValidationResultName name =
1142    *       AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
1143    *   AgentValidationResult response = agentsClient.getAgentValidationResult(name);
1144    * }
1145    * }</pre>
1146    *
1147    * @param name Required. The agent name. Format: `projects/&lt;Project
1148    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/validationResult`.
1149    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1150    */
getAgentValidationResult(AgentValidationResultName name)1151   public final AgentValidationResult getAgentValidationResult(AgentValidationResultName name) {
1152     GetAgentValidationResultRequest request =
1153         GetAgentValidationResultRequest.newBuilder()
1154             .setName(name == null ? null : name.toString())
1155             .build();
1156     return getAgentValidationResult(request);
1157   }
1158 
1159   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1160   /**
1161    * Gets the latest agent validation result. Agent validation is performed when ValidateAgent is
1162    * called.
1163    *
1164    * <p>Sample code:
1165    *
1166    * <pre>{@code
1167    * // This snippet has been automatically generated and should be regarded as a code template only.
1168    * // It will require modifications to work:
1169    * // - It may require correct/in-range values for request initialization.
1170    * // - It may require specifying regional endpoints when creating the service client as shown in
1171    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1172    * try (AgentsClient agentsClient = AgentsClient.create()) {
1173    *   String name = AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
1174    *   AgentValidationResult response = agentsClient.getAgentValidationResult(name);
1175    * }
1176    * }</pre>
1177    *
1178    * @param name Required. The agent name. Format: `projects/&lt;Project
1179    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/validationResult`.
1180    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1181    */
getAgentValidationResult(String name)1182   public final AgentValidationResult getAgentValidationResult(String name) {
1183     GetAgentValidationResultRequest request =
1184         GetAgentValidationResultRequest.newBuilder().setName(name).build();
1185     return getAgentValidationResult(request);
1186   }
1187 
1188   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1189   /**
1190    * Gets the latest agent validation result. Agent validation is performed when ValidateAgent is
1191    * called.
1192    *
1193    * <p>Sample code:
1194    *
1195    * <pre>{@code
1196    * // This snippet has been automatically generated and should be regarded as a code template only.
1197    * // It will require modifications to work:
1198    * // - It may require correct/in-range values for request initialization.
1199    * // - It may require specifying regional endpoints when creating the service client as shown in
1200    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1201    * try (AgentsClient agentsClient = AgentsClient.create()) {
1202    *   GetAgentValidationResultRequest request =
1203    *       GetAgentValidationResultRequest.newBuilder()
1204    *           .setName(
1205    *               AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
1206    *           .setLanguageCode("languageCode-2092349083")
1207    *           .build();
1208    *   AgentValidationResult response = agentsClient.getAgentValidationResult(request);
1209    * }
1210    * }</pre>
1211    *
1212    * @param request The request object containing all of the parameters for the API call.
1213    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1214    */
getAgentValidationResult( GetAgentValidationResultRequest request)1215   public final AgentValidationResult getAgentValidationResult(
1216       GetAgentValidationResultRequest request) {
1217     return getAgentValidationResultCallable().call(request);
1218   }
1219 
1220   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1221   /**
1222    * Gets the latest agent validation result. Agent validation is performed when ValidateAgent is
1223    * called.
1224    *
1225    * <p>Sample code:
1226    *
1227    * <pre>{@code
1228    * // This snippet has been automatically generated and should be regarded as a code template only.
1229    * // It will require modifications to work:
1230    * // - It may require correct/in-range values for request initialization.
1231    * // - It may require specifying regional endpoints when creating the service client as shown in
1232    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1233    * try (AgentsClient agentsClient = AgentsClient.create()) {
1234    *   GetAgentValidationResultRequest request =
1235    *       GetAgentValidationResultRequest.newBuilder()
1236    *           .setName(
1237    *               AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
1238    *           .setLanguageCode("languageCode-2092349083")
1239    *           .build();
1240    *   ApiFuture<AgentValidationResult> future =
1241    *       agentsClient.getAgentValidationResultCallable().futureCall(request);
1242    *   // Do something.
1243    *   AgentValidationResult response = future.get();
1244    * }
1245    * }</pre>
1246    */
1247   public final UnaryCallable<GetAgentValidationResultRequest, AgentValidationResult>
getAgentValidationResultCallable()1248       getAgentValidationResultCallable() {
1249     return stub.getAgentValidationResultCallable();
1250   }
1251 
1252   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1253   /**
1254    * Lists information about the supported locations for this service.
1255    *
1256    * <p>Sample code:
1257    *
1258    * <pre>{@code
1259    * // This snippet has been automatically generated and should be regarded as a code template only.
1260    * // It will require modifications to work:
1261    * // - It may require correct/in-range values for request initialization.
1262    * // - It may require specifying regional endpoints when creating the service client as shown in
1263    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1264    * try (AgentsClient agentsClient = AgentsClient.create()) {
1265    *   ListLocationsRequest request =
1266    *       ListLocationsRequest.newBuilder()
1267    *           .setName("name3373707")
1268    *           .setFilter("filter-1274492040")
1269    *           .setPageSize(883849137)
1270    *           .setPageToken("pageToken873572522")
1271    *           .build();
1272    *   for (Location element : agentsClient.listLocations(request).iterateAll()) {
1273    *     // doThingsWith(element);
1274    *   }
1275    * }
1276    * }</pre>
1277    *
1278    * @param request The request object containing all of the parameters for the API call.
1279    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1280    */
listLocations(ListLocationsRequest request)1281   public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
1282     return listLocationsPagedCallable().call(request);
1283   }
1284 
1285   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1286   /**
1287    * Lists information about the supported locations for this service.
1288    *
1289    * <p>Sample code:
1290    *
1291    * <pre>{@code
1292    * // This snippet has been automatically generated and should be regarded as a code template only.
1293    * // It will require modifications to work:
1294    * // - It may require correct/in-range values for request initialization.
1295    * // - It may require specifying regional endpoints when creating the service client as shown in
1296    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1297    * try (AgentsClient agentsClient = AgentsClient.create()) {
1298    *   ListLocationsRequest request =
1299    *       ListLocationsRequest.newBuilder()
1300    *           .setName("name3373707")
1301    *           .setFilter("filter-1274492040")
1302    *           .setPageSize(883849137)
1303    *           .setPageToken("pageToken873572522")
1304    *           .build();
1305    *   ApiFuture<Location> future = agentsClient.listLocationsPagedCallable().futureCall(request);
1306    *   // Do something.
1307    *   for (Location element : future.get().iterateAll()) {
1308    *     // doThingsWith(element);
1309    *   }
1310    * }
1311    * }</pre>
1312    */
1313   public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()1314       listLocationsPagedCallable() {
1315     return stub.listLocationsPagedCallable();
1316   }
1317 
1318   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1319   /**
1320    * Lists information about the supported locations for this service.
1321    *
1322    * <p>Sample code:
1323    *
1324    * <pre>{@code
1325    * // This snippet has been automatically generated and should be regarded as a code template only.
1326    * // It will require modifications to work:
1327    * // - It may require correct/in-range values for request initialization.
1328    * // - It may require specifying regional endpoints when creating the service client as shown in
1329    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1330    * try (AgentsClient agentsClient = AgentsClient.create()) {
1331    *   ListLocationsRequest request =
1332    *       ListLocationsRequest.newBuilder()
1333    *           .setName("name3373707")
1334    *           .setFilter("filter-1274492040")
1335    *           .setPageSize(883849137)
1336    *           .setPageToken("pageToken873572522")
1337    *           .build();
1338    *   while (true) {
1339    *     ListLocationsResponse response = agentsClient.listLocationsCallable().call(request);
1340    *     for (Location element : response.getLocationsList()) {
1341    *       // doThingsWith(element);
1342    *     }
1343    *     String nextPageToken = response.getNextPageToken();
1344    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
1345    *       request = request.toBuilder().setPageToken(nextPageToken).build();
1346    *     } else {
1347    *       break;
1348    *     }
1349    *   }
1350    * }
1351    * }</pre>
1352    */
listLocationsCallable()1353   public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
1354     return stub.listLocationsCallable();
1355   }
1356 
1357   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1358   /**
1359    * Gets information about a location.
1360    *
1361    * <p>Sample code:
1362    *
1363    * <pre>{@code
1364    * // This snippet has been automatically generated and should be regarded as a code template only.
1365    * // It will require modifications to work:
1366    * // - It may require correct/in-range values for request initialization.
1367    * // - It may require specifying regional endpoints when creating the service client as shown in
1368    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1369    * try (AgentsClient agentsClient = AgentsClient.create()) {
1370    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
1371    *   Location response = agentsClient.getLocation(request);
1372    * }
1373    * }</pre>
1374    *
1375    * @param request The request object containing all of the parameters for the API call.
1376    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1377    */
getLocation(GetLocationRequest request)1378   public final Location getLocation(GetLocationRequest request) {
1379     return getLocationCallable().call(request);
1380   }
1381 
1382   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1383   /**
1384    * Gets information about a location.
1385    *
1386    * <p>Sample code:
1387    *
1388    * <pre>{@code
1389    * // This snippet has been automatically generated and should be regarded as a code template only.
1390    * // It will require modifications to work:
1391    * // - It may require correct/in-range values for request initialization.
1392    * // - It may require specifying regional endpoints when creating the service client as shown in
1393    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1394    * try (AgentsClient agentsClient = AgentsClient.create()) {
1395    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
1396    *   ApiFuture<Location> future = agentsClient.getLocationCallable().futureCall(request);
1397    *   // Do something.
1398    *   Location response = future.get();
1399    * }
1400    * }</pre>
1401    */
getLocationCallable()1402   public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
1403     return stub.getLocationCallable();
1404   }
1405 
1406   @Override
close()1407   public final void close() {
1408     stub.close();
1409   }
1410 
1411   @Override
shutdown()1412   public void shutdown() {
1413     stub.shutdown();
1414   }
1415 
1416   @Override
isShutdown()1417   public boolean isShutdown() {
1418     return stub.isShutdown();
1419   }
1420 
1421   @Override
isTerminated()1422   public boolean isTerminated() {
1423     return stub.isTerminated();
1424   }
1425 
1426   @Override
shutdownNow()1427   public void shutdownNow() {
1428     stub.shutdownNow();
1429   }
1430 
1431   @Override
awaitTermination(long duration, TimeUnit unit)1432   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1433     return stub.awaitTermination(duration, unit);
1434   }
1435 
1436   public static class ListAgentsPagedResponse
1437       extends AbstractPagedListResponse<
1438           ListAgentsRequest,
1439           ListAgentsResponse,
1440           Agent,
1441           ListAgentsPage,
1442           ListAgentsFixedSizeCollection> {
1443 
createAsync( PageContext<ListAgentsRequest, ListAgentsResponse, Agent> context, ApiFuture<ListAgentsResponse> futureResponse)1444     public static ApiFuture<ListAgentsPagedResponse> createAsync(
1445         PageContext<ListAgentsRequest, ListAgentsResponse, Agent> context,
1446         ApiFuture<ListAgentsResponse> futureResponse) {
1447       ApiFuture<ListAgentsPage> futurePage =
1448           ListAgentsPage.createEmptyPage().createPageAsync(context, futureResponse);
1449       return ApiFutures.transform(
1450           futurePage, input -> new ListAgentsPagedResponse(input), MoreExecutors.directExecutor());
1451     }
1452 
ListAgentsPagedResponse(ListAgentsPage page)1453     private ListAgentsPagedResponse(ListAgentsPage page) {
1454       super(page, ListAgentsFixedSizeCollection.createEmptyCollection());
1455     }
1456   }
1457 
1458   public static class ListAgentsPage
1459       extends AbstractPage<ListAgentsRequest, ListAgentsResponse, Agent, ListAgentsPage> {
1460 
ListAgentsPage( PageContext<ListAgentsRequest, ListAgentsResponse, Agent> context, ListAgentsResponse response)1461     private ListAgentsPage(
1462         PageContext<ListAgentsRequest, ListAgentsResponse, Agent> context,
1463         ListAgentsResponse response) {
1464       super(context, response);
1465     }
1466 
createEmptyPage()1467     private static ListAgentsPage createEmptyPage() {
1468       return new ListAgentsPage(null, null);
1469     }
1470 
1471     @Override
createPage( PageContext<ListAgentsRequest, ListAgentsResponse, Agent> context, ListAgentsResponse response)1472     protected ListAgentsPage createPage(
1473         PageContext<ListAgentsRequest, ListAgentsResponse, Agent> context,
1474         ListAgentsResponse response) {
1475       return new ListAgentsPage(context, response);
1476     }
1477 
1478     @Override
createPageAsync( PageContext<ListAgentsRequest, ListAgentsResponse, Agent> context, ApiFuture<ListAgentsResponse> futureResponse)1479     public ApiFuture<ListAgentsPage> createPageAsync(
1480         PageContext<ListAgentsRequest, ListAgentsResponse, Agent> context,
1481         ApiFuture<ListAgentsResponse> futureResponse) {
1482       return super.createPageAsync(context, futureResponse);
1483     }
1484   }
1485 
1486   public static class ListAgentsFixedSizeCollection
1487       extends AbstractFixedSizeCollection<
1488           ListAgentsRequest,
1489           ListAgentsResponse,
1490           Agent,
1491           ListAgentsPage,
1492           ListAgentsFixedSizeCollection> {
1493 
ListAgentsFixedSizeCollection(List<ListAgentsPage> pages, int collectionSize)1494     private ListAgentsFixedSizeCollection(List<ListAgentsPage> pages, int collectionSize) {
1495       super(pages, collectionSize);
1496     }
1497 
createEmptyCollection()1498     private static ListAgentsFixedSizeCollection createEmptyCollection() {
1499       return new ListAgentsFixedSizeCollection(null, 0);
1500     }
1501 
1502     @Override
createCollection( List<ListAgentsPage> pages, int collectionSize)1503     protected ListAgentsFixedSizeCollection createCollection(
1504         List<ListAgentsPage> pages, int collectionSize) {
1505       return new ListAgentsFixedSizeCollection(pages, collectionSize);
1506     }
1507   }
1508 
1509   public static class ListLocationsPagedResponse
1510       extends AbstractPagedListResponse<
1511           ListLocationsRequest,
1512           ListLocationsResponse,
1513           Location,
1514           ListLocationsPage,
1515           ListLocationsFixedSizeCollection> {
1516 
createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1517     public static ApiFuture<ListLocationsPagedResponse> createAsync(
1518         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1519         ApiFuture<ListLocationsResponse> futureResponse) {
1520       ApiFuture<ListLocationsPage> futurePage =
1521           ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
1522       return ApiFutures.transform(
1523           futurePage,
1524           input -> new ListLocationsPagedResponse(input),
1525           MoreExecutors.directExecutor());
1526     }
1527 
ListLocationsPagedResponse(ListLocationsPage page)1528     private ListLocationsPagedResponse(ListLocationsPage page) {
1529       super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
1530     }
1531   }
1532 
1533   public static class ListLocationsPage
1534       extends AbstractPage<
1535           ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
1536 
ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1537     private ListLocationsPage(
1538         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1539         ListLocationsResponse response) {
1540       super(context, response);
1541     }
1542 
createEmptyPage()1543     private static ListLocationsPage createEmptyPage() {
1544       return new ListLocationsPage(null, null);
1545     }
1546 
1547     @Override
createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1548     protected ListLocationsPage createPage(
1549         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1550         ListLocationsResponse response) {
1551       return new ListLocationsPage(context, response);
1552     }
1553 
1554     @Override
createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1555     public ApiFuture<ListLocationsPage> createPageAsync(
1556         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1557         ApiFuture<ListLocationsResponse> futureResponse) {
1558       return super.createPageAsync(context, futureResponse);
1559     }
1560   }
1561 
1562   public static class ListLocationsFixedSizeCollection
1563       extends AbstractFixedSizeCollection<
1564           ListLocationsRequest,
1565           ListLocationsResponse,
1566           Location,
1567           ListLocationsPage,
1568           ListLocationsFixedSizeCollection> {
1569 
ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1570     private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
1571       super(pages, collectionSize);
1572     }
1573 
createEmptyCollection()1574     private static ListLocationsFixedSizeCollection createEmptyCollection() {
1575       return new ListLocationsFixedSizeCollection(null, 0);
1576     }
1577 
1578     @Override
createCollection( List<ListLocationsPage> pages, int collectionSize)1579     protected ListLocationsFixedSizeCollection createCollection(
1580         List<ListLocationsPage> pages, int collectionSize) {
1581       return new ListLocationsFixedSizeCollection(pages, collectionSize);
1582     }
1583   }
1584 }
1585