{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECS.Waiters where

import qualified Amazonka.Core as Core
import Amazonka.ECS.DescribeServices
import Amazonka.ECS.DescribeTasks
import Amazonka.ECS.Lens
import Amazonka.ECS.Types
import qualified Amazonka.Lens as Lens
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 =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"ServicesInactive",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
40,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
15,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeServices]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeServices) (CI Text)
-> Acceptor DescribeServices
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"MISSING"
            Accept
Core.AcceptFailure
            ( (DescribeServicesResponse -> [Failure])
-> Fold DescribeServicesResponse Failure
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Failure] DescribeServicesResponse [Failure]
-> DescribeServicesResponse -> [Failure]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( (Maybe [Failure] -> Const [Failure] (Maybe [Failure]))
-> DescribeServicesResponse
-> Const [Failure] DescribeServicesResponse
Lens' DescribeServicesResponse (Maybe [Failure])
describeServicesResponse_failures
                        ((Maybe [Failure] -> Const [Failure] (Maybe [Failure]))
 -> DescribeServicesResponse
 -> Const [Failure] DescribeServicesResponse)
-> (([Failure] -> Const [Failure] [Failure])
    -> Maybe [Failure] -> Const [Failure] (Maybe [Failure]))
-> Getting [Failure] DescribeServicesResponse [Failure]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Failure] -> Const [Failure] [Failure])
-> Maybe [Failure] -> Const [Failure] (Maybe [Failure])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                ((Failure -> f Failure)
 -> DescribeServicesResponse -> f DescribeServicesResponse)
-> ((CI Text -> f (CI Text)) -> Failure -> f Failure)
-> (CI Text -> f (CI Text))
-> DescribeServicesResponse
-> f DescribeServicesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe Text -> f (Maybe Text)) -> Failure -> f Failure
Lens' Failure (Maybe Text)
failure_reason
                ((Maybe Text -> f (Maybe Text)) -> Failure -> f Failure)
-> ((CI Text -> f (CI Text)) -> Maybe Text -> f (Maybe Text))
-> (CI Text -> f (CI Text))
-> Failure
-> f Failure
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Maybe Text -> f (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((Text -> f Text) -> Maybe Text -> f (Maybe Text))
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> Maybe Text
-> f (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeServices) (CI Text)
-> Acceptor DescribeServices
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"INACTIVE"
            Accept
Core.AcceptSuccess
            ( (DescribeServicesResponse -> [ContainerService])
-> Fold DescribeServicesResponse ContainerService
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting
  [ContainerService] DescribeServicesResponse [ContainerService]
-> DescribeServicesResponse -> [ContainerService]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( (Maybe [ContainerService]
 -> Const [ContainerService] (Maybe [ContainerService]))
-> DescribeServicesResponse
-> Const [ContainerService] DescribeServicesResponse
Lens' DescribeServicesResponse (Maybe [ContainerService])
describeServicesResponse_services
                        ((Maybe [ContainerService]
  -> Const [ContainerService] (Maybe [ContainerService]))
 -> DescribeServicesResponse
 -> Const [ContainerService] DescribeServicesResponse)
-> (([ContainerService]
     -> Const [ContainerService] [ContainerService])
    -> Maybe [ContainerService]
    -> Const [ContainerService] (Maybe [ContainerService]))
-> Getting
     [ContainerService] DescribeServicesResponse [ContainerService]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ContainerService] -> Const [ContainerService] [ContainerService])
-> Maybe [ContainerService]
-> Const [ContainerService] (Maybe [ContainerService])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                ((ContainerService -> f ContainerService)
 -> DescribeServicesResponse -> f DescribeServicesResponse)
-> ((CI Text -> f (CI Text))
    -> ContainerService -> f ContainerService)
-> (CI Text -> f (CI Text))
-> DescribeServicesResponse
-> f DescribeServicesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe Text -> f (Maybe Text))
-> ContainerService -> f ContainerService
Lens' ContainerService (Maybe Text)
containerService_status
                ((Maybe Text -> f (Maybe Text))
 -> ContainerService -> f ContainerService)
-> ((CI Text -> f (CI Text)) -> Maybe Text -> f (Maybe Text))
-> (CI Text -> f (CI Text))
-> ContainerService
-> f ContainerService
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Maybe Text -> f (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((Text -> f Text) -> Maybe Text -> f (Maybe Text))
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> Maybe Text
-> f (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.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 =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"TasksRunning",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
100,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
6,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeTasks]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeTasks) (CI Text)
-> Acceptor DescribeTasks
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"STOPPED"
            Accept
Core.AcceptFailure
            ( (DescribeTasksResponse -> [Task])
-> Fold DescribeTasksResponse Task
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Task] DescribeTasksResponse [Task]
-> DescribeTasksResponse -> [Task]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Task] -> Const [Task] (Maybe [Task]))
-> DescribeTasksResponse -> Const [Task] DescribeTasksResponse
Lens' DescribeTasksResponse (Maybe [Task])
describeTasksResponse_tasks ((Maybe [Task] -> Const [Task] (Maybe [Task]))
 -> DescribeTasksResponse -> Const [Task] DescribeTasksResponse)
-> (([Task] -> Const [Task] [Task])
    -> Maybe [Task] -> Const [Task] (Maybe [Task]))
-> Getting [Task] DescribeTasksResponse [Task]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Task] -> Const [Task] [Task])
-> Maybe [Task] -> Const [Task] (Maybe [Task])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Task -> f Task)
 -> DescribeTasksResponse -> f DescribeTasksResponse)
-> ((CI Text -> f (CI Text)) -> Task -> f Task)
-> (CI Text -> f (CI Text))
-> DescribeTasksResponse
-> f DescribeTasksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe Text -> f (Maybe Text)) -> Task -> f Task
Lens' Task (Maybe Text)
task_lastStatus
                ((Maybe Text -> f (Maybe Text)) -> Task -> f Task)
-> ((CI Text -> f (CI Text)) -> Maybe Text -> f (Maybe Text))
-> (CI Text -> f (CI Text))
-> Task
-> f Task
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Maybe Text -> f (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((Text -> f Text) -> Maybe Text -> f (Maybe Text))
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> Maybe Text
-> f (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeTasks) (CI Text)
-> Acceptor DescribeTasks
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"MISSING"
            Accept
Core.AcceptFailure
            ( (DescribeTasksResponse -> [Failure])
-> Fold DescribeTasksResponse Failure
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Failure] DescribeTasksResponse [Failure]
-> DescribeTasksResponse -> [Failure]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( (Maybe [Failure] -> Const [Failure] (Maybe [Failure]))
-> DescribeTasksResponse -> Const [Failure] DescribeTasksResponse
Lens' DescribeTasksResponse (Maybe [Failure])
describeTasksResponse_failures
                        ((Maybe [Failure] -> Const [Failure] (Maybe [Failure]))
 -> DescribeTasksResponse -> Const [Failure] DescribeTasksResponse)
-> (([Failure] -> Const [Failure] [Failure])
    -> Maybe [Failure] -> Const [Failure] (Maybe [Failure]))
-> Getting [Failure] DescribeTasksResponse [Failure]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Failure] -> Const [Failure] [Failure])
-> Maybe [Failure] -> Const [Failure] (Maybe [Failure])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                ((Failure -> f Failure)
 -> DescribeTasksResponse -> f DescribeTasksResponse)
-> ((CI Text -> f (CI Text)) -> Failure -> f Failure)
-> (CI Text -> f (CI Text))
-> DescribeTasksResponse
-> f DescribeTasksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe Text -> f (Maybe Text)) -> Failure -> f Failure
Lens' Failure (Maybe Text)
failure_reason
                ((Maybe Text -> f (Maybe Text)) -> Failure -> f Failure)
-> ((CI Text -> f (CI Text)) -> Maybe Text -> f (Maybe Text))
-> (CI Text -> f (CI Text))
-> Failure
-> f Failure
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Maybe Text -> f (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((Text -> f Text) -> Maybe Text -> f (Maybe Text))
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> Maybe Text
-> f (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeTasks) (CI Text)
-> Acceptor DescribeTasks
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"RUNNING"
            Accept
Core.AcceptSuccess
            ( (DescribeTasksResponse -> [Task])
-> Fold DescribeTasksResponse Task
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Task] DescribeTasksResponse [Task]
-> DescribeTasksResponse -> [Task]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Task] -> Const [Task] (Maybe [Task]))
-> DescribeTasksResponse -> Const [Task] DescribeTasksResponse
Lens' DescribeTasksResponse (Maybe [Task])
describeTasksResponse_tasks ((Maybe [Task] -> Const [Task] (Maybe [Task]))
 -> DescribeTasksResponse -> Const [Task] DescribeTasksResponse)
-> (([Task] -> Const [Task] [Task])
    -> Maybe [Task] -> Const [Task] (Maybe [Task]))
-> Getting [Task] DescribeTasksResponse [Task]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Task] -> Const [Task] [Task])
-> Maybe [Task] -> Const [Task] (Maybe [Task])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Task -> f Task)
 -> DescribeTasksResponse -> f DescribeTasksResponse)
-> ((CI Text -> f (CI Text)) -> Task -> f Task)
-> (CI Text -> f (CI Text))
-> DescribeTasksResponse
-> f DescribeTasksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe Text -> f (Maybe Text)) -> Task -> f Task
Lens' Task (Maybe Text)
task_lastStatus
                ((Maybe Text -> f (Maybe Text)) -> Task -> f Task)
-> ((CI Text -> f (CI Text)) -> Maybe Text -> f (Maybe Text))
-> (CI Text -> f (CI Text))
-> Task
-> f Task
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Maybe Text -> f (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((Text -> f Text) -> Maybe Text -> f (Maybe Text))
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> Maybe Text
-> f (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.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 =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"TasksStopped",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
100,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
6,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeTasks]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeTasks) (CI Text)
-> Acceptor DescribeTasks
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"STOPPED"
            Accept
Core.AcceptSuccess
            ( (DescribeTasksResponse -> [Task])
-> Fold DescribeTasksResponse Task
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Task] DescribeTasksResponse [Task]
-> DescribeTasksResponse -> [Task]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Task] -> Const [Task] (Maybe [Task]))
-> DescribeTasksResponse -> Const [Task] DescribeTasksResponse
Lens' DescribeTasksResponse (Maybe [Task])
describeTasksResponse_tasks ((Maybe [Task] -> Const [Task] (Maybe [Task]))
 -> DescribeTasksResponse -> Const [Task] DescribeTasksResponse)
-> (([Task] -> Const [Task] [Task])
    -> Maybe [Task] -> Const [Task] (Maybe [Task]))
-> Getting [Task] DescribeTasksResponse [Task]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Task] -> Const [Task] [Task])
-> Maybe [Task] -> Const [Task] (Maybe [Task])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Task -> f Task)
 -> DescribeTasksResponse -> f DescribeTasksResponse)
-> ((CI Text -> f (CI Text)) -> Task -> f Task)
-> (CI Text -> f (CI Text))
-> DescribeTasksResponse
-> f DescribeTasksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe Text -> f (Maybe Text)) -> Task -> f Task
Lens' Task (Maybe Text)
task_lastStatus
                ((Maybe Text -> f (Maybe Text)) -> Task -> f Task)
-> ((CI Text -> f (CI Text)) -> Maybe Text -> f (Maybe Text))
-> (CI Text -> f (CI Text))
-> Task
-> f Task
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Maybe Text -> f (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((Text -> f Text) -> Maybe Text -> f (Maybe Text))
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> Maybe Text
-> f (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }