# 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.ecs import (ECSContainerInstanceModelMixin,
                                  ECSServiceModelMixin, ecs_clusters_only,
                                  ecs_container_instances_only,
                                  ecs_services_only, ecs_task_definitions_only,
                                  ecs_task_populate_taskDefinition,
                                  ecs_task_populate_taskDefinitions,
                                  ecs_tasks_only)
from botocraft.mixins.tags import TagsDictMixin
from botocraft.services.ec2 import Instance, InstanceManager

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

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


class ServiceManager(Boto3ModelManager):

    service_name: str = "ecs"

    def create(
        self,
        model: "Service",
        clientToken: Optional[str] = None,
        serviceConnectConfiguration: Optional["ServiceConnectConfiguration"] = None,
        volumeConfigurations: Optional[List["ServiceVolumeConfiguration"]] = None,
    ) -> "Service":
        """
        Create an ECS service.

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

        Keyword Args:
            clientToken: An identifier that you provide to ensure the idempotency of
                the request. It must be unique and is case sensitive. Up to 36 ASCII
                characters in the range of 33-126 (inclusive) are allowed.
            serviceConnectConfiguration: The configuration for this service to discover
                and connect to services, and be discovered by, and connected from, other
                services within a namespace.
            volumeConfigurations: The configuration for a volume specified in the task
                definition as a volume that is configured at launch time. Currently, the
                only supported volume type is an Amazon EBS volume.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            serviceName=data.get("serviceName"),
            clusterArn=data.get("clusterArn"),
            taskDefinition=data.get("taskDefinition"),
            loadBalancers=data.get("loadBalancers"),
            serviceRegistries=data.get("serviceRegistries"),
            desiredCount=data.get("desiredCount"),
            clientToken=self.serialize(clientToken),
            launchType=data.get("launchType"),
            capacityProviderStrategy=data.get("capacityProviderStrategy"),
            platformVersion=data.get("platformVersion"),
            roleArn=data.get("roleArn"),
            deploymentConfiguration=data.get("deploymentConfiguration"),
            placementConstraints=data.get("placementConstraints"),
            placementStrategy=data.get("placementStrategy"),
            networkConfiguration=data.get("networkConfiguration"),
            healthCheckGracePeriodSeconds=data.get("healthCheckGracePeriodSeconds"),
            schedulingStrategy=data.get("schedulingStrategy"),
            deploymentController=data.get("deploymentController"),
            tags=data.get("tags"),
            enableECSManagedTags=data.get("enableECSManagedTags"),
            propagateTags=data.get("propagateTags"),
            enableExecuteCommand=data.get("enableExecuteCommand"),
            serviceConnectConfiguration=self.serialize(serviceConnectConfiguration),
            volumeConfigurations=self.serialize(volumeConfigurations),
        )
        _response = self.client.create_service(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = CreateServiceResponse(**_response)

        self.sessionize(response.service)
        return cast("Service", response.service)

    def delete(
        self, service: str, *, cluster: Optional[str] = None, force: bool = False
    ) -> "Service":
        """
        Delete an ECS service.

        Args:
            service: The name of the service to delete.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                that hosts the service to delete. If you do not specify a cluster, the
                default cluster is assumed.
            force: If ``true``, allows you to delete a service even if it wasn't scaled
                down to zero tasks. It's only necessary to use this if the service uses the
                ``REPLICA`` scheduling strategy.
        """
        args: Dict[str, Any] = dict(
            service=self.serialize(service),
            cluster=self.serialize(cluster),
            force=self.serialize(force),
        )
        _response = self.client.delete_service(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DeleteServiceResponse(**_response)
        return cast(Service, response.service)

    def get(
        self,
        service: str,
        *,
        cluster: Optional[str] = None,
        include: Optional[List[Literal["TAGS"]]] = None
    ) -> Optional["Service"]:
        """
        Describes the specified services running in your cluster.

        Args:
            service: The name or full Amazon Resource Name (ARN) of the service to
                describe.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN)the cluster that
                hosts the service to describe. If you do not specify a cluster, the default
                cluster is assumed. This parameter is required if the service or services
                you are describing were launched in any cluster other than the default
                cluster.
            include: Determines whether you want to see the resource tags for the
                service. If ``TAGS`` is specified, the tags are included in the response.
                If this field is omitted, tags aren't included in the response.
        """
        args: Dict[str, Any] = dict(
            services=self.serialize([service]),
            cluster=self.serialize(cluster),
            include=self.serialize(include),
        )
        _response = self.client.describe_services(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeServicesResponse(**_response)

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

    def get_many(
        self,
        services: List[str],
        *,
        cluster: str = "default",
        include: Optional[List[Literal["TAGS"]]] = None
    ) -> List["Service"]:
        """
        Describes the specified services running in your cluster.

        Args:
            services: A list of services to describe. You may specify up to 10 services
                to describe in a single operation.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN)the cluster that
                hosts the service to describe. If you do not specify a cluster, the default
                cluster is assumed. This parameter is required if the service or services
                you are describing were launched in any cluster other than the default
                cluster.
            include: Determines whether you want to see the resource tags for the
                service. If ``TAGS`` is specified, the tags are included in the response.
                If this field is omitted, tags aren't included in the response.
        """
        args: Dict[str, Any] = dict(
            services=self.serialize(services),
            cluster=self.serialize(cluster),
            include=self.serialize(include),
        )
        _response = self.client.describe_services(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeServicesResponse(**_response)

        self.sessionize(respsonse.services)
        return response.servicesj

    @ecs_services_only
    def list(
        self,
        *,
        cluster: Optional[str] = None,
        launchType: Optional[Literal["EC2", "FARGATE", "EXTERNAL"]] = None,
        schedulingStrategy: Optional[Literal["REPLICA", "DAEMON"]] = None
    ) -> List[str]:
        """
        Returns a list of services. You can filter the results by cluster,
        launch type, and scheduling strategy.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                to use when filtering the ``ListServices`` results. If you do not specify a
                cluster, the default cluster is assumed.
            launchType: The launch type to use when filtering the ``ListServices``
                results.
            schedulingStrategy: The scheduling strategy to use when filtering the
                ``ListServices`` results.
        """
        paginator = self.client.get_paginator("list_services")
        args: Dict[str, Any] = dict(
            cluster=self.serialize(cluster),
            launchType=self.serialize(launchType),
            schedulingStrategy=self.serialize(schedulingStrategy),
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results: List[str] = []
        for _response in response_iterator:
            response = ListServicesResponse(**_response)
            if response.serviceArns:
                results.extend(response.serviceArns)
            else:
                break
        self.sessionize(results)
        return results

    def update(
        self,
        model: "Service",
        forceNewDeployment: bool = False,
        serviceConnectConfiguration: Optional["ServiceConnectConfiguration"] = None,
        volumeConfigurations: Optional[List["ServiceVolumeConfiguration"]] = None,
    ) -> "Service":
        """
        Modifies the parameters of a service.

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

        Keyword Args:
            forceNewDeployment: Determines whether to force a new deployment of the
                service. By default, deployments aren't forced. You can use this option to
                start a new deployment with no service definition changes. For example, you
                can update a service's tasks to use a newer Docker image with the same
                image/tag combination (``my_image:latest``) or to roll Fargate tasks onto a
                newer platform version.
            serviceConnectConfiguration: The configuration for this service to discover
                and connect to services, and be discovered by, and connected from, other
                services within a namespace.
            volumeConfigurations: The details of the volume that was
                ``configuredAtLaunch``. You can configure the size, volumeType, IOPS,
                throughput, snapshot and encryption in `ServiceMana
                gedEBSVolumeConfiguration
                <https://docs.aws.amazon.com/AmazonECS/latest/APIRefe
                rence/API_ServiceManagedEBSVolumeConfiguration.html>`_. The ``name`` of the
                volume must match the ``name`` from the task definition. If set to null, no
                new deployment is triggered. Otherwise, if this configuration differs from
                the existing one, it triggers a new deployment.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            serviceName=data.get("serviceName"),
            clusterArn=data.get("clusterArn"),
            desiredCount=data.get("desiredCount"),
            taskDefinition=data.get("taskDefinition"),
            capacityProviderStrategy=data.get("capacityProviderStrategy"),
            deploymentConfiguration=data.get("deploymentConfiguration"),
            networkConfiguration=data.get("networkConfiguration"),
            placementConstraints=data.get("placementConstraints"),
            placementStrategy=data.get("placementStrategy"),
            platformVersion=data.get("platformVersion"),
            forceNewDeployment=self.serialize(forceNewDeployment),
            healthCheckGracePeriodSeconds=data.get("healthCheckGracePeriodSeconds"),
            enableExecuteCommand=data.get("enableExecuteCommand"),
            enableECSManagedTags=data.get("enableECSManagedTags"),
            loadBalancers=data.get("loadBalancers"),
            propagateTags=data.get("propagateTags"),
            serviceRegistries=data.get("serviceRegistries"),
            serviceConnectConfiguration=self.serialize(serviceConnectConfiguration),
            volumeConfigurations=self.serialize(volumeConfigurations),
        )
        _response = self.client.update_service(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = UpdateServiceResponse(**_response)

        self.sessionize(response.service)
        return cast("Service", response.service)

    def partial_update(
        self,
        service: str,
        *,
        cluster: Optional[str] = None,
        desiredCount: Optional[int] = None,
        taskDefinition: Optional[str] = None,
        capacityProviderStrategy: Optional[List["CapacityProviderStrategyItem"]] = None,
        deploymentConfiguration: Optional["DeploymentConfiguration"] = None,
        networkConfiguration: Optional["NetworkConfiguration"] = None,
        placementConstraints: Optional[List["PlacementConstraint"]] = None,
        placementStrategy: Optional[List["PlacementStrategy"]] = None,
        platformVersion: Optional[str] = None,
        forceNewDeployment: bool = False,
        healthCheckGracePeriodSeconds: Optional[int] = None,
        enableExecuteCommand: Optional[bool] = None,
        enableECSManagedTags: Optional[bool] = None,
        loadBalancers: Optional[List["LoadBalancerConfiguration"]] = None,
        propagateTags: Optional[Literal["TASK_DEFINITION", "SERVICE", "NONE"]] = None,
        serviceRegistries: Optional[List["ServiceRegistry"]] = None,
        serviceConnectConfiguration: Optional["ServiceConnectConfiguration"] = None,
        volumeConfigurations: Optional[List["ServiceVolumeConfiguration"]] = None
    ) -> "Service":
        """
        Update individual attributes of an ECS service.

        Args:
            service: The name of the service to update.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                that your service runs on. If you do not specify a cluster, the default
                cluster is assumed.
            desiredCount: The number of instantiations of the task to place and keep
                running in your service.
            taskDefinition: The ``family`` and ``revision`` (``family:revision``) or
                full ARN of the task definition to run in your service. If a ``revision``
                is not specified, the latest ``ACTIVE`` revision is used. If you modify the
                task definition with ``UpdateService``, Amazon ECS spawns a task with the
                new version of the task definition and then stops an old task after the new
                version is running.
            capacityProviderStrategy: The capacity provider strategy to update the
                service to use.
            deploymentConfiguration: Optional deployment parameters that control how
                many tasks run during the deployment and the ordering of stopping and
                starting tasks.
            networkConfiguration: An object representing the network configuration for
                the service.
            placementConstraints: An array of task placement constraint objects to
                update the service to use. If no value is specified, the existing placement
                constraints for the service will remain unchanged. If this value is
                specified, it will override any existing placement constraints defined for
                the service. To remove all existing placement constraints, specify an empty
                array.
            placementStrategy: The task placement strategy objects to update the
                service to use. If no value is specified, the existing placement strategy
                for the service will remain unchanged. If this value is specified, it will
                override the existing placement strategy defined for the service. To remove
                an existing placement strategy, specify an empty object.
            platformVersion: The platform version that your tasks in the service run
                on. A platform version is only specified for tasks using the Fargate launch
                type. If a platform version is not specified, the ``LATEST`` platform
                version is used. For more information, see `Fargate Platform Versions
                <https://docs.aws.amazon.com/Amazon
                ECS/latest/developerguide/platform_versions.html>`_ in the *Amazon Elastic
                Container Service Developer Guide*.
            forceNewDeployment: Determines whether to force a new deployment of the
                service. By default, deployments aren't forced. You can use this option to
                start a new deployment with no service definition changes. For example, you
                can update a service's tasks to use a newer Docker image with the same
                image/tag combination (``my_image:latest``) or to roll Fargate tasks onto a
                newer platform version.
            healthCheckGracePeriodSeconds: The period of time, in seconds, that the
                Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing
                target health checks after a task has first started. This is only valid if
                your service is configured to use a load balancer. If your service's tasks
                take a while to start and respond to Elastic Load Balancing health checks,
                you can specify a health check grace period of up to 2,147,483,647 seconds.
                During that time, the Amazon ECS service scheduler ignores the Elastic Load
                Balancing health check status. This grace period can prevent the ECS
                service scheduler from marking tasks as unhealthy and stopping them before
                they have time to come up.
            enableExecuteCommand: If ``true``, this enables execute command
                functionality on all task containers.
            enableECSManagedTags: Determines whether to turn on Amazon ECS managed tags
                for the tasks in the service. For more information, see `Tagging Your
                Amazon ECS Resources
                <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs- using-
                tags.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
            loadBalancers: A list of Elastic Load Balancing load balancer objects. It
                contains the load balancer name, the container name, and the container port
                to access from the load balancer. The container name is as it appears in a
                container definition.
            propagateTags: Determines whether to propagate the tags from the task
                definition or the service to the task. If no value is specified, the tags
                aren't propagated.
            serviceRegistries: The details for the service discovery registries to
                assign to this service. For more information, see `Service Discovery
                <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-
                discovery.html>`_.
            serviceConnectConfiguration: The configuration for this service to discover
                and connect to services, and be discovered by, and connected from, other
                services within a namespace.
            volumeConfigurations: The details of the volume that was
                ``configuredAtLaunch``. You can configure the size, volumeType, IOPS,
                throughput, snapshot and encryption in `ServiceMana
                gedEBSVolumeConfiguration
                <https://docs.aws.amazon.com/AmazonECS/latest/APIRefe
                rence/API_ServiceManagedEBSVolumeConfiguration.html>`_. The ``name`` of the
                volume must match the ``name`` from the task definition. If set to null, no
                new deployment is triggered. Otherwise, if this configuration differs from
                the existing one, it triggers a new deployment.
        """
        args: Dict[str, Any] = dict(
            service=self.serialize(service),
            cluster=self.serialize(cluster),
            desiredCount=self.serialize(desiredCount),
            taskDefinition=self.serialize(taskDefinition),
            capacityProviderStrategy=self.serialize(capacityProviderStrategy),
            deploymentConfiguration=self.serialize(deploymentConfiguration),
            networkConfiguration=self.serialize(networkConfiguration),
            placementConstraints=self.serialize(placementConstraints),
            placementStrategy=self.serialize(placementStrategy),
            platformVersion=self.serialize(platformVersion),
            forceNewDeployment=self.serialize(forceNewDeployment),
            healthCheckGracePeriodSeconds=self.serialize(healthCheckGracePeriodSeconds),
            enableExecuteCommand=self.serialize(enableExecuteCommand),
            enableECSManagedTags=self.serialize(enableECSManagedTags),
            loadBalancers=self.serialize(loadBalancers),
            propagateTags=self.serialize(propagateTags),
            serviceRegistries=self.serialize(serviceRegistries),
            serviceConnectConfiguration=self.serialize(serviceConnectConfiguration),
            volumeConfigurations=self.serialize(volumeConfigurations),
        )
        _response = self.client.update_service(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = UpdateServiceResponse(**_response)

        self.sessionize(response.service)
        return cast("Service", response.service)


class ClusterManager(Boto3ModelManager):

    service_name: str = "ecs"

    def create(self, model: "Cluster") -> "Cluster":
        """
        Create an ECS cluster.

        Args:
            model: The :py:class:``Cluster`` to create.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            clusterName=data.get("clusterName"),
            tags=data.get("tags"),
            settings=data.get("settings"),
            configuration=data.get("configuration"),
            capacityProviders=data.get("capacityProviders"),
            defaultCapacityProviderStrategy=data.get("defaultCapacityProviderStrategy"),
            serviceConnectDefaults=data.get("serviceConnectDefaults"),
        )
        _response = self.client.create_cluster(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = CreateClusterResponse(**_response)

        self.sessionize(response.cluster)
        return cast("Cluster", response.cluster)

    def delete(self, cluster: str) -> "Cluster":
        """
        Delete an ECS cluster.

        Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                to delete.
        """
        args: Dict[str, Any] = dict(cluster=self.serialize(cluster))
        _response = self.client.delete_cluster(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DeleteClusterResponse(**_response)
        return cast(Cluster, response.cluster)

    def get(
        self,
        cluster: str,
        *,
        include: List[
            Literal["ATTACHMENTS", "CONFIGURATIONS", "SETTINGS", "STATISTICS", "TAGS"]
        ] = ["ATTACHMENTS", "CONFIGURATIONS", "SETTINGS", "STATISTICS", "TAGS"]
    ) -> Optional["Cluster"]:
        """
        Describes one or more of your clusters.

        Args:
            cluster: The name or full Amazon Resource Name (ARN) of the cluster to
                describe.

        Keyword Args:
            include: Determines whether to include additional information about the
                clusters in the response. If this field is omitted, this information isn't
                included.
        """
        args: Dict[str, Any] = dict(
            clusters=self.serialize([cluster]), include=self.serialize(include)
        )
        _response = self.client.describe_clusters(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeClustersResponse(**_response)

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

    def get_many(
        self,
        *,
        clusters: Optional[List[str]] = None,
        include: List[
            Literal["ATTACHMENTS", "CONFIGURATIONS", "SETTINGS", "STATISTICS", "TAGS"]
        ] = ["ATTACHMENTS", "CONFIGURATIONS", "SETTINGS", "STATISTICS", "TAGS"]
    ) -> List["Cluster"]:
        """
        Describes one or more of your clusters.

        Keyword Args:
            clusters: A list of up to 100 cluster names or full cluster Amazon Resource
                Name (ARN) entries. If you do not specify a cluster, the default cluster is
                assumed.
            include: Determines whether to include additional information about the
                clusters in the response. If this field is omitted, this information isn't
                included.
        """
        args: Dict[str, Any] = dict(
            clusters=self.serialize(clusters), include=self.serialize(include)
        )
        _response = self.client.describe_clusters(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeClustersResponse(**_response)

        self.sessionize(respsonse.clusters)
        return response.clustersj

    @ecs_clusters_only
    def list(
        self,
    ) -> List[str]:
        """
        Returns a list of existing clusters.
        """
        paginator = self.client.get_paginator("list_clusters")
        args: Dict[str, Any] = dict()
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results: List[str] = []
        for _response in response_iterator:
            response = ListClustersResponse(**_response)
            if response.clusterArns:
                results.extend(response.clusterArns)
            else:
                break
        self.sessionize(results)
        return results

    def update(self, model: "Cluster") -> "Cluster":
        """
        Update an ECS cluster.

        Args:
            model: The :py:class:``Cluster`` to update.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            clusterName=data.get("clusterName"),
            settings=data.get("settings"),
            configuration=data.get("configuration"),
            serviceConnectDefaults=data.get("serviceConnectDefaults"),
        )
        _response = self.client.update_cluster(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = UpdateClusterResponse(**_response)

        self.sessionize(response.cluster)
        return cast("Cluster", response.cluster)

    def partial_update(
        self,
        cluster: str,
        *,
        settings: Optional[List["ClusterSetting"]] = None,
        configuration: Optional["ClusterConfiguration"] = None,
        serviceConnectDefaults: Optional["ClusterServiceConnectDefaultsRequest"] = None
    ) -> "Cluster":
        """
        Update individual attributes of an ECS cluster.

        Args:
            cluster: The name of the cluster to modify the settings for.

        Keyword Args:
            settings: The cluster settings for your cluster.
            configuration: The execute command configuration for the cluster.
            serviceConnectDefaults: Use this parameter to set a default Service Connect
                namespace. After you set a default Service Connect namespace, any new
                services with Service Connect turned on that are created in the cluster are
                added as client services in the namespace. This setting only applies to new
                services that set the ``enabled`` parameter to ``true`` in the
                ``ServiceConnectConfiguration``. You can set the namespace of each service
                individually in the ``ServiceConnectConfiguration`` to override this
                default parameter.
        """
        args: Dict[str, Any] = dict(
            cluster=self.serialize(cluster),
            settings=self.serialize(settings),
            configuration=self.serialize(configuration),
            serviceConnectDefaults=self.serialize(serviceConnectDefaults),
        )
        _response = self.client.update_cluster(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = UpdateClusterResponse(**_response)

        self.sessionize(response.cluster)
        return cast("Cluster", response.cluster)


class TaskDefinitionManager(Boto3ModelManager):

    service_name: str = "ecs"

    def create(
        self, model: "TaskDefinition", tags: Optional[List["ECSTag"]] = None
    ) -> "TaskDefinition":
        """
        Registers a new task definition from the supplied ``family`` and
        ``containerDefinitions``. Optionally, you can add data volumes to your
        containers with the ``volumes`` parameter. For more information about task
        definition parameters and defaults, see `Amazon ECS Task Definitions <https://d
        ocs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html>`_ in the
        *Amazon Elastic Container Service Developer Guide*.

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

        Keyword Args:
            tags: The metadata that you apply to the task definition to help you
                categorize and organize them. Each tag consists of a key and an optional
                value. You define both of them.

        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            family=data.get("family"),
            containerDefinitions=data.get("containerDefinitions"),
            taskRoleArn=data.get("taskRoleArn"),
            executionRoleArn=data.get("executionRoleArn"),
            networkMode=data.get("networkMode"),
            volumes=data.get("volumes"),
            placementConstraints=data.get("placementConstraints"),
            requiresCompatibilities=data.get("requiresCompatibilities"),
            cpu=data.get("cpu"),
            memory=data.get("memory"),
            tags=self.serialize(tags),
            pidMode=data.get("pidMode"),
            ipcMode=data.get("ipcMode"),
            proxyConfiguration=data.get("proxyConfiguration"),
            inferenceAccelerators=data.get("inferenceAccelerators"),
            ephemeralStorage=data.get("ephemeralStorage"),
            runtimePlatform=data.get("runtimePlatform"),
        )
        _response = self.client.register_task_definition(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = RegisterTaskDefinitionResponse(**_response)

        self.sessionize(response.taskDefinition)
        return cast("TaskDefinition", response.taskDefinition)

    def delete(self, taskDefinition: str) -> "TaskDefinition":
        """
        Deregisters the specified task definition by family and revision. Upon
        deregistration, the task definition is marked as ``INACTIVE``. Existing
        tasks and services that reference an ``INACTIVE`` task definition
        continue to run without disruption. Existing services that reference an
        ``INACTIVE`` task definition can still scale up or down by modifying
        the service's desired count. If you want to delete a task definition
        revision, you must first deregister the task definition revision.

        Args:
            taskDefinition: The ``family`` and ``revision`` (``family:revision``) or
                full Amazon Resource Name (ARN) of the task definition to deregister. You
                must specify a ``revision``.
        """
        args: Dict[str, Any] = dict(taskDefinition=self.serialize(taskDefinition))
        _response = self.client.deregister_task_definition(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DeregisterTaskDefinitionResponse(**_response)
        return cast(TaskDefinition, response.taskDefinition)

    def get(
        self, taskDefinition: str, *, include: Optional[List[Literal["TAGS"]]] = None
    ) -> Optional["TaskDefinition"]:
        """
        Describes a task definition. You can specify a ``family`` and
        ``revision`` to find information about a specific task definition, or
        you can simply specify the family to find the latest ``ACTIVE``
        revision in that family.

        Args:
            taskDefinition: The ``family`` for the latest ``ACTIVE`` revision,
                ``family`` and ``revision`` (``family:revision``) for a specific revision
                in the family, or full Amazon Resource Name (ARN) of the task definition to
                describe.

        Keyword Args:
            include: Determines whether to see the resource tags for the task
                definition. If ``TAGS`` is specified, the tags are included in the
                response. If this field is omitted, tags aren't included in the response.
        """
        args: Dict[str, Any] = dict(
            taskDefinition=self.serialize(taskDefinition),
            include=self.serialize(include),
        )
        _response = self.client.describe_task_definition(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeTaskDefinitionResponse(**_response)

        if response and response.taskDefinition:
            self.sessionize(response.taskDefinition)
            return response.taskDefinition
        return None

    @ecs_task_definitions_only
    def list(
        self,
        *,
        familyPrefix: Optional[str] = None,
        status: Optional[Literal["ACTIVE", "INACTIVE", "DELETE_IN_PROGRESS"]] = None,
        sort: Optional[Literal["ASC", "DESC"]] = None
    ) -> List[str]:
        """
        Returns a list of task definitions that are registered to your account.
        You can filter the results by family name with the ``familyPrefix``
        parameter or by status with the ``status`` parameter.

        Keyword Args:
            familyPrefix: The full family name to filter the ``ListTaskDefinitions``
                results with. Specifying a ``familyPrefix`` limits the listed task
                definitions to task definition revisions that belong to that family.
            status: The task definition status to filter the ``ListTaskDefinitions``
                results with. By default, only ``ACTIVE`` task definitions are listed. By
                setting this parameter to ``INACTIVE``, you can view task definitions that
                are ``INACTIVE`` as long as an active task or service still references
                them. If you paginate the resulting output, be sure to keep the ``status``
                value constant in each subsequent request.
            sort: The order to sort the results in. Valid values are ``ASC`` and
                ``DESC``. By default, (``ASC``) task definitions are listed
                lexicographically by family name and in ascending numerical order by
                revision so that the newest task definitions in a family are listed last.
                Setting this parameter to ``DESC`` reverses the sort order on family name
                and revision. This is so that the newest task definitions in a family are
                listed first.
        """
        paginator = self.client.get_paginator("list_task_definitions")
        args: Dict[str, Any] = dict(
            familyPrefix=self.serialize(familyPrefix),
            status=self.serialize(status),
            sort=self.serialize(sort),
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results: List[str] = []
        for _response in response_iterator:
            response = ListTaskDefinitionsResponse(**_response)
            if response.taskDefinitionArns:
                results.extend(response.taskDefinitionArns)
            else:
                break
        self.sessionize(results)
        return results

    def update(
        self, model: "TaskDefinition", tags: Optional[List["ECSTag"]] = None
    ) -> "TaskDefinition":
        """
        Registers a new task definition from the supplied ``family`` and
        ``containerDefinitions``. Optionally, you can add data volumes to your
        containers with the ``volumes`` parameter. For more information about task
        definition parameters and defaults, see `Amazon ECS Task Definitions <https://d
        ocs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html>`_ in the
        *Amazon Elastic Container Service Developer Guide*.

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

        Keyword Args:
            tags: The metadata that you apply to the task definition to help you
                categorize and organize them. Each tag consists of a key and an optional
                value. You define both of them.

        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            family=data.get("family"),
            containerDefinitions=data.get("containerDefinitions"),
            taskRoleArn=data.get("taskRoleArn"),
            executionRoleArn=data.get("executionRoleArn"),
            networkMode=data.get("networkMode"),
            volumes=data.get("volumes"),
            placementConstraints=data.get("placementConstraints"),
            requiresCompatibilities=data.get("requiresCompatibilities"),
            cpu=data.get("cpu"),
            memory=data.get("memory"),
            tags=self.serialize(tags),
            pidMode=data.get("pidMode"),
            ipcMode=data.get("ipcMode"),
            proxyConfiguration=data.get("proxyConfiguration"),
            inferenceAccelerators=data.get("inferenceAccelerators"),
            ephemeralStorage=data.get("ephemeralStorage"),
            runtimePlatform=data.get("runtimePlatform"),
        )
        _response = self.client.register_task_definition(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = RegisterTaskDefinitionResponse(**_response)

        self.sessionize(response.taskDefinition)
        return cast("TaskDefinition", response.taskDefinition)


class ContainerInstanceManager(ReadonlyBoto3ModelManager):

    service_name: str = "ecs"

    def get(
        self,
        containerInstance: str,
        *,
        cluster: str = "default",
        include: List[Literal["TAGS", "CONTAINER_INSTANCE_HEALTH"]] = [
            "TAGS",
            "CONTAINER_INSTANCE_HEALTH",
        ]
    ) -> Optional["ContainerInstance"]:
        """
        Describes one or more container instances. Returns metadata about each
        container instance requested.

        Args:
            containerInstance: The container instance ID or full Amazon Resource Name
                (ARN) entry for the container instance you want to describe.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                that hosts the container instances to describe. If you do not specify a
                cluster, the default cluster is assumed. This parameter is required if the
                container instance or container instances you are describing were launched
                in any cluster other than the default cluster.
            include: Specifies whether you want to see the resource tags for the
                container instance. If ``TAGS`` is specified, the tags are included in the
                response. If ``CONTAINER_INSTANCE_HEALTH`` is specified, the container
                instance health is included in the response. If this field is omitted, tags
                and container instance health status aren't included in the response.
        """
        args: Dict[str, Any] = dict(
            containerInstances=self.serialize([containerInstance]),
            cluster=self.serialize(cluster),
            include=self.serialize(include),
        )
        _response = self.client.describe_container_instances(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeContainerInstancesResponse(**_response)

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

    def get_many(
        self,
        containerInstances: List[str],
        *,
        cluster: str = "default",
        include: List[Literal["TAGS", "CONTAINER_INSTANCE_HEALTH"]] = [
            "TAGS",
            "CONTAINER_INSTANCE_HEALTH",
        ]
    ) -> List["ContainerInstance"]:
        """
        Describes one or more container instances. Returns metadata about each
        container instance requested.

        Args:
            containerInstances: A list of up to 100 container instance IDs or full
                Amazon Resource Name (ARN) entries.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                that hosts the container instances to describe. If you do not specify a
                cluster, the default cluster is assumed. This parameter is required if the
                container instance or container instances you are describing were launched
                in any cluster other than the default cluster.
            include: Specifies whether you want to see the resource tags for the
                container instance. If ``TAGS`` is specified, the tags are included in the
                response. If ``CONTAINER_INSTANCE_HEALTH`` is specified, the container
                instance health is included in the response. If this field is omitted, tags
                and container instance health status aren't included in the response.
        """
        args: Dict[str, Any] = dict(
            containerInstances=self.serialize(containerInstances),
            cluster=self.serialize(cluster),
            include=self.serialize(include),
        )
        _response = self.client.describe_container_instances(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeContainerInstancesResponse(**_response)

        self.sessionize(respsonse.containerInstances)
        return response.containerInstancesj

    @ecs_container_instances_only
    def list(
        self,
        *,
        cluster: str = "default",
        filter: Optional[str] = None,
        status: Optional[
            Literal[
                "ACTIVE",
                "DRAINING",
                "REGISTERING",
                "DEREGISTERING",
                "REGISTRATION_FAILED",
            ]
        ] = None
    ) -> List[str]:
        """
        Returns a list of container instances in a specified cluster. You can filter
        the results of a ``ListContainerInstances`` operation with cluster query
        language statements inside the ``filter`` parameter. For more information, see
        `Cluster Query
        Language <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-
        query-language.html>`_ in the *Amazon Elastic Container Service Developer Guide*.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                that hosts the container instances to list. If you do not specify a
                cluster, the default cluster is assumed.
            filter: You can filter the results of a ``ListContainerInstances``
                operation with cluster query language statements. For more information, see
                `Cluster Query Language
                <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-
                query-language.html>`_ in the *Amazon Elastic Container Service Developer
                Guide*.
            status: Filters the container instances by status. For example, if you
                specify the ``DRAINING`` status, the results include only container
                instances that have been set to ``DRAINING`` using
                `UpdateContainerInstancesState <https://docs.aws .amazon.com/AmazonECS/late
                st/APIReference/API_UpdateContainerInstancesState.htm l>`_. If you don't
                specify this parameter, the default is to include container instances set
                to all states other than ``INACTIVE``.

        """
        paginator = self.client.get_paginator("list_container_instances")
        args: Dict[str, Any] = dict(
            cluster=self.serialize(cluster),
            filter=self.serialize(filter),
            status=self.serialize(status),
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results: List[str] = []
        for _response in response_iterator:
            response = ListContainerInstancesResponse(**_response)
            if response.containerInstanceArns:
                results.extend(response.containerInstanceArns)
            else:
                break
        self.sessionize(results)
        return results

    def list_tasks(
        self,
        containerInstance: str,
        *,
        cluster: Optional[str] = None,
        family: Optional[str] = None,
        startedBy: Optional[str] = None,
        serviceName: Optional[str] = None,
        desiredStatus: Optional[Literal["RUNNING", "PENDING", "STOPPED"]] = None,
        launchType: Optional[Literal["EC2", "FARGATE", "EXTERNAL"]] = None
    ) -> List[str]:
        """
        Returns a list of tasks. You can filter the results by cluster, task
        definition family, container instance, launch type, what IAM principal
        started the task, or by the desired status of the task.

        Args:
            containerInstance: The container instance ID or full ARN of the container
                instance to use when filtering the ``ListTasks`` results. Specifying a
                ``containerInstance`` limits the results to tasks that belong to that
                container instance.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                to use when filtering the ``ListTasks`` results. If you do not specify a
                cluster, the default cluster is assumed.
            family: The name of the task definition family to use when filtering the
                ``ListTasks`` results. Specifying a ``family`` limits the results to tasks
                that belong to that family.
            startedBy: The ``startedBy`` value to filter the task results with.
                Specifying a ``startedBy`` value limits the results to tasks that were
                started with that value.
            serviceName: The name of the service to use when filtering the
                ``ListTasks`` results. Specifying a ``serviceName`` limits the results to
                tasks that belong to that service.
            desiredStatus: The task desired status to use when filtering the
                ``ListTasks`` results. Specifying a ``desiredStatus`` of ``STOPPED`` limits
                the results to tasks that Amazon ECS has set the desired status to
                ``STOPPED``. This can be useful for debugging tasks that aren't starting
                properly or have died or finished. The default status filter is
                ``RUNNING``, which shows tasks that Amazon ECS has set the desired status
                to ``RUNNING``.
            launchType: The launch type to use when filtering the ``ListTasks``
                results.
        """
        paginator = self.client.get_paginator("list_tasks")
        args: Dict[str, Any] = dict(
            cluster=self.serialize(cluster),
            containerInstance=self.serialize([containerInstance]),
            family=self.serialize(family),
            startedBy=self.serialize(startedBy),
            serviceName=self.serialize(serviceName),
            desiredStatus=self.serialize(desiredStatus),
            launchType=self.serialize(launchType),
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )

        results: List[str] = []

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

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


class TaskManager(Boto3ModelManager):

    service_name: str = "ecs"

    @ecs_task_populate_taskDefinition
    def get(
        self,
        task: str,
        *,
        cluster: str = "default",
        include: List[Literal["TAGS"]] = ["TAGS"]
    ) -> Optional["Task"]:
        """
        Describes a specified task or tasks.

        Args:
            task: The task ID or full Amazon Resource Name (ARN) entry of the task that
                you want to describe.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                that hosts the task or tasks to describe. If you do not specify a cluster,
                the default cluster is assumed. This parameter is required if the task or
                tasks you are describing were launched in any cluster other than the
                default cluster.
            include: Specifies whether you want to see the resource tags for the task.
                If ``TAGS`` is specified, the tags are included in the response. If this
                field is omitted, tags aren't included in the response.
        """
        args: Dict[str, Any] = dict(
            tasks=self.serialize([task]),
            cluster=self.serialize(cluster),
            include=self.serialize(include),
        )
        _response = self.client.describe_tasks(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeTasksResponse(**_response)

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

    @ecs_task_populate_taskDefinitions
    def get_many(
        self,
        tasks: List[str],
        *,
        cluster: str = "default",
        include: List[Literal["TAGS"]] = ["TAGS"]
    ) -> List["Task"]:
        """
        Describes a specified task or tasks.

        Args:
            tasks: A list of up to 100 task IDs or full ARN entries.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                that hosts the task or tasks to describe. If you do not specify a cluster,
                the default cluster is assumed. This parameter is required if the task or
                tasks you are describing were launched in any cluster other than the
                default cluster.
            include: Specifies whether you want to see the resource tags for the task.
                If ``TAGS`` is specified, the tags are included in the response. If this
                field is omitted, tags aren't included in the response.
        """
        args: Dict[str, Any] = dict(
            tasks=self.serialize(tasks),
            cluster=self.serialize(cluster),
            include=self.serialize(include),
        )
        _response = self.client.describe_tasks(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = DescribeTasksResponse(**_response)

        self.sessionize(respsonse.tasks)
        return response.tasksj

    @ecs_tasks_only
    def list(
        self,
        *,
        cluster: str = "default",
        containerInstance: Optional[str] = None,
        family: Optional[str] = None,
        startedBy: Optional[str] = None,
        serviceName: Optional[str] = None,
        desiredStatus: Optional[Literal["RUNNING", "PENDING", "STOPPED"]] = None,
        launchType: Optional[Literal["EC2", "FARGATE", "EXTERNAL"]] = None
    ) -> List[str]:
        """
        Returns a list of tasks. You can filter the results by cluster, task
        definition family, container instance, launch type, what IAM principal
        started the task, or by the desired status of the task.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                to use when filtering the ``ListTasks`` results. If you do not specify a
                cluster, the default cluster is assumed.
            containerInstance: The container instance ID or full ARN of the container
                instance to use when filtering the ``ListTasks`` results. Specifying a
                ``containerInstance`` limits the results to tasks that belong to that
                container instance.
            family: The name of the task definition family to use when filtering the
                ``ListTasks`` results. Specifying a ``family`` limits the results to tasks
                that belong to that family.
            startedBy: The ``startedBy`` value to filter the task results with.
                Specifying a ``startedBy`` value limits the results to tasks that were
                started with that value.
            serviceName: The name of the service to use when filtering the
                ``ListTasks`` results. Specifying a ``serviceName`` limits the results to
                tasks that belong to that service.
            desiredStatus: The task desired status to use when filtering the
                ``ListTasks`` results. Specifying a ``desiredStatus`` of ``STOPPED`` limits
                the results to tasks that Amazon ECS has set the desired status to
                ``STOPPED``. This can be useful for debugging tasks that aren't starting
                properly or have died or finished. The default status filter is
                ``RUNNING``, which shows tasks that Amazon ECS has set the desired status
                to ``RUNNING``.
            launchType: The launch type to use when filtering the ``ListTasks``
                results.
        """
        paginator = self.client.get_paginator("list_tasks")
        args: Dict[str, Any] = dict(
            cluster=self.serialize(cluster),
            containerInstance=self.serialize(containerInstance),
            family=self.serialize(family),
            startedBy=self.serialize(startedBy),
            serviceName=self.serialize(serviceName),
            desiredStatus=self.serialize(desiredStatus),
            launchType=self.serialize(launchType),
        )
        response_iterator = paginator.paginate(
            **{k: v for k, v in args.items() if v is not None}
        )
        results: List[str] = []
        for _response in response_iterator:
            response = ListTasksResponse(**_response)
            if response.taskArns:
                results.extend(response.taskArns)
            else:
                break
        self.sessionize(results)
        return results

    def create(
        self,
        model: "Task",
        capacityProviderStrategy: Optional[List["CapacityProviderStrategyItem"]] = None,
        count: Optional[int] = None,
        enableECSManagedTags: Optional[bool] = None,
        networkConfiguration: Optional["NetworkConfiguration"] = None,
        placementConstraints: Optional[List["PlacementConstraint"]] = None,
        placementStrategy: Optional[List["PlacementStrategy"]] = None,
        propagateTags: Optional[Literal["TASK_DEFINITION", "SERVICE", "NONE"]] = None,
        referenceId: Optional[str] = None,
        clientToken: Optional[str] = None,
        volumeConfigurations: Optional[List["TaskVolumeConfiguration"]] = None,
    ) -> "Task":
        """
        Starts a new task using the specified task definition.

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

        Keyword Args:
            capacityProviderStrategy: The capacity provider strategy to use for the
                task.
            count: The number of instantiations of the specified task to place on your
                cluster. You can specify up to 10 tasks for each call.
            enableECSManagedTags: Specifies whether to use Amazon ECS managed tags for
                the task. For more information, see `Tagging Your Amazon ECS Resources
                <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs- using-
                tags.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
            networkConfiguration: The network configuration for the task. This
                parameter is required for task definitions that use the ``awsvpc`` network
                mode to receive their own elastic network interface, and it isn't supported
                for other network modes. For more information, see `Task networking
                <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-
                networking.html>`_ in the *Amazon Elastic Container Service Developer
                Guide*.
            placementConstraints: An array of placement constraint objects to use for
                the task. You can specify up to 10 constraints for each task (including
                constraints in the task definition and those specified at runtime).
            placementStrategy: The placement strategy objects to use for the task. You
                can specify a maximum of 5 strategy rules for each task.
            propagateTags: Specifies whether to propagate the tags from the task
                definition to the task. If no value is specified, the tags aren't
                propagated. Tags can only be propagated to the task during task creation.
                To add tags to a task after task creation, use the`TagResource
                <https://docs.aws.amazon.com/AmazonECS/latest/API
                Reference/API_TagResource.html>`_ API action.
            referenceId: The reference ID to use for the task. The reference ID can
                have a maximum length of 1024 characters.
            clientToken: An identifier that you provide to ensure the idempotency of
                the request. It must be unique and is case sensitive. Up to 64 characters
                are allowed. The valid characters are characters in the range of 33-126,
                inclusive. For more information, see `Ensuring idempotency
                <https://docs.aws.amazon.com/AmazonECS/l
                atest/APIReference/ECS_Idempotency.html>`_.
            volumeConfigurations: The details of the volume that was
                ``configuredAtLaunch``. You can configure the size, volumeType, IOPS,
                throughput, snapshot and encryption in in `TaskMana
                gedEBSVolumeConfiguration
                <https://docs.aws.amazon.com/AmazonECS/latest/APIRefe
                rence/API_TaskManagedEBSVolumeConfiguration.html>`_. The ``name`` of the
                volume must match the ``name`` from the task definition.
        """
        data = model.model_dump(exclude_none=True, by_alias=True)
        args = dict(
            taskDefinition=data.get("taskDefinition"),
            capacityProviderStrategy=self.serialize(capacityProviderStrategy),
            clusterArn=data.get("clusterArn"),
            count=self.serialize(count),
            enableECSManagedTags=self.serialize(enableECSManagedTags),
            enableExecuteCommand=data.get("enableExecuteCommand"),
            group=data.get("group"),
            launchType=data.get("launchType"),
            networkConfiguration=self.serialize(networkConfiguration),
            overrides=data.get("overrides"),
            placementConstraints=self.serialize(placementConstraints),
            placementStrategy=self.serialize(placementStrategy),
            platformVersion=data.get("platformVersion"),
            propagateTags=self.serialize(propagateTags),
            referenceId=self.serialize(referenceId),
            startedBy=data.get("startedBy"),
            tags=data.get("tags"),
            clientToken=self.serialize(clientToken),
            volumeConfigurations=self.serialize(volumeConfigurations),
        )
        _response = self.client.run_task(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = RunTaskResponse(**_response)

        self.sessionize(response.tasks[0])
        return cast("Task", response.tasks[0])

    def delete(
        self, task: str, *, cluster: Optional[str] = None, reason: Optional[str] = None
    ) -> "Task":
        """
        Stops a running task. Any tags associated with the task will be
        deleted.

        Args:
            task: The task ID of the task to stop.

        Keyword Args:
            cluster: The short name or full Amazon Resource Name (ARN) of the cluster
                that hosts the task to stop. If you do not specify a cluster, the default
                cluster is assumed.
            reason: An optional message specified when a task is stopped. For example,
                if you're using a custom scheduler, you can use this parameter to specify
                the reason for stopping the task here, and the message appears in
                subsequent `DescribeTasks <h ttps://docs.aws.amazon.com/AmazonECS/latest/AP
                IReference/API_DescribeTasks.html >`_> API operations on this task.
        """
        args: Dict[str, Any] = dict(
            task=self.serialize(task),
            cluster=self.serialize(cluster),
            reason=self.serialize(reason),
        )
        _response = self.client.stop_task(
            **{k: v for k, v in args.items() if v is not None}
        )
        response = StopTaskResponse(**_response)
        return cast(Task, response.task)


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


class ECSTag(Boto3Model):
    """
    The metadata that you apply to a resource to help you categorize and
    organize them. Each tag consists of a key and an optional value. You define
    them.

    The following basic restrictions apply to tags:

    * Maximum number of tags per resource - 50
    * For each resource, each tag key must be unique, and each tag key can have
      only one value.
    * Maximum key length - 128 Unicode characters in UTF-8
    * Maximum value length - 256 Unicode characters in UTF-8
    * If your tagging schema is used across multiple services and resources,
      remember that other services may have restrictions on allowed characters.
      Generally allowed characters are: letters, numbers, and spaces representable in
      UTF-8, and the following characters: + - = . _ : / @.
    * Tag keys and values are case-sensitive.
    * Do not use ``aws:``, ``AWS:``, or any upper or lowercase combination of such
      as a prefix for either keys or values as it is reserved for Amazon Web Services
      use. You cannot edit or delete tag keys or values with this prefix. Tags with
      this prefix do not count against your tags per resource limit.
    """

    key: Optional[str] = None
    """
    One part of a key-value pair that make up a tag.

    A ``key`` is a general label
    that acts like a category for more specific tag values.
    """
    value: Optional[str] = None
    """
    The optional part of a key-value pair that make up a tag.

    A ``value`` acts as
    a descriptor within a tag category (key).
    """


class LoadBalancerConfiguration(Boto3Model):
    """
    The load balancer configuration to use with a service or task set.

    When you add, update, or remove a load balancer configuration, Amazon ECS
    starts a new deployment with the updated Elastic Load Balancing configuration.
    This causes tasks to register to and deregister from load balancers.

    We recommend that you verify this on a test environment before you update the
    Elastic Load Balancing configuration.

    A service-linked role is required for services that use multiple target
    groups. For more information, see `Using service-linked
    roles <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using-
    service-linked-roles.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.
    """

    targetGroupArn: Optional[str] = None
    """
    The full Amazon Resource Name (ARN) of the Elastic Load Balancing target
    group or groups associated with a service or task set.
    """
    loadBalancerName: Optional[str] = None
    """
    The name of the load balancer to associate with the Amazon ECS service or
    task set.
    """
    containerName: Optional[str] = None
    """
    The name of the container (as it appears in a container definition) to
    associate with the load balancer.
    """
    containerPort: Optional[int] = None
    """
    The port on the container to associate with the load balancer.

    This port must
    correspond to a ``containerPort`` in the task definition the tasks in the
    service are using. For tasks that use the EC2 launch type, the container
    instance they're launched on must allow ingress traffic on the ``hostPort`` of
    the port mapping.
    """


class ServiceRegistry(Boto3Model):
    """
    The details for the service registry.

    Each service may be associated with one service registry. Multiple service
    registries for each service are not supported.

    When you add, update, or remove the service registries configuration,
    Amazon ECS starts a new deployment. New tasks are registered and
    deregistered to the updated service registry configuration.
    """

    registryArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the service registry.

    The currently supported service registry is Cloud Map. For more
    information, see
    `CreateService <https://docs.aws.amazon.com/cloud-
    map/latest/api/API_CreateService.html>`_.
    """
    port: Optional[int] = None
    """
    The port value used if your service discovery service specified an SRV
    record.

    This field might be used if both the ``awsvpc`` network mode and SRV records
    are used.
    """
    containerName: Optional[str] = None
    """
    The container name value to be used for your service discovery service.

    It's
    already specified in the task definition. If the task definition that your
    service task specifies uses the ``bridge`` or ``host`` network mode, you must
    specify a ``containerName`` and ``containerPort`` combination from the task
    definition. If the task definition that your service task specifies uses the
    ``awsvpc`` network mode and a type SRV DNS record is used, you must specify
    either a ``containerName`` and ``containerPort`` combination or a ``port``
    value. However, you can't specify both.
    """
    containerPort: Optional[int] = None
    """
    The port value to be used for your service discovery service.

    It's already
    specified in the task definition. If the task definition your service task
    specifies uses the ``bridge`` or ``host`` network mode, you must specify a
    ``containerName`` and ``containerPort`` combination from the task definition.
    If the task definition your service task specifies uses the ``awsvpc`` network
    mode and a type SRV DNS record is used, you must specify either a
    ``containerName`` and ``containerPort`` combination or a ``port`` value.
    However, you can't specify both.
    """


class CapacityProviderStrategyItem(Boto3Model):
    """The details of a capacity provider strategy. A capacity provider strategy can
    be set when using the `RunTask <https://docs.aws.amazon.com/AmazonECS/latest/AP
    IReference/API_RunTask.html>`_or `CreateCluster <https://docs.aws.amazon.com/Amaz
    onECS/latest/APIReference/API_CreateCluster.html>`_ APIs or as the default
    capacity provider strategy for a cluster with the ``CreateCluster`` API.

    Only capacity providers that are already associated with a cluster and have an
    ``ACTIVE`` or ``UPDATING`` status can be used in a capacity provider strategy.
    The `PutClusterCapacityProviders <https://docs.aws.amazon.com/AmazonECS/latest/
    APIReference/API_PutClusterCapacityProviders.html>`_ API is used to associate a
    capacity provider with a cluster.

    If specifying a capacity provider that uses an Auto Scaling group, the capacity
    provider must already be created. New Auto Scaling group capacity providers can
    be created with the `CreateClusterCapacityProvider <https://docs.aws.amazon.com
    /AmazonECS/latest/APIReference/API_CreateClusterCapacityProvider.html>`_ API
    operation.

    To use a Fargate capacity provider, specify either the ``FARGATE`` or
    ``FARGATE_SPOT`` capacity providers. The Fargate capacity providers are
    available to all accounts and only need to be associated with a cluster to be
    used in a capacity provider strategy.

    With ``FARGATE_SPOT``, you can run interruption tolerant tasks at a rate that's
    discounted compared to the ``FARGATE`` price. ``FARGATE_SPOT`` runs tasks on
    spare compute capacity. When Amazon Web Services needs the capacity back, your
    tasks are interrupted with a two-minute warning. ``FARGATE_SPOT`` only
    supports Linux tasks with the X86_64 architecture on platform version 1.3.0
    or later.

    A capacity provider strategy may contain a maximum of 6 capacity providers.

    """

    capacityProvider: str
    """
    The short name of the capacity provider.
    """
    weight: Optional[int] = None
    """
    The *weight* value designates the relative percentage of the total number
    of tasks launched that should use the specified capacity provider.

    The ``weight``
    value is taken into consideration after the ``base`` value, if defined, is
    satisfied.
    """
    base: Optional[int] = None
    """
    The *base* value designates how many tasks, at a minimum, to run on the
    specified capacity provider.

    Only one capacity provider in a capacity provider
    strategy can have a *base* defined. If no value is specified, the default value
    of ``0`` is used.
    """


class DeploymentCircuitBreaker(Boto3Model):
    """
    The deployment circuit breaker can only be used for services using the
    rolling update (``ECS``) deployment type.

    The **deployment circuit breaker** determines whether a service deployment
    will fail if the service can't reach a steady state. If you use the
    deployment circuit breaker, a service deployment will transition to a
    failed state and stop launching new tasks. If you use the rollback option,
    when a service deployment fails, the service is rolled back to the last
    deployment that completed successfully. For more information, see
    `Rolling update <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-
    type-ecs.html>`_ in the *Amazon Elastic Container Service Developer Guide*
    """

    enable: bool
    """
    Determines whether to use the deployment circuit breaker logic for the
    service.
    """
    rollback: bool
    """
    Determines whether to configure Amazon ECS to roll back the service if a
    service deployment fails.

    If rollback is on, when a service deployment fails, the service is rolled
    back to the last deployment that completed successfully.
    """


class DeploymentAlarms(Boto3Model):
    """
    Information about the CloudWatch alarms.
    """

    alarmNames: List[str]
    """
    One or more CloudWatch alarm names.

    Use a "," to separate the alarms.
    """
    enable: bool
    """
    Determines whether to use the CloudWatch alarm option in the service
    deployment process.
    """
    rollback: bool
    """
    Determines whether to configure Amazon ECS to roll back the service if a
    service deployment fails.

    If rollback is used, when a service deployment fails, the service is rolled
    back to the last deployment that completed successfully.
    """


class DeploymentConfiguration(Boto3Model):
    """
    Optional deployment parameters that control how many tasks run during the
    deployment and the ordering of stopping and starting tasks.
    """

    deploymentCircuitBreaker: Optional[DeploymentCircuitBreaker] = None
    """
    The deployment circuit breaker can only be used for services using the
    rolling update (``ECS``) deployment type.
    """
    maximumPercent: Optional[int] = None
    """
    If a service is using the rolling update (``ECS``) deployment type, the
    ``maximumPercent`` parameter represents an upper limit on the number of
    your service's tasks that are allowed in the ``RUNNING`` or ``PENDING``
    state during a deployment, as a percentage of the ``desiredCount`` (rounded
    down to the nearest integer).

    This parameter enables you to define the deployment batch
    size. For example, if your service is using the ``REPLICA`` service scheduler
    and has a ``desiredCount`` of four tasks and a ``maximumPercent`` value of
    200%, the scheduler may start four new tasks before stopping the four older
    tasks (provided that the cluster resources required to do this are available).
    The default ``maximumPercent`` value for a service using the ``REPLICA``
    service scheduler is 200%.
    """
    minimumHealthyPercent: Optional[int] = None
    """
    If a service is using the rolling update (``ECS``) deployment type, the
    ``minimumHealthyPercent`` represents a lower limit on the number of your
    service's tasks that must remain in the ``RUNNING`` state during a
    deployment, as a percentage of the ``desiredCount`` (rounded up to the
    nearest integer).

    This parameter enables you to deploy without using additional cluster capacity.
    For example, if your service has a ``desiredCount`` of four tasks and a
    ``minimumHealthyPercent`` of 50%, the service scheduler may stop two existing
    tasks to free up cluster capacity before starting two new tasks.
    """
    alarms: Optional[DeploymentAlarms] = None
    """
    Information about the CloudWatch alarms.
    """


class AwsVpcConfiguration(Boto3Model):
    """
    The VPC subnets and security groups that are associated with a task.

    All specified subnets and security groups must be from the same VPC.
    """

    subnets: List[str]
    """
    The IDs of the subnets associated with the task or service.

    There's a limit of
    16 subnets that can be specified per ``awsvpcConfiguration``.
    """
    securityGroups: Optional[List[str]] = None
    """
    The IDs of the security groups associated with the task or service.

    If you
    don't specify a security group, the default security group for the VPC is used.
    There's a limit of 5 security groups that can be specified per
    ``awsvpcConfiguration``.
    """
    assignPublicIp: Optional[Literal["ENABLED", "DISABLED"]] = None
    """
    Whether the task's elastic network interface receives a public IP address.

    The
    default value is ``DISABLED``.
    """


class NetworkConfiguration(Boto3Model):
    """
    The network configuration for the task set.
    """

    awsvpcConfiguration: Optional[AwsVpcConfiguration] = None
    """
    The VPC subnets and security groups that are associated with a task.
    """


class Scale(Boto3Model):
    """
    A floating-point percentage of your desired number of tasks to place and
    keep running in the task set.
    """

    value: Optional[float] = None
    """
    The value, specified as a percent total of a service's ``desiredCount``, to
    scale the task set.

    Accepted values are numbers between 0 and 100.
    """
    unit: Optional[Literal["PERCENT"]] = None
    """
    The unit of measure for the scale value.
    """


class DeploymentEphemeralStorage(Boto3Model):
    """
    The Fargate ephemeral storage settings for the task set.
    """

    kmsKeyId: Optional[str] = None
    """
    Specify an Key Management Service key ID to encrypt the ephemeral storage
    for deployment.
    """


class TaskSet(TagsDictMixin, Boto3Model):
    """
    Information about a set of Amazon ECS tasks in either an CodeDeploy or an
    ``EXTERNAL`` deployment.

    An Amazon ECS task set includes details such as the desired number of
    tasks, how many tasks are running, and whether the task set serves
    production traffic.
    """

    tag_class: ClassVar[Type] = ECSTag
    Tags: List["ECSTag"] = Field(default=None, serialization_alias="tags")
    """
    The metadata that you apply to the task set to help you categorize and
    organize them.

    Each tag consists of a key and an optional value. You define both.
    """
    id: Optional[str] = None
    """
    The ID of the task set.
    """
    taskSetArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the task set.
    """
    serviceArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the service the task set exists in.
    """
    clusterArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the cluster that the service that hosts
    the task set exists in.
    """
    startedBy: Optional[str] = None
    """
    The tag specified when a task set is started.

    If an CodeDeploy deployment
    created the task set, the ``startedBy`` parameter is ``CODE_DEPLOY``. If an
    external deployment created the task set, the ``startedBy`` field isn't used.
    """
    externalId: Optional[str] = None
    """
    The external ID associated with the task set.
    """
    status: Optional[str] = None
    """
    The status of the task set.

    The following describes each state.
    """
    taskDefinition: Optional[str] = None
    """
    The task definition that the task set is using.
    """
    computedDesiredCount: Optional[int] = None
    """
    The computed desired count for the task set.

    This is calculated by multiplying
    the service's ``desiredCount`` by the task set's ``scale`` percentage. The
    result is always rounded up. For example, if the computed desired count is
    1.2, it rounds up to 2 tasks.
    """
    pendingCount: Optional[int] = None
    """
    The number of tasks in the task set that are in the ``PENDING`` status
    during a deployment.

    A task in the ``PENDING`` state is preparing to enter the
    ``RUNNING`` state. A task set enters the ``PENDING`` status when it launches
    for the first time or when it's restarted after being in the ``STOPPED`` state.
    """
    runningCount: Optional[int] = None
    """
    The number of tasks in the task set that are in the ``RUNNING`` status
    during a deployment.

    A task in the ``RUNNING`` state is running and ready for use.
    """
    createdAt: Optional[datetime] = None
    """
    The Unix timestamp for the time when the task set was created.
    """
    updatedAt: Optional[datetime] = None
    """
    The Unix timestamp for the time when the task set was last updated.
    """
    launchType: Optional[Literal["EC2", "FARGATE", "EXTERNAL"]] = None
    """
    The launch type the tasks in the task set are using.

    For more information, see
    `Amazon ECS launch types <https://docs.aws.amazon.com/AmazonECS/latest/develope
    rguide/launch_types.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.
    """
    capacityProviderStrategy: Optional[List["CapacityProviderStrategyItem"]] = None
    """
    The capacity provider strategy that are associated with the task set.
    """
    platformVersion: Optional[str] = None
    """
    The Fargate platform version where the tasks in the task set are running.

    A
    platform version is only specified for tasks run on Fargate. For more
    information, see `Fargate platform versions <https://docs.aws.amazon.com/Amazon
    ECS/latest/developerguide/platform_versions.html>`_ in the *Amazon Elastic
    Container Service Developer Guide*.
    """
    platformFamily: Optional[str] = None
    """
    The operating system that your tasks in the set are running on.

    A platform family is specified only for tasks that use the Fargate launch
    type.
    """
    networkConfiguration: Optional[NetworkConfiguration] = None
    """
    The network configuration for the task set.
    """
    loadBalancers: Optional[List["LoadBalancerConfiguration"]] = None
    """
    Details on a load balancer that are used with a task set.
    """
    serviceRegistries: Optional[List["ServiceRegistry"]] = None
    """
    The details for the service discovery registries to assign to this task
    set.

    For more information, see
    `Service discovery <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-
    discovery.html>`_.
    """
    scale: Optional[Scale] = None
    """
    A floating-point percentage of your desired number of tasks to place and
    keep running in the task set.
    """
    stabilityStatus: Optional[Literal["STEADY_STATE", "STABILIZING"]] = None
    """
    The stability status.

    This indicates whether the task set has reached a steady
    state. If the following conditions are met, the task set are in
    ``STEADY_STATE``:
    """
    stabilityStatusAt: Optional[datetime] = None
    """
    The Unix timestamp for the time when the task set stability status was
    retrieved.
    """
    fargateEphemeralStorage: Optional[DeploymentEphemeralStorage] = None
    """
    The Fargate ephemeral storage settings for the task set.
    """


class ServiceConnectClientAlias(Boto3Model):
    """
    Each alias ("endpoint") is a fully-qualified name and port number that
    other tasks ("clients") can use to connect to this service.

    Each name and port mapping must be unique within the namespace.

    Tasks that run in a namespace can use short names to connect to services in
    the namespace. Tasks can connect to services across all of the clusters in
    the namespace. Tasks connect through a managed proxy container that
    collects logs and metrics for increased visibility. Only the tasks that
    Amazon ECS services create are supported with Service Connect. For more
    information, see
    `Service Connect <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-
    connect.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    port: int
    """
    The listening port number for the Service Connect proxy.

    This port is available inside of all of the tasks within the same
    namespace.
    """
    dnsName: Optional[str] = None
    """
    The ``dnsName`` is the name that you use in the applications of client
    tasks to connect to this service.

    The name must be a valid DNS name but doesn't need to be fully-qualified.
    The name can include up to 127 characters. The name can include lowercase
    letters, numbers, underscores (_), hyphens (-), and periods (.). The name
    can't start with a hyphen.
    """


class TimeoutConfiguration(Boto3Model):
    """
    A reference to an object that represents the configured timeouts for
    Service Connect.
    """

    idleTimeoutSeconds: Optional[int] = None
    """
    The amount of time in seconds a connection will stay active while idle.

    A value
    of ``0`` can be set to disable ``idleTimeout``.
    """
    perRequestTimeoutSeconds: Optional[int] = None
    """
    The amount of time waiting for the upstream to respond with a complete
    response per request.

    A value of ``0`` can be set to disable ``perRequestTimeout``.
    ``perRequestTimeout`` can only be set if Service Connect ``appProtocol`` isn't
    ``TCP``. Only ``idleTimeout`` is allowed for ``TCP`` ``appProtocol``.
    """


class ServiceConnectTlsCertificateAuthority(Boto3Model):
    """
    The signer certificate authority.
    """

    awsPcaAuthorityArn: Optional[str] = None
    """
    The ARN of the Amazon Web Services Private Certificate Authority
    certificate.
    """


class ServiceConnectTlsConfiguration(Boto3Model):
    """
    A reference to an object that represents a Transport Layer Security (TLS)
    configuration.
    """

    issuerCertificateAuthority: ServiceConnectTlsCertificateAuthority
    """
    The signer certificate authority.
    """
    kmsKey: Optional[str] = None
    """
    The Amazon Web Services Key Management Service key.
    """
    roleArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the IAM role that's associated with the
    Service Connect TLS.
    """


class ServiceConnectService(Boto3Model):
    """
    The Service Connect service object configuration.

    For more information, see
    `Service Connect <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-
    connect.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    portName: str
    """
    The ``portName`` must match the name of one of the ``portMappings`` from
    all the containers in the task definition of this Amazon ECS service.
    """
    discoveryName: Optional[str] = None
    """
    The ``discoveryName`` is the name of the new Cloud Map service that Amazon
    ECS creates for this Amazon ECS service.

    This must be unique within the Cloud Map namespace. The name can contain up
    to 64 characters. The name can include lowercase letters, numbers,
    underscores (_), and hyphens (-). The name can't start with a hyphen.
    """
    clientAliases: Optional[List["ServiceConnectClientAlias"]] = None
    """
    The list of client aliases for this Service Connect service.

    You use these to assign names that can be used by client applications. The
    maximum number of client aliases that you can have in this list is 1.
    """
    ingressPortOverride: Optional[int] = None
    """
    The port number for the Service Connect proxy to listen on.
    """
    timeout: Optional[TimeoutConfiguration] = None
    """
    A reference to an object that represents the configured timeouts for
    Service Connect.
    """
    tls: Optional[ServiceConnectTlsConfiguration] = None
    """
    A reference to an object that represents a Transport Layer Security (TLS)
    configuration.
    """


class Secret(Boto3Model):
    """An object representing the secret to expose to your container. Secrets can be
    exposed to a container in the following ways:

    * To inject sensitive data into your containers as environment variables, use
      the ``secrets`` container definition parameter.
    * To reference sensitive information in the log configuration of a container,
      use the ``secretOptions`` container definition parameter.

    For more information, see `Specifying sensitive
    data <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-
    sensitive-data.html>`_ in the *Amazon Elastic Container Service Developer Guide*.

    """

    name: str
    """
    The name of the secret.
    """
    valueFrom: str
    """
    The secret to expose to the container.

    The supported values are either the full ARN of the Secrets Manager secret
    or the full ARN of the parameter in the SSM Parameter Store.
    """


class LogConfiguration(Boto3Model):
    """
    The log configuration for the container. This parameter maps to
    ``LogConfig`` in the docker container create command and the ``--log-
    driver`` option to docker run.

    By default, containers use the same logging driver that the Docker daemon uses.
    However, the container might use a different logging driver than the Docker
    daemon by specifying a log driver configuration in the container definition.

    Understand the following when specifying a log configuration for your
    containers.

    * Amazon ECS currently supports a subset of the logging drivers available to
      the Docker daemon. Additional log drivers may be available in future releases
      of the Amazon ECS container agent.

    For tasks on Fargate, the supported log drivers are ``awslogs``, ``splunk``,
    and ``awsfirelens``.

    For tasks hosted on Amazon EC2 instances, the supported log drivers are
    ``awslogs``, ``fluentd``, ``gelf``, ``json-file``, ``journald``,``syslog``,
    ``splunk``, and ``awsfirelens``.

    * This parameter requires version 1.18 of the Docker Remote API or greater on
      your container instance.
    * For tasks that are hosted on Amazon EC2 instances, the Amazon ECS container
      agent must register the available logging drivers with the
      ``ECS_AVAILABLE_LOGGING_DRIVERS`` environment variable before containers placed
      on that instance can use these log configuration options. For more information,
      see `Amazon ECS container agent
      configuration <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-
    agent-config.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    * For tasks that are on Fargate, because you don't have access to the
      underlying infrastructure your tasks are hosted on, any additional software
      needed must be installed outside of the task. For example, the Fluentd output
      aggregators or a remote host running Logstash to send Gelf logs to.
    """

    logDriver: Literal[
        "json-file",
        "syslog",
        "journald",
        "gelf",
        "fluentd",
        "awslogs",
        "splunk",
        "awsfirelens",
    ]
    """
    The log driver to use for the container.
    """
    options: Optional[Dict[str, str]] = None
    """
    The configuration options to send to the log driver. This parameter
    requires version 1.19 of the Docker Remote API or greater on your container
    instance. To check the Docker Remote API version on your container
    instance, log in to.

    your container instance and run the following command: ``sudo docker version
    --format '{{.Server.APIVersion}}'``
    """
    secretOptions: Optional[List["Secret"]] = None
    """
    The secrets to pass to the log configuration.

    For more information, see
    `Specifying sensitive data <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-
    sensitive-data.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """


class ServiceConnectConfiguration(Boto3Model):
    """
    The details of the Service Connect configuration that's used by this
    deployment. Compare the configuration between multiple deployments when
    troubleshooting issues with new deployments.

    The configuration for this service to discover and connect to services, and
    be discovered by, and connected from, other services within a namespace.

    Tasks that run in a namespace can use short names to connect to services in
    the namespace. Tasks can connect to services across all of the clusters in
    the namespace. Tasks connect through a managed proxy container that
    collects logs and metrics for increased visibility. Only the tasks that
    Amazon ECS services create are supported with Service Connect. For more
    information, see
    `Service Connect <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-
    connect.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    enabled: bool
    """
    Specifies whether to use Service Connect with this service.
    """
    namespace: Optional[str] = None
    """
    The namespace name or full Amazon Resource Name (ARN) of the Cloud Map
    namespace for use with Service Connect.

    The namespace must be in the same Amazon Web Services Region as the Amazon
    ECS service and cluster. The type of namespace doesn't affect Service
    Connect. For more information about Cloud Map, see
    `Working with Services <https://docs.aws.amazon.com/cloud-
    map/latest/dg/working-with-services.html>`_ in the *Cloud Map Developer Guide*.
    """
    services: Optional[List["ServiceConnectService"]] = None
    """
    The list of Service Connect service objects.

    These are names and aliases (also known as endpoints) that are used by
    other Amazon ECS services to connect to this service.
    """
    logConfiguration: Optional[LogConfiguration] = None
    """
    The log configuration for the container.

    This parameter maps to ``LogConfig``
    in the docker container create command and the ``--log-driver`` option to
    docker run.
    """


class ServiceConnectServiceResource(Boto3Model):
    """
    The Service Connect resource. Each configuration maps a discovery name to a
    Cloud Map service name. The data is stored in Cloud Map as part of the
    Service Connect configuration for each discovery name of this Amazon ECS
    service.

    A task can resolve the ``dnsName`` for each of the ``clientAliases`` of a
    service. However a task can't resolve the discovery names. If you want to
    connect to a service, refer to the ``ServiceConnectConfiguration`` of that
    service for the list of ``clientAliases`` that you can use.
    """

    discoveryName: Optional[str] = None
    """
    The discovery name of this Service Connect resource.
    """
    discoveryArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) for the namespace in Cloud Map that matches
    the discovery name for this Service Connect resource.

    You can use this ARN in other integrations with Cloud Map. However, Service
    Connect can't ensure connectivity outside of Amazon ECS.
    """


class EBSTagSpecification(TagsDictMixin, Boto3Model):
    """
    The tag specifications of an Amazon EBS volume.
    """

    tag_class: ClassVar[Type] = ECSTag
    Tags: List["ECSTag"] = Field(default=None, serialization_alias="tags")
    """
    The tags applied to this Amazon EBS volume.

    ``AmazonECSCreated`` and
    ``AmazonECSManaged`` are reserved tags that can't be used.
    """
    resourceType: Literal["volume"]
    """
    The type of volume resource.
    """
    propagateTags: Optional[Literal["TASK_DEFINITION", "SERVICE", "NONE"]] = None
    """
    Determines whether to propagate the tags from the task definition to the
    Amazon EBS volume. Tags can only propagate to a ``SERVICE`` specified in.

    ``ServiceVolumeConfiguration``. If no value is specified, the tags aren't

    propagated.
    """


class ServiceManagedEBSVolumeConfiguration(Boto3Model):
    """
    The configuration for the Amazon EBS volume that Amazon ECS creates and
    manages on your behalf.

    These settings are used to create each Amazon EBS volume, with one volume
    created for each task in the service. The Amazon EBS volumes are visible in
    your account in the Amazon EC2 console once they are created.
    """

    encrypted: Optional[bool] = None
    """
    Indicates whether the volume should be encrypted.

    If no value is specified,
    encryption is turned on by default. This parameter maps 1:1 with the
    ``Encrypted`` parameter of the `CreateVolume API <https://docs.aws.amazon.com/A
    WSEC2/latest/APIReference/API_CreateVolume.html>`_ in the *Amazon EC2 API
    Reference*.
    """
    kmsKeyId: Optional[str] = None
    """
    The Amazon Resource Name (ARN) identifier of the Amazon Web Services Key
    Management Service key to use for Amazon EBS encryption.

    When encryption is
    turned on and no Amazon Web Services Key Management Service key is specified,
    the default Amazon Web Services managed key for Amazon EBS volumes is used.
    This parameter maps 1:1 with the ``KmsKeyId`` parameter of the `CreateVolume AP
    I <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateVolume.html
    >`_ in the *Amazon EC2 API Reference*.
    """
    volumeType: Optional[str] = None
    """
    The volume type.

    This parameter maps 1:1 with the ``VolumeType`` parameter of
    the `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/A
    PI_CreateVolume.html>`_ in the *Amazon EC2 API Reference*. For more information,
    see `Amazon EBS volume
    types <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-
    types.html>`_ in the *Amazon EC2 User Guide*.
    """
    sizeInGiB: Optional[int] = None
    """
    The size of the volume in GiB.

    You must specify either a volume size or a
    snapshot ID. If you specify a snapshot ID, the snapshot size is used for the
    volume size by default. You can optionally specify a volume size greater than
    or equal to the snapshot size. This parameter maps 1:1 with the ``Size``
    parameter of the `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/A
    PIReference/API_CreateVolume.html>`_ in the *Amazon EC2 API Reference*.
    """
    snapshotId: Optional[str] = None
    """
    The snapshot that Amazon ECS uses to create the volume.

    You must specify either
    a snapshot ID or a volume size. This parameter maps 1:1 with the ``SnapshotId``
    parameter of the `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/A
    PIReference/API_CreateVolume.html>`_ in the *Amazon EC2 API Reference*.
    """
    iops: Optional[int] = None
    """
    The number of I/O operations per second (IOPS).

    For ``gp3``, ``io1``, and
    ``io2`` 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.
    """
    throughput: Optional[int] = None
    """
    The throughput to provision for a volume, in MiB/s, with a maximum of 1,000
    MiB/s.

    This parameter maps 1:1 with the ``Throughput`` parameter of the
    `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_C
    reateVolume.html>`_ in the *Amazon EC2 API Reference*.
    """
    tagSpecifications: Optional[List["EBSTagSpecification"]] = None
    """
    The tags to apply to the volume.

    Amazon ECS applies service-managed tags by
    default. This parameter maps 1:1 with the ``TagSpecifications.N`` parameter of
    the `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/A
    PI_CreateVolume.html>`_ in the *Amazon EC2 API Reference*.
    """
    roleArn: str
    """
    The ARN of the IAM role to associate with this volume.

    This is the Amazon ECS
    infrastructure IAM role that is used to manage your Amazon Web Services
    infrastructure. We recommend using the Amazon ECS-managed
    ``AmazonECSInfrastructureRolePolicyForVolumes`` IAM policy with this role. For
    more information, see `Amazon ECS infrastructure IAM role <https://docs.aws.ama
    zon.com/AmazonECS/latest/developerguide/infrastructure_IAM_role.html>`_ in the
    *Amazon ECS Developer Guide*.
    """
    filesystemType: Optional[Literal["ext3", "ext4", "xfs"]] = None
    """
    The Linux filesystem type for the volume.

    For volumes created from a snapshot, you must specify the same filesystem
    type that the volume was using when the snapshot was created. If there is a
    filesystem type mismatch, the task will fail to start.
    """


class ServiceVolumeConfiguration(Boto3Model):
    """
    The configuration for a volume specified in the task definition as a volume
    that is configured at launch time.

    Currently, the only supported volume type is an Amazon EBS volume.
    """

    name: str
    """
    The name of the volume.

    This value must match the volume name from the
    ``Volume`` object in the task definition.
    """
    managedEBSVolume: Optional[ServiceManagedEBSVolumeConfiguration] = None
    """
    The configuration for the Amazon EBS volume that Amazon ECS creates and
    manages on your behalf.

    These settings are used to create each Amazon EBS volume, with one volume
    created for each task in the service. The Amazon EBS volumes are visible in
    your account in the Amazon EC2 console once they are created.
    """


class Deployment(ReadonlyBoto3Model):
    """
    The details of an Amazon ECS service deployment.

    This is used only when a
    service uses the ``ECS`` deployment controller type.
    """

    id: Optional[str] = None
    """
    The ID of the deployment.
    """
    status: Optional[str] = None
    """
    The status of the deployment.

    The following describes each state.
    """
    taskDefinition: Optional[str] = None
    """
    The most recent task definition that was specified for the tasks in the
    service to use.
    """
    desiredCount: Optional[int] = None
    """
    The most recent desired count of tasks that was specified for the service
    to deploy or maintain.
    """
    pendingCount: Optional[int] = None
    """
    The number of tasks in the deployment that are in the ``PENDING`` status.
    """
    runningCount: Optional[int] = None
    """
    The number of tasks in the deployment that are in the ``RUNNING`` status.
    """
    failedTasks: Optional[int] = None
    """
    The number of consecutively failed tasks in the deployment.

    A task is
    considered a failure if the service scheduler can't launch the task, the task
    doesn't transition to a ``RUNNING`` state, or if it fails any of its defined
    health checks and is stopped.
    """
    createdAt: Optional[datetime] = None
    """
    The Unix timestamp for the time when the service deployment was created.
    """
    updatedAt: Optional[datetime] = None
    """
    The Unix timestamp for the time when the service deployment was last
    updated.
    """
    capacityProviderStrategy: Optional[List["CapacityProviderStrategyItem"]] = None
    """
    The capacity provider strategy that the deployment is using.
    """
    launchType: Optional[Literal["EC2", "FARGATE", "EXTERNAL"]] = None
    """
    The launch type the tasks in the service are using.

    For more information, see
    `Amazon ECS Launch Types <https://docs.aws.amazon.com/AmazonECS/latest/develope
    rguide/launch_types.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.
    """
    platformVersion: Optional[str] = None
    """
    The platform version that your tasks in the service run on.

    A platform version
    is only specified for tasks using the Fargate launch type. If one isn't
    specified, the ``LATEST`` platform version is used. For more information, see
    `Fargate Platform Versions <https://docs.aws.amazon.com/AmazonECS/latest/develo
    perguide/platform_versions.html>`_ in the *Amazon Elastic Container Service
    Developer Guide*.
    """
    platformFamily: Optional[str] = None
    """
    The operating system that your tasks in the service, or tasks are running
    on.

    A platform family is specified only for tasks using the Fargate launch
    type.
    """
    networkConfiguration: Optional[NetworkConfiguration] = None
    """
    The VPC subnet and security group configuration for tasks that receive
    their own elastic network interface by using the ``awsvpc`` networking
    mode.
    """
    rolloutState: Optional[Literal["COMPLETED", "FAILED", "IN_PROGRESS"]] = None
    """
    The ``rolloutState`` of a service is only returned for services that use
    the rolling update (``ECS``) deployment type that aren't behind a Classic
    Load Balancer.
    """
    rolloutStateReason: Optional[str] = None
    """
    A description of the rollout state of a deployment.
    """
    serviceConnectConfiguration: Optional[ServiceConnectConfiguration] = None
    """
    The details of the Service Connect configuration that's used by this
    deployment.

    Compare the configuration between multiple deployments when troubleshooting
    issues with new deployments.
    """
    serviceConnectResources: Optional[List["ServiceConnectServiceResource"]] = None
    """
    The list of Service Connect resources that are associated with this
    deployment.

    Each list entry maps a discovery name to a Cloud Map service name.
    """
    volumeConfigurations: Optional[List["ServiceVolumeConfiguration"]] = None
    """
    The details of the volume that was ``configuredAtLaunch``.

    You can configure
    different settings like the size, throughput, volumeType, and ecryption in `Ser
    viceManagedEBSVolumeConfiguration <https://docs.aws.amazon.com/AmazonECS/latest
    /APIReference/API_ServiceManagedEBSVolumeConfiguration.html>`_. The ``name`` of
    the volume must match the ``name`` from the task definition.
    """
    fargateEphemeralStorage: Optional[DeploymentEphemeralStorage] = None
    """
    The Fargate ephemeral storage settings for the deployment.
    """


class ServiceEvent(Boto3Model):
    """
    The details for an event that's associated with a service.
    """

    id: Optional[str] = None
    """
    The ID string for the event.
    """
    createdAt: Optional[datetime] = None
    """
    The Unix timestamp for the time when the event was triggered.
    """
    message: Optional[str] = None
    """
    The event message.
    """


class PlacementConstraint(Boto3Model):
    """An object representing a constraint on task placement. For more information,
    see `Task placement
    constraints <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-
    placement-constraints.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.

    If you're using the Fargate launch type, task placement constraints aren't
    supported.

    """

    type: Optional[Literal["distinctInstance", "memberOf"]] = None
    """
    The type of constraint.

    Use ``distinctInstance`` to ensure that each task in a
    particular group is running on a different container instance. Use ``memberOf``
    to restrict the selection to a group of valid candidates.
    """
    expression: Optional[str] = None
    """
    A cluster query language expression to apply to the constraint.

    The expression
    can have a maximum length of 2000 characters. You can't specify an expression
    if the constraint type is ``distinctInstance``. For more information, see
    `Cluster query
    language <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-
    query-language.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """


class PlacementStrategy(Boto3Model):
    """
    The task placement strategy for a task or service.

    For more information, see
    `Task placement strategies <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-
    placement-strategies.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.
    """

    type: Optional[Literal["random", "spread", "binpack"]] = None
    """
    The type of placement strategy.

    The ``random`` placement strategy randomly
    places tasks on available candidates. The ``spread`` placement strategy spreads
    placement across available candidates evenly based on the ``field`` parameter.
    The ``binpack`` strategy places tasks on available candidates that have the
    least available amount of the resource that's specified with the ``field``
    parameter. For example, if you binpack on memory, a task is placed on the
    instance with the least amount of remaining memory but still enough to run the
    task.
    """
    field: Optional[str] = None
    """
    The field to apply the placement strategy against.

    For the ``spread`` placement
    strategy, valid values are ``instanceId`` (or ``host``, which has the same
    effect), or any platform or custom attribute that's applied to a container
    instance, such as ``attribute:ecs.availability-zone``. For the ``binpack``
    placement strategy, valid values are ``cpu`` and ``memory``. For the ``random``
    placement strategy, this field is not used.
    """


class DeploymentController(Boto3Model):
    """
    The deployment controller type the service is using.
    """

    type: Literal["ECS", "CODE_DEPLOY", "EXTERNAL"]
    """
    The deployment controller type to use.
    """


class Service(TagsDictMixin, ECSServiceModelMixin, PrimaryBoto3Model):
    """
    Details on a service within a cluster.
    """

    tag_class: ClassVar[Type] = ECSTag
    manager_class: ClassVar[Type[Boto3ModelManager]] = ServiceManager

    serviceName: str
    """
    The name of your service.

    Up to 255 letters (uppercase and lowercase), numbers, underscores, and
    hyphens are allowed. Service names must be unique within a cluster.
    However, you can have similarly named services in multiple clusters within
    a Region or across multiple Regions.
    """
    taskDefinition: str
    """
    The task definition to use for tasks in the service.

    This value is specified
    when the service is created with `CreateService <https://docs.aws.amazon.com/Am
    azonECS/latest/APIReference/API_CreateService.html>`_, and it can be modified
    with `UpdateService <https://docs.aws.amazon.com/AmazonECS/latest/APIReference/
    API_UpdateService.html>`_.
    """
    clusterArn: str
    """
    The Amazon Resource Name (ARN) of the cluster that hosts the service.
    """
    desiredCount: int
    """
    The desired number of instantiations of the task definition to keep running
    on the service.

    This value is specified when the service is created with `CreateSe
    rvice <https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateServ
    ice.html>`_ , and it can be modified with `UpdateService <https://docs.aws.amazon
    .com/AmazonECS/latest/APIReference/API_UpdateService.html>`_.
    """
    launchType: Literal["EC2", "FARGATE", "EXTERNAL"]
    """
    The launch type the service is using.

    When using the DescribeServices API, this field is omitted if the service
    was created using a capacity provider strategy.
    """
    schedulingStrategy: Literal["REPLICA", "DAEMON"]
    """
    The scheduling strategy to use for the service.

    For more information, see
    `Serv ices <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.
    html>`_.
    """
    Tags: List["ECSTag"] = Field(default=None, serialization_alias="tags")
    """
    The metadata that you apply to the service to help you categorize and
    organize them.

    Each tag consists of a key and an optional value. You define bot the key
    and value.
    """
    serviceArn: str = Field(default=None, frozen=True)
    """
    The ARN that identifies the service.

    For more information about the ARN format,
    see `Amazon Resource Name
    (ARN) <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-
    settings.html#ecs-resource-ids>`_ in the *Amazon ECS Developer Guide*.
    """
    loadBalancers: Optional[List["LoadBalancerConfiguration"]] = None
    """
    A list of Elastic Load Balancing load balancer objects.

    It contains the load balancer name, the container name, and the container
    port to access from the load balancer. The container name is as it appears
    in a container definition.
    """
    serviceRegistries: Optional[List["ServiceRegistry"]] = None
    """
    The details for the service discovery registries to assign to this service.

    For more information, see
    `Service Discovery <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-
    discovery.html>`_.
    """
    status: str = Field(default=None, frozen=True)
    """
    The status of the service.

    The valid values are ``ACTIVE``, ``DRAINING``, or
    ``INACTIVE``.
    """
    runningCount: int = Field(default=None, frozen=True)
    """
    The number of tasks in the cluster that are in the ``RUNNING`` state.
    """
    pendingCount: int = Field(default=None, frozen=True)
    """
    The number of tasks in the cluster that are in the ``PENDING`` state.
    """
    capacityProviderStrategy: Optional[List["CapacityProviderStrategyItem"]] = None
    """
    The capacity provider strategy the service uses.

    When using the DescribeServices API, this field is omitted if the service
    was created using a launch type.
    """
    platformVersion: Optional[str] = None
    """
    The platform version to run your service on.

    A platform version is only
    specified for tasks that are hosted on Fargate. If one isn't specified, the
    ``LATEST`` platform version is used. For more information, see `Fargate
    Platform Versions <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/
    platform_versions.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.
    """
    platformFamily: str = Field(default=None, frozen=True)
    """
    The operating system that your tasks in the service run on.

    A platform family is specified only for tasks using the Fargate launch
    type.
    """
    deploymentConfiguration: Optional[DeploymentConfiguration] = None
    """
    Optional deployment parameters that control how many tasks run during the
    deployment and the ordering of stopping and starting tasks.
    """
    taskSets: List["TaskSet"] = Field(default=None, frozen=True)
    """
    Information about a set of Amazon ECS tasks in either an CodeDeploy or an
    ``EXTERNAL`` deployment.

    An Amazon ECS task set includes details such as the desired number of
    tasks, how many tasks are running, and whether the task set serves
    production traffic.
    """
    deployments: List["Deployment"] = Field(default=None, frozen=True)
    """
    The current state of deployments for the service.
    """
    roleArn: str = Field(default=None, frozen=True)
    """
    The ARN of the IAM role that's associated with the service.

    It allows the Amazon ECS container agent to register container instances
    with an Elastic Load Balancing load balancer.
    """
    events: List["ServiceEvent"] = Field(default=None, frozen=True)
    """
    The event stream for your service.

    A maximum of 100 of the latest events are displayed.
    """
    createdAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the service was created.
    """
    placementConstraints: Optional[List["PlacementConstraint"]] = None
    """
    The placement constraints for the tasks in the service.
    """
    placementStrategy: Optional[List["PlacementStrategy"]] = None
    """
    The placement strategy that determines how tasks for the service are
    placed.
    """
    networkConfiguration: Optional[NetworkConfiguration] = None
    """
    The VPC subnet and security group configuration for tasks that receive
    their own elastic network interface by using the ``awsvpc`` networking
    mode.
    """
    healthCheckGracePeriodSeconds: Optional[int] = None
    """
    The period of time, in seconds, that the Amazon ECS service scheduler
    ignores unhealthy Elastic Load Balancing target health checks after a task
    has first started.
    """
    deploymentController: Optional[DeploymentController] = None
    """
    The deployment controller type the service is using.
    """
    createdBy: str = Field(default=None, frozen=True)
    """
    The principal that created the service.
    """
    enableECSManagedTags: Optional[bool] = None
    """
    Determines whether to use Amazon ECS managed tags for the tasks in the
    service.

    For more information, see
    `Tagging Your Amazon ECS Resources <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-
    using-tags.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """
    propagateTags: Optional[Literal["TASK_DEFINITION", "SERVICE", "NONE"]] = None
    """
    Determines whether to propagate the tags from the task definition or the
    service to the task.

    If no value is specified, the tags aren't propagated.
    """
    enableExecuteCommand: Optional[bool] = None
    """
    Determines whether the execute command functionality is turned on for the
    service.

    If ``true``, the execute command functionality is turned on for all
    containers in tasks as part of the service.
    """

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

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

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

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

    @property
    def pk(self) -> OrderedDict[str, Any]:
        """
        The primary key of the service.

        This can be used to get the service with the :py:meth:`botocraft.services.ecs.ServiceManager.get` method, or to do :py:meth:`botocraft.services.ecs.ServiceManager.partial_update`.
        """

        return OrderedDict(
            {
                "service": self.serviceName,
                "cluster": self.clusterArn,
            }
        )

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

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

    @property
    def tasks(self) -> Optional[List["Task"]]:
        """
        Return the ARNs of :py:class:`Task` objects that run in this service,
        if any.
        """

        try:
            pk = OrderedDict(
                {
                    "serviceName": self.serviceName,
                    "cluster": self.clusterArn,
                }
            )
        except AttributeError:
            return []
        return Task.objects.using(self.session).list(**pk)  # type: ignore[arg-type]


class ExecuteCommandLogConfiguration(Boto3Model):
    """
    The log configuration for the results of the execute command actions.

    The logs
    can be sent to CloudWatch Logs or an Amazon S3 bucket. When
    ``logging=OVERRIDE`` is specified, a ``logConfiguration`` must be provided.
    """

    cloudWatchLogGroupName: Optional[str] = None
    """
    The name of the CloudWatch log group to send logs to.
    """
    cloudWatchEncryptionEnabled: Optional[bool] = None
    """
    Determines whether to use encryption on the CloudWatch logs.

    If not specified, encryption will be off.
    """
    s3BucketName: Optional[str] = None
    """
    The name of the S3 bucket to send logs to.
    """
    s3EncryptionEnabled: Optional[bool] = None
    """
    Determines whether to use encryption on the S3 logs.

    If not specified, encryption is not used.
    """
    s3KeyPrefix: Optional[str] = None
    """
    An optional folder in the S3 bucket to place logs in.
    """


class ExecuteCommandConfiguration(Boto3Model):
    """
    The details of the execute command configuration.
    """

    kmsKeyId: Optional[str] = None
    """
    Specify an Key Management Service key ID to encrypt the data between the
    local client and the container.
    """
    logging: Optional[Literal["NONE", "DEFAULT", "OVERRIDE"]] = None
    """
    The log setting to use for redirecting logs for your execute command
    results.

    The following log settings are available.
    """
    logConfiguration: Optional[ExecuteCommandLogConfiguration] = None
    """
    The log configuration for the results of the execute command actions.

    The logs
    can be sent to CloudWatch Logs or an Amazon S3 bucket. When
    ``logging=OVERRIDE`` is specified, a ``logConfiguration`` must be provided.
    """


class ManagedStorageConfiguration(Boto3Model):
    """
    The details of the managed storage configuration.
    """

    kmsKeyId: Optional[str] = None
    """
    Specify a Key Management Service key ID to encrypt the managed storage.
    """
    fargateEphemeralStorageKmsKeyId: Optional[str] = None
    """
    Specify the Key Management Service key ID for the Fargate ephemeral
    storage.
    """


class ClusterConfiguration(Boto3Model):
    """
    The execute command configuration for the cluster.
    """

    executeCommandConfiguration: Optional[ExecuteCommandConfiguration] = None
    """
    The details of the execute command configuration.
    """
    managedStorageConfiguration: Optional[ManagedStorageConfiguration] = None
    """
    The details of the managed storage configuration.
    """


class KeyValuePair(Boto3Model):
    """
    A key-value pair object.
    """

    name: Optional[str] = None
    """
    The name of the key-value pair.

    For environment variables, this is the name of the environment variable.
    """
    value: Optional[str] = None
    """
    The value of the key-value pair.

    For environment variables, this is the value of the environment variable.
    """


class ClusterSetting(Boto3Model):
    """
    The settings to use when creating a cluster.

    This parameter is used to turn on CloudWatch Container Insights for a
    cluster.
    """

    name: Optional[Literal["containerInsights"]] = None
    """
    The name of the cluster setting.

    The value is ``containerInsights`` .
    """
    value: Optional[str] = None
    """
    The value to set for the cluster setting.

    The supported values are ``enabled``
    and ``disabled``.
    """


class Attachment(Boto3Model):
    """
    An object representing a container instance or task attachment.
    """

    id: Optional[str] = None
    """
    The unique identifier for the attachment.
    """
    type: Optional[str] = None
    """
    The type of the attachment, such as ``ElasticNetworkInterface``, ``Service
    Connect``, and ``AmazonElasticBlockStorage``.
    """
    status: Optional[str] = None
    """
    The status of the attachment.

    Valid values are ``PRECREATED``, ``CREATED``,
    ``ATTACHING``, ``ATTACHED``, ``DETACHING``, ``DETACHED``, ``DELETED``, and
    ``FAILED``.
    """
    details: Optional[List["KeyValuePair"]] = None
    """
    Details of the attachment.
    """


class ClusterServiceConnectDefaults(Boto3Model):
    """
    Use this parameter to set a default Service Connect namespace. After you
    set a default Service Connect namespace, any new services with Service
    Connect turned on that are created in the cluster are added as client
    services in the namespace. This setting only applies to new services that
    set the ``enabled`` parameter to ``true`` in the
    ``ServiceConnectConfiguration``. You can set the namespace of each service
    individually in the ``ServiceConnectConfiguration`` to override this
    default parameter.

    Tasks that run in a namespace can use short names to connect to services in
    the namespace. Tasks can connect to services across all of the clusters in
    the namespace. Tasks connect through a managed proxy container that
    collects logs and metrics for increased visibility. Only the tasks that
    Amazon ECS services create are supported with Service Connect. For more
    information, see
    `Service Connect <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-
    connect.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    namespace: Optional[str] = None
    """
    The namespace name or full Amazon Resource Name (ARN) of the Cloud Map
    namespace.

    When you create a service and don't specify a Service Connect
    configuration, this namespace is used.
    """


class Cluster(TagsDictMixin, PrimaryBoto3Model):
    """
    A regional grouping of one or more container instances where you can run
    task requests.

    Each account receives a default cluster the first time you use the Amazon
    ECS service, but you may also create other clusters. Clusters may contain
    more than one instance type simultaneously.
    """

    tag_class: ClassVar[Type] = ECSTag
    manager_class: ClassVar[Type[Boto3ModelManager]] = ClusterManager

    clusterName: str
    """
    A user-generated string that you use to identify your cluster.
    """
    Tags: List["ECSTag"] = Field(default=None, serialization_alias="tags")
    """
    The metadata that you apply to the cluster to help you categorize and
    organize them.

    Each tag consists of a key and an optional value. You define both.
    """
    clusterArn: str = Field(default=None, frozen=True)
    """
    The Amazon Resource Name (ARN) that identifies the cluster.

    For more
    information about the ARN format, see `Amazon Resource Name
    (ARN) <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-
    settings.html#ecs-resource-ids>`_ in the *Amazon ECS Developer Guide*.
    """
    configuration: Optional[ClusterConfiguration] = None
    """
    The execute command configuration for the cluster.
    """
    status: str = Field(default=None, frozen=True)
    """
    The status of the cluster.

    The following are the possible states that are returned.
    """
    registeredContainerInstancesCount: int = Field(default=None, frozen=True)
    """
    The number of container instances registered into the cluster.

    This includes
    container instances in both ``ACTIVE`` and ``DRAINING`` status.
    """
    runningTasksCount: int = Field(default=None, frozen=True)
    """
    The number of tasks in the cluster that are in the ``RUNNING`` state.
    """
    pendingTasksCount: int = Field(default=None, frozen=True)
    """
    The number of tasks in the cluster that are in the ``PENDING`` state.
    """
    activeServicesCount: int = Field(default=None, frozen=True)
    """
    The number of services that are running on the cluster in an ``ACTIVE``
    state.

    You can view these services with `PListServices <https://docs.aws.amazon.com/Am
    azonECS/latest/APIReference/API_ListServices.html>`_.
    """
    statistics: List["KeyValuePair"] = Field(default=None, frozen=True)
    """
    Additional information about your clusters that are separated by launch
    type.

    They include the following:
    """
    settings: Optional[List["ClusterSetting"]] = None
    """
    The settings for the cluster.

    This parameter indicates whether CloudWatch Container Insights is on or off
    for a cluster.
    """
    capacityProviders: Optional[List[str]] = None
    """
    The capacity providers associated with the cluster.
    """
    defaultCapacityProviderStrategy: Optional[List["CapacityProviderStrategyItem"]] = (
        None
    )
    """
    The default capacity provider strategy for the cluster.

    When services or tasks are run in the cluster with no launch type or
    capacity provider strategy specified, the default capacity provider
    strategy is used.
    """
    attachments: List["Attachment"] = Field(default=None, frozen=True)
    """
    The resources attached to a cluster.

    When using a capacity provider with a cluster, the capacity provider and
    associated resources are returned as cluster attachments.
    """
    attachmentsStatus: str = Field(default=None, frozen=True)
    """
    The status of the capacity providers associated with the cluster.

    The following are the states that are returned.
    """
    serviceConnectDefaults: Optional[ClusterServiceConnectDefaults] = None
    """
    Use this parameter to set a default Service Connect namespace.

    After you set a
    default Service Connect namespace, any new services with Service Connect turned
    on that are created in the cluster are added as client services in the
    namespace. This setting only applies to new services that set the ``enabled``
    parameter to ``true`` in the ``ServiceConnectConfiguration``. You can set the
    namespace of each service individually in the ``ServiceConnectConfiguration``
    to override this default parameter.
    """

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

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

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

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

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

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

    @cached_property
    def services(self) -> Optional[List["Service"]]:
        """
        Return the ARNs of :py:class:`Service` objects that run in this
        cluster, 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(
                {
                    "cluster": self.clusterArn,
                }
            )
        except AttributeError:
            return []
        return Service.objects.using(self.session).list(**pk)  # type: ignore[arg-type]

    @cached_property
    def container_instances(self) -> Optional[List["ContainerInstance"]]:
        """
        Return the ARNs of :py:class:`ContainerInstance` objects that run in
        this cluster, 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(
                {
                    "cluster": self.clusterArn,
                }
            )
        except AttributeError:
            return []
        return ContainerInstance.objects.using(self.session).list(**pk)  # type: ignore[arg-type]


class RepositoryCredentials(Boto3Model):
    """
    The private repository authentication credentials to use.
    """

    credentialsParameter: str
    """
    The Amazon Resource Name (ARN) of the secret containing the private
    repository credentials.
    """


class PortMapping(Boto3Model):
    """
    Port mappings allow containers to access ports on the host container
    instance to send or receive traffic. Port mappings are specified as part of
    the container definition.

    If you use containers in a task with the ``awsvpc`` or ``host`` network mode,
    specify the exposed ports using ``containerPort``. The ``hostPort`` can be left
    blank or it must be the same value as the ``containerPort``.

    Most fields of this parameter (``containerPort``, ``hostPort``, ``protocol``)
    maps to ``PortBindings`` in the docker container create command and the
    ``--publish`` option to ``docker run``. If the network mode of a task
    definition is set to ``host``, host ports must either be undefined or match the
    container port in the port mapping.

    You can't expose the same container port for multiple protocols. If you attempt
    this, an error is returned.

    After a task reaches the ``RUNNING`` status, manual and automatic host and
    container port assignments are visible in the ``networkBindings`` section of `D
    escribeTasks <https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Des
    cribeTasks.html>`_ API responses.
    """

    containerPort: Optional[int] = None
    """
    The port number on the container that's bound to the user-specified or
    automatically assigned host port.
    """
    hostPort: Optional[int] = None
    """
    The port number on the container instance to reserve for your container.
    """
    protocol: Optional[Literal["tcp", "udp"]] = None
    """
    The protocol used for the port mapping.

    Valid values are ``tcp`` and ``udp``.
    The default is ``tcp``. ``protocol`` is immutable in a Service Connect service.
    Updating this field requires a service deletion and redeployment.
    """
    name: Optional[str] = None
    """
    The name that's used for the port mapping.

    This parameter only applies to
    Service Connect. This parameter is the name that you use in the
    ``serviceConnectConfiguration`` of a service. The name can include up to 64
    characters. The characters can include lowercase letters, numbers, underscores
    (_), and hyphens (-). The name can't start with a hyphen.
    """
    appProtocol: Optional[Literal["http", "http2", "grpc"]] = None
    """
    The application protocol that's used for the port mapping.

    This parameter only applies to Service Connect. We recommend that you set
    this parameter to be consistent with the protocol that your application
    uses. If you set this parameter, Amazon ECS adds protocol-specific
    connection handling to the Service Connect proxy. If you set this
    parameter, Amazon ECS adds protocol-specific telemetry in the Amazon ECS
    console and CloudWatch.
    """
    containerPortRange: Optional[str] = None
    """
    The port number range on the container that's bound to the dynamically
    mapped host port range.
    """


class ContainerRestartPolicy(Boto3Model):
    """
    The restart policy for a container.

    When you set up a restart policy, Amazon ECS can restart the container
    without needing to replace the task. For more information, see
    `Restart individual containers in Amazon ECS tasks with container restart policies <https://docs.aws.amazon.com/AmazonECS/latest/develo
    perguide/container-restart-policy.html>`_ in the *Amazon Elastic Container
    Service Developer Guide*.
    """

    enabled: bool
    """
    Specifies whether a restart policy is enabled for the container.
    """
    ignoredExitCodes: Optional[List[int]] = None
    """
    A list of exit codes that Amazon ECS will ignore and not attempt a restart
    on.

    You can specify a maximum of 50 container exit codes. By default, Amazon
    ECS does not ignore any exit codes.
    """
    restartAttemptPeriod: Optional[int] = None
    """
    A period of time (in seconds) that the container must run for before a
    restart can be attempted.

    A container can be restarted only once every
    ``restartAttemptPeriod`` seconds. If a container isn't able to run for this
    time period and exits early, it will not be restarted. You can set a minimum
    ``restartAttemptPeriod`` of 60 seconds and a maximum ``restartAttemptPeriod``
    of 1800 seconds. By default, a container must run for 300 seconds before it can
    be restarted.
    """


class EnvironmentFile(Boto3Model):
    """
    A list of files containing the environment variables to pass to a
    container. You can specify up to ten environment files. The file must have
    a ``.env`` file extension. Each line in an environment file should contain
    an environment variable in ``VARIABLE=VALUE`` format. Lines beginning with
    ``#`` are treated as comments and are ignored.

    If there are environment variables specified using the ``environment``
    parameter in a container definition, they take precedence over the variables
    contained within an environment file. If multiple environment files are
    specified that contain the same variable, they're processed from the top down.
    We recommend that you use unique variable names. For more information, see `Use
    a file to pass environment variables to a
    container <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/use-
    environment-file.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.

    Environment variable files are objects in Amazon S3 and all Amazon S3 security
    considerations apply.

    You must use the following platforms for the Fargate launch type:

    * Linux platform version ``1.4.0`` or later.
    * Windows platform version ``1.0.0`` or later.

    Consider the following when using the Fargate launch type:

    * The file is handled like a native Docker env-file.
    * There is no support for shell escape handling.
    * The container entry point interperts the ``VARIABLE`` values.
    """

    value: str
    """
    The Amazon Resource Name (ARN) of the Amazon S3 object containing the
    environment variable file.
    """
    type: Literal["s3"]
    """
    The file type to use.

    Environment files are objects in Amazon S3. The only
    supported value is ``s3``.
    """


class MountPoint(Boto3Model):
    """
    The details for a volume mount point that's used in a container definition.
    """

    sourceVolume: Optional[str] = None
    """
    The name of the volume to mount.

    Must be a volume name referenced in the
    ``name`` parameter of task definition ``volume``.
    """
    containerPath: Optional[str] = None
    """
    The path on the container to mount the host volume at.
    """
    readOnly: Optional[bool] = None
    """
    If this value is ``true``, the container has read-only access to the
    volume.

    If this value is ``false``, then the container can write to the volume. The
    default value is ``false``.
    """


class VolumeFrom(Boto3Model):
    """
    Details on a data volume from another container in the same task
    definition.
    """

    sourceContainer: Optional[str] = None
    """
    The name of another container within the same task definition to mount
    volumes from.
    """
    readOnly: Optional[bool] = None
    """
    If this value is ``true``, the container has read-only access to the
    volume.

    If this value is ``false``, then the container can write to the volume. The
    default value is ``false``.
    """


class KernelCapabilities(Boto3Model):
    """
    The Linux capabilities for the container that are added to or dropped from
    the default configuration provided by Docker.

    For tasks that use the Fargate launch type, ``capabilities`` is supported for
    all platform versions but the ``add`` parameter is only supported if using
    platform version 1.4.0 or later.
    """

    add: Optional[List[str]] = None
    """
    The Linux capabilities for the container that have been added to the
    default configuration provided by Docker.

    This parameter maps to ``CapAdd`` in the
    docker container create command and the ``--cap-add`` option to docker run.
    """
    drop: Optional[List[str]] = None
    """
    The Linux capabilities for the container that have been removed from the
    default configuration provided by Docker.

    This parameter maps to ``CapDrop`` in
    the docker container create command and the ``--cap-drop`` option to docker
    run.
    """


class Device(Boto3Model):
    """
    An object representing a container instance host device.
    """

    hostPath: str
    """
    The path for the device on the host container instance.
    """
    containerPath: Optional[str] = None
    """
    The path inside the container at which to expose the host device.
    """
    permissions: Optional[List[Literal["read", "write", "mknod"]]] = None
    """
    The explicit permissions to provide to the container for the device.

    By
    default, the container has permissions for ``read``, ``write``, and ``mknod``
    for the device.
    """


class Tmpfs(Boto3Model):
    """
    The container path, mount options, and size of the tmpfs mount.
    """

    containerPath: str
    """
    The absolute file path where the tmpfs volume is to be mounted.
    """
    size: int
    """
    The maximum size (in MiB) of the tmpfs volume.
    """
    mountOptions: Optional[List[str]] = None
    """
    The list of tmpfs volume mount options.
    """


class LinuxParameters(Boto3Model):
    """Linux-specific modifications that are applied to the container, such as Linux
    kernel capabilities. For more information see `KernelCapabilities <https://docs
    .aws.amazon.com/AmazonECS/latest/APIReference/API_KernelCapabilities.html>`_.

    This parameter is not supported for Windows containers.

    """

    capabilities: Optional[KernelCapabilities] = None
    """
    The Linux capabilities for the container that are added to or dropped from
    the default configuration provided by Docker.
    """
    devices: Optional[List["Device"]] = None
    """
    Any host devices to expose to the container.

    This parameter maps to ``Devices``
    in the docker container create command and the ``--device`` option to docker
    run.
    """
    initProcessEnabled: Optional[bool] = None
    """
    Run an ``init`` process inside the container that forwards signals and
    reaps processes.

    This parameter maps to the ``--init`` option to docker run. This
    parameter requires version 1.25 of the Docker Remote API or greater on your
    container instance. To check the Docker Remote API version on your container
    instance, log in to your container instance and run the following command:
    ``sudo docker version --format '{{.Server.APIVersion}}'``
    """
    sharedMemorySize: Optional[int] = None
    """
    The value for the size (in MiB) of the ``/dev/shm`` volume.

    This parameter maps
    to the ``--shm-size`` option to docker run.
    """
    tmpfs: Optional[List["Tmpfs"]] = None
    """
    The container path, mount options, and size (in MiB) of the tmpfs mount.

    This
    parameter maps to the ``--tmpfs`` option to docker run.
    """
    maxSwap: Optional[int] = None
    """
    The total amount of swap memory (in MiB) a container can use.

    This parameter
    will be translated to the ``--memory-swap`` option to docker run where the
    value would be the sum of the container memory plus the ``maxSwap`` value.
    """
    swappiness: Optional[int] = None
    """
    This allows you to tune a container's memory swappiness behavior.

    A
    ``swappiness`` value of ``0`` will cause swapping to not happen unless
    absolutely necessary. A ``swappiness`` value of ``100`` will cause pages to be
    swapped very aggressively. Accepted values are whole numbers between ``0`` and
    ``100``. If the ``swappiness`` parameter is not specified, a default value of
    ``60`` is used. If a value is not specified for ``maxSwap`` then this parameter
    is ignored. This parameter maps to the ``--memory-swappiness`` option to docker
    run.
    """


class ContainerDependency(Boto3Model):
    """
    The dependencies defined for container startup and shutdown. A container
    can contain multiple dependencies. When a dependency is defined for
    container startup, for container shutdown it is reversed.

    Your Amazon ECS container instances require at least version 1.26.0 of the
    container agent to use container dependencies. However, we recommend using the
    latest container agent version. For information about checking your agent
    version and updating to the latest version, see `Updating the Amazon ECS
    Container
    Agent <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-
    update.html>`_ in the *Amazon Elastic Container Service Developer Guide*. If
    you're using an Amazon ECS-optimized Linux AMI, your instance needs at least
    version 1.26.0-1 of the ``ecs-init`` package. If your container instances
    are launched from version ``20190301`` or later, then they contain the required
    versions of the container agent and ``ecs-init``. For more information, see
    `Amazon ECS-optimized Linux
    AMI <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-
    optimized_AMI.html>`_ in the *Amazon Elastic Container Service Developer Guide*.

    For tasks that use the Fargate launch type, the task or service requires the
    following platforms:

    * Linux platform version ``1.3.0`` or later.
    * Windows platform version ``1.0.0`` or later.

    For more information about how to create a container dependency, see `Container
    dependency <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/example
    _task_definitions.html#example_task_definition-containerdependency>`_ in the
    *Amazon Elastic Container Service Developer Guide*.
    """

    containerName: str
    """
    The name of a container.
    """
    condition: Literal["START", "COMPLETE", "SUCCESS", "HEALTHY"]
    """
    The dependency condition of the container.

    The following are the available
    conditions and their behavior:
    """


class HostEntry(Boto3Model):
    """Hostnames and IP address entries that are added to the ``/etc/hosts`` file of a
    container via the ``extraHosts`` parameter of its `ContainerDefinition <https:/
    /docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html
    >`_.

    """

    hostname: str
    """
    The hostname to use in the ``/etc/hosts`` entry.
    """
    ipAddress: str
    """
    The IP address to use in the ``/etc/hosts`` entry.
    """


class Ulimit(Boto3Model):
    """
    The ``ulimit`` settings to pass to the container.

    Amazon ECS tasks hosted on Fargate use the default resource limit values set by
    the operating system with the exception of the ``nofile`` resource limit
    parameter which Fargate overrides. The ``nofile`` resource limit sets a
    restriction on the number of open files that a container can use. The default
    ``nofile`` soft limit is  ``65535`` and the default hard limit is ``65535``.

    You can specify the ``ulimit`` settings for a container in a task definition.
    """

    name: Literal[
        "core",
        "cpu",
        "data",
        "fsize",
        "locks",
        "memlock",
        "msgqueue",
        "nice",
        "nofile",
        "nproc",
        "rss",
        "rtprio",
        "rttime",
        "sigpending",
        "stack",
    ]
    """
    The ``type`` of the ``ulimit``.
    """
    softLimit: int
    """
    The soft limit for the ``ulimit`` type.

    The value can be specified in bytes,
    seconds, or as a count, depending on the ``type`` of the ``ulimit``.
    """
    hardLimit: int
    """
    The hard limit for the ``ulimit`` type.

    The value can be specified in bytes,
    seconds, or as a count, depending on the ``type`` of the ``ulimit``.
    """


class HealthCheck(Boto3Model):
    """
    The container health check command and associated configuration parameters
    for the container.

    This parameter maps to ``HealthCheck`` in the docker container
    create command and the ``HEALTHCHECK`` parameter of docker run.
    """

    command: List[str]
    """
    A string array representing the command that the container runs to
    determine if it is healthy.

    The string array must start with ``CMD`` to run the command
    arguments directly, or ``CMD-SHELL`` to run the command with the container's
    default shell.
    """
    interval: Optional[int] = None
    """
    The time period in seconds between each health check execution.

    You may specify between 5 and 300 seconds. The default value is 30 seconds.
    """
    timeout: Optional[int] = None
    """
    The time period in seconds to wait for a health check to succeed before it
    is considered a failure.

    You may specify between 2 and 60 seconds. The default value is 5.
    """
    retries: Optional[int] = None
    """
    The number of times to retry a failed health check before the container is
    considered unhealthy.

    You may specify between 1 and 10 retries. The default value is 3.
    """
    startPeriod: Optional[int] = None
    """
    The optional grace period to provide containers time to bootstrap before
    failed health checks count towards the maximum number of retries.

    You can specify
    between 0 and 300 seconds. By default, the ``startPeriod`` is off.
    """


class SystemControl(Boto3Model):
    """
    A list of namespaced kernel parameters to set in the container. This
    parameter maps to ``Sysctls`` in the docker container create command and
    the ``--sysctl`` option to docker run. For example, you can configure
    ``net.ipv4.tcp_keepalive_time`` setting to maintain longer lived
    connections.

    We don't recommend that you specify network-related ``systemControls``
    parameters for multiple containers in a single task that also uses either the
    ``awsvpc`` or ``host`` network mode. Doing this has the following
    disadvantages:

    * For tasks that use the ``awsvpc`` network mode including Fargate, if you set
      ``systemControls`` for any container, it applies to all containers in the task.
      If you set different ``systemControls`` for multiple containers in a single
      task, the container that's started last determines which ``systemControls``
      take effect.
    * For tasks that use the ``host`` network mode, the network namespace
      ``systemControls`` aren't supported.

    If you're setting an IPC resource namespace to use for the containers in the
    task, the following conditions apply to your system controls. For more
    information, see `IPC mode <https://docs.aws.amazon.com/AmazonECS/latest/develo
    perguide/task_definition_parameters.html#task_definition_ipcmode>`_.

    * For tasks that use the ``host`` IPC mode, IPC namespace ``systemControls``
      aren't supported.
    * For tasks that use the ``task`` IPC mode, IPC namespace ``systemControls``
      values apply to all containers within a task.

    This parameter is not supported for Windows containers.

    This parameter is only supported for tasks that are hosted on Fargate if the
    tasks are using platform version ``1.4.0`` or later (Linux). This isn't
    supported for Windows containers on Fargate.
    """

    namespace: Optional[str] = None
    """
    The namespaced kernel parameter to set a ``value`` for.
    """
    value: Optional[str] = None
    """
    The namespaced kernel parameter to set a ``value`` for.
    """


class ResourceRequirement(Boto3Model):
    """
    The type and amount of a resource to assign to a container.

    The supported resource types are GPUs and Elastic Inference accelerators.
    For more information, see
    `Working with GPUs on Amazon ECS <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-gpu.html>`_
     or
    `Working with Amazon Elastic Inference on Amazon ECS <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-
    inference.html>`_ in the *Amazon Elastic Container Service Developer Guide*
    """

    value: str
    """
    The value for the specified resource type.
    """
    type: Literal["GPU", "InferenceAccelerator"]
    """
    The type of resource to assign to a container.
    """


class FirelensConfiguration(Boto3Model):
    """
    The FireLens configuration for the container.

    This is used to specify and configure a log router for container logs. For
    more information, see
    `Custom Log Routing <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_
    firelens.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    type: Literal["fluentd", "fluentbit"]
    """
    The log router to use.

    The valid values are ``fluentd`` or ``fluentbit``.
    """
    options: Optional[Dict[str, str]] = None
    """
    The options to use when configuring the log router.

    This field is optional and
    can be used to specify a custom configuration file or to add additional
    metadata, such as the task, task definition, cluster, and container instance
    details to the log event. If specified, the syntax to use is
    ``"options":{"enable-ecs-log-metadata":"true|false","config-file-
    type:"s3|file","config-file-
    value":"arn:aws:s3:::mybucket/fluent.conf|filepath"}``. For more information,
    see `Creating a task definition that uses a FireLens configuration <https://doc
    s.aws.amazon.com/AmazonECS/latest/developerguide/using_firelens.html#firelens-
    taskdef>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """


class ContainerDefinition(Boto3Model):
    """
    Container definitions are used in task definitions to describe the
    different containers that are launched as part of a task.
    """

    name: str
    """
    The name of a container.

    If you're linking multiple containers together in a
    task definition, the ``name`` of one container can be entered in the ``links``
    of another container to connect the containers. Up to 255 letters (uppercase
    and lowercase), numbers, underscores, and hyphens are allowed. This parameter
    maps to ``name`` in the docker container create command and the ``--name``
    option to docker run.
    """
    image: str
    """
    The image used to start a container.

    This string is passed directly to the
    Docker daemon. By default, images in the Docker Hub registry are available.
    Other repositories are specified with either  ``repository-url/image:tag``  or
    ``repository-url/image@digest`` . Up to 255 letters (uppercase and lowercase),
    numbers, hyphens, underscores, colons, periods, forward slashes, and number
    signs are allowed. This parameter maps to ``Image`` in the docker container
    create command and the ``IMAGE`` parameter of docker run.
    """
    essential: bool
    """
    If the ``essential`` parameter of a container is marked as ``true``, and
    that container fails or stops for any reason, all other containers that are
    part of the task are stopped.

    If the ``essential`` parameter of a container is marked
    as ``false``, its failure doesn't affect the rest of the containers in a task.
    If this parameter is omitted, a container is assumed to be essential.
    """
    repositoryCredentials: Optional[RepositoryCredentials] = None
    """
    The private repository authentication credentials to use.
    """
    cpu: Optional[int] = None
    """
    The number of ``cpu`` units reserved for the container.

    This parameter maps to
    ``CpuShares`` in the docker container create commandand the ``--cpu-shares``
    option to docker run.
    """
    memory: Optional[int] = None
    """
    The amount (in MiB) of memory to present to the container.

    If your container
    attempts to exceed the memory specified here, the container is killed. The
    total amount of memory reserved for all containers within a task must be lower
    than the task ``memory`` value, if one is specified. This parameter maps to
    ``Memory`` in the docker container create command and the ``--memory`` option
    to docker run.
    """
    memoryReservation: Optional[int] = None
    """
    The soft limit (in MiB) of memory to reserve for the container.

    When system
    memory is under heavy contention, Docker attempts to keep the container memory
    to this soft limit. However, your container can consume more memory when it
    needs to, up to either the hard limit specified with the ``memory`` parameter
    (if applicable), or all of the available memory on the container instance,
    whichever comes first. This parameter maps to ``MemoryReservation`` in the
    docker container create command and the ``--memory-reservation`` option to
    docker run.
    """
    links: Optional[List[str]] = None
    """
    The ``links`` parameter allows containers to communicate with each other
    without the need for port mappings.

    This parameter is only supported if the
    network mode of a task definition is ``bridge``. The ``name:internalName``
    construct is analogous to ``name:alias`` in Docker links. Up to 255 letters
    (uppercase and lowercase), numbers, underscores, and hyphens are allowed.. This
    parameter maps to ``Links`` in the docker container create command and the
    ``--link`` option to docker run.
    """
    portMappings: Optional[List["PortMapping"]] = None
    """
    The list of port mappings for the container.

    Port mappings allow containers to access ports on the host container
    instance to send or receive traffic.
    """
    restartPolicy: Optional[ContainerRestartPolicy] = None
    """
    The restart policy for a container.

    When you set up a restart policy, Amazon ECS can restart the container
    without needing to replace the task. For more information, see
    `Restart individual containers in Amazon ECS tasks with container restart policies <https://docs.aws.amazon.com/AmazonECS/latest/develo
    perguide/container-restart-policy.html>`_ in the *Amazon Elastic Container
    Service Developer Guide*.
    """
    entryPoint: Optional[List[str]] = None
    """
    Early versions of the Amazon ECS container agent don't properly handle
    ``entryPoint`` parameters.

    If you have problems using ``entryPoint``, update
    your container agent or enter your commands and arguments as ``command`` array
    items instead.
    """
    command: Optional[List[str]] = None
    """
    The command that's passed to the container.

    This parameter maps to ``Cmd`` in
    the docker container create command and the ``COMMAND`` parameter to docker
    run. If there are multiple arguments, each argument is a separated string in
    the array.
    """
    environment: Optional[List["KeyValuePair"]] = None
    """
    The environment variables to pass to a container.

    This parameter maps to
    ``Env`` in the docker container create command and the ``--env`` option to
    docker run.
    """
    environmentFiles: Optional[List["EnvironmentFile"]] = None
    """
    A list of files containing the environment variables to pass to a
    container.

    This parameter maps to the ``--env-file`` option to docker run.
    """
    mountPoints: Optional[List["MountPoint"]] = None
    """
    The mount points for data volumes in your container.
    """
    volumesFrom: Optional[List["VolumeFrom"]] = None
    """
    Data volumes to mount from another container.

    This parameter maps to
    ``VolumesFrom`` in the docker container create command and the ``--volumes-
    from`` option to docker run.
    """
    linuxParameters: Optional[LinuxParameters] = None
    """
    Linux-specific modifications that are applied to the container, such as
    Linux kernel capabilities.

    For more information see `KernelCapabilities <https://docs
    .aws.amazon.com/AmazonECS/latest/APIReference/API_KernelCapabilities.html>`_.
    """
    secrets: Optional[List["Secret"]] = None
    """
    The secrets to pass to the container.

    For more information, see
    `Specifying Sensitive Data <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-
    sensitive-data.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """
    dependsOn: Optional[List["ContainerDependency"]] = None
    """
    The dependencies defined for container startup and shutdown.

    A container can contain multiple dependencies on other containers in a task
    definition. When a dependency is defined for container startup, for
    container shutdown it is reversed.
    """
    startTimeout: Optional[int] = None
    """
    Time duration (in seconds) to wait before giving up on resolving
    dependencies for a container.

    For example, you specify two containers in a task definition
    with containerA having a dependency on containerB reaching a ``COMPLETE``,
    ``SUCCESS``, or ``HEALTHY`` status. If a ``startTimeout`` value is specified
    for containerB and it doesn't reach the desired status within that time then
    containerA gives up and not start. This results in the task transitioning to a
    ``STOPPED`` state.
    """
    stopTimeout: Optional[int] = None
    """
    Time duration (in seconds) to wait before the container is forcefully
    killed if it doesn't exit normally on its own.
    """
    hostname: Optional[str] = None
    """
    The hostname to use for your container.

    This parameter maps to ``Hostname`` in
    the docker container create command and the ``--hostname`` option to docker
    run.
    """
    user: Optional[str] = None
    """
    The user to use inside the container.

    This parameter maps to ``User`` in the
    docker container create command and the ``--user`` option to docker run.
    """
    workingDirectory: Optional[str] = None
    """
    The working directory to run commands inside the container in.

    This parameter
    maps to ``WorkingDir`` in the docker container create command and the
    ``--workdir`` option to docker run.
    """
    disableNetworking: Optional[bool] = None
    """
    When this parameter is true, networking is off within the container.

    This
    parameter maps to ``NetworkDisabled`` in the docker container create command.
    """
    privileged: Optional[bool] = None
    """
    When this parameter is true, the container is given elevated privileges on
    the host container instance (similar to the ``root`` user).

    This parameter maps to
    ``Privileged`` in the docker container create command and the ``--privileged``
    option to docker run
    """
    readonlyRootFilesystem: Optional[bool] = None
    """
    When this parameter is true, the container is given read-only access to its
    root file system.

    This parameter maps to ``ReadonlyRootfs`` in the docker
    container create command and the ``--read-only`` option to docker run.
    """
    dnsServers: Optional[List[str]] = None
    """
    A list of DNS servers that are presented to the container.

    This parameter maps
    to ``Dns`` in the docker container create command and the ``--dns`` option to
    docker run.
    """
    dnsSearchDomains: Optional[List[str]] = None
    """
    A list of DNS search domains that are presented to the container.

    This
    parameter maps to ``DnsSearch`` in the docker container create command and the
    ``--dns-search`` option to docker run.
    """
    extraHosts: Optional[List["HostEntry"]] = None
    """
    A list of hostnames and IP address mappings to append to the ``/etc/hosts``
    file on the container.

    This parameter maps to ``ExtraHosts`` in the docker
    container create command and the ``--add-host`` option to docker run.
    """
    dockerSecurityOptions: Optional[List[str]] = None
    """
    A list of strings to provide custom configuration for multiple security
    systems.

    This field isn't valid for containers in tasks using the Fargate launch
    type.
    """
    interactive: Optional[bool] = None
    """
    When this parameter is ``true``, you can deploy containerized applications
    that require ``stdin`` or a ``tty`` to be allocated.

    This parameter maps to
    ``OpenStdin`` in the docker container create command and the ``--interactive``
    option to docker run.
    """
    pseudoTerminal: Optional[bool] = None
    """
    When this parameter is ``true``, a TTY is allocated.

    This parameter maps to
    ``Tty`` in the docker container create command and the ``--tty`` option to
    docker run.
    """
    dockerLabels: Optional[Dict[str, str]] = None
    """
    A key/value map of labels to add to the container.

    This parameter maps to
    ``Labels`` in the docker container create command and the ``--label`` option to
    docker run. This parameter requires version 1.18 of the Docker Remote API or
    greater on your container instance. To check the Docker Remote API version on
    your container instance, log in to your container instance and run the
    following command: ``sudo docker version --format '{{.Server.APIVersion}}'``
    """
    ulimits: Optional[List["Ulimit"]] = None
    """
    A list of ``ulimits`` to set in the container.

    If a ``ulimit`` value is
    specified in a task definition, it overrides the default values set by Docker.
    This parameter maps to ``Ulimits`` in the docker container create command and
    the ``--ulimit`` option to docker run. Valid naming values are displayed in the
    `Ulimit <https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Ulimit.h
    tml>`_ data type.
    """
    logConfiguration: Optional[LogConfiguration] = None
    """
    The log configuration specification for the container.
    """
    healthCheck: Optional[HealthCheck] = None
    """
    The container health check command and associated configuration parameters
    for the container.

    This parameter maps to ``HealthCheck`` in the docker container
    create command and the ``HEALTHCHECK`` parameter of docker run.
    """
    systemControls: Optional[List["SystemControl"]] = None
    """
    A list of namespaced kernel parameters to set in the container.

    This parameter
    maps to ``Sysctls`` in the docker container create command and the ``--sysctl``
    option to docker run. For example, you can configure
    ``net.ipv4.tcp_keepalive_time`` setting to maintain longer lived connections.
    """
    resourceRequirements: Optional[List["ResourceRequirement"]] = None
    """
    The type and amount of a resource to assign to a container.

    The only supported resource is a GPU.
    """
    firelensConfiguration: Optional[FirelensConfiguration] = None
    """
    The FireLens configuration for the container.

    This is used to specify and configure a log router for container logs. For
    more information, see
    `Custom Log Routing <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_
    firelens.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """
    credentialSpecs: Optional[List[str]] = None
    """
    A list of ARNs in SSM or Amazon S3 to a credential spec (``CredSpec``) file
    that configures the container for Active Directory authentication.

    We recommend
    that you use this parameter instead of the ``dockerSecurityOptions``. The
    maximum number of ARNs is 1.
    """


class HostVolumeProperties(Boto3Model):
    """
    This parameter is specified when you use bind mount host volumes. The
    contents of the ``host`` parameter determine whether your bind mount host
    volume persists on the host container instance and where it's stored. If
    the ``host`` parameter is empty, then the Docker daemon assigns a host path
    for your data volume. However, the data isn't guaranteed to persist after
    the containers that are associated with it stop running.

    Windows containers can mount whole directories on the same drive as
    ``$env:ProgramData``. Windows containers can't mount directories on a different
    drive, and mount point can't be across drives. For example, you can mount
    ``C:mypath:C:mypath`` and ``D::D:``, but not ``D:mypath:C:mypath`` or
    ``D::C:mypath``.
    """

    sourcePath: Optional[str] = None
    """
    When the ``host`` parameter is used, specify a ``sourcePath`` to declare
    the path on the host container instance that's presented to the container.

    If this
    parameter is empty, then the Docker daemon has assigned a host path for you. If
    the ``host`` parameter contains a ``sourcePath`` file location, then the data
    volume persists at the specified location on the host container instance until
    you delete it manually. If the ``sourcePath`` value doesn't exist on the host
    container instance, the Docker daemon creates it. If the location does exist,
    the contents of the source path folder are exported.
    """


class DockerVolumeConfiguration(Boto3Model):
    """
    This parameter is specified when you use Docker volumes.

    Windows containers only support the use of the ``local`` driver. To use bind
    mounts, specify the ``host`` parameter instead.

    Docker volumes aren't supported by tasks run on Fargate.
    """

    scope: Optional[Literal["task", "shared"]] = None
    """
    The scope for the Docker volume that determines its lifecycle.

    Docker volumes
    that are scoped to a ``task`` are automatically provisioned when the task
    starts and destroyed when the task stops. Docker volumes that are scoped as
    ``shared`` persist after the task stops.
    """
    autoprovision: Optional[bool] = None
    """
    If this value is ``true``, the Docker volume is created if it doesn't
    already exist.
    """
    driver: Optional[str] = None
    """
    The Docker volume driver to use.

    The driver value must match the driver name
    provided by Docker because it is used for task placement. If the driver was
    installed using the Docker plugin CLI, use ``docker plugin ls`` to retrieve the
    driver name from your container instance. If the driver was installed using
    another method, use Docker plugin discovery to retrieve the driver name. This
    parameter maps to ``Driver`` in the docker container create command and the
    ``xxdriver`` option to docker volume create.
    """
    driverOpts: Optional[Dict[str, str]] = None
    """
    A map of Docker driver-specific options passed through.

    This parameter maps to
    ``DriverOpts`` in the docker create-volume command and the ``xxopt`` option to
    docker volume create.
    """
    labels: Optional[Dict[str, str]] = None
    """
    Custom metadata to add to your Docker volume.

    This parameter maps to ``Labels``
    in the docker container create command and the ``xxlabel`` option to docker
    volume create.
    """


class EFSAuthorizationConfig(Boto3Model):
    """
    The authorization configuration details for the Amazon EFS file system.
    """

    accessPointId: Optional[str] = None
    """
    The Amazon EFS access point ID to use.

    If an access point is specified, the
    root directory value specified in the ``EFSVolumeConfiguration`` must either be
    omitted or set to ``/`` which will enforce the path set on the EFS access
    point. If an access point is used, transit encryption must be on in the
    ``EFSVolumeConfiguration``. For more information, see `Working with Amazon EFS
    access points <https://docs.aws.amazon.com/efs/latest/ug/efs-access-
    points.html>`_ in the *Amazon Elastic File System User Guide*.
    """
    iam: Optional[Literal["ENABLED", "DISABLED"]] = None
    """
    Determines whether to use the Amazon ECS task role defined in a task
    definition when mounting the Amazon EFS file system.

    If it is turned on, transit
    encryption must be turned on in the ``EFSVolumeConfiguration``. If this
    parameter is omitted, the default value of ``DISABLED`` is used. For more
    information, see `Using Amazon EFS access
    points <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-
    volumes.html#efs-volume-accesspoints>`_ in the *Amazon Elastic Container Service
    Developer Guide*.
    """


class EFSVolumeConfiguration(Boto3Model):
    """
    This parameter is specified when you use an Amazon Elastic File System file
    system for task storage.
    """

    fileSystemId: str
    """
    The Amazon EFS file system ID to use.
    """
    rootDirectory: Optional[str] = None
    """
    The directory within the Amazon EFS file system to mount as the root
    directory inside the host.

    If this parameter is omitted, the root of the Amazon EFS
    volume will be used. Specifying ``/`` will have the same effect as omitting
    this parameter.
    """
    transitEncryption: Optional[Literal["ENABLED", "DISABLED"]] = None
    """
    Determines whether to use encryption for Amazon EFS data in transit between
    the Amazon ECS host and the Amazon EFS server.

    Transit encryption must be turned on
    if Amazon EFS IAM authorization is used. If this parameter is omitted, the
    default value of ``DISABLED`` is used. For more information, see `Encrypting
    data in transit <https://docs.aws.amazon.com/efs/latest/ug/encryption-in-
    transit.html>`_ in the *Amazon Elastic File System User Guide*.
    """
    transitEncryptionPort: Optional[int] = None
    """
    The port to use when sending encrypted data between the Amazon ECS host and
    the Amazon EFS server.

    If you do not specify a transit encryption port, it will use the port
    selection strategy that the Amazon EFS mount helper uses. For more
    information, see
    `EFS mount helper <https://docs.aws.amazon.com/efs/latest/ug/efs-mount-helper.html>`_
    in the
    *Amazon Elastic File System User Guide*.
    """
    authorizationConfig: Optional[EFSAuthorizationConfig] = None
    """
    The authorization configuration details for the Amazon EFS file system.
    """


class FSxWindowsFileServerAuthorizationConfig(Boto3Model):
    """
    The authorization configuration details for the Amazon FSx for Windows File
    Server file system.
    """

    credentialsParameter: str
    """
    The authorization credential option to use.

    The authorization credential options can be provided using either the
    Amazon Resource Name (ARN) of an Secrets Manager secret or SSM Parameter
    Store parameter. The ARN refers to the stored credentials.
    """
    domain: str
    """
A fully qualified domain name hosted by an `Directory
Service <https://docs.aws.amazon.com/directoryservice/latest/admin-
guide/directory_microsoft_ad.html>`_ Managed Microsoft AD (Active Directory) or
self-hosted AD on Amazon EC2.
    """


class FSxWindowsFileServerVolumeConfiguration(Boto3Model):
    """
    This parameter is specified when you use Amazon FSx for Windows File Server
    file system for task storage.
    """

    fileSystemId: str
    """
    The Amazon FSx for Windows File Server file system ID to use.
    """
    rootDirectory: str
    """
    The directory within the Amazon FSx for Windows File Server file system to
    mount as the root directory inside the host.
    """
    authorizationConfig: FSxWindowsFileServerAuthorizationConfig
    """
    The authorization configuration details for the Amazon FSx for Windows File
    Server file system.
    """


class Volume(Boto3Model):
    """
    The data volume configuration for tasks launched using this task
    definition.

    Specifying a volume configuration in a task definition is optional. The volume
    configuration may contain multiple volumes but only one volume configured at
    launch is supported. Each volume defined in the volume configuration may only
    specify a ``name`` and one of either ``configuredAtLaunch``,
    ``dockerVolumeConfiguration``, ``efsVolumeConfiguration``,
    ``fsxWindowsFileServerVolumeConfiguration``, or ``host``. If an empty volume
    configuration is specified, by default Amazon ECS uses a host volume. For more
    information, see `Using data volumes in tasks <https://docs.aws.amazon.com/Amaz
    onECS/latest/developerguide/using_data_volumes.html>`_.
    """

    name: Optional[str] = None
    """
    The name of the volume.

    Up to 255 letters (uppercase and lowercase), numbers, underscores, and
    hyphens are allowed.
    """
    host: Optional[HostVolumeProperties] = None
    """
    This parameter is specified when you use bind mount host volumes.

    The contents
    of the ``host`` parameter determine whether your bind mount host volume
    persists on the host container instance and where it's stored. If the ``host``
    parameter is empty, then the Docker daemon assigns a host path for your data
    volume. However, the data isn't guaranteed to persist after the containers that
    are associated with it stop running.
    """
    dockerVolumeConfiguration: Optional[DockerVolumeConfiguration] = None
    """
    This parameter is specified when you use Docker volumes.
    """
    efsVolumeConfiguration: Optional[EFSVolumeConfiguration] = None
    """
    This parameter is specified when you use an Amazon Elastic File System file
    system for task storage.
    """
    fsxWindowsFileServerVolumeConfiguration: Optional[
        FSxWindowsFileServerVolumeConfiguration
    ] = None
    """
    This parameter is specified when you use Amazon FSx for Windows File Server
    file system for task storage.
    """
    configuredAtLaunch: Optional[bool] = None
    """
    Indicates whether the volume should be configured at launch time.

    This is used to create Amazon EBS volumes for standalone tasks or tasks
    created as part of a service. Each task definition revision may only have
    one volume configured at launch in the volume configuration.
    """


class Attribute(Boto3Model):
    """
    An attribute is a name-value pair that's associated with an Amazon ECS
    object.

    Use attributes to extend the Amazon ECS data model by adding custom
    metadata to your resources. For more information, see
    `Attributes <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-
    placement-constraints.html#attributes>`_ in the *Amazon Elastic Container Service
    Developer Guide*.
    """

    name: str
    """
    The name of the attribute.

    The ``name`` must contain between 1 and 128
    characters. The name may contain letters (uppercase and lowercase), numbers,
    hyphens (-), underscores (_), forward slashes (/), back slashes (), or
    periods (.).
    """
    value: Optional[str] = None
    """
    The value of the attribute.

    The ``value`` must contain between 1 and 128
    characters. It can contain letters (uppercase and lowercase), numbers, hyphens
    (-), underscores (_), periods (.), at signs (@), forward slashes (/), back
    slashes (), colons (:), or spaces. The value can't start or end with a space.
    """
    targetType: Optional[Literal["container-instance"]] = None
    """
    The type of the target to attach the attribute with.

    This parameter is required if you use the short form ID for a resource
    instead of the full ARN.
    """
    targetId: Optional[str] = None
    """
    The ID of the target.

    You can specify the short form ID for a resource or the full Amazon
    Resource Name (ARN).
    """


class TaskDefinitionPlacementConstraint(Boto3Model):
    """The constraint on task placement in the task definition. For more information,
    see `Task placement
    constraints <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-
    placement-constraints.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.

    Task placement constraints aren't supported for tasks run on Fargate.

    """

    type: Optional[Literal["memberOf"]] = None
    """
    The type of constraint.

    The ``MemberOf`` constraint restricts selection to be
    from a group of valid candidates.
    """
    expression: Optional[str] = None
    """
    A cluster query language expression to apply to the constraint.

    For more information, see
    `Cluster query language <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-
    query-language.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """


class RuntimePlatform(Boto3Model):
    """
    The operating system that your task definitions are running on. A platform
    family is specified only for tasks using the Fargate launch type.

    When you specify a task in a service, this value must match the
    ``runtimePlatform`` value of the service.
    """

    cpuArchitecture: Optional[Literal["X86_64", "ARM64"]] = None
    """
    The CPU architecture.
    """
    operatingSystemFamily: Optional[
        Literal[
            "WINDOWS_SERVER_2019_FULL",
            "WINDOWS_SERVER_2019_CORE",
            "WINDOWS_SERVER_2016_FULL",
            "WINDOWS_SERVER_2004_CORE",
            "WINDOWS_SERVER_2022_CORE",
            "WINDOWS_SERVER_2022_FULL",
            "WINDOWS_SERVER_20H2_CORE",
            "LINUX",
        ]
    ] = None
    """
    The operating system.
    """


class InferenceAccelerator(Boto3Model):
    """
    Details on an Elastic Inference accelerator.

    For more information, see
    `Working with Amazon Elastic Inference on Amazon ECS <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-
    inference.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    deviceName: str
    """
    The Elastic Inference accelerator device name.

    The ``deviceName`` must also be
    referenced in a container definition as a `ResourceRequirement <https://docs.aw
    s.amazon.com/AmazonECS/latest/APIReference/API_ResourceRequirement.html>`_.
    """
    deviceType: str
    """
    The Elastic Inference accelerator type to use.
    """


class ProxyConfiguration(Boto3Model):
    """
    The configuration details for the App Mesh proxy.

    Your Amazon ECS container instances require at least version 1.26.0 of the
    container agent and at least version 1.26.0-1 of the ``ecs-init`` package to
    use a proxy configuration. If your container instances are launched from the
    Amazon ECS optimized AMI version ``20190301`` or later, they contain the
    required versions of the container agent and ``ecs-init``. For more
    information, see `Amazon ECS-optimized Linux
    AMI <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-
    optimized_AMI.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    type: Optional[Literal["APPMESH"]] = None
    """
    The proxy type.

    The only supported value is ``APPMESH``.
    """
    containerName: str
    """
    The name of the container that will serve as the App Mesh proxy.
    """
    properties: Optional[List["KeyValuePair"]] = None
    """
    The set of network configuration parameters to provide the Container
    Network Interface (CNI) plugin, specified as key-value pairs.
    """


class EphemeralStorage(Boto3Model):
    """
    The ephemeral storage settings to use for tasks run with the task
    definition.
    """

    sizeInGiB: int
    """
    The total amount, in GiB, of ephemeral storage to set for the task.

    The minimum
    supported value is ``20`` GiB and the maximum supported value is ``200`` GiB.
    """


class TaskDefinition(TagsDictMixin, PrimaryBoto3Model):
    """
    The details of a task definition which describes the container and volume
    definitions of an Amazon Elastic Container Service task.

    You can specify which Docker images to use, the required resources, and
    other configurations related to launching the task definition through an
    Amazon ECS service or task.
    """

    tag_class: ClassVar[Type] = ECSTag
    manager_class: ClassVar[Type[Boto3ModelManager]] = TaskDefinitionManager

    family: str
    """
    The name of a family that this task definition is registered to.

    Up to 255 characters are allowed. Letters (both uppercase and lowercase
    letters), numbers, hyphens (-), and underscores (_) are allowed.
    """
    containerDefinitions: List["ContainerDefinition"]
    """
    A list of container definitions in JSON format that describe the different
    containers that make up your task.

    For more information about container
    definition parameters and defaults, see `Amazon ECS Task Definitions <https://d
    ocs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html>`_ in the
    *Amazon Elastic Container Service Developer Guide*.
    """
    networkMode: Optional[Literal["bridge", "host", "awsvpc", "none"]] = "awsvpc"
    """
    The Docker networking mode to use for the containers in the task.

    The valid
    values are ``none``, ``bridge``, ``awsvpc``, and ``host``. If no network mode
    is specified, the default is ``bridge``.
    """
    taskDefinitionArn: str = Field(default=None, frozen=True)
    """
    The full Amazon Resource Name (ARN) of the task definition.
    """
    taskRoleArn: Optional[str] = None
    """
    The short name or full Amazon Resource Name (ARN) of the Identity and
    Access Management role that grants containers in the task permission to
    call Amazon Web Services APIs on your behalf.

    For informationabout the required IAM roles for Amazon ECS, see
    `IAM roles for Amazon ECS <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/security-ecs-
    iam-role-overview.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.
    """
    executionRoleArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the task execution role that grants the
    Amazon ECS container agent permission to make Amazon Web Services API calls
    on your behalf.

    For informationabout the required IAM roles for Amazon ECS, see
    `IAM roles for Amazon ECS <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/security-ecs-
    iam-role-overview.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.
    """
    revision: int = Field(default=None, frozen=True)
    """
    The revision of the task in a particular family.

    The revision is a version
    number of a task definition in a family. When you register a task definition
    for the first time, the revision is ``1``. Each time that you register a new
    revision of a task definition in the same family, the revision value always
    increases by one. This is even if you deregistered previous revisions in this
    family.
    """
    volumes: Optional[List["Volume"]] = None
    """
    The list of data volume definitions for the task.

    For more information, see
    `Using data volumes in tasks <https://docs.aws.amazon.com/AmazonECS/latest/deve
    loperguide/using_data_volumes.html>`_ in the *Amazon Elastic Container Service
    Developer Guide*.
    """
    status: Literal["ACTIVE", "INACTIVE", "DELETE_IN_PROGRESS"] = Field(
        default=None, frozen=True
    )
    """
    The status of the task definition.
    """
    requiresAttributes: List["Attribute"] = Field(default=None, frozen=True)
    """
    The container instance attributes required by your task.

    When an Amazon EC2 instance is registered to your cluster, the Amazon ECS
    container agent assigns some standard attributes to the instance. You can
    apply custom attributes. These are specified as key-value pairs using the
    Amazon ECS console or the
    `Pu tAttributes <https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PutA
     ttributes.html>`_ API. These attributes are used when determining task
    placement for tasks hosted on Amazon EC2 instances. For more information,
    see
    `Attributes <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-
    placement-constraints.html#attributes>`_ in the *Amazon Elastic Container Service
    Developer Guide*.
    """
    placementConstraints: Optional[List["TaskDefinitionPlacementConstraint"]] = None
    """
    An array of placement constraint objects to use for tasks.
    """
    compatibilities: List[Literal["EC2", "FARGATE", "EXTERNAL"]] = Field(
        default=None, frozen=True
    )
    """
    Amazon ECS validates the task definition parameters with those supported by
    the launch type.

    For more information, see `Amazon ECS launch types <https://docs.a
    ws.amazon.com/AmazonECS/latest/developerguide/launch_types.html>`_ in the *Amazon
    Elastic Container Service Developer Guide*.
    """
    runtimePlatform: Optional[RuntimePlatform] = None
    """
    The operating system that your task definitions are running on.

    A platform family is specified only for tasks using the Fargate launch
    type.
    """
    requiresCompatibilities: Optional[List[Literal["EC2", "FARGATE", "EXTERNAL"]]] = (
        None
    )
    """
    The task launch types the task definition was validated against.

    The valid
    values are ``EC2``, ``FARGATE``, and ``EXTERNAL``. For more information, see
    `Amazon ECS launch types <https://docs.aws.amazon.com/AmazonECS/latest/develope
    rguide/launch_types.html>`_ in the *Amazon Elastic Container Service Developer
    Guide*.
    """
    cpu: Optional[str] = None
    """
    The number of ``cpu`` units used by the task.

    If you use the EC2 launch type,
    this field is optional. Any value can be used. If you use the Fargate launch
    type, this field is required. You must use one of the following values. The
    value that you choose determines your range of valid values for the ``memory``
    parameter.
    """
    memory: Optional[str] = None
    """
    The amount (in MiB) of memory used by the task.
    """
    inferenceAccelerators: Optional[List["InferenceAccelerator"]] = None
    """
    The Elastic Inference accelerator that's associated with the task.
    """
    pidMode: Optional[Literal["host", "task"]] = None
    """
    The process namespace to use for the containers in the task.

    The valid values
    are ``host`` or ``task``. On Fargate for Linux containers, the only valid value
    is ``task``. For example, monitoring sidecars might need ``pidMode`` to access
    information about other containers running in the same task.
    """
    ipcMode: Optional[Literal["host", "task", "none"]] = None
    """
    The IPC resource namespace to use for the containers in the task.

    The valid
    values are ``host``, ``task``, or ``none``. If ``host`` is specified, then all
    containers within the tasks that specified the ``host`` IPC mode on the same
    container instance share the same IPC resources with the host Amazon EC2
    instance. If ``task`` is specified, all containers within the specified task
    share the same IPC resources. If ``none`` is specified, then IPC resources
    within the containers of a task are private and not shared with other
    containers in a task or on the container instance. If no value is specified,
    then the IPC resource namespace sharing depends on the Docker daemon setting on
    the container instance.
    """
    proxyConfiguration: Optional[ProxyConfiguration] = None
    """
    The configuration details for the App Mesh proxy.
    """
    registeredAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the task definition was registered.
    """
    deregisteredAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the task definition was deregistered.
    """
    registeredBy: str = Field(default=None, frozen=True)
    """
    The principal that registered the task definition.
    """
    ephemeralStorage: Optional[EphemeralStorage] = None
    """
    The ephemeral storage settings to use for tasks run with the task
    definition.
    """
    Tags: Optional[List["ECSTag"]] = None
    """
    The tags for the task definition.
    """

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

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

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

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


class NetworkBinding(Boto3Model):
    """
    Details on the network bindings between a container and its host container
    instance.

    After a task reaches the ``RUNNING`` status, manual and automatic
    host and container port assignments are visible in the ``networkBindings``
    section of `DescribeTasks <https://docs.aws.amazon.com/AmazonECS/latest/APIRefe
    rence/API_DescribeTasks.html>`_ API responses.
    """

    bindIP: Optional[str] = None
    """
    The IP address that the container is bound to on the container instance.
    """
    containerPort: Optional[int] = None
    """
    The port number on the container that's used with the network binding.
    """
    hostPort: Optional[int] = None
    """
    The port number on the host that's used with the network binding.
    """
    protocol: Optional[Literal["tcp", "udp"]] = None
    """
    The protocol used for the network binding.
    """
    containerPortRange: Optional[str] = None
    """
    The port number range on the container that's bound to the dynamically
    mapped host port range.
    """
    hostPortRange: Optional[str] = None
    """
    The port number range on the host that's used with the network binding.

    This is assigned is assigned by Docker and delivered by the Amazon ECS
    agent.
    """


class NetworkInterface(Boto3Model):
    """
    An object representing the elastic network interface for tasks that use the
    ``awsvpc`` network mode.
    """

    attachmentId: Optional[str] = None
    """
    The attachment ID for the network interface.
    """
    privateIpv4Address: Optional[str] = None
    """
    The private IPv4 address for the network interface.
    """
    ipv6Address: Optional[str] = None
    """
    The private IPv6 address for the network interface.
    """


class ManagedAgent(Boto3Model):
    """
    Details about the managed agent status for the container.
    """

    lastStartedAt: Optional[datetime] = None
    """
    The Unix timestamp for the time when the managed agent was last started.
    """
    name: Optional[Literal["ExecuteCommandAgent"]] = None
    """
    The name of the managed agent.

    When the execute command feature is turned on,
    the managed agent name is ``ExecuteCommandAgent``.
    """
    reason: Optional[str] = None
    """
    The reason for why the managed agent is in the state it is in.
    """
    lastStatus: Optional[str] = None
    """
    The last known status of the managed agent.
    """


class Container(Boto3Model):
    """
    A Docker container that's part of a task.
    """

    containerArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the container.
    """
    taskArn: Optional[str] = None
    """
    The ARN of the task.
    """
    name: Optional[str] = None
    """
    The name of the container.
    """
    image: Optional[str] = None
    """
    The image used for the container.
    """
    imageDigest: Optional[str] = None
    """
    The container image manifest digest.
    """
    runtimeId: Optional[str] = None
    """
    The ID of the Docker container.
    """
    lastStatus: Optional[str] = None
    """
    The last known status of the container.
    """
    exitCode: Optional[int] = None
    """
    The exit code returned from the container.
    """
    reason: Optional[str] = None
    """
    A short (255 max characters) human-readable string to provide additional
    details about a running or stopped container.
    """
    networkBindings: Optional[List["NetworkBinding"]] = None
    """
    The network bindings associated with the container.
    """
    networkInterfaces: Optional[List["NetworkInterface"]] = None
    """
    The network interfaces associated with the container.
    """
    healthStatus: Optional[Literal["HEALTHY", "UNHEALTHY", "UNKNOWN"]] = None
    """
    The health status of the container.

    If health checks aren't configured for this
    container in its task definition, then it reports the health status as
    ``UNKNOWN``.
    """
    managedAgents: Optional[List["ManagedAgent"]] = None
    """
    The details of any Amazon ECS managed agents associated with the container.
    """
    cpu: Optional[str] = None
    """
    The number of CPU units set for the container.

    The value is ``0`` if no value
    was specified in the container definition when the task definition was
    registered.
    """
    memory: Optional[str] = None
    """
    The hard limit (in MiB) of memory set for the container.
    """
    memoryReservation: Optional[str] = None
    """
    The soft limit (in MiB) of memory set for the container.
    """
    gpuIds: Optional[List[str]] = None
    """
    The IDs of each GPU assigned to the container.
    """


class ContainerOverride(Boto3Model):
    """
    The overrides that are sent to a container. An empty container override can
    be passed in. An example of an empty container override is
    ``{"containerOverrides": ` ] }``. If a non-empty container override is
    specified, the ``name`` parameter must be included.

    You can use Secrets Manager or Amazon Web Services Systems Manager Parameter
    Store to store the sensitive data. For more information, see [Retrieve secrets
    through environment
    variables <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/secrets-
    envvar.html>`_ in the Amazon ECS Developer Guide.
    """

    name: Optional[str] = None
    """
    The name of the container that receives the override.

    This parameter is required if any override is specified.
    """
    command: Optional[List[str]] = None
    """
    The command to send to the container that overrides the default command
    from the Docker image or the task definition.

    You must also specify a container name.
    """
    environment: Optional[List["KeyValuePair"]] = None
    """
    The environment variables to send to the container.

    You can add new environment variables, which are added to the container at
    launch, or you can override the existing environment variables from the
    Docker image or the task definition. You must also specify a container
    name.
    """
    environmentFiles: Optional[List["EnvironmentFile"]] = None
    """
    A list of files containing the environment variables to pass to a
    container, instead of the value from the container definition.
    """
    cpu: Optional[int] = None
    """
    The number of ``cpu`` units reserved for the container, instead of the
    default value from the task definition.

    You must also specify a container name.
    """
    memory: Optional[int] = None
    """
    The hard limit (in MiB) of memory to present to the container, instead of
    the default value from the task definition.

    If your container attempts to exceed the memory specified here, the
    container is killed. You must also specify a container name.
    """
    memoryReservation: Optional[int] = None
    """
    The soft limit (in MiB) of memory to reserve for the container, instead of
    the default value from the task definition.

    You must also specify a container name.
    """
    resourceRequirements: Optional[List["ResourceRequirement"]] = None
    """
    The type and amount of a resource to assign to a container, instead of the
    default value from the task definition.

    The only supported resource is a GPU.
    """


class InferenceAcceleratorOverride(Boto3Model):
    """
    Details on an Elastic Inference accelerator task override.

    This parameter is used to override the Elastic Inference accelerator
    specified in the task definition. For more information, see
    `Working with Amazon Elastic Inference on Amazon ECS <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-
    inference.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    deviceName: Optional[str] = None
    """
    The Elastic Inference accelerator device name to override for the task.

    This
    parameter must match a ``deviceName`` specified in the task definition.
    """
    deviceType: Optional[str] = None
    """
    The Elastic Inference accelerator type to use.
    """


class TaskOverride(Boto3Model):
    """
    One or more container overrides.
    """

    containerOverrides: Optional[List["ContainerOverride"]] = None
    """
    One or more container overrides that are sent to a task.
    """
    cpu: Optional[str] = None
    """
    The CPU override for the task.
    """
    inferenceAcceleratorOverrides: Optional[List["InferenceAcceleratorOverride"]] = None
    """
    The Elastic Inference accelerator override for the task.
    """
    executionRoleArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the task execution role override for the
    task.

    For more information, see `Amazon ECS task execution IAM role <https://do
    cs.aws.amazon.com/AmazonECS/latest/developerguide/task_execution_IAM_role.html>`_
    in the *Amazon Elastic Container Service Developer Guide*.
    """
    memory: Optional[str] = None
    """
    The memory override for the task.
    """
    taskRoleArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the role that containers in this task can
    assume.

    All containers in this task are granted the permissions that are specified
    in this role. For more information, see
    `IAM Role for Tasks <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-
    roles.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """
    ephemeralStorage: Optional[EphemeralStorage] = None
    """
    The ephemeral storage setting override for the task.
    """


class TaskEphemeralStorage(Boto3Model):
    """
    The Fargate ephemeral storage settings for the task.
    """

    sizeInGiB: Optional[int] = None
    """
    The total amount, in GiB, of the ephemeral storage to set for the task. The
    minimum supported value is ``20`` GiB and the maximum supported value is.

    ``200`` GiB.
    """
    kmsKeyId: Optional[str] = None
    """
    Specify an Key Management Service key ID to encrypt the ephemeral storage
    for the task.
    """


class Task(TagsDictMixin, PrimaryBoto3Model):
    """
    Details on a task in a cluster.
    """

    tag_class: ClassVar[Type] = ECSTag
    manager_class: ClassVar[Type[Boto3ModelManager]] = TaskManager

    Tags: List["ECSTag"] = Field(default=None, serialization_alias="tags")
    """
    The metadata that you apply to the task to help you categorize and organize
    the task.

    Each tag consists of a key and an optional value. You define both the key
    and value.
    """
    clusterArn: str
    """
    The ARN of the cluster that hosts the task.
    """
    platformVersion: Optional[str] = "LATEST"
    """
    The platform version where your task runs on.

    A platform version is only
    specified for tasks that use the Fargate launch type. If you didn't specify
    one, the ``LATEST`` platform version is used. For more information, see
    `Fargate Platform Versions <https://docs.aws.amazon.com/AmazonECS/latest/develo
    perguide/platform_versions.html>`_ in the *Amazon Elastic Container Service
    Developer Guide*.
    """
    launchType: Optional[Literal["EC2", "FARGATE", "EXTERNAL"]] = "FARGATE"
    """
    The infrastructure where your task runs on.

    For more information, see
    `Amazon ECS launch types <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/l
    aunch_types.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """
    attachments: List["Attachment"] = Field(default=None, frozen=True)
    """
    The Elastic Network Adapter that's associated with the task if the task
    uses the ``awsvpc`` network mode.
    """
    attributes: List["Attribute"] = Field(default=None, frozen=True)
    """
    The attributes of the task.
    """
    availabilityZone: str = Field(default=None, frozen=True)
    """
    The Availability Zone for the task.
    """
    capacityProviderName: str = Field(default=None, frozen=True)
    """
    The capacity provider that's associated with the task.
    """
    connectivity: Literal["CONNECTED", "DISCONNECTED"] = Field(
        default=None, frozen=True
    )
    """
    The connectivity status of a task.
    """
    connectivityAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the task last went into ``CONNECTED``
    status.
    """
    containerInstanceArn: str = Field(default=None, frozen=True)
    """
    The ARN of the container instances that host the task.
    """
    containers: List["Container"] = Field(default=None, frozen=True)
    """
    The containers that's associated with the task.
    """
    cpu: str = Field(default=None, frozen=True)
    """
    The number of CPU units used by the task as expressed in a task definition.

    It
    can be expressed as an integer using CPU units (for example, ``1024``). It can
    also be expressed as a string using vCPUs (for example, ``1 vCPU`` or ``1
    vcpu``). String values are converted to an integer that indicates the CPU units
    when the task definition is registered.
    """
    createdAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the task was created.

    More specifically,
    it's for the time when the task entered the ``PENDING`` state.
    """
    desiredStatus: str = Field(default=None, frozen=True)
    """
    The desired status of the task.

    For more information, see
    `Task Lifecycle <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-
    lifecycle.html>`_.
    """
    enableExecuteCommand: Optional[bool] = None
    """
    Determines whether execute command functionality is turned on for this
    task.

    If
    ``true``, execute command functionality is turned on all the containers in the
    task.
    """
    executionStoppedAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the task execution stopped.
    """
    group: Optional[str] = None
    """
    The name of the task group that's associated with the task.
    """
    healthStatus: Literal["HEALTHY", "UNHEALTHY", "UNKNOWN"] = Field(
        default=None, frozen=True
    )
    """
    The health status for the task.

    It's determined by the health of the essential
    containers in the task. If all essential containers in the task are reporting
    as ``HEALTHY``, the task status also reports as ``HEALTHY``. If any essential
    containers in the task are reporting as ``UNHEALTHY`` or ``UNKNOWN``, the task
    status also reports as ``UNHEALTHY`` or ``UNKNOWN``.
    """
    inferenceAccelerators: List["InferenceAccelerator"] = Field(
        default=None, frozen=True
    )
    """
    The Elastic Inference accelerator that's associated with the task.
    """
    lastStatus: str = Field(default=None, frozen=True)
    """
    The last known status for the task.

    For more information, see
    `Task Lifecycle <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-
    lifecycle.html>`_.
    """
    memory: str = Field(default=None, frozen=True)
    """
    The amount of memory (in MiB) that the task uses as expressed in a task
    definition.

    It can be expressed as an integer using MiB (for example,
    ``1024``). If it's expressed as a string using GB (for example, ``1GB`` or ``1
    GB``), it's converted to an integer indicating the MiB when the task definition
    is registered.
    """
    overrides: Optional[TaskOverride] = None
    """
    One or more container overrides.
    """
    platformFamily: str = Field(default=None, frozen=True)
    """
    The operating system that your tasks are running on.

    A platform family is specified only for tasks that use the Fargate launch
    type.
    """
    pullStartedAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the container image pull began.
    """
    pullStoppedAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the container image pull completed.
    """
    startedAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the task started.

    More specifically, it's
    for the time when the task transitioned from the ``PENDING`` state to the
    ``RUNNING`` state.
    """
    startedBy: Optional[str] = None
    """
    The tag specified when a task is started.

    If an Amazon ECS service started the
    task, the ``startedBy`` parameter contains the deployment ID of that service.
    """
    stopCode: Literal[
        "TaskFailedToStart",
        "EssentialContainerExited",
        "UserInitiated",
        "ServiceSchedulerInitiated",
        "SpotInterruption",
        "TerminationNotice",
    ] = Field(default=None, frozen=True)
    """
    The stop code indicating why a task was stopped.

    The ``stoppedReason`` might
    contain additional details.
    """
    stoppedAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the task was stopped.

    More specifically,
    it's for the time when the task transitioned from the ``RUNNING`` state to the
    ``STOPPED`` state.
    """
    stoppedReason: str = Field(default=None, frozen=True)
    """
    The reason that the task was stopped.
    """
    stoppingAt: datetime = Field(default=None, frozen=True)
    """
    The Unix timestamp for the time when the task stops.

    More specifically, it's
    for the time when the task transitions from the ``RUNNING`` state to
    ``STOPPING``.
    """
    taskArn: str = Field(default=None, frozen=True)
    """
    The Amazon Resource Name (ARN) of the task.
    """
    taskDefinitionArn: str = Field(default=None, frozen=True)
    """
    The ARN of the task definition that creates the task.
    """
    version: int = Field(default=None, frozen=True)
    """
    The version counter for the task.

    Every time a task experiences a change that
    starts a CloudWatch event, the version counter is incremented. If you replicate
    your Amazon ECS task state with CloudWatch Events, you can compare the version
    of a task reported by the Amazon ECS API actions with the version reported in
    CloudWatch Events for the task (inside the ``detail`` object) to verify that
    the version in your event stream is current.
    """
    ephemeralStorage: EphemeralStorage = Field(default=None, frozen=True)
    """
    The ephemeral storage settings for the task.
    """
    fargateEphemeralStorage: TaskEphemeralStorage = Field(default=None, frozen=True)
    """
    The Fargate ephemeral storage settings for the task.
    """
    taskDefinition: Optional[str] = None
    """
    The ``family`` and ``revision`` (``family:revision``) or full ARN of the
    task definition to run.

    If a ``revision`` isn't specified, the latest
    ``ACTIVE`` revision is used.
    """

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

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

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

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

    @property
    def serviceName(self) -> Optional[str]:
        """
        The name of the service that ran this task, if any.
        """

        return self.transform("group", r"^service:(.+)$")

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

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

    @cached_property
    def container_instance(self) -> Optional["ContainerInstance"]:
        """
        Return the :py:class:`ContainerInstance` object that runs this task, 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(
                {
                    "containerInstance": self.containerInstanceArn,
                    "cluster": self.clusterArn,
                }
            )
        except AttributeError:
            return None
        return ContainerInstance.objects.using(self.session).get(**pk)  # type: ignore[arg-type]

    @cached_property
    def service(self) -> Optional["Service"]:
        """
        Return the :py:class:`Service` object that runs this task, 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(
                {
                    "service": self.serviceName,
                    "cluster": self.clusterArn,
                }
            )
        except AttributeError:
            return None
        return Service.objects.using(self.session).get(**pk)  # type: ignore[arg-type]


class VersionInfo(Boto3Model):
    """
    The version information for the Amazon ECS container agent and Docker
    daemon running on the container instance.
    """

    agentVersion: Optional[str] = None
    """
    The version number of the Amazon ECS container agent.
    """
    agentHash: Optional[str] = None
    """
The Git commit hash for the Amazon ECS container agent build on the
`amazon-ecs-agent <https://github.com/aws/amazon-ecs-agent/commits/master>`_
GitHub repository.
    """
    dockerVersion: Optional[str] = None
    """
    The Docker version that's running on the container instance.
    """


class ContainerInstanceResource(Boto3Model):
    """
    Describes the resources available for a container instance.
    """

    name: Optional[str] = None
    """
    The name of the resource, such as ``CPU``, ``MEMORY``, ``PORTS``,
    ``PORTS_UDP``, or a user-defined resource.
    """
    type: Optional[str] = None
    """
    The type of the resource.

    Valid values: ``INTEGER``, ``DOUBLE``, ``LONG``, or
    ``STRINGSET``.
    """
    doubleValue: Optional[float] = None
    """
    When the ``doubleValue`` type is set, the value of the resource must be a
    double precision floating-point type.
    """
    longValue: Optional[int] = None
    """
    When the ``longValue`` type is set, the value of the resource must be an
    extended precision floating-point type.
    """
    integerValue: Optional[int] = None
    """
    When the ``integerValue`` type is set, the value of the resource must be an
    integer.
    """
    stringSetValue: Optional[List[str]] = None
    """
    When the ``stringSetValue`` type is set, the value of the resource must be
    a string type.
    """


class InstanceHealthCheckResult(Boto3Model):
    """
    An object representing the result of a container instance health status
    check.
    """

    type: Optional[Literal["CONTAINER_RUNTIME"]] = None
    """
    The type of container instance health status that was verified.
    """
    status: Optional[Literal["OK", "IMPAIRED", "INSUFFICIENT_DATA", "INITIALIZING"]] = (
        None
    )
    """
    The container instance health status.
    """
    lastUpdated: Optional[datetime] = None
    """
    The Unix timestamp for when the container instance health status was last
    updated.
    """
    lastStatusChange: Optional[datetime] = None
    """
    The Unix timestamp for when the container instance health status last
    changed.
    """


class ContainerInstanceHealthStatus(Boto3Model):
    """
    An object representing the health status of the container instance.
    """

    overallStatus: Optional[
        Literal["OK", "IMPAIRED", "INSUFFICIENT_DATA", "INITIALIZING"]
    ] = None
    """
    The overall health status of the container instance.

    This is an aggregate status of all container instance health checks.
    """
    details: Optional[List["InstanceHealthCheckResult"]] = None
    """
    An array of objects representing the details of the container instance
    health status.
    """


class ContainerInstance(
    TagsDictMixin, ECSContainerInstanceModelMixin, ReadonlyPrimaryBoto3Model
):
    """
    An Amazon EC2 or External instance that's running the Amazon ECS agent and
    has been registered with a cluster.
    """

    tag_class: ClassVar[Type] = ECSTag
    manager_class: ClassVar[Type[Boto3ModelManager]] = ContainerInstanceManager

    Tags: List["ECSTag"] = Field(default=None, serialization_alias="tags")
    """
    The metadata that you apply to the container instance to help you
    categorize and organize them.

    Each tag consists of a key and an optional value. You define both.
    """
    containerInstanceArn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the container instance.

    For more information
    about the ARN format, see `Amazon Resource Name
    (ARN) <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-
    settings.html#ecs-resource-ids>`_ in the *Amazon ECS Developer Guide*.
    """
    ec2InstanceId: Optional[str] = None
    """
    The ID of the container instance.

    For Amazon EC2 instances, this value is the Amazon EC2 instance ID. For
    external instances, this value is the Amazon Web Services Systems Manager
    managed instance ID.
    """
    capacityProviderName: Optional[str] = None
    """
    The capacity provider that's associated with the container instance.
    """
    version: Optional[int] = None
    """
    The version counter for the container instance.

    Every time a container instance
    experiences a change that triggers a CloudWatch event, the version counter is
    incremented. If you're replicating your Amazon ECS container instance state
    with CloudWatch Events, you can compare the version of a container instance
    reported by the Amazon ECS APIs with the version reported in CloudWatch Events
    for the container instance (inside the ``detail`` object) to verify that the
    version in your event stream is current.
    """
    versionInfo: Optional[VersionInfo] = None
    """
    The version information for the Amazon ECS container agent and Docker
    daemon running on the container instance.
    """
    remainingResources: Optional[List["ContainerInstanceResource"]] = None
    """
    For CPU and memory resource types, this parameter describes the remaining
    CPU and memory that wasn't already allocated to tasks and is therefore
    available for new tasks.

    For port resource types, this parameter describes the ports that
    were reserved by the Amazon ECS container agent (at instance registration time)
    and any task containers that have reserved port mappings on the host (with the
    ``host`` or ``bridge`` network mode). Any port that's not specified here is
    available for new tasks.
    """
    registeredResources: Optional[List["ContainerInstanceResource"]] = None
    """
    For CPU and memory resource types, this parameter describes the amount of
    each resource that was available on the container instance when the
    container agent registered it with Amazon ECS.

    This value represents the total amount of CPU and memory that can be
    allocated on this container instance to tasks. For port resource types,
    this parameter describes the ports that were reserved by the Amazon ECS
    container agent when it registered the container instance with Amazon ECS.
    """
    status: Optional[str] = None
    """
    The status of the container instance.

    The valid values are ``REGISTERING``,
    ``REGISTRATION_FAILED``, ``ACTIVE``, ``INACTIVE``, ``DEREGISTERING``, or
    ``DRAINING``.
    """
    statusReason: Optional[str] = None
    """
    The reason that the container instance reached its current status.
    """
    agentConnected: Optional[bool] = None
    """
    This parameter returns ``true`` if the agent is connected to Amazon ECS.

    An
    instance with an agent that may be unhealthy or stopped return ``false``. Only
    instances connected to an agent can accept task placement requests.
    """
    runningTasksCount: Optional[int] = None
    """
    The number of tasks on the container instance that have a desired status
    (``desiredStatus``) of ``RUNNING``.
    """
    pendingTasksCount: Optional[int] = None
    """
    The number of tasks on the container instance that are in the ``PENDING``
    status.
    """
    agentUpdateStatus: Optional[
        Literal["PENDING", "STAGING", "STAGED", "UPDATING", "UPDATED", "FAILED"]
    ] = None
    """
    The status of the most recent agent update.

    If an update wasn't ever requested,
    this value is ``NULL``.
    """
    attributes: Optional[List["Attribute"]] = None
    """
    The attributes set for the container instance, either by the Amazon ECS
    container agent at instance registration or manually with the
    `PutAttributes <h ttps://docs.aws.amazon.com/AmazonECS/latest/APIReference/
    API_PutAttributes.html >`_ operation.
    """
    registeredAt: Optional[datetime] = None
    """
    The Unix timestamp for the time when the container instance was registered.
    """
    attachments: Optional[List["Attachment"]] = None
    """
    The resources attached to a container instance, such as an elastic network
    interface.
    """
    healthStatus: Optional[ContainerInstanceHealthStatus] = None
    """
    An object representing the health status of the container instance.
    """

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

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

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

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

    @property
    def clusterName(self) -> Optional[str]:
        """
        The name of the cluster that houses this task, if any.
        """

        return self.transform(
            "containerInstanceArn", r":container-instance/(.+)/[0-9a-f]+$"
        )

    @property
    def name(self) -> Optional[str]:
        """
        The name of the cluster that houses this task, if any.
        """

        return self.transform(
            "containerInstanceArn", r":container-instance/.+/([0-9a-f]+)$"
        )

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

    @property
    def tasks(self) -> Optional[List["Task"]]:
        """
        Return the ARNs of :py:class:`Task` objects that run on this container
        instance, if any.
        """

        try:
            pk = OrderedDict(
                {
                    "cluster": self.clusterName,
                    "containerInstance": self.containerInstanceArn,
                    "desiredStatus": "RUNNING",
                }
            )
        except AttributeError:
            return []
        return Task.objects.using(self.session).list(**pk)  # type: ignore[arg-type]


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


class CreateServiceResponse(Boto3Model):
    service: Optional[Service] = None
    """
    The full description of your service following the create call.
    """


class DeleteServiceResponse(Boto3Model):
    service: Optional[Service] = None
    """
    The full description of the deleted service.
    """


class Failure(Boto3Model):
    """
    A failed resource.

    For a list of common causes, see `API failure reasons <https
    ://docs.aws.amazon.com/AmazonECS/latest/developerguide/api_failures_messages.ht
    ml>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    arn: Optional[str] = None
    """
    The Amazon Resource Name (ARN) of the failed resource.
    """
    reason: Optional[str] = None
    """
    The reason for the failure.
    """
    detail: Optional[str] = None
    """
    The details of the failure.
    """


class DescribeServicesResponse(Boto3Model):
    services: Optional[List["Service"]] = None
    """
    The list of services described.
    """
    failures: Optional[List["Failure"]] = None
    """
    Any failures associated with the call.
    """


class ListServicesResponse(Boto3Model):
    serviceArns: Optional[List[str]] = None
    """
    The list of full ARN entries for each service that's associated with the
    specified cluster.
    """
    nextToken: Optional[str] = None
    """
    The ``nextToken`` value to include in a future ``ListServices`` request.

    When
    the results of a ``ListServices`` request exceed ``maxResults``, this value can
    be used to retrieve the next page of results. This value is ``null`` when there
    are no more results to return.
    """


class UpdateServiceResponse(Boto3Model):
    service: Optional[Service] = None
    """
    The full description of your service following the update call.
    """


class ClusterServiceConnectDefaultsRequest(Boto3Model):
    """
    Use this parameter to set a default Service Connect namespace. After you
    set a default Service Connect namespace, any new services with Service
    Connect turned on that are created in the cluster are added as client
    services in the namespace. This setting only applies to new services that
    set the ``enabled`` parameter to ``true`` in the
    ``ServiceConnectConfiguration``. You can set the namespace of each service
    individually in the ``ServiceConnectConfiguration`` to override this
    default parameter.

    Tasks that run in a namespace can use short names to connect to services in
    the namespace. Tasks can connect to services across all of the clusters in
    the namespace. Tasks connect through a managed proxy container that
    collects logs and metrics for increased visibility. Only the tasks that
    Amazon ECS services create are supported with Service Connect. For more
    information, see
    `Service Connect <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-
    connect.html>`_ in the *Amazon Elastic Container Service Developer Guide*.
    """

    namespace: str
    """
    The namespace name or full Amazon Resource Name (ARN) of the Cloud Map
    namespace that's used when you create a service and don't specify a Service
    Connect configuration.

    The namespace name can include up to 1024 characters. The name is case-
    sensitive. The name can't include hyphens (-), tilde (~), greater than (>),
    less than (<), or slash (/).
    """


class CreateClusterResponse(Boto3Model):
    cluster: Optional[Cluster] = None
    """
    The full description of your new cluster.
    """


class DeleteClusterResponse(Boto3Model):
    cluster: Optional[Cluster] = None
    """
    The full description of the deleted cluster.
    """


class DescribeClustersResponse(Boto3Model):
    clusters: Optional[List["Cluster"]] = None
    """
    The list of clusters.
    """
    failures: Optional[List["Failure"]] = None
    """
    Any failures associated with the call.
    """


class ListClustersResponse(Boto3Model):
    clusterArns: Optional[List[str]] = None
    """
    The list of full Amazon Resource Name (ARN) entries for each cluster that's
    associated with your account.
    """
    nextToken: Optional[str] = None
    """
    The ``nextToken`` value to include in a future ``ListClusters`` request.

    When
    the results of a ``ListClusters`` request exceed ``maxResults``, this value can
    be used to retrieve the next page of results. This value is ``null`` when there
    are no more results to return.
    """


class UpdateClusterResponse(Boto3Model):
    cluster: Optional[Cluster] = None
    """
    Details about the cluster.
    """


class RegisterTaskDefinitionResponse(TagsDictMixin, Boto3Model):
    tag_class: ClassVar[Type] = ECSTag
    Tags: List["ECSTag"] = Field(default=None, serialization_alias="tags")
    """
    The list of tags associated with the task definition.
    """
    taskDefinition: Optional[TaskDefinition] = None
    """
    The full description of the registered task definition.
    """


class DeregisterTaskDefinitionResponse(Boto3Model):
    taskDefinition: Optional[TaskDefinition] = None
    """
    The full description of the deregistered task.
    """


class DescribeTaskDefinitionResponse(TagsDictMixin, Boto3Model):
    tag_class: ClassVar[Type] = ECSTag
    Tags: List["ECSTag"] = Field(default=None, serialization_alias="tags")
    """
    The metadata that's applied to the task definition to help you categorize
    and organize them.

    Each tag consists of a key and an optional value. You define both.
    """
    taskDefinition: Optional[TaskDefinition] = None
    """
    The full task definition description.
    """


class ListTaskDefinitionsResponse(Boto3Model):
    taskDefinitionArns: Optional[List[str]] = None
    """
    The list of task definition Amazon Resource Name (ARN) entries for the
    ``ListTaskDefinitions`` request.
    """
    nextToken: Optional[str] = None
    """
    The ``nextToken`` value to include in a future ``ListTaskDefinitions``
    request.

    When the results of a ``ListTaskDefinitions`` request exceed ``maxResults``,
    this value can be used to retrieve the next page of results. This value is
    ``null`` when there are no more results to return.
    """


class DescribeContainerInstancesResponse(Boto3Model):
    containerInstances: Optional[List["ContainerInstance"]] = None
    """
    The list of container instances.
    """
    failures: Optional[List["Failure"]] = None
    """
    Any failures associated with the call.
    """


class ListContainerInstancesResponse(Boto3Model):
    containerInstanceArns: Optional[List[str]] = None
    """
    The list of container instances with full ARN entries for each container
    instance associated with the specified cluster.
    """
    nextToken: Optional[str] = None
    """
    The ``nextToken`` value to include in a future ``ListContainerInstances``
    request.

    When the results of a ``ListContainerInstances`` request exceed
    ``maxResults``, this value can be used to retrieve the next page of results.
    This value is ``null`` when there are no more results to return.
    """


class ListTasksResponse(Boto3Model):
    taskArns: Optional[List[str]] = None
    """
    The list of task ARN entries for the ``ListTasks`` request.
    """
    nextToken: Optional[str] = None
    """
    The ``nextToken`` value to include in a future ``ListTasks`` request.

    When the
    results of a ``ListTasks`` request exceed ``maxResults``, this value can be
    used to retrieve the next page of results. This value is ``null`` when there
    are no more results to return.
    """


class DescribeTasksResponse(Boto3Model):
    tasks: Optional[List["Task"]] = None
    """
    The list of tasks.
    """
    failures: Optional[List["Failure"]] = None
    """
    Any failures associated with the call.
    """


class TaskManagedEBSVolumeTerminationPolicy(Boto3Model):
    """
    The termination policy for the volume when the task exits.

    This provides a way to control whether Amazon ECS terminates the Amazon EBS
    volume when the task stops.
    """

    deleteOnTermination: bool
    """
    Indicates whether the volume should be deleted on when the task stops.

    If a
    value of ``true`` is specified,
    Amazon ECS deletes the Amazon EBS volume on
    your behalf when the task goes into the ``STOPPED`` state. If no value is
    specified, the
    default value is ``true`` is used. When set to ``false``,
    Amazon ECS leaves the volume in your
    account.
    """


class TaskManagedEBSVolumeConfiguration(Boto3Model):
    """
    The configuration for the Amazon EBS volume that Amazon ECS creates and
    manages on your behalf.

    These settings are used to create each Amazon EBS volume, with one volume
    created for each task. The Amazon EBS volumes are visible in your account
    in the Amazon EC2 console once they are created.
    """

    encrypted: Optional[bool] = None
    """
    Indicates whether the volume should be encrypted.

    If no value is specified,
    encryption is turned on by default. This parameter maps 1:1 with the
    ``Encrypted`` parameter of the `CreateVolume API <https://docs.aws.amazon.com/A
    WSEC2/latest/APIReference/API_CreateVolume.html>`_ in the *Amazon EC2 API
    Reference*.
    """
    kmsKeyId: Optional[str] = None
    """
    The Amazon Resource Name (ARN) identifier of the Amazon Web Services Key
    Management Service key to use for Amazon EBS encryption.

    When encryption is
    turned on and no Amazon Web Services Key Management Service key is specified,
    the default Amazon Web Services managed key for Amazon EBS volumes is used.
    This parameter maps 1:1 with the ``KmsKeyId`` parameter of the `CreateVolume AP
    I <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateVolume.html
    >`_ in the *Amazon EC2 API Reference*.
    """
    volumeType: Optional[str] = None
    """
    The volume type.

    This parameter maps 1:1 with the ``VolumeType`` parameter of
    the `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/A
    PI_CreateVolume.html>`_ in the *Amazon EC2 API Reference*. For more information,
    see `Amazon EBS volume
    types <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-
    types.html>`_ in the *Amazon EC2 User Guide*.
    """
    sizeInGiB: Optional[int] = None
    """
    The size of the volume in GiB.

    You must specify either a volume size or a
    snapshot ID. If you specify a snapshot ID, the snapshot size is used for the
    volume size by default. You can optionally specify a volume size greater than
    or equal to the snapshot size. This parameter maps 1:1 with the ``Size``
    parameter of the `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/A
    PIReference/API_CreateVolume.html>`_ in the *Amazon EC2 API Reference*.
    """
    snapshotId: Optional[str] = None
    """
    The snapshot that Amazon ECS uses to create the volume.

    You must specify either
    a snapshot ID or a volume size. This parameter maps 1:1 with the ``SnapshotId``
    parameter of the `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/A
    PIReference/API_CreateVolume.html>`_ in the *Amazon EC2 API Reference*.
    """
    iops: Optional[int] = None
    """
    The number of I/O operations per second (IOPS).

    For ``gp3``, ``io1``, and
    ``io2`` 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.
    """
    throughput: Optional[int] = None
    """
    The throughput to provision for a volume, in MiB/s, with a maximum of 1,000
    MiB/s.

    This parameter maps 1:1 with the ``Throughput`` parameter of the
    `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_C
    reateVolume.html>`_ in the *Amazon EC2 API Reference*.
    """
    tagSpecifications: Optional[List["EBSTagSpecification"]] = None
    """
    The tags to apply to the volume.

    Amazon ECS applies service-managed tags by
    default. This parameter maps 1:1 with the ``TagSpecifications.N`` parameter of
    the `CreateVolume API <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/A
    PI_CreateVolume.html>`_ in the *Amazon EC2 API Reference*.
    """
    roleArn: str
    """
    The ARN of the IAM role to associate with this volume.

    This is the Amazon ECS
    infrastructure IAM role that is used to manage your Amazon Web Services
    infrastructure. We recommend using the Amazon ECS-managed
    ``AmazonECSInfrastructureRolePolicyForVolumes`` IAM policy with this role. For
    more information, see `Amazon ECS infrastructure IAM role <https://docs.aws.ama
    zon.com/AmazonECS/latest/developerguide/infrastructure_IAM_role.html>`_ in the
    *Amazon ECS Developer Guide*.
    """
    terminationPolicy: Optional[TaskManagedEBSVolumeTerminationPolicy] = None
    """
    The termination policy for the volume when the task exits.

    This provides a way to control whether Amazon ECS terminates the Amazon EBS
    volume when the task stops.
    """
    filesystemType: Optional[Literal["ext3", "ext4", "xfs"]] = None
    """
    The Linux filesystem type for the volume.

    For volumes created from a snapshot, you must specify the same filesystem
    type that the volume was using when the snapshot was created. If there is a
    filesystem type mismatch, the task will fail to start.
    """


class TaskVolumeConfiguration(Boto3Model):
    """
    Configuration settings for the task volume that was ``configuredAtLaunch``
    that weren't set during ``RegisterTaskDef``.
    """

    name: str
    """
    The name of the volume.

    This value must match the volume name from the
    ``Volume`` object in the task definition.
    """
    managedEBSVolume: Optional[TaskManagedEBSVolumeConfiguration] = None
    """
    The configuration for the Amazon EBS volume that Amazon ECS creates and
    manages on your behalf.

    These settings are used to create each Amazon EBS volume, with one volume
    created for each task. The Amazon EBS volumes are visible in your account
    in the Amazon EC2 console once they are created.
    """


class RunTaskResponse(Boto3Model):
    tasks: Optional[List["Task"]] = None
    """
    A full description of the tasks that were run.

    The tasks that were successfully placed on your cluster are described here.
    """
    failures: Optional[List["Failure"]] = None
    """
    Any failures associated with the call.
    """


class StopTaskResponse(Boto3Model):
    task: Optional[Task] = None
    """
    The task that was stopped.
    """
