# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import warnings
import pulumi
import pulumi.runtime
from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
from .. import _utilities, _tables

__all__ = ['BackupPolicy']


class BackupPolicy(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 archive_backup_keep_count: Optional[pulumi.Input[float]] = None,
                 archive_backup_keep_policy: Optional[pulumi.Input[str]] = None,
                 archive_backup_retention_period: Optional[pulumi.Input[float]] = None,
                 backup_periods: Optional[pulumi.Input[List[pulumi.Input[str]]]] = None,
                 backup_retention_period: Optional[pulumi.Input[float]] = None,
                 backup_time: Optional[pulumi.Input[str]] = None,
                 compress_type: Optional[pulumi.Input[str]] = None,
                 enable_backup_log: Optional[pulumi.Input[bool]] = None,
                 high_space_usage_protection: Optional[pulumi.Input[str]] = None,
                 instance_id: Optional[pulumi.Input[str]] = None,
                 local_log_retention_hours: Optional[pulumi.Input[float]] = None,
                 local_log_retention_space: Optional[pulumi.Input[float]] = None,
                 log_backup: Optional[pulumi.Input[bool]] = None,
                 log_backup_frequency: Optional[pulumi.Input[str]] = None,
                 log_backup_retention_period: Optional[pulumi.Input[float]] = None,
                 log_retention_period: Optional[pulumi.Input[float]] = None,
                 preferred_backup_periods: Optional[pulumi.Input[List[pulumi.Input[str]]]] = None,
                 preferred_backup_time: Optional[pulumi.Input[str]] = None,
                 retention_period: Optional[pulumi.Input[float]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Provides an RDS instance backup policy resource and used to configure instance backup policy.

        > **NOTE:** Each DB instance has a backup policy and it will be set default values when destroying the resource.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        creation = config.get("creation")
        if creation is None:
            creation = "Rds"
        name = config.get("name")
        if name is None:
            name = "dbbackuppolicybasic"
        default_zones = alicloud.get_zones(available_resource_creation=creation)
        default_network = alicloud.vpc.Network("defaultNetwork", cidr_block="172.16.0.0/16")
        default_switch = alicloud.vpc.Switch("defaultSwitch",
            vpc_id=default_network.id,
            cidr_block="172.16.0.0/24",
            availability_zone=default_zones.zones[0].id)
        instance = alicloud.rds.Instance("instance",
            engine="MySQL",
            engine_version="5.6",
            instance_type="rds.mysql.s1.small",
            instance_storage=10,
            vswitch_id=default_switch.id,
            instance_name=name)
        policy = alicloud.rds.BackupPolicy("policy", instance_id=instance.id)
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[float] archive_backup_keep_count: Instance archive backup keep count. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. When `archive_backup_keep_policy` is `ByMonth` Valid values: [1-31]. When `archive_backup_keep_policy` is `ByWeek` Valid values: [1-7].
        :param pulumi.Input[str] archive_backup_keep_policy: Instance archive backup keep policy. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. Valid values are `ByMonth`, `Disable`, `KeepAll`.
        :param pulumi.Input[float] archive_backup_retention_period: Instance archive backup retention days. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. Valid values: [30-1095], and `archive_backup_retention_period` must larger than `backup_retention_period` 730.
        :param pulumi.Input[List[pulumi.Input[str]]] backup_periods: It has been deprecated from version 1.69.0, and use field 'preferred_backup_period' instead.
        :param pulumi.Input[float] backup_retention_period: Instance backup retention days. Valid values: [7-730]. Default to 7. But mysql local disk is unlimited.
        :param pulumi.Input[str] backup_time: It has been deprecated from version 1.69.0, and use field 'preferred_backup_time' instead.
        :param pulumi.Input[str] compress_type: The compress type of instance policy. Valid values are `1`, `4`, `8`.
        :param pulumi.Input[bool] enable_backup_log: Whether to backup instance log. Valid values are `true`, `false`, Default to `true`. Note: The 'Basic Edition' category Rds instance does not support setting log backup. [What is Basic Edition](https://www.alibabacloud.com/help/doc-detail/48980.htm).
        :param pulumi.Input[str] high_space_usage_protection: Instance high space usage protection policy. Valid when the `enable_backup_log` is `true`. Valid values are `Enable`, `Disable`.
        :param pulumi.Input[str] instance_id: The Id of instance that can run database.
        :param pulumi.Input[float] local_log_retention_hours: Instance log backup local retention hours. Valid when the `enable_backup_log` is `true`. Valid values: [0-7*24].
        :param pulumi.Input[float] local_log_retention_space: Instance log backup local retention space. Valid when the `enable_backup_log` is `true`. Valid values: [5-50].
        :param pulumi.Input[bool] log_backup: It has been deprecated from version 1.68.0, and use field 'enable_backup_log' instead.
        :param pulumi.Input[str] log_backup_frequency: Instance log backup frequency. Valid when the instance engine is `SQLServer`. Valid values are `LogInterval`.
        :param pulumi.Input[float] log_backup_retention_period: Instance log backup retention days. Valid when the `enable_backup_log` is `1`. Valid values: [7-730]. Default to 7. It cannot be larger than `backup_retention_period`.
        :param pulumi.Input[float] log_retention_period: It has been deprecated from version 1.69.0, and use field 'log_backup_retention_period' instead.
        :param pulumi.Input[List[pulumi.Input[str]]] preferred_backup_periods: DB Instance backup period. Please set at least two days to ensure backing up at least twice a week. Valid values: [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]. Default to ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].
        :param pulumi.Input[str] preferred_backup_time: DB instance backup time, in the format of HH:mmZ- HH:mmZ. Time setting interval is one hour. Default to "02:00Z-03:00Z". China time is 8 hours behind it.
        :param pulumi.Input[float] retention_period: It has been deprecated from version 1.69.0, and use field 'backup_retention_period' instead.
        """
        if __name__ is not None:
            warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
            resource_name = __name__
        if __opts__ is not None:
            warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
            opts = __opts__
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = _utilities.get_version()
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = dict()

            __props__['archive_backup_keep_count'] = archive_backup_keep_count
            __props__['archive_backup_keep_policy'] = archive_backup_keep_policy
            __props__['archive_backup_retention_period'] = archive_backup_retention_period
            if backup_periods is not None:
                warnings.warn("Attribute 'backup_period' has been deprecated from version 1.69.0. Use `preferred_backup_period` instead", DeprecationWarning)
                pulumi.log.warn("backup_periods is deprecated: Attribute 'backup_period' has been deprecated from version 1.69.0. Use `preferred_backup_period` instead")
            __props__['backup_periods'] = backup_periods
            __props__['backup_retention_period'] = backup_retention_period
            if backup_time is not None:
                warnings.warn("Attribute 'backup_time' has been deprecated from version 1.69.0. Use `preferred_backup_time` instead", DeprecationWarning)
                pulumi.log.warn("backup_time is deprecated: Attribute 'backup_time' has been deprecated from version 1.69.0. Use `preferred_backup_time` instead")
            __props__['backup_time'] = backup_time
            __props__['compress_type'] = compress_type
            __props__['enable_backup_log'] = enable_backup_log
            __props__['high_space_usage_protection'] = high_space_usage_protection
            if instance_id is None:
                raise TypeError("Missing required property 'instance_id'")
            __props__['instance_id'] = instance_id
            __props__['local_log_retention_hours'] = local_log_retention_hours
            __props__['local_log_retention_space'] = local_log_retention_space
            if log_backup is not None:
                warnings.warn("Attribute 'log_backup' has been deprecated from version 1.68.0. Use `enable_backup_log` instead", DeprecationWarning)
                pulumi.log.warn("log_backup is deprecated: Attribute 'log_backup' has been deprecated from version 1.68.0. Use `enable_backup_log` instead")
            __props__['log_backup'] = log_backup
            __props__['log_backup_frequency'] = log_backup_frequency
            __props__['log_backup_retention_period'] = log_backup_retention_period
            if log_retention_period is not None:
                warnings.warn("Attribute 'log_retention_period' has been deprecated from version 1.69.0. Use `log_backup_retention_period` instead", DeprecationWarning)
                pulumi.log.warn("log_retention_period is deprecated: Attribute 'log_retention_period' has been deprecated from version 1.69.0. Use `log_backup_retention_period` instead")
            __props__['log_retention_period'] = log_retention_period
            __props__['preferred_backup_periods'] = preferred_backup_periods
            __props__['preferred_backup_time'] = preferred_backup_time
            if retention_period is not None:
                warnings.warn("Attribute 'retention_period' has been deprecated from version 1.69.0. Use `backup_retention_period` instead", DeprecationWarning)
                pulumi.log.warn("retention_period is deprecated: Attribute 'retention_period' has been deprecated from version 1.69.0. Use `backup_retention_period` instead")
            __props__['retention_period'] = retention_period
        super(BackupPolicy, __self__).__init__(
            'alicloud:rds/backupPolicy:BackupPolicy',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            archive_backup_keep_count: Optional[pulumi.Input[float]] = None,
            archive_backup_keep_policy: Optional[pulumi.Input[str]] = None,
            archive_backup_retention_period: Optional[pulumi.Input[float]] = None,
            backup_periods: Optional[pulumi.Input[List[pulumi.Input[str]]]] = None,
            backup_retention_period: Optional[pulumi.Input[float]] = None,
            backup_time: Optional[pulumi.Input[str]] = None,
            compress_type: Optional[pulumi.Input[str]] = None,
            enable_backup_log: Optional[pulumi.Input[bool]] = None,
            high_space_usage_protection: Optional[pulumi.Input[str]] = None,
            instance_id: Optional[pulumi.Input[str]] = None,
            local_log_retention_hours: Optional[pulumi.Input[float]] = None,
            local_log_retention_space: Optional[pulumi.Input[float]] = None,
            log_backup: Optional[pulumi.Input[bool]] = None,
            log_backup_frequency: Optional[pulumi.Input[str]] = None,
            log_backup_retention_period: Optional[pulumi.Input[float]] = None,
            log_retention_period: Optional[pulumi.Input[float]] = None,
            preferred_backup_periods: Optional[pulumi.Input[List[pulumi.Input[str]]]] = None,
            preferred_backup_time: Optional[pulumi.Input[str]] = None,
            retention_period: Optional[pulumi.Input[float]] = None) -> 'BackupPolicy':
        """
        Get an existing BackupPolicy resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[float] archive_backup_keep_count: Instance archive backup keep count. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. When `archive_backup_keep_policy` is `ByMonth` Valid values: [1-31]. When `archive_backup_keep_policy` is `ByWeek` Valid values: [1-7].
        :param pulumi.Input[str] archive_backup_keep_policy: Instance archive backup keep policy. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. Valid values are `ByMonth`, `Disable`, `KeepAll`.
        :param pulumi.Input[float] archive_backup_retention_period: Instance archive backup retention days. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. Valid values: [30-1095], and `archive_backup_retention_period` must larger than `backup_retention_period` 730.
        :param pulumi.Input[List[pulumi.Input[str]]] backup_periods: It has been deprecated from version 1.69.0, and use field 'preferred_backup_period' instead.
        :param pulumi.Input[float] backup_retention_period: Instance backup retention days. Valid values: [7-730]. Default to 7. But mysql local disk is unlimited.
        :param pulumi.Input[str] backup_time: It has been deprecated from version 1.69.0, and use field 'preferred_backup_time' instead.
        :param pulumi.Input[str] compress_type: The compress type of instance policy. Valid values are `1`, `4`, `8`.
        :param pulumi.Input[bool] enable_backup_log: Whether to backup instance log. Valid values are `true`, `false`, Default to `true`. Note: The 'Basic Edition' category Rds instance does not support setting log backup. [What is Basic Edition](https://www.alibabacloud.com/help/doc-detail/48980.htm).
        :param pulumi.Input[str] high_space_usage_protection: Instance high space usage protection policy. Valid when the `enable_backup_log` is `true`. Valid values are `Enable`, `Disable`.
        :param pulumi.Input[str] instance_id: The Id of instance that can run database.
        :param pulumi.Input[float] local_log_retention_hours: Instance log backup local retention hours. Valid when the `enable_backup_log` is `true`. Valid values: [0-7*24].
        :param pulumi.Input[float] local_log_retention_space: Instance log backup local retention space. Valid when the `enable_backup_log` is `true`. Valid values: [5-50].
        :param pulumi.Input[bool] log_backup: It has been deprecated from version 1.68.0, and use field 'enable_backup_log' instead.
        :param pulumi.Input[str] log_backup_frequency: Instance log backup frequency. Valid when the instance engine is `SQLServer`. Valid values are `LogInterval`.
        :param pulumi.Input[float] log_backup_retention_period: Instance log backup retention days. Valid when the `enable_backup_log` is `1`. Valid values: [7-730]. Default to 7. It cannot be larger than `backup_retention_period`.
        :param pulumi.Input[float] log_retention_period: It has been deprecated from version 1.69.0, and use field 'log_backup_retention_period' instead.
        :param pulumi.Input[List[pulumi.Input[str]]] preferred_backup_periods: DB Instance backup period. Please set at least two days to ensure backing up at least twice a week. Valid values: [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]. Default to ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].
        :param pulumi.Input[str] preferred_backup_time: DB instance backup time, in the format of HH:mmZ- HH:mmZ. Time setting interval is one hour. Default to "02:00Z-03:00Z". China time is 8 hours behind it.
        :param pulumi.Input[float] retention_period: It has been deprecated from version 1.69.0, and use field 'backup_retention_period' instead.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["archive_backup_keep_count"] = archive_backup_keep_count
        __props__["archive_backup_keep_policy"] = archive_backup_keep_policy
        __props__["archive_backup_retention_period"] = archive_backup_retention_period
        __props__["backup_periods"] = backup_periods
        __props__["backup_retention_period"] = backup_retention_period
        __props__["backup_time"] = backup_time
        __props__["compress_type"] = compress_type
        __props__["enable_backup_log"] = enable_backup_log
        __props__["high_space_usage_protection"] = high_space_usage_protection
        __props__["instance_id"] = instance_id
        __props__["local_log_retention_hours"] = local_log_retention_hours
        __props__["local_log_retention_space"] = local_log_retention_space
        __props__["log_backup"] = log_backup
        __props__["log_backup_frequency"] = log_backup_frequency
        __props__["log_backup_retention_period"] = log_backup_retention_period
        __props__["log_retention_period"] = log_retention_period
        __props__["preferred_backup_periods"] = preferred_backup_periods
        __props__["preferred_backup_time"] = preferred_backup_time
        __props__["retention_period"] = retention_period
        return BackupPolicy(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="archiveBackupKeepCount")
    def archive_backup_keep_count(self) -> pulumi.Output[float]:
        """
        Instance archive backup keep count. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. When `archive_backup_keep_policy` is `ByMonth` Valid values: [1-31]. When `archive_backup_keep_policy` is `ByWeek` Valid values: [1-7].
        """
        return pulumi.get(self, "archive_backup_keep_count")

    @property
    @pulumi.getter(name="archiveBackupKeepPolicy")
    def archive_backup_keep_policy(self) -> pulumi.Output[str]:
        """
        Instance archive backup keep policy. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. Valid values are `ByMonth`, `Disable`, `KeepAll`.
        """
        return pulumi.get(self, "archive_backup_keep_policy")

    @property
    @pulumi.getter(name="archiveBackupRetentionPeriod")
    def archive_backup_retention_period(self) -> pulumi.Output[float]:
        """
        Instance archive backup retention days. Valid when the `enable_backup_log` is `true` and instance is mysql local disk. Valid values: [30-1095], and `archive_backup_retention_period` must larger than `backup_retention_period` 730.
        """
        return pulumi.get(self, "archive_backup_retention_period")

    @property
    @pulumi.getter(name="backupPeriods")
    def backup_periods(self) -> pulumi.Output[List[str]]:
        """
        It has been deprecated from version 1.69.0, and use field 'preferred_backup_period' instead.
        """
        return pulumi.get(self, "backup_periods")

    @property
    @pulumi.getter(name="backupRetentionPeriod")
    def backup_retention_period(self) -> pulumi.Output[Optional[float]]:
        """
        Instance backup retention days. Valid values: [7-730]. Default to 7. But mysql local disk is unlimited.
        """
        return pulumi.get(self, "backup_retention_period")

    @property
    @pulumi.getter(name="backupTime")
    def backup_time(self) -> pulumi.Output[str]:
        """
        It has been deprecated from version 1.69.0, and use field 'preferred_backup_time' instead.
        """
        return pulumi.get(self, "backup_time")

    @property
    @pulumi.getter(name="compressType")
    def compress_type(self) -> pulumi.Output[str]:
        """
        The compress type of instance policy. Valid values are `1`, `4`, `8`.
        """
        return pulumi.get(self, "compress_type")

    @property
    @pulumi.getter(name="enableBackupLog")
    def enable_backup_log(self) -> pulumi.Output[bool]:
        """
        Whether to backup instance log. Valid values are `true`, `false`, Default to `true`. Note: The 'Basic Edition' category Rds instance does not support setting log backup. [What is Basic Edition](https://www.alibabacloud.com/help/doc-detail/48980.htm).
        """
        return pulumi.get(self, "enable_backup_log")

    @property
    @pulumi.getter(name="highSpaceUsageProtection")
    def high_space_usage_protection(self) -> pulumi.Output[Optional[str]]:
        """
        Instance high space usage protection policy. Valid when the `enable_backup_log` is `true`. Valid values are `Enable`, `Disable`.
        """
        return pulumi.get(self, "high_space_usage_protection")

    @property
    @pulumi.getter(name="instanceId")
    def instance_id(self) -> pulumi.Output[str]:
        """
        The Id of instance that can run database.
        """
        return pulumi.get(self, "instance_id")

    @property
    @pulumi.getter(name="localLogRetentionHours")
    def local_log_retention_hours(self) -> pulumi.Output[float]:
        """
        Instance log backup local retention hours. Valid when the `enable_backup_log` is `true`. Valid values: [0-7*24].
        """
        return pulumi.get(self, "local_log_retention_hours")

    @property
    @pulumi.getter(name="localLogRetentionSpace")
    def local_log_retention_space(self) -> pulumi.Output[float]:
        """
        Instance log backup local retention space. Valid when the `enable_backup_log` is `true`. Valid values: [5-50].
        """
        return pulumi.get(self, "local_log_retention_space")

    @property
    @pulumi.getter(name="logBackup")
    def log_backup(self) -> pulumi.Output[bool]:
        """
        It has been deprecated from version 1.68.0, and use field 'enable_backup_log' instead.
        """
        return pulumi.get(self, "log_backup")

    @property
    @pulumi.getter(name="logBackupFrequency")
    def log_backup_frequency(self) -> pulumi.Output[str]:
        """
        Instance log backup frequency. Valid when the instance engine is `SQLServer`. Valid values are `LogInterval`.
        """
        return pulumi.get(self, "log_backup_frequency")

    @property
    @pulumi.getter(name="logBackupRetentionPeriod")
    def log_backup_retention_period(self) -> pulumi.Output[float]:
        """
        Instance log backup retention days. Valid when the `enable_backup_log` is `1`. Valid values: [7-730]. Default to 7. It cannot be larger than `backup_retention_period`.
        """
        return pulumi.get(self, "log_backup_retention_period")

    @property
    @pulumi.getter(name="logRetentionPeriod")
    def log_retention_period(self) -> pulumi.Output[float]:
        """
        It has been deprecated from version 1.69.0, and use field 'log_backup_retention_period' instead.
        """
        return pulumi.get(self, "log_retention_period")

    @property
    @pulumi.getter(name="preferredBackupPeriods")
    def preferred_backup_periods(self) -> pulumi.Output[List[str]]:
        """
        DB Instance backup period. Please set at least two days to ensure backing up at least twice a week. Valid values: [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]. Default to ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].
        """
        return pulumi.get(self, "preferred_backup_periods")

    @property
    @pulumi.getter(name="preferredBackupTime")
    def preferred_backup_time(self) -> pulumi.Output[Optional[str]]:
        """
        DB instance backup time, in the format of HH:mmZ- HH:mmZ. Time setting interval is one hour. Default to "02:00Z-03:00Z". China time is 8 hours behind it.
        """
        return pulumi.get(self, "preferred_backup_time")

    @property
    @pulumi.getter(name="retentionPeriod")
    def retention_period(self) -> pulumi.Output[float]:
        """
        It has been deprecated from version 1.69.0, and use field 'backup_retention_period' instead.
        """
        return pulumi.get(self, "retention_period")

    def translate_output_property(self, prop):
        return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

    def translate_input_property(self, prop):
        return _tables.SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop

