Class Firewall.Builder (1.91.0)

public static final class Firewall.Builder extends GeneratedMessageV3.Builder<Firewall.Builder> implements FirewallOrBuilder

Represents a Firewall Rule resource.

Firewall rules allow or deny ingress traffic to, and egress traffic from your instances. For more information, readFirewall rules.

Protobuf type google.cloud.compute.v1.Firewall

Implements

FirewallOrBuilder

Static Methods

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

Methods

addAllAllowed(Iterable<? extends Allowed> values)

public Firewall.Builder addAllAllowed(Iterable<? extends Allowed> values)

The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection.

repeated .google.cloud.compute.v1.Allowed allowed = 162398632;

Parameter
Name Description
values Iterable<? extends com.google.cloud.compute.v1.Allowed>
Returns
Type Description
Firewall.Builder

addAllDenied(Iterable<? extends Denied> values)

public Firewall.Builder addAllDenied(Iterable<? extends Denied> values)

The list of DENY rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a denied connection.

repeated .google.cloud.compute.v1.Denied denied = 275217307;

Parameter
Name Description
values Iterable<? extends com.google.cloud.compute.v1.Denied>
Returns
Type Description
Firewall.Builder

addAllDestinationRanges(Iterable<String> values)

public Firewall.Builder addAllDestinationRanges(Iterable<String> values)

If destination ranges are specified, the firewall rule applies only to traffic that has destination IP address in these ranges. These ranges must be expressed inCIDR format. Both IPv4 and IPv6 are supported.

repeated string destination_ranges = 305699879;

Parameter
Name Description
values Iterable<String>

The destinationRanges to add.

Returns
Type Description
Firewall.Builder

This builder for chaining.

addAllSourceRanges(Iterable<String> values)

public Firewall.Builder addAllSourceRanges(Iterable<String> values)

If source ranges are specified, the firewall rule applies only to traffic that has a source IP address in these ranges. These ranges must be expressed inCIDR format. One or both of sourceRanges and sourceTags may be set. If both fields are set, the rule applies to traffic that has a source IP address within sourceRanges OR a source IP from a resource with a matching tag listed in thesourceTags field. The connection does not need to match both fields for the rule to apply. Both IPv4 and IPv6 are supported.

repeated string source_ranges = 200097658;

Parameter
Name Description
values Iterable<String>

The sourceRanges to add.

Returns
Type Description
Firewall.Builder

This builder for chaining.

addAllSourceServiceAccounts(Iterable<String> values)

public Firewall.Builder addAllSourceServiceAccounts(Iterable<String> values)

If source service accounts are specified, the firewall rules apply only to traffic originating from an instance with a service account in this list. Source service accounts cannot be used to control traffic to an instance's external IP address because service accounts are associated with an instance, not an IP address.sourceRanges can be set at the same time assourceServiceAccounts. If both are set, the firewall applies to traffic that has a source IP address within the sourceRanges OR a source IP that belongs to an instance with service account listed insourceServiceAccount. The connection does not need to match both fields for the firewall to apply.sourceServiceAccounts cannot be used at the same time assourceTags or targetTags.

repeated string source_service_accounts = 105100756;

Parameter
Name Description
values Iterable<String>

The sourceServiceAccounts to add.

Returns
Type Description
Firewall.Builder

This builder for chaining.

addAllSourceTags(Iterable<String> values)

public Firewall.Builder addAllSourceTags(Iterable<String> values)

If source tags are specified, the firewall rule applies only to traffic with source IPs that match the primary network interfaces of VM instances that have the tag and are in the same VPC network. Source tags cannot be used to control traffic to an instance's external IP address, it only applies to traffic between instances in the same virtual network. Because tags are associated with instances, not IP addresses. One or both of sourceRanges and sourceTags may be set. If both fields are set, the firewall applies to traffic that has a source IP address within sourceRanges OR a source IP from a resource with a matching tag listed in the sourceTags field. The connection does not need to match both fields for the firewall to apply.

repeated string source_tags = 452222397;

Parameter
Name Description
values Iterable<String>

The sourceTags to add.

Returns
Type Description
Firewall.Builder

This builder for chaining.

addAllTargetServiceAccounts(Iterable<String> values)

public Firewall.Builder addAllTargetServiceAccounts(Iterable<String> values)

A list of service accounts indicating sets of instances located in the network that may make network connections as specified inallowed[].targetServiceAccounts cannot be used at the same time astargetTags or sourceTags. If neither targetServiceAccounts nor targetTags are specified, the firewall rule applies to all instances on the specified network.

repeated string target_service_accounts = 457639710;

Parameter
Name Description
values Iterable<String>

The targetServiceAccounts to add.

Returns
Type Description
Firewall.Builder

This builder for chaining.

addAllTargetTags(Iterable<String> values)

public Firewall.Builder addAllTargetTags(Iterable<String> values)

A list of tags that controls which instances the firewall rule applies to. If targetTags are specified, then the firewall rule applies only to instances in the VPC network that have one of those tags. If no targetTags are specified, the firewall rule applies to all instances on the specified network.

repeated string target_tags = 62901767;

Parameter
Name Description
values Iterable<String>

The targetTags to add.

Returns
Type Description
Firewall.Builder

This builder for chaining.

addAllowed(Allowed value)

public Firewall.Builder addAllowed(Allowed value)

The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection.

repeated .google.cloud.compute.v1.Allowed allowed = 162398632;

Parameter
Name Description
value Allowed
Returns
Type Description
Firewall.Builder

addAllowed(Allowed.Builder builderForValue)

public Firewall.Builder addAllowed(Allowed.Builder builderForValue)

The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection.

repeated .google.cloud.compute.v1.Allowed allowed = 162398632;

Parameter
Name Description
builderForValue Allowed.Builder
Returns
Type Description
Firewall.Builder

addAllowed(int index, Allowed value)

public Firewall.Builder addAllowed(int index, Allowed value)

The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection.

repeated .google.cloud.compute.v1.Allowed allowed = 162398632;

Parameters
Name Description
index int
value Allowed
Returns
Type Description
Firewall.Builder

addAllowed(int index, Allowed.Builder builderForValue)

public Firewall.Builder addAllowed(int index, Allowed.Builder builderForValue)

The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection.

repeated .google.cloud.compute.v1.Allowed allowed = 162398632;

Parameters
Name Description
index int
builderForValue Allowed.Builder
Returns
Type Description
Firewall.Builder

addAllowedBuilder()

public Allowed.Builder addAllowedBuilder()

The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection.

repeated .google.cloud.compute.v1.Allowed allowed = 162398632;

Returns
Type Description
Allowed.Builder

addAllowedBuilder(int index)

public Allowed.Builder addAllowedBuilder(int index)

The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection.

repeated .google.cloud.compute.v1.Allowed allowed = 162398632;

Parameter
Name Description
index int
Returns
Type Description
Allowed.Builder

addDenied(Denied value)

public Firewall.Builder addDenied(Denied value)

The list of DENY rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a denied connection.

repeated .google.cloud.compute.v1.Denied denied = 275217307;

Parameter
Name Description
value Denied
Returns
Type Description
Firewall.Builder

addDenied(Denied.Builder builderForValue)

public Firewall.Builder addDenied(Denied.Builder builderForValue)

The list of DENY rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a denied connection.

repeated .google.cloud.compute.v1.Denied denied = 275217307;

Parameter
Name Description
builderForValue Denied.Builder
Returns
Type Description
Firewall.Builder

addDenied(int index, Denied value)

public Firewall.Builder addDenied(int index, Denied value)

The list of DENY rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a denied connection.

repeated .google.cloud.compute.v1.Denied denied = 275217307;

Parameters
Name Description
index int
value Denied
Returns
Type Description
Firewall.Builder

addDenied(int index, Denied.Builder builderForValue)

public Firewall.Builder addDenied(int index, Denied.Builder builderForValue)

The list of DENY rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a denied connection.

repeated .google.cloud.compute.v1.Denied denied = 275217307;

Parameters
Name Description
index int
builderForValue Denied.Builder
Returns
Type Description
Firewall.Builder

addDeniedBuilder()

public Denied.Builder addDeniedBuilder()

The list of DENY rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a denied connection.

repeated .google.cloud.compute.v1.Denied denied = 275217307;

Returns
Type Description
Denied.Builder

addDeniedBuilder(int index)

public Denied.Builder addDeniedBuilder(int index)

The list of DENY rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a denied connection.

repeated .google.cloud.comp