<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/monitoring/v3/alert.proto

namespace Google\Cloud\Monitoring\V3\AlertPolicy\Condition;

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

/**
 * Specifies how many time series must fail a predicate to trigger a
 * condition. If not specified, then a `{count: 1}` trigger is used.
 *
 * Generated from protobuf message <code>google.monitoring.v3.AlertPolicy.Condition.Trigger</code>
 */
class Trigger extends \Google\Protobuf\Internal\Message
{
    protected $type;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type int $count
     *           The absolute number of time series that must fail
     *           the predicate for the condition to be triggered.
     *     @type float $percent
     *           The percentage of time series that must fail the
     *           predicate for the condition to be triggered.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Monitoring\V3\Alert::initOnce();
        parent::__construct($data);
    }

    /**
     * The absolute number of time series that must fail
     * the predicate for the condition to be triggered.
     *
     * Generated from protobuf field <code>int32 count = 1;</code>
     * @return int
     */
    public function getCount()
    {
        return $this->readOneof(1);
    }

    /**
     * The absolute number of time series that must fail
     * the predicate for the condition to be triggered.
     *
     * Generated from protobuf field <code>int32 count = 1;</code>
     * @param int $var
     * @return $this
     */
    public function setCount($var)
    {
        GPBUtil::checkInt32($var);
        $this->writeOneof(1, $var);

        return $this;
    }

    /**
     * The percentage of time series that must fail the
     * predicate for the condition to be triggered.
     *
     * Generated from protobuf field <code>double percent = 2;</code>
     * @return float
     */
    public function getPercent()
    {
        return $this->readOneof(2);
    }

    /**
     * The percentage of time series that must fail the
     * predicate for the condition to be triggered.
     *
     * Generated from protobuf field <code>double percent = 2;</code>
     * @param float $var
     * @return $this
     */
    public function setPercent($var)
    {
        GPBUtil::checkDouble($var);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * @return string
     */
    public function getType()
    {
        return $this->whichOneof("type");
    }

}

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(Trigger::class, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_Trigger::class);

