This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
/
OperationsClient.java
666 lines (621 loc) · 25.5 KB
/
OperationsClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
/*
* Copyright 2018 Google LLC
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google LLC nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.google.longrunning;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import com.google.api.core.ApiFunction;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.longrunning.stub.OperationsStub;
import com.google.longrunning.stub.OperationsStubSettings;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* Service Description: Manages long-running operations with an API service.
*
* <p>When an API method normally takes long time to complete, it can be designed to return
* [Operation][google.longrunning.Operation] to the client, and the client can use this interface to
* receive the real response asynchronously by polling the operation resource, or pass the operation
* resource to another API (such as Google Cloud Pub/Sub API) to receive the response. Any API
* service that returns long-running operations should implement the `Operations` interface so
* developers can have a consistent client experience.
*
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
* <pre>
* <code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* Operation response = operationsClient.getOperation(name);
* }
* </code>
* </pre>
*
* <p>Note: close() needs to be called on the operationsClient object to clean up resources such as
* threads. In the example above, try-with-resources is used, which automatically calls close().
*
* <p>The surface of this class includes several types of Java methods for each of the API's
* methods:
*
* <ol>
* <li>A "flattened" method. With this type of method, the fields of the request type have been
* converted into function parameters. It may be the case that not all fields are available as
* parameters, and not every API method will have a flattened method entry point.
* <li>A "request object" method. This type of method only takes one parameter, a request object,
* which must be constructed before the call. Not every API method will have a request object
* method.
* <li>A "callable" method. This type of method takes no parameters and returns an immutable API
* callable object, which can be used to initiate calls to the service.
* </ol>
*
* <p>See the individual methods for example code.
*
* <p>Many parameters require resource names to be formatted in a particular way. To assist with
* these names, this class includes a format method for each type of name, and additionally a parse
* method to extract the individual identifiers contained within names that are returned.
*
* <p>This class can be customized by passing in a custom instance of OperationsSettings to
* create(). For example:
*
* <p>To customize credentials:
*
* <pre>
* <code>
* OperationsSettings operationsSettings =
* OperationsSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* OperationsClient operationsClient =
* OperationsClient.create(operationsSettings);
* </code>
* </pre>
*/
public class OperationsClient implements BackgroundResource {
private final OperationsSettings settings;
private final OperationsStub stub;
/**
* Constructs an instance of OperationsClient, using the given settings. The channels are created
* based on the settings passed in, or defaults for any settings that are not set.
*/
public static final OperationsClient create(OperationsSettings settings) throws IOException {
return new OperationsClient(settings);
}
/**
* Constructs an instance of OperationsClient, using the given stub for making calls. This is for
* advanced usage - prefer to use OperationsSettings}.
*/
public static final OperationsClient create(OperationsStub stub) {
return new OperationsClient(stub);
}
/**
* Constructs an instance of OperationsClient, using the given settings. This is protected so that
* it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
*/
protected OperationsClient(OperationsSettings settings) throws IOException {
this.settings = settings;
this.stub = ((OperationsStubSettings) settings.getStubSettings()).createStub();
}
protected OperationsClient(OperationsStub stub) {
this.settings = null;
this.stub = stub;
}
public final OperationsSettings getSettings() {
return settings;
}
public OperationsStub getStub() {
return stub;
}
/**
* Gets the latest state of a long-running operation. Clients can use this method to poll the
* operation result at intervals as recommended by the API service.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* Operation response = operationsClient.getOperation(name);
* }
* </code></pre>
*
* @param name The name of the operation resource.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation getOperation(String name) {
GetOperationRequest request = GetOperationRequest.newBuilder().setName(name).build();
return getOperation(request);
}
/**
* Gets the latest state of a long-running operation. Clients can use this method to poll the
* operation result at intervals as recommended by the API service.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* GetOperationRequest request = GetOperationRequest.newBuilder()
* .setName(name)
* .build();
* Operation response = operationsClient.getOperation(request);
* }
* </code></pre>
*
* @param request the request object containing all of the parameters for the API call
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
private final Operation getOperation(GetOperationRequest request) {
return getOperationCallable().call(request);
}
/**
* Gets the latest state of a long-running operation. Clients can use this method to poll the
* operation result at intervals as recommended by the API service.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* GetOperationRequest request = GetOperationRequest.newBuilder()
* .setName(name)
* .build();
* ApiFuture<Operation> future = operationsClient.getOperationCallable().futureCall(request);
* // Do something
* Operation response = future.get();
* }
* </code></pre>
*/
public final UnaryCallable<GetOperationRequest, Operation> getOperationCallable() {
return stub.getOperationCallable();
}
/**
* Lists operations that match the specified filter in the request. If the server doesn't support
* this method, it returns `UNIMPLEMENTED`.
*
* <p>NOTE: the `name` binding below allows API services to override the binding to use different
* resource name schemes, such as `users/*/operations`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* String filter = "";
* for (Operation element : operationsClient.listOperations(name, filter).iterateAll()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*
* @param name The name of the operation collection.
* @param filter The standard list filter.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListOperationsPagedResponse listOperations(String name, String filter) {
ListOperationsRequest request =
ListOperationsRequest.newBuilder().setName(name).setFilter(filter).build();
return listOperations(request);
}
/**
* Lists operations that match the specified filter in the request. If the server doesn't support
* this method, it returns `UNIMPLEMENTED`.
*
* <p>NOTE: the `name` binding below allows API services to override the binding to use different
* resource name schemes, such as `users/*/operations`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* String filter = "";
* ListOperationsRequest request = ListOperationsRequest.newBuilder()
* .setName(name)
* .setFilter(filter)
* .build();
* for (Operation element : operationsClient.listOperations(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListOperationsPagedResponse listOperations(ListOperationsRequest request) {
return listOperationsPagedCallable().call(request);
}
/**
* Lists operations that match the specified filter in the request. If the server doesn't support
* this method, it returns `UNIMPLEMENTED`.
*
* <p>NOTE: the `name` binding below allows API services to override the binding to use different
* resource name schemes, such as `users/*/operations`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* String filter = "";
* ListOperationsRequest request = ListOperationsRequest.newBuilder()
* .setName(name)
* .setFilter(filter)
* .build();
* ApiFuture<ListOperationsPagedResponse> future = operationsClient.listOperationsPagedCallable().futureCall(request);
* // Do something
* for (Operation element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*/
public final UnaryCallable<ListOperationsRequest, ListOperationsPagedResponse>
listOperationsPagedCallable() {
return stub.listOperationsPagedCallable();
}
/**
* Lists operations that match the specified filter in the request. If the server doesn't support
* this method, it returns `UNIMPLEMENTED`.
*
* <p>NOTE: the `name` binding below allows API services to override the binding to use different
* resource name schemes, such as `users/*/operations`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* String filter = "";
* ListOperationsRequest request = ListOperationsRequest.newBuilder()
* .setName(name)
* .setFilter(filter)
* .build();
* while (true) {
* ListOperationsResponse response = operationsClient.listOperationsCallable().call(request);
* for (Operation element : response.getOperationsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* </code></pre>
*/
public final UnaryCallable<ListOperationsRequest, ListOperationsResponse>
listOperationsCallable() {
return stub.listOperationsCallable();
}
/**
* Starts asynchronous cancellation on a long-running operation. The server makes a best effort to
* cancel the operation, but success is not guaranteed. If the server doesn't support this method,
* it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use
* [Operations.GetOperation][google.longrunning.Operations.GetOperation] or other methods to check
* whether the cancellation succeeded or whether the operation completed despite cancellation. On
* successful cancellation, the operation is not deleted; instead, it becomes an operation with an
* [Operation.error][google.longrunning.Operation.error] value with a
* [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* operationsClient.cancelOperation(name);
* }
* </code></pre>
*
* @param name The name of the operation resource to be cancelled.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void cancelOperation(String name) {
CancelOperationRequest request = CancelOperationRequest.newBuilder().setName(name).build();
cancelOperation(request);
}
/**
* Starts asynchronous cancellation on a long-running operation. The server makes a best effort to
* cancel the operation, but success is not guaranteed. If the server doesn't support this method,
* it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use
* [Operations.GetOperation][google.longrunning.Operations.GetOperation] or other methods to check
* whether the cancellation succeeded or whether the operation completed despite cancellation. On
* successful cancellation, the operation is not deleted; instead, it becomes an operation with an
* [Operation.error][google.longrunning.Operation.error] value with a
* [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* CancelOperationRequest request = CancelOperationRequest.newBuilder()
* .setName(name)
* .build();
* operationsClient.cancelOperation(request);
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
private final void cancelOperation(CancelOperationRequest request) {
cancelOperationCallable().call(request);
}
/**
* Starts asynchronous cancellation on a long-running operation. The server makes a best effort to
* cancel the operation, but success is not guaranteed. If the server doesn't support this method,
* it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use
* [Operations.GetOperation][google.longrunning.Operations.GetOperation] or other methods to check
* whether the cancellation succeeded or whether the operation completed despite cancellation. On
* successful cancellation, the operation is not deleted; instead, it becomes an operation with an
* [Operation.error][google.longrunning.Operation.error] value with a
* [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* CancelOperationRequest request = CancelOperationRequest.newBuilder()
* .setName(name)
* .build();
* ApiFuture<Void> future = operationsClient.cancelOperationCallable().futureCall(request);
* // Do something
* future.get();
* }
* </code></pre>
*/
public final UnaryCallable<CancelOperationRequest, Empty> cancelOperationCallable() {
return stub.cancelOperationCallable();
}
/**
* Deletes a long-running operation. This method indicates that the client is no longer interested
* in the operation result. It does not cancel the operation. If the server doesn't support this
* method, it returns `google.rpc.Code.UNIMPLEMENTED`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* operationsClient.deleteOperation(name);
* }
* </code></pre>
*
* @param name The name of the operation resource to be deleted.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteOperation(String name) {
DeleteOperationRequest request = DeleteOperationRequest.newBuilder().setName(name).build();
deleteOperation(request);
}
/**
* Deletes a long-running operation. This method indicates that the client is no longer interested
* in the operation result. It does not cancel the operation. If the server doesn't support this
* method, it returns `google.rpc.Code.UNIMPLEMENTED`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* DeleteOperationRequest request = DeleteOperationRequest.newBuilder()
* .setName(name)
* .build();
* operationsClient.deleteOperation(request);
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
private final void deleteOperation(DeleteOperationRequest request) {
deleteOperationCallable().call(request);
}
/**
* Deletes a long-running operation. This method indicates that the client is no longer interested
* in the operation result. It does not cancel the operation. If the server doesn't support this
* method, it returns `google.rpc.Code.UNIMPLEMENTED`.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* DeleteOperationRequest request = DeleteOperationRequest.newBuilder()
* .setName(name)
* .build();
* ApiFuture<Void> future = operationsClient.deleteOperationCallable().futureCall(request);
* // Do something
* future.get();
* }
* </code></pre>
*/
public final UnaryCallable<DeleteOperationRequest, Empty> deleteOperationCallable() {
return stub.deleteOperationCallable();
}
/**
* Waits until the specified long-running operation is done or reaches at most a specified
* timeout, returning the latest state. If the operation is already done, the latest state is
* immediately returned. If the timeout specified is greater than the default HTTP/RPC timeout,
* the HTTP/RPC timeout is used. If the server does not support this method, it returns
* `google.rpc.Code.UNIMPLEMENTED`. Note that this method is on a best-effort basis. It may return
* the latest state before the specified timeout (including immediately), meaning even an
* immediate response is no guarantee that the operation is done.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* WaitOperationRequest request = WaitOperationRequest.newBuilder()
* .setName(name)
* .setTimeout(Duration.ofMillis(100))
* .build();
* Operation response = operationsClient.waitOperation(request);
* }
* </code></pre>
*
* @param request the request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation waitOperation(WaitOperationRequest request) {
return waitOperationCallable().call(request);
}
/**
* Waits until the specified long-running operation is done or reaches at most a specified
* timeout, returning the latest state. If the operation is already done, the latest state is
* immediately returned. If the timeout specified is greater than the default HTTP/RPC timeout,
* the HTTP/RPC timeout is used. If the server does not support this method, it returns
* `google.rpc.Code.UNIMPLEMENTED`. Note that this method is on a best-effort basis. It may return
* the latest state before the specified timeout (including immediately), meaning even an
* immediate response is no guarantee that the operation is done.
*
* <p>Sample code:
*
* <pre><code>
* try (OperationsClient operationsClient = OperationsClient.create()) {
* String name = "";
* WaitOperationRequest request = WaitOperationRequest.newBuilder()
* .setName(name)
* .setTimeout(Duration.ofMillis(100))
* .build();
* ApiFuture<Operation> future = operationsClient.waitOperationCallable().futureCall(request);
* }
* </code></pre>
*/
public final UnaryCallable<WaitOperationRequest, Operation> waitOperationCallable() {
return stub.waitOperationCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class ListOperationsPagedResponse
extends AbstractPagedListResponse<
ListOperationsRequest,
ListOperationsResponse,
Operation,
ListOperationsPage,
ListOperationsFixedSizeCollection> {
public static ApiFuture<ListOperationsPagedResponse> createAsync(
PageContext<ListOperationsRequest, ListOperationsResponse, Operation> context,
ApiFuture<ListOperationsResponse> futureResponse) {
ApiFuture<ListOperationsPage> futurePage =
ListOperationsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
new ApiFunction<ListOperationsPage, ListOperationsPagedResponse>() {
@Override
public ListOperationsPagedResponse apply(ListOperationsPage input) {
return new ListOperationsPagedResponse(input);
}
},
directExecutor());
}
private ListOperationsPagedResponse(ListOperationsPage page) {
super(page, ListOperationsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListOperationsPage
extends AbstractPage<
ListOperationsRequest, ListOperationsResponse, Operation, ListOperationsPage> {
private ListOperationsPage(
PageContext<ListOperationsRequest, ListOperationsResponse, Operation> context,
ListOperationsResponse response) {
super(context, response);
}
private static ListOperationsPage createEmptyPage() {
return new ListOperationsPage(null, null);
}
@Override
protected ListOperationsPage createPage(
PageContext<ListOperationsRequest, ListOperationsResponse, Operation> context,
ListOperationsResponse response) {
return new ListOperationsPage(context, response);
}
@Override
public ApiFuture<ListOperationsPage> createPageAsync(
PageContext<ListOperationsRequest, ListOperationsResponse, Operation> context,
ApiFuture<ListOperationsResponse> futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListOperationsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListOperationsRequest,
ListOperationsResponse,
Operation,
ListOperationsPage,
ListOperationsFixedSizeCollection> {
private ListOperationsFixedSizeCollection(List<ListOperationsPage> pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListOperationsFixedSizeCollection createEmptyCollection() {
return new ListOperationsFixedSizeCollection(null, 0);
}
@Override
protected ListOperationsFixedSizeCollection createCollection(
List<ListOperationsPage> pages, int collectionSize) {
return new ListOperationsFixedSizeCollection(pages, collectionSize);
}
}
}