• 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.functions.v1;
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.httpjson.longrunning.OperationsClient;
24 import com.google.api.gax.longrunning.OperationFuture;
25 import com.google.api.gax.paging.AbstractFixedSizeCollection;
26 import com.google.api.gax.paging.AbstractPage;
27 import com.google.api.gax.paging.AbstractPagedListResponse;
28 import com.google.api.gax.rpc.OperationCallable;
29 import com.google.api.gax.rpc.PageContext;
30 import com.google.api.gax.rpc.UnaryCallable;
31 import com.google.cloud.functions.v1.stub.CloudFunctionsServiceStub;
32 import com.google.cloud.functions.v1.stub.CloudFunctionsServiceStubSettings;
33 import com.google.cloud.location.ListLocationsRequest;
34 import com.google.cloud.location.ListLocationsResponse;
35 import com.google.cloud.location.Location;
36 import com.google.common.util.concurrent.MoreExecutors;
37 import com.google.iam.v1.GetIamPolicyRequest;
38 import com.google.iam.v1.Policy;
39 import com.google.iam.v1.SetIamPolicyRequest;
40 import com.google.iam.v1.TestIamPermissionsRequest;
41 import com.google.iam.v1.TestIamPermissionsResponse;
42 import com.google.longrunning.Operation;
43 import com.google.protobuf.Empty;
44 import java.io.IOException;
45 import java.util.List;
46 import java.util.concurrent.TimeUnit;
47 import javax.annotation.Generated;
48 
49 // AUTO-GENERATED DOCUMENTATION AND CLASS.
50 /**
51  * Service Description: A service that application uses to manipulate triggers and functions.
52  *
53  * <p>This class provides the ability to make remote calls to the backing service through method
54  * calls that map to API methods. Sample code to get started:
55  *
56  * <pre>{@code
57  * // This snippet has been automatically generated and should be regarded as a code template only.
58  * // It will require modifications to work:
59  * // - It may require correct/in-range values for request initialization.
60  * // - It may require specifying regional endpoints when creating the service client as shown in
61  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
62  * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
63  *     CloudFunctionsServiceClient.create()) {
64  *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
65  *   CloudFunction response = cloudFunctionsServiceClient.getFunction(name);
66  * }
67  * }</pre>
68  *
69  * <p>Note: close() needs to be called on the CloudFunctionsServiceClient object to clean up
70  * resources such as threads. In the example above, try-with-resources is used, which automatically
71  * calls close().
72  *
73  * <p>The surface of this class includes several types of Java methods for each of the API's
74  * methods:
75  *
76  * <ol>
77  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
78  *       converted into function parameters. It may be the case that not all fields are available as
79  *       parameters, and not every API method will have a flattened method entry point.
80  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
81  *       which must be constructed before the call. Not every API method will have a request object
82  *       method.
83  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
84  *       callable object, which can be used to initiate calls to the service.
85  * </ol>
86  *
87  * <p>See the individual methods for example code.
88  *
89  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
90  * these names, this class includes a format method for each type of name, and additionally a parse
91  * method to extract the individual identifiers contained within names that are returned.
92  *
93  * <p>This class can be customized by passing in a custom instance of CloudFunctionsServiceSettings
94  * to create(). For example:
95  *
96  * <p>To customize credentials:
97  *
98  * <pre>{@code
99  * // This snippet has been automatically generated and should be regarded as a code template only.
100  * // It will require modifications to work:
101  * // - It may require correct/in-range values for request initialization.
102  * // - It may require specifying regional endpoints when creating the service client as shown in
103  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
104  * CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
105  *     CloudFunctionsServiceSettings.newBuilder()
106  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
107  *         .build();
108  * CloudFunctionsServiceClient cloudFunctionsServiceClient =
109  *     CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
110  * }</pre>
111  *
112  * <p>To customize the endpoint:
113  *
114  * <pre>{@code
115  * // This snippet has been automatically generated and should be regarded as a code template only.
116  * // It will require modifications to work:
117  * // - It may require correct/in-range values for request initialization.
118  * // - It may require specifying regional endpoints when creating the service client as shown in
119  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
120  * CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
121  *     CloudFunctionsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
122  * CloudFunctionsServiceClient cloudFunctionsServiceClient =
123  *     CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
124  * }</pre>
125  *
126  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
127  * the wire:
128  *
129  * <pre>{@code
130  * // This snippet has been automatically generated and should be regarded as a code template only.
131  * // It will require modifications to work:
132  * // - It may require correct/in-range values for request initialization.
133  * // - It may require specifying regional endpoints when creating the service client as shown in
134  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
135  * CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
136  *     CloudFunctionsServiceSettings.newHttpJsonBuilder().build();
137  * CloudFunctionsServiceClient cloudFunctionsServiceClient =
138  *     CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
139  * }</pre>
140  *
141  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
142  */
143 @Generated("by gapic-generator-java")
144 public class CloudFunctionsServiceClient implements BackgroundResource {
145   private final CloudFunctionsServiceSettings settings;
146   private final CloudFunctionsServiceStub stub;
147   private final OperationsClient httpJsonOperationsClient;
148   private final com.google.longrunning.OperationsClient operationsClient;
149 
150   /** Constructs an instance of CloudFunctionsServiceClient with default settings. */
create()151   public static final CloudFunctionsServiceClient create() throws IOException {
152     return create(CloudFunctionsServiceSettings.newBuilder().build());
153   }
154 
155   /**
156    * Constructs an instance of CloudFunctionsServiceClient, using the given settings. The channels
157    * are created based on the settings passed in, or defaults for any settings that are not set.
158    */
create(CloudFunctionsServiceSettings settings)159   public static final CloudFunctionsServiceClient create(CloudFunctionsServiceSettings settings)
160       throws IOException {
161     return new CloudFunctionsServiceClient(settings);
162   }
163 
164   /**
165    * Constructs an instance of CloudFunctionsServiceClient, using the given stub for making calls.
166    * This is for advanced usage - prefer using create(CloudFunctionsServiceSettings).
167    */
create(CloudFunctionsServiceStub stub)168   public static final CloudFunctionsServiceClient create(CloudFunctionsServiceStub stub) {
169     return new CloudFunctionsServiceClient(stub);
170   }
171 
172   /**
173    * Constructs an instance of CloudFunctionsServiceClient, using the given settings. This is
174    * protected so that it is easy to make a subclass, but otherwise, the static factory methods
175    * should be preferred.
176    */
CloudFunctionsServiceClient(CloudFunctionsServiceSettings settings)177   protected CloudFunctionsServiceClient(CloudFunctionsServiceSettings settings) throws IOException {
178     this.settings = settings;
179     this.stub = ((CloudFunctionsServiceStubSettings) settings.getStubSettings()).createStub();
180     this.operationsClient =
181         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
182     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
183   }
184 
CloudFunctionsServiceClient(CloudFunctionsServiceStub stub)185   protected CloudFunctionsServiceClient(CloudFunctionsServiceStub stub) {
186     this.settings = null;
187     this.stub = stub;
188     this.operationsClient =
189         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
190     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
191   }
192 
getSettings()193   public final CloudFunctionsServiceSettings getSettings() {
194     return settings;
195   }
196 
getStub()197   public CloudFunctionsServiceStub getStub() {
198     return stub;
199   }
200 
201   /**
202    * Returns the OperationsClient that can be used to query the status of a long-running operation
203    * returned by another API method call.
204    */
getOperationsClient()205   public final com.google.longrunning.OperationsClient getOperationsClient() {
206     return operationsClient;
207   }
208 
209   /**
210    * Returns the OperationsClient that can be used to query the status of a long-running operation
211    * returned by another API method call.
212    */
213   @BetaApi
getHttpJsonOperationsClient()214   public final OperationsClient getHttpJsonOperationsClient() {
215     return httpJsonOperationsClient;
216   }
217 
218   // AUTO-GENERATED DOCUMENTATION AND METHOD.
219   /**
220    * Returns a list of functions that belong to the requested project.
221    *
222    * <p>Sample code:
223    *
224    * <pre>{@code
225    * // This snippet has been automatically generated and should be regarded as a code template only.
226    * // It will require modifications to work:
227    * // - It may require correct/in-range values for request initialization.
228    * // - It may require specifying regional endpoints when creating the service client as shown in
229    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
230    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
231    *     CloudFunctionsServiceClient.create()) {
232    *   ListFunctionsRequest request =
233    *       ListFunctionsRequest.newBuilder()
234    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
235    *           .setPageSize(883849137)
236    *           .setPageToken("pageToken873572522")
237    *           .build();
238    *   for (CloudFunction element :
239    *       cloudFunctionsServiceClient.listFunctions(request).iterateAll()) {
240    *     // doThingsWith(element);
241    *   }
242    * }
243    * }</pre>
244    *
245    * @param request The request object containing all of the parameters for the API call.
246    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
247    */
listFunctions(ListFunctionsRequest request)248   public final ListFunctionsPagedResponse listFunctions(ListFunctionsRequest request) {
249     return listFunctionsPagedCallable().call(request);
250   }
251 
252   // AUTO-GENERATED DOCUMENTATION AND METHOD.
253   /**
254    * Returns a list of functions that belong to the requested project.
255    *
256    * <p>Sample code:
257    *
258    * <pre>{@code
259    * // This snippet has been automatically generated and should be regarded as a code template only.
260    * // It will require modifications to work:
261    * // - It may require correct/in-range values for request initialization.
262    * // - It may require specifying regional endpoints when creating the service client as shown in
263    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
264    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
265    *     CloudFunctionsServiceClient.create()) {
266    *   ListFunctionsRequest request =
267    *       ListFunctionsRequest.newBuilder()
268    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
269    *           .setPageSize(883849137)
270    *           .setPageToken("pageToken873572522")
271    *           .build();
272    *   ApiFuture<CloudFunction> future =
273    *       cloudFunctionsServiceClient.listFunctionsPagedCallable().futureCall(request);
274    *   // Do something.
275    *   for (CloudFunction element : future.get().iterateAll()) {
276    *     // doThingsWith(element);
277    *   }
278    * }
279    * }</pre>
280    */
281   public final UnaryCallable<ListFunctionsRequest, ListFunctionsPagedResponse>
listFunctionsPagedCallable()282       listFunctionsPagedCallable() {
283     return stub.listFunctionsPagedCallable();
284   }
285 
286   // AUTO-GENERATED DOCUMENTATION AND METHOD.
287   /**
288    * Returns a list of functions that belong to the requested project.
289    *
290    * <p>Sample code:
291    *
292    * <pre>{@code
293    * // This snippet has been automatically generated and should be regarded as a code template only.
294    * // It will require modifications to work:
295    * // - It may require correct/in-range values for request initialization.
296    * // - It may require specifying regional endpoints when creating the service client as shown in
297    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
298    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
299    *     CloudFunctionsServiceClient.create()) {
300    *   ListFunctionsRequest request =
301    *       ListFunctionsRequest.newBuilder()
302    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
303    *           .setPageSize(883849137)
304    *           .setPageToken("pageToken873572522")
305    *           .build();
306    *   while (true) {
307    *     ListFunctionsResponse response =
308    *         cloudFunctionsServiceClient.listFunctionsCallable().call(request);
309    *     for (CloudFunction element : response.getFunctionsList()) {
310    *       // doThingsWith(element);
311    *     }
312    *     String nextPageToken = response.getNextPageToken();
313    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
314    *       request = request.toBuilder().setPageToken(nextPageToken).build();
315    *     } else {
316    *       break;
317    *     }
318    *   }
319    * }
320    * }</pre>
321    */
listFunctionsCallable()322   public final UnaryCallable<ListFunctionsRequest, ListFunctionsResponse> listFunctionsCallable() {
323     return stub.listFunctionsCallable();
324   }
325 
326   // AUTO-GENERATED DOCUMENTATION AND METHOD.
327   /**
328    * Returns a function with the given name from the requested project.
329    *
330    * <p>Sample code:
331    *
332    * <pre>{@code
333    * // This snippet has been automatically generated and should be regarded as a code template only.
334    * // It will require modifications to work:
335    * // - It may require correct/in-range values for request initialization.
336    * // - It may require specifying regional endpoints when creating the service client as shown in
337    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
338    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
339    *     CloudFunctionsServiceClient.create()) {
340    *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
341    *   CloudFunction response = cloudFunctionsServiceClient.getFunction(name);
342    * }
343    * }</pre>
344    *
345    * @param name Required. The name of the function which details should be obtained.
346    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
347    */
getFunction(CloudFunctionName name)348   public final CloudFunction getFunction(CloudFunctionName name) {
349     GetFunctionRequest request =
350         GetFunctionRequest.newBuilder().setName(name == null ? null : name.toString()).build();
351     return getFunction(request);
352   }
353 
354   // AUTO-GENERATED DOCUMENTATION AND METHOD.
355   /**
356    * Returns a function with the given name from the requested project.
357    *
358    * <p>Sample code:
359    *
360    * <pre>{@code
361    * // This snippet has been automatically generated and should be regarded as a code template only.
362    * // It will require modifications to work:
363    * // - It may require correct/in-range values for request initialization.
364    * // - It may require specifying regional endpoints when creating the service client as shown in
365    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
366    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
367    *     CloudFunctionsServiceClient.create()) {
368    *   String name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString();
369    *   CloudFunction response = cloudFunctionsServiceClient.getFunction(name);
370    * }
371    * }</pre>
372    *
373    * @param name Required. The name of the function which details should be obtained.
374    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
375    */
getFunction(String name)376   public final CloudFunction getFunction(String name) {
377     GetFunctionRequest request = GetFunctionRequest.newBuilder().setName(name).build();
378     return getFunction(request);
379   }
380 
381   // AUTO-GENERATED DOCUMENTATION AND METHOD.
382   /**
383    * Returns a function with the given name from the requested project.
384    *
385    * <p>Sample code:
386    *
387    * <pre>{@code
388    * // This snippet has been automatically generated and should be regarded as a code template only.
389    * // It will require modifications to work:
390    * // - It may require correct/in-range values for request initialization.
391    * // - It may require specifying regional endpoints when creating the service client as shown in
392    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
393    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
394    *     CloudFunctionsServiceClient.create()) {
395    *   GetFunctionRequest request =
396    *       GetFunctionRequest.newBuilder()
397    *           .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
398    *           .build();
399    *   CloudFunction response = cloudFunctionsServiceClient.getFunction(request);
400    * }
401    * }</pre>
402    *
403    * @param request The request object containing all of the parameters for the API call.
404    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
405    */
getFunction(GetFunctionRequest request)406   public final CloudFunction getFunction(GetFunctionRequest request) {
407     return getFunctionCallable().call(request);
408   }
409 
410   // AUTO-GENERATED DOCUMENTATION AND METHOD.
411   /**
412    * Returns a function with the given name from the requested project.
413    *
414    * <p>Sample code:
415    *
416    * <pre>{@code
417    * // This snippet has been automatically generated and should be regarded as a code template only.
418    * // It will require modifications to work:
419    * // - It may require correct/in-range values for request initialization.
420    * // - It may require specifying regional endpoints when creating the service client as shown in
421    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
422    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
423    *     CloudFunctionsServiceClient.create()) {
424    *   GetFunctionRequest request =
425    *       GetFunctionRequest.newBuilder()
426    *           .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
427    *           .build();
428    *   ApiFuture<CloudFunction> future =
429    *       cloudFunctionsServiceClient.getFunctionCallable().futureCall(request);
430    *   // Do something.
431    *   CloudFunction response = future.get();
432    * }
433    * }</pre>
434    */
getFunctionCallable()435   public final UnaryCallable<GetFunctionRequest, CloudFunction> getFunctionCallable() {
436     return stub.getFunctionCallable();
437   }
438 
439   // AUTO-GENERATED DOCUMENTATION AND METHOD.
440   /**
441    * Creates a new function. If a function with the given name already exists in the specified
442    * project, the long running operation returns an `ALREADY_EXISTS` error.
443    *
444    * <p>Sample code:
445    *
446    * <pre>{@code
447    * // This snippet has been automatically generated and should be regarded as a code template only.
448    * // It will require modifications to work:
449    * // - It may require correct/in-range values for request initialization.
450    * // - It may require specifying regional endpoints when creating the service client as shown in
451    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
452    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
453    *     CloudFunctionsServiceClient.create()) {
454    *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
455    *   CloudFunction function = CloudFunction.newBuilder().build();
456    *   CloudFunction response =
457    *       cloudFunctionsServiceClient.createFunctionAsync(location, function).get();
458    * }
459    * }</pre>
460    *
461    * @param location Required. The project and location in which the function should be created,
462    *     specified in the format `projects/&#42;/locations/&#42;`
463    * @param function Required. Function to be created.
464    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
465    */
createFunctionAsync( LocationName location, CloudFunction function)466   public final OperationFuture<CloudFunction, OperationMetadataV1> createFunctionAsync(
467       LocationName location, CloudFunction function) {
468     CreateFunctionRequest request =
469         CreateFunctionRequest.newBuilder()
470             .setLocation(location == null ? null : location.toString())
471             .setFunction(function)
472             .build();
473     return createFunctionAsync(request);
474   }
475 
476   // AUTO-GENERATED DOCUMENTATION AND METHOD.
477   /**
478    * Creates a new function. If a function with the given name already exists in the specified
479    * project, the long running operation returns an `ALREADY_EXISTS` error.
480    *
481    * <p>Sample code:
482    *
483    * <pre>{@code
484    * // This snippet has been automatically generated and should be regarded as a code template only.
485    * // It will require modifications to work:
486    * // - It may require correct/in-range values for request initialization.
487    * // - It may require specifying regional endpoints when creating the service client as shown in
488    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
489    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
490    *     CloudFunctionsServiceClient.create()) {
491    *   String location = LocationName.of("[PROJECT]", "[LOCATION]").toString();
492    *   CloudFunction function = CloudFunction.newBuilder().build();
493    *   CloudFunction response =
494    *       cloudFunctionsServiceClient.createFunctionAsync(location, function).get();
495    * }
496    * }</pre>
497    *
498    * @param location Required. The project and location in which the function should be created,
499    *     specified in the format `projects/&#42;/locations/&#42;`
500    * @param function Required. Function to be created.
501    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
502    */
createFunctionAsync( String location, CloudFunction function)503   public final OperationFuture<CloudFunction, OperationMetadataV1> createFunctionAsync(
504       String location, CloudFunction function) {
505     CreateFunctionRequest request =
506         CreateFunctionRequest.newBuilder().setLocation(location).setFunction(function).build();
507     return createFunctionAsync(request);
508   }
509 
510   // AUTO-GENERATED DOCUMENTATION AND METHOD.
511   /**
512    * Creates a new function. If a function with the given name already exists in the specified
513    * project, the long running operation returns an `ALREADY_EXISTS` error.
514    *
515    * <p>Sample code:
516    *
517    * <pre>{@code
518    * // This snippet has been automatically generated and should be regarded as a code template only.
519    * // It will require modifications to work:
520    * // - It may require correct/in-range values for request initialization.
521    * // - It may require specifying regional endpoints when creating the service client as shown in
522    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
523    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
524    *     CloudFunctionsServiceClient.create()) {
525    *   CreateFunctionRequest request =
526    *       CreateFunctionRequest.newBuilder()
527    *           .setLocation(LocationName.of("[PROJECT]", "[LOCATION]").toString())
528    *           .setFunction(CloudFunction.newBuilder().build())
529    *           .build();
530    *   CloudFunction response = cloudFunctionsServiceClient.createFunctionAsync(request).get();
531    * }
532    * }</pre>
533    *
534    * @param request The request object containing all of the parameters for the API call.
535    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
536    */
createFunctionAsync( CreateFunctionRequest request)537   public final OperationFuture<CloudFunction, OperationMetadataV1> createFunctionAsync(
538       CreateFunctionRequest request) {
539     return createFunctionOperationCallable().futureCall(request);
540   }
541 
542   // AUTO-GENERATED DOCUMENTATION AND METHOD.
543   /**
544    * Creates a new function. If a function with the given name already exists in the specified
545    * project, the long running operation returns an `ALREADY_EXISTS` error.
546    *
547    * <p>Sample code:
548    *
549    * <pre>{@code
550    * // This snippet has been automatically generated and should be regarded as a code template only.
551    * // It will require modifications to work:
552    * // - It may require correct/in-range values for request initialization.
553    * // - It may require specifying regional endpoints when creating the service client as shown in
554    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
555    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
556    *     CloudFunctionsServiceClient.create()) {
557    *   CreateFunctionRequest request =
558    *       CreateFunctionRequest.newBuilder()
559    *           .setLocation(LocationName.of("[PROJECT]", "[LOCATION]").toString())
560    *           .setFunction(CloudFunction.newBuilder().build())
561    *           .build();
562    *   OperationFuture<CloudFunction, OperationMetadataV1> future =
563    *       cloudFunctionsServiceClient.createFunctionOperationCallable().futureCall(request);
564    *   // Do something.
565    *   CloudFunction response = future.get();
566    * }
567    * }</pre>
568    */
569   public final OperationCallable<CreateFunctionRequest, CloudFunction, OperationMetadataV1>
createFunctionOperationCallable()570       createFunctionOperationCallable() {
571     return stub.createFunctionOperationCallable();
572   }
573 
574   // AUTO-GENERATED DOCUMENTATION AND METHOD.
575   /**
576    * Creates a new function. If a function with the given name already exists in the specified
577    * project, the long running operation returns an `ALREADY_EXISTS` error.
578    *
579    * <p>Sample code:
580    *
581    * <pre>{@code
582    * // This snippet has been automatically generated and should be regarded as a code template only.
583    * // It will require modifications to work:
584    * // - It may require correct/in-range values for request initialization.
585    * // - It may require specifying regional endpoints when creating the service client as shown in
586    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
587    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
588    *     CloudFunctionsServiceClient.create()) {
589    *   CreateFunctionRequest request =
590    *       CreateFunctionRequest.newBuilder()
591    *           .setLocation(LocationName.of("[PROJECT]", "[LOCATION]").toString())
592    *           .setFunction(CloudFunction.newBuilder().build())
593    *           .build();
594    *   ApiFuture<Operation> future =
595    *       cloudFunctionsServiceClient.createFunctionCallable().futureCall(request);
596    *   // Do something.
597    *   Operation response = future.get();
598    * }
599    * }</pre>
600    */
createFunctionCallable()601   public final UnaryCallable<CreateFunctionRequest, Operation> createFunctionCallable() {
602     return stub.createFunctionCallable();
603   }
604 
605   // AUTO-GENERATED DOCUMENTATION AND METHOD.
606   /**
607    * Updates existing function.
608    *
609    * <p>Sample code:
610    *
611    * <pre>{@code
612    * // This snippet has been automatically generated and should be regarded as a code template only.
613    * // It will require modifications to work:
614    * // - It may require correct/in-range values for request initialization.
615    * // - It may require specifying regional endpoints when creating the service client as shown in
616    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
617    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
618    *     CloudFunctionsServiceClient.create()) {
619    *   CloudFunction function = CloudFunction.newBuilder().build();
620    *   CloudFunction response = cloudFunctionsServiceClient.updateFunctionAsync(function).get();
621    * }
622    * }</pre>
623    *
624    * @param function Required. New version of the function.
625    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
626    */
updateFunctionAsync( CloudFunction function)627   public final OperationFuture<CloudFunction, OperationMetadataV1> updateFunctionAsync(
628       CloudFunction function) {
629     UpdateFunctionRequest request =
630         UpdateFunctionRequest.newBuilder().setFunction(function).build();
631     return updateFunctionAsync(request);
632   }
633 
634   // AUTO-GENERATED DOCUMENTATION AND METHOD.
635   /**
636    * Updates existing function.
637    *
638    * <p>Sample code:
639    *
640    * <pre>{@code
641    * // This snippet has been automatically generated and should be regarded as a code template only.
642    * // It will require modifications to work:
643    * // - It may require correct/in-range values for request initialization.
644    * // - It may require specifying regional endpoints when creating the service client as shown in
645    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
646    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
647    *     CloudFunctionsServiceClient.create()) {
648    *   UpdateFunctionRequest request =
649    *       UpdateFunctionRequest.newBuilder()
650    *           .setFunction(CloudFunction.newBuilder().build())
651    *           .setUpdateMask(FieldMask.newBuilder().build())
652    *           .build();
653    *   CloudFunction response = cloudFunctionsServiceClient.updateFunctionAsync(request).get();
654    * }
655    * }</pre>
656    *
657    * @param request The request object containing all of the parameters for the API call.
658    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
659    */
updateFunctionAsync( UpdateFunctionRequest request)660   public final OperationFuture<CloudFunction, OperationMetadataV1> updateFunctionAsync(
661       UpdateFunctionRequest request) {
662     return updateFunctionOperationCallable().futureCall(request);
663   }
664 
665   // AUTO-GENERATED DOCUMENTATION AND METHOD.
666   /**
667    * Updates existing function.
668    *
669    * <p>Sample code:
670    *
671    * <pre>{@code
672    * // This snippet has been automatically generated and should be regarded as a code template only.
673    * // It will require modifications to work:
674    * // - It may require correct/in-range values for request initialization.
675    * // - It may require specifying regional endpoints when creating the service client as shown in
676    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
677    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
678    *     CloudFunctionsServiceClient.create()) {
679    *   UpdateFunctionRequest request =
680    *       UpdateFunctionRequest.newBuilder()
681    *           .setFunction(CloudFunction.newBuilder().build())
682    *           .setUpdateMask(FieldMask.newBuilder().build())
683    *           .build();
684    *   OperationFuture<CloudFunction, OperationMetadataV1> future =
685    *       cloudFunctionsServiceClient.updateFunctionOperationCallable().futureCall(request);
686    *   // Do something.
687    *   CloudFunction response = future.get();
688    * }
689    * }</pre>
690    */
691   public final OperationCallable<UpdateFunctionRequest, CloudFunction, OperationMetadataV1>
updateFunctionOperationCallable()692       updateFunctionOperationCallable() {
693     return stub.updateFunctionOperationCallable();
694   }
695 
696   // AUTO-GENERATED DOCUMENTATION AND METHOD.
697   /**
698    * Updates existing function.
699    *
700    * <p>Sample code:
701    *
702    * <pre>{@code
703    * // This snippet has been automatically generated and should be regarded as a code template only.
704    * // It will require modifications to work:
705    * // - It may require correct/in-range values for request initialization.
706    * // - It may require specifying regional endpoints when creating the service client as shown in
707    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
708    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
709    *     CloudFunctionsServiceClient.create()) {
710    *   UpdateFunctionRequest request =
711    *       UpdateFunctionRequest.newBuilder()
712    *           .setFunction(CloudFunction.newBuilder().build())
713    *           .setUpdateMask(FieldMask.newBuilder().build())
714    *           .build();
715    *   ApiFuture<Operation> future =
716    *       cloudFunctionsServiceClient.updateFunctionCallable().futureCall(request);
717    *   // Do something.
718    *   Operation response = future.get();
719    * }
720    * }</pre>
721    */
updateFunctionCallable()722   public final UnaryCallable<UpdateFunctionRequest, Operation> updateFunctionCallable() {
723     return stub.updateFunctionCallable();
724   }
725 
726   // AUTO-GENERATED DOCUMENTATION AND METHOD.
727   /**
728    * Deletes a function with the given name from the specified project. If the given function is
729    * used by some trigger, the trigger is updated to remove this function.
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 (CloudFunctionsServiceClient cloudFunctionsServiceClient =
740    *     CloudFunctionsServiceClient.create()) {
741    *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
742    *   cloudFunctionsServiceClient.deleteFunctionAsync(name).get();
743    * }
744    * }</pre>
745    *
746    * @param name Required. The name of the function which should be deleted.
747    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
748    */
deleteFunctionAsync( CloudFunctionName name)749   public final OperationFuture<Empty, OperationMetadataV1> deleteFunctionAsync(
750       CloudFunctionName name) {
751     DeleteFunctionRequest request =
752         DeleteFunctionRequest.newBuilder().setName(name == null ? null : name.toString()).build();
753     return deleteFunctionAsync(request);
754   }
755 
756   // AUTO-GENERATED DOCUMENTATION AND METHOD.
757   /**
758    * Deletes a function with the given name from the specified project. If the given function is
759    * used by some trigger, the trigger is updated to remove this function.
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 (CloudFunctionsServiceClient cloudFunctionsServiceClient =
770    *     CloudFunctionsServiceClient.create()) {
771    *   String name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString();
772    *   cloudFunctionsServiceClient.deleteFunctionAsync(name).get();
773    * }
774    * }</pre>
775    *
776    * @param name Required. The name of the function which should be deleted.
777    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
778    */
deleteFunctionAsync(String name)779   public final OperationFuture<Empty, OperationMetadataV1> deleteFunctionAsync(String name) {
780     DeleteFunctionRequest request = DeleteFunctionRequest.newBuilder().setName(name).build();
781     return deleteFunctionAsync(request);
782   }
783 
784   // AUTO-GENERATED DOCUMENTATION AND METHOD.
785   /**
786    * Deletes a function with the given name from the specified project. If the given function is
787    * used by some trigger, the trigger is updated to remove this function.
788    *
789    * <p>Sample code:
790    *
791    * <pre>{@code
792    * // This snippet has been automatically generated and should be regarded as a code template only.
793    * // It will require modifications to work:
794    * // - It may require correct/in-range values for request initialization.
795    * // - It may require specifying regional endpoints when creating the service client as shown in
796    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
797    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
798    *     CloudFunctionsServiceClient.create()) {
799    *   DeleteFunctionRequest request =
800    *       DeleteFunctionRequest.newBuilder()
801    *           .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
802    *           .build();
803    *   cloudFunctionsServiceClient.deleteFunctionAsync(request).get();
804    * }
805    * }</pre>
806    *
807    * @param request The request object containing all of the parameters for the API call.
808    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
809    */
deleteFunctionAsync( DeleteFunctionRequest request)810   public final OperationFuture<Empty, OperationMetadataV1> deleteFunctionAsync(
811       DeleteFunctionRequest request) {
812     return deleteFunctionOperationCallable().futureCall(request);
813   }
814 
815   // AUTO-GENERATED DOCUMENTATION AND METHOD.
816   /**
817    * Deletes a function with the given name from the specified project. If the given function is
818    * used by some trigger, the trigger is updated to remove this function.
819    *
820    * <p>Sample code:
821    *
822    * <pre>{@code
823    * // This snippet has been automatically generated and should be regarded as a code template only.
824    * // It will require modifications to work:
825    * // - It may require correct/in-range values for request initialization.
826    * // - It may require specifying regional endpoints when creating the service client as shown in
827    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
828    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
829    *     CloudFunctionsServiceClient.create()) {
830    *   DeleteFunctionRequest request =
831    *       DeleteFunctionRequest.newBuilder()
832    *           .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
833    *           .build();
834    *   OperationFuture<Empty, OperationMetadataV1> future =
835    *       cloudFunctionsServiceClient.deleteFunctionOperationCallable().futureCall(request);
836    *   // Do something.
837    *   future.get();
838    * }
839    * }</pre>
840    */
841   public final OperationCallable<DeleteFunctionRequest, Empty, OperationMetadataV1>
deleteFunctionOperationCallable()842       deleteFunctionOperationCallable() {
843     return stub.deleteFunctionOperationCallable();
844   }
845 
846   // AUTO-GENERATED DOCUMENTATION AND METHOD.
847   /**
848    * Deletes a function with the given name from the specified project. If the given function is
849    * used by some trigger, the trigger is updated to remove this function.
850    *
851    * <p>Sample code:
852    *
853    * <pre>{@code
854    * // This snippet has been automatically generated and should be regarded as a code template only.
855    * // It will require modifications to work:
856    * // - It may require correct/in-range values for request initialization.
857    * // - It may require specifying regional endpoints when creating the service client as shown in
858    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
859    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
860    *     CloudFunctionsServiceClient.create()) {
861    *   DeleteFunctionRequest request =
862    *       DeleteFunctionRequest.newBuilder()
863    *           .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
864    *           .build();
865    *   ApiFuture<Operation> future =
866    *       cloudFunctionsServiceClient.deleteFunctionCallable().futureCall(request);
867    *   // Do something.
868    *   future.get();
869    * }
870    * }</pre>
871    */
deleteFunctionCallable()872   public final UnaryCallable<DeleteFunctionRequest, Operation> deleteFunctionCallable() {
873     return stub.deleteFunctionCallable();
874   }
875 
876   // AUTO-GENERATED DOCUMENTATION AND METHOD.
877   /**
878    * Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very
879    * limited traffic is allowed. For more information on the actual limits, refer to [Rate
880    * Limits](https://cloud.google.com/functions/quotas#rate_limits).
881    *
882    * <p>Sample code:
883    *
884    * <pre>{@code
885    * // This snippet has been automatically generated and should be regarded as a code template only.
886    * // It will require modifications to work:
887    * // - It may require correct/in-range values for request initialization.
888    * // - It may require specifying regional endpoints when creating the service client as shown in
889    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
890    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
891    *     CloudFunctionsServiceClient.create()) {
892    *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
893    *   String data = "data3076010";
894    *   CallFunctionResponse response = cloudFunctionsServiceClient.callFunction(name, data);
895    * }
896    * }</pre>
897    *
898    * @param name Required. The name of the function to be called.
899    * @param data Required. Input to be passed to the function.
900    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
901    */
callFunction(CloudFunctionName name, String data)902   public final CallFunctionResponse callFunction(CloudFunctionName name, String data) {
903     CallFunctionRequest request =
904         CallFunctionRequest.newBuilder()
905             .setName(name == null ? null : name.toString())
906             .setData(data)
907             .build();
908     return callFunction(request);
909   }
910 
911   // AUTO-GENERATED DOCUMENTATION AND METHOD.
912   /**
913    * Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very
914    * limited traffic is allowed. For more information on the actual limits, refer to [Rate
915    * Limits](https://cloud.google.com/functions/quotas#rate_limits).
916    *
917    * <p>Sample code:
918    *
919    * <pre>{@code
920    * // This snippet has been automatically generated and should be regarded as a code template only.
921    * // It will require modifications to work:
922    * // - It may require correct/in-range values for request initialization.
923    * // - It may require specifying regional endpoints when creating the service client as shown in
924    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
925    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
926    *     CloudFunctionsServiceClient.create()) {
927    *   String name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString();
928    *   String data = "data3076010";
929    *   CallFunctionResponse response = cloudFunctionsServiceClient.callFunction(name, data);
930    * }
931    * }</pre>
932    *
933    * @param name Required. The name of the function to be called.
934    * @param data Required. Input to be passed to the function.
935    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
936    */
callFunction(String name, String data)937   public final CallFunctionResponse callFunction(String name, String data) {
938     CallFunctionRequest request =
939         CallFunctionRequest.newBuilder().setName(name).setData(data).build();
940     return callFunction(request);
941   }
942 
943   // AUTO-GENERATED DOCUMENTATION AND METHOD.
944   /**
945    * Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very
946    * limited traffic is allowed. For more information on the actual limits, refer to [Rate
947    * Limits](https://cloud.google.com/functions/quotas#rate_limits).
948    *
949    * <p>Sample code:
950    *
951    * <pre>{@code
952    * // This snippet has been automatically generated and should be regarded as a code template only.
953    * // It will require modifications to work:
954    * // - It may require correct/in-range values for request initialization.
955    * // - It may require specifying regional endpoints when creating the service client as shown in
956    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
957    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
958    *     CloudFunctionsServiceClient.create()) {
959    *   CallFunctionRequest request =
960    *       CallFunctionRequest.newBuilder()
961    *           .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
962    *           .setData("data3076010")
963    *           .build();
964    *   CallFunctionResponse response = cloudFunctionsServiceClient.callFunction(request);
965    * }
966    * }</pre>
967    *
968    * @param request The request object containing all of the parameters for the API call.
969    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
970    */
callFunction(CallFunctionRequest request)971   public final CallFunctionResponse callFunction(CallFunctionRequest request) {
972     return callFunctionCallable().call(request);
973   }
974 
975   // AUTO-GENERATED DOCUMENTATION AND METHOD.
976   /**
977    * Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very
978    * limited traffic is allowed. For more information on the actual limits, refer to [Rate
979    * Limits](https://cloud.google.com/functions/quotas#rate_limits).
980    *
981    * <p>Sample code:
982    *
983    * <pre>{@code
984    * // This snippet has been automatically generated and should be regarded as a code template only.
985    * // It will require modifications to work:
986    * // - It may require correct/in-range values for request initialization.
987    * // - It may require specifying regional endpoints when creating the service client as shown in
988    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
989    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
990    *     CloudFunctionsServiceClient.create()) {
991    *   CallFunctionRequest request =
992    *       CallFunctionRequest.newBuilder()
993    *           .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
994    *           .setData("data3076010")
995    *           .build();
996    *   ApiFuture<CallFunctionResponse> future =
997    *       cloudFunctionsServiceClient.callFunctionCallable().futureCall(request);
998    *   // Do something.
999    *   CallFunctionResponse response = future.get();
1000    * }
1001    * }</pre>
1002    */
callFunctionCallable()1003   public final UnaryCallable<CallFunctionRequest, CallFunctionResponse> callFunctionCallable() {
1004     return stub.callFunctionCallable();
1005   }
1006 
1007   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1008   /**
1009    * Returns a signed URL for uploading a function source code. For more information about the
1010    * signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once
1011    * the function source code upload is complete, the used signed URL should be provided in
1012    * CreateFunction or UpdateFunction request as a reference to the function source code.
1013    *
1014    * <p>When uploading source code to the generated signed URL, please follow these restrictions:
1015    *
1016    * <ul>
1017    *   <li>Source file type should be a zip file.
1018    *   <li>Source file size should not exceed 100MB limit.
1019    *   <li>No credentials should be attached - the signed URLs provide access to the target bucket
1020    *       using internal service identity; if credentials were attached, the identity from the
1021    *       credentials would be used, but that identity does not have permissions to upload files to
1022    *       the URL.
1023    * </ul>
1024    *
1025    * <p>When making an HTTP PUT request, these two headers must be specified:
1026    *
1027    * <ul>
1028    *   <li>`content-type: application/zip`
1029    *   <li>`x-goog-content-length-range: 0,104857600`
1030    * </ul>
1031    *
1032    * <p>And this header must NOT be specified:
1033    *
1034    * <ul>
1035    *   <li>`Authorization: Bearer YOUR_TOKEN`
1036    * </ul>
1037    *
1038    * <p>Sample code:
1039    *
1040    * <pre>{@code
1041    * // This snippet has been automatically generated and should be regarded as a code template only.
1042    * // It will require modifications to work:
1043    * // - It may require correct/in-range values for request initialization.
1044    * // - It may require specifying regional endpoints when creating the service client as shown in
1045    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1046    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1047    *     CloudFunctionsServiceClient.create()) {
1048    *   GenerateUploadUrlRequest request =
1049    *       GenerateUploadUrlRequest.newBuilder()
1050    *           .setParent("parent-995424086")
1051    *           .setKmsKeyName(
1052    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1053    *                   .toString())
1054    *           .build();
1055    *   GenerateUploadUrlResponse response = cloudFunctionsServiceClient.generateUploadUrl(request);
1056    * }
1057    * }</pre>
1058    *
1059    * @param request The request object containing all of the parameters for the API call.
1060    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1061    */
generateUploadUrl(GenerateUploadUrlRequest request)1062   public final GenerateUploadUrlResponse generateUploadUrl(GenerateUploadUrlRequest request) {
1063     return generateUploadUrlCallable().call(request);
1064   }
1065 
1066   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1067   /**
1068    * Returns a signed URL for uploading a function source code. For more information about the
1069    * signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once
1070    * the function source code upload is complete, the used signed URL should be provided in
1071    * CreateFunction or UpdateFunction request as a reference to the function source code.
1072    *
1073    * <p>When uploading source code to the generated signed URL, please follow these restrictions:
1074    *
1075    * <ul>
1076    *   <li>Source file type should be a zip file.
1077    *   <li>Source file size should not exceed 100MB limit.
1078    *   <li>No credentials should be attached - the signed URLs provide access to the target bucket
1079    *       using internal service identity; if credentials were attached, the identity from the
1080    *       credentials would be used, but that identity does not have permissions to upload files to
1081    *       the URL.
1082    * </ul>
1083    *
1084    * <p>When making an HTTP PUT request, these two headers must be specified:
1085    *
1086    * <ul>
1087    *   <li>`content-type: application/zip`
1088    *   <li>`x-goog-content-length-range: 0,104857600`
1089    * </ul>
1090    *
1091    * <p>And this header must NOT be specified:
1092    *
1093    * <ul>
1094    *   <li>`Authorization: Bearer YOUR_TOKEN`
1095    * </ul>
1096    *
1097    * <p>Sample code:
1098    *
1099    * <pre>{@code
1100    * // This snippet has been automatically generated and should be regarded as a code template only.
1101    * // It will require modifications to work:
1102    * // - It may require correct/in-range values for request initialization.
1103    * // - It may require specifying regional endpoints when creating the service client as shown in
1104    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1105    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1106    *     CloudFunctionsServiceClient.create()) {
1107    *   GenerateUploadUrlRequest request =
1108    *       GenerateUploadUrlRequest.newBuilder()
1109    *           .setParent("parent-995424086")
1110    *           .setKmsKeyName(
1111    *               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1112    *                   .toString())
1113    *           .build();
1114    *   ApiFuture<GenerateUploadUrlResponse> future =
1115    *       cloudFunctionsServiceClient.generateUploadUrlCallable().futureCall(request);
1116    *   // Do something.
1117    *   GenerateUploadUrlResponse response = future.get();
1118    * }
1119    * }</pre>
1120    */
1121   public final UnaryCallable<GenerateUploadUrlRequest, GenerateUploadUrlResponse>
generateUploadUrlCallable()1122       generateUploadUrlCallable() {
1123     return stub.generateUploadUrlCallable();
1124   }
1125 
1126   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1127   /**
1128    * Returns a signed URL for downloading deployed function source code. The URL is only valid for a
1129    * limited period and must be used within minutes after generation. For more information about the
1130    * signed URL usage, see: https://cloud.google.com/storage/docs/access-control/signed-urls
1131    *
1132    * <p>Sample code:
1133    *
1134    * <pre>{@code
1135    * // This snippet has been automatically generated and should be regarded as a code template only.
1136    * // It will require modifications to work:
1137    * // - It may require correct/in-range values for request initialization.
1138    * // - It may require specifying regional endpoints when creating the service client as shown in
1139    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1140    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1141    *     CloudFunctionsServiceClient.create()) {
1142    *   GenerateDownloadUrlRequest request =
1143    *       GenerateDownloadUrlRequest.newBuilder()
1144    *           .setName("name3373707")
1145    *           .setVersionId(-670497310)
1146    *           .build();
1147    *   GenerateDownloadUrlResponse response =
1148    *       cloudFunctionsServiceClient.generateDownloadUrl(request);
1149    * }
1150    * }</pre>
1151    *
1152    * @param request The request object containing all of the parameters for the API call.
1153    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1154    */
generateDownloadUrl(GenerateDownloadUrlRequest request)1155   public final GenerateDownloadUrlResponse generateDownloadUrl(GenerateDownloadUrlRequest request) {
1156     return generateDownloadUrlCallable().call(request);
1157   }
1158 
1159   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1160   /**
1161    * Returns a signed URL for downloading deployed function source code. The URL is only valid for a
1162    * limited period and must be used within minutes after generation. For more information about the
1163    * signed URL usage, see: https://cloud.google.com/storage/docs/access-control/signed-urls
1164    *
1165    * <p>Sample code:
1166    *
1167    * <pre>{@code
1168    * // This snippet has been automatically generated and should be regarded as a code template only.
1169    * // It will require modifications to work:
1170    * // - It may require correct/in-range values for request initialization.
1171    * // - It may require specifying regional endpoints when creating the service client as shown in
1172    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1173    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1174    *     CloudFunctionsServiceClient.create()) {
1175    *   GenerateDownloadUrlRequest request =
1176    *       GenerateDownloadUrlRequest.newBuilder()
1177    *           .setName("name3373707")
1178    *           .setVersionId(-670497310)
1179    *           .build();
1180    *   ApiFuture<GenerateDownloadUrlResponse> future =
1181    *       cloudFunctionsServiceClient.generateDownloadUrlCallable().futureCall(request);
1182    *   // Do something.
1183    *   GenerateDownloadUrlResponse response = future.get();
1184    * }
1185    * }</pre>
1186    */
1187   public final UnaryCallable<GenerateDownloadUrlRequest, GenerateDownloadUrlResponse>
generateDownloadUrlCallable()1188       generateDownloadUrlCallable() {
1189     return stub.generateDownloadUrlCallable();
1190   }
1191 
1192   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1193   /**
1194    * Sets the IAM access control policy on the specified function. Replaces any existing policy.
1195    *
1196    * <p>Sample code:
1197    *
1198    * <pre>{@code
1199    * // This snippet has been automatically generated and should be regarded as a code template only.
1200    * // It will require modifications to work:
1201    * // - It may require correct/in-range values for request initialization.
1202    * // - It may require specifying regional endpoints when creating the service client as shown in
1203    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1204    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1205    *     CloudFunctionsServiceClient.create()) {
1206    *   SetIamPolicyRequest request =
1207    *       SetIamPolicyRequest.newBuilder()
1208    *           .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
1209    *           .setPolicy(Policy.newBuilder().build())
1210    *           .setUpdateMask(FieldMask.newBuilder().build())
1211    *           .build();
1212    *   Policy response = cloudFunctionsServiceClient.setIamPolicy(request);
1213    * }
1214    * }</pre>
1215    *
1216    * @param request The request object containing all of the parameters for the API call.
1217    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1218    */
setIamPolicy(SetIamPolicyRequest request)1219   public final Policy setIamPolicy(SetIamPolicyRequest request) {
1220     return setIamPolicyCallable().call(request);
1221   }
1222 
1223   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1224   /**
1225    * Sets the IAM access control policy on the specified function. Replaces any existing policy.
1226    *
1227    * <p>Sample code:
1228    *
1229    * <pre>{@code
1230    * // This snippet has been automatically generated and should be regarded as a code template only.
1231    * // It will require modifications to work:
1232    * // - It may require correct/in-range values for request initialization.
1233    * // - It may require specifying regional endpoints when creating the service client as shown in
1234    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1235    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1236    *     CloudFunctionsServiceClient.create()) {
1237    *   SetIamPolicyRequest request =
1238    *       SetIamPolicyRequest.newBuilder()
1239    *           .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
1240    *           .setPolicy(Policy.newBuilder().build())
1241    *           .setUpdateMask(FieldMask.newBuilder().build())
1242    *           .build();
1243    *   ApiFuture<Policy> future =
1244    *       cloudFunctionsServiceClient.setIamPolicyCallable().futureCall(request);
1245    *   // Do something.
1246    *   Policy response = future.get();
1247    * }
1248    * }</pre>
1249    */
setIamPolicyCallable()1250   public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
1251     return stub.setIamPolicyCallable();
1252   }
1253 
1254   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1255   /**
1256    * Gets the IAM access control policy for a function. Returns an empty policy if the function
1257    * exists and does not have a policy set.
1258    *
1259    * <p>Sample code:
1260    *
1261    * <pre>{@code
1262    * // This snippet has been automatically generated and should be regarded as a code template only.
1263    * // It will require modifications to work:
1264    * // - It may require correct/in-range values for request initialization.
1265    * // - It may require specifying regional endpoints when creating the service client as shown in
1266    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1267    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1268    *     CloudFunctionsServiceClient.create()) {
1269    *   GetIamPolicyRequest request =
1270    *       GetIamPolicyRequest.newBuilder()
1271    *           .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
1272    *           .setOptions(GetPolicyOptions.newBuilder().build())
1273    *           .build();
1274    *   Policy response = cloudFunctionsServiceClient.getIamPolicy(request);
1275    * }
1276    * }</pre>
1277    *
1278    * @param request The request object containing all of the parameters for the API call.
1279    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1280    */
getIamPolicy(GetIamPolicyRequest request)1281   public final Policy getIamPolicy(GetIamPolicyRequest request) {
1282     return getIamPolicyCallable().call(request);
1283   }
1284 
1285   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1286   /**
1287    * Gets the IAM access control policy for a function. Returns an empty policy if the function
1288    * exists and does not have a policy set.
1289    *
1290    * <p>Sample code:
1291    *
1292    * <pre>{@code
1293    * // This snippet has been automatically generated and should be regarded as a code template only.
1294    * // It will require modifications to work:
1295    * // - It may require correct/in-range values for request initialization.
1296    * // - It may require specifying regional endpoints when creating the service client as shown in
1297    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1298    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1299    *     CloudFunctionsServiceClient.create()) {
1300    *   GetIamPolicyRequest request =
1301    *       GetIamPolicyRequest.newBuilder()
1302    *           .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
1303    *           .setOptions(GetPolicyOptions.newBuilder().build())
1304    *           .build();
1305    *   ApiFuture<Policy> future =
1306    *       cloudFunctionsServiceClient.getIamPolicyCallable().futureCall(request);
1307    *   // Do something.
1308    *   Policy response = future.get();
1309    * }
1310    * }</pre>
1311    */
getIamPolicyCallable()1312   public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
1313     return stub.getIamPolicyCallable();
1314   }
1315 
1316   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1317   /**
1318    * Tests the specified permissions against the IAM access control policy for a function. If the
1319    * function does not exist, this returns an empty set of permissions, not a NOT_FOUND error.
1320    *
1321    * <p>Sample code:
1322    *
1323    * <pre>{@code
1324    * // This snippet has been automatically generated and should be regarded as a code template only.
1325    * // It will require modifications to work:
1326    * // - It may require correct/in-range values for request initialization.
1327    * // - It may require specifying regional endpoints when creating the service client as shown in
1328    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1329    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1330    *     CloudFunctionsServiceClient.create()) {
1331    *   TestIamPermissionsRequest request =
1332    *       TestIamPermissionsRequest.newBuilder()
1333    *           .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
1334    *           .addAllPermissions(new ArrayList<String>())
1335    *           .build();
1336    *   TestIamPermissionsResponse response = cloudFunctionsServiceClient.testIamPermissions(request);
1337    * }
1338    * }</pre>
1339    *
1340    * @param request The request object containing all of the parameters for the API call.
1341    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1342    */
testIamPermissions(TestIamPermissionsRequest request)1343   public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) {
1344     return testIamPermissionsCallable().call(request);
1345   }
1346 
1347   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1348   /**
1349    * Tests the specified permissions against the IAM access control policy for a function. If the
1350    * function does not exist, this returns an empty set of permissions, not a NOT_FOUND error.
1351    *
1352    * <p>Sample code:
1353    *
1354    * <pre>{@code
1355    * // This snippet has been automatically generated and should be regarded as a code template only.
1356    * // It will require modifications to work:
1357    * // - It may require correct/in-range values for request initialization.
1358    * // - It may require specifying regional endpoints when creating the service client as shown in
1359    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1360    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1361    *     CloudFunctionsServiceClient.create()) {
1362    *   TestIamPermissionsRequest request =
1363    *       TestIamPermissionsRequest.newBuilder()
1364    *           .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
1365    *           .addAllPermissions(new ArrayList<String>())
1366    *           .build();
1367    *   ApiFuture<TestIamPermissionsResponse> future =
1368    *       cloudFunctionsServiceClient.testIamPermissionsCallable().futureCall(request);
1369    *   // Do something.
1370    *   TestIamPermissionsResponse response = future.get();
1371    * }
1372    * }</pre>
1373    */
1374   public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable()1375       testIamPermissionsCallable() {
1376     return stub.testIamPermissionsCallable();
1377   }
1378 
1379   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1380   /**
1381    * Lists information about the supported locations for this service.
1382    *
1383    * <p>Sample code:
1384    *
1385    * <pre>{@code
1386    * // This snippet has been automatically generated and should be regarded as a code template only.
1387    * // It will require modifications to work:
1388    * // - It may require correct/in-range values for request initialization.
1389    * // - It may require specifying regional endpoints when creating the service client as shown in
1390    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1391    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1392    *     CloudFunctionsServiceClient.create()) {
1393    *   ListLocationsRequest request =
1394    *       ListLocationsRequest.newBuilder()
1395    *           .setName("name3373707")
1396    *           .setFilter("filter-1274492040")
1397    *           .setPageSize(883849137)
1398    *           .setPageToken("pageToken873572522")
1399    *           .build();
1400    *   for (Location element : cloudFunctionsServiceClient.listLocations(request).iterateAll()) {
1401    *     // doThingsWith(element);
1402    *   }
1403    * }
1404    * }</pre>
1405    *
1406    * @param request The request object containing all of the parameters for the API call.
1407    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1408    */
listLocations(ListLocationsRequest request)1409   public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
1410     return listLocationsPagedCallable().call(request);
1411   }
1412 
1413   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1414   /**
1415    * Lists information about the supported locations for this service.
1416    *
1417    * <p>Sample code:
1418    *
1419    * <pre>{@code
1420    * // This snippet has been automatically generated and should be regarded as a code template only.
1421    * // It will require modifications to work:
1422    * // - It may require correct/in-range values for request initialization.
1423    * // - It may require specifying regional endpoints when creating the service client as shown in
1424    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1425    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1426    *     CloudFunctionsServiceClient.create()) {
1427    *   ListLocationsRequest request =
1428    *       ListLocationsRequest.newBuilder()
1429    *           .setName("name3373707")
1430    *           .setFilter("filter-1274492040")
1431    *           .setPageSize(883849137)
1432    *           .setPageToken("pageToken873572522")
1433    *           .build();
1434    *   ApiFuture<Location> future =
1435    *       cloudFunctionsServiceClient.listLocationsPagedCallable().futureCall(request);
1436    *   // Do something.
1437    *   for (Location element : future.get().iterateAll()) {
1438    *     // doThingsWith(element);
1439    *   }
1440    * }
1441    * }</pre>
1442    */
1443   public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()1444       listLocationsPagedCallable() {
1445     return stub.listLocationsPagedCallable();
1446   }
1447 
1448   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1449   /**
1450    * Lists information about the supported locations for this service.
1451    *
1452    * <p>Sample code:
1453    *
1454    * <pre>{@code
1455    * // This snippet has been automatically generated and should be regarded as a code template only.
1456    * // It will require modifications to work:
1457    * // - It may require correct/in-range values for request initialization.
1458    * // - It may require specifying regional endpoints when creating the service client as shown in
1459    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1460    * try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
1461    *     CloudFunctionsServiceClient.create()) {
1462    *   ListLocationsRequest request =
1463    *       ListLocationsRequest.newBuilder()
1464    *           .setName("name3373707")
1465    *           .setFilter("filter-1274492040")
1466    *           .setPageSize(883849137)
1467    *           .setPageToken("pageToken873572522")
1468    *           .build();
1469    *   while (true) {
1470    *     ListLocationsResponse response =
1471    *         cloudFunctionsServiceClient.listLocationsCallable().call(request);
1472    *     for (Location element : response.getLocationsList()) {
1473    *       // doThingsWith(element);
1474    *     }
1475    *     String nextPageToken = response.getNextPageToken();
1476    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
1477    *       request = request.toBuilder().setPageToken(nextPageToken).build();
1478    *     } else {
1479    *       break;
1480    *     }
1481    *   }
1482    * }
1483    * }</pre>
1484    */
listLocationsCallable()1485   public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
1486     return stub.listLocationsCallable();
1487   }
1488 
1489   @Override
close()1490   public final void close() {
1491     stub.close();
1492   }
1493 
1494   @Override
shutdown()1495   public void shutdown() {
1496     stub.shutdown();
1497   }
1498 
1499   @Override
isShutdown()1500   public boolean isShutdown() {
1501     return stub.isShutdown();
1502   }
1503 
1504   @Override
isTerminated()1505   public boolean isTerminated() {
1506     return stub.isTerminated();
1507   }
1508 
1509   @Override
shutdownNow()1510   public void shutdownNow() {
1511     stub.shutdownNow();
1512   }
1513 
1514   @Override
awaitTermination(long duration, TimeUnit unit)1515   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1516     return stub.awaitTermination(duration, unit);
1517   }
1518 
1519   public static class ListFunctionsPagedResponse
1520       extends AbstractPagedListResponse<
1521           ListFunctionsRequest,
1522           ListFunctionsResponse,
1523           CloudFunction,
1524           ListFunctionsPage,
1525           ListFunctionsFixedSizeCollection> {
1526 
createAsync( PageContext<ListFunctionsRequest, ListFunctionsResponse, CloudFunction> context, ApiFuture<ListFunctionsResponse> futureResponse)1527     public static ApiFuture<ListFunctionsPagedResponse> createAsync(
1528         PageContext<ListFunctionsRequest, ListFunctionsResponse, CloudFunction> context,
1529         ApiFuture<ListFunctionsResponse> futureResponse) {
1530       ApiFuture<ListFunctionsPage> futurePage =
1531           ListFunctionsPage.createEmptyPage().createPageAsync(context, futureResponse);
1532       return ApiFutures.transform(
1533           futurePage,
1534           input -> new ListFunctionsPagedResponse(input),
1535           MoreExecutors.directExecutor());
1536     }
1537 
ListFunctionsPagedResponse(ListFunctionsPage page)1538     private ListFunctionsPagedResponse(ListFunctionsPage page) {
1539       super(page, ListFunctionsFixedSizeCollection.createEmptyCollection());
1540     }
1541   }
1542 
1543   public static class ListFunctionsPage
1544       extends AbstractPage<
1545           ListFunctionsRequest, ListFunctionsResponse, CloudFunction, ListFunctionsPage> {
1546 
ListFunctionsPage( PageContext<ListFunctionsRequest, ListFunctionsResponse, CloudFunction> context, ListFunctionsResponse response)1547     private ListFunctionsPage(
1548         PageContext<ListFunctionsRequest, ListFunctionsResponse, CloudFunction> context,
1549         ListFunctionsResponse response) {
1550       super(context, response);
1551     }
1552 
createEmptyPage()1553     private static ListFunctionsPage createEmptyPage() {
1554       return new ListFunctionsPage(null, null);
1555     }
1556 
1557     @Override
createPage( PageContext<ListFunctionsRequest, ListFunctionsResponse, CloudFunction> context, ListFunctionsResponse response)1558     protected ListFunctionsPage createPage(
1559         PageContext<ListFunctionsRequest, ListFunctionsResponse, CloudFunction> context,
1560         ListFunctionsResponse response) {
1561       return new ListFunctionsPage(context, response);
1562     }
1563 
1564     @Override
createPageAsync( PageContext<ListFunctionsRequest, ListFunctionsResponse, CloudFunction> context, ApiFuture<ListFunctionsResponse> futureResponse)1565     public ApiFuture<ListFunctionsPage> createPageAsync(
1566         PageContext<ListFunctionsRequest, ListFunctionsResponse, CloudFunction> context,
1567         ApiFuture<ListFunctionsResponse> futureResponse) {
1568       return super.createPageAsync(context, futureResponse);
1569     }
1570   }
1571 
1572   public static class ListFunctionsFixedSizeCollection
1573       extends AbstractFixedSizeCollection<
1574           ListFunctionsRequest,
1575           ListFunctionsResponse,
1576           CloudFunction,
1577           ListFunctionsPage,
1578           ListFunctionsFixedSizeCollection> {
1579 
ListFunctionsFixedSizeCollection(List<ListFunctionsPage> pages, int collectionSize)1580     private ListFunctionsFixedSizeCollection(List<ListFunctionsPage> pages, int collectionSize) {
1581       super(pages, collectionSize);
1582     }
1583 
createEmptyCollection()1584     private static ListFunctionsFixedSizeCollection createEmptyCollection() {
1585       return new ListFunctionsFixedSizeCollection(null, 0);
1586     }
1587 
1588     @Override
createCollection( List<ListFunctionsPage> pages, int collectionSize)1589     protected ListFunctionsFixedSizeCollection createCollection(
1590         List<ListFunctionsPage> pages, int collectionSize) {
1591       return new ListFunctionsFixedSizeCollection(pages, collectionSize);
1592     }
1593   }
1594 
1595   public static class ListLocationsPagedResponse
1596       extends AbstractPagedListResponse<
1597           ListLocationsRequest,
1598           ListLocationsResponse,
1599           Location,
1600           ListLocationsPage,
1601           ListLocationsFixedSizeCollection> {
1602 
createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1603     public static ApiFuture<ListLocationsPagedResponse> createAsync(
1604         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1605         ApiFuture<ListLocationsResponse> futureResponse) {
1606       ApiFuture<ListLocationsPage> futurePage =
1607           ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
1608       return ApiFutures.transform(
1609           futurePage,
1610           input -> new ListLocationsPagedResponse(input),
1611           MoreExecutors.directExecutor());
1612     }
1613 
ListLocationsPagedResponse(ListLocationsPage page)1614     private ListLocationsPagedResponse(ListLocationsPage page) {
1615       super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
1616     }
1617   }
1618 
1619   public static class ListLocationsPage
1620       extends AbstractPage<
1621           ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
1622 
ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1623     private ListLocationsPage(
1624         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1625         ListLocationsResponse response) {
1626       super(context, response);
1627     }
1628 
createEmptyPage()1629     private static ListLocationsPage createEmptyPage() {
1630       return new ListLocationsPage(null, null);
1631     }
1632 
1633     @Override
createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1634     protected ListLocationsPage createPage(
1635         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1636         ListLocationsResponse response) {
1637       return new ListLocationsPage(context, response);
1638     }
1639 
1640     @Override
createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1641     public ApiFuture<ListLocationsPage> createPageAsync(
1642         PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
1643         ApiFuture<ListLocationsResponse> futureResponse) {
1644       return super.createPageAsync(context, futureResponse);
1645     }
1646   }
1647 
1648   public static class ListLocationsFixedSizeCollection
1649       extends AbstractFixedSizeCollection<
1650           ListLocationsRequest,
1651           ListLocationsResponse,
1652           Location,
1653           ListLocationsPage,
1654           ListLocationsFixedSizeCollection> {
1655 
ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1656     private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
1657       super(pages, collectionSize);
1658     }
1659 
createEmptyCollection()1660     private static ListLocationsFixedSizeCollection createEmptyCollection() {
1661       return new ListLocationsFixedSizeCollection(null, 0);
1662     }
1663 
1664     @Override
createCollection( List<ListLocationsPage> pages, int collectionSize)1665     protected ListLocationsFixedSizeCollection createCollection(
1666         List<ListLocationsPage> pages, int collectionSize) {
1667       return new ListLocationsFixedSizeCollection(pages, collectionSize);
1668     }
1669   }
1670 }
1671