{-# 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.AppStream.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.AppStream.Waiters where

import Amazonka.AppStream.DescribeFleets
import Amazonka.AppStream.Lens
import Amazonka.AppStream.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.AppStream.DescribeFleets' every 30 seconds until a successful state is reached. An error is returned after 40 failed checks.
newFleetStopped :: Core.Wait DescribeFleets
newFleetStopped :: Wait DescribeFleets
newFleetStopped =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"FleetStopped",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
40,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
30,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeFleets]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeFleets) (CI Text)
-> Acceptor DescribeFleets
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"INACTIVE"
            Accept
Core.AcceptSuccess
            ( (DescribeFleetsResponse -> [Fleet])
-> Fold DescribeFleetsResponse Fleet
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Fleet] DescribeFleetsResponse [Fleet]
-> DescribeFleetsResponse -> [Fleet]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse
Lens' DescribeFleetsResponse (Maybe [Fleet])
describeFleetsResponse_fleets ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
 -> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse)
-> (([Fleet] -> Const [Fleet] [Fleet])
    -> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> Getting [Fleet] DescribeFleetsResponse [Fleet]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Fleet] -> Const [Fleet] [Fleet])
-> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Fleet -> f Fleet)
 -> DescribeFleetsResponse -> f DescribeFleetsResponse)
-> ((CI Text -> f (CI Text)) -> Fleet -> f Fleet)
-> (CI Text -> f (CI Text))
-> DescribeFleetsResponse
-> f DescribeFleetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> f FleetState) -> Fleet -> f Fleet
Lens' Fleet FleetState
fleet_state
                ((FleetState -> f FleetState) -> Fleet -> f Fleet)
-> ((CI Text -> f (CI Text)) -> FleetState -> f FleetState)
-> (CI Text -> f (CI Text))
-> Fleet
-> f Fleet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> CI Text)
-> (CI Text -> f (CI Text)) -> FleetState -> f FleetState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to FleetState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeFleets) (CI Text)
-> Acceptor DescribeFleets
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"PENDING_ACTIVATE"
            Accept
Core.AcceptFailure
            ( (DescribeFleetsResponse -> [Fleet])
-> Fold DescribeFleetsResponse Fleet
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Fleet] DescribeFleetsResponse [Fleet]
-> DescribeFleetsResponse -> [Fleet]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse
Lens' DescribeFleetsResponse (Maybe [Fleet])
describeFleetsResponse_fleets ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
 -> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse)
-> (([Fleet] -> Const [Fleet] [Fleet])
    -> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> Getting [Fleet] DescribeFleetsResponse [Fleet]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Fleet] -> Const [Fleet] [Fleet])
-> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Fleet -> f Fleet)
 -> DescribeFleetsResponse -> f DescribeFleetsResponse)
-> ((CI Text -> f (CI Text)) -> Fleet -> f Fleet)
-> (CI Text -> f (CI Text))
-> DescribeFleetsResponse
-> f DescribeFleetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> f FleetState) -> Fleet -> f Fleet
Lens' Fleet FleetState
fleet_state
                ((FleetState -> f FleetState) -> Fleet -> f Fleet)
-> ((CI Text -> f (CI Text)) -> FleetState -> f FleetState)
-> (CI Text -> f (CI Text))
-> Fleet
-> f Fleet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> CI Text)
-> (CI Text -> f (CI Text)) -> FleetState -> f FleetState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to FleetState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeFleets) (CI Text)
-> Acceptor DescribeFleets
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"ACTIVE"
            Accept
Core.AcceptFailure
            ( (DescribeFleetsResponse -> [Fleet])
-> Fold DescribeFleetsResponse Fleet
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Fleet] DescribeFleetsResponse [Fleet]
-> DescribeFleetsResponse -> [Fleet]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse
Lens' DescribeFleetsResponse (Maybe [Fleet])
describeFleetsResponse_fleets ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
 -> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse)
-> (([Fleet] -> Const [Fleet] [Fleet])
    -> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> Getting [Fleet] DescribeFleetsResponse [Fleet]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Fleet] -> Const [Fleet] [Fleet])
-> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Fleet -> f Fleet)
 -> DescribeFleetsResponse -> f DescribeFleetsResponse)
-> ((CI Text -> f (CI Text)) -> Fleet -> f Fleet)
-> (CI Text -> f (CI Text))
-> DescribeFleetsResponse
-> f DescribeFleetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> f FleetState) -> Fleet -> f Fleet
Lens' Fleet FleetState
fleet_state
                ((FleetState -> f FleetState) -> Fleet -> f Fleet)
-> ((CI Text -> f (CI Text)) -> FleetState -> f FleetState)
-> (CI Text -> f (CI Text))
-> Fleet
-> f Fleet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> CI Text)
-> (CI Text -> f (CI Text)) -> FleetState -> f FleetState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to FleetState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.AppStream.DescribeFleets' every 30 seconds until a successful state is reached. An error is returned after 40 failed checks.
newFleetStarted :: Core.Wait DescribeFleets
newFleetStarted :: Wait DescribeFleets
newFleetStarted =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"FleetStarted",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
40,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
30,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeFleets]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeFleets) (CI Text)
-> Acceptor DescribeFleets
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"ACTIVE"
            Accept
Core.AcceptSuccess
            ( (DescribeFleetsResponse -> [Fleet])
-> Fold DescribeFleetsResponse Fleet
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Fleet] DescribeFleetsResponse [Fleet]
-> DescribeFleetsResponse -> [Fleet]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse
Lens' DescribeFleetsResponse (Maybe [Fleet])
describeFleetsResponse_fleets ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
 -> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse)
-> (([Fleet] -> Const [Fleet] [Fleet])
    -> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> Getting [Fleet] DescribeFleetsResponse [Fleet]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Fleet] -> Const [Fleet] [Fleet])
-> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Fleet -> f Fleet)
 -> DescribeFleetsResponse -> f DescribeFleetsResponse)
-> ((CI Text -> f (CI Text)) -> Fleet -> f Fleet)
-> (CI Text -> f (CI Text))
-> DescribeFleetsResponse
-> f DescribeFleetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> f FleetState) -> Fleet -> f Fleet
Lens' Fleet FleetState
fleet_state
                ((FleetState -> f FleetState) -> Fleet -> f Fleet)
-> ((CI Text -> f (CI Text)) -> FleetState -> f FleetState)
-> (CI Text -> f (CI Text))
-> Fleet
-> f Fleet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> CI Text)
-> (CI Text -> f (CI Text)) -> FleetState -> f FleetState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to FleetState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeFleets) (CI Text)
-> Acceptor DescribeFleets
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"PENDING_DEACTIVATE"
            Accept
Core.AcceptFailure
            ( (DescribeFleetsResponse -> [Fleet])
-> Fold DescribeFleetsResponse Fleet
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Fleet] DescribeFleetsResponse [Fleet]
-> DescribeFleetsResponse -> [Fleet]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse
Lens' DescribeFleetsResponse (Maybe [Fleet])
describeFleetsResponse_fleets ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
 -> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse)
-> (([Fleet] -> Const [Fleet] [Fleet])
    -> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> Getting [Fleet] DescribeFleetsResponse [Fleet]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Fleet] -> Const [Fleet] [Fleet])
-> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Fleet -> f Fleet)
 -> DescribeFleetsResponse -> f DescribeFleetsResponse)
-> ((CI Text -> f (CI Text)) -> Fleet -> f Fleet)
-> (CI Text -> f (CI Text))
-> DescribeFleetsResponse
-> f DescribeFleetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> f FleetState) -> Fleet -> f Fleet
Lens' Fleet FleetState
fleet_state
                ((FleetState -> f FleetState) -> Fleet -> f Fleet)
-> ((CI Text -> f (CI Text)) -> FleetState -> f FleetState)
-> (CI Text -> f (CI Text))
-> Fleet
-> f Fleet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> CI Text)
-> (CI Text -> f (CI Text)) -> FleetState -> f FleetState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to FleetState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeFleets) (CI Text)
-> Acceptor DescribeFleets
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"INACTIVE"
            Accept
Core.AcceptFailure
            ( (DescribeFleetsResponse -> [Fleet])
-> Fold DescribeFleetsResponse Fleet
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting [Fleet] DescribeFleetsResponse [Fleet]
-> DescribeFleetsResponse -> [Fleet]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse
Lens' DescribeFleetsResponse (Maybe [Fleet])
describeFleetsResponse_fleets ((Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
 -> DescribeFleetsResponse -> Const [Fleet] DescribeFleetsResponse)
-> (([Fleet] -> Const [Fleet] [Fleet])
    -> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet]))
-> Getting [Fleet] DescribeFleetsResponse [Fleet]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Fleet] -> Const [Fleet] [Fleet])
-> Maybe [Fleet] -> Const [Fleet] (Maybe [Fleet])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just)
                )
                ((Fleet -> f Fleet)
 -> DescribeFleetsResponse -> f DescribeFleetsResponse)
-> ((CI Text -> f (CI Text)) -> Fleet -> f Fleet)
-> (CI Text -> f (CI Text))
-> DescribeFleetsResponse
-> f DescribeFleetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> f FleetState) -> Fleet -> f Fleet
Lens' Fleet FleetState
fleet_state
                ((FleetState -> f FleetState) -> Fleet -> f Fleet)
-> ((CI Text -> f (CI Text)) -> FleetState -> f FleetState)
-> (CI Text -> f (CI Text))
-> Fleet
-> f Fleet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (FleetState -> CI Text)
-> (CI Text -> f (CI Text)) -> FleetState -> f FleetState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to FleetState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }