# This file is automatically generated by botocraft.  Do not edit directly.
# mypy: disable-error-code="index, override, assignment, union-attr, misc"
from botocraft.mixins.tags import TagsDictMixin
from botocraft.services.common import Tag
from .abstract import (
    Boto3Model,
    ReadonlyBoto3Model,
    PrimaryBoto3Model,
    ReadonlyPrimaryBoto3Model,
    Boto3ModelManager,
    ReadonlyBoto3ModelManager,
)
from botocraft.services.ec2 import Vpc, VpcManager
from typing import ClassVar, Type, Optional, Literal, Dict, List, Union, Any, cast
from botocraft.services.ec2 import SecurityGroup, SecurityGroupManager
from functools import cached_property
from botocraft.services.common import Filter
from .abstract import PrimaryBoto3ModelQuerySet
from datetime import datetime
from collections import OrderedDict
from pydantic import Field

# ===============
# Managers
# ===============


class DBInstanceManager(Boto3ModelManager):
    service_name: str = "rds"

    def create(
        self,
        model: "DBInstance",
        MasterUserPassword: str | None = None,
        VpcSecurityGroupIds: List[str] | None = None,
        DBSubnetGroupName: str | None = None,
        DBParameterGroupName: str | None = None,
        OptionGroupName: str | None = None,
        TdeCredentialPassword: str | None = None,
        Domain: str | None = None,
        DomainFqdn: str | None = None,
        DomainOu: str | None = None,
        DomainAuthSecretArn: str | None = None,
        DomainDnsIps: List[str] | None = None,
        DomainIAMRoleName: str | None = None,
        ManageMasterUserPassword: bool | None = None,
        MasterUserSecretKmsKeyId: str | None = None,
    ) -> "DBInstance":
        """
        Creates a new DB instance.

        Args:
            model: The :py:class:`DBInstance` to create.

        Keyword Args:
            MasterUserPassword: The password for the master user.
            VpcSecurityGroupIds: A list of Amazon EC2 VPC security groups to associate with this DB instance.
            DBSubnetGroupName: A DB subnet group to associate with this DB instance.
            DBParameterGroupName: The name of the DB parameter group to associate with this DB instance. If you don't specify a
                value, then Amazon RDS uses the default DB parameter group for the specified DB engine and version.
            OptionGroupName: The option group to associate the DB instance with.
            TdeCredentialPassword: The password for the given ARN from the key store in order to access the device.
            Domain: The Active Directory directory ID to create the DB instance in. Currently, you can create only Db2, MySQL,
                Microsoft SQL Server, Oracle, and PostgreSQL DB instances in an Active Directory Domain.
            DomainFqdn: The fully qualified domain name (FQDN) of an Active Directory domain.
            DomainOu: The Active Directory organizational unit for your DB instance to join.
            DomainAuthSecretArn: The ARN for the Secrets Manager secret with the credentials for the user joining the domain.
            DomainDnsIps: The IPv4 DNS IP addresses of your primary and secondary Active Directory domain controllers.
            DomainIAMRoleName: The name of the IAM role to use when making API calls to the Directory Service.
            ManageMasterUserPassword: Specifies whether to manage the master user password with Amazon Web Services Secrets
                Manager.
            MasterUserSecretKmsKeyId: The Amazon Web Services KMS key identifier to encrypt a secret that is automatically
                generated and managed in Amazon Web Services Secrets Manager.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            DBInstanceIdentifier=data.get("DBInstanceIdentifier"),
            DBInstanceClass=data.get("DBInstanceClass"),
            Engine=data.get("Engine"),
            DBName=data.get("DBName"),
            AllocatedStorage=data.get("AllocatedStorage"),
            MasterUsername=data.get("MasterUsername"),
            MasterUserPassword=self.serialize(MasterUserPassword),
            VpcSecurityGroupIds=self.serialize(VpcSecurityGroupIds),
            AvailabilityZone=data.get("AvailabilityZone"),
            DBSubnetGroupName=self.serialize(DBSubnetGroupName),
            PreferredMaintenanceWindow=data.get("PreferredMaintenanceWindow"),
            DBParameterGroupName=self.serialize(DBParameterGroupName),
            BackupRetentionPeriod=data.get("BackupRetentionPeriod"),
            PreferredBackupWindow=data.get("PreferredBackupWindow"),
            Port=data.get("DbInstancePort"),
            MultiAZ=data.get("MultiAZ"),
            EngineVersion=data.get("EngineVersion"),
            AutoMinorVersionUpgrade=data.get("AutoMinorVersionUpgrade"),
            LicenseModel=data.get("LicenseModel"),
            Iops=data.get("Iops"),
            OptionGroupName=self.serialize(OptionGroupName),
            CharacterSetName=data.get("CharacterSetName"),
            NcharCharacterSetName=data.get("NcharCharacterSetName"),
            PubliclyAccessible=data.get("PubliclyAccessible"),
            Tags=data.get("TagList"),
            DBClusterIdentifier=data.get("DBClusterIdentifier"),
            StorageType=data.get("StorageType"),
            TdeCredentialArn=data.get("TdeCredentialArn"),
            TdeCredentialPassword=self.serialize(TdeCredentialPassword),
            StorageEncrypted=data.get("StorageEncrypted"),
            KmsKeyId=data.get("KmsKeyId"),
            Domain=self.serialize(Domain),
            DomainFqdn=self.serialize(DomainFqdn),
            DomainOu=self.serialize(DomainOu),
            DomainAuthSecretArn=self.serialize(DomainAuthSecretArn),
            DomainDnsIps=self.serialize(DomainDnsIps),
            CopyTagsToSnapshot=data.get("CopyTagsToSnapshot"),
            MonitoringInterval=data.get("MonitoringInterval"),
            MonitoringRoleArn=data.get("MonitoringRoleArn"),
            DomainIAMRoleName=self.serialize(DomainIAMRoleName),
            PromotionTier=data.get("PromotionTier"),
            Timezone=data.get("Timezone"),
            EnableIAMDatabaseAuthentication=data.get(
                "IAMDatabaseAuthenticationEnabled"
            ),
            DatabaseInsightsMode=data.get("DatabaseInsightsMode"),
            EnablePerformanceInsights=data.get("PerformanceInsightsEnabled"),
            PerformanceInsightsKMSKeyId=data.get("PerformanceInsightsKMSKeyId"),
            PerformanceInsightsRetentionPeriod=data.get(
                "PerformanceInsightsRetentionPeriod"
            ),
            EnableCloudwatchLogsExports=data.get("EnabledCloudwatchLogsExports"),
            ProcessorFeatures=data.get("ProcessorFeatures"),
            DeletionProtection=data.get("DeletionProtection"),
            MaxAllocatedStorage=data.get("MaxAllocatedStorage"),
            EnableCustomerOwnedIp=data.get("CustomerOwnedIpEnabled"),
            CustomIamInstanceProfile=data.get("CustomIamInstanceProfile"),
            BackupTarget=data.get("BackupTarget"),
            NetworkType=data.get("NetworkType"),
            StorageThroughput=data.get("StorageThroughput"),
            ManageMasterUserPassword=self.serialize(ManageMasterUserPassword),
            MasterUserSecretKmsKeyId=self.serialize(MasterUserSecretKmsKeyId),
            CACertificateIdentifier=data.get("CACertificateIdentifier"),
            DBSystemId=data.get("DBSystemId"),
            DedicatedLogVolume=data.get("DedicatedLogVolume"),
            MultiTenant=data.get("MultiTenant"),
            EngineLifecycleSupport=data.get("EngineLifecycleSupport"),
        )
        _response = self.client.create_db_instance(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = CreateDBInstanceResult(**_response)

        self.sessionize(response.RDSDBInstance)
        return cast("DBInstance", response.RDSDBInstance)

    def update(
        self,
        model: "DBInstance",
        DBSubnetGroupName: str | None = None,
        VpcSecurityGroupIds: List[str] | None = None,
        ApplyImmediately: bool | None = None,
        MasterUserPassword: str | None = None,
        DBParameterGroupName: str | None = None,
        AllowMajorVersionUpgrade: bool | None = None,
        OptionGroupName: str | None = None,
        NewDBInstanceIdentifier: str | None = None,
        TdeCredentialPassword: str | None = None,
        Domain: str | None = None,
        DomainFqdn: str | None = None,
        DomainOu: str | None = None,
        DomainAuthSecretArn: str | None = None,
        DomainDnsIps: List[str] | None = None,
        DBPortNumber: int | None = None,
        DomainIAMRoleName: str | None = None,
        DisableDomain: bool | None = None,
        CloudwatchLogsExportConfiguration: Optional[
            "CloudwatchLogsExportConfiguration"
        ] = None,
        UseDefaultProcessorFeatures: bool | None = None,
        CertificateRotationRestart: bool | None = None,
        ResumeFullAutomationModeMinutes: int | None = None,
        ManageMasterUserPassword: bool | None = None,
        RotateMasterUserPassword: bool | None = None,
        MasterUserSecretKmsKeyId: str | None = None,
    ) -> "DBInstance":
        """
        Modifies settings for a DB instance. You can change one or more database
        configuration parameters by specifying these parameters and the new values in
        the request. To learn what modifications you can make to your DB instance, call
        ``DescribeValidDBInstanceModifications`` before you call ``ModifyDBInstance``.

        Args:
            model: The :py:class:`DBInstance` to update.

        Keyword Args:
            DBSubnetGroupName: The new DB subnet group for the DB instance. You can use this parameter to move your DB instance
                to a different VPC. If your DB instance isn't in a VPC, you can also use this parameter to move your DB instance
                into a VPC. For more information, see `Working with a DB instance in a VPC
                <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html#USER_VPC.Non-
                VPC2VPC>`_ in the *Amazon RDS User Guide*.
            VpcSecurityGroupIds: A list of Amazon EC2 VPC security groups to associate with this DB instance. This change is
                asynchronously applied as soon as possible.
            ApplyImmediately: Specifies whether the modifications in this request and any pending modifications are
                asynchronously applied as soon as possible, regardless of the ``PreferredMaintenanceWindow`` setting for the DB
                instance. By default, this parameter is disabled.
            MasterUserPassword: The new password for the master user.
            DBParameterGroupName: The name of the DB parameter group to apply to the DB instance.
            AllowMajorVersionUpgrade: Specifies whether major version upgrades are allowed. Changing this parameter doesn't
                result in an outage and the change is asynchronously applied as soon as possible.
            OptionGroupName: The option group to associate the DB instance with.
            NewDBInstanceIdentifier: The new identifier for the DB instance when renaming a DB instance. When you change the DB
                instance identifier, an instance reboot occurs immediately if you enable ``ApplyImmediately``, or will occur during
                the next maintenance window if you disable ``ApplyImmediately``. This value is stored as a lowercase string.
            TdeCredentialPassword: The password for the given ARN from the key store in order to access the device.
            Domain: The Active Directory directory ID to move the DB instance to. Specify ``none`` to remove the instance from
                its current domain. You must create the domain before this operation. Currently, you can create only Db2, MySQL,
                Microsoft SQL Server, Oracle, and PostgreSQL DB instances in an Active Directory Domain.
            DomainFqdn: The fully qualified domain name (FQDN) of an Active Directory domain.
            DomainOu: The Active Directory organizational unit for your DB instance to join.
            DomainAuthSecretArn: The ARN for the Secrets Manager secret with the credentials for the user joining the domain.
            DomainDnsIps: The IPv4 DNS IP addresses of your primary and secondary Active Directory domain controllers.
            DBPortNumber: The port number on which the database accepts connections.
            DomainIAMRoleName: The name of the IAM role to use when making API calls to the Directory Service.
            DisableDomain: Specifies whether to remove the DB instance from the Active Directory domain.
            CloudwatchLogsExportConfiguration: The log types to be enabled for export to CloudWatch Logs for a specific DB
                instance.
            UseDefaultProcessorFeatures: Specifies whether the DB instance class of the DB instance uses its default processor
                features.
            CertificateRotationRestart: Specifies whether the DB instance is restarted when you rotate your SSL/TLS certificate.
            ResumeFullAutomationModeMinutes: The number of minutes to pause the automation. When the time period ends, RDS
                Custom resumes full automation.
            ManageMasterUserPassword: Specifies whether to manage the master user password with Amazon Web Services Secrets
                Manager.
            RotateMasterUserPassword: Specifies whether to rotate the secret managed by Amazon Web Services Secrets Manager for
                the master user password.
            MasterUserSecretKmsKeyId: The Amazon Web Services KMS key identifier to encrypt a secret that is automatically
                generated and managed in Amazon Web Services Secrets Manager.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            DBInstanceIdentifier=data.get("DBInstanceIdentifier"),
            AllocatedStorage=data.get("AllocatedStorage"),
            DBInstanceClass=data.get("DBInstanceClass"),
            DBSubnetGroupName=self.serialize(DBSubnetGroupName),
            VpcSecurityGroupIds=self.serialize(VpcSecurityGroupIds),
            ApplyImmediately=self.serialize(ApplyImmediately),
            MasterUserPassword=self.serialize(MasterUserPassword),
            DBParameterGroupName=self.serialize(DBParameterGroupName),
            BackupRetentionPeriod=data.get("BackupRetentionPeriod"),
            PreferredBackupWindow=data.get("PreferredBackupWindow"),
            PreferredMaintenanceWindow=data.get("PreferredMaintenanceWindow"),
            MultiAZ=data.get("MultiAZ"),
            EngineVersion=data.get("EngineVersion"),
            AllowMajorVersionUpgrade=self.serialize(AllowMajorVersionUpgrade),
            AutoMinorVersionUpgrade=data.get("AutoMinorVersionUpgrade"),
            LicenseModel=data.get("LicenseModel"),
            Iops=data.get("Iops"),
            OptionGroupName=self.serialize(OptionGroupName),
            NewDBInstanceIdentifier=self.serialize(NewDBInstanceIdentifier),
            StorageType=data.get("StorageType"),
            TdeCredentialArn=data.get("TdeCredentialArn"),
            TdeCredentialPassword=self.serialize(TdeCredentialPassword),
            CACertificateIdentifier=data.get("CACertificateIdentifier"),
            Domain=self.serialize(Domain),
            DomainFqdn=self.serialize(DomainFqdn),
            DomainOu=self.serialize(DomainOu),
            DomainAuthSecretArn=self.serialize(DomainAuthSecretArn),
            DomainDnsIps=self.serialize(DomainDnsIps),
            CopyTagsToSnapshot=data.get("CopyTagsToSnapshot"),
            MonitoringInterval=data.get("MonitoringInterval"),
            DBPortNumber=self.serialize(DBPortNumber),
            PubliclyAccessible=data.get("PubliclyAccessible"),
            MonitoringRoleArn=data.get("MonitoringRoleArn"),
            DomainIAMRoleName=self.serialize(DomainIAMRoleName),
            DisableDomain=self.serialize(DisableDomain),
            PromotionTier=data.get("PromotionTier"),
            EnableIAMDatabaseAuthentication=data.get(
                "IAMDatabaseAuthenticationEnabled"
            ),
            DatabaseInsightsMode=data.get("DatabaseInsightsMode"),
            EnablePerformanceInsights=data.get("PerformanceInsightsEnabled"),
            PerformanceInsightsKMSKeyId=data.get("PerformanceInsightsKMSKeyId"),
            PerformanceInsightsRetentionPeriod=data.get(
                "PerformanceInsightsRetentionPeriod"
            ),
            CloudwatchLogsExportConfiguration=self.serialize(
                CloudwatchLogsExportConfiguration
            ),
            ProcessorFeatures=data.get("ProcessorFeatures"),
            UseDefaultProcessorFeatures=self.serialize(UseDefaultProcessorFeatures),
            DeletionProtection=data.get("DeletionProtection"),
            MaxAllocatedStorage=data.get("MaxAllocatedStorage"),
            CertificateRotationRestart=self.serialize(CertificateRotationRestart),
            ReplicaMode=data.get("ReplicaMode"),
            EnableCustomerOwnedIp=data.get("CustomerOwnedIpEnabled"),
            AwsBackupRecoveryPointArn=data.get("AwsBackupRecoveryPointArn"),
            AutomationMode=data.get("AutomationMode"),
            ResumeFullAutomationModeMinutes=self.serialize(
                ResumeFullAutomationModeMinutes
            ),
            NetworkType=data.get("NetworkType"),
            StorageThroughput=data.get("StorageThroughput"),
            ManageMasterUserPassword=self.serialize(ManageMasterUserPassword),
            RotateMasterUserPassword=self.serialize(RotateMasterUserPassword),
            MasterUserSecretKmsKeyId=self.serialize(MasterUserSecretKmsKeyId),
            Engine=data.get("Engine"),
            DedicatedLogVolume=data.get("DedicatedLogVolume"),
            MultiTenant=data.get("MultiTenant"),
        )
        _response = self.client.modify_db_instance(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = ModifyDBInstanceResult(**_response)

        self.sessionize(response.RDSDBInstance)
        return cast("DBInstance", response.RDSDBInstance)

    def delete(
        self,
        DBInstanceIdentifier: str,
        *,
        SkipFinalSnapshot: bool | None = None,
        FinalDBSnapshotIdentifier: str | None = None,
        DeleteAutomatedBackups: bool | None = None,
    ) -> "DBInstance":
        """
        Deletes a previously provisioned DB instance. When you delete a DB instance, all
        automated backups for that instance are deleted and can't be recovered. However,
        manual DB snapshots of the DB instance aren't deleted.

        Args:
            DBInstanceIdentifier: The DB instance identifier for the DB instance to be deleted. This parameter isn't case-
                sensitive.

        Keyword Args:
            SkipFinalSnapshot: Specifies whether to skip the creation of a final DB snapshot before deleting the instance. If
                you enable this parameter, RDS doesn't create a DB snapshot. If you don't enable this parameter, RDS creates a DB
                snapshot before the DB instance is deleted. By default, skip isn't enabled, and the DB snapshot is created.
            FinalDBSnapshotIdentifier: The ``DBSnapshotIdentifier`` of the new ``DBSnapshot`` created when the
                ``SkipFinalSnapshot`` parameter is disabled.
            DeleteAutomatedBackups: Specifies whether to remove automated backups immediately after the DB instance is deleted.
                This parameter isn't case- sensitive. The default is to remove automated backups immediately after the DB instance
                is deleted.
        """
        args: Dict[str, Any] = dict(
            DBInstanceIdentifier=self.serialize(DBInstanceIdentifier),
            SkipFinalSnapshot=self.serialize(SkipFinalSnapshot),
            FinalDBSnapshotIdentifier=self.serialize(FinalDBSnapshotIdentifier),
            DeleteAutomatedBackups=self.serialize(DeleteAutomatedBackups),
        )
        _response = self.client.delete_db_instance(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DeleteDBInstanceResult(**_response)
        return cast("DBInstance", response.RDSDBInstance)

    def get(
        self, DBInstanceIdentifier: str, *, Filters: List[Filter] | None = None
    ) -> Optional["DBInstance"]:
        """
        Describes provisioned RDS instances. This API supports pagination.

        Args:
            DBInstanceIdentifier: The user-supplied instance identifier or the Amazon Resource Name (ARN) of the DB instance. If
                this parameter is specified, information from only the specific DB instance is returned. This parameter isn't case-
                sensitive.

        Keyword Args:
            Filters: A filter that specifies one or more DB instances to describe.
        """
        args: Dict[str, Any] = dict(
            DBInstanceIdentifier=self.serialize(DBInstanceIdentifier),
            Filters=self.serialize(Filters),
        )
        _response = self.client.describe_db_instances(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DBInstanceMessage(**_response)

        if response and response.DBInstances:
            self.sessionize(response.DBInstances[0])
            return response.DBInstances[0]
        return None

    def list(
        self,
        *,
        DBInstanceIdentifier: str | None = None,
        Filters: List[Filter] | None = None,
    ) -> PrimaryBoto3ModelQuerySet:
        """
        Describes provisioned RDS instances. This API supports pagination.

        Keyword Args:
            DBInstanceIdentifier: The user-supplied instance identifier or the Amazon Resource Name (ARN) of the DB instance. If
                this parameter is specified, information from only the specific DB instance is returned. This parameter isn't case-
                sensitive.
            Filters: A filter that specifies one or more DB instances to describe.
        """
        paginator = self.client.get_paginator("describe_db_instances")
        args: Dict[str, Any] = dict(
            DBInstanceIdentifier=self.serialize(DBInstanceIdentifier),
            Filters=self.serialize(Filters),
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results = []
        for _response in response_iterator:
            if list(_response.keys()) == ["ResponseMetadata"]:
                break
            if "ResponseMetadata" in _response:
                del _response["ResponseMetadata"]
            response = DBInstanceMessage(**_response)
            if response.DBInstances:
                results.extend(response.DBInstances)
            else:
                if getattr(response, "NextToken", None):
                    continue
                break
        self.sessionize(results)
        if results and isinstance(results[0], Boto3Model):
            return PrimaryBoto3ModelQuerySet(results)
        return results


class RDSDBSubnetGroupManager(Boto3ModelManager):
    service_name: str = "rds"

    def create(
        self, model: "RDSDBSubnetGroup", SubnetIds: List[str]
    ) -> "RDSDBSubnetGroup":
        """
        Creates a new DB subnet group. DB subnet groups must contain at least one subnet
        in at least two AZs in the Amazon Web Services Region.

        Args:
            model: The :py:class:`DBSubnetGroup` to create.
            SubnetIds: The EC2 Subnet IDs for the DB subnet group.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            DBSubnetGroupName=data.get("DBSubnetGroupName"),
            DBSubnetGroupDescription=data.get("DBSubnetGroupDescription"),
            SubnetIds=self.serialize(SubnetIds),
            Tags=data.get("TagList"),
        )
        _response = self.client.create_db_subnet_group(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = CreateDBSubnetGroupResult(**_response)

        self.sessionize(response.DBSubnetGroup)
        return cast("RDSDBSubnetGroup", response.DBSubnetGroup)

    def update(
        self, model: "RDSDBSubnetGroup", SubnetIds: List[str]
    ) -> "RDSDBSubnetGroup":
        """
        Modifies an existing DB subnet group. DB subnet groups must contain at least one
        subnet in at least two AZs in the Amazon Web Services Region.

        Args:
            model: The :py:class:`DBSubnetGroup` to update.
            SubnetIds: The EC2 subnet IDs for the DB subnet group.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            DBSubnetGroupName=data.get("DBSubnetGroupName"),
            SubnetIds=self.serialize(SubnetIds),
            DBSubnetGroupDescription=data.get("DBSubnetGroupDescription"),
        )
        _response = self.client.modify_db_subnet_group(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = ModifyDBSubnetGroupResult(**_response)

        self.sessionize(response.DBSubnetGroup)
        return cast("RDSDBSubnetGroup", response.DBSubnetGroup)

    def delete(self, DBSubnetGroupName: str) -> None:
        """
        Deletes a DB subnet group.

        Args:
            DBSubnetGroupName: The name of the database subnet group to delete.
        """
        args: Dict[str, Any] = dict(DBSubnetGroupName=self.serialize(DBSubnetGroupName))
        self.client.delete_db_subnet_group(
            **{k: v for k, v in args.items() if v is not None}
        )

    def get(self, DBSubnetGroupName: str) -> Optional["RDSDBSubnetGroup"]:
        """
        Returns a list of DBSubnetGroup descriptions. If a DBSubnetGroupName is
        specified, the list will contain only the descriptions of the specified
        DBSubnetGroup.

        Args:
            DBSubnetGroupName: The name of the DB subnet group to return details for.
        """
        args: Dict[str, Any] = dict(DBSubnetGroupName=self.serialize(DBSubnetGroupName))
        _response = self.client.describe_db_subnet_groups(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DBSubnetGroupMessage(**_response)

        if response and response.DBSubnetGroups:
            self.sessionize(response.DBSubnetGroups[0])
            return response.DBSubnetGroups[0]
        return None

    def list(
        self,
        *,
        DBSubnetGroupName: str | None = None,
        Filters: List[Filter] | None = None,
    ) -> PrimaryBoto3ModelQuerySet:
        """
        Returns a list of DBSubnetGroup descriptions. If a DBSubnetGroupName is
        specified, the list will contain only the descriptions of the specified
        DBSubnetGroup.

        Keyword Args:
            DBSubnetGroupName: The name of the DB subnet group to return details for.
            Filters: This parameter isn't currently supported.
        """
        paginator = self.client.get_paginator("describe_db_subnet_groups")
        args: Dict[str, Any] = dict(
            DBSubnetGroupName=self.serialize(DBSubnetGroupName),
            Filters=self.serialize(Filters),
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results = []
        for _response in response_iterator:
            if list(_response.keys()) == ["ResponseMetadata"]:
                break
            if "ResponseMetadata" in _response:
                del _response["ResponseMetadata"]
            response = DBSubnetGroupMessage(**_response)
            if response.DBSubnetGroups:
                results.extend(response.DBSubnetGroups)
            else:
                if getattr(response, "NextToken", None):
                    continue
                break
        self.sessionize(results)
        if results and isinstance(results[0], Boto3Model):
            return PrimaryBoto3ModelQuerySet(results)
        return results


# ==============
# Service Models
# ==============


class RDSEndpoint(Boto3Model):
    """This data type represents the information you need to connect to an Amazon RDS DB instance. This data type is used as a
    response element in the following actions:

    * ``CreateDBInstance``
    * ``DescribeDBInstances``
    * ``DeleteDBInstance``

    For the data structure that represents Amazon Aurora DB cluster endpoints, see ``DBClusterEndpoint``.
    """

    Address: str | None = None
    """
    Specifies the DNS address of the DB instance.
    """
    Port: int | None = None
    """
    Specifies the port that the database engine is listening on.
    """
    HostedZoneId: str | None = None
    """
    Specifies the ID that Amazon Route 53 assigns when you create a hosted zone.
    """


class DBSecurityGroupMembership(Boto3Model):
    """This data type is used as a response element in the following actions:

    * ``ModifyDBInstance``
    * ``RebootDBInstance``
    * ``RestoreDBInstanceFromDBSnapshot``
    * ``RestoreDBInstanceToPointInTime``
    """

    DBSecurityGroupName: str | None = None
    """
    The name of the DB security group.
    """
    Status: str | None = None
    """
    The status of the DB security group.
    """


class VpcSecurityGroupMembership(Boto3Model):
    """
    This data type is used as a response element for queries on VPC security group
    membership.
    """

    VpcSecurityGroupId: str | None = None
    """
    The name of the VPC security group.
    """
    Status: str | None = None
    """
    The membership status of the VPC security group.
    """


class DBParameterGroupStatus(Boto3Model):
    """
    The status of the DB parameter group.

    This data type is used as a response element in the following actions:

    * ``CreateDBInstance``
    * ``CreateDBInstanceReadReplica``
    * ``DeleteDBInstance``
    * ``ModifyDBInstance``
    * ``RebootDBInstance``
    * ``RestoreDBInstanceFromDBSnapshot``
    """

    DBParameterGroupName: str | None = None
    """
    The name of the DB parameter group.
    """
    ParameterApplyStatus: str | None = None
    """
    The status of parameter updates.

    Valid values are:
    """


class RDSPendingCloudwatchLogsExports(Boto3Model):
    """
    A list of the log types whose configuration is still pending.

    In other words, these log types are in the process of being activated or
    deactivated.
    """

    LogTypesToEnable: List[str] | None = None
    """
    Log types that are in the process of being deactivated.

    After they are deactivated, these log types aren't exported to CloudWatch Logs.
    """
    LogTypesToDisable: List[str] | None = None
    """
    Log types that are in the process of being enabled.

    After they are enabled, these log types are exported to CloudWatch Logs.
    """


class ProcessorFeature(Boto3Model):
    """
    Contains the processor features of a DB instance class.

    To specify the number of CPU cores, use the ``coreCount`` feature name for the ``Name`` parameter. To specify the number
    of threads per core, use the ``threadsPerCore`` feature name for the ``Name`` parameter.

    You can set the processor features of the DB instance class for a DB instance when you call one of the following
    actions:

    * ``CreateDBInstance``
    * ``ModifyDBInstance``
    * ``RestoreDBInstanceFromDBSnapshot``
    * ``RestoreDBInstanceFromS3``
    * ``RestoreDBInstanceToPointInTime``

    You can view the valid processor values for a particular instance class by calling the
    ``DescribeOrderableDBInstanceOptions`` action and specifying the instance class for the ``DBInstanceClass`` parameter.

    In addition, you can use the following actions for DB instance class processor information:

    * ``DescribeDBInstances``
    * ``DescribeDBSnapshots``
    * ``DescribeValidDBInstanceModifications``

    If you call ``DescribeDBInstances``, ``ProcessorFeature`` returns non-null values only if the following conditions are
    met:

    * You are accessing an Oracle DB instance.
    * Your Oracle DB instance class supports configuring the number of CPU cores and threads per core.
    * The current number CPU cores and threads is set to a non-default value.

    For more information, see  `Configuring the processor for a DB instance class in RDS for
    Oracle <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html#USER_ConfigureProcessor>`_ in
    the *Amazon RDS User Guide.*
    """

    Name: str | None = None
    """
    The name of the processor feature.

    Valid names are ``coreCount`` and ``threadsPerCore``.
    """
    Value: str | None = None
    """
    The value of a processor feature.
    """


class RDSPendingModifiedValues(Boto3Model):
    """
    This data type is used as a response element in the ``ModifyDBInstance`` operation
    and contains changes that will be applied during the next maintenance window.
    """

    DBInstanceClass: str | None = None
    """
    The name of the compute and memory capacity class for the DB instance.
    """
    AllocatedStorage: int | None = None
    """
    The allocated storage size for the DB instance specified in gibibytes (GiB).
    """
    MasterUserPassword: str | None = None
    """
    The master credentials for the DB instance.
    """
    Port: int | None = None
    """
    The port for the DB instance.
    """
    BackupRetentionPeriod: int | None = None
    """
    The number of days for which automated backups are retained.
    """
    MultiAZ: bool | None = None
    """
    Indicates whether the Single-AZ DB instance will change to a Multi-AZ deployment.
    """
    EngineVersion: str | None = None
    """
    The database engine version.
    """
    LicenseModel: str | None = None
    """
    The license model for the DB instance.
    """
    Iops: int | None = None
    """
    The Provisioned IOPS value for the DB instance.
    """
    DBInstanceIdentifier: str | None = None
    """
    The database identifier for the DB instance.
    """
    StorageType: str | None = None
    """
    The storage type of the DB instance.
    """
    CACertificateIdentifier: str | None = None
    """
    The identifier of the CA certificate for the DB instance.
    """
    DBSubnetGroupName: str | None = None
    """
    The DB subnet group for the DB instance.
    """
    PendingCloudwatchLogsExports: RDSPendingCloudwatchLogsExports | None = None
    """
    A list of the log types whose configuration is still pending.

    In other words, these log types are in the process of being activated or
    deactivated.
    """
    ProcessorFeatures: List["ProcessorFeature"] | None = None
    """
    The number of CPU cores and the number of threads per core for the DB instance class
    of the DB instance.
    """
    IAMDatabaseAuthenticationEnabled: bool | None = None
    """
    Indicates whether mapping of Amazon Web Services Identity and Access Management
    (IAM) accounts to database accounts is enabled.
    """
    AutomationMode: Literal["full", "all-paused"] | None = None
    """
The automation mode of the RDS Custom DB instance: ``full`` or ``all-paused``. If ``full``, the DB instance automates
monitoring and instance recovery. If ``all-paused``, the instance pauses automation for the duration set by ``--resume-
full-automation-mode-minutes``.
    """
    ResumeFullAutomationModeTime: datetime | None = None
    """
    The number of minutes to pause the automation.

    When the time period ends, RDS Custom resumes full automation. The minimum value is
    60 (default). The maximum value is 1,440.
    """
    StorageThroughput: int | None = None
    """
    The storage throughput of the DB instance.
    """
    Engine: str | None = None
    """
    The database engine of the DB instance.
    """
    DedicatedLogVolume: bool | None = None
    """
    Indicates whether the DB instance has a dedicated log volume (DLV) enabled.>
    """
    MultiTenant: bool | None = None
    """
    Indicates whether the DB instance will change to the multi-tenant configuration
    (TRUE) or the single-tenant configuration (FALSE).
    """


class OptionGroupMembership(Boto3Model):
    """
    Provides information on the option groups the DB instance is a member of.
    """

    OptionGroupName: str | None = None
    """
    The name of the option group that the instance belongs to.
    """
    Status: str | None = None
    """
    The status of the DB instance's option group membership.

    Valid values are: ``in-sync``, ``pending-apply``, ``pending-
    removal``, ``pending-maintenance-apply``, ``pending-maintenance-removal``, ``applying``, ``removing``, and ``failed``.
    """


class DBInstanceStatusInfo(Boto3Model):
    """
    Provides a list of status information for a DB instance.
    """

    StatusType: str | None = None
    """
    This value is currently "read replication.".
    """
    Normal: bool | None = None
    """
    Indicates whether the instance is operating normally (TRUE) or is in an error state
    (FALSE).
    """
    Status: str | None = None
    """
    The status of the DB instance.

    For a StatusType of read replica, the values can be replicating, replication stop
    point set, replication stop point reached, error, stopped, or terminated.
    """
    Message: str | None = None
    """
    Details of the error if there is an error for the instance.

    If the instance isn't in an error state, this value is blank.
    """


class DomainMembership(Boto3Model):
    """
    An Active Directory Domain membership record associated with the DB instance or
    cluster.
    """

    Domain: str | None = None
    """
    The identifier of the Active Directory Domain.
    """
    Status: str | None = None
    """
    The status of the Active Directory Domain membership for the DB instance or cluster.

    Values include ``joined``,
    ``pending-join``, ``failed``, and so on.
    """
    FQDN: str | None = None
    """
    The fully qualified domain name (FQDN) of the Active Directory Domain.
    """
    IAMRoleName: str | None = None
    """
    The name of the IAM role used when making API calls to the Directory Service.
    """
    OU: str | None = None
    """
    The Active Directory organizational unit for the DB instance or cluster.
    """
    AuthSecretArn: str | None = None
    """
    The ARN for the Secrets Manager secret with the credentials for the user that's a
    member of the domain.
    """
    DnsIps: List[str] | None = None
    """
    The IPv4 DNS IP addresses of the primary and secondary Active Directory domain
    controllers.
    """


class DBInstanceRole(Boto3Model):
    """
    Information about an Amazon Web Services Identity and Access Management (IAM) role
    that is associated with a DB instance.
    """

    RoleArn: str | None = None
    """
    The Amazon Resource Name (ARN) of the IAM role that is associated with the DB
    instance.
    """
    FeatureName: str | None = None
    """
    The name of the feature associated with the Amazon Web Services Identity and Access
    Management (IAM) role.

    For
    information about supported feature names, see ``DBEngineVersion``.
    """
    Status: str | None = None
    """
    Information about the state of association between the IAM role and the DB instance.

    The Status property returns one of
    the following values:
    """


class DBInstanceAutomatedBackupsReplication(Boto3Model):
    """
    Automated backups of a DB instance replicated to another Amazon Web Services Region.

    They consist of system backups, transaction logs, and database instance properties.
    """

    DBInstanceAutomatedBackupsArn: str | None = None
    """
    The Amazon Resource Name (ARN) of the replicated automated backups.
    """


class RDSMasterUserSecret(Boto3Model):
    """
    Contains the secret managed by RDS in Amazon Web Services Secrets Manager for the
    master user password.

    For more information, see
    `Password management with Amazon Web Services Secrets Manager <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-secrets-manager.html>`_
    in the *Amazon RDS User Guide*    and
    `Password management with Amazon Web Services Secrets Manager <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-secrets-manager.html>`_
    in the *Amazon Aurora
    User Guide.*
    """

    SecretArn: str | None = None
    """
    The Amazon Resource Name (ARN) of the secret.
    """
    SecretStatus: str | None = None
    """
    The status of the secret.
    """
    KmsKeyId: str | None = None
    """
    The Amazon Web Services KMS key identifier that is used to encrypt the secret.
    """


class RDSCertificateDetails(Boto3Model):
    """
    The details of the DB instance’s server certificate.

    For more information, see `Using SSL/TLS to encrypt a connection to a DB
    instance <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html>`_ in the *Amazon RDS User Guide*
    and  `Using SSL/TLS to encrypt a connection to a DB
    cluster <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.SSL.html>`_ in the *Amazon Aurora User
    Guide*.
    """

    CAIdentifier: str | None = None
    """
    The CA identifier of the CA certificate used for the DB instance's server
    certificate.
    """
    ValidTill: datetime | None = None
    """
    The expiration date of the DB instance’s server certificate.
    """


class DBInstance(TagsDictMixin, PrimaryBoto3Model):
    """
    Contains the details of an Amazon RDS DB instance.

    This data type is used as a response element in the operations ``CreateDBInstance``, ``CreateDBInstanceReadReplica``,
    ``DeleteDBInstance``, ``DescribeDBInstances``, ``ModifyDBInstance``, ``PromoteReadReplica``, ``RebootDBInstance``,
    ``RestoreDBInstanceFromDBSnapshot``, ``RestoreDBInstanceFromS3``, ``RestoreDBInstanceToPointInTime``,
    ``StartDBInstance``, and ``StopDBInstance``.
    """

    tag_class: ClassVar[Type] = Tag
    manager_class: ClassVar[Type[Boto3ModelManager]] = DBInstanceManager

    DBInstanceIdentifier: str
    """
    The user-supplied database identifier.

    This identifier is the unique key that identifies a DB instance.
    """
    DBInstanceClass: str
    """
    The name of the compute and memory capacity class of the DB instance.
    """
    MultiAZ: bool | None
    """
    Indicates whether the DB instance is a Multi-AZ deployment.

    This setting doesn't apply to RDS Custom DB instances.
    """
    Engine: str
    """
    The database engine used for this DB instance.
    """
    EngineVersion: str
    """
    The version of the database engine.
    """
    AutoMinorVersionUpgrade: bool | None = True
    """
    Indicates whether minor version patches are applied automatically.
    """
    PubliclyAccessible: bool | None
    """
    Indicates whether the DB instance is publicly accessible.
    """
    StorageEncrypted: bool | None = True
    """
    Indicates whether the DB instance is encrypted.
    """
    BackupRetentionPeriod: int | None = 1
    """
    The number of days for which automatic DB snapshots are retained.
    """
    DbInstancePort: int | None = None
    """
    The port that the DB instance listens on.

    If the DB instance is part of a DB cluster, this can be a different port than the DB
    cluster port.
    """
    IAMDatabaseAuthenticationEnabled: bool | None = None
    """
    Indicates whether mapping of Amazon Web Services Identity and Access Management
    (IAM) accounts to database accounts is enabled for the DB instance.
    """
    EnabledCloudwatchLogsExports: List[str] | None = None
    """
    A list of log types that this DB instance is configured to export to CloudWatch
    Logs.
    """
    Tags: List[Tag] = Field(default_factory=list, alias="TagList")
    """
    A list of tags.
    """
    CustomerOwnedIpEnabled: bool | None = None
    """
    Indicates whether a customer-owned IP address (CoIP) is enabled for an RDS on
    Outposts DB instance.
    """
    PerformanceInsightsEnabled: bool | None = None
    """
    Indicates whether Performance Insights is enabled for the DB instance.
    """
    DBSubnetGroup: Optional["RDSDBSubnetGroup"] = None
    """
    Information about the subnet group associated with the DB instance, including the
    name, description, and subnets in the subnet group.
    """
    DBInstanceStatus: str = Field(default=None, frozen=True)
    """
    The current state of this database.
    """
    AutomaticRestartTime: datetime = Field(default=None, frozen=True)
    """
    The time when a stopped DB instance is restarted automatically.
    """
    MasterUsername: str | None = None
    """
    The master username for the DB instance.
    """
    DBName: str | None = None
    """
    The initial database name that you provided (if required) when you created the DB
    instance.

    This name is returned for the life of your DB instance. For an RDS for Oracle CDB
    instance, the name identifies the PDB rather than the CDB.
    """
    Endpoint: RDSEndpoint = Field(default=None, frozen=True)
    """
    The connection endpoint for the DB instance.
    """
    AllocatedStorage: int | None = None
    """
    The amount of storage in gibibytes (GiB) allocated for the DB instance.
    """
    InstanceCreateTime: datetime = Field(default=None, frozen=True)
    """
    The date and time when the DB instance was created.
    """
    PreferredBackupWindow: str | None = None
    """
    The daily time range during which automated backups are created if automated backups
    are enabled, as determined by the ``BackupRetentionPeriod``.
    """
    DBSecurityGroups: List["DBSecurityGroupMembership"] | None = None
    """
    A list of DB security group elements containing ``DBSecurityGroup.Name`` and
    ``DBSecurityGroup.Status`` subelements.
    """
    VpcSecurityGroups: List["VpcSecurityGroupMembership"] = Field(
        default_factory=list, frozen=True
    )
    """
    The list of Amazon EC2 VPC security groups that the DB instance belongs to.
    """
    DBParameterGroups: List["DBParameterGroupStatus"] = Field(
        default_factory=list, frozen=True
    )
    """
    The list of DB parameter groups applied to this DB instance.
    """
    AvailabilityZone: str | None = None
    """
    The name of the Availability Zone where the DB instance is located.
    """
    PreferredMaintenanceWindow: str | None = None
    """
    The weekly time range during which system maintenance can occur, in Universal
    Coordinated Time (UTC).
    """
    PendingModifiedValues: RDSPendingModifiedValues = Field(default=None, frozen=True)
    """
    Information about pending changes to the DB instance.

    This information is returned only when there are pending changes. Specific changes
    are identified by subelements.
    """
    LatestRestorableTime: datetime = Field(default=None, frozen=True)
    """
    The latest time to which a database in this DB instance can be restored with point-
    in-time restore.
    """
    ReadReplicaSourceDBInstanceIdentifier: str = Field(default=None, frozen=True)
    """
    The identifier of the source DB instance if this DB instance is a read replica.
    """
    ReadReplicaDBInstanceIdentifiers: List[str] = Field(
        default_factory=list, frozen=True
    )
    """
    The identifiers of the read replicas associated with this DB instance.
    """
    ReadReplicaDBClusterIdentifiers: List[str] = Field(
        default_factory=list, frozen=True
    )
    """
    The identifiers of Aurora DB clusters to which the RDS DB instance is replicated as
    a read replica.

    For example, when you create an Aurora read replica of an RDS for MySQL DB instance,
    the Aurora MySQL DB cluster for the Aurora read replica is shown. This output
    doesn't contain information about cross-Region Aurora read replicas.
    """
    ReplicaMode: Literal["open-read-only", "mounted"] | None = None
    """
    The open mode of a Db2 or an Oracle read replica.

    The default is ``open-read-only``. For more information, see `Working
    with replicas for Amazon RDS for Db2 <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/db2-replication.html>`_ and
    `Working with read replicas for Amazon RDS for Oracle <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/oracle-
    read-replicas.html>`_ in the *Amazon RDS User Guide*.
    """
    LicenseModel: str | None = None
    """
    The license model information for this DB instance.

    This setting doesn't apply to Amazon Aurora or RDS Custom DB instances.
    """
    Iops: int | None = None
    """
    The Provisioned IOPS (I/O operations per second) value for the DB instance.
    """
    OptionGroupMemberships: List["OptionGroupMembership"] = Field(
        default_factory=list, frozen=True
    )
    """
    The list of option group memberships for this DB instance.
    """
    CharacterSetName: str | None = None
    """
    If present, specifies the name of the character set that this instance is associated
    with.
    """
    NcharCharacterSetName: str | None = None
    """
    The name of the NCHAR character set for the Oracle DB instance.

    This character set specifies the Unicode encoding for data stored in table columns
    of type NCHAR, NCLOB, or NVARCHAR2.
    """
    SecondaryAvailabilityZone: str = Field(default=None, frozen=True)
    """
    If present, specifies the name of the secondary Availability Zone for a DB instance
    with multi-AZ support.
    """
    StatusInfos: List["DBInstanceStatusInfo"] = Field(default_factory=list, frozen=True)
    """
    The status of a read replica.

    If the DB instance isn't a read replica, the value is blank.
    """
    StorageType: str | None = None
    """
    The storage type associated with the DB instance.
    """
    TdeCredentialArn: str | None = None
    """
    The ARN from the key store with which the instance is associated for TDE encryption.
    """
    DBClusterIdentifier: str | None = None
    """
    If the DB instance is a member of a DB cluster, indicates the name of the DB cluster
    that the DB instance is a member of.
    """
    KmsKeyId: str | None = None
    """
    If ``StorageEncrypted`` is enabled, the Amazon Web Services KMS key identifier for
    the encrypted DB instance.
    """
    DbiResourceId: str = Field(default=None, frozen=True)
    """
    The Amazon Web Services Region-unique, immutable identifier for the DB instance.

    This identifier is found in Amazon Web Services CloudTrail log entries whenever the
    Amazon Web Services KMS key for the DB instance is accessed.
    """
    CACertificateIdentifier: str | None = None
    """
    The identifier of the CA certificate for this DB instance.
    """
    DomainMemberships: List["DomainMembership"] = Field(
        default_factory=list, frozen=True
    )
    """
    The Active Directory Domain membership records associated with the DB instance.
    """
    CopyTagsToSnapshot: bool | None = None
    """
    Indicates whether tags are copied from the DB instance to snapshots of the DB
    instance.
    """
    MonitoringInterval: int | None = None
    """
    The interval, in seconds, between points when Enhanced Monitoring metrics are
    collected for the DB instance.
    """
    EnhancedMonitoringResourceArn: str = Field(default=None, frozen=True)
    """
    The Amazon Resource Name (ARN) of the Amazon CloudWatch Logs log stream that
    receives the Enhanced Monitoring metrics data for the DB instance.
    """
    MonitoringRoleArn: str | None = None
    """
    The ARN for the IAM role that permits RDS to send Enhanced Monitoring metrics to
    Amazon CloudWatch Logs.
    """
    PromotionTier: int | None = None
    """
    The order of priority in which an Aurora Replica is promoted to the primary instance
    after a failure of the existing primary instance.

    For more information, see  `Fault Tolerance for an Aurora DB Cluster <https://docs.aws.amazon.com/Amaz
    onRDS/latest/AuroraUserGuide/Concepts.AuroraHighAvailability.html#Aurora.Managing.FaultTolerance>`_ in the *Amazon Aurora
    User Guide*.
    """
    DBInstanceArn: str = Field(default=None, frozen=True)
    """
    The Amazon Resource Name (ARN) for the DB instance.
    """
    Timezone: str | None = None
    """
    The time zone of the DB instance.

    In most cases, the ``Timezone`` element is empty. ``Timezone`` content appears only
    for RDS for Db2 and RDS for SQL Server DB instances that were created with a time zone specified.
    """
    DatabaseInsightsMode: Literal["standard", "advanced"] | None = None
    """
    The mode of Database Insights that is enabled for the instance.
    """
    PerformanceInsightsKMSKeyId: str | None = None
    """
    The Amazon Web Services KMS key identifier for encryption of Performance Insights
    data.
    """
    PerformanceInsightsRetentionPeriod: int | None = None
    """
    The number of days to retain Performance Insights data.
    """
    ProcessorFeatures: List["ProcessorFeature"] | None = None
    """
    The number of CPU cores and the number of threads per core for the DB instance class
    of the DB instance.
    """
    DeletionProtection: bool | None = None
    """
    Indicates whether the DB instance has deletion protection enabled.

    The database can't be deleted when deletion protection is enabled. For more
    information, see
    `Deleting a DB Instance <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_DeleteInstance.html>`_.
    """
    AssociatedRoles: List["DBInstanceRole"] = Field(default_factory=list, frozen=True)
    """
    The Amazon Web Services Identity and Access Management (IAM) roles associated with
    the DB instance.
    """
    ListenerEndpoint: RDSEndpoint = Field(default=None, frozen=True)
    """
    The listener connection endpoint for SQL Server Always On.
    """
    MaxAllocatedStorage: int | None = None
    """
    The upper limit in gibibytes (GiB) to which Amazon RDS can automatically scale the
    storage of the DB instance.
    """
    DBInstanceAutomatedBackupsReplications: List[
        "DBInstanceAutomatedBackupsReplication"
    ] = Field(default_factory=list, frozen=True)
    """
    The list of replicated automated backups associated with the DB instance.
    """
    AwsBackupRecoveryPointArn: str | None = None
    """
    The Amazon Resource Name (ARN) of the recovery point in Amazon Web Services Backup.
    """
    ActivityStreamStatus: Literal["stopped", "starting", "started", "stopping"] = Field(
        default=None, frozen=True
    )
    """
    The status of the database activity stream.
    """
    ActivityStreamKmsKeyId: str = Field(default=None, frozen=True)
    """
    The Amazon Web Services KMS key identifier used for encrypting messages in the
    database activity stream.

    The Amazon Web Services KMS key identifier is the key ARN, key ID, alias ARN, or
    alias name for the KMS key.
    """
    ActivityStreamKinesisStreamName: str = Field(default=None, frozen=True)
    """
    The name of the Amazon Kinesis data stream used for the database activity stream.
    """
    ActivityStreamMode: Literal["sync", "async"] = Field(default=None, frozen=True)
    """
    The mode of the database activity stream.

    Database events such as a change or access generate an activity stream event. RDS
    for Oracle always handles these events asynchronously.
    """
    ActivityStreamEngineNativeAuditFieldsIncluded: bool = Field(
        default=None, frozen=True
    )
    """
    Indicates whether engine-native audit fields are included in the database activity
    stream.
    """
    AutomationMode: Literal["full", "all-paused"] | None = None
    """
The automation mode of the RDS Custom DB instance: ``full`` or ``all paused``. If ``full``, the DB instance automates
monitoring and instance recovery. If ``all paused``, the instance pauses automation for the duration set by ``--resume-
full-automation-mode-minutes``.
    """
    ResumeFullAutomationModeTime: datetime = Field(default=None, frozen=True)
    """
    The number of minutes to pause the automation.

    When the time period ends, RDS Custom resumes full automation. The minimum value is
    60 (default). The maximum value is 1,440.
    """
    CustomIamInstanceProfile: str | None = None
    """
    The instance profile associated with the underlying Amazon EC2 instance of an RDS
    Custom DB instance.

    The instance
    profile must meet the following requirements:
    """
    BackupTarget: str | None = None
    """
The location where automated backups and manual snapshots are stored: Dedicated Local Zones, Amazon Web Services
Outposts or the Amazon Web Services Region.
    """
    NetworkType: str | None = None
    """
    The network type of the DB instance.
    """
    ActivityStreamPolicyStatus: Literal[
        "locked", "unlocked", "locking-policy", "unlocking-policy"
    ] = Field(default=None, frozen=True)
    """
    The status of the policy state of the activity stream.
    """
    StorageThroughput: int | None = None
    """
    The storage throughput for the DB instance.
    """
    DBSystemId: str | None = None
    """
    The Oracle system ID (Oracle SID) for a container database (CDB).

    The Oracle SID is also the name of the CDB. This setting is only valid for RDS
    Custom DB instances.
    """
    MasterUserSecret: RDSMasterUserSecret = Field(default=None, frozen=True)
    """
    The secret managed by RDS in Amazon Web Services Secrets Manager for the master user
    password.
    """
    CertificateDetails: RDSCertificateDetails = Field(default=None, frozen=True)
    """
    The details of the DB instance's server certificate.
    """
    ReadReplicaSourceDBClusterIdentifier: str = Field(default=None, frozen=True)
    """
    The identifier of the source DB cluster if this DB instance is a read replica.
    """
    PercentProgress: str = Field(default=None, frozen=True)
    """
    The progress of the storage optimization operation as a percentage.
    """
    DedicatedLogVolume: bool | None = None
    """
    Indicates whether the DB instance has a dedicated log volume (DLV) enabled.
    """
    IsStorageConfigUpgradeAvailable: bool = Field(default=None, frozen=True)
    """
    Indicates whether an upgrade is recommended for the storage file system
    configuration on the DB instance.

    To migrate to
    the preferred configuration, you can either create a blue/green deployment, or create a read replica from the DB
    instance. For more information, see `Upgrading the storage file system for a DB instance <https://docs.aws.amazon.com/Am
    azonRDS/latest/UserGuide/USER_PIOPS.StorageTypes.html#USER_PIOPS.UpgradeFileSystem>`_.
    """
    MultiTenant: bool | None = None
    """
    Specifies whether the DB instance is in the multi-tenant configuration (TRUE) or the
    single-tenant configuration (FALSE).
    """
    EngineLifecycleSupport: str | None = None
    """
    The lifecycle type for the DB instance.
    """

    @property
    def pk(self) -> str | None:
        """
        Return the primary key of the model.   This is the value of the
        :py:attr:`DBInstanceArn` attribute.

        Returns:
            The primary key of the model instance.
        """
        return self.DBInstanceArn

    @property
    def arn(self) -> str | None:
        """
        Return the ARN of the model.   This is the value of the :py:attr:`DBInstanceArn`
        attribute.

        Returns:
            The ARN of the model instance.
        """
        return self.DBInstanceArn

    @property
    def name(self) -> str | None:
        """
        Return the name of the model.   This is the value of the
        :py:attr:`DBInstanceIdentifier` attribute.

        Returns:
            The name of the model instance.
        """
        return self.DBInstanceIdentifier

    def __hash__(self) -> int:
        """
        Return the hash of the model.

        This is the value of the
        :py:attr:`DBInstanceArn` attribute.
        """
        return hash(self.DBInstanceArn)

    @cached_property
    def subnet_group(self) -> Optional["RDSDBSubnetGroup"]:
        """
        Return the subnet group that this DB instance is in, if any.

        .. note::

            The output of this property is cached on the model instance, so
            calling this multiple times will not result in multiple calls to the
            AWS API.   If you need a fresh copy of the data, you can re-get the
            model instance from the manager.
        """

        try:
            pk = OrderedDict(
                {
                    "DBSubnetGroupName": self.DBSubnetGroup.DBSubnetGroupName,
                }
            )
        except AttributeError:
            return None
        return RDSDBSubnetGroup.objects.using(self.session).get(**pk)  # type: ignore[arg-type]

    @cached_property
    def security_groups(self) -> List["SecurityGroup"] | None:
        """
        Return the security groups that this DB instance is in, if any.

        .. note::

            The output of this property is cached on the model instance, so
            calling this multiple times will not result in multiple calls to the
            AWS API.   If you need a fresh copy of the data, you can re-get the
            model instance from the manager.
        """

        try:
            pk = OrderedDict(
                {
                    "GroupIds": [
                        g.VpcSecurityGroupId
                        for g in self.VpcSecurityGroups
                        if g.VpcSecurityGroupId
                    ],
                }
            )
        except AttributeError:
            return []
        return SecurityGroup.objects.using(self.session).list(**pk)  # type: ignore[arg-type]

    @cached_property
    def vpc(self) -> Optional["Vpc"]:
        """
        Return the VPC that this DB instance is in, if any.

        .. note::

            The output of this property is cached on the model instance, so
            calling this multiple times will not result in multiple calls to the
            AWS API.   If you need a fresh copy of the data, you can re-get the
            model instance from the manager.
        """

        try:
            pk = OrderedDict(
                {
                    "VpcId": self.DBSubnetGroup.VpcId,
                }
            )
        except AttributeError:
            return None
        return Vpc.objects.using(self.session).get(**pk)  # type: ignore[arg-type]


class RDSAvailabilityZone(Boto3Model):
    """
    Contains Availability Zone information.

    This data type is used as an element in the ``OrderableDBInstanceOption`` data type.
    """

    Name: str | None = None
    """
    The name of the Availability Zone.
    """


class Outpost(Boto3Model):
    """
    A data type that represents an Outpost.

    For more information about RDS on Outposts, see
    `Amazon RDS on Amazon Web Services Outposts <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-on-outposts.html>`_
    in the *Amazon RDS User Guide.*
    """

    Arn: str | None = None
    """
    The Amazon Resource Name (ARN) of the Outpost.
    """


class RDSSubnet(Boto3Model):
    """
    This data type is used as a response element for the ``DescribeDBSubnetGroups``
    operation.
    """

    SubnetIdentifier: str | None = None
    """
    The identifier of the subnet.
    """
    SubnetAvailabilityZone: RDSAvailabilityZone | None = None
    """
    Contains Availability Zone information.
    """
    SubnetOutpost: Outpost | None = None
    """
    If the subnet is associated with an Outpost, this value specifies the Outpost.
    """
    SubnetStatus: str | None = None
    """
    The status of the subnet.
    """


class RDSDBSubnetGroup(PrimaryBoto3Model):
    """
    Contains the details of an Amazon RDS DB subnet group.

    This data type is used as a response element in the ``DescribeDBSubnetGroups`` action.
    """

    manager_class: ClassVar[Type[Boto3ModelManager]] = RDSDBSubnetGroupManager

    DBSubnetGroupName: str
    """
    The name of the DB subnet group.
    """
    DBSubnetGroupDescription: str
    """
    Provides the description of the DB subnet group.
    """
    Subnets: List["RDSSubnet"]
    """
    Contains a list of ``Subnet`` elements.

    The list of subnets shown here might not reflect the current state of your VPC. For
    the most up-to-date information, we recommend checking your VPC configuration
    directly.
    """
    VpcId: str
    """
    Provides the VpcId of the DB subnet group.
    """
    SubnetGroupStatus: str | None = "Complete"
    """
    Provides the status of the DB subnet group.
    """
    DBSubnetGroupArn: str = Field(default=None, frozen=True)
    """
    The Amazon Resource Name (ARN) for the DB subnet group.
    """
    SupportedNetworkTypes: List[str] = Field(default_factory=list, frozen=True)
    """
    The network type of the DB subnet group.
    """

    @property
    def pk(self) -> str | None:
        """
        Return the primary key of the model.   This is the value of the
        :py:attr:`DBSubnetGroupArn` attribute.

        Returns:
            The primary key of the model instance.
        """
        return self.DBSubnetGroupArn

    @property
    def arn(self) -> str | None:
        """
        Return the ARN of the model.   This is the value of the
        :py:attr:`DBSubnetGroupArn` attribute.

        Returns:
            The ARN of the model instance.
        """
        return self.DBSubnetGroupArn

    @property
    def name(self) -> str | None:
        """
        Return the name of the model.   This is the value of the
        :py:attr:`DBSubnetGroupName` attribute.

        Returns:
            The name of the model instance.
        """
        return self.DBSubnetGroupName

    def __hash__(self) -> int:
        """
        Return the hash of the model.

        This is the value of the
        :py:attr:`DBSubnetGroupArn` attribute.
        """
        return hash(self.DBSubnetGroupArn)


# =======================
# Request/Response Models
# =======================


class CreateDBInstanceResult(Boto3Model):
    RDSDBInstance: DBInstance = Field(default=None, alias="DBInstance")
    """
    Contains the details of an Amazon RDS DB instance.
    """


class CloudwatchLogsExportConfiguration(Boto3Model):
    """
    The configuration setting for the log types to be enabled for export to CloudWatch
    Logs for a specific DB instance or DB cluster.

    The ``EnableLogTypes`` and ``DisableLogTypes`` arrays determine which logs will be exported (or not exported) to
    CloudWatch Logs. The values within these arrays depend on the DB engine being used.

    For more information about exporting CloudWatch Logs for Amazon RDS DB instances, see `Publishing Database Logs to
    Amazon CloudWatch Logs <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.html#USER_LogAccess.Proced
    ural.UploadtoCloudWatch>`_  in the *Amazon RDS User Guide*.

    For more information about exporting CloudWatch Logs for Amazon Aurora DB clusters, see `Publishing Database Logs to
    Amazon CloudWatch Logs <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_LogAccess.html#USER_LogAccess.
    Procedural.UploadtoCloudWatch>`_ in the *Amazon Aurora User Guide*.
    """

    EnableLogTypes: List[str] | None = None
    """
    The list of log types to enable.
    """
    DisableLogTypes: List[str] | None = None
    """
    The list of log types to disable.
    """


class ModifyDBInstanceResult(Boto3Model):
    RDSDBInstance: DBInstance = Field(default=None, alias="DBInstance")
    """
    Contains the details of an Amazon RDS DB instance.
    """


class DeleteDBInstanceResult(Boto3Model):
    RDSDBInstance: DBInstance = Field(default=None, alias="DBInstance")
    """
    Contains the details of an Amazon RDS DB instance.
    """


class DBInstanceMessage(Boto3Model):
    """
    Contains the result of a successful invocation of the ``DescribeDBInstances``
    action.
    """

    Marker: str | None = None
    """
    An optional pagination token provided by a previous request.

    If this parameter is specified, the response includes only
    records beyond the marker, up to the value specified by ``MaxRecords`` .
    """
    DBInstances: List["DBInstance"] | None = None
    """
    A list of ``DBInstance`` instances.
    """


class CreateDBSubnetGroupResult(Boto3Model):
    DBSubnetGroup: RDSDBSubnetGroup | None = None
    """
    Contains the details of an Amazon RDS DB subnet group.
    """


class ModifyDBSubnetGroupResult(Boto3Model):
    DBSubnetGroup: RDSDBSubnetGroup | None = None
    """
    Contains the details of an Amazon RDS DB subnet group.
    """


class DBSubnetGroupMessage(Boto3Model):
    """
    Contains the result of a successful invocation of the ``DescribeDBSubnetGroups``
    action.
    """

    Marker: str | None = None
    """
    An optional pagination token provided by a previous request.

    If this parameter is specified, the response includes only
    records beyond the marker, up to the value specified by ``MaxRecords``.
    """
    DBSubnetGroups: List["RDSDBSubnetGroup"] | None = None
    """
    A list of ``DBSubnetGroup`` instances.
    """
