17
17
package com .google .cloud .functions .v1 .stub ;
18
18
19
19
import static com .google .cloud .functions .v1 .CloudFunctionsServiceClient .ListFunctionsPagedResponse ;
20
+ import static com .google .cloud .functions .v1 .CloudFunctionsServiceClient .ListLocationsPagedResponse ;
20
21
21
22
import com .google .api .core .ApiFunction ;
22
23
import com .google .api .core .ApiFuture ;
61
62
import com .google .cloud .functions .v1 .ListFunctionsResponse ;
62
63
import com .google .cloud .functions .v1 .OperationMetadataV1 ;
63
64
import com .google .cloud .functions .v1 .UpdateFunctionRequest ;
65
+ import com .google .cloud .location .ListLocationsRequest ;
66
+ import com .google .cloud .location .ListLocationsResponse ;
67
+ import com .google .cloud .location .Location ;
64
68
import com .google .common .collect .ImmutableList ;
65
69
import com .google .common .collect .ImmutableMap ;
66
70
import com .google .common .collect .ImmutableSet ;
@@ -145,6 +149,9 @@ public class CloudFunctionsServiceStubSettings
145
149
private final UnaryCallSettings <GetIamPolicyRequest , Policy > getIamPolicySettings ;
146
150
private final UnaryCallSettings <TestIamPermissionsRequest , TestIamPermissionsResponse >
147
151
testIamPermissionsSettings ;
152
+ private final PagedCallSettings <
153
+ ListLocationsRequest , ListLocationsResponse , ListLocationsPagedResponse >
154
+ listLocationsSettings ;
148
155
149
156
private static final PagedListDescriptor <
150
157
ListFunctionsRequest , ListFunctionsResponse , CloudFunction >
@@ -183,6 +190,42 @@ public Iterable<CloudFunction> extractResources(ListFunctionsResponse payload) {
183
190
}
184
191
};
185
192
193
+ private static final PagedListDescriptor <ListLocationsRequest , ListLocationsResponse , Location >
194
+ LIST_LOCATIONS_PAGE_STR_DESC =
195
+ new PagedListDescriptor <ListLocationsRequest , ListLocationsResponse , Location >() {
196
+ @ Override
197
+ public String emptyToken () {
198
+ return "" ;
199
+ }
200
+
201
+ @ Override
202
+ public ListLocationsRequest injectToken (ListLocationsRequest payload , String token ) {
203
+ return ListLocationsRequest .newBuilder (payload ).setPageToken (token ).build ();
204
+ }
205
+
206
+ @ Override
207
+ public ListLocationsRequest injectPageSize (ListLocationsRequest payload , int pageSize ) {
208
+ return ListLocationsRequest .newBuilder (payload ).setPageSize (pageSize ).build ();
209
+ }
210
+
211
+ @ Override
212
+ public Integer extractPageSize (ListLocationsRequest payload ) {
213
+ return payload .getPageSize ();
214
+ }
215
+
216
+ @ Override
217
+ public String extractNextToken (ListLocationsResponse payload ) {
218
+ return payload .getNextPageToken ();
219
+ }
220
+
221
+ @ Override
222
+ public Iterable <Location > extractResources (ListLocationsResponse payload ) {
223
+ return payload .getLocationsList () == null
224
+ ? ImmutableList .<Location >of ()
225
+ : payload .getLocationsList ();
226
+ }
227
+ };
228
+
186
229
private static final PagedListResponseFactory <
187
230
ListFunctionsRequest , ListFunctionsResponse , ListFunctionsPagedResponse >
188
231
LIST_FUNCTIONS_PAGE_STR_FACT =
@@ -200,6 +243,23 @@ public ApiFuture<ListFunctionsPagedResponse> getFuturePagedResponse(
200
243
}
201
244
};
202
245
246
+ private static final PagedListResponseFactory <
247
+ ListLocationsRequest , ListLocationsResponse , ListLocationsPagedResponse >
248
+ LIST_LOCATIONS_PAGE_STR_FACT =
249
+ new PagedListResponseFactory <
250
+ ListLocationsRequest , ListLocationsResponse , ListLocationsPagedResponse >() {
251
+ @ Override
252
+ public ApiFuture <ListLocationsPagedResponse > getFuturePagedResponse (
253
+ UnaryCallable <ListLocationsRequest , ListLocationsResponse > callable ,
254
+ ListLocationsRequest request ,
255
+ ApiCallContext context ,
256
+ ApiFuture <ListLocationsResponse > futureResponse ) {
257
+ PageContext <ListLocationsRequest , ListLocationsResponse , Location > pageContext =
258
+ PageContext .create (callable , LIST_LOCATIONS_PAGE_STR_DESC , request , context );
259
+ return ListLocationsPagedResponse .createAsync (pageContext , futureResponse );
260
+ }
261
+ };
262
+
203
263
/** Returns the object with the settings used for calls to listFunctions. */
204
264
public PagedCallSettings <ListFunctionsRequest , ListFunctionsResponse , ListFunctionsPagedResponse >
205
265
listFunctionsSettings () {
@@ -277,6 +337,12 @@ public UnaryCallSettings<GetIamPolicyRequest, Policy> getIamPolicySettings() {
277
337
return testIamPermissionsSettings ;
278
338
}
279
339
340
+ /** Returns the object with the settings used for calls to listLocations. */
341
+ public PagedCallSettings <ListLocationsRequest , ListLocationsResponse , ListLocationsPagedResponse >
342
+ listLocationsSettings () {
343
+ return listLocationsSettings ;
344
+ }
345
+
280
346
public CloudFunctionsServiceStub createStub () throws IOException {
281
347
if (getTransportChannelProvider ()
282
348
.getTransportName ()
@@ -397,6 +463,7 @@ protected CloudFunctionsServiceStubSettings(Builder settingsBuilder) throws IOEx
397
463
setIamPolicySettings = settingsBuilder .setIamPolicySettings ().build ();
398
464
getIamPolicySettings = settingsBuilder .getIamPolicySettings ().build ();
399
465
testIamPermissionsSettings = settingsBuilder .testIamPermissionsSettings ().build ();
466
+ listLocationsSettings = settingsBuilder .listLocationsSettings ().build ();
400
467
}
401
468
402
469
/** Builder for CloudFunctionsServiceStubSettings. */
@@ -431,6 +498,9 @@ public static class Builder
431
498
private final UnaryCallSettings .Builder <GetIamPolicyRequest , Policy > getIamPolicySettings ;
432
499
private final UnaryCallSettings .Builder <TestIamPermissionsRequest , TestIamPermissionsResponse >
433
500
testIamPermissionsSettings ;
501
+ private final PagedCallSettings .Builder <
502
+ ListLocationsRequest , ListLocationsResponse , ListLocationsPagedResponse >
503
+ listLocationsSettings ;
434
504
private static final ImmutableMap <String , ImmutableSet <StatusCode .Code >>
435
505
RETRYABLE_CODE_DEFINITIONS ;
436
506
@@ -498,6 +568,7 @@ protected Builder(ClientContext clientContext) {
498
568
setIamPolicySettings = UnaryCallSettings .newUnaryCallSettingsBuilder ();
499
569
getIamPolicySettings = UnaryCallSettings .newUnaryCallSettingsBuilder ();
500
570
testIamPermissionsSettings = UnaryCallSettings .newUnaryCallSettingsBuilder ();
571
+ listLocationsSettings = PagedCallSettings .newBuilder (LIST_LOCATIONS_PAGE_STR_FACT );
501
572
502
573
unaryMethodSettingsBuilders =
503
574
ImmutableList .<UnaryCallSettings .Builder <?, ?>>of (
@@ -511,7 +582,8 @@ protected Builder(ClientContext clientContext) {
511
582
generateDownloadUrlSettings ,
512
583
setIamPolicySettings ,
513
584
getIamPolicySettings ,
514
- testIamPermissionsSettings );
585
+ testIamPermissionsSettings ,
586
+ listLocationsSettings );
515
587
initDefaults (this );
516
588
}
517
589
@@ -532,6 +604,7 @@ protected Builder(CloudFunctionsServiceStubSettings settings) {
532
604
setIamPolicySettings = settings .setIamPolicySettings .toBuilder ();
533
605
getIamPolicySettings = settings .getIamPolicySettings .toBuilder ();
534
606
testIamPermissionsSettings = settings .testIamPermissionsSettings .toBuilder ();
607
+ listLocationsSettings = settings .listLocationsSettings .toBuilder ();
535
608
536
609
unaryMethodSettingsBuilders =
537
610
ImmutableList .<UnaryCallSettings .Builder <?, ?>>of (
@@ -545,7 +618,8 @@ protected Builder(CloudFunctionsServiceStubSettings settings) {
545
618
generateDownloadUrlSettings ,
546
619
setIamPolicySettings ,
547
620
getIamPolicySettings ,
548
- testIamPermissionsSettings );
621
+ testIamPermissionsSettings ,
622
+ listLocationsSettings );
549
623
}
550
624
551
625
private static Builder createDefault () {
@@ -630,6 +704,11 @@ private static Builder initDefaults(Builder builder) {
630
704
.setRetryableCodes (RETRYABLE_CODE_DEFINITIONS .get ("no_retry_codes" ))
631
705
.setRetrySettings (RETRY_PARAM_DEFINITIONS .get ("no_retry_params" ));
632
706
707
+ builder
708
+ .listLocationsSettings ()
709
+ .setRetryableCodes (RETRYABLE_CODE_DEFINITIONS .get ("no_retry_codes" ))
710
+ .setRetrySettings (RETRY_PARAM_DEFINITIONS .get ("no_retry_params" ));
711
+
633
712
builder
634
713
.createFunctionOperationSettings ()
635
714
.setInitialCallSettings (
@@ -805,6 +884,13 @@ public UnaryCallSettings.Builder<GetIamPolicyRequest, Policy> getIamPolicySettin
805
884
return testIamPermissionsSettings ;
806
885
}
807
886
887
+ /** Returns the builder for the settings used for calls to listLocations. */
888
+ public PagedCallSettings .Builder <
889
+ ListLocationsRequest , ListLocationsResponse , ListLocationsPagedResponse >
890
+ listLocationsSettings () {
891
+ return listLocationsSettings ;
892
+ }
893
+
808
894
@ Override
809
895
public CloudFunctionsServiceStubSettings build () throws IOException {
810
896
return new CloudFunctionsServiceStubSettings (this );
0 commit comments