<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/compute/v1/compute.proto

namespace Google\Cloud\Compute\V1;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 *
 * Generated from protobuf message <code>google.cloud.compute.v1.FirewallPolicyRuleMatcherLayer4Config</code>
 */
class FirewallPolicyRuleMatcherLayer4Config extends \Google\Protobuf\Internal\Message
{
    /**
     * The IP protocol to which this rule applies. The protocol type is
     * required when creating a firewall rule. This value can either be
     * one of the following well known protocol strings (tcp,udp, icmp, esp,ah, ipip, sctp), or the IP
     * protocol number.
     *
     * Generated from protobuf field <code>optional string ip_protocol = 475958960;</code>
     */
    protected $ip_protocol = null;
    /**
     * An optional list of ports to which this rule applies. This field is
     * only applicable for UDP or TCP protocol. Each entry must be either
     * an integer or a range. If not specified, this rule applies to
     * connections through any port.
     * Example inputs include: ["22"],["80","443"], and ["12345-12349"].
     *
     * Generated from protobuf field <code>repeated string ports = 106854418;</code>
     */
    private $ports;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $ip_protocol
     *           The IP protocol to which this rule applies. The protocol type is
     *           required when creating a firewall rule. This value can either be
     *           one of the following well known protocol strings (tcp,udp, icmp, esp,ah, ipip, sctp), or the IP
     *           protocol number.
     *     @type array<string>|\Google\Protobuf\Internal\RepeatedField $ports
     *           An optional list of ports to which this rule applies. This field is
     *           only applicable for UDP or TCP protocol. Each entry must be either
     *           an integer or a range. If not specified, this rule applies to
     *           connections through any port.
     *           Example inputs include: ["22"],["80","443"], and ["12345-12349"].
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Compute\V1\Compute::initOnce();
        parent::__construct($data);
    }

    /**
     * The IP protocol to which this rule applies. The protocol type is
     * required when creating a firewall rule. This value can either be
     * one of the following well known protocol strings (tcp,udp, icmp, esp,ah, ipip, sctp), or the IP
     * protocol number.
     *
     * Generated from protobuf field <code>optional string ip_protocol = 475958960;</code>
     * @return string
     */
    public function getIpProtocol()
    {
        return isset($this->ip_protocol) ? $this->ip_protocol : '';
    }

    public function hasIpProtocol()
    {
        return isset($this->ip_protocol);
    }

    public function clearIpProtocol()
    {
        unset($this->ip_protocol);
    }

    /**
     * The IP protocol to which this rule applies. The protocol type is
     * required when creating a firewall rule. This value can either be
     * one of the following well known protocol strings (tcp,udp, icmp, esp,ah, ipip, sctp), or the IP
     * protocol number.
     *
     * Generated from protobuf field <code>optional string ip_protocol = 475958960;</code>
     * @param string $var
     * @return $this
     */
    public function setIpProtocol($var)
    {
        GPBUtil::checkString($var, True);
        $this->ip_protocol = $var;

        return $this;
    }

    /**
     * An optional list of ports to which this rule applies. This field is
     * only applicable for UDP or TCP protocol. Each entry must be either
     * an integer or a range. If not specified, this rule applies to
     * connections through any port.
     * Example inputs include: ["22"],["80","443"], and ["12345-12349"].
     *
     * Generated from protobuf field <code>repeated string ports = 106854418;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getPorts()
    {
        return $this->ports;
    }

    /**
     * An optional list of ports to which this rule applies. This field is
     * only applicable for UDP or TCP protocol. Each entry must be either
     * an integer or a range. If not specified, this rule applies to
     * connections through any port.
     * Example inputs include: ["22"],["80","443"], and ["12345-12349"].
     *
     * Generated from protobuf field <code>repeated string ports = 106854418;</code>
     * @param array<string>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setPorts($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->ports = $arr;

        return $this;
    }

}

