• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.dialogflow.cx.v3beta1;
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.cx.v3beta1.stub.PagesStub;
29 import com.google.cloud.dialogflow.cx.v3beta1.stub.PagesStubSettings;
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 [Pages][google.cloud.dialogflow.cx.v3beta1.Page].
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 (PagesClient pagesClient = PagesClient.create()) {
56  *   PageName name = PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]");
57  *   Page response = pagesClient.getPage(name);
58  * }
59  * }</pre>
60  *
61  * <p>Note: close() needs to be called on the PagesClient 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 PagesSettings to create(). For
85  * 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  * PagesSettings pagesSettings =
96  *     PagesSettings.newBuilder()
97  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
98  *         .build();
99  * PagesClient pagesClient = PagesClient.create(pagesSettings);
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  * PagesSettings pagesSettings = PagesSettings.newBuilder().setEndpoint(myEndpoint).build();
111  * PagesClient pagesClient = PagesClient.create(pagesSettings);
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  * PagesSettings pagesSettings = PagesSettings.newHttpJsonBuilder().build();
124  * PagesClient pagesClient = PagesClient.create(pagesSettings);
125  * }</pre>
126  *
127  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
128  */
129 @BetaApi
130 @Generated("by gapic-generator-java")
131 public class PagesClient implements BackgroundResource {
132   private final PagesSettings settings;
133   private final PagesStub stub;
134 
135   /** Constructs an instance of PagesClient with default settings. */
create()136   public static final PagesClient create() throws IOException {
137     return create(PagesSettings.newBuilder().build());
138   }
139 
140   /**
141    * Constructs an instance of PagesClient, using the given settings. The channels are created based
142    * on the settings passed in, or defaults for any settings that are not set.
143    */
create(PagesSettings settings)144   public static final PagesClient create(PagesSettings settings) throws IOException {
145     return new PagesClient(settings);
146   }
147 
148   /**
149    * Constructs an instance of PagesClient, using the given stub for making calls. This is for
150    * advanced usage - prefer using create(PagesSettings).
151    */
create(PagesStub stub)152   public static final PagesClient create(PagesStub stub) {
153     return new PagesClient(stub);
154   }
155 
156   /**
157    * Constructs an instance of PagesClient, using the given settings. This is protected so that it
158    * is easy to make a subclass, but otherwise, the static factory methods should be preferred.
159    */
PagesClient(PagesSettings settings)160   protected PagesClient(PagesSettings settings) throws IOException {
161     this.settings = settings;
162     this.stub = ((PagesStubSettings) settings.getStubSettings()).createStub();
163   }
164 
PagesClient(PagesStub stub)165   protected PagesClient(PagesStub stub) {
166     this.settings = null;
167     this.stub = stub;
168   }
169 
getSettings()170   public final PagesSettings getSettings() {
171     return settings;
172   }
173 
getStub()174   public PagesStub getStub() {
175     return stub;
176   }
177 
178   // AUTO-GENERATED DOCUMENTATION AND METHOD.
179   /**
180    * Returns the list of all pages in the specified flow.
181    *
182    * <p>Sample code:
183    *
184    * <pre>{@code
185    * // This snippet has been automatically generated and should be regarded as a code template only.
186    * // It will require modifications to work:
187    * // - It may require correct/in-range values for request initialization.
188    * // - It may require specifying regional endpoints when creating the service client as shown in
189    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
190    * try (PagesClient pagesClient = PagesClient.create()) {
191    *   FlowName parent = FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]");
192    *   for (Page element : pagesClient.listPages(parent).iterateAll()) {
193    *     // doThingsWith(element);
194    *   }
195    * }
196    * }</pre>
197    *
198    * @param parent Required. The flow to list all pages for. Format: `projects/&lt;Project
199    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/flows/&lt;Flow ID&gt;`.
200    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
201    */
listPages(FlowName parent)202   public final ListPagesPagedResponse listPages(FlowName parent) {
203     ListPagesRequest request =
204         ListPagesRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build();
205     return listPages(request);
206   }
207 
208   // AUTO-GENERATED DOCUMENTATION AND METHOD.
209   /**
210    * Returns the list of all pages in the specified flow.
211    *
212    * <p>Sample code:
213    *
214    * <pre>{@code
215    * // This snippet has been automatically generated and should be regarded as a code template only.
216    * // It will require modifications to work:
217    * // - It may require correct/in-range values for request initialization.
218    * // - It may require specifying regional endpoints when creating the service client as shown in
219    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
220    * try (PagesClient pagesClient = PagesClient.create()) {
221    *   String parent = FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]").toString();
222    *   for (Page element : pagesClient.listPages(parent).iterateAll()) {
223    *     // doThingsWith(element);
224    *   }
225    * }
226    * }</pre>
227    *
228    * @param parent Required. The flow to list all pages for. Format: `projects/&lt;Project
229    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/flows/&lt;Flow ID&gt;`.
230    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
231    */
listPages(String parent)232   public final ListPagesPagedResponse listPages(String parent) {
233     ListPagesRequest request = ListPagesRequest.newBuilder().setParent(parent).build();
234     return listPages(request);
235   }
236 
237   // AUTO-GENERATED DOCUMENTATION AND METHOD.
238   /**
239    * Returns the list of all pages in the specified flow.
240    *
241    * <p>Sample code:
242    *
243    * <pre>{@code
244    * // This snippet has been automatically generated and should be regarded as a code template only.
245    * // It will require modifications to work:
246    * // - It may require correct/in-range values for request initialization.
247    * // - It may require specifying regional endpoints when creating the service client as shown in
248    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
249    * try (PagesClient pagesClient = PagesClient.create()) {
250    *   ListPagesRequest request =
251    *       ListPagesRequest.newBuilder()
252    *           .setParent(FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]").toString())
253    *           .setLanguageCode("languageCode-2092349083")
254    *           .setPageSize(883849137)
255    *           .setPageToken("pageToken873572522")
256    *           .build();
257    *   for (Page element : pagesClient.listPages(request).iterateAll()) {
258    *     // doThingsWith(element);
259    *   }
260    * }
261    * }</pre>
262    *
263    * @param request The request object containing all of the parameters for the API call.
264    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
265    */
listPages(ListPagesRequest request)266   public final ListPagesPagedResponse listPages(ListPagesRequest request) {
267     return listPagesPagedCallable().call(request);
268   }
269 
270   // AUTO-GENERATED DOCUMENTATION AND METHOD.
271   /**
272    * Returns the list of all pages in the specified flow.
273    *
274    * <p>Sample code:
275    *
276    * <pre>{@code
277    * // This snippet has been automatically generated and should be regarded as a code template only.
278    * // It will require modifications to work:
279    * // - It may require correct/in-range values for request initialization.
280    * // - It may require specifying regional endpoints when creating the service client as shown in
281    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
282    * try (PagesClient pagesClient = PagesClient.create()) {
283    *   ListPagesRequest request =
284    *       ListPagesRequest.newBuilder()
285    *           .setParent(FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]").toString())
286    *           .setLanguageCode("languageCode-2092349083")
287    *           .setPageSize(883849137)
288    *           .setPageToken("pageToken873572522")
289    *           .build();
290    *   ApiFuture<Page> future = pagesClient.listPagesPagedCallable().futureCall(request);
291    *   // Do something.
292    *   for (Page element : future.get().iterateAll()) {
293    *     // doThingsWith(element);
294    *   }
295    * }
296    * }</pre>
297    */
listPagesPagedCallable()298   public final UnaryCallable<ListPagesRequest, ListPagesPagedResponse> listPagesPagedCallable() {
299     return stub.listPagesPagedCallable();
300   }
301 
302   // AUTO-GENERATED DOCUMENTATION AND METHOD.
303   /**
304    * Returns the list of all pages in the specified flow.
305    *
306    * <p>Sample code:
307    *
308    * <pre>{@code
309    * // This snippet has been automatically generated and should be regarded as a code template only.
310    * // It will require modifications to work:
311    * // - It may require correct/in-range values for request initialization.
312    * // - It may require specifying regional endpoints when creating the service client as shown in
313    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
314    * try (PagesClient pagesClient = PagesClient.create()) {
315    *   ListPagesRequest request =
316    *       ListPagesRequest.newBuilder()
317    *           .setParent(FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]").toString())
318    *           .setLanguageCode("languageCode-2092349083")
319    *           .setPageSize(883849137)
320    *           .setPageToken("pageToken873572522")
321    *           .build();
322    *   while (true) {
323    *     ListPagesResponse response = pagesClient.listPagesCallable().call(request);
324    *     for (Page element : response.getPagesList()) {
325    *       // doThingsWith(element);
326    *     }
327    *     String nextPageToken = response.getNextPageToken();
328    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
329    *       request = request.toBuilder().setPageToken(nextPageToken).build();
330    *     } else {
331    *       break;
332    *     }
333    *   }
334    * }
335    * }</pre>
336    */
listPagesCallable()337   public final UnaryCallable<ListPagesRequest, ListPagesResponse> listPagesCallable() {
338     return stub.listPagesCallable();
339   }
340 
341   // AUTO-GENERATED DOCUMENTATION AND METHOD.
342   /**
343    * Retrieves the specified page.
344    *
345    * <p>Sample code:
346    *
347    * <pre>{@code
348    * // This snippet has been automatically generated and should be regarded as a code template only.
349    * // It will require modifications to work:
350    * // - It may require correct/in-range values for request initialization.
351    * // - It may require specifying regional endpoints when creating the service client as shown in
352    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
353    * try (PagesClient pagesClient = PagesClient.create()) {
354    *   PageName name = PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]");
355    *   Page response = pagesClient.getPage(name);
356    * }
357    * }</pre>
358    *
359    * @param name Required. The name of the page. Format: `projects/&lt;Project
360    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/flows/&lt;Flow
361    *     ID&gt;/pages/&lt;Page ID&gt;`.
362    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
363    */
getPage(PageName name)364   public final Page getPage(PageName name) {
365     GetPageRequest request =
366         GetPageRequest.newBuilder().setName(name == null ? null : name.toString()).build();
367     return getPage(request);
368   }
369 
370   // AUTO-GENERATED DOCUMENTATION AND METHOD.
371   /**
372    * Retrieves the specified page.
373    *
374    * <p>Sample code:
375    *
376    * <pre>{@code
377    * // This snippet has been automatically generated and should be regarded as a code template only.
378    * // It will require modifications to work:
379    * // - It may require correct/in-range values for request initialization.
380    * // - It may require specifying regional endpoints when creating the service client as shown in
381    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
382    * try (PagesClient pagesClient = PagesClient.create()) {
383    *   String name =
384    *       PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]").toString();
385    *   Page response = pagesClient.getPage(name);
386    * }
387    * }</pre>
388    *
389    * @param name Required. The name of the page. Format: `projects/&lt;Project
390    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/flows/&lt;Flow
391    *     ID&gt;/pages/&lt;Page ID&gt;`.
392    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
393    */
getPage(String name)394   public final Page getPage(String name) {
395     GetPageRequest request = GetPageRequest.newBuilder().setName(name).build();
396     return getPage(request);
397   }
398 
399   // AUTO-GENERATED DOCUMENTATION AND METHOD.
400   /**
401    * Retrieves the specified page.
402    *
403    * <p>Sample code:
404    *
405    * <pre>{@code
406    * // This snippet has been automatically generated and should be regarded as a code template only.
407    * // It will require modifications to work:
408    * // - It may require correct/in-range values for request initialization.
409    * // - It may require specifying regional endpoints when creating the service client as shown in
410    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
411    * try (PagesClient pagesClient = PagesClient.create()) {
412    *   GetPageRequest request =
413    *       GetPageRequest.newBuilder()
414    *           .setName(
415    *               PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]").toString())
416    *           .setLanguageCode("languageCode-2092349083")
417    *           .build();
418    *   Page response = pagesClient.getPage(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    */
getPage(GetPageRequest request)425   public final Page getPage(GetPageRequest request) {
426     return getPageCallable().call(request);
427   }
428 
429   // AUTO-GENERATED DOCUMENTATION AND METHOD.
430   /**
431    * Retrieves the specified page.
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 (PagesClient pagesClient = PagesClient.create()) {
442    *   GetPageRequest request =
443    *       GetPageRequest.newBuilder()
444    *           .setName(
445    *               PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]").toString())
446    *           .setLanguageCode("languageCode-2092349083")
447    *           .build();
448    *   ApiFuture<Page> future = pagesClient.getPageCallable().futureCall(request);
449    *   // Do something.
450    *   Page response = future.get();
451    * }
452    * }</pre>
453    */
getPageCallable()454   public final UnaryCallable<GetPageRequest, Page> getPageCallable() {
455     return stub.getPageCallable();
456   }
457 
458   // AUTO-GENERATED DOCUMENTATION AND METHOD.
459   /**
460    * Creates a page in the specified flow.
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 (PagesClient pagesClient = PagesClient.create()) {
471    *   FlowName parent = FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]");
472    *   Page page = Page.newBuilder().build();
473    *   Page response = pagesClient.createPage(parent, page);
474    * }
475    * }</pre>
476    *
477    * @param parent Required. The flow to create a page for. Format: `projects/&lt;Project
478    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/flows/&lt;Flow ID&gt;`.
479    * @param page Required. The page to create.
480    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
481    */
createPage(FlowName parent, Page page)482   public final Page createPage(FlowName parent, Page page) {
483     CreatePageRequest request =
484         CreatePageRequest.newBuilder()
485             .setParent(parent == null ? null : parent.toString())
486             .setPage(page)
487             .build();
488     return createPage(request);
489   }
490 
491   // AUTO-GENERATED DOCUMENTATION AND METHOD.
492   /**
493    * Creates a page in the specified flow.
494    *
495    * <p>Sample code:
496    *
497    * <pre>{@code
498    * // This snippet has been automatically generated and should be regarded as a code template only.
499    * // It will require modifications to work:
500    * // - It may require correct/in-range values for request initialization.
501    * // - It may require specifying regional endpoints when creating the service client as shown in
502    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
503    * try (PagesClient pagesClient = PagesClient.create()) {
504    *   String parent = FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]").toString();
505    *   Page page = Page.newBuilder().build();
506    *   Page response = pagesClient.createPage(parent, page);
507    * }
508    * }</pre>
509    *
510    * @param parent Required. The flow to create a page for. Format: `projects/&lt;Project
511    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/flows/&lt;Flow ID&gt;`.
512    * @param page Required. The page to create.
513    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
514    */
createPage(String parent, Page page)515   public final Page createPage(String parent, Page page) {
516     CreatePageRequest request =
517         CreatePageRequest.newBuilder().setParent(parent).setPage(page).build();
518     return createPage(request);
519   }
520 
521   // AUTO-GENERATED DOCUMENTATION AND METHOD.
522   /**
523    * Creates a page in the specified flow.
524    *
525    * <p>Sample code:
526    *
527    * <pre>{@code
528    * // This snippet has been automatically generated and should be regarded as a code template only.
529    * // It will require modifications to work:
530    * // - It may require correct/in-range values for request initialization.
531    * // - It may require specifying regional endpoints when creating the service client as shown in
532    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
533    * try (PagesClient pagesClient = PagesClient.create()) {
534    *   CreatePageRequest request =
535    *       CreatePageRequest.newBuilder()
536    *           .setParent(FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]").toString())
537    *           .setPage(Page.newBuilder().build())
538    *           .setLanguageCode("languageCode-2092349083")
539    *           .build();
540    *   Page response = pagesClient.createPage(request);
541    * }
542    * }</pre>
543    *
544    * @param request The request object containing all of the parameters for the API call.
545    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
546    */
createPage(CreatePageRequest request)547   public final Page createPage(CreatePageRequest request) {
548     return createPageCallable().call(request);
549   }
550 
551   // AUTO-GENERATED DOCUMENTATION AND METHOD.
552   /**
553    * Creates a page in the specified flow.
554    *
555    * <p>Sample code:
556    *
557    * <pre>{@code
558    * // This snippet has been automatically generated and should be regarded as a code template only.
559    * // It will require modifications to work:
560    * // - It may require correct/in-range values for request initialization.
561    * // - It may require specifying regional endpoints when creating the service client as shown in
562    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
563    * try (PagesClient pagesClient = PagesClient.create()) {
564    *   CreatePageRequest request =
565    *       CreatePageRequest.newBuilder()
566    *           .setParent(FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]").toString())
567    *           .setPage(Page.newBuilder().build())
568    *           .setLanguageCode("languageCode-2092349083")
569    *           .build();
570    *   ApiFuture<Page> future = pagesClient.createPageCallable().futureCall(request);
571    *   // Do something.
572    *   Page response = future.get();
573    * }
574    * }</pre>
575    */
createPageCallable()576   public final UnaryCallable<CreatePageRequest, Page> createPageCallable() {
577     return stub.createPageCallable();
578   }
579 
580   // AUTO-GENERATED DOCUMENTATION AND METHOD.
581   /**
582    * Updates the specified page.
583    *
584    * <p>Sample code:
585    *
586    * <pre>{@code
587    * // This snippet has been automatically generated and should be regarded as a code template only.
588    * // It will require modifications to work:
589    * // - It may require correct/in-range values for request initialization.
590    * // - It may require specifying regional endpoints when creating the service client as shown in
591    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
592    * try (PagesClient pagesClient = PagesClient.create()) {
593    *   Page page = Page.newBuilder().build();
594    *   FieldMask updateMask = FieldMask.newBuilder().build();
595    *   Page response = pagesClient.updatePage(page, updateMask);
596    * }
597    * }</pre>
598    *
599    * @param page Required. The page to update.
600    * @param updateMask The mask to control which fields get updated. If the mask is not present, all
601    *     fields will be updated.
602    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
603    */
updatePage(Page page, FieldMask updateMask)604   public final Page updatePage(Page page, FieldMask updateMask) {
605     UpdatePageRequest request =
606         UpdatePageRequest.newBuilder().setPage(page).setUpdateMask(updateMask).build();
607     return updatePage(request);
608   }
609 
610   // AUTO-GENERATED DOCUMENTATION AND METHOD.
611   /**
612    * Updates the specified page.
613    *
614    * <p>Sample code:
615    *
616    * <pre>{@code
617    * // This snippet has been automatically generated and should be regarded as a code template only.
618    * // It will require modifications to work:
619    * // - It may require correct/in-range values for request initialization.
620    * // - It may require specifying regional endpoints when creating the service client as shown in
621    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
622    * try (PagesClient pagesClient = PagesClient.create()) {
623    *   UpdatePageRequest request =
624    *       UpdatePageRequest.newBuilder()
625    *           .setPage(Page.newBuilder().build())
626    *           .setLanguageCode("languageCode-2092349083")
627    *           .setUpdateMask(FieldMask.newBuilder().build())
628    *           .build();
629    *   Page response = pagesClient.updatePage(request);
630    * }
631    * }</pre>
632    *
633    * @param request The request object containing all of the parameters for the API call.
634    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
635    */
updatePage(UpdatePageRequest request)636   public final Page updatePage(UpdatePageRequest request) {
637     return updatePageCallable().call(request);
638   }
639 
640   // AUTO-GENERATED DOCUMENTATION AND METHOD.
641   /**
642    * Updates the specified page.
643    *
644    * <p>Sample code:
645    *
646    * <pre>{@code
647    * // This snippet has been automatically generated and should be regarded as a code template only.
648    * // It will require modifications to work:
649    * // - It may require correct/in-range values for request initialization.
650    * // - It may require specifying regional endpoints when creating the service client as shown in
651    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
652    * try (PagesClient pagesClient = PagesClient.create()) {
653    *   UpdatePageRequest request =
654    *       UpdatePageRequest.newBuilder()
655    *           .setPage(Page.newBuilder().build())
656    *           .setLanguageCode("languageCode-2092349083")
657    *           .setUpdateMask(FieldMask.newBuilder().build())
658    *           .build();
659    *   ApiFuture<Page> future = pagesClient.updatePageCallable().futureCall(request);
660    *   // Do something.
661    *   Page response = future.get();
662    * }
663    * }</pre>
664    */
updatePageCallable()665   public final UnaryCallable<UpdatePageRequest, Page> updatePageCallable() {
666     return stub.updatePageCallable();
667   }
668 
669   // AUTO-GENERATED DOCUMENTATION AND METHOD.
670   /**
671    * Deletes the specified page.
672    *
673    * <p>Sample code:
674    *
675    * <pre>{@code
676    * // This snippet has been automatically generated and should be regarded as a code template only.
677    * // It will require modifications to work:
678    * // - It may require correct/in-range values for request initialization.
679    * // - It may require specifying regional endpoints when creating the service client as shown in
680    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
681    * try (PagesClient pagesClient = PagesClient.create()) {
682    *   PageName name = PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]");
683    *   pagesClient.deletePage(name);
684    * }
685    * }</pre>
686    *
687    * @param name Required. The name of the page to delete. Format: `projects/&lt;Project
688    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/Flows/&lt;flow
689    *     ID&gt;/pages/&lt;Page ID&gt;`.
690    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
691    */
deletePage(PageName name)692   public final void deletePage(PageName name) {
693     DeletePageRequest request =
694         DeletePageRequest.newBuilder().setName(name == null ? null : name.toString()).build();
695     deletePage(request);
696   }
697 
698   // AUTO-GENERATED DOCUMENTATION AND METHOD.
699   /**
700    * Deletes the specified page.
701    *
702    * <p>Sample code:
703    *
704    * <pre>{@code
705    * // This snippet has been automatically generated and should be regarded as a code template only.
706    * // It will require modifications to work:
707    * // - It may require correct/in-range values for request initialization.
708    * // - It may require specifying regional endpoints when creating the service client as shown in
709    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
710    * try (PagesClient pagesClient = PagesClient.create()) {
711    *   String name =
712    *       PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]").toString();
713    *   pagesClient.deletePage(name);
714    * }
715    * }</pre>
716    *
717    * @param name Required. The name of the page to delete. Format: `projects/&lt;Project
718    *     ID&gt;/locations/&lt;Location ID&gt;/agents/&lt;Agent ID&gt;/Flows/&lt;flow
719    *     ID&gt;/pages/&lt;Page ID&gt;`.
720    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
721    */
deletePage(String name)722   public final void deletePage(String name) {
723     DeletePageRequest request = DeletePageRequest.newBuilder().setName(name).build();
724     deletePage(request);
725   }
726 
727   // AUTO-GENERATED DOCUMENTATION AND METHOD.
728   /**
729    * Deletes the specified page.
730    *
731    * <p>Sample code:
732    *
733    * <pre>{@code
734    * // This snippet has been automatically generated and should be regarded as a code template only.
735    * // It will require modifications to work:
736    * // - It may require correct/in-range values for request initialization.
737    * // - It may require specifying regional endpoints when creating the service client as shown in
738    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
739    * try (PagesClient pagesClient = PagesClient.create()) {
740    *   DeletePageRequest request =
741    *       DeletePageRequest.newBuilder()
742    *           .setName(
743    *               PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]").toString())
744    *           .setForce(true)
745    *           .build();
746    *   pagesClient.deletePage(request);
747    * }
748    * }</pre>
749    *
750    * @param request The request object containing all of the parameters for the API call.
751    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
752    */
deletePage(DeletePageRequest request)753   public final void deletePage(DeletePageRequest request) {
754     deletePageCallable().call(request);
755   }
756 
757   // AUTO-GENERATED DOCUMENTATION AND METHOD.
758   /**
759    * Deletes the specified page.
760    *
761    * <p>Sample code:
762    *
763    * <pre>{@code
764    * // This snippet has been automatically generated and should be regarded as a code template only.
765    * // It will require modifications to work:
766    * // - It may require correct/in-range values for request initialization.
767    * // - It may require specifying regional endpoints when creating the service client as shown in
768    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
769    * try (PagesClient pagesClient = PagesClient.create()) {
770    *   DeletePageRequest request =
771    *       DeletePageRequest.newBuilder()
772    *           .setName(
773    *               PageName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[PAGE]").toString())
774    *           .setForce(true)
775    *           .build();
776    *   ApiFuture<Empty> future = pagesClient.deletePageCallable().futureCall(request);
777    *   // Do something.
778    *   future.get();
779    * }
780    * }</pre>
781    */
deletePageCallable()782   public final UnaryCallable<DeletePageRequest, Empty> deletePageCallable() {
783     return stub.deletePageCallable();
784   }
785 
786   // AUTO-GENERATED DOCUMENTATION AND METHOD.
787   /**
788    * Lists information about the supported locations for this service.
789    *
790    * <p>Sample code:
791    *
792    * <pre>{@code
793    * // This snippet has been automatically generated and should be regarded as a code template only.
794    * // It will require modifications to work:
795    * // - It may require correct/in-range values for request initialization.
796    * // - It may require specifying regional endpoints when creating the service client as shown in
797    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
798    * try (PagesClient pagesClient = PagesClient.create()) {
799    *   ListLocationsRequest request =
800    *       ListLocationsRequest.newBuilder()
801    *           .setName("name3373707")
802    *           .setFilter("filter-1274492040")
803    *           .setPageSize(883849137)
804    *           .setPageToken("pageToken873572522")
805    *           .build();
806    *   for (Location element : pagesClient.listLocations(request).iterateAll()) {
807    *     // doThingsWith(element);
808    *   }
809    * }
810    * }</pre>
811    *
812    * @param request The request object containing all of the parameters for the API call.
813    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
814    */
listLocations(ListLocationsRequest request)815   public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
816     return listLocationsPagedCallable().call(request);
817   }
818 
819   // AUTO-GENERATED DOCUMENTATION AND METHOD.
820   /**
821    * Lists information about the supported locations for this service.
822    *
823    * <p>Sample code:
824    *
825    * <pre>{@code
826    * // This snippet has been automatically generated and should be regarded as a code template only.
827    * // It will require modifications to work:
828    * // - It may require correct/in-range values for request initialization.
829    * // - It may require specifying regional endpoints when creating the service client as shown in
830    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
831    * try (PagesClient pagesClient = PagesClient.create()) {
832    *   ListLocationsRequest request =
833    *       ListLocationsRequest.newBuilder()
834    *           .setName("name3373707")
835    *           .setFilter("filter-1274492040")
836    *           .setPageSize(883849137)
837    *           .setPageToken("pageToken873572522")
838    *           .build();
839    *   ApiFuture<Location> future = pagesClient.listLocationsPagedCallable().futureCall(request);
840    *   // Do something.
841    *   for (Location element : future.get().iterateAll()) {
842    *     // doThingsWith(element);
843    *   }
844    * }
845    * }</pre>
846    */
847   public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()848       listLocationsPagedCallable() {
849     return stub.listLocationsPagedCallable();
850   }
851 
852   // AUTO-GENERATED DOCUMENTATION AND METHOD.
853   /**
854    * Lists information about the supported locations for this service.
855    *
856    * <p>Sample code:
857    *
858    * <pre>{@code
859    * // This snippet has been automatically generated and should be regarded as a code template only.
860    * // It will require modifications to work:
861    * // - It may require correct/in-range values for request initialization.
862    * // - It may require specifying regional endpoints when creating the service client as shown in
863    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
864    * try (PagesClient pagesClient = PagesClient.create()) {
865    *   ListLocationsRequest request =
866    *       ListLocationsRequest.newBuilder()
867    *           .setName("name3373707")
868    *           .setFilter("filter-1274492040")
869    *           .setPageSize(883849137)
870    *           .setPageToken("pageToken873572522")
871    *           .build();
872    *   while (true) {
873    *     ListLocationsResponse response = pagesClient.listLocationsCallable().call(request);
874    *     for (Location element : response.getLocationsList()) {
875    *       // doThingsWith(element);
876    *     }
877    *     String nextPageToken = response.getNextPageToken();
878    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
879    *       request = request.toBuilder().setPageToken(nextPageToken).build();
880    *     } else {
881    *       break;
882    *     }
883    *   }
884    * }
885    * }</pre>
886    */
listLocationsCallable()887   public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
888     return stub.listLocationsCallable();
889   }
890 
891   // AUTO-GENERATED DOCUMENTATION AND METHOD.
892   /**
893    * Gets information about a location.
894    *
895    * <p>Sample code:
896    *
897    * <pre>{@code
898    * // This snippet has been automatically generated and should be regarded as a code template only.
899    * // It will require modifications to work:
900    * // - It may require correct/in-range values for request initialization.
901    * // - It may require specifying regional endpoints when creating the service client as shown in
902    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
903    * try (PagesClient pagesClient = PagesClient.create()) {
904    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
905    *   Location response = pagesClient.getLocation(request);
906    * }
907    * }</pre>
908    *
909    * @param request The request object containing all of the parameters for the API call.
910    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
911    */
getLocation(GetLocationRequest request)912   public final Location getLocation(GetLocationRequest request) {
913     return getLocationCallable().call(request);
914   }
915 
916   // AUTO-GENERATED DOCUMENTATION AND METHOD.
917   /**
918    * Gets information about a location.
919    *
920    * <p>Sample code:
921    *
922    * <pre>{@code
923    * // This snippet has been automatically generated and should be regarded as a code template only.
924    * // It will require modifications to work:
925    * // - It may require correct/in-range values for request initialization.
926    * // - It may require specifying regional endpoints when creating the service client as shown in
927    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
928    * try (PagesClient pagesClient = PagesClient.create()) {
929    *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
930    *   ApiFuture<Location> future = pagesClient.getLocationCallable().futureCall(request);
931    *   // Do something.
932    *   Location response = future.get();
933    * }
934    * }</pre>
935    */
getLocationCallable()936   public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
937     return stub.getLocationCallable();
938   }
939 
940   @Override
close()941   public final void close() {
942     stub.close();
943   }
944 
945   @Override
shutdown()946   public void shutdown() {
947     stub.shutdown();
948   }
949 
950   @Override
isShutdown()951   public boolean isShutdown() {
952     return stub.isShutdown();
953   }
954 
955   @Override
isTerminated()956   public boolean isTerminated() {
957     return stub.isTerminated();
958   }
959 
960   @Override
shutdownNow()961   public void shutdownNow() {
962     stub.shutdownNow();
963   }
964 
965   @Override
awaitTermination(long duration, TimeUnit unit)966   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
967     return stub.awaitTermination(duration, unit);
968   }
969 
970   public static class ListPagesPagedResponse
971       extends AbstractPagedListResponse<
972           ListPagesRequest, ListPagesResponse, Page, ListPagesPage, ListPagesFixedSizeCollection> {
973 
createAsync( PageContext<ListPagesRequest, ListPagesResponse, Page> context, ApiFuture<ListPagesResponse> futureResponse)974     public static ApiFuture<ListPagesPagedResponse> createAsync(
975         PageContext<ListPagesRequest, ListPagesResponse, Page> context,
976         ApiFuture<ListPagesResponse> futureResponse) {
977       ApiFuture<ListPagesPage> futurePage =
978           ListPagesPage.createEmptyPage().createPageAsync(context, futureResponse);
979       return ApiFutures.transform(
980           futurePage, input -> new ListPagesPagedResponse(input), MoreExecutors.directExecutor());
981     }
982 
ListPagesPagedResponse(ListPagesPage page)983     private ListPagesPagedResponse(ListPagesPage page) {
984       super(page, ListPagesFixedSizeCollection.createEmptyCollection());
985     }
986   }
987 
988   public static class ListPagesPage
989       extends AbstractPage<ListPagesRequest, ListPagesResponse, Page, ListPagesPage> {
990 
ListPagesPage( PageContext<ListPagesRequest, ListPagesResponse, Page> context, ListPagesResponse response)991     private ListPagesPage(
992         PageContext<ListPagesRequest, ListPagesResponse, Page> context,
993         ListPagesResponse response) {
994       super(context, response);
995     }
996 
createEmptyPage()997     private static ListPagesPage createEmptyPage() {
998       return new ListPagesPage(null, null);
999     }
1000 
1001     @Override
createPage( PageContext<ListPagesRequest, ListPagesResponse, Page> context, ListPagesResponse response)1002     protected ListPagesPage createPage(
1003         PageContext<ListPagesRequest, ListPagesResponse, Page> context,
1004         ListPagesResponse response) {
1005       return new ListPagesPage(context, response);
1006     }
1007 
1008     @Override
createPageAsync( PageContext<ListPagesRequest, ListPagesResponse, Page> context, ApiFuture<ListPagesResponse> futureResponse)1009     public ApiFuture<ListPagesPage> createPageAsync(
1010         PageContext<ListPagesRequest, ListPagesResponse, Page> context,
1011         ApiFuture<ListPagesResponse> futureResponse) {
1012       return super.createPageAsync(context, futureResponse);
1013     }
1014   }
1015 
1016   public static class ListPagesFixedSizeCollection
1017       extends AbstractFixedSizeCollection<
1018           ListPagesRequest, ListPagesResponse, Page, ListPagesPage, ListPagesFixedSizeCollection> {
1019 
ListPagesFixedSizeCollection(List<ListPagesPage> pages, int collectionSize)1020     private ListPagesFixedSizeCollection(List<ListPagesPage> pages, int collectionSize) {
1021       super(pages, collectionSize);
1022     }
1023 
createEmptyCollection()1024     private static ListPagesFixedSizeCollection createEmptyCollection() {
1025       return new ListPagesFixedSizeCollection(null, 0);
1026     }
1027 
1028     @Override
createCollection( List<ListPagesPage> pages, int collectionSize)1029     protected ListPagesFixedSizeCollection createCollection(
1030         List<ListPagesPage> pages, int collectionSize) {
1031       return new ListPagesFixedSizeCollection(pages, collectionSize);
1032     }
1033   }
1034 
1035   public static class ListLocationsPagedResponse
1036       extends AbstractPagedListResponse<
1037           ListLocationsRequest,
1038           ListLocationsResponse,
1039           Location,
1040           ListLocationsPage,
1041           ListLocationsFixedSizeCollection> {
1042 
createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1043     public static ApiFuture<ListLocationsPagedResponse> createAsync(
1044         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1045         ApiFuture<ListLocationsResponse> futureResponse) {
1046       ApiFuture<ListLocationsPage> futurePage =
1047           ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
1048       return ApiFutures.transform(
1049           futurePage,
1050           input -> new ListLocationsPagedResponse(input),
1051           MoreExecutors.directExecutor());
1052     }
1053 
ListLocationsPagedResponse(ListLocationsPage page)1054     private ListLocationsPagedResponse(ListLocationsPage page) {
1055       super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
1056     }
1057   }
1058 
1059   public static class ListLocationsPage
1060       extends AbstractPage<
1061           ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
1062 
ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1063     private ListLocationsPage(
1064         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1065         ListLocationsResponse response) {
1066       super(context, response);
1067     }
1068 
createEmptyPage()1069     private static ListLocationsPage createEmptyPage() {
1070       return new ListLocationsPage(null, null);
1071     }
1072 
1073     @Override
createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1074     protected ListLocationsPage createPage(
1075         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1076         ListLocationsResponse response) {
1077       return new ListLocationsPage(context, response);
1078     }
1079 
1080     @Override
createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1081     public ApiFuture<ListLocationsPage> createPageAsync(
1082         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1083         ApiFuture<ListLocationsResponse> futureResponse) {
1084       return super.createPageAsync(context, futureResponse);
1085     }
1086   }
1087 
1088   public static class ListLocationsFixedSizeCollection
1089       extends AbstractFixedSizeCollection<
1090           ListLocationsRequest,
1091           ListLocationsResponse,
1092           Location,
1093           ListLocationsPage,
1094           ListLocationsFixedSizeCollection> {
1095 
ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1096     private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
1097       super(pages, collectionSize);
1098     }
1099 
createEmptyCollection()1100     private static ListLocationsFixedSizeCollection createEmptyCollection() {
1101       return new ListLocationsFixedSizeCollection(null, 0);
1102     }
1103 
1104     @Override
createCollection( List<ListLocationsPage> pages, int collectionSize)1105     protected ListLocationsFixedSizeCollection createCollection(
1106         List<ListLocationsPage> pages, int collectionSize) {
1107       return new ListLocationsFixedSizeCollection(pages, collectionSize);
1108     }
1109   }
1110 }
1111