1515 */ 
1616package  com .google .cloud .dialogflow .v2beta1 ;
1717
18+ import  com .google .api .core .ApiFunction ;
19+ import  com .google .api .core .ApiFuture ;
20+ import  com .google .api .core .ApiFutures ;
1821import  com .google .api .core .BetaApi ;
1922import  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 ;
2027import  com .google .api .gax .rpc .UnaryCallable ;
2128import  com .google .cloud .dialogflow .v2beta1 .stub .EnvironmentsStub ;
2229import  com .google .cloud .dialogflow .v2beta1 .stub .EnvironmentsStubSettings ;
30+ import  com .google .common .util .concurrent .MoreExecutors ;
2331import  java .io .IOException ;
32+ import  java .util .List ;
2433import  java .util .concurrent .TimeUnit ;
2534import  javax .annotation .Generated ;
2635
3443 * <pre> 
3544 * <code> 
3645 * try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { 
37-  * ListEnvironmentsRequest request = ListEnvironmentsRequest.newBuilder().build(); 
38-  * ListEnvironmentsResponse response = environmentsClient.listEnvironments(request); 
46+  * ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); 
47+  * for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) { 
48+  * // doThingsWith(element); 
49+  * } 
3950 * } 
4051 * </code> 
4152 * </pre> 
@@ -151,16 +162,73 @@ public EnvironmentsStub getStub() {
151162 * 
152163 * <pre><code> 
153164 * try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { 
154-  * ListEnvironmentsRequest request = ListEnvironmentsRequest.newBuilder().build(); 
155-  * ListEnvironmentsResponse response = environmentsClient.listEnvironments(request); 
165+  * ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); 
166+  * for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) { 
167+  * // doThingsWith(element); 
168+  * } 
169+  * } 
170+  * </code></pre> 
171+  * 
172+  * @param parent Required. The agent to list all environments from. Format: `projects/<Project 
173+  * ID>/agent`. 
174+  * @throws com.google.api.gax.rpc.ApiException if the remote call fails 
175+  */ 
176+  public  final  ListEnvironmentsPagedResponse  listEnvironments (ProjectAgentName  parent ) {
177+  ListEnvironmentsRequest  request  =
178+  ListEnvironmentsRequest .newBuilder ()
179+  .setParent (parent  == null  ? null  : parent .toString ())
180+  .build ();
181+  return  listEnvironments (request );
182+  }
183+ 
184+  // AUTO-GENERATED DOCUMENTATION AND METHOD 
185+  /** 
186+  * Returns the list of all non-draft environments of the specified agent. 
187+  * 
188+  * <p>Sample code: 
189+  * 
190+  * <pre><code> 
191+  * try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { 
192+  * ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); 
193+  * for (Environment element : environmentsClient.listEnvironments(parent.toString()).iterateAll()) { 
194+  * // doThingsWith(element); 
195+  * } 
196+  * } 
197+  * </code></pre> 
198+  * 
199+  * @param parent Required. The agent to list all environments from. Format: `projects/<Project 
200+  * ID>/agent`. 
201+  * @throws com.google.api.gax.rpc.ApiException if the remote call fails 
202+  */ 
203+  public  final  ListEnvironmentsPagedResponse  listEnvironments (String  parent ) {
204+  ListEnvironmentsRequest  request  =
205+  ListEnvironmentsRequest .newBuilder ().setParent (parent ).build ();
206+  return  listEnvironments (request );
207+  }
208+ 
209+  // AUTO-GENERATED DOCUMENTATION AND METHOD 
210+  /** 
211+  * Returns the list of all non-draft environments of the specified agent. 
212+  * 
213+  * <p>Sample code: 
214+  * 
215+  * <pre><code> 
216+  * try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { 
217+  * ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); 
218+  * ListEnvironmentsRequest request = ListEnvironmentsRequest.newBuilder() 
219+  * .setParent(parent.toString()) 
220+  * .build(); 
221+  * for (Environment element : environmentsClient.listEnvironments(request).iterateAll()) { 
222+  * // doThingsWith(element); 
223+  * } 
156224 * } 
157225 * </code></pre> 
158226 * 
159227 * @param request The request object containing all of the parameters for the API call. 
160228 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 
161229 */ 
162-  public  final  ListEnvironmentsResponse  listEnvironments (ListEnvironmentsRequest  request ) {
163-  return  listEnvironmentsCallable ().call (request );
230+  public  final  ListEnvironmentsPagedResponse  listEnvironments (ListEnvironmentsRequest  request ) {
231+  return  listEnvironmentsPagedCallable ().call (request );
164232 }
165233
166234 // AUTO-GENERATED DOCUMENTATION AND METHOD 
@@ -171,10 +239,47 @@ public final ListEnvironmentsResponse listEnvironments(ListEnvironmentsRequest r
171239 * 
172240 * <pre><code> 
173241 * try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { 
174-  * ListEnvironmentsRequest request = ListEnvironmentsRequest.newBuilder().build(); 
175-  * ApiFuture<ListEnvironmentsResponse> future = environmentsClient.listEnvironmentsCallable().futureCall(request); 
242+  * ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); 
243+  * ListEnvironmentsRequest request = ListEnvironmentsRequest.newBuilder() 
244+  * .setParent(parent.toString()) 
245+  * .build(); 
246+  * ApiFuture<ListEnvironmentsPagedResponse> future = environmentsClient.listEnvironmentsPagedCallable().futureCall(request); 
176247 * // Do something 
177-  * ListEnvironmentsResponse response = future.get(); 
248+  * for (Environment element : future.get().iterateAll()) { 
249+  * // doThingsWith(element); 
250+  * } 
251+  * } 
252+  * </code></pre> 
253+  */ 
254+  public  final  UnaryCallable <ListEnvironmentsRequest , ListEnvironmentsPagedResponse >
255+  listEnvironmentsPagedCallable () {
256+  return  stub .listEnvironmentsPagedCallable ();
257+  }
258+ 
259+  // AUTO-GENERATED DOCUMENTATION AND METHOD 
260+  /** 
261+  * Returns the list of all non-draft environments of the specified agent. 
262+  * 
263+  * <p>Sample code: 
264+  * 
265+  * <pre><code> 
266+  * try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { 
267+  * ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); 
268+  * ListEnvironmentsRequest request = ListEnvironmentsRequest.newBuilder() 
269+  * .setParent(parent.toString()) 
270+  * .build(); 
271+  * while (true) { 
272+  * ListEnvironmentsResponse response = environmentsClient.listEnvironmentsCallable().call(request); 
273+  * for (Environment element : response.getEnvironmentsList()) { 
274+  * // doThingsWith(element); 
275+  * } 
276+  * String nextPageToken = response.getNextPageToken(); 
277+  * if (!Strings.isNullOrEmpty(nextPageToken)) { 
278+  * request = request.toBuilder().setPageToken(nextPageToken).build(); 
279+  * } else { 
280+  * break; 
281+  * } 
282+  * } 
178283 * } 
179284 * </code></pre> 
180285 */ 
@@ -212,4 +317,86 @@ public void shutdownNow() {
212317 public  boolean  awaitTermination (long  duration , TimeUnit  unit ) throws  InterruptedException  {
213318 return  stub .awaitTermination (duration , unit );
214319 }
320+ 
321+  public  static  class  ListEnvironmentsPagedResponse 
322+  extends  AbstractPagedListResponse <
323+  ListEnvironmentsRequest ,
324+  ListEnvironmentsResponse ,
325+  Environment ,
326+  ListEnvironmentsPage ,
327+  ListEnvironmentsFixedSizeCollection > {
328+ 
329+  public  static  ApiFuture <ListEnvironmentsPagedResponse > createAsync (
330+  PageContext <ListEnvironmentsRequest , ListEnvironmentsResponse , Environment > context ,
331+  ApiFuture <ListEnvironmentsResponse > futureResponse ) {
332+  ApiFuture <ListEnvironmentsPage > futurePage  =
333+  ListEnvironmentsPage .createEmptyPage ().createPageAsync (context , futureResponse );
334+  return  ApiFutures .transform (
335+  futurePage ,
336+  new  ApiFunction <ListEnvironmentsPage , ListEnvironmentsPagedResponse >() {
337+  @ Override 
338+  public  ListEnvironmentsPagedResponse  apply (ListEnvironmentsPage  input ) {
339+  return  new  ListEnvironmentsPagedResponse (input );
340+  }
341+  },
342+  MoreExecutors .directExecutor ());
343+  }
344+ 
345+  private  ListEnvironmentsPagedResponse (ListEnvironmentsPage  page ) {
346+  super (page , ListEnvironmentsFixedSizeCollection .createEmptyCollection ());
347+  }
348+  }
349+ 
350+  public  static  class  ListEnvironmentsPage 
351+  extends  AbstractPage <
352+  ListEnvironmentsRequest , ListEnvironmentsResponse , Environment , ListEnvironmentsPage > {
353+ 
354+  private  ListEnvironmentsPage (
355+  PageContext <ListEnvironmentsRequest , ListEnvironmentsResponse , Environment > context ,
356+  ListEnvironmentsResponse  response ) {
357+  super (context , response );
358+  }
359+ 
360+  private  static  ListEnvironmentsPage  createEmptyPage () {
361+  return  new  ListEnvironmentsPage (null , null );
362+  }
363+ 
364+  @ Override 
365+  protected  ListEnvironmentsPage  createPage (
366+  PageContext <ListEnvironmentsRequest , ListEnvironmentsResponse , Environment > context ,
367+  ListEnvironmentsResponse  response ) {
368+  return  new  ListEnvironmentsPage (context , response );
369+  }
370+ 
371+  @ Override 
372+  public  ApiFuture <ListEnvironmentsPage > createPageAsync (
373+  PageContext <ListEnvironmentsRequest , ListEnvironmentsResponse , Environment > context ,
374+  ApiFuture <ListEnvironmentsResponse > futureResponse ) {
375+  return  super .createPageAsync (context , futureResponse );
376+  }
377+  }
378+ 
379+  public  static  class  ListEnvironmentsFixedSizeCollection 
380+  extends  AbstractFixedSizeCollection <
381+  ListEnvironmentsRequest ,
382+  ListEnvironmentsResponse ,
383+  Environment ,
384+  ListEnvironmentsPage ,
385+  ListEnvironmentsFixedSizeCollection > {
386+ 
387+  private  ListEnvironmentsFixedSizeCollection (
388+  List <ListEnvironmentsPage > pages , int  collectionSize ) {
389+  super (pages , collectionSize );
390+  }
391+ 
392+  private  static  ListEnvironmentsFixedSizeCollection  createEmptyCollection () {
393+  return  new  ListEnvironmentsFixedSizeCollection (null , 0 );
394+  }
395+ 
396+  @ Override 
397+  protected  ListEnvironmentsFixedSizeCollection  createCollection (
398+  List <ListEnvironmentsPage > pages , int  collectionSize ) {
399+  return  new  ListEnvironmentsFixedSizeCollection (pages , collectionSize );
400+  }
401+  }
215402}
0 commit comments