# Google Cloud Security Command Center V2 Client - Class IpRule (2.5.1)

2.5.1 (latest) 2.5.0 2.4.2 2.3.0 2.2.1 2.1.1 2.0.4 1.32.0 1.31.0 1.30.0 1.29.0 1.28.2 1.21.0 1.20.2 1.19.1 1.18.0 1.17.0 1.16.0 1.15.1 1.14.2 1.13.1 Reference documentation and code samples for the Google Cloud Security Command Center V2 Client class IpRule.

IP rule information.

Generated from protobuf message `google.cloud.securitycenter.v2.IpRule`

## Namespace

Google \\ Cloud \\ SecurityCenter \\ V2

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ protocol` | `string` The IP protocol this rule applies to. This value can either be one of the following well known protocol strings (TCP, UDP, ICMP, ESP, AH, IPIP, SCTP) or a string representation of the integer value. |
| `↳ port_ranges` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-security-center/latest/V2.IpRule.PortRange>` Optional. An optional list of ports to which this rule applies. This field is only applicable for the UDP or (S)TCP protocols. Each entry must be either an integer or a range including a min and max port number. |

### getProtocol

The IP protocol this rule applies to. This value can either be one of the
following well known protocol strings (TCP, UDP, ICMP, ESP, AH, IPIP,
SCTP) or a string representation of the integer value.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setProtocol

The IP protocol this rule applies to. This value can either be one of the
following well known protocol strings (TCP, UDP, ICMP, ESP, AH, IPIP,
SCTP) or a string representation of the integer value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getPortRanges

Optional. An optional list of ports to which this rule applies. This field
is only applicable for the UDP or (S)TCP protocols. Each entry must be
either an integer or a range including a min and max port number.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-security-center/latest/V2.IpRule.PortRange>` |   |

### setPortRanges

Optional. An optional list of ports to which this rule applies. This field
is only applicable for the UDP or (S)TCP protocols. Each entry must be
either an integer or a range including a min and max port number.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-security-center/latest/V2.IpRule.PortRange>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |