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

namespace Google\Cloud\Sql\V1beta4;

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

/**
 * We currently only support backup retention by specifying the number
 * of backups we will retain.
 *
 * Generated from protobuf message <code>google.cloud.sql.v1beta4.BackupRetentionSettings</code>
 */
class BackupRetentionSettings extends \Google\Protobuf\Internal\Message
{
    /**
     * The unit that 'retained_backups' represents.
     *
     * Generated from protobuf field <code>.google.cloud.sql.v1beta4.BackupRetentionSettings.RetentionUnit retention_unit = 1;</code>
     */
    private $retention_unit = 0;
    /**
     * Depending on the value of retention_unit, this is used to determine
     * if a backup needs to be deleted.  If retention_unit is 'COUNT', we will
     * retain this many backups.
     *
     * Generated from protobuf field <code>.google.protobuf.Int32Value retained_backups = 2;</code>
     */
    private $retained_backups = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type int $retention_unit
     *           The unit that 'retained_backups' represents.
     *     @type \Google\Protobuf\Int32Value $retained_backups
     *           Depending on the value of retention_unit, this is used to determine
     *           if a backup needs to be deleted.  If retention_unit is 'COUNT', we will
     *           retain this many backups.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Sql\V1Beta4\CloudSqlResources::initOnce();
        parent::__construct($data);
    }

    /**
     * The unit that 'retained_backups' represents.
     *
     * Generated from protobuf field <code>.google.cloud.sql.v1beta4.BackupRetentionSettings.RetentionUnit retention_unit = 1;</code>
     * @return int
     */
    public function getRetentionUnit()
    {
        return $this->retention_unit;
    }

    /**
     * The unit that 'retained_backups' represents.
     *
     * Generated from protobuf field <code>.google.cloud.sql.v1beta4.BackupRetentionSettings.RetentionUnit retention_unit = 1;</code>
     * @param int $var
     * @return $this
     */
    public function setRetentionUnit($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Sql\V1beta4\BackupRetentionSettings\RetentionUnit::class);
        $this->retention_unit = $var;

        return $this;
    }

    /**
     * Depending on the value of retention_unit, this is used to determine
     * if a backup needs to be deleted.  If retention_unit is 'COUNT', we will
     * retain this many backups.
     *
     * Generated from protobuf field <code>.google.protobuf.Int32Value retained_backups = 2;</code>
     * @return \Google\Protobuf\Int32Value|null
     */
    public function getRetainedBackups()
    {
        return $this->retained_backups;
    }

    public function hasRetainedBackups()
    {
        return isset($this->retained_backups);
    }

    public function clearRetainedBackups()
    {
        unset($this->retained_backups);
    }

    /**
     * Returns the unboxed value from <code>getRetainedBackups()</code>

     * Depending on the value of retention_unit, this is used to determine
     * if a backup needs to be deleted.  If retention_unit is 'COUNT', we will
     * retain this many backups.
     *
     * Generated from protobuf field <code>.google.protobuf.Int32Value retained_backups = 2;</code>
     * @return int|null
     */
    public function getRetainedBackupsValue()
    {
        return $this->readWrapperValue("retained_backups");
    }

    /**
     * Depending on the value of retention_unit, this is used to determine
     * if a backup needs to be deleted.  If retention_unit is 'COUNT', we will
     * retain this many backups.
     *
     * Generated from protobuf field <code>.google.protobuf.Int32Value retained_backups = 2;</code>
     * @param \Google\Protobuf\Int32Value $var
     * @return $this
     */
    public function setRetainedBackups($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Int32Value::class);
        $this->retained_backups = $var;

        return $this;
    }

    /**
     * Sets the field by wrapping a primitive type in a Google\Protobuf\Int32Value object.

     * Depending on the value of retention_unit, this is used to determine
     * if a backup needs to be deleted.  If retention_unit is 'COUNT', we will
     * retain this many backups.
     *
     * Generated from protobuf field <code>.google.protobuf.Int32Value retained_backups = 2;</code>
     * @param int|null $var
     * @return $this
     */
    public function setRetainedBackupsValue($var)
    {
        $this->writeWrapperValue("retained_backups", $var);
        return $this;}

}

