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