• 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.compute.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.longrunning.OperationFuture;
24 import com.google.api.gax.paging.AbstractFixedSizeCollection;
25 import com.google.api.gax.paging.AbstractPage;
26 import com.google.api.gax.paging.AbstractPagedListResponse;
27 import com.google.api.gax.rpc.OperationCallable;
28 import com.google.api.gax.rpc.PageContext;
29 import com.google.api.gax.rpc.UnaryCallable;
30 import com.google.cloud.compute.v1.stub.FirewallsStub;
31 import com.google.cloud.compute.v1.stub.FirewallsStubSettings;
32 import com.google.common.util.concurrent.MoreExecutors;
33 import java.io.IOException;
34 import java.util.List;
35 import java.util.concurrent.TimeUnit;
36 import javax.annotation.Generated;
37 
38 // AUTO-GENERATED DOCUMENTATION AND CLASS.
39 /**
40  * Service Description: The Firewalls API.
41  *
42  * <p>This class provides the ability to make remote calls to the backing service through method
43  * calls that map to API methods. Sample code to get started:
44  *
45  * <pre>{@code
46  * // This snippet has been automatically generated and should be regarded as a code template only.
47  * // It will require modifications to work:
48  * // - It may require correct/in-range values for request initialization.
49  * // - It may require specifying regional endpoints when creating the service client as shown in
50  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
51  * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
52  *   String project = "project-309310695";
53  *   String firewall = "firewall-562725632";
54  *   Firewall response = firewallsClient.get(project, firewall);
55  * }
56  * }</pre>
57  *
58  * <p>Note: close() needs to be called on the FirewallsClient object to clean up resources such as
59  * threads. In the example above, try-with-resources is used, which automatically calls close().
60  *
61  * <p>The surface of this class includes several types of Java methods for each of the API's
62  * methods:
63  *
64  * <ol>
65  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
66  *       converted into function parameters. It may be the case that not all fields are available as
67  *       parameters, and not every API method will have a flattened method entry point.
68  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
69  *       which must be constructed before the call. Not every API method will have a request object
70  *       method.
71  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
72  *       callable object, which can be used to initiate calls to the service.
73  * </ol>
74  *
75  * <p>See the individual methods for example code.
76  *
77  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
78  * these names, this class includes a format method for each type of name, and additionally a parse
79  * method to extract the individual identifiers contained within names that are returned.
80  *
81  * <p>This class can be customized by passing in a custom instance of FirewallsSettings to create().
82  * For example:
83  *
84  * <p>To customize credentials:
85  *
86  * <pre>{@code
87  * // This snippet has been automatically generated and should be regarded as a code template only.
88  * // It will require modifications to work:
89  * // - It may require correct/in-range values for request initialization.
90  * // - It may require specifying regional endpoints when creating the service client as shown in
91  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
92  * FirewallsSettings firewallsSettings =
93  *     FirewallsSettings.newBuilder()
94  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
95  *         .build();
96  * FirewallsClient firewallsClient = FirewallsClient.create(firewallsSettings);
97  * }</pre>
98  *
99  * <p>To customize the endpoint:
100  *
101  * <pre>{@code
102  * // This snippet has been automatically generated and should be regarded as a code template only.
103  * // It will require modifications to work:
104  * // - It may require correct/in-range values for request initialization.
105  * // - It may require specifying regional endpoints when creating the service client as shown in
106  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
107  * FirewallsSettings firewallsSettings =
108  *     FirewallsSettings.newBuilder().setEndpoint(myEndpoint).build();
109  * FirewallsClient firewallsClient = FirewallsClient.create(firewallsSettings);
110  * }</pre>
111  *
112  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
113  */
114 @Generated("by gapic-generator-java")
115 public class FirewallsClient implements BackgroundResource {
116   private final FirewallsSettings settings;
117   private final FirewallsStub stub;
118 
119   /** Constructs an instance of FirewallsClient with default settings. */
create()120   public static final FirewallsClient create() throws IOException {
121     return create(FirewallsSettings.newBuilder().build());
122   }
123 
124   /**
125    * Constructs an instance of FirewallsClient, using the given settings. The channels are created
126    * based on the settings passed in, or defaults for any settings that are not set.
127    */
create(FirewallsSettings settings)128   public static final FirewallsClient create(FirewallsSettings settings) throws IOException {
129     return new FirewallsClient(settings);
130   }
131 
132   /**
133    * Constructs an instance of FirewallsClient, using the given stub for making calls. This is for
134    * advanced usage - prefer using create(FirewallsSettings).
135    */
create(FirewallsStub stub)136   public static final FirewallsClient create(FirewallsStub stub) {
137     return new FirewallsClient(stub);
138   }
139 
140   /**
141    * Constructs an instance of FirewallsClient, using the given settings. This is protected so that
142    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
143    */
FirewallsClient(FirewallsSettings settings)144   protected FirewallsClient(FirewallsSettings settings) throws IOException {
145     this.settings = settings;
146     this.stub = ((FirewallsStubSettings) settings.getStubSettings()).createStub();
147   }
148 
FirewallsClient(FirewallsStub stub)149   protected FirewallsClient(FirewallsStub stub) {
150     this.settings = null;
151     this.stub = stub;
152   }
153 
getSettings()154   public final FirewallsSettings getSettings() {
155     return settings;
156   }
157 
getStub()158   public FirewallsStub getStub() {
159     return stub;
160   }
161 
162   // AUTO-GENERATED DOCUMENTATION AND METHOD.
163   /**
164    * Deletes the specified firewall.
165    *
166    * <p>Sample code:
167    *
168    * <pre>{@code
169    * // This snippet has been automatically generated and should be regarded as a code template only.
170    * // It will require modifications to work:
171    * // - It may require correct/in-range values for request initialization.
172    * // - It may require specifying regional endpoints when creating the service client as shown in
173    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
174    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
175    *   String project = "project-309310695";
176    *   String firewall = "firewall-562725632";
177    *   Operation response = firewallsClient.deleteAsync(project, firewall).get();
178    * }
179    * }</pre>
180    *
181    * @param project Project ID for this request.
182    * @param firewall Name of the firewall rule to delete.
183    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
184    */
deleteAsync(String project, String firewall)185   public final OperationFuture<Operation, Operation> deleteAsync(String project, String firewall) {
186     DeleteFirewallRequest request =
187         DeleteFirewallRequest.newBuilder().setProject(project).setFirewall(firewall).build();
188     return deleteAsync(request);
189   }
190 
191   // AUTO-GENERATED DOCUMENTATION AND METHOD.
192   /**
193    * Deletes the specified firewall.
194    *
195    * <p>Sample code:
196    *
197    * <pre>{@code
198    * // This snippet has been automatically generated and should be regarded as a code template only.
199    * // It will require modifications to work:
200    * // - It may require correct/in-range values for request initialization.
201    * // - It may require specifying regional endpoints when creating the service client as shown in
202    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
203    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
204    *   DeleteFirewallRequest request =
205    *       DeleteFirewallRequest.newBuilder()
206    *           .setFirewall("firewall-562725632")
207    *           .setProject("project-309310695")
208    *           .setRequestId("requestId693933066")
209    *           .build();
210    *   Operation response = firewallsClient.deleteAsync(request).get();
211    * }
212    * }</pre>
213    *
214    * @param request The request object containing all of the parameters for the API call.
215    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
216    */
217   @BetaApi(
218       "The surface for long-running operations is not stable yet and may change in the future.")
deleteAsync(DeleteFirewallRequest request)219   public final OperationFuture<Operation, Operation> deleteAsync(DeleteFirewallRequest request) {
220     return deleteOperationCallable().futureCall(request);
221   }
222 
223   // AUTO-GENERATED DOCUMENTATION AND METHOD.
224   /**
225    * Deletes the specified firewall.
226    *
227    * <p>Sample code:
228    *
229    * <pre>{@code
230    * // This snippet has been automatically generated and should be regarded as a code template only.
231    * // It will require modifications to work:
232    * // - It may require correct/in-range values for request initialization.
233    * // - It may require specifying regional endpoints when creating the service client as shown in
234    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
235    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
236    *   DeleteFirewallRequest request =
237    *       DeleteFirewallRequest.newBuilder()
238    *           .setFirewall("firewall-562725632")
239    *           .setProject("project-309310695")
240    *           .setRequestId("requestId693933066")
241    *           .build();
242    *   OperationFuture<Operation, Operation> future =
243    *       firewallsClient.deleteOperationCallable().futureCall(request);
244    *   // Do something.
245    *   Operation response = future.get();
246    * }
247    * }</pre>
248    */
249   public final OperationCallable<DeleteFirewallRequest, Operation, Operation>
deleteOperationCallable()250       deleteOperationCallable() {
251     return stub.deleteOperationCallable();
252   }
253 
254   // AUTO-GENERATED DOCUMENTATION AND METHOD.
255   /**
256    * Deletes the specified firewall.
257    *
258    * <p>Sample code:
259    *
260    * <pre>{@code
261    * // This snippet has been automatically generated and should be regarded as a code template only.
262    * // It will require modifications to work:
263    * // - It may require correct/in-range values for request initialization.
264    * // - It may require specifying regional endpoints when creating the service client as shown in
265    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
266    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
267    *   DeleteFirewallRequest request =
268    *       DeleteFirewallRequest.newBuilder()
269    *           .setFirewall("firewall-562725632")
270    *           .setProject("project-309310695")
271    *           .setRequestId("requestId693933066")
272    *           .build();
273    *   ApiFuture<Operation> future = firewallsClient.deleteCallable().futureCall(request);
274    *   // Do something.
275    *   Operation response = future.get();
276    * }
277    * }</pre>
278    */
deleteCallable()279   public final UnaryCallable<DeleteFirewallRequest, Operation> deleteCallable() {
280     return stub.deleteCallable();
281   }
282 
283   // AUTO-GENERATED DOCUMENTATION AND METHOD.
284   /**
285    * Returns the specified firewall.
286    *
287    * <p>Sample code:
288    *
289    * <pre>{@code
290    * // This snippet has been automatically generated and should be regarded as a code template only.
291    * // It will require modifications to work:
292    * // - It may require correct/in-range values for request initialization.
293    * // - It may require specifying regional endpoints when creating the service client as shown in
294    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
295    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
296    *   String project = "project-309310695";
297    *   String firewall = "firewall-562725632";
298    *   Firewall response = firewallsClient.get(project, firewall);
299    * }
300    * }</pre>
301    *
302    * @param project Project ID for this request.
303    * @param firewall Name of the firewall rule to return.
304    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
305    */
get(String project, String firewall)306   public final Firewall get(String project, String firewall) {
307     GetFirewallRequest request =
308         GetFirewallRequest.newBuilder().setProject(project).setFirewall(firewall).build();
309     return get(request);
310   }
311 
312   // AUTO-GENERATED DOCUMENTATION AND METHOD.
313   /**
314    * Returns the specified firewall.
315    *
316    * <p>Sample code:
317    *
318    * <pre>{@code
319    * // This snippet has been automatically generated and should be regarded as a code template only.
320    * // It will require modifications to work:
321    * // - It may require correct/in-range values for request initialization.
322    * // - It may require specifying regional endpoints when creating the service client as shown in
323    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
324    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
325    *   GetFirewallRequest request =
326    *       GetFirewallRequest.newBuilder()
327    *           .setFirewall("firewall-562725632")
328    *           .setProject("project-309310695")
329    *           .build();
330    *   Firewall response = firewallsClient.get(request);
331    * }
332    * }</pre>
333    *
334    * @param request The request object containing all of the parameters for the API call.
335    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
336    */
get(GetFirewallRequest request)337   public final Firewall get(GetFirewallRequest request) {
338     return getCallable().call(request);
339   }
340 
341   // AUTO-GENERATED DOCUMENTATION AND METHOD.
342   /**
343    * Returns the specified firewall.
344    *
345    * <p>Sample code:
346    *
347    * <pre>{@code
348    * // This snippet has been automatically generated and should be regarded as a code template only.
349    * // It will require modifications to work:
350    * // - It may require correct/in-range values for request initialization.
351    * // - It may require specifying regional endpoints when creating the service client as shown in
352    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
353    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
354    *   GetFirewallRequest request =
355    *       GetFirewallRequest.newBuilder()
356    *           .setFirewall("firewall-562725632")
357    *           .setProject("project-309310695")
358    *           .build();
359    *   ApiFuture<Firewall> future = firewallsClient.getCallable().futureCall(request);
360    *   // Do something.
361    *   Firewall response = future.get();
362    * }
363    * }</pre>
364    */
getCallable()365   public final UnaryCallable<GetFirewallRequest, Firewall> getCallable() {
366     return stub.getCallable();
367   }
368 
369   // AUTO-GENERATED DOCUMENTATION AND METHOD.
370   /**
371    * Creates a firewall rule in the specified project using the data included in the request.
372    *
373    * <p>Sample code:
374    *
375    * <pre>{@code
376    * // This snippet has been automatically generated and should be regarded as a code template only.
377    * // It will require modifications to work:
378    * // - It may require correct/in-range values for request initialization.
379    * // - It may require specifying regional endpoints when creating the service client as shown in
380    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
381    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
382    *   String project = "project-309310695";
383    *   Firewall firewallResource = Firewall.newBuilder().build();
384    *   Operation response = firewallsClient.insertAsync(project, firewallResource).get();
385    * }
386    * }</pre>
387    *
388    * @param project Project ID for this request.
389    * @param firewallResource The body resource for this request
390    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
391    */
insertAsync( String project, Firewall firewallResource)392   public final OperationFuture<Operation, Operation> insertAsync(
393       String project, Firewall firewallResource) {
394     InsertFirewallRequest request =
395         InsertFirewallRequest.newBuilder()
396             .setProject(project)
397             .setFirewallResource(firewallResource)
398             .build();
399     return insertAsync(request);
400   }
401 
402   // AUTO-GENERATED DOCUMENTATION AND METHOD.
403   /**
404    * Creates a firewall rule in the specified project using the data included in the request.
405    *
406    * <p>Sample code:
407    *
408    * <pre>{@code
409    * // This snippet has been automatically generated and should be regarded as a code template only.
410    * // It will require modifications to work:
411    * // - It may require correct/in-range values for request initialization.
412    * // - It may require specifying regional endpoints when creating the service client as shown in
413    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
414    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
415    *   InsertFirewallRequest request =
416    *       InsertFirewallRequest.newBuilder()
417    *           .setFirewallResource(Firewall.newBuilder().build())
418    *           .setProject("project-309310695")
419    *           .setRequestId("requestId693933066")
420    *           .build();
421    *   Operation response = firewallsClient.insertAsync(request).get();
422    * }
423    * }</pre>
424    *
425    * @param request The request object containing all of the parameters for the API call.
426    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
427    */
428   @BetaApi(
429       "The surface for long-running operations is not stable yet and may change in the future.")
insertAsync(InsertFirewallRequest request)430   public final OperationFuture<Operation, Operation> insertAsync(InsertFirewallRequest request) {
431     return insertOperationCallable().futureCall(request);
432   }
433 
434   // AUTO-GENERATED DOCUMENTATION AND METHOD.
435   /**
436    * Creates a firewall rule in the specified project using the data included in the request.
437    *
438    * <p>Sample code:
439    *
440    * <pre>{@code
441    * // This snippet has been automatically generated and should be regarded as a code template only.
442    * // It will require modifications to work:
443    * // - It may require correct/in-range values for request initialization.
444    * // - It may require specifying regional endpoints when creating the service client as shown in
445    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
446    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
447    *   InsertFirewallRequest request =
448    *       InsertFirewallRequest.newBuilder()
449    *           .setFirewallResource(Firewall.newBuilder().build())
450    *           .setProject("project-309310695")
451    *           .setRequestId("requestId693933066")
452    *           .build();
453    *   OperationFuture<Operation, Operation> future =
454    *       firewallsClient.insertOperationCallable().futureCall(request);
455    *   // Do something.
456    *   Operation response = future.get();
457    * }
458    * }</pre>
459    */
460   public final OperationCallable<InsertFirewallRequest, Operation, Operation>
insertOperationCallable()461       insertOperationCallable() {
462     return stub.insertOperationCallable();
463   }
464 
465   // AUTO-GENERATED DOCUMENTATION AND METHOD.
466   /**
467    * Creates a firewall rule in the specified project using the data included in the request.
468    *
469    * <p>Sample code:
470    *
471    * <pre>{@code
472    * // This snippet has been automatically generated and should be regarded as a code template only.
473    * // It will require modifications to work:
474    * // - It may require correct/in-range values for request initialization.
475    * // - It may require specifying regional endpoints when creating the service client as shown in
476    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
477    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
478    *   InsertFirewallRequest request =
479    *       InsertFirewallRequest.newBuilder()
480    *           .setFirewallResource(Firewall.newBuilder().build())
481    *           .setProject("project-309310695")
482    *           .setRequestId("requestId693933066")
483    *           .build();
484    *   ApiFuture<Operation> future = firewallsClient.insertCallable().futureCall(request);
485    *   // Do something.
486    *   Operation response = future.get();
487    * }
488    * }</pre>
489    */
insertCallable()490   public final UnaryCallable<InsertFirewallRequest, Operation> insertCallable() {
491     return stub.insertCallable();
492   }
493 
494   // AUTO-GENERATED DOCUMENTATION AND METHOD.
495   /**
496    * Retrieves the list of firewall rules available to the specified project.
497    *
498    * <p>Sample code:
499    *
500    * <pre>{@code
501    * // This snippet has been automatically generated and should be regarded as a code template only.
502    * // It will require modifications to work:
503    * // - It may require correct/in-range values for request initialization.
504    * // - It may require specifying regional endpoints when creating the service client as shown in
505    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
506    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
507    *   String project = "project-309310695";
508    *   for (Firewall element : firewallsClient.list(project).iterateAll()) {
509    *     // doThingsWith(element);
510    *   }
511    * }
512    * }</pre>
513    *
514    * @param project Project ID for this request.
515    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
516    */
list(String project)517   public final ListPagedResponse list(String project) {
518     ListFirewallsRequest request = ListFirewallsRequest.newBuilder().setProject(project).build();
519     return list(request);
520   }
521 
522   // AUTO-GENERATED DOCUMENTATION AND METHOD.
523   /**
524    * Retrieves the list of firewall rules available to the specified project.
525    *
526    * <p>Sample code:
527    *
528    * <pre>{@code
529    * // This snippet has been automatically generated and should be regarded as a code template only.
530    * // It will require modifications to work:
531    * // - It may require correct/in-range values for request initialization.
532    * // - It may require specifying regional endpoints when creating the service client as shown in
533    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
534    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
535    *   ListFirewallsRequest request =
536    *       ListFirewallsRequest.newBuilder()
537    *           .setFilter("filter-1274492040")
538    *           .setMaxResults(1128457243)
539    *           .setOrderBy("orderBy-1207110587")
540    *           .setPageToken("pageToken873572522")
541    *           .setProject("project-309310695")
542    *           .setReturnPartialSuccess(true)
543    *           .build();
544    *   for (Firewall element : firewallsClient.list(request).iterateAll()) {
545    *     // doThingsWith(element);
546    *   }
547    * }
548    * }</pre>
549    *
550    * @param request The request object containing all of the parameters for the API call.
551    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
552    */
list(ListFirewallsRequest request)553   public final ListPagedResponse list(ListFirewallsRequest request) {
554     return listPagedCallable().call(request);
555   }
556 
557   // AUTO-GENERATED DOCUMENTATION AND METHOD.
558   /**
559    * Retrieves the list of firewall rules available to the specified project.
560    *
561    * <p>Sample code:
562    *
563    * <pre>{@code
564    * // This snippet has been automatically generated and should be regarded as a code template only.
565    * // It will require modifications to work:
566    * // - It may require correct/in-range values for request initialization.
567    * // - It may require specifying regional endpoints when creating the service client as shown in
568    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
569    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
570    *   ListFirewallsRequest request =
571    *       ListFirewallsRequest.newBuilder()
572    *           .setFilter("filter-1274492040")
573    *           .setMaxResults(1128457243)
574    *           .setOrderBy("orderBy-1207110587")
575    *           .setPageToken("pageToken873572522")
576    *           .setProject("project-309310695")
577    *           .setReturnPartialSuccess(true)
578    *           .build();
579    *   ApiFuture<Firewall> future = firewallsClient.listPagedCallable().futureCall(request);
580    *   // Do something.
581    *   for (Firewall element : future.get().iterateAll()) {
582    *     // doThingsWith(element);
583    *   }
584    * }
585    * }</pre>
586    */
listPagedCallable()587   public final UnaryCallable<ListFirewallsRequest, ListPagedResponse> listPagedCallable() {
588     return stub.listPagedCallable();
589   }
590 
591   // AUTO-GENERATED DOCUMENTATION AND METHOD.
592   /**
593    * Retrieves the list of firewall rules available to the specified project.
594    *
595    * <p>Sample code:
596    *
597    * <pre>{@code
598    * // This snippet has been automatically generated and should be regarded as a code template only.
599    * // It will require modifications to work:
600    * // - It may require correct/in-range values for request initialization.
601    * // - It may require specifying regional endpoints when creating the service client as shown in
602    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
603    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
604    *   ListFirewallsRequest request =
605    *       ListFirewallsRequest.newBuilder()
606    *           .setFilter("filter-1274492040")
607    *           .setMaxResults(1128457243)
608    *           .setOrderBy("orderBy-1207110587")
609    *           .setPageToken("pageToken873572522")
610    *           .setProject("project-309310695")
611    *           .setReturnPartialSuccess(true)
612    *           .build();
613    *   while (true) {
614    *     FirewallList response = firewallsClient.listCallable().call(request);
615    *     for (Firewall element : response.getItemsList()) {
616    *       // doThingsWith(element);
617    *     }
618    *     String nextPageToken = response.getNextPageToken();
619    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
620    *       request = request.toBuilder().setPageToken(nextPageToken).build();
621    *     } else {
622    *       break;
623    *     }
624    *   }
625    * }
626    * }</pre>
627    */
listCallable()628   public final UnaryCallable<ListFirewallsRequest, FirewallList> listCallable() {
629     return stub.listCallable();
630   }
631 
632   // AUTO-GENERATED DOCUMENTATION AND METHOD.
633   /**
634    * Updates the specified firewall rule with the data included in the request. This method supports
635    * PATCH semantics and uses the JSON merge patch format and processing rules.
636    *
637    * <p>Sample code:
638    *
639    * <pre>{@code
640    * // This snippet has been automatically generated and should be regarded as a code template only.
641    * // It will require modifications to work:
642    * // - It may require correct/in-range values for request initialization.
643    * // - It may require specifying regional endpoints when creating the service client as shown in
644    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
645    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
646    *   String project = "project-309310695";
647    *   String firewall = "firewall-562725632";
648    *   Firewall firewallResource = Firewall.newBuilder().build();
649    *   Operation response = firewallsClient.patchAsync(project, firewall, firewallResource).get();
650    * }
651    * }</pre>
652    *
653    * @param project Project ID for this request.
654    * @param firewall Name of the firewall rule to patch.
655    * @param firewallResource The body resource for this request
656    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
657    */
patchAsync( String project, String firewall, Firewall firewallResource)658   public final OperationFuture<Operation, Operation> patchAsync(
659       String project, String firewall, Firewall firewallResource) {
660     PatchFirewallRequest request =
661         PatchFirewallRequest.newBuilder()
662             .setProject(project)
663             .setFirewall(firewall)
664             .setFirewallResource(firewallResource)
665             .build();
666     return patchAsync(request);
667   }
668 
669   // AUTO-GENERATED DOCUMENTATION AND METHOD.
670   /**
671    * Updates the specified firewall rule with the data included in the request. This method supports
672    * PATCH semantics and uses the JSON merge patch format and processing rules.
673    *
674    * <p>Sample code:
675    *
676    * <pre>{@code
677    * // This snippet has been automatically generated and should be regarded as a code template only.
678    * // It will require modifications to work:
679    * // - It may require correct/in-range values for request initialization.
680    * // - It may require specifying regional endpoints when creating the service client as shown in
681    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
682    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
683    *   PatchFirewallRequest request =
684    *       PatchFirewallRequest.newBuilder()
685    *           .setFirewall("firewall-562725632")
686    *           .setFirewallResource(Firewall.newBuilder().build())
687    *           .setProject("project-309310695")
688    *           .setRequestId("requestId693933066")
689    *           .build();
690    *   Operation response = firewallsClient.patchAsync(request).get();
691    * }
692    * }</pre>
693    *
694    * @param request The request object containing all of the parameters for the API call.
695    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
696    */
697   @BetaApi(
698       "The surface for long-running operations is not stable yet and may change in the future.")
patchAsync(PatchFirewallRequest request)699   public final OperationFuture<Operation, Operation> patchAsync(PatchFirewallRequest request) {
700     return patchOperationCallable().futureCall(request);
701   }
702 
703   // AUTO-GENERATED DOCUMENTATION AND METHOD.
704   /**
705    * Updates the specified firewall rule with the data included in the request. This method supports
706    * PATCH semantics and uses the JSON merge patch format and processing rules.
707    *
708    * <p>Sample code:
709    *
710    * <pre>{@code
711    * // This snippet has been automatically generated and should be regarded as a code template only.
712    * // It will require modifications to work:
713    * // - It may require correct/in-range values for request initialization.
714    * // - It may require specifying regional endpoints when creating the service client as shown in
715    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
716    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
717    *   PatchFirewallRequest request =
718    *       PatchFirewallRequest.newBuilder()
719    *           .setFirewall("firewall-562725632")
720    *           .setFirewallResource(Firewall.newBuilder().build())
721    *           .setProject("project-309310695")
722    *           .setRequestId("requestId693933066")
723    *           .build();
724    *   OperationFuture<Operation, Operation> future =
725    *       firewallsClient.patchOperationCallable().futureCall(request);
726    *   // Do something.
727    *   Operation response = future.get();
728    * }
729    * }</pre>
730    */
731   public final OperationCallable<PatchFirewallRequest, Operation, Operation>
patchOperationCallable()732       patchOperationCallable() {
733     return stub.patchOperationCallable();
734   }
735 
736   // AUTO-GENERATED DOCUMENTATION AND METHOD.
737   /**
738    * Updates the specified firewall rule with the data included in the request. This method supports
739    * PATCH semantics and uses the JSON merge patch format and processing rules.
740    *
741    * <p>Sample code:
742    *
743    * <pre>{@code
744    * // This snippet has been automatically generated and should be regarded as a code template only.
745    * // It will require modifications to work:
746    * // - It may require correct/in-range values for request initialization.
747    * // - It may require specifying regional endpoints when creating the service client as shown in
748    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
749    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
750    *   PatchFirewallRequest request =
751    *       PatchFirewallRequest.newBuilder()
752    *           .setFirewall("firewall-562725632")
753    *           .setFirewallResource(Firewall.newBuilder().build())
754    *           .setProject("project-309310695")
755    *           .setRequestId("requestId693933066")
756    *           .build();
757    *   ApiFuture<Operation> future = firewallsClient.patchCallable().futureCall(request);
758    *   // Do something.
759    *   Operation response = future.get();
760    * }
761    * }</pre>
762    */
patchCallable()763   public final UnaryCallable<PatchFirewallRequest, Operation> patchCallable() {
764     return stub.patchCallable();
765   }
766 
767   // AUTO-GENERATED DOCUMENTATION AND METHOD.
768   /**
769    * Updates the specified firewall rule with the data included in the request. Note that all fields
770    * will be updated if using PUT, even fields that are not specified. To update individual fields,
771    * please use PATCH instead.
772    *
773    * <p>Sample code:
774    *
775    * <pre>{@code
776    * // This snippet has been automatically generated and should be regarded as a code template only.
777    * // It will require modifications to work:
778    * // - It may require correct/in-range values for request initialization.
779    * // - It may require specifying regional endpoints when creating the service client as shown in
780    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
781    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
782    *   String project = "project-309310695";
783    *   String firewall = "firewall-562725632";
784    *   Firewall firewallResource = Firewall.newBuilder().build();
785    *   Operation response = firewallsClient.updateAsync(project, firewall, firewallResource).get();
786    * }
787    * }</pre>
788    *
789    * @param project Project ID for this request.
790    * @param firewall Name of the firewall rule to update.
791    * @param firewallResource The body resource for this request
792    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
793    */
updateAsync( String project, String firewall, Firewall firewallResource)794   public final OperationFuture<Operation, Operation> updateAsync(
795       String project, String firewall, Firewall firewallResource) {
796     UpdateFirewallRequest request =
797         UpdateFirewallRequest.newBuilder()
798             .setProject(project)
799             .setFirewall(firewall)
800             .setFirewallResource(firewallResource)
801             .build();
802     return updateAsync(request);
803   }
804 
805   // AUTO-GENERATED DOCUMENTATION AND METHOD.
806   /**
807    * Updates the specified firewall rule with the data included in the request. Note that all fields
808    * will be updated if using PUT, even fields that are not specified. To update individual fields,
809    * please use PATCH instead.
810    *
811    * <p>Sample code:
812    *
813    * <pre>{@code
814    * // This snippet has been automatically generated and should be regarded as a code template only.
815    * // It will require modifications to work:
816    * // - It may require correct/in-range values for request initialization.
817    * // - It may require specifying regional endpoints when creating the service client as shown in
818    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
819    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
820    *   UpdateFirewallRequest request =
821    *       UpdateFirewallRequest.newBuilder()
822    *           .setFirewall("firewall-562725632")
823    *           .setFirewallResource(Firewall.newBuilder().build())
824    *           .setProject("project-309310695")
825    *           .setRequestId("requestId693933066")
826    *           .build();
827    *   Operation response = firewallsClient.updateAsync(request).get();
828    * }
829    * }</pre>
830    *
831    * @param request The request object containing all of the parameters for the API call.
832    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
833    */
834   @BetaApi(
835       "The surface for long-running operations is not stable yet and may change in the future.")
updateAsync(UpdateFirewallRequest request)836   public final OperationFuture<Operation, Operation> updateAsync(UpdateFirewallRequest request) {
837     return updateOperationCallable().futureCall(request);
838   }
839 
840   // AUTO-GENERATED DOCUMENTATION AND METHOD.
841   /**
842    * Updates the specified firewall rule with the data included in the request. Note that all fields
843    * will be updated if using PUT, even fields that are not specified. To update individual fields,
844    * please use PATCH instead.
845    *
846    * <p>Sample code:
847    *
848    * <pre>{@code
849    * // This snippet has been automatically generated and should be regarded as a code template only.
850    * // It will require modifications to work:
851    * // - It may require correct/in-range values for request initialization.
852    * // - It may require specifying regional endpoints when creating the service client as shown in
853    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
854    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
855    *   UpdateFirewallRequest request =
856    *       UpdateFirewallRequest.newBuilder()
857    *           .setFirewall("firewall-562725632")
858    *           .setFirewallResource(Firewall.newBuilder().build())
859    *           .setProject("project-309310695")
860    *           .setRequestId("requestId693933066")
861    *           .build();
862    *   OperationFuture<Operation, Operation> future =
863    *       firewallsClient.updateOperationCallable().futureCall(request);
864    *   // Do something.
865    *   Operation response = future.get();
866    * }
867    * }</pre>
868    */
869   public final OperationCallable<UpdateFirewallRequest, Operation, Operation>
updateOperationCallable()870       updateOperationCallable() {
871     return stub.updateOperationCallable();
872   }
873 
874   // AUTO-GENERATED DOCUMENTATION AND METHOD.
875   /**
876    * Updates the specified firewall rule with the data included in the request. Note that all fields
877    * will be updated if using PUT, even fields that are not specified. To update individual fields,
878    * please use PATCH instead.
879    *
880    * <p>Sample code:
881    *
882    * <pre>{@code
883    * // This snippet has been automatically generated and should be regarded as a code template only.
884    * // It will require modifications to work:
885    * // - It may require correct/in-range values for request initialization.
886    * // - It may require specifying regional endpoints when creating the service client as shown in
887    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
888    * try (FirewallsClient firewallsClient = FirewallsClient.create()) {
889    *   UpdateFirewallRequest request =
890    *       UpdateFirewallRequest.newBuilder()
891    *           .setFirewall("firewall-562725632")
892    *           .setFirewallResource(Firewall.newBuilder().build())
893    *           .setProject("project-309310695")
894    *           .setRequestId("requestId693933066")
895    *           .build();
896    *   ApiFuture<Operation> future = firewallsClient.updateCallable().futureCall(request);
897    *   // Do something.
898    *   Operation response = future.get();
899    * }
900    * }</pre>
901    */
updateCallable()902   public final UnaryCallable<UpdateFirewallRequest, Operation> updateCallable() {
903     return stub.updateCallable();
904   }
905 
906   @Override
close()907   public final void close() {
908     stub.close();
909   }
910 
911   @Override
shutdown()912   public void shutdown() {
913     stub.shutdown();
914   }
915 
916   @Override
isShutdown()917   public boolean isShutdown() {
918     return stub.isShutdown();
919   }
920 
921   @Override
isTerminated()922   public boolean isTerminated() {
923     return stub.isTerminated();
924   }
925 
926   @Override
shutdownNow()927   public void shutdownNow() {
928     stub.shutdownNow();
929   }
930 
931   @Override
awaitTermination(long duration, TimeUnit unit)932   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
933     return stub.awaitTermination(duration, unit);
934   }
935 
936   public static class ListPagedResponse
937       extends AbstractPagedListResponse<
938           ListFirewallsRequest, FirewallList, Firewall, ListPage, ListFixedSizeCollection> {
939 
createAsync( PageContext<ListFirewallsRequest, FirewallList, Firewall> context, ApiFuture<FirewallList> futureResponse)940     public static ApiFuture<ListPagedResponse> createAsync(
941         PageContext<ListFirewallsRequest, FirewallList, Firewall> context,
942         ApiFuture<FirewallList> futureResponse) {
943       ApiFuture<ListPage> futurePage =
944           ListPage.createEmptyPage().createPageAsync(context, futureResponse);
945       return ApiFutures.transform(
946           futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor());
947     }
948 
ListPagedResponse(ListPage page)949     private ListPagedResponse(ListPage page) {
950       super(page, ListFixedSizeCollection.createEmptyCollection());
951     }
952   }
953 
954   public static class ListPage
955       extends AbstractPage<ListFirewallsRequest, FirewallList, Firewall, ListPage> {
956 
ListPage( PageContext<ListFirewallsRequest, FirewallList, Firewall> context, FirewallList response)957     private ListPage(
958         PageContext<ListFirewallsRequest, FirewallList, Firewall> context, FirewallList response) {
959       super(context, response);
960     }
961 
createEmptyPage()962     private static ListPage createEmptyPage() {
963       return new ListPage(null, null);
964     }
965 
966     @Override
createPage( PageContext<ListFirewallsRequest, FirewallList, Firewall> context, FirewallList response)967     protected ListPage createPage(
968         PageContext<ListFirewallsRequest, FirewallList, Firewall> context, FirewallList response) {
969       return new ListPage(context, response);
970     }
971 
972     @Override
createPageAsync( PageContext<ListFirewallsRequest, FirewallList, Firewall> context, ApiFuture<FirewallList> futureResponse)973     public ApiFuture<ListPage> createPageAsync(
974         PageContext<ListFirewallsRequest, FirewallList, Firewall> context,
975         ApiFuture<FirewallList> futureResponse) {
976       return super.createPageAsync(context, futureResponse);
977     }
978   }
979 
980   public static class ListFixedSizeCollection
981       extends AbstractFixedSizeCollection<
982           ListFirewallsRequest, FirewallList, Firewall, ListPage, ListFixedSizeCollection> {
983 
ListFixedSizeCollection(List<ListPage> pages, int collectionSize)984     private ListFixedSizeCollection(List<ListPage> pages, int collectionSize) {
985       super(pages, collectionSize);
986     }
987 
createEmptyCollection()988     private static ListFixedSizeCollection createEmptyCollection() {
989       return new ListFixedSizeCollection(null, 0);
990     }
991 
992     @Override
createCollection(List<ListPage> pages, int collectionSize)993     protected ListFixedSizeCollection createCollection(List<ListPage> pages, int collectionSize) {
994       return new ListFixedSizeCollection(pages, collectionSize);
995     }
996   }
997 }
998