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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Schemas.DescribeCodeBinding
import Amazonka.Schemas.Lens
import Amazonka.Schemas.Types

-- | Polls 'Amazonka.Schemas.DescribeCodeBinding' every 2 seconds until a successful state is reached. An error is returned after 30 failed checks.
newCodeBindingExists :: Core.Wait DescribeCodeBinding
newCodeBindingExists :: Wait DescribeCodeBinding
newCodeBindingExists =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"CodeBindingExists",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
30,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
2,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeCodeBinding]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeCodeBinding) (CI Text)
-> Acceptor DescribeCodeBinding
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"CREATE_COMPLETE"
            Accept
Core.AcceptSuccess
            ( (Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> DescribeCodeBindingResponse -> f DescribeCodeBindingResponse
Lens' DescribeCodeBindingResponse (Maybe CodeGenerationStatus)
describeCodeBindingResponse_status
                ((Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
 -> DescribeCodeBindingResponse -> f DescribeCodeBindingResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> (CI Text -> f (CI Text))
-> DescribeCodeBindingResponse
-> f DescribeCodeBindingResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CodeGenerationStatus -> f CodeGenerationStatus)
-> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CodeGenerationStatus -> f CodeGenerationStatus)
 -> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> ((CI Text -> f (CI Text))
    -> CodeGenerationStatus -> f CodeGenerationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CodeGenerationStatus
-> f (Maybe CodeGenerationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CodeGenerationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CodeGenerationStatus
-> f CodeGenerationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CodeGenerationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeCodeBinding) (CI Text)
-> Acceptor DescribeCodeBinding
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"CREATE_IN_PROGRESS"
            Accept
Core.AcceptRetry
            ( (Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> DescribeCodeBindingResponse -> f DescribeCodeBindingResponse
Lens' DescribeCodeBindingResponse (Maybe CodeGenerationStatus)
describeCodeBindingResponse_status
                ((Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
 -> DescribeCodeBindingResponse -> f DescribeCodeBindingResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> (CI Text -> f (CI Text))
-> DescribeCodeBindingResponse
-> f DescribeCodeBindingResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CodeGenerationStatus -> f CodeGenerationStatus)
-> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CodeGenerationStatus -> f CodeGenerationStatus)
 -> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> ((CI Text -> f (CI Text))
    -> CodeGenerationStatus -> f CodeGenerationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CodeGenerationStatus
-> f (Maybe CodeGenerationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CodeGenerationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CodeGenerationStatus
-> f CodeGenerationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CodeGenerationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeCodeBinding) (CI Text)
-> Acceptor DescribeCodeBinding
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"CREATE_FAILED"
            Accept
Core.AcceptFailure
            ( (Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> DescribeCodeBindingResponse -> f DescribeCodeBindingResponse
Lens' DescribeCodeBindingResponse (Maybe CodeGenerationStatus)
describeCodeBindingResponse_status
                ((Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
 -> DescribeCodeBindingResponse -> f DescribeCodeBindingResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> (CI Text -> f (CI Text))
-> DescribeCodeBindingResponse
-> f DescribeCodeBindingResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CodeGenerationStatus -> f CodeGenerationStatus)
-> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CodeGenerationStatus -> f CodeGenerationStatus)
 -> Maybe CodeGenerationStatus -> f (Maybe CodeGenerationStatus))
-> ((CI Text -> f (CI Text))
    -> CodeGenerationStatus -> f CodeGenerationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CodeGenerationStatus
-> f (Maybe CodeGenerationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CodeGenerationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CodeGenerationStatus
-> f CodeGenerationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CodeGenerationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          ErrorCode -> Accept -> Acceptor DescribeCodeBinding
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"NotFoundException"
            Accept
Core.AcceptFailure
        ]
    }