• 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.v2;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.gax.core.BackgroundResource;
22 import com.google.api.gax.paging.AbstractFixedSizeCollection;
23 import com.google.api.gax.paging.AbstractPage;
24 import com.google.api.gax.paging.AbstractPagedListResponse;
25 import com.google.api.gax.rpc.PageContext;
26 import com.google.api.gax.rpc.UnaryCallable;
27 import com.google.cloud.dialogflow.v2.stub.VersionsStub;
28 import com.google.cloud.dialogflow.v2.stub.VersionsStubSettings;
29 import com.google.cloud.location.GetLocationRequest;
30 import com.google.cloud.location.ListLocationsRequest;
31 import com.google.cloud.location.ListLocationsResponse;
32 import com.google.cloud.location.Location;
33 import com.google.common.util.concurrent.MoreExecutors;
34 import com.google.protobuf.Empty;
35 import com.google.protobuf.FieldMask;
36 import java.io.IOException;
37 import java.util.List;
38 import java.util.concurrent.TimeUnit;
39 import javax.annotation.Generated;
40 
41 // AUTO-GENERATED DOCUMENTATION AND CLASS.
42 /**
43  * Service Description: Service for managing [Versions][google.cloud.dialogflow.v2.Version].
44  *
45  * <p>This class provides the ability to make remote calls to the backing service through method
46  * calls that map to API methods. Sample code to get started:
47  *
48  * <pre>{@code
49  * // This snippet has been automatically generated and should be regarded as a code template only.
50  * // It will require modifications to work:
51  * // - It may require correct/in-range values for request initialization.
52  * // - It may require specifying regional endpoints when creating the service client as shown in
53  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
54  * try (VersionsClient versionsClient = VersionsClient.create()) {
55  *   VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]");
56  *   Version response = versionsClient.getVersion(name);
57  * }
58  * }</pre>
59  *
60  * <p>Note: close() needs to be called on the VersionsClient object to clean up resources such as
61  * threads. In the example above, try-with-resources is used, which automatically calls close().
62  *
63  * <p>The surface of this class includes several types of Java methods for each of the API's
64  * methods:
65  *
66  * <ol>
67  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
68  *       converted into function parameters. It may be the case that not all fields are available as
69  *       parameters, and not every API method will have a flattened method entry point.
70  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
71  *       which must be constructed before the call. Not every API method will have a request object
72  *       method.
73  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
74  *       callable object, which can be used to initiate calls to the service.
75  * </ol>
76  *
77  * <p>See the individual methods for example code.
78  *
79  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
80  * these names, this class includes a format method for each type of name, and additionally a parse
81  * method to extract the individual identifiers contained within names that are returned.
82  *
83  * <p>This class can be customized by passing in a custom instance of VersionsSettings to create().
84  * For example:
85  *
86  * <p>To customize credentials:
87  *
88  * <pre>{@code
89  * // This snippet has been automatically generated and should be regarded as a code template only.
90  * // It will require modifications to work:
91  * // - It may require correct/in-range values for request initialization.
92  * // - It may require specifying regional endpoints when creating the service client as shown in
93  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
94  * VersionsSettings versionsSettings =
95  *     VersionsSettings.newBuilder()
96  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
97  *         .build();
98  * VersionsClient versionsClient = VersionsClient.create(versionsSettings);
99  * }</pre>
100  *
101  * <p>To customize the endpoint:
102  *
103  * <pre>{@code
104  * // This snippet has been automatically generated and should be regarded as a code template only.
105  * // It will require modifications to work:
106  * // - It may require correct/in-range values for request initialization.
107  * // - It may require specifying regional endpoints when creating the service client as shown in
108  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
109  * VersionsSettings versionsSettings =
110  *     VersionsSettings.newBuilder().setEndpoint(myEndpoint).build();
111  * VersionsClient versionsClient = VersionsClient.create(versionsSettings);
112  * }</pre>
113  *
114  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
115  * the wire:
116  *
117  * <pre>{@code
118  * // This snippet has been automatically generated and should be regarded as a code template only.
119  * // It will require modifications to work:
120  * // - It may require correct/in-range values for request initialization.
121  * // - It may require specifying regional endpoints when creating the service client as shown in
122  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
123  * VersionsSettings versionsSettings = VersionsSettings.newHttpJsonBuilder().build();
124  * VersionsClient versionsClient = VersionsClient.create(versionsSettings);
125  * }</pre>
126  *
127  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
128  */
129 @Generated("by gapic-generator-java")
130 public class VersionsClient implements BackgroundResource {
131   private final VersionsSettings settings;
132   private final VersionsStub stub;
133 
134   /** Constructs an instance of VersionsClient with default settings. */
create()135   public static final VersionsClient create() throws IOException {
136     return create(VersionsSettings.newBuilder().build());
137   }
138 
139   /**
140    * Constructs an instance of VersionsClient, using the given settings. The channels are created
141    * based on the settings passed in, or defaults for any settings that are not set.
142    */
create(VersionsSettings settings)143   public static final VersionsClient create(VersionsSettings settings) throws IOException {
144     return new VersionsClient(settings);
145   }
146 
147   /**
148    * Constructs an instance of VersionsClient, using the given stub for making calls. This is for
149    * advanced usage - prefer using create(VersionsSettings).
150    */
create(VersionsStub stub)151   public static final VersionsClient create(VersionsStub stub) {
152     return new VersionsClient(stub);
153   }
154 
155   /**
156    * Constructs an instance of VersionsClient, using the given settings. This is protected so that
157    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
158    */
VersionsClient(VersionsSettings settings)159   protected VersionsClient(VersionsSettings settings) throws IOException {
160     this.settings = settings;
161     this.stub = ((VersionsStubSettings) settings.getStubSettings()).createStub();
162   }
163 
VersionsClient(VersionsStub stub)164   protected VersionsClient(VersionsStub stub) {
165     this.settings = null;
166     this.stub = stub;
167   }
168 
getSettings()169   public final VersionsSettings getSettings() {
170     return settings;
171   }
172 
getStub()173   public VersionsStub getStub() {
174     return stub;
175   }
176 
177   // AUTO-GENERATED DOCUMENTATION AND METHOD.
178   /**
179    * Returns the list of all versions of the specified agent.
180    *
181    * <p>Sample code:
182    *
183    * <pre>{@code
184    * // This snippet has been automatically generated and should be regarded as a code template only.
185    * // It will require modifications to work:
186    * // - It may require correct/in-range values for request initialization.
187    * // - It may require specifying regional endpoints when creating the service client as shown in
188    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
189    * try (VersionsClient versionsClient = VersionsClient.create()) {
190    *   AgentName parent = AgentName.ofProjectName("[PROJECT]");
191    *   for (Version element : versionsClient.listVersions(parent).iterateAll()) {
192    *     // doThingsWith(element);
193    *   }
194    * }
195    * }</pre>
196    *
197    * @param parent Required. The agent to list all versions from. Supported formats:
198    *     <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
199    *     ID&gt;/locations/&lt;Location ID&gt;/agent`
200    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
201    */
listVersions(AgentName parent)202   public final ListVersionsPagedResponse listVersions(AgentName parent) {
203     ListVersionsRequest request =
204         ListVersionsRequest.newBuilder()
205             .setParent(parent == null ? null : parent.toString())
206             .build();
207     return listVersions(request);
208   }
209 
210   // AUTO-GENERATED DOCUMENTATION AND METHOD.
211   /**
212    * Returns the list of all versions of the specified agent.
213    *
214    * <p>Sample code:
215    *
216    * <pre>{@code
217    * // This snippet has been automatically generated and should be regarded as a code template only.
218    * // It will require modifications to work:
219    * // - It may require correct/in-range values for request initialization.
220    * // - It may require specifying regional endpoints when creating the service client as shown in
221    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
222    * try (VersionsClient versionsClient = VersionsClient.create()) {
223    *   String parent = AgentName.ofProjectName("[PROJECT]").toString();
224    *   for (Version element : versionsClient.listVersions(parent).iterateAll()) {
225    *     // doThingsWith(element);
226    *   }
227    * }
228    * }</pre>
229    *
230    * @param parent Required. The agent to list all versions from. Supported formats:
231    *     <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
232    *     ID&gt;/locations/&lt;Location ID&gt;/agent`
233    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
234    */
listVersions(String parent)235   public final ListVersionsPagedResponse listVersions(String parent) {
236     ListVersionsRequest request = ListVersionsRequest.newBuilder().setParent(parent).build();
237     return listVersions(request);
238   }
239 
240   // AUTO-GENERATED DOCUMENTATION AND METHOD.
241   /**
242    * Returns the list of all versions of the specified agent.
243    *
244    * <p>Sample code:
245    *
246    * <pre>{@code
247    * // This snippet has been automatically generated and should be regarded as a code template only.
248    * // It will require modifications to work:
249    * // - It may require correct/in-range values for request initialization.
250    * // - It may require specifying regional endpoints when creating the service client as shown in
251    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
252    * try (VersionsClient versionsClient = VersionsClient.create()) {
253    *   ListVersionsRequest request =
254    *       ListVersionsRequest.newBuilder()
255    *           .setParent(AgentName.ofProjectName("[PROJECT]").toString())
256    *           .setPageSize(883849137)
257    *           .setPageToken("pageToken873572522")
258    *           .build();
259    *   for (Version element : versionsClient.listVersions(request).iterateAll()) {
260    *     // doThingsWith(element);
261    *   }
262    * }
263    * }</pre>
264    *
265    * @param request The request object containing all of the parameters for the API call.
266    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
267    */
listVersions(ListVersionsRequest request)268   public final ListVersionsPagedResponse listVersions(ListVersionsRequest request) {
269     return listVersionsPagedCallable().call(request);
270   }
271 
272   // AUTO-GENERATED DOCUMENTATION AND METHOD.
273   /**
274    * Returns the list of all versions of the specified agent.
275    *
276    * <p>Sample code:
277    *
278    * <pre>{@code
279    * // This snippet has been automatically generated and should be regarded as a code template only.
280    * // It will require modifications to work:
281    * // - It may require correct/in-range values for request initialization.
282    * // - It may require specifying regional endpoints when creating the service client as shown in
283    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
284    * try (VersionsClient versionsClient = VersionsClient.create()) {
285    *   ListVersionsRequest request =
286    *       ListVersionsRequest.newBuilder()
287    *           .setParent(AgentName.ofProjectName("[PROJECT]").toString())
288    *           .setPageSize(883849137)
289    *           .setPageToken("pageToken873572522")
290    *           .build();
291    *   ApiFuture<Version> future = versionsClient.listVersionsPagedCallable().futureCall(request);
292    *   // Do something.
293    *   for (Version element : future.get().iterateAll()) {
294    *     // doThingsWith(element);
295    *   }
296    * }
297    * }</pre>
298    */
299   public final UnaryCallable<ListVersionsRequest, ListVersionsPagedResponse>
listVersionsPagedCallable()300       listVersionsPagedCallable() {
301     return stub.listVersionsPagedCallable();
302   }
303 
304   // AUTO-GENERATED DOCUMENTATION AND METHOD.
305   /**
306    * Returns the list of all versions of the specified agent.
307    *
308    * <p>Sample code:
309    *
310    * <pre>{@code
311    * // This snippet has been automatically generated and should be regarded as a code template only.
312    * // It will require modifications to work:
313    * // - It may require correct/in-range values for request initialization.
314    * // - It may require specifying regional endpoints when creating the service client as shown in
315    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
316    * try (VersionsClient versionsClient = VersionsClient.create()) {
317    *   ListVersionsRequest request =
318    *       ListVersionsRequest.newBuilder()
319    *           .setParent(AgentName.ofProjectName("[PROJECT]").toString())
320    *           .setPageSize(883849137)
321    *           .setPageToken("pageToken873572522")
322    *           .build();
323    *   while (true) {
324    *     ListVersionsResponse response = versionsClient.listVersionsCallable().call(request);
325    *     for (Version element : response.getVersionsList()) {
326    *       // doThingsWith(element);
327    *     }
328    *     String nextPageToken = response.getNextPageToken();
329    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
330    *       request = request.toBuilder().setPageToken(nextPageToken).build();
331    *     } else {
332    *       break;
333    *     }
334    *   }
335    * }
336    * }</pre>
337    */
listVersionsCallable()338   public final UnaryCallable<ListVersionsRequest, ListVersionsResponse> listVersionsCallable() {
339     return stub.listVersionsCallable();
340   }
341 
342   // AUTO-GENERATED DOCUMENTATION AND METHOD.
343   /**
344    * Retrieves the specified agent version.
345    *
346    * <p>Sample code:
347    *
348    * <pre>{@code
349    * // This snippet has been automatically generated and should be regarded as a code template only.
350    * // It will require modifications to work:
351    * // - It may require correct/in-range values for request initialization.
352    * // - It may require specifying regional endpoints when creating the service client as shown in
353    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
354    * try (VersionsClient versionsClient = VersionsClient.create()) {
355    *   VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]");
356    *   Version response = versionsClient.getVersion(name);
357    * }
358    * }</pre>
359    *
360    * @param name Required. The name of the version. Supported formats:
361    *     <p>- `projects/&lt;Project ID&gt;/agent/versions/&lt;Version ID&gt;` -
362    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/agent/versions/&lt;Version
363    *     ID&gt;`
364    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
365    */
getVersion(VersionName name)366   public final Version getVersion(VersionName name) {
367     GetVersionRequest request =
368         GetVersionRequest.newBuilder().setName(name == null ? null : name.toString()).build();
369     return getVersion(request);
370   }
371 
372   // AUTO-GENERATED DOCUMENTATION AND METHOD.
373   /**
374    * Retrieves the specified agent version.
375    *
376    * <p>Sample code:
377    *
378    * <pre>{@code
379    * // This snippet has been automatically generated and should be regarded as a code template only.
380    * // It will require modifications to work:
381    * // - It may require correct/in-range values for request initialization.
382    * // - It may require specifying regional endpoints when creating the service client as shown in
383    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
384    * try (VersionsClient versionsClient = VersionsClient.create()) {
385    *   String name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString();
386    *   Version response = versionsClient.getVersion(name);
387    * }
388    * }</pre>
389    *
390    * @param name Required. The name of the version. Supported formats:
391    *     <p>- `projects/&lt;Project ID&gt;/agent/versions/&lt;Version ID&gt;` -
392    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/agent/versions/&lt;Version
393    *     ID&gt;`
394    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
395    */
getVersion(String name)396   public final Version getVersion(String name) {
397     GetVersionRequest request = GetVersionRequest.newBuilder().setName(name).build();
398     return getVersion(request);
399   }
400 
401   // AUTO-GENERATED DOCUMENTATION AND METHOD.
402   /**
403    * Retrieves the specified agent version.
404    *
405    * <p>Sample code:
406    *
407    * <pre>{@code
408    * // This snippet has been automatically generated and should be regarded as a code template only.
409    * // It will require modifications to work:
410    * // - It may require correct/in-range values for request initialization.
411    * // - It may require specifying regional endpoints when creating the service client as shown in
412    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
413    * try (VersionsClient versionsClient = VersionsClient.create()) {
414    *   GetVersionRequest request =
415    *       GetVersionRequest.newBuilder()
416    *           .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString())
417    *           .build();
418    *   Version response = versionsClient.getVersion(request);
419    * }
420    * }</pre>
421    *
422    * @param request The request object containing all of the parameters for the API call.
423    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
424    */
getVersion(GetVersionRequest request)425   public final Version getVersion(GetVersionRequest request) {
426     return getVersionCallable().call(request);
427   }
428 
429   // AUTO-GENERATED DOCUMENTATION AND METHOD.
430   /**
431    * Retrieves the specified agent version.
432    *
433    * <p>Sample code:
434    *
435    * <pre>{@code
436    * // This snippet has been automatically generated and should be regarded as a code template only.
437    * // It will require modifications to work:
438    * // - It may require correct/in-range values for request initialization.
439    * // - It may require specifying regional endpoints when creating the service client as shown in
440    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
441    * try (VersionsClient versionsClient = VersionsClient.create()) {
442    *   GetVersionRequest request =
443    *       GetVersionRequest.newBuilder()
444    *           .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString())
445    *           .build();
446    *   ApiFuture<Version> future = versionsClient.getVersionCallable().futureCall(request);
447    *   // Do something.
448    *   Version response = future.get();
449    * }
450    * }</pre>
451    */
getVersionCallable()452   public final UnaryCallable<GetVersionRequest, Version> getVersionCallable() {
453     return stub.getVersionCallable();
454   }
455 
456   // AUTO-GENERATED DOCUMENTATION AND METHOD.
457   /**
458    * Creates an agent version.
459    *
460    * <p>The new version points to the agent instance in the "default" environment.
461    *
462    * <p>Sample code:
463    *
464    * <pre>{@code
465    * // This snippet has been automatically generated and should be regarded as a code template only.
466    * // It will require modifications to work:
467    * // - It may require correct/in-range values for request initialization.
468    * // - It may require specifying regional endpoints when creating the service client as shown in
469    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
470    * try (VersionsClient versionsClient = VersionsClient.create()) {
471    *   AgentName parent = AgentName.ofProjectName("[PROJECT]");
472    *   Version version = Version.newBuilder().build();
473    *   Version response = versionsClient.createVersion(parent, version);
474    * }
475    * }</pre>
476    *
477    * @param parent Required. The agent to create a version for. Supported formats:
478    *     <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
479    *     ID&gt;/locations/&lt;Location ID&gt;/agent`
480    * @param version Required. The version to create.
481    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
482    */
createVersion(AgentName parent, Version version)483   public final Version createVersion(AgentName parent, Version version) {
484     CreateVersionRequest request =
485         CreateVersionRequest.newBuilder()
486             .setParent(parent == null ? null : parent.toString())
487             .setVersion(version)
488             .build();
489     return createVersion(request);
490   }
491 
492   // AUTO-GENERATED DOCUMENTATION AND METHOD.
493   /**
494    * Creates an agent version.
495    *
496    * <p>The new version points to the agent instance in the "default" environment.
497    *
498    * <p>Sample code:
499    *
500    * <pre>{@code
501    * // This snippet has been automatically generated and should be regarded as a code template only.
502    * // It will require modifications to work:
503    * // - It may require correct/in-range values for request initialization.
504    * // - It may require specifying regional endpoints when creating the service client as shown in
505    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
506    * try (VersionsClient versionsClient = VersionsClient.create()) {
507    *   String parent = AgentName.ofProjectName("[PROJECT]").toString();
508    *   Version version = Version.newBuilder().build();
509    *   Version response = versionsClient.createVersion(parent, version);
510    * }
511    * }</pre>
512    *
513    * @param parent Required. The agent to create a version for. Supported formats:
514    *     <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
515    *     ID&gt;/locations/&lt;Location ID&gt;/agent`
516    * @param version Required. The version to create.
517    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
518    */
createVersion(String parent, Version version)519   public final Version createVersion(String parent, Version version) {
520     CreateVersionRequest request =
521         CreateVersionRequest.newBuilder().setParent(parent).setVersion(version).build();
522     return createVersion(request);
523   }
524 
525   // AUTO-GENERATED DOCUMENTATION AND METHOD.
526   /**
527    * Creates an agent version.
528    *
529    * <p>The new version points to the agent instance in the "default" environment.
530    *
531    * <p>Sample code:
532    *
533    * <pre>{@code
534    * // This snippet has been automatically generated and should be regarded as a code template only.
535    * // It will require modifications to work:
536    * // - It may require correct/in-range values for request initialization.
537    * // - It may require specifying regional endpoints when creating the service client as shown in
538    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
539    * try (VersionsClient versionsClient = VersionsClient.create()) {
540    *   CreateVersionRequest request =
541    *       CreateVersionRequest.newBuilder()
542    *           .setParent(AgentName.ofProjectName("[PROJECT]").toString())
543    *           .setVersion(Version.newBuilder().build())
544    *           .build();
545    *   Version response = versionsClient.createVersion(request);
546    * }
547    * }</pre>
548    *
549    * @param request The request object containing all of the parameters for the API call.
550    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
551    */
createVersion(CreateVersionRequest request)552   public final Version createVersion(CreateVersionRequest request) {
553     return createVersionCallable().call(request);
554   }
555 
556   // AUTO-GENERATED DOCUMENTATION AND METHOD.
557   /**
558    * Creates an agent version.
559    *
560    * <p>The new version points to the agent instance in the "default" environment.
561    *
562    * <p>Sample code:
563    *
564    * <pre>{@code
565    * // This snippet has been automatically generated and should be regarded as a code template only.
566    * // It will require modifications to work:
567    * // - It may require correct/in-range values for request initialization.
568    * // - It may require specifying regional endpoints when creating the service client as shown in
569    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
570    * try (VersionsClient versionsClient = VersionsClient.create()) {
571    *   CreateVersionRequest request =
572    *       CreateVersionRequest.newBuilder()
573    *           .setParent(AgentName.ofProjectName("[PROJECT]").toString())
574    *           .setVersion(Version.newBuilder().build())
575    *           .build();
576    *   ApiFuture<Version> future = versionsClient.createVersionCallable().futureCall(request);
577    *   // Do something.
578    *   Version response = future.get();
579    * }
580    * }</pre>
581    */
createVersionCallable()582   public final UnaryCallable<CreateVersionRequest, Version> createVersionCallable() {
583     return stub.createVersionCallable();
584   }
585 
586   // AUTO-GENERATED DOCUMENTATION AND METHOD.
587   /**
588    * Updates the specified agent version.
589    *
590    * <p>Note that this method does not allow you to update the state of the agent the given version
591    * points to. It allows you to update only mutable properties of the version resource.
592    *
593    * <p>Sample code:
594    *
595    * <pre>{@code
596    * // This snippet has been automatically generated and should be regarded as a code template only.
597    * // It will require modifications to work:
598    * // - It may require correct/in-range values for request initialization.
599    * // - It may require specifying regional endpoints when creating the service client as shown in
600    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
601    * try (VersionsClient versionsClient = VersionsClient.create()) {
602    *   Version version = Version.newBuilder().build();
603    *   FieldMask updateMask = FieldMask.newBuilder().build();
604    *   Version response = versionsClient.updateVersion(version, updateMask);
605    * }
606    * }</pre>
607    *
608    * @param version Required. The version to update. Supported formats:
609    *     <p>- `projects/&lt;Project ID&gt;/agent/versions/&lt;Version ID&gt;` -
610    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/agent/versions/&lt;Version
611    *     ID&gt;`
612    * @param updateMask Required. The mask to control which fields get updated.
613    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
614    */
updateVersion(Version version, FieldMask updateMask)615   public final Version updateVersion(Version version, FieldMask updateMask) {
616     UpdateVersionRequest request =
617         UpdateVersionRequest.newBuilder().setVersion(version).setUpdateMask(updateMask).build();
618     return updateVersion(request);
619   }
620 
621   // AUTO-GENERATED DOCUMENTATION AND METHOD.
622   /**
623    * Updates the specified agent version.
624    *
625    * <p>Note that this method does not allow you to update the state of the agent the given version
626    * points to. It allows you to update only mutable properties of the version resource.
627    *
628    * <p>Sample code:
629    *
630    * <pre>{@code
631    * // This snippet has been automatically generated and should be regarded as a code template only.
632    * // It will require modifications to work:
633    * // - It may require correct/in-range values for request initialization.
634    * // - It may require specifying regional endpoints when creating the service client as shown in
635    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
636    * try (VersionsClient versionsClient = VersionsClient.create()) {
637    *   UpdateVersionRequest request =
638    *       UpdateVersionRequest.newBuilder()
639    *           .setVersion(Version.newBuilder().build())
640    *           .setUpdateMask(FieldMask.newBuilder().build())
641    *           .build();
642    *   Version response = versionsClient.updateVersion(request);
643    * }
644    * }</pre>
645    *
646    * @param request The request object containing all of the parameters for the API call.
647    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
648    */
updateVersion(UpdateVersionRequest request)649   public final Version updateVersion(UpdateVersionRequest request) {
650     return updateVersionCallable().call(request);
651   }
652 
653   // AUTO-GENERATED DOCUMENTATION AND METHOD.
654   /**
655    * Updates the specified agent version.
656    *
657    * <p>Note that this method does not allow you to update the state of the agent the given version
658    * points to. It allows you to update only mutable properties of the version resource.
659    *
660    * <p>Sample code:
661    *
662    * <pre>{@code
663    * // This snippet has been automatically generated and should be regarded as a code template only.
664    * // It will require modifications to work:
665    * // - It may require correct/in-range values for request initialization.
666    * // - It may require specifying regional endpoints when creating the service client as shown in
667    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
668    * try (VersionsClient versionsClient = VersionsClient.create()) {
669    *   UpdateVersionRequest request =
670    *       UpdateVersionRequest.newBuilder()
671    *           .setVersion(Version.newBuilder().build())
672    *           .setUpdateMask(FieldMask.newBuilder().build())
673    *           .build();
674    *   ApiFuture<Version> future = versionsClient.updateVersionCallable().futureCall(request);
675    *   // Do something.
676    *   Version response = future.get();
677    * }
678    * }</pre>
679    */
updateVersionCallable()680   public final UnaryCallable<UpdateVersionRequest, Version> updateVersionCallable() {
681     return stub.updateVersionCallable();
682   }
683 
684   // AUTO-GENERATED DOCUMENTATION AND METHOD.
685   /**
686    * Delete the specified agent version.
687    *
688    * <p>Sample code:
689    *
690    * <pre>{@code
691    * // This snippet has been automatically generated and should be regarded as a code template only.
692    * // It will require modifications to work:
693    * // - It may require correct/in-range values for request initialization.
694    * // - It may require specifying regional endpoints when creating the service client as shown in
695    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
696    * try (VersionsClient versionsClient = VersionsClient.create()) {
697    *   VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]");
698    *   versionsClient.deleteVersion(name);
699    * }
700    * }</pre>
701    *
702    * @param name Required. The name of the version to delete. Supported formats:
703    *     <p>- `projects/&lt;Project ID&gt;/agent/versions/&lt;Version ID&gt;` -
704    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/agent/versions/&lt;Version
705    *     ID&gt;`
706    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
707    */
deleteVersion(VersionName name)708   public final void deleteVersion(VersionName name) {
709     DeleteVersionRequest request =
710         DeleteVersionRequest.newBuilder().setName(name == null ? null : name.toString()).build();
711     deleteVersion(request);
712   }
713 
714   // AUTO-GENERATED DOCUMENTATION AND METHOD.
715   /**
716    * Delete the specified agent version.
717    *
718    * <p>Sample code:
719    *
720    * <pre>{@code
721    * // This snippet has been automatically generated and should be regarded as a code template only.
722    * // It will require modifications to work:
723    * // - It may require correct/in-range values for request initialization.
724    * // - It may require specifying regional endpoints when creating the service client as shown in
725    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
726    * try (VersionsClient versionsClient = VersionsClient.create()) {
727    *   String name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString();
728    *   versionsClient.deleteVersion(name);
729    * }
730    * }</pre>
731    *
732    * @param name Required. The name of the version to delete. Supported formats:
733    *     <p>- `projects/&lt;Project ID&gt;/agent/versions/&lt;Version ID&gt;` -
734    *     `projects/&lt;Project ID&gt;/locations/&lt;Location ID&gt;/agent/versions/&lt;Version
735    *     ID&gt;`
736    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
737    */
deleteVersion(String name)738   public final void deleteVersion(String name) {
739     DeleteVersionRequest request = DeleteVersionRequest.newBuilder().setName(name).build();
740     deleteVersion(request);
741   }
742 
743   // AUTO-GENERATED DOCUMENTATION AND METHOD.
744   /**
745    * Delete the specified agent version.
746    *
747    * <p>Sample code:
748    *
749    * <pre>{@code
750    * // This snippet has been automatically generated and should be regarded as a code template only.
751    * // It will require modifications to work:
752    * // - It may require correct/in-range values for request initialization.
753    * // - It may require specifying regional endpoints when creating the service client as shown in
754    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
755    * try (VersionsClient versionsClient = VersionsClient.create()) {
756    *   DeleteVersionRequest request =
757    *       DeleteVersionRequest.newBuilder()
758    *           .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString())
759    *           .build();
760    *   versionsClient.deleteVersion(request);
761    * }
762    * }</pre>
763    *
764    * @param request The request object containing all of the parameters for the API call.
765    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
766    */
deleteVersion(DeleteVersionRequest request)767   public final void deleteVersion(DeleteVersionRequest request) {
768     deleteVersionCallable().call(request);
769   }
770 
771   // AUTO-GENERATED DOCUMENTATION AND METHOD.
772   /**
773    * Delete the specified agent version.
774    *
775    * <p>Sample code:
776    *
777    * <pre>{@code
778    * // This snippet has been automatically generated and should be regarded as a code template only.
779    * // It will require modifications to work:
780    * // - It may require correct/in-range values for request initialization.
781    * // - It may require specifying regional endpoints when creating the service client as shown in
782    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
783    * try (VersionsClient versionsClient = VersionsClient.create()) {
784    *   DeleteVersionRequest request =
785    *       DeleteVersionRequest.newBuilder()
786    *           .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString())
787    *           .build();
788    *   ApiFuture<Empty> future = versionsClient.deleteVersionCallable().futureCall(request);
789    *   // Do something.
790    *   future.get();
791    * }
792    * }</pre>
793    */
deleteVersionCallable()794   public final UnaryCallable<DeleteVersionRequest, Empty> deleteVersionCallable() {
795     return stub.deleteVersionCallable();
796   }
797 
798   // AUTO-GENERATED DOCUMENTATION AND METHOD.
799   /**
800    * Lists information about the supported locations for this service.
801    *
802    * <p>Sample code:
803    *
804    * <pre>{@code
805    * // This snippet has been automatically generated and should be regarded as a code template only.
806    * // It will require modifications to work:
807    * // - It may require correct/in-range values for request initialization.
808    * // - It may require specifying regional endpoints when creating the service client as shown in
809    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
810    * try (VersionsClient versionsClient = VersionsClient.create()) {
811    *   ListLocationsRequest request =
812    *       ListLocationsRequest.newBuilder()
813    *           .setName("name3373707")
814    *           .setFilter("filter-1274492040")
815    *           .setPageSize(883849137)
816    *           .setPageToken("pageToken873572522")
817    *           .build();
818    *   for (Location element : versionsClient.listLocations(request).iterateAll()) {
819    *     // doThingsWith(element);
820    *   }
821    * }
822    * }</pre>
823    *
824    * @param request The request object containing all of the parameters for the API call.
825    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
826    */
listLocations(ListLocationsRequest request)827   public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
828     return listLocationsPagedCallable().call(request);
829   }
830 
831   // AUTO-GENERATED DOCUMENTATION AND METHOD.
832   /**
833    * Lists information about the supported locations for this service.
834    *
835    * <p>Sample code:
836    *
837    * <pre>{@code
838    * // This snippet has been automatically generated and should be regarded as a code template only.
839    * // It will require modifications to work:
840    * // - It may require correct/in-range values for request initialization.
841    * // - It may require specifying regional endpoints when creating the service client as shown in
842    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
843    * try (VersionsClient versionsClient = VersionsClient.create()) {
844    *   ListLocationsRequest request =
845    *       ListLocationsRequest.newBuilder()
846    *           .setName("name3373707")
847    *           .setFilter("filter-1274492040")
848    *           .setPageSize(883849137)
849    *           .setPageToken("pageToken873572522")
850    *           .build();
851    *   ApiFuture<Location> future = versionsClient.listLocationsPagedCallable().futureCall(request);
852    *   // Do something.
853    *   for (Location element : future.get().iterateAll()) {
854    *     // doThingsWith(element);
855    *   }
856    * }
857    * }</pre>
858    */
859   public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()860       listLocationsPagedCallable() {
861     return stub.listLocationsPagedCallable();
862   }
863 
864   // AUTO-GENERATED DOCUMENTATION AND METHOD.
865   /**
866    * Lists information about the supported locations for this service.
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 (VersionsClient versionsClient = VersionsClient.create()) {
877    *   ListLocationsRequest request =
878    *       ListLocationsRequest.newBuilder()
879    *           .setName("name3373707")
880    *           .setFilter("filter-1274492040")
881    *           .setPageSize(883849137)
882    *           .setPageToken("pageToken873572522")
883    *           .build();
884    *   while (true) {
885    *     ListLocationsResponse response = versionsClient.listLocationsCallable().call(request);
886    *     for (Location element : response.getLocationsList()) {
887    *       // doThingsWith(element);
888    *     }
889    *     String nextPageToken = response.getNextPageToken();
890    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
891    *       request = request.toBuilder().setPageToken(nextPageToken).build();
892    *     } else {
893    *       break;
894    *     }
895    *   }
896    * }
897    * }</pre>
898    */
listLocationsCallable()899   public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
900     return stub.listLocationsCallable();
901   }
902 
903   // AUTO-GENERATED DOCUMENTATION AND METHOD.
904   /**
905    * Gets information about a location.
906    *
907    * <p>Sample code:
908    *
909    * <pre>{@code
910    * // This snippet has been automatically generated and should be regarded as a code template only.
911    * // It will require modifications to work:
912    * // - It may require correct/in-range values for request initialization.
913    * // - It may require specifying regional endpoints when creating the service client as shown in
914    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
915    * try (VersionsClient versionsClient = VersionsClient.create()) {
916    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
917    *   Location response = versionsClient.getLocation(request);
918    * }
919    * }</pre>
920    *
921    * @param request The request object containing all of the parameters for the API call.
922    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
923    */
getLocation(GetLocationRequest request)924   public final Location getLocation(GetLocationRequest request) {
925     return getLocationCallable().call(request);
926   }
927 
928   // AUTO-GENERATED DOCUMENTATION AND METHOD.
929   /**
930    * Gets information about a location.
931    *
932    * <p>Sample code:
933    *
934    * <pre>{@code
935    * // This snippet has been automatically generated and should be regarded as a code template only.
936    * // It will require modifications to work:
937    * // - It may require correct/in-range values for request initialization.
938    * // - It may require specifying regional endpoints when creating the service client as shown in
939    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
940    * try (VersionsClient versionsClient = VersionsClient.create()) {
941    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
942    *   ApiFuture<Location> future = versionsClient.getLocationCallable().futureCall(request);
943    *   // Do something.
944    *   Location response = future.get();
945    * }
946    * }</pre>
947    */
getLocationCallable()948   public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
949     return stub.getLocationCallable();
950   }
951 
952   @Override
close()953   public final void close() {
954     stub.close();
955   }
956 
957   @Override
shutdown()958   public void shutdown() {
959     stub.shutdown();
960   }
961 
962   @Override
isShutdown()963   public boolean isShutdown() {
964     return stub.isShutdown();
965   }
966 
967   @Override
isTerminated()968   public boolean isTerminated() {
969     return stub.isTerminated();
970   }
971 
972   @Override
shutdownNow()973   public void shutdownNow() {
974     stub.shutdownNow();
975   }
976 
977   @Override
awaitTermination(long duration, TimeUnit unit)978   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
979     return stub.awaitTermination(duration, unit);
980   }
981 
982   public static class ListVersionsPagedResponse
983       extends AbstractPagedListResponse<
984           ListVersionsRequest,
985           ListVersionsResponse,
986           Version,
987           ListVersionsPage,
988           ListVersionsFixedSizeCollection> {
989 
createAsync( PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, ApiFuture<ListVersionsResponse> futureResponse)990     public static ApiFuture<ListVersionsPagedResponse> createAsync(
991         PageContext<ListVersionsRequest, ListVersionsResponse, Version> context,
992         ApiFuture<ListVersionsResponse> futureResponse) {
993       ApiFuture<ListVersionsPage> futurePage =
994           ListVersionsPage.createEmptyPage().createPageAsync(context, futureResponse);
995       return ApiFutures.transform(
996           futurePage,
997           input -> new ListVersionsPagedResponse(input),
998           MoreExecutors.directExecutor());
999     }
1000 
ListVersionsPagedResponse(ListVersionsPage page)1001     private ListVersionsPagedResponse(ListVersionsPage page) {
1002       super(page, ListVersionsFixedSizeCollection.createEmptyCollection());
1003     }
1004   }
1005 
1006   public static class ListVersionsPage
1007       extends AbstractPage<ListVersionsRequest, ListVersionsResponse, Version, ListVersionsPage> {
1008 
ListVersionsPage( PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, ListVersionsResponse response)1009     private ListVersionsPage(
1010         PageContext<ListVersionsRequest, ListVersionsResponse, Version> context,
1011         ListVersionsResponse response) {
1012       super(context, response);
1013     }
1014 
createEmptyPage()1015     private static ListVersionsPage createEmptyPage() {
1016       return new ListVersionsPage(null, null);
1017     }
1018 
1019     @Override
createPage( PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, ListVersionsResponse response)1020     protected ListVersionsPage createPage(
1021         PageContext<ListVersionsRequest, ListVersionsResponse, Version> context,
1022         ListVersionsResponse response) {
1023       return new ListVersionsPage(context, response);
1024     }
1025 
1026     @Override
createPageAsync( PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, ApiFuture<ListVersionsResponse> futureResponse)1027     public ApiFuture<ListVersionsPage> createPageAsync(
1028         PageContext<ListVersionsRequest, ListVersionsResponse, Version> context,
1029         ApiFuture<ListVersionsResponse> futureResponse) {
1030       return super.createPageAsync(context, futureResponse);
1031     }
1032   }
1033 
1034   public static class ListVersionsFixedSizeCollection
1035       extends AbstractFixedSizeCollection<
1036           ListVersionsRequest,
1037           ListVersionsResponse,
1038           Version,
1039           ListVersionsPage,
1040           ListVersionsFixedSizeCollection> {
1041 
ListVersionsFixedSizeCollection(List<ListVersionsPage> pages, int collectionSize)1042     private ListVersionsFixedSizeCollection(List<ListVersionsPage> pages, int collectionSize) {
1043       super(pages, collectionSize);
1044     }
1045 
createEmptyCollection()1046     private static ListVersionsFixedSizeCollection createEmptyCollection() {
1047       return new ListVersionsFixedSizeCollection(null, 0);
1048     }
1049 
1050     @Override
createCollection( List<ListVersionsPage> pages, int collectionSize)1051     protected ListVersionsFixedSizeCollection createCollection(
1052         List<ListVersionsPage> pages, int collectionSize) {
1053       return new ListVersionsFixedSizeCollection(pages, collectionSize);
1054     }
1055   }
1056 
1057   public static class ListLocationsPagedResponse
1058       extends AbstractPagedListResponse<
1059           ListLocationsRequest,
1060           ListLocationsResponse,
1061           Location,
1062           ListLocationsPage,
1063           ListLocationsFixedSizeCollection> {
1064 
createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1065     public static ApiFuture<ListLocationsPagedResponse> createAsync(
1066         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1067         ApiFuture<ListLocationsResponse> futureResponse) {
1068       ApiFuture<ListLocationsPage> futurePage =
1069           ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
1070       return ApiFutures.transform(
1071           futurePage,
1072           input -> new ListLocationsPagedResponse(input),
1073           MoreExecutors.directExecutor());
1074     }
1075 
ListLocationsPagedResponse(ListLocationsPage page)1076     private ListLocationsPagedResponse(ListLocationsPage page) {
1077       super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
1078     }
1079   }
1080 
1081   public static class ListLocationsPage
1082       extends AbstractPage<
1083           ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
1084 
ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1085     private ListLocationsPage(
1086         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1087         ListLocationsResponse response) {
1088       super(context, response);
1089     }
1090 
createEmptyPage()1091     private static ListLocationsPage createEmptyPage() {
1092       return new ListLocationsPage(null, null);
1093     }
1094 
1095     @Override
createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1096     protected ListLocationsPage createPage(
1097         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1098         ListLocationsResponse response) {
1099       return new ListLocationsPage(context, response);
1100     }
1101 
1102     @Override
createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1103     public ApiFuture<ListLocationsPage> createPageAsync(
1104         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1105         ApiFuture<ListLocationsResponse> futureResponse) {
1106       return super.createPageAsync(context, futureResponse);
1107     }
1108   }
1109 
1110   public static class ListLocationsFixedSizeCollection
1111       extends AbstractFixedSizeCollection<
1112           ListLocationsRequest,
1113           ListLocationsResponse,
1114           Location,
1115           ListLocationsPage,
1116           ListLocationsFixedSizeCollection> {
1117 
ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1118     private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
1119       super(pages, collectionSize);
1120     }
1121 
createEmptyCollection()1122     private static ListLocationsFixedSizeCollection createEmptyCollection() {
1123       return new ListLocationsFixedSizeCollection(null, 0);
1124     }
1125 
1126     @Override
createCollection( List<ListLocationsPage> pages, int collectionSize)1127     protected ListLocationsFixedSizeCollection createCollection(
1128         List<ListLocationsPage> pages, int collectionSize) {
1129       return new ListLocationsFixedSizeCollection(pages, collectionSize);
1130     }
1131   }
1132 }
1133