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

namespace Google\Cloud\NetworkServices\V1\HttpRoute;

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

/**
 * Specifies how to match traffic and how to route traffic when traffic is
 * matched.
 *
 * Generated from protobuf message <code>google.cloud.networkservices.v1.HttpRoute.RouteRule</code>
 */
class RouteRule extends \Google\Protobuf\Internal\Message
{
    /**
     * A list of matches define conditions used for matching the rule against
     * incoming HTTP requests. Each match is independent, i.e. this rule will be
     * matched if ANY one of the matches is satisfied.
     * If no matches field is specified, this rule will unconditionally match
     * traffic.
     * If a default rule is desired to be configured, add a rule with no matches
     * specified to the end of the rules list.
     *
     * Generated from protobuf field <code>repeated .google.cloud.networkservices.v1.HttpRoute.RouteMatch matches = 1;</code>
     */
    private $matches;
    /**
     * The detailed rule defining how to route matched traffic.
     *
     * Generated from protobuf field <code>.google.cloud.networkservices.v1.HttpRoute.RouteAction action = 2;</code>
     */
    protected $action = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type array<\Google\Cloud\NetworkServices\V1\HttpRoute\RouteMatch>|\Google\Protobuf\Internal\RepeatedField $matches
     *           A list of matches define conditions used for matching the rule against
     *           incoming HTTP requests. Each match is independent, i.e. this rule will be
     *           matched if ANY one of the matches is satisfied.
     *           If no matches field is specified, this rule will unconditionally match
     *           traffic.
     *           If a default rule is desired to be configured, add a rule with no matches
     *           specified to the end of the rules list.
     *     @type \Google\Cloud\NetworkServices\V1\HttpRoute\RouteAction $action
     *           The detailed rule defining how to route matched traffic.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Networkservices\V1\HttpRoute::initOnce();
        parent::__construct($data);
    }

    /**
     * A list of matches define conditions used for matching the rule against
     * incoming HTTP requests. Each match is independent, i.e. this rule will be
     * matched if ANY one of the matches is satisfied.
     * If no matches field is specified, this rule will unconditionally match
     * traffic.
     * If a default rule is desired to be configured, add a rule with no matches
     * specified to the end of the rules list.
     *
     * Generated from protobuf field <code>repeated .google.cloud.networkservices.v1.HttpRoute.RouteMatch matches = 1;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getMatches()
    {
        return $this->matches;
    }

    /**
     * A list of matches define conditions used for matching the rule against
     * incoming HTTP requests. Each match is independent, i.e. this rule will be
     * matched if ANY one of the matches is satisfied.
     * If no matches field is specified, this rule will unconditionally match
     * traffic.
     * If a default rule is desired to be configured, add a rule with no matches
     * specified to the end of the rules list.
     *
     * Generated from protobuf field <code>repeated .google.cloud.networkservices.v1.HttpRoute.RouteMatch matches = 1;</code>
     * @param array<\Google\Cloud\NetworkServices\V1\HttpRoute\RouteMatch>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setMatches($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\NetworkServices\V1\HttpRoute\RouteMatch::class);
        $this->matches = $arr;

        return $this;
    }

    /**
     * The detailed rule defining how to route matched traffic.
     *
     * Generated from protobuf field <code>.google.cloud.networkservices.v1.HttpRoute.RouteAction action = 2;</code>
     * @return \Google\Cloud\NetworkServices\V1\HttpRoute\RouteAction|null
     */
    public function getAction()
    {
        return $this->action;
    }

    public function hasAction()
    {
        return isset($this->action);
    }

    public function clearAction()
    {
        unset($this->action);
    }

    /**
     * The detailed rule defining how to route matched traffic.
     *
     * Generated from protobuf field <code>.google.cloud.networkservices.v1.HttpRoute.RouteAction action = 2;</code>
     * @param \Google\Cloud\NetworkServices\V1\HttpRoute\RouteAction $var
     * @return $this
     */
    public function setAction($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\NetworkServices\V1\HttpRoute\RouteAction::class);
        $this->action = $var;

        return $this;
    }

}


