<?php
/**
 * DeadmanCheck
 *
 * PHP version 5
 *
 * @category Class
 * @package  InfluxDB2
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * InfluxDB OSS API Service
 *
 * The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint.
 *
 * OpenAPI spec version: 2.0.0
 *
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 3.3.4
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace InfluxDB2\Model;
use \InfluxDB2\ObjectSerializer;

/**
 * DeadmanCheck Class Doc Comment
 *
 * @category Class
 * @package  InfluxDB2
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */
class DeadmanCheck extends Check
{
    const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $openAPIModelName = 'DeadmanCheck';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'type' => 'string',
        'time_since' => 'string',
        'stale_time' => 'string',
        'report_zero' => 'bool',
        'level' => '\InfluxDB2\Model\CheckStatusLevel',
        'every' => 'string',
        'offset' => 'string',
        'tags' => '\InfluxDB2\Model\ThresholdCheckTags[]',
        'status_message_template' => 'string'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPIFormats = [
        'type' => null,
        'time_since' => null,
        'stale_time' => null,
        'report_zero' => null,
        'level' => null,
        'every' => null,
        'offset' => null,
        'tags' => null,
        'status_message_template' => null
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPITypes()
    {
        return self::$openAPITypes + parent::openAPITypes();
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPIFormats()
    {
        return self::$openAPIFormats + parent::openAPIFormats();
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'type' => 'type',
        'time_since' => 'timeSince',
        'stale_time' => 'staleTime',
        'report_zero' => 'reportZero',
        'level' => 'level',
        'every' => 'every',
        'offset' => 'offset',
        'tags' => 'tags',
        'status_message_template' => 'statusMessageTemplate'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'type' => 'setType',
        'time_since' => 'setTimeSince',
        'stale_time' => 'setStaleTime',
        'report_zero' => 'setReportZero',
        'level' => 'setLevel',
        'every' => 'setEvery',
        'offset' => 'setOffset',
        'tags' => 'setTags',
        'status_message_template' => 'setStatusMessageTemplate'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'type' => 'getType',
        'time_since' => 'getTimeSince',
        'stale_time' => 'getStaleTime',
        'report_zero' => 'getReportZero',
        'level' => 'getLevel',
        'every' => 'getEvery',
        'offset' => 'getOffset',
        'tags' => 'getTags',
        'status_message_template' => 'getStatusMessageTemplate'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return parent::attributeMap() + self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return parent::setters() + self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return parent::getters() + self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$openAPIModelName;
    }

    const TYPE_DEADMAN = 'deadman';



    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getTypeAllowableValues()
    {
        return [
            self::TYPE_DEADMAN,
        ];
    }



    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        parent::__construct($data);

        $this->container['type'] = isset($data['type']) ? $data['type'] : "deadman";
        $this->container['time_since'] = isset($data['time_since']) ? $data['time_since'] : null;
        $this->container['stale_time'] = isset($data['stale_time']) ? $data['stale_time'] : null;
        $this->container['report_zero'] = isset($data['report_zero']) ? $data['report_zero'] : null;
        $this->container['level'] = isset($data['level']) ? $data['level'] : null;
        $this->container['every'] = isset($data['every']) ? $data['every'] : null;
        $this->container['offset'] = isset($data['offset']) ? $data['offset'] : null;
        $this->container['tags'] = isset($data['tags']) ? $data['tags'] : null;
        $this->container['status_message_template'] = isset($data['status_message_template']) ? $data['status_message_template'] : null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = parent::listInvalidProperties();

        if ($this->container['type'] === null) {
            $invalidProperties[] = "'type' can't be null";
        }
        $allowedValues = $this->getTypeAllowableValues();
        if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'type', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets type
     *
     * @return string
     */
    public function getType()
    {
        return $this->container['type'];
    }

    /**
     * Sets type
     *
     * @param string $type type
     *
     * @return $this
     */
    public function setType($type)
    {
        $allowedValues = $this->getTypeAllowableValues();
        if (!in_array($type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['type'] = $type;

        return $this;
    }

    /**
     * Gets time_since
     *
     * @return string|null
     */
    public function getTimeSince()
    {
        return $this->container['time_since'];
    }

    /**
     * Sets time_since
     *
     * @param string|null $time_since String duration before deadman triggers.
     *
     * @return $this
     */
    public function setTimeSince($time_since)
    {
        $this->container['time_since'] = $time_since;

        return $this;
    }

    /**
     * Gets stale_time
     *
     * @return string|null
     */
    public function getStaleTime()
    {
        return $this->container['stale_time'];
    }

    /**
     * Sets stale_time
     *
     * @param string|null $stale_time String duration for time that a series is considered stale and should not trigger deadman.
     *
     * @return $this
     */
    public function setStaleTime($stale_time)
    {
        $this->container['stale_time'] = $stale_time;

        return $this;
    }

    /**
     * Gets report_zero
     *
     * @return bool|null
     */
    public function getReportZero()
    {
        return $this->container['report_zero'];
    }

    /**
     * Sets report_zero
     *
     * @param bool|null $report_zero If only zero values reported since time, trigger an alert
     *
     * @return $this
     */
    public function setReportZero($report_zero)
    {
        $this->container['report_zero'] = $report_zero;

        return $this;
    }

    /**
     * Gets level
     *
     * @return \InfluxDB2\Model\CheckStatusLevel|null
     */
    public function getLevel()
    {
        return $this->container['level'];
    }

    /**
     * Sets level
     *
     * @param \InfluxDB2\Model\CheckStatusLevel|null $level level
     *
     * @return $this
     */
    public function setLevel($level)
    {
        $this->container['level'] = $level;

        return $this;
    }

    /**
     * Gets every
     *
     * @return string|null
     */
    public function getEvery()
    {
        return $this->container['every'];
    }

    /**
     * Sets every
     *
     * @param string|null $every Check repetition interval.
     *
     * @return $this
     */
    public function setEvery($every)
    {
        $this->container['every'] = $every;

        return $this;
    }

    /**
     * Gets offset
     *
     * @return string|null
     */
    public function getOffset()
    {
        return $this->container['offset'];
    }

    /**
     * Sets offset
     *
     * @param string|null $offset Duration to delay after the schedule, before executing check.
     *
     * @return $this
     */
    public function setOffset($offset)
    {
        $this->container['offset'] = $offset;

        return $this;
    }

    /**
     * Gets tags
     *
     * @return \InfluxDB2\Model\ThresholdCheckTags[]|null
     */
    public function getTags()
    {
        return $this->container['tags'];
    }

    /**
     * Sets tags
     *
     * @param \InfluxDB2\Model\ThresholdCheckTags[]|null $tags List of tags to write to each status.
     *
     * @return $this
     */
    public function setTags($tags)
    {
        $this->container['tags'] = $tags;

        return $this;
    }

    /**
     * Gets status_message_template
     *
     * @return string|null
     */
    public function getStatusMessageTemplate()
    {
        return $this->container['status_message_template'];
    }

    /**
     * Sets status_message_template
     *
     * @param string|null $status_message_template The template used to generate and write a status message.
     *
     * @return $this
     */
    public function setStatusMessageTemplate($status_message_template)
    {
        $this->container['status_message_template'] = $status_message_template;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

    /**
     * Sets value based on offset.
     *
     * @param integer $offset Offset
     * @param mixed   $value  Value to be set
     *
     * @return void
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }
}


