{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ECS.Waiters
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECS.Waiters where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.DescribeServices
import Amazonka.ECS.DescribeTasks
import Amazonka.ECS.Lens
import Amazonka.ECS.Types
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.ECS.DescribeServices' every 15 seconds until a successful state is reached. An error is returned after 40 failed checks.
newServicesInactive :: Core.Wait DescribeServices
newServicesInactive :: Wait DescribeServices
newServicesInactive =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"ServicesInactive",
      $sel:attempts:Wait :: Int
Core.attempts = Int
40,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
15,
      $sel:acceptors:Wait :: [Acceptor DescribeServices]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"MISSING"
            Accept
Core.AcceptFailure
            ( forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( Lens' DescribeServicesResponse (Maybe [Failure])
describeServicesResponse_failures
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' Failure (Maybe Text)
failure_reason
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            ),
          forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"INACTIVE"
            Accept
Core.AcceptSuccess
            ( forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( Lens' DescribeServicesResponse (Maybe [ContainerService])
describeServicesResponse_services
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' ContainerService (Maybe Text)
containerService_status
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.ECS.DescribeTasks' every 6 seconds until a successful state is reached. An error is returned after 100 failed checks.
newTasksRunning :: Core.Wait DescribeTasks
newTasksRunning :: Wait DescribeTasks
newTasksRunning =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"TasksRunning",
      $sel:attempts:Wait :: Int
Core.attempts = Int
100,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
6,
      $sel:acceptors:Wait :: [Acceptor DescribeTasks]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"STOPPED"
            Accept
Core.AcceptFailure
            ( forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    (Lens' DescribeTasksResponse (Maybe [Task])
describeTasksResponse_tasks forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' Task (Maybe Text)
task_lastStatus
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            ),
          forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"MISSING"
            Accept
Core.AcceptFailure
            ( forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( Lens' DescribeTasksResponse (Maybe [Failure])
describeTasksResponse_failures
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' Failure (Maybe Text)
failure_reason
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            ),
          forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"RUNNING"
            Accept
Core.AcceptSuccess
            ( forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    (Lens' DescribeTasksResponse (Maybe [Task])
describeTasksResponse_tasks forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' Task (Maybe Text)
task_lastStatus
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.ECS.DescribeTasks' every 6 seconds until a successful state is reached. An error is returned after 100 failed checks.
newTasksStopped :: Core.Wait DescribeTasks
newTasksStopped :: Wait DescribeTasks
newTasksStopped =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"TasksStopped",
      $sel:attempts:Wait :: Int
Core.attempts = Int
100,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
6,
      $sel:acceptors:Wait :: [Acceptor DescribeTasks]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"STOPPED"
            Accept
Core.AcceptSuccess
            ( forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    (Lens' DescribeTasksResponse (Maybe [Task])
describeTasksResponse_tasks forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' Task (Maybe Text)
task_lastStatus
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            )
        ]
    }