# This file is automatically generated by botocraft.  Do not edit directly.
# pylint: disable=anomalous-backslash-in-string,unsubscriptable-object,line-too-long,arguments-differ,arguments-renamed,unused-import,redefined-outer-name
# pyright: reportUnusedImport=false
# mypy: disable-error-code="index, override, assignment, union-attr, misc"
from collections import OrderedDict
from datetime import datetime
from functools import cached_property
from typing import Any, ClassVar, Dict, List, Literal, Optional, Type, cast

from pydantic import Field

from botocraft.mixins.autoscaling import AutoScalingGroupModelMixin
from botocraft.mixins.tags import TagsDictMixin
from botocraft.services.common import Filter, Tag
from botocraft.services.ec2 import (LaunchTemplateVersion,
                                    LaunchTemplateVersionManager)

from .abstract import (Boto3Model, Boto3ModelManager, PrimaryBoto3Model,
                       ReadonlyBoto3Model, ReadonlyBoto3ModelManager,
                       ReadonlyPrimaryBoto3Model)

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


class AutoScalingGroupManager(Boto3ModelManager):

    service_name: str = "autoscaling"

    def create(
        self,
        model: "AutoScalingGroup",
        InstanceId: Optional[str] = None,
        LifecycleHookSpecificationList: Optional[
            List["LifecycleHookSpecification"]
        ] = None,
    ) -> None:
        """
        **We strongly recommend using a launch template when calling this
        operation to ensure full functionality for Amazon EC2 Auto Scaling and
        Amazon EC2.**

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

        Keyword Args:
            InstanceId: The ID of the instance used to base the launch configuration
                on. If specified, Amazon EC2 Auto Scaling uses the configuration values
                from the specified instance to create a new launch configuration. To get
                the instance ID, use the Amazon EC2 `DescribeInstances
                <https://docs.aws.amazon.com/AWSEC2/latest/APIRef
                erence/API_DescribeInstances.html>`_ API operation. For more information,
                see `Create an Auto Scaling group using parameters from an existing
                instance <https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-asg-
                from-instance.html>`_ in the *Amazon EC2 Auto Scaling User Guide*.
            LifecycleHookSpecificationList: One or more lifecycle hooks to add to the
                Auto Scaling group before instances are launched.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            AutoScalingGroupName=data.get("AutoScalingGroupName"),
            MinSize=data.get("MinSize"),
            MaxSize=data.get("MaxSize"),
            LaunchConfigurationName=data.get("LaunchConfigurationName"),
            LaunchTemplate=data.get("LaunchTemplate"),
            MixedInstancesPolicy=data.get("MixedInstancesPolicy"),
            InstanceId=self.serialize(InstanceId),
            DesiredCapacity=data.get("DesiredCapacity"),
            DefaultCooldown=data.get("DefaultCooldown"),
            AvailabilityZones=data.get("AvailabilityZones"),
            LoadBalancerNames=data.get("LoadBalancerNames"),
            TargetGroupARNs=data.get("TargetGroupARNs"),
            HealthCheckType=data.get("HealthCheckType"),
            HealthCheckGracePeriod=data.get("HealthCheckGracePeriod"),
            PlacementGroup=data.get("PlacementGroup"),
            VPCZoneIdentifier=data.get("VPCZoneIdentifier"),
            TerminationPolicies=data.get("TerminationPolicies"),
            NewInstancesProtectedFromScaleIn=data.get(
                "NewInstancesProtectedFromScaleIn"
            ),
            CapacityRebalance=data.get("CapacityRebalance"),
            LifecycleHookSpecificationList=self.serialize(
                LifecycleHookSpecificationList
            ),
            Tags=data.get("Tags"),
            ServiceLinkedRoleARN=data.get("ServiceLinkedRoleARN"),
            MaxInstanceLifetime=data.get("MaxInstanceLifetime"),
            Context=data.get("Context"),
            DesiredCapacityType=data.get("DesiredCapacityType"),
            DefaultInstanceWarmup=data.get("DefaultInstanceWarmup"),
            TrafficSources=data.get("TrafficSources"),
            InstanceMaintenancePolicy=data.get("InstanceMaintenancePolicy"),
        )
        self.client.create_auto_scaling_group(
            **{k: v for k, v in args.items() if v is not None}
        )

    def update(self, model: "AutoScalingGroup") -> None:
        """
        **We strongly recommend that all Auto Scaling groups use launch
        templates to ensure full functionality for Amazon EC2 Auto Scaling and
        Amazon EC2.**

        Args:
            model: The :py:class:``AutoScalingGroup`` to update.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            AutoScalingGroupName=data.get("AutoScalingGroupName"),
            LaunchConfigurationName=data.get("LaunchConfigurationName"),
            LaunchTemplate=(
                {
                    "LaunchTemplateId": data["LaunchTemplate"]["LaunchTemplateId"],
                    "Version": data["LaunchTemplate"]["Version"],
                }
                if "LaunchTemplate" in data
                else None
            ),
            MixedInstancesPolicy=data.get("MixedInstancesPolicy"),
            MinSize=data.get("MinSize"),
            MaxSize=data.get("MaxSize"),
            DesiredCapacity=data.get("DesiredCapacity"),
            DefaultCooldown=data.get("DefaultCooldown"),
            AvailabilityZones=data.get("AvailabilityZones"),
            HealthCheckType=data.get("HealthCheckType"),
            HealthCheckGracePeriod=data.get("HealthCheckGracePeriod"),
            PlacementGroup=data.get("PlacementGroup"),
            VPCZoneIdentifier=data.get("VPCZoneIdentifier"),
            TerminationPolicies=data.get("TerminationPolicies"),
            NewInstancesProtectedFromScaleIn=data.get(
                "NewInstancesProtectedFromScaleIn"
            ),
            ServiceLinkedRoleARN=data.get("ServiceLinkedRoleARN"),
            MaxInstanceLifetime=data.get("MaxInstanceLifetime"),
            CapacityRebalance=data.get("CapacityRebalance"),
            Context=data.get("Context"),
            DesiredCapacityType=data.get("DesiredCapacityType"),
            DefaultInstanceWarmup=data.get("DefaultInstanceWarmup"),
            InstanceMaintenancePolicy=data.get("InstanceMaintenancePolicy"),
        )
        self.client.update_auto_scaling_group(
            **{k: v for k, v in args.items() if v is not None}
        )

    def delete(
        self, AutoScalingGroupName: str, *, ForceDelete: Optional[bool] = None
    ) -> None:
        """
        Deletes the specified Auto Scaling group.

        Args:
            AutoScalingGroupName: The name of the Auto Scaling group.

        Keyword Args:
            ForceDelete: Specifies that the group is to be deleted along with all
                instances associated with the group, without waiting for all instances to
                be terminated. This action also deletes any outstanding lifecycle actions
                associated with the group.
        """
        args: Dict[str, Any] = dict(
            AutoScalingGroupName=self.serialize(AutoScalingGroupName),
            ForceDelete=self.serialize(ForceDelete),
        )
        self.client.delete_auto_scaling_group(
            **{k: v for k, v in args.items() if v is not None}
        )

    def get(self, AutoScalingGroupName: str) -> Optional["AutoScalingGroup"]:
        """
        Gets information about the Auto Scaling groups in the account and
        Region.

        Args:
            AutoScalingGroupName: The name of the Auto Scaling group. The name can be a
                maximum of 1600 characters.
        """
        args: Dict[str, Any] = dict(
            AutoScalingGroupNames=self.serialize([AutoScalingGroupName])
        )
        _response = self.client.describe_auto_scaling_groups(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = AutoScalingGroupsType(**_response)

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

    def list(
        self,
        *,
        AutoScalingGroupNames: Optional[List[str]] = None,
        Filters: Optional[List[Filter]] = None
    ) -> List["AutoScalingGroup"]:
        """
        Gets information about the Auto Scaling groups in the account and
        Region.

        Keyword Args:
            AutoScalingGroupNames: The names of the Auto Scaling groups. By default,
                you can only specify up to 50 names. You can optionally increase this limit
                using the ``MaxRecords`` property.
            Filters: One or more filters to limit the results based on specific tags.
        """
        paginator = self.client.get_paginator("describe_auto_scaling_groups")
        args: Dict[str, Any] = dict(
            AutoScalingGroupNames=self.serialize(AutoScalingGroupNames),
            Filters=self.serialize(Filters),
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results: List["AutoScalingGroup"] = []
        for _response in response_iterator:
            response = AutoScalingGroupsType(**_response)
            if response.AutoScalingGroups:
                results.extend(response.AutoScalingGroups)
            else:
                break
        self.sessionize(results)
        return results

    def scale(self, AutoScalingGroupName: str, DesiredCapacity: int) -> None:
        """
        Sets the size of the specified Auto Scaling group.

        Args:
            AutoScalingGroupName: The name of the Auto Scaling group.
            DesiredCapacity: The desired capacity is the initial capacity of the Auto
                Scaling group after this operation completes and the capacity it attempts
                to maintain.
        """
        args: Dict[str, Any] = dict(
            AutoScalingGroupName=self.serialize(AutoScalingGroupName),
            DesiredCapacity=self.serialize(DesiredCapacity),
            HonorCooldown=False,
        )
        self.client.set_desired_capacity(
            **{k: v for k, v in args.items() if v is not None}
        )

        self.sessionize(results)
        return cast(None, results)

    def instance_status(
        self, *, InstanceIds: Optional[List[str]] = None
    ) -> List["AutoScalingInstanceDetails"]:
        """
        Gets information about the Auto Scaling instances in the account and
        Region.

        Keyword Args:
            InstanceIds: The IDs of the instances. If you omit this property, all Auto
                Scaling instances are described. If you specify an ID that does not exist,
                it is ignored with no error.
        """
        paginator = self.client.get_paginator("describe_auto_scaling_instances")
        args: Dict[str, Any] = dict(InstanceIds=self.serialize(InstanceIds))
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )

        results: List["AutoScalingInstanceDetails"] = []

        for _response in response_iterator:
            response = AutoScalingInstancesType(**_response)
            if response.AutoScalingInstances is not None:
                results.extend(response.AutoScalingInstances)
            else:
                break

        self.sessionize(results)
        return cast(List["AutoScalingInstanceDetails"], results)

    def terminate_instance(
        self, InstanceId: str, ShouldDecrementDesiredCapacity: bool
    ) -> "ActivityType":
        """
        Terminates the specified instance and optionally adjusts the desired
        group size. This operation cannot be called on instances in a warm
        pool.

        Args:
            InstanceId: The ID of the instance.
            ShouldDecrementDesiredCapacity: Indicates whether terminating the instance
                also decrements the size of the Auto Scaling group.
        """
        args: Dict[str, Any] = dict(
            InstanceId=self.serialize(InstanceId),
            ShouldDecrementDesiredCapacity=self.serialize(
                ShouldDecrementDesiredCapacity
            ),
        )
        _response = self.client.terminate_instance_in_auto_scaling_group(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = ActivityType(**_response)

        results: "ActivityType" = None
        if response is not None:
            results = response

        self.sessionize(results)
        return cast("ActivityType", results)


class LaunchConfigurationManager(Boto3ModelManager):

    service_name: str = "autoscaling"

    def create(
        self, model: "LaunchConfiguration", InstanceId: Optional[str] = None
    ) -> None:
        """
        Creates a launch configuration.

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

        Keyword Args:
            InstanceId: The ID of the instance to use to create the launch
                configuration. The new launch configuration derives attributes from the
                instance, except for the block device mapping.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            LaunchConfigurationName=data.get("LaunchConfigurationName"),
            ImageId=data.get("ImageId"),
            KeyName=data.get("KeyName"),
            SecurityGroups=data.get("SecurityGroups"),
            ClassicLinkVPCId=data.get("ClassicLinkVPCId"),
            ClassicLinkVPCSecurityGroups=data.get("ClassicLinkVPCSecurityGroups"),
            UserData=data.get("UserData"),
            InstanceId=self.serialize(InstanceId),
            InstanceType=data.get("InstanceType"),
            KernelId=data.get("KernelId"),
            RamdiskId=data.get("RamdiskId"),
            BlockDeviceMappings=data.get("BlockDeviceMappings"),
            InstanceMonitoring=data.get("InstanceMonitoring"),
            SpotPrice=data.get("SpotPrice"),
            IamInstanceProfile=data.get("IamInstanceProfile"),
            EbsOptimized=data.get("EbsOptimized"),
            AssociatePublicIpAddress=data.get("AssociatePublicIpAddress"),
            PlacementTenancy=data.get("PlacementTenancy"),
            MetadataOptions=data.get("MetadataOptions"),
        )
        self.client.create_launch_configuration(
            **{k: v for k, v in args.items() if v is not None}
        )

    def delete(self, LaunchConfigurationName: str) -> None:
        """
        Deletes the specified launch configuration.

        Args:
            LaunchConfigurationName: The name of the launch configuration.
        """
        args: Dict[str, Any] = dict(
            LaunchConfigurationName=self.serialize(LaunchConfigurationName)
        )
        self.client.delete_launch_configuration(
            **{k: v for k, v in args.items() if v is not None}
        )

    def get(self, LaunchConfigurationName: str) -> Optional["LaunchConfiguration"]:
        """
        Gets information about the launch configurations in the account and
        Region.

        Args:
            LaunchConfigurationName: The name of the launch configuration. This name
                must be unique per Region per account.
        """
        args: Dict[str, Any] = dict(
            LaunchConfigurationNames=self.serialize([LaunchConfigurationName])
        )
        _response = self.client.describe_launch_configurations(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = LaunchConfigurationsType(**_response)

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

    def list(
        self, *, LaunchConfigurationNames: Optional[List[str]] = None
    ) -> List["LaunchConfiguration"]:
        """
        Gets information about the launch configurations in the account and
        Region.

        Keyword Args:
            LaunchConfigurationNames: The launch configuration names. If you omit this
                property, all launch configurations are described.
        """
        paginator = self.client.get_paginator("describe_launch_configurations")
        args: Dict[str, Any] = dict(
            LaunchConfigurationNames=self.serialize(LaunchConfigurationNames)
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results: List["LaunchConfiguration"] = []
        for _response in response_iterator:
            response = LaunchConfigurationsType(**_response)
            if response.LaunchConfigurations:
                results.extend(response.LaunchConfigurations)
            else:
                break
        self.sessionize(results)
        return results


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


class AutoScalingLaunchTemplateSpecification(Boto3Model):
    """
    The launch template for the group.
    """

    LaunchTemplateId: Optional[str] = None
    """
    The ID of the launch template.

    To get the template ID, use the Amazon EC2 `Desc
    ribeLaunchTemplates <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API
    _DescribeLaunchTemplates.html>`_ API operation. New launch templates can be
    created using the Amazon EC2 `CreateLaunchTemplate <https://docs.aws.amazon.com
    /AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html>`_ API.
    """
    LaunchTemplateName: Optional[str] = None
    """
    The name of the launch template.

    To get the template name, use the Amazon EC2 `
    DescribeLaunchTemplates <https://docs.aws.amazon.com/AWSEC2/latest/APIReference
    /API_DescribeLaunchTemplates.html>`_ API operation. New launch templates can be
    created using the Amazon EC2 `CreateLaunchTemplate <https://docs.aws.amazon.com
    /AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html>`_ API.
    """
    Version: Optional[str] = None
    """
    The version number, ``$Latest``, or ``$Default``.

    To get the version number,
    use the Amazon EC2 `DescribeLaunchTemplateVersions <https://docs.aws.amazon.com
    /AWSEC2/latest/APIReference/API_DescribeLaunchTemplateVersions.html>`_ API
    operation. New launch template versions can be created using the Amazon EC2 `Cr
    eateLaunchTemplateVersion <https://docs.aws.amazon.com/AWSEC2/latest/APIReferen
    ce/API_CreateLaunchTemplateVersion.html>`_ API. If the value is ``$Latest``,
    Amazon EC2 Auto Scaling selects the latest version of the launch template when
    launching instances. If the value is ``$Default``, Amazon EC2 Auto Scaling
    selects the default version of the launch template when launching instances.
    The default value is ``$Default``.
    """


class VCpuCountRequest(Boto3Model):
    """
    The minimum and maximum number of vCPUs for an instance type.
    """

    Min: int
    """
    The minimum number of vCPUs.
    """
    Max: Optional[int] = None
    """
    The maximum number of vCPUs.
    """


class AutoScalingMemoryMiBRequest(Boto3Model):
    """
    The minimum and maximum instance memory size for an instance type, in MiB.
    """

    Min: int
    """
    The memory minimum in MiB.
    """
    Max: Optional[int] = None
    """
    The memory maximum in MiB.
    """


class MemoryGiBPerVCpuRequest(Boto3Model):
    """
    The minimum and maximum amount of memory per vCPU for an instance type, in
    GiB.

    Default: No minimum or maximum limits
    """

    Min: Optional[float] = None
    """
    The memory minimum in GiB.
    """
    Max: Optional[float] = None
    """
    The memory maximum in GiB.
    """


class AutoScalingNetworkInterfaceCountRequest(Boto3Model):
    """
    The minimum and maximum number of network interfaces for an instance type.

    Default: No minimum or maximum limits
    """

    Min: Optional[int] = None
    """
    The minimum number of network interfaces.
    """
    Max: Optional[int] = None
    """
    The maximum number of network interfaces.
    """


class AutoScalingTotalLocalStorageGBRequest(Boto3Model):
    """
    The minimum and maximum total local storage size for an instance type, in
    GB.

    Default: No minimum or maximum limits
    """

    Min: Optional[float] = None
    """
    The storage minimum in GB.
    """
    Max: Optional[float] = None
    """
    The storage maximum in GB.
    """


class AutoScalingBaselineEbsBandwidthMbsRequest(Boto3Model):
    """The minimum and maximum baseline bandwidth performance for an instance type, in
    Mbps. For more information, see `Amazon EBS-optimized
    instances <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-
    optimized.html>`_ in the *Amazon EC2 User Guide for Linux Instances*.

    Default: No minimum or maximum limits

    """

    Min: Optional[int] = None
    """
    The minimum value in Mbps.
    """
    Max: Optional[int] = None
    """
    The maximum value in Mbps.
    """


class AutoScalingAcceleratorCountRequest(Boto3Model):
    """
    The minimum and maximum number of accelerators (GPUs, FPGAs, or Amazon Web
    Services Inferentia chips) for an instance type.

    To exclude accelerator-enabled instance types, set ``Max`` to ``0``.

    Default: No minimum or maximum limits
    """

    Min: Optional[int] = None
    """
    The minimum value.
    """
    Max: Optional[int] = None
    """
    The maximum value.
    """


class AutoScalingAcceleratorTotalMemoryMiBRequest(Boto3Model):
    """
    The minimum and maximum total memory size for the accelerators on an
    instance type, in MiB.

    Default: No minimum or maximum limits
    """

    Min: Optional[int] = None
    """
    The memory minimum in MiB.
    """
    Max: Optional[int] = None
    """
    The memory maximum in MiB.
    """


class NetworkBandwidthGbpsRequest(Boto3Model):
    """
    The minimum and maximum amount of network bandwidth, in gigabits per second
    (Gbps).

    Default: No minimum or maximum limits
    """

    Min: Optional[float] = None
    """
    The minimum amount of network bandwidth, in gigabits per second (Gbps).
    """
    Max: Optional[float] = None
    """
    The maximum amount of network bandwidth, in gigabits per second (Gbps).
    """


class AutoScalingInstanceRequirements(Boto3Model):
    """
    The instance requirements. Amazon EC2 Auto Scaling uses your specified
    requirements to identify instance types. Then, it uses your On-Demand and
    Spot allocation strategies to launch instances from these instance types.

    You can specify up to four separate sets of instance requirements per Auto
    Scaling group. This is useful for provisioning instances from different Amazon
    Machine Images (AMIs) in the same Auto Scaling group. To do this, create the
    AMIs and create a new launch template for each AMI. Then, create a compatible
    set of instance requirements for each launch template.

    If you specify ``InstanceRequirements``, you can't specify ``InstanceType``.
    """

    VCpuCount: VCpuCountRequest
    """
    The minimum and maximum number of vCPUs for an instance type.
    """
    MemoryMiB: AutoScalingMemoryMiBRequest
    """
    The minimum and maximum instance memory size for an instance type, in MiB.
    """
    CpuManufacturers: Optional[List[Literal["intel", "amd", "amazon-web-services"]]] = (
        None
    )
    """
    Lists which specific CPU manufacturers to include.
    """
    MemoryGiBPerVCpu: Optional[MemoryGiBPerVCpuRequest] = None
    """
    The minimum and maximum amount of memory per vCPU for an instance type, in
    GiB.
    """
    ExcludedInstanceTypes: Optional[List[str]] = None
    """
    The instance types to exclude.

    You can use strings with one or more wild cards,
    represented by an asterisk (``*``), to exclude an instance family, type, size,
    or generation. The following are examples: ``m5.8xlarge``, ``c5*.*``,
    ``m5a.*``, ``r*``, ``*3*``.
    """
    InstanceGenerations: Optional[List[Literal["current", "previous"]]] = None
    """
    Indicates whether current or previous generation instance types are
    included.
    """
    SpotMaxPricePercentageOverLowestPrice: Optional[int] = None
    """
    [Price protection] The price protection threshold for Spot Instances, as a
    percentage higher than an identified Spot price.

    The identified Spot price is the price of the lowest priced current
    generation C, M, or R instance type with your specified attributes. If no
    current generation C, M, or R instance type matches your attributes, then
    the identified price is from either the lowest priced current generation
    instance types or, failing that, the lowest priced previous generation
    instance types that match your attributes. When Amazon EC2 Auto Scaling
    selects instance types with your attributes, we will exclude instance types
    whose price exceeds your specified threshold.
    """
    MaxSpotPriceAsPercentageOfOptimalOnDemandPrice: Optional[int] = None
    """
    [Price protection] The price protection threshold for Spot Instances, as a
    percentage of an identified On-Demand price.

    The identified On-Demand price is the price of the lowest priced current
    generation C, M, or R instance type with your specified attributes. If no
    current generation C, M, or R instance type matches your attributes, then
    the identified price is from either the lowest priced current generation
    instance types or, failing that, the lowest priced previous generation
    instance types that match your attributes. When Amazon EC2 Auto Scaling
    selects instance types with your attributes, we will exclude instance types
    whose price exceeds your specified threshold.
    """
    OnDemandMaxPricePercentageOverLowestPrice: Optional[int] = None
    """
    [Price protection] The price protection threshold for On-Demand Instances,
    as a percentage higher than an identified On-Demand price.

    The identified On-Demand price is the price of the lowest priced current
    generation C, M, or R instance type with your specified attributes. If no
    current generation C, M, or R instance type matches your attributes, then
    the identified price is from either the lowest priced current generation
    instance types or, failing that, the lowest priced previous generation
    instance types that match your attributes. When Amazon EC2 Auto Scaling
    selects instance types with your attributes, we will exclude instance types
    whose price exceeds your specified threshold.
    """
    BareMetal: Optional[Literal["included", "excluded", "required"]] = None
    """
    Indicates whether bare metal instance types are included, excluded, or
    required.
    """
    BurstablePerformance: Optional[Literal["included", "excluded", "required"]] = None
    """
    Indicates whether burstable performance instance types are included,
    excluded, or required.

    For more information, see
    `Burstable performance instances <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-
    performance-instances.html>`_ in the *Amazon EC2 User Guide for Linux Instances*.
    """
    RequireHibernateSupport: Optional[bool] = None
    """
    Indicates whether instance types must provide On-Demand Instance
    hibernation support.
    """
    NetworkInterfaceCount: Optional[AutoScalingNetworkInterfaceCountRequest] = None
    """
    The minimum and maximum number of network interfaces for an instance type.
    """
    LocalStorage: Optional[Literal["included", "excluded", "required"]] = None
    """
    Indicates whether instance types with instance store volumes are included,
    excluded, or required.

    For more information, see `Amazon EC2 instance store <ht
    tps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html>`_ in the
    *Amazon EC2 User Guide for Linux Instances*.
    """
    LocalStorageTypes: Optional[List[Literal["hdd", "ssd"]]] = None
    """
    Indicates the type of local storage that is required.
    """
    TotalLocalStorageGB: Optional[AutoScalingTotalLocalStorageGBRequest] = None
    """
    The minimum and maximum total local storage size for an instance type, in
    GB.
    """
    BaselineEbsBandwidthMbps: Optional[AutoScalingBaselineEbsBandwidthMbsRequest] = None
    """
    The minimum and maximum baseline bandwidth performance for an instance
    type, in Mbps.

    For more information, see `Amazon EBS-optimized
    instances <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-
    optimized.html>`_ in the *Amazon EC2 User Guide for Linux Instances*.
    """
    AcceleratorTypes: Optional[List[Literal["gpu", "fpga", "inference"]]] = None
    """
    Lists the accelerator types that must be on an instance type.
    """
    AcceleratorCount: Optional[AutoScalingAcceleratorCountRequest] = None
    """
    The minimum and maximum number of accelerators (GPUs, FPGAs, or Amazon Web
    Services Inferentia chips) for an instance type.
    """
    AcceleratorManufacturers: Optional[
        List[Literal["nvidia", "amd", "amazon-web-services", "xilinx"]]
    ] = None
    """
    Indicates whether instance types must have accelerators by specific
    manufacturers.
    """
    AcceleratorNames: Optional[
        List[Literal["a100", "v100", "k80", "t4", "m60", "radeon-pro-v520", "vu9p"]]
    ] = None
    """
    Lists the accelerators that must be on an instance type.
    """
    AcceleratorTotalMemoryMiB: Optional[AutoScalingAcceleratorTotalMemoryMiBRequest] = (
        None
    )
    """
    The minimum and maximum total memory size for the accelerators on an
    instance type, in MiB.
    """
    NetworkBandwidthGbps: Optional[NetworkBandwidthGbpsRequest] = None
    """
    The minimum and maximum amount of network bandwidth, in gigabits per second
    (Gbps).
    """
    AllowedInstanceTypes: Optional[List[str]] = None
    """
    The instance types to apply your specified attributes against.

    All other instance types are ignored, even if they match your specified
    attributes.
    """


class LaunchTemplateOverrides(Boto3Model):
    """Use this structure to let Amazon EC2 Auto Scaling do the following when the
    Auto Scaling group has a mixed instances policy:

    * Override the instance type that is specified in the launch template.
    * Use multiple instance types.

    Specify the instance types that you want, or define your instance requirements
    instead and let Amazon EC2 Auto Scaling provision the available instance types
    that meet your requirements. This can provide Amazon EC2 Auto Scaling with a
    larger selection of instance types to choose from when fulfilling Spot and
    On-Demand capacities. You can view which instance types are matched before you
    apply the instance requirements to your Auto Scaling group.

    After you define your instance requirements, you don't have to keep updating
    these settings to get new EC2 instance types automatically. Amazon EC2 Auto
    Scaling uses the instance requirements of the Auto Scaling group to determine
    whether a new EC2 instance type can be used.

    """

    InstanceType: Optional[str] = None
    """
    The instance type, such as ``m3.xlarge``.

    You must specify an instance type that is supported in your requested
    Region and Availability Zones. For more information, see
    `Instance types <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html>`_
    in the *Amazon EC2 User Guide for Linux Instances*.
    """
    WeightedCapacity: Optional[str] = None
    """
    If you provide a list of instance types to use, you can specify the number
    of capacity units provided by each instance type in terms of virtual CPUs,
    memory, storage, throughput, or other relative performance characteristic.

    When a Spot
    or On-Demand Instance is launched, the capacity units count toward the desired
    capacity. Amazon EC2 Auto Scaling launches instances until the desired capacity
    is totally fulfilled, even if this results in an overage. For example, if there
    are two units remaining to fulfill capacity, and Amazon EC2 Auto Scaling can
    only launch an instance with a ``WeightedCapacity`` of five units, the instance
    is launched, and the desired capacity is exceeded by three units. For more
    information, see `Configure an Auto Scaling group to use instance
    weights <https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-
    scaling-mixed-instances-groups-instance-weighting.html>`_ in the *Amazon EC2 Auto
    Scaling User Guide*. Value must be in the range of 1-999.
    """
    LaunchTemplateSpecification: Optional[AutoScalingLaunchTemplateSpecification] = None
    """
    Provides a launch template for the specified instance type or set of
    instance requirements.

    For example, some instance types might require a launch template
    with a different AMI. If not provided, Amazon EC2 Auto Scaling uses the launch
    template that's specified in the ``LaunchTemplate`` definition. For more
    information, see `Specifying a different launch template for an instance
    type <https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-
    mixed-instances-groups-launch-template-overrides.html>`_ in the *Amazon EC2 Auto
    Scaling User Guide*.
    """
    InstanceRequirements: Optional[AutoScalingInstanceRequirements] = None
    """
    The instance requirements.

    Amazon EC2 Auto Scaling uses your specified requirements to identify
    instance types. Then, it uses your On-Demand and Spot allocation strategies
    to launch instances from these instance types.
    """


class AutoScalingLaunchTemplate(Boto3Model):
    """
    One or more launch templates and the instance types (overrides) that are
    used to launch EC2 instances to fulfill On-Demand and Spot capacities.
    """

    LaunchTemplateSpecification: Optional[AutoScalingLaunchTemplateSpecification] = None
    """
    The launch template.
    """
    Overrides: Optional[List["LaunchTemplateOverrides"]] = None
    """
    Any properties that you specify override the same properties in the launch
    template.
    """


class AutoScalingInstancesDistribution(Boto3Model):
    """
    The instances distribution.
    """

    OnDemandAllocationStrategy: Optional[str] = None
    """
    The allocation strategy to apply to your On-Demand Instances when they are
    launched.

    Possible instance types are determined by the launch template overrides
    that you specify.
    """
    OnDemandBaseCapacity: Optional[int] = None
    """
    The minimum amount of the Auto Scaling group's capacity that must be
    fulfilled by On-Demand Instances.

    This base portion is launched first as your group scales.
    """
    OnDemandPercentageAboveBaseCapacity: Optional[int] = None
    """
    Controls the percentages of On-Demand Instances and Spot Instances for your
    additional capacity beyond ``OnDemandBaseCapacity``.

    Expressed as a number (for example, 20 specifies 20% On-Demand Instances,
    80% Spot Instances). If set to 100, only On-Demand Instances are used.
    """
    SpotAllocationStrategy: Optional[str] = None
    """
    The allocation strategy to apply to your Spot Instances when they are
    launched.

    Possible instance types are determined by the launch template overrides
    that you specify.
    """
    SpotInstancePools: Optional[int] = None
    """
    The number of Spot Instance pools across which to allocate your Spot
    Instances.

    The Spot pools are determined from the different instance types in the
    overrides. Valid only when the ``SpotAllocationStrategy`` is ``lowest-price``.
    Value must be in the range of 1-20.
    """
    SpotMaxPrice: Optional[str] = None
    """
    The maximum price per unit hour that you are willing to pay for a Spot
    Instance.

    If your maximum price is lower than the Spot price for the instance types
    that you selected, your Spot Instances are not launched. We do not
    recommend specifying a maximum price because it can lead to increased
    interruptions. When Spot Instances launch, you pay the current Spot price.
    To remove a maximum price that you previously set, include the property but
    specify an empty string ("") for the value.
    """


class AutoScalingMixedInstancesPolicy(Boto3Model):
    """
    The mixed instances policy for the group.
    """

    LaunchTemplate: Optional[AutoScalingLaunchTemplate] = None
    """
    One or more launch templates and the instance types (overrides) that are
    used to launch EC2 instances to fulfill On-Demand and Spot capacities.
    """
    InstancesDistribution: Optional[AutoScalingInstancesDistribution] = None
    """
    The instances distribution.
    """


class AutoScalingInstanceReference(Boto3Model):
    """
    Describes an EC2 instance.
    """

    InstanceId: str
    """
    The ID of the instance.
    """
    InstanceType: Optional[str] = None
    """
    The instance type of the EC2 instance.
    """
    AvailabilityZone: str
    """
    The Availability Zone in which the instance is running.
    """
    LifecycleState: Literal[
        "Pending",
        "Pending:Wait",
        "Pending:Proceed",
        "Quarantined",
        "InService",
        "Terminating",
        "Terminating:Wait",
        "Terminating:Proceed",
        "Terminated",
        "Detaching",
        "Detached",
        "EnteringStandby",
        "Standby",
        "Warmed:Pending",
        "Warmed:Pending:Wait",
        "Warmed:Pending:Proceed",
        "Warmed:Terminating",
        "Warmed:Terminating:Wait",
        "Warmed:Terminating:Proceed",
        "Warmed:Terminated",
        "Warmed:Stopped",
        "Warmed:Running",
        "Warmed:Hibernated",
    ]
    """
    A description of the current lifecycle state.

    The ``Quarantined`` state is not
    used. For more information, see `Amazon EC2 Auto Scaling instance
    lifecycle <https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-
    scaling-lifecycle.html>`_ in the *Amazon EC2 Auto Scaling User Guide*.
    """
    HealthStatus: str
    """
    The last reported health status of the instance.

    ``Healthy`` means that the
    instance is healthy and should remain in service. ``Unhealthy`` means that the
    instance is unhealthy and that Amazon EC2 Auto Scaling should terminate and
    replace it.
    """
    LaunchConfigurationName: Optional[str] = None
    """
    The launch configuration associated with the instance.
    """
    LaunchTemplate: Optional[AutoScalingLaunchTemplateSpecification] = None
    """
    The launch template for the instance.
    """
    ProtectedFromScaleIn: bool
    """
    Indicates whether the instance is protected from termination by Amazon EC2
    Auto Scaling when scaling in.
    """
    WeightedCapacity: Optional[str] = None
    """
    The number of capacity units contributed by the instance based on its
    instance type.
    """


class SuspendedProcess(Boto3Model):
    """
    Describes an auto scaling process that has been suspended.

    For more information, see
    `Types of processes <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-suspend-
    resume-processes.html#process-types>`_ in the *Amazon EC2 Auto Scaling User
    Guide*.
    """

    ProcessName: Optional[str] = None
    """
    The name of the suspended process.
    """
    SuspensionReason: Optional[str] = None
    """
    The reason that the process was suspended.
    """


class EnabledMetric(Boto3Model):
    """
    Describes an enabled Auto Scaling group metric.
    """

    Metric: Optional[str] = None
    """
One of the following metrics:
    """
    Granularity: Optional[str] = None
    """
    The granularity of the metric.

    The only valid value is ``1Minute``.
    """


class TagDescription(Boto3Model):
    """
    Describes a tag for an Auto Scaling group.
    """

    ResourceId: Optional[str] = None
    """
    The name of the group.
    """
    ResourceType: Optional[str] = None
    """
    The type of resource.

    The only supported value is ``auto-scaling-group``.
    """
    Key: Optional[str] = None
    """
    The tag key.
    """
    Value: Optional[str] = None
    """
    The tag value.
    """
    PropagateAtLaunch: Optional[bool] = None
    """
    Determines whether the tag is added to new instances as they are launched
    in the group.
    """


class AutoScalingInstanceReusePolicy(Boto3Model):
    """
    The instance reuse policy.
    """

    ReuseOnScaleIn: Optional[bool] = None
    """
    Specifies whether instances in the Auto Scaling group can be returned to
    the warm pool on scale in.
    """


class AutoScalingWarmPoolConfiguration(Boto3Model):
    """
    The warm pool for the group.
    """

    MaxGroupPreparedCapacity: Optional[int] = None
    """
    The maximum number of instances that are allowed to be in the warm pool or
    in any state except ``Terminated`` for the Auto Scaling group.
    """
    MinSize: Optional[int] = None
    """
    The minimum number of instances to maintain in the warm pool.
    """
    PoolState: Optional[Literal["Stopped", "Running", "Hibernated"]] = None
    """
    The instance state to transition to after the lifecycle actions are
    complete.
    """
    Status: Optional[Literal["PendingDelete"]] = None
    """
    The status of a warm pool that is marked for deletion.
    """
    InstanceReusePolicy: Optional[AutoScalingInstanceReusePolicy] = None
    """
    The instance reuse policy.
    """


class TrafficSourceIdentifier(Boto3Model):
    """
    Identifying information for a traffic source.
    """

    Identifier: str
    """
    Identifies the traffic source.
    """
    Type: Optional[str] = None
    """
    Provides additional context for the value of ``Identifier``.
    """


class AutoScalingInstanceMaintenancePolicy(Boto3Model):
    """
    An instance maintenance policy.
    """

    MinHealthyPercentage: Optional[int] = None
    """
    Specifies the lower threshold as a percentage of the desired capacity of
    the Auto Scaling group.

    It represents the minimum percentage of the group to keep
    in service, healthy, and ready to use to support your workload when replacing
    instances. Value range is 0 to 100. To clear a previously set value, specify a
    value of ``-1``.
    """
    MaxHealthyPercentage: Optional[int] = None
    """
    Specifies the upper threshold as a percentage of the desired capacity of
    the Auto Scaling group.

    It represents the maximum percentage of the group that can
    be in service and healthy, or pending, to support your workload when replacing
    instances. Value range is 100 to 200. To clear a previously set value, specify
    a value of ``-1``.
    """


class AutoScalingGroup(TagsDictMixin, AutoScalingGroupModelMixin, PrimaryBoto3Model):
    """
    Describes an Auto Scaling group.
    """

    tag_class: ClassVar[Type] = TagDescription
    manager_class: ClassVar[Type[Boto3ModelManager]] = AutoScalingGroupManager

    DefaultCooldown: int
    """
    The duration of the default cooldown period, in seconds.
    """
    AutoScalingGroupName: str
    """
    The name of the Auto Scaling group.
    """
    AutoScalingGroupARN: str = Field(default=None, frozen=True)
    """
    The Amazon Resource Name (ARN) of the Auto Scaling group.
    """
    LaunchConfigurationName: Optional[str] = None
    """
    The name of the associated launch configuration.
    """
    LaunchTemplate: Optional[AutoScalingLaunchTemplateSpecification] = None
    """
    The launch template for the group.
    """
    MixedInstancesPolicy: Optional[AutoScalingMixedInstancesPolicy] = None
    """
    The mixed instances policy for the group.
    """
    MinSize: int
    """
    The minimum size of the group.
    """
    MaxSize: int
    """
    The maximum size of the group.
    """
    DesiredCapacity: int
    """
    The desired size of the group.
    """
    PredictedCapacity: int = Field(default=None, frozen=True)
    """
    The predicted capacity of the group when it has a predictive scaling
    policy.
    """
    AvailabilityZones: List[str]
    """
    One or more Availability Zones for the group.
    """
    LoadBalancerNames: Optional[List[str]] = None
    """
    One or more load balancers associated with the group.
    """
    TargetGroupARNs: Optional[List[str]] = None
    """
    The Amazon Resource Names (ARN) of the target groups for your load
    balancer.
    """
    HealthCheckType: str
    """
    A comma-separated value string of one or more health check types.
    """
    HealthCheckGracePeriod: Optional[int] = None
    """
    The duration of the health check grace period, in seconds.
    """
    Instances: List["AutoScalingInstanceReference"] = Field(default=None, frozen=True)
    """
    The EC2 instances associated with the group.
    """
    CreatedTime: datetime = Field(frozen=True)
    """
    The date and time the group was created.
    """
    SuspendedProcesses: List["SuspendedProcess"] = Field(default=None, frozen=True)
    """
    The suspended processes associated with the group.
    """
    PlacementGroup: Optional[str] = None
    """
    The name of the placement group into which to launch your instances, if
    any.
    """
    VPCZoneIdentifier: Optional[str] = None
    """
    One or more subnet IDs, if applicable, separated by commas.
    """
    EnabledMetrics: List["EnabledMetric"] = Field(default=None, frozen=True)
    """
    The metrics enabled for the group.
    """
    Status: str = Field(default=None, frozen=True)
    """
    The current state of the group when the DeleteAutoScalingGroup operation is
    in progress.
    """
    Tags: Optional[List["TagDescription"]] = None
    """
    The tags for the group.
    """
    TerminationPolicies: Optional[List[str]] = None
    """
    The termination policies for the group.
    """
    NewInstancesProtectedFromScaleIn: Optional[bool] = None
    """
    Indicates whether newly launched instances are protected from termination
    by Amazon EC2 Auto Scaling when scaling in.
    """
    ServiceLinkedRoleARN: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the service-linked role that the Auto
    Scaling group uses to call other Amazon Web Services on your behalf.
    """
    MaxInstanceLifetime: Optional[int] = None
    """
    The maximum amount of time, in seconds, that an instance can be in service.
    """
    CapacityRebalance: Optional[bool] = None
    """
    Indicates whether Capacity Rebalancing is enabled.
    """
    WarmPoolConfiguration: AutoScalingWarmPoolConfiguration = Field(
        default=None, frozen=True
    )
    """
    The warm pool for the group.
    """
    WarmPoolSize: int = Field(default=None, frozen=True)
    """
    The current size of the warm pool.
    """
    Context: Optional[str] = None
    """
    Reserved.
    """
    DesiredCapacityType: Optional[str] = None
    """
    The unit of measurement for the value specified for desired capacity.

    Amazon
    EC2 Auto Scaling supports ``DesiredCapacityType`` for attribute-based instance
    type selection only.
    """
    DefaultInstanceWarmup: Optional[int] = None
    """
    The duration of the default instance warmup, in seconds.
    """
    TrafficSources: Optional[List["TrafficSourceIdentifier"]] = None
    """
    The traffic sources associated with this Auto Scaling group.
    """
    InstanceMaintenancePolicy: Optional[AutoScalingInstanceMaintenancePolicy] = None
    """
    An instance maintenance policy.
    """

    @property
    def pk(self) -> Optional[str]:
        """
        Return the primary key of the model.   This is the value of the
        :py:attr:`AutoScalingGroupName` attribute.

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

    @property
    def arn(self) -> Optional[str]:
        """
        Return the ARN of the model.   This is the value of the
        :py:attr:`AutoScalingGroupARN` attribute.

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

    @property
    def name(self) -> Optional[str]:
        """
        Return the name of the model.   This is the value of the
        :py:attr:`AutoScalingGroupName` attribute.

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

    @cached_property
    def launch_configuration(self) -> Optional["LaunchConfiguration"]:
        """
        Return the :py:class:`LaunchConfiguration` object that this group uses,
        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(
                {
                    "LaunchConfigurationName": self.LaunchConfigurationName,
                }
            )
        except AttributeError:
            return None
        return LaunchConfiguration.objects.using(self.session).get(**pk)  # type: ignore[arg-type]

    @cached_property
    def launch_template(self) -> Optional["LaunchTemplateVersion"]:
        """
        Return the :py:class:`LaunchTemplate` object that this group uses, 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(
                {
                    "LaunchTemplateId": self.LaunchTemplate.LaunchTemplateId,
                    "Version": self.LaunchTemplate.Version,
                }
            )
        except AttributeError:
            return None
        return LaunchTemplateVersion.objects.using(self.session).get(**pk)  # type: ignore[arg-type]


class EbsMapping(Boto3Model):
    """
    Information to attach an EBS volume to an instance at launch.
    """

    SnapshotId: Optional[str] = None
    """
    The snapshot ID of the volume to use.
    """
    VolumeSize: Optional[int] = None
    """
    The volume size, in GiBs.

    The following are the supported volumes sizes for
    each volume type:
    """
    VolumeType: Optional[str] = None
    """
    The volume type.

    For more information, see
    `Amazon EBS volume types <https://docs.aws.amazon.com/ebs/latest/userguide/ebs-volume-types.html>`_
    in the *Amazon EBS User Guide*.
    """
    DeleteOnTermination: Optional[bool] = None
    """
    Indicates whether the volume is deleted on instance termination.

    For Amazon EC2
    Auto Scaling, the default value is ``true``.
    """
    Iops: Optional[int] = None
    """
    The number of input/output (I/O) operations per second (IOPS) to provision
    for the volume.

    For ``gp3`` and ``io1`` volumes, this represents the number of IOPS
    that are provisioned for the volume. For ``gp2`` volumes, this represents the
    baseline performance of the volume and the rate at which the volume accumulates
    I/O credits for bursting.
    """
    Encrypted: Optional[bool] = None
    """
    Specifies whether the volume should be encrypted.

    Encrypted EBS volumes can only be attached to instances that support Amazon
    EBS encryption. For more information, see
    `Requirements for Amazon EBS encryption <https://docs.aws.amazon.com/ebs/latest/userguide/ebs-encryption-
    requirements.html>`_ in the *Amazon EBS User Guide*. If your AMI uses encrypted
    volumes, you can also only launch it on supported instance types.
    """
    Throughput: Optional[int] = None
    """
    The throughput (MiBps) to provision for a ``gp3`` volume.
    """


class AutoScalingBlockDeviceMapping(Boto3Model):
    """
    Describes a block device mapping.
    """

    VirtualName: Optional[str] = None
    """
    The name of the instance store volume (virtual device) to attach to an
    instance at launch.

    The name must be in the form ephemeral*X* where *X* is a number
    starting from zero (0), for example, ``ephemeral0``.
    """
    DeviceName: str
    """
    The device name assigned to the volume (for example, ``/dev/sdh`` or
    ``xvdh``).

    For more information, see `Device naming on Linux instances <https://docs.aws.a
    mazon.com/AWSEC2/latest/UserGuide/device_naming.html>`_ in the *Amazon EC2 User
    Guide for Linux Instances*.
    """
    Ebs: Optional[EbsMapping] = None
    """
    Information to attach an EBS volume to an instance at launch.
    """
    NoDevice: Optional[bool] = None
    """
    Setting this value to ``true`` prevents a volume that is included in the
    block device mapping of the AMI from being mapped to the specified device
    name at launch.
    """


class AutoScalingInstanceMonitoring(Boto3Model):
    """
    Controls whether instances in this group are launched with detailed
    (``true``) or basic (``false``) monitoring.

    For more information, see
    `Configure monitoring for Auto Scaling instances <https://docs.aws.amazon.com/autoscaling/latest/userguide/enable-as-
    instance-metrics.html>`_ in the *Amazon EC2 Auto Scaling User Guide*.
    """

    Enabled: Optional[bool] = None
    """
    If ``true``, detailed monitoring is enabled.

    Otherwise, basic monitoring is enabled.
    """


class InstanceMetadataOptions(Boto3Model):
    """
    The metadata options for the instances.

    For more information, see
    `Configure the instance metadata options <https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-launch-
    config.html#launch-configurations-imds>`_ in the *Amazon EC2 Auto Scaling User
    Guide*.
    """

    HttpTokens: Optional[Literal["optional", "required"]] = None
    """
    The state of token usage for your instance metadata requests.

    If the parameter
    is not specified in the request, the default state is ``optional``.
    """
    HttpPutResponseHopLimit: Optional[int] = None
    """
    The desired HTTP PUT response hop limit for instance metadata requests.

    The larger the number, the further instance metadata requests can travel.
    """
    HttpEndpoint: Optional[Literal["disabled", "enabled"]] = None
    """
    This parameter enables or disables the HTTP metadata endpoint on your
    instances.

    If the parameter is not specified, the default state is ``enabled``.
    """


class LaunchConfiguration(PrimaryBoto3Model):
    """
    Describes a launch configuration.
    """

    manager_class: ClassVar[Type[Boto3ModelManager]] = LaunchConfigurationManager

    LaunchConfigurationName: str
    """
    The name of the launch configuration.
    """
    LaunchConfigurationARN: str = Field(default=None, frozen=True)
    """
    The Amazon Resource Name (ARN) of the launch configuration.
    """
    ImageId: str
    """
    The ID of the Amazon Machine Image (AMI) to use to launch your EC2
    instances.

    For more information, see
    `Find a Linux AMI <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html>`_
    in the *Amazon EC2 User Guide for Linux Instances*.
    """
    KeyName: Optional[str] = None
    """
    The name of the key pair.
    """
    SecurityGroups: Optional[List[str]] = None
    """
    A list that contains the security groups to assign to the instances in the
    Auto Scaling group.

    For more information, see
    `Control traffic to your Amazon Web Services resources using security groups <https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-
    groups.html>`_ in the *Amazon Virtual Private Cloud User Guide*.
    """
    ClassicLinkVPCId: Optional[str] = None
    """
    Available for backward compatibility.
    """
    ClassicLinkVPCSecurityGroups: Optional[List[str]] = None
    """
    Available for backward compatibility.
    """
    UserData: Optional[str] = None
    """
    The user data to make available to the launched EC2 instances.

    For more information, see
    `Instance metadata and user data <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-
     metadata.html>`_ (Linux) and
    `Instance metadata and user data <https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-instance-
    metadata.html>`_ (Windows). If you are using a command line tool,
    base64-encoding is performed for you, and you can load the text from a file.
    Otherwise, you must provide base64-encoded text. User data is limited to 16
    KB.
    """
    InstanceType: str
    """
    The instance type for the instances.

    For information about available instance types, see
    `Available instance types <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-
    types.html#AvailableInstanceTypes>`_ in the *Amazon EC2 User Guide for Linux
    Instances*.
    """
    KernelId: Optional[str] = None
    """
    The ID of the kernel associated with the AMI.
    """
    RamdiskId: Optional[str] = None
    """
    The ID of the RAM disk associated with the AMI.
    """
    BlockDeviceMappings: Optional[List["AutoScalingBlockDeviceMapping"]] = None
    """
    The block device mapping entries that define the block devices to attach to
    the instances at launch.

    By default, the block devices specified in the block device mapping for the
    AMI are used. For more information, see
    `Block device mappings <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-
    mapping-concepts.html>`_ in the *Amazon EC2 User Guide for Linux Instances*.
    """
    InstanceMonitoring: Optional[AutoScalingInstanceMonitoring] = None
    """
    Controls whether instances in this group are launched with detailed
    (``true``) or basic (``false``) monitoring.
    """
    SpotPrice: Optional[str] = None
    """
    The maximum hourly price to be paid for any Spot Instance launched to
    fulfill the request.

    Spot Instances are launched when the price you specify exceeds the
    current Spot price. For more information, see `Requesting Spot Instances for
    fault-tolerant and flexible
    applications <https://docs.aws.amazon.com/autoscaling/ec2/userguide/launch-
    template-spot-instances.html>`_ in the *Amazon EC2 Auto Scaling User Guide*.
    """
    IamInstanceProfile: Optional[str] = None
    """
    The name or the Amazon Resource Name (ARN) of the instance profile
    associated with the IAM role for the instance.

    The instance profile contains the IAM role. For more information, see
    `IAM role for applications that run on Amazon EC2 instances <https://docs.aws.amazon.com/autoscaling/ec2/userguide/us-iam-
    role.html>`_ in the *Amazon EC2 Auto Scaling User Guide*.
    """
    CreatedTime: datetime = Field(frozen=True)
    """
    The creation date and time for the launch configuration.
    """
    EbsOptimized: Optional[bool] = None
    """
    Specifies whether the launch configuration is optimized for EBS I/O
    (``true``) or not (``false``).

    For more information, see `Amazon EBS-optimized
    instances <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-
    optimized.html>`_ in the *Amazon EC2 User Guide for Linux Instances*.
    """
    AssociatePublicIpAddress: Optional[bool] = None
    """
    Specifies whether to assign a public IPv4 address to the group's instances.

    If the instance is launched into a default subnet, the default is to assign
    a public IPv4 address, unless you disabled the option to assign a public
    IPv4 address on the subnet. If the instance is launched into a nondefault
    subnet, the default is not to assign a public IPv4 address, unless you
    enabled the option to assign a public IPv4 address on the subnet. For more
    information, see
    `Provide network connectivity for your Auto Scaling instances using Amazon VPC <https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-in-vpc.html>`_
    in
    the *Amazon EC2 Auto Scaling User Guide*.
    """
    PlacementTenancy: Optional[str] = None
    """
    The tenancy of the instance, either ``default`` or ``dedicated``.

    An instance
    with ``dedicated`` tenancy runs on isolated, single-tenant hardware and can
    only be launched into a VPC.
    """
    MetadataOptions: Optional[InstanceMetadataOptions] = None
    """
    The metadata options for the instances.

    For more information, see
    `Configure the instance metadata options <https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-launch-
    config.html#launch-configurations-imds>`_ in the *Amazon EC2 Auto Scaling User
    Guide*.
    """

    @property
    def pk(self) -> Optional[str]:
        """
        Return the primary key of the model.   This is the value of the
        :py:attr:`LaunchConfigurationName` attribute.

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

    @property
    def arn(self) -> Optional[str]:
        """
        Return the ARN of the model.   This is the value of the
        :py:attr:`LaunchConfigurationARN` attribute.

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

    @property
    def name(self) -> Optional[str]:
        """
        Return the name of the model.   This is the value of the
        :py:attr:`LaunchConfigurationName` attribute.

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


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


class LifecycleHookSpecification(Boto3Model):
    """
    Describes information used to specify a lifecycle hook for an Auto Scaling
    group.

    For more information, see
    `Amazon EC2 Auto Scaling lifecycle hooks <https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-
    hooks.html>`_ in the *Amazon EC2 Auto Scaling User Guide*.
    """

    LifecycleHookName: str
    """
    The name of the lifecycle hook.
    """
    LifecycleTransition: str
    """
    The lifecycle transition.

    For Auto Scaling groups, there are two major lifecycle transitions.
    """
    NotificationMetadata: Optional[str] = None
    """
    Additional information that you want to include any time Amazon EC2 Auto
    Scaling sends a message to the notification target.
    """
    HeartbeatTimeout: Optional[int] = None
    """
    The maximum time, in seconds, that can elapse before the lifecycle hook
    times out.

    The range is from ``30`` to ``7200`` seconds. The default value is
    ``3600`` seconds (1 hour).
    """
    DefaultResult: Optional[str] = None
    """
    The action the Auto Scaling group takes when the lifecycle hook timeout
    elapses or if an unexpected failure occurs.

    The default value is ``ABANDON``.
    """
    NotificationTargetARN: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the notification target that Amazon EC2
    Auto Scaling sends notifications to when an instance is in a wait state for
    the lifecycle hook.

    You can specify an Amazon SNS topic or an Amazon SQS queue.
    """
    RoleARN: Optional[str] = None
    """
    The ARN of the IAM role that allows the Auto Scaling group to publish to
    the specified notification target.

    For information about creating this role, see
    `Prepare to add a lifecycle hook to your Auto Scaling group <https://docs.aws.amazon.com/autoscaling/ec2/userguide/prepare-for-
    lifecycle-notifications.html>`_ in the *Amazon EC2 Auto Scaling User Guide*.
    """


class AutoScalingGroupsType(Boto3Model):
    AutoScalingGroups: List["AutoScalingGroup"]
    """
    The groups.
    """
    NextToken: Optional[str] = None
    """
    A string that indicates that the response contains more items than can be
    returned in a single response.

    To receive additional items, specify this string
    for the ``NextToken`` value when requesting the next set of items. This value
    is null when there are no more items to return.
    """


class AutoScalingInstanceDetails(Boto3Model):
    """
    Describes an EC2 instance associated with an Auto Scaling group.
    """

    InstanceId: str
    """
    The ID of the instance.
    """
    InstanceType: Optional[str] = None
    """
    The instance type of the EC2 instance.
    """
    AutoScalingGroupName: str
    """
    The name of the Auto Scaling group for the instance.
    """
    AvailabilityZone: str
    """
    The Availability Zone for the instance.
    """
    LifecycleState: str
    """
    The lifecycle state for the instance.

    The ``Quarantined`` state is not used.
    For more information, see `Amazon EC2 Auto Scaling instance
    lifecycle <https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-
    scaling-lifecycle.html>`_ in the *Amazon EC2 Auto Scaling User Guide*.
    """
    HealthStatus: str
    """
    The last reported health status of this instance.

    ``Healthy`` means that the
    instance is healthy and should remain in service. ``Unhealthy`` means that the
    instance is unhealthy and Amazon EC2 Auto Scaling should terminate and replace
    it.
    """
    LaunchConfigurationName: Optional[str] = None
    """
    The launch configuration used to launch the instance.

    This value is not available if you attached the instance to the Auto
    Scaling group.
    """
    LaunchTemplate: Optional[AutoScalingLaunchTemplateSpecification] = None
    """
    The launch template for the instance.
    """
    ProtectedFromScaleIn: bool
    """
    Indicates whether the instance is protected from termination by Amazon EC2
    Auto Scaling when scaling in.
    """
    WeightedCapacity: Optional[str] = None
    """
    The number of capacity units contributed by the instance based on its
    instance type.
    """


class AutoScalingInstancesType(Boto3Model):
    AutoScalingInstances: Optional[List["AutoScalingInstanceDetails"]] = None
    """
    The instances.
    """
    NextToken: Optional[str] = None
    """
    A string that indicates that the response contains more items than can be
    returned in a single response.

    To receive additional items, specify this string
    for the ``NextToken`` value when requesting the next set of items. This value
    is null when there are no more items to return.
    """


class AutoScalingActivity(Boto3Model):
    """
    A scaling activity.
    """

    ActivityId: str
    """
    The ID of the activity.
    """
    AutoScalingGroupName: str
    """
    The name of the Auto Scaling group.
    """
    Description: Optional[str] = None
    """
    A friendly, more verbose description of the activity.
    """
    Cause: str
    """
    The reason the activity began.
    """
    StartTime: datetime
    """
    The start time of the activity.
    """
    EndTime: Optional[datetime] = None
    """
    The end time of the activity.
    """
    StatusCode: Literal[
        "PendingSpotBidPlacement",
        "WaitingForSpotInstanceRequestId",
        "WaitingForSpotInstanceId",
        "WaitingForInstanceId",
        "PreInService",
        "InProgress",
        "WaitingForELBConnectionDraining",
        "MidLifecycleAction",
        "WaitingForInstanceWarmup",
        "Successful",
        "Failed",
        "Cancelled",
        "WaitingForConnectionDraining",
    ]
    """
    The current status of the activity.
    """
    StatusMessage: Optional[str] = None
    """
    A friendly, more verbose description of the activity status.
    """
    Progress: Optional[int] = None
    """
    A value between 0 and 100 that indicates the progress of the activity.
    """
    Details: Optional[str] = None
    """
    The details about the activity.
    """
    AutoScalingGroupState: Optional[str] = None
    """
    The state of the Auto Scaling group, which is either ``InService`` or
    ``Deleted``.
    """
    AutoScalingGroupARN: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the Auto Scaling group.
    """


class ActivityType(Boto3Model):
    Activity: Optional[AutoScalingActivity] = None
    """
    A scaling activity.
    """


class LaunchConfigurationsType(Boto3Model):
    LaunchConfigurations: List["LaunchConfiguration"]
    """
    The launch configurations.
    """
    NextToken: Optional[str] = None
    """
    A string that indicates that the response contains more items than can be
    returned in a single response.

    To receive additional items, specify this string
    for the ``NextToken`` value when requesting the next set of items. This value
    is null when there are no more items to return.
    """
