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

import qualified Amazonka.Core as Core
import Amazonka.Kinesis.DescribeStream
import Amazonka.Kinesis.Lens
import Amazonka.Kinesis.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.Kinesis.DescribeStream' every 10 seconds until a successful state is reached. An error is returned after 18 failed checks.
newStreamExists :: Core.Wait DescribeStream
newStreamExists :: Wait DescribeStream
newStreamExists =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"StreamExists",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
18,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
10,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeStream]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeStream) (CI Text)
-> Acceptor DescribeStream
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"ACTIVE"
            Accept
Core.AcceptSuccess
            ( (StreamDescription -> f StreamDescription)
-> DescribeStreamResponse -> f DescribeStreamResponse
Lens' DescribeStreamResponse StreamDescription
describeStreamResponse_streamDescription
                ((StreamDescription -> f StreamDescription)
 -> DescribeStreamResponse -> f DescribeStreamResponse)
-> ((CI Text -> f (CI Text))
    -> StreamDescription -> f StreamDescription)
-> (CI Text -> f (CI Text))
-> DescribeStreamResponse
-> f DescribeStreamResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (StreamStatus -> f StreamStatus)
-> StreamDescription -> f StreamDescription
Lens' StreamDescription StreamStatus
streamDescription_streamStatus
                ((StreamStatus -> f StreamStatus)
 -> StreamDescription -> f StreamDescription)
-> ((CI Text -> f (CI Text)) -> StreamStatus -> f StreamStatus)
-> (CI Text -> f (CI Text))
-> StreamDescription
-> f StreamDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (StreamStatus -> CI Text)
-> (CI Text -> f (CI Text)) -> StreamStatus -> f StreamStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to StreamStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.Kinesis.DescribeStream' every 10 seconds until a successful state is reached. An error is returned after 18 failed checks.
newStreamNotExists :: Core.Wait DescribeStream
newStreamNotExists :: Wait DescribeStream
newStreamNotExists =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"StreamNotExists",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
18,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
10,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeStream]
Core._waitAcceptors =
        [ ErrorCode -> Accept -> Acceptor DescribeStream
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"ResourceNotFoundException"
            Accept
Core.AcceptSuccess
        ]
    }