<?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;

/**
 * A condition type that allows alert policies to be defined using
 * [Monitoring Query Language](https://cloud.google.com/monitoring/mql).
 *
 * Generated from protobuf message <code>google.monitoring.v3.AlertPolicy.Condition.MonitoringQueryLanguageCondition</code>
 */
class MonitoringQueryLanguageCondition extends \Google\Protobuf\Internal\Message
{
    /**
     * [Monitoring Query Language](https://cloud.google.com/monitoring/mql)
     * query that outputs a boolean stream.
     *
     * Generated from protobuf field <code>string query = 1;</code>
     */
    private $query = '';
    /**
     * The amount of time that a time series must violate the
     * threshold to be considered failing. Currently, only values
     * that are a multiple of a minute--e.g., 0, 60, 120, or 300
     * seconds--are supported. If an invalid value is given, an
     * error will be returned. When choosing a duration, it is useful to
     * keep in mind the frequency of the underlying time series data
     * (which may also be affected by any alignments specified in the
     * `aggregations` field); a good duration is long enough so that a single
     * outlier does not generate spurious alerts, but short enough that
     * unhealthy states are detected and alerted on quickly.
     *
     * Generated from protobuf field <code>.google.protobuf.Duration duration = 2;</code>
     */
    private $duration = null;
    /**
     * The number/percent of time series for which the comparison must hold
     * in order for the condition to trigger. If unspecified, then the
     * condition will trigger if the comparison is true for any of the
     * time series that have been identified by `filter` and `aggregations`,
     * or by the ratio, if `denominator_filter` and `denominator_aggregations`
     * are specified.
     *
     * Generated from protobuf field <code>.google.monitoring.v3.AlertPolicy.Condition.Trigger trigger = 3;</code>
     */
    private $trigger = null;
    /**
     * A condition control that determines how metric-threshold conditions
     * are evaluated when data stops arriving.
     *
     * Generated from protobuf field <code>.google.monitoring.v3.AlertPolicy.Condition.EvaluationMissingData evaluation_missing_data = 4;</code>
     */
    private $evaluation_missing_data = 0;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $query
     *           [Monitoring Query Language](https://cloud.google.com/monitoring/mql)
     *           query that outputs a boolean stream.
     *     @type \Google\Protobuf\Duration $duration
     *           The amount of time that a time series must violate the
     *           threshold to be considered failing. Currently, only values
     *           that are a multiple of a minute--e.g., 0, 60, 120, or 300
     *           seconds--are supported. If an invalid value is given, an
     *           error will be returned. When choosing a duration, it is useful to
     *           keep in mind the frequency of the underlying time series data
     *           (which may also be affected by any alignments specified in the
     *           `aggregations` field); a good duration is long enough so that a single
     *           outlier does not generate spurious alerts, but short enough that
     *           unhealthy states are detected and alerted on quickly.
     *     @type \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger $trigger
     *           The number/percent of time series for which the comparison must hold
     *           in order for the condition to trigger. If unspecified, then the
     *           condition will trigger if the comparison is true for any of the
     *           time series that have been identified by `filter` and `aggregations`,
     *           or by the ratio, if `denominator_filter` and `denominator_aggregations`
     *           are specified.
     *     @type int $evaluation_missing_data
     *           A condition control that determines how metric-threshold conditions
     *           are evaluated when data stops arriving.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Monitoring\V3\Alert::initOnce();
        parent::__construct($data);
    }

    /**
     * [Monitoring Query Language](https://cloud.google.com/monitoring/mql)
     * query that outputs a boolean stream.
     *
     * Generated from protobuf field <code>string query = 1;</code>
     * @return string
     */
    public function getQuery()
    {
        return $this->query;
    }

    /**
     * [Monitoring Query Language](https://cloud.google.com/monitoring/mql)
     * query that outputs a boolean stream.
     *
     * Generated from protobuf field <code>string query = 1;</code>
     * @param string $var
     * @return $this
     */
    public function setQuery($var)
    {
        GPBUtil::checkString($var, True);
        $this->query = $var;

        return $this;
    }

    /**
     * The amount of time that a time series must violate the
     * threshold to be considered failing. Currently, only values
     * that are a multiple of a minute--e.g., 0, 60, 120, or 300
     * seconds--are supported. If an invalid value is given, an
     * error will be returned. When choosing a duration, it is useful to
     * keep in mind the frequency of the underlying time series data
     * (which may also be affected by any alignments specified in the
     * `aggregations` field); a good duration is long enough so that a single
     * outlier does not generate spurious alerts, but short enough that
     * unhealthy states are detected and alerted on quickly.
     *
     * Generated from protobuf field <code>.google.protobuf.Duration duration = 2;</code>
     * @return \Google\Protobuf\Duration|null
     */
    public function getDuration()
    {
        return $this->duration;
    }

    public function hasDuration()
    {
        return isset($this->duration);
    }

    public function clearDuration()
    {
        unset($this->duration);
    }

    /**
     * The amount of time that a time series must violate the
     * threshold to be considered failing. Currently, only values
     * that are a multiple of a minute--e.g., 0, 60, 120, or 300
     * seconds--are supported. If an invalid value is given, an
     * error will be returned. When choosing a duration, it is useful to
     * keep in mind the frequency of the underlying time series data
     * (which may also be affected by any alignments specified in the
     * `aggregations` field); a good duration is long enough so that a single
     * outlier does not generate spurious alerts, but short enough that
     * unhealthy states are detected and alerted on quickly.
     *
     * Generated from protobuf field <code>.google.protobuf.Duration duration = 2;</code>
     * @param \Google\Protobuf\Duration $var
     * @return $this
     */
    public function setDuration($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class);
        $this->duration = $var;

        return $this;
    }

    /**
     * The number/percent of time series for which the comparison must hold
     * in order for the condition to trigger. If unspecified, then the
     * condition will trigger if the comparison is true for any of the
     * time series that have been identified by `filter` and `aggregations`,
     * or by the ratio, if `denominator_filter` and `denominator_aggregations`
     * are specified.
     *
     * Generated from protobuf field <code>.google.monitoring.v3.AlertPolicy.Condition.Trigger trigger = 3;</code>
     * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger|null
     */
    public function getTrigger()
    {
        return $this->trigger;
    }

    public function hasTrigger()
    {
        return isset($this->trigger);
    }

    public function clearTrigger()
    {
        unset($this->trigger);
    }

    /**
     * The number/percent of time series for which the comparison must hold
     * in order for the condition to trigger. If unspecified, then the
     * condition will trigger if the comparison is true for any of the
     * time series that have been identified by `filter` and `aggregations`,
     * or by the ratio, if `denominator_filter` and `denominator_aggregations`
     * are specified.
     *
     * Generated from protobuf field <code>.google.monitoring.v3.AlertPolicy.Condition.Trigger trigger = 3;</code>
     * @param \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger $var
     * @return $this
     */
    public function setTrigger($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger::class);
        $this->trigger = $var;

        return $this;
    }

    /**
     * A condition control that determines how metric-threshold conditions
     * are evaluated when data stops arriving.
     *
     * Generated from protobuf field <code>.google.monitoring.v3.AlertPolicy.Condition.EvaluationMissingData evaluation_missing_data = 4;</code>
     * @return int
     */
    public function getEvaluationMissingData()
    {
        return $this->evaluation_missing_data;
    }

    /**
     * A condition control that determines how metric-threshold conditions
     * are evaluated when data stops arriving.
     *
     * Generated from protobuf field <code>.google.monitoring.v3.AlertPolicy.Condition.EvaluationMissingData evaluation_missing_data = 4;</code>
     * @param int $var
     * @return $this
     */
    public function setEvaluationMissingData($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\EvaluationMissingData::class);
        $this->evaluation_missing_data = $var;

        return $this;
    }

}

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

