Class NetworkFirewallPoliciesClient (1.88.0)

GitHub RepositoryProduct Reference

Service Description: The NetworkFirewallPolicies API.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (NetworkFirewallPoliciesClient networkFirewallPoliciesClient =
     NetworkFirewallPoliciesClient.create()) {
   String project = "project-309310695";
   String firewallPolicy = "firewallPolicy1819692626";
   FirewallPolicy response = networkFirewallPoliciesClient.get(project, firewallPolicy);
 }
 

Note: close() needs to be called on the NetworkFirewallPoliciesClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

AddAssociation

Inserts an association for the specified firewall policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • addAssociationAsync(AddAssociationNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • addAssociationAsync(String project, String firewallPolicy, FirewallPolicyAssociation firewallPolicyAssociationResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • addAssociationOperationCallable()

  • addAssociationCallable()

AddPacketMirroringRule

Inserts a packet mirroring rule into a firewall policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • addPacketMirroringRuleAsync(AddPacketMirroringRuleNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • addPacketMirroringRuleAsync(String project, String firewallPolicy, FirewallPolicyRule firewallPolicyRuleResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • addPacketMirroringRuleOperationCallable()

  • addPacketMirroringRuleCallable()

AddRule

Inserts a rule into a firewall policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • addRuleAsync(AddRuleNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • addRuleAsync(String project, String firewallPolicy, FirewallPolicyRule firewallPolicyRuleResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • addRuleOperationCallable()

  • addRuleCallable()

AggregatedList

Retrieves an aggregated list of network firewall policies, listing network firewall policies from all applicable scopes (global and regional) and grouping the results per scope. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • aggregatedList(AggregatedListNetworkFirewallPoliciesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • aggregatedList(String project)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • aggregatedListPagedCallable()

  • aggregatedListCallable()

CloneRules

Copies rules to the specified firewall policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • cloneRulesAsync(CloneRulesNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • cloneRulesAsync(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • cloneRulesOperationCallable()

  • cloneRulesCallable()

Delete

Deletes the specified policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteAsync(DeleteNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • deleteAsync(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteOperationCallable()

  • deleteCallable()

Get

Returns the specified network firewall policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • get(GetNetworkFirewallPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • get(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getCallable()

GetAssociation

Gets an association with the specified name.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getAssociation(GetAssociationNetworkFirewallPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getAssociation(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getAssociationCallable()

GetIamPolicy

Gets the access control policy for a resource. May be empty if no such policy or resource exists.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getIamPolicy(GetIamPolicyNetworkFirewallPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getIamPolicy(String project, String resource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getIamPolicyCallable()

GetPacketMirroringRule

Gets a packet mirroring rule of the specified priority.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getPacketMirroringRule(GetPacketMirroringRuleNetworkFirewallPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getPacketMirroringRule(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getPacketMirroringRuleCallable()

GetRule

Gets a rule of the specified priority.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getRule(GetRuleNetworkFirewallPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getRule(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getRuleCallable()

Insert

Creates a new policy in the specified project using the data included in the request.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • insertAsync(InsertNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • insertAsync(String project, FirewallPolicy firewallPolicyResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • insertOperationCallable()

  • insertCallable()

List

Lists all the policies that have been configured for the specified project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • list(ListNetworkFirewallPoliciesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • list(String project)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listPagedCallable()

  • listCallable()

Patch

Patches the specified policy with the data included in the request.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • patchAsync(PatchNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • patchAsync(String project, String firewallPolicy, FirewallPolicy firewallPolicyResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • patchOperationCallable()

  • patchCallable()

PatchPacketMirroringRule

Patches a packet mirroring rule of the specified priority.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • patchPacketMirroringRuleAsync(PatchPacketMirroringRuleNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • patchPacketMirroringRuleAsync(String project, String firewallPolicy, FirewallPolicyRule firewallPolicyRuleResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • patchPacketMirroringRuleOperationCallable()

  • patchPacketMirroringRuleCallable()

PatchRule

Patches a rule of the specified priority.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • patchRuleAsync(PatchRuleNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • patchRuleAsync(String project, String firewallPolicy, FirewallPolicyRule firewallPolicyRuleResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • patchRuleOperationCallable()

  • patchRuleCallable()

RemoveAssociation

Removes an association for the specified firewall policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • removeAssociationAsync(RemoveAssociationNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • removeAssociationAsync(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • removeAssociationOperationCallable()

  • removeAssociationCallable()

RemovePacketMirroringRule

Deletes a packet mirroring rule of the specified priority.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • removePacketMirroringRuleAsync(RemovePacketMirroringRuleNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • removePacketMirroringRuleAsync(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • removePacketMirroringRuleOperationCallable()

  • removePacketMirroringRuleCallable()

RemoveRule

Deletes a rule of the specified priority.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • removeRuleAsync(RemoveRuleNetworkFirewallPolicyRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • removeRuleAsync(String project, String firewallPolicy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • removeRuleOperationCallable()

  • removeRuleCallable()

SetIamPolicy

Sets the access control policy on the specified resource. Replaces any existing policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • setIamPolicy(SetIamPolicyNetworkFirewallPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • setIamPolicy(String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • setIamPolicyCallable()

TestIamPermissions

Returns permissions that a caller has on the specified resource.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • testIamPermissions(TestIamPermissionsNetworkFirewallPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • testIamPermissions(String project, String resource, TestPermissionsRequest testPermissionsRequestResource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • testIamPermissionsCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of NetworkFirewallPoliciesSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 NetworkFirewallPoliciesSettings networkFirewallPoliciesSettings =
     NetworkFirewallPoliciesSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 NetworkFirewallPoliciesClient networkFirewallPoliciesClient =
     NetworkFirewallPoliciesClient.create(networkFirewallPoliciesSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 NetworkFirewallPoliciesSettings networkFirewallPoliciesSettings =
     NetworkFirewallPoliciesSettings.newBuilder().setEndpoint(myEndpoint).build();
 NetworkFirewallPoliciesClient networkFirewallPoliciesClient =
     NetworkFirewallPoliciesClient.create(networkFirewallPoliciesSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > NetworkFirewallPoliciesClient

Static Methods

create()

public static final NetworkFirewallPoliciesClient create()

Constructs an instance of NetworkFirewallPoliciesClient with default settings.

Returns
Type Description
NetworkFirewallPoliciesClient
Exceptions
Type Description
IOException

create(NetworkFirewallPoliciesSettings settings)

public static final NetworkFirewallPoliciesClient create(NetworkFirewallPoliciesSettings settings)

Constructs an instance of NetworkFirewallPoliciesClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings NetworkFirewallPoliciesSettings
Returns
Type Description
NetworkFirewallPoliciesClient
Exceptions
Type Description
IOException

create(NetworkFirewallPoliciesStub stub)

public static final NetworkFirewallPoliciesClient create(NetworkFirewallPoliciesStub stub)

Constructs an instance of NetworkFirewallPoliciesClient, using the given stub for making calls. This is for advanced usage - prefer using create(NetworkFirewallPoliciesSettings).

Parameter
Name Description
stub NetworkFirewallPoliciesStub
Returns
Type Description
NetworkFirewallPoliciesClient

Constructors

NetworkFirewallPoliciesClient(NetworkFirewallPoliciesSettings settings)

protected NetworkFirewallPoliciesClient(NetworkFirewallPoliciesSettings settings)

Constructs an instance of NetworkFirewallPoliciesClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings NetworkFirewallPoliciesSettings

NetworkFirewallPoliciesClient(NetworkFirewallPoliciesStub stub)

protected NetworkFirewallPoliciesClient(NetworkFirewallPoliciesStub stub)
Parameter
Name Description
stub NetworkFirewallPoliciesStub

Methods

addAssociationAsync(AddAssociationNetworkFirewallPolicyRequest request)

public final OperationFuture<Operation,Operation> addAssociationAsync(AddAssociationNetworkFirewallPolicyRequest request)

Inserts an association for the specified firewall policy.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (NetworkFirewallPoliciesClient networkFirewallPoliciesClient =
     NetworkFirewallPoliciesClient.create()) {
   AddAssociationNetworkFirewallPolicyRequest request =
       AddAssociationNetworkFirewallPolicyRequest.newBuilder()
           .setFirewallPolicy("firewallPolicy1819692626")
           .setFirewallPolicyAssociationResource(FirewallPolicyAssociation.newBuilder().build())
           .setProject("project-309310695")
           .setReplaceExistingAssociation(true)
           .setRequestId("requestId693933066")
           .build();
   Operation response = networkFirewallPoliciesClient.addAssociationAsync(request).get();
 }
 
Parameter
Name Description
request AddAssociationNetworkFirewallPolicyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<Operation,Operation>

addAssociationAsync(String project, String firewallPolicy, FirewallPolicyAssociation firewallPolicyAssociationResource)

public final OperationFuture<Operation,Operation> addAssociationAsync(String project, String firewallPolicy, FirewallPolicyAssociation firewallPolicyAssociationResource)

Inserts an association for the specified firewall policy.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (NetworkFirewallPoliciesClient networkFirewallPoliciesClient =
     NetworkFirewallPoliciesClient.create()) {
   String project = "project-309310695";
   String firewallPolicy = "firewallPolicy1819692626";
   FirewallPolicyAssociation firewallPolicyAssociationResource =
       FirewallPolicyAssociation.newBuilder().build();
   Operation response =
       networkFirewallPoliciesClient
           .addAssociationAsync(project, firewallPolicy, firewallPolicyAssociationResource)
           .get();
 }
 
Parameters
Name Description
project String

Project ID for this request.

firewallPolicy String

Name of the firewall policy to update.

firewallPolicyAssociationResource FirewallPolicyAssociation

The body resource for this request

Returns
Type Description
OperationFuture<Operation,Operation>

addAssociationCallable()

public final UnaryCallable<AddAssociationNetworkFirewallPolicyRequest,Operation> addAssociationCallable()

Inserts an association for the specified firewall policy.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (NetworkFirewallPoliciesClient networkFirewallPoliciesClient =
     NetworkFirewallPoliciesClient.create()) {
   AddAssociationNetworkFirewallPolicyRequest request =
       AddAssociationNetworkFirewallPolicyRequest.newBuilder()
           .setFirewallPolicy("firewallPolicy1819692626")
           .setFirewallPolicyAssociationResource(FirewallPolicyAssociation.newBuilder().build())
           .setProject("project-309310695")
           .setReplaceExistingAssociation(true)
           .setRequestId("requestId693933066")
           .build();
   ApiFuture<Operation> future =
       networkFirewallPoliciesClient.addAssociationCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<AddAssociationNetworkFirewallPolicyRequest,Operation>

addAssociationOperationCallable()

public final OperationCallable<AddAssociationNetworkFirewallPolicyRequest,Operation,Operation> addAssociationOperationCallable()

Inserts an association for the specified firewall policy.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (NetworkFirewallPoliciesClient networkFirewallPoliciesClient =
     NetworkFirewallPoliciesClient.create()) {
   AddAssociationNetworkFirewallPolicyRequest request =
       AddAssociationNetworkFirewallPolicyRequest.newBuilder()
           .setFirewallPolicy("firewallPolicy1819692626")
           .setFirewallPolicyAssociationResource(FirewallPolicyAssociation.newBuilder().build())
           .setProject("project-309310695")
           .setReplaceExistingAssociation(true)
           .setRequestId("requestId693933066")
           .build();
   OperationFuture<Operation, Operation> future =
       networkFirewallPoliciesClient.addAssociationOperationCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
OperationCallable<AddAssociationNetworkFirewallPolicyRequest,Operation,Operation>

addPacketMirroringRuleAsync(AddPacketMirroringRuleNetworkFirewallPolicyRequest request)

public final OperationFuture<Operation,Operation> addPacketMirroringRuleAsync(AddPacketMirroringRuleNetworkFirewallPolicyRequest request)

Inserts a packet mirroring rule into a firewall policy.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (NetworkFirewallPoliciesClient networkFirewallPoliciesClient =
     NetworkFirewallPoliciesClient.create()) {
   AddPacketMirroringRuleNetworkFirewallPolicyRequest request =
       AddPacketMirroringRuleNetworkFirewallPolicyRequest.newBuilder()
           .setFirewallPolicy("firewallPolicy1819692626")
           .setFirewallPolicyRuleResource(FirewallPolicyRule.newBuilder().build())
           .setMaxPriority(-207235553)
           .setMinPriority(267190513)
           .setProject("project-309310695")
           .setRequestId("requestId693933066")
           .build();
   Operation response