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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Signer.DescribeSigningJob
import Amazonka.Signer.Lens
import Amazonka.Signer.Types

-- | Polls 'Amazonka.Signer.DescribeSigningJob' every 20 seconds until a successful state is reached. An error is returned after 25 failed checks.
newSuccessfulSigningJob :: Core.Wait DescribeSigningJob
newSuccessfulSigningJob :: Wait DescribeSigningJob
newSuccessfulSigningJob =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"SuccessfulSigningJob",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
25,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
20,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeSigningJob]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeSigningJob) (CI Text)
-> Acceptor DescribeSigningJob
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Succeeded"
            Accept
Core.AcceptSuccess
            ( (Maybe SigningStatus -> f (Maybe SigningStatus))
-> DescribeSigningJobResponse -> f DescribeSigningJobResponse
Lens' DescribeSigningJobResponse (Maybe SigningStatus)
describeSigningJobResponse_status
                ((Maybe SigningStatus -> f (Maybe SigningStatus))
 -> DescribeSigningJobResponse -> f DescribeSigningJobResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe SigningStatus -> f (Maybe SigningStatus))
-> (CI Text -> f (CI Text))
-> DescribeSigningJobResponse
-> f DescribeSigningJobResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (SigningStatus -> f SigningStatus)
-> Maybe SigningStatus -> f (Maybe SigningStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((SigningStatus -> f SigningStatus)
 -> Maybe SigningStatus -> f (Maybe SigningStatus))
-> ((CI Text -> f (CI Text)) -> SigningStatus -> f SigningStatus)
-> (CI Text -> f (CI Text))
-> Maybe SigningStatus
-> f (Maybe SigningStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (SigningStatus -> CI Text)
-> (CI Text -> f (CI Text)) -> SigningStatus -> f SigningStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to SigningStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeSigningJob) (CI Text)
-> Acceptor DescribeSigningJob
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Failed"
            Accept
Core.AcceptFailure
            ( (Maybe SigningStatus -> f (Maybe SigningStatus))
-> DescribeSigningJobResponse -> f DescribeSigningJobResponse
Lens' DescribeSigningJobResponse (Maybe SigningStatus)
describeSigningJobResponse_status
                ((Maybe SigningStatus -> f (Maybe SigningStatus))
 -> DescribeSigningJobResponse -> f DescribeSigningJobResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe SigningStatus -> f (Maybe SigningStatus))
-> (CI Text -> f (CI Text))
-> DescribeSigningJobResponse
-> f DescribeSigningJobResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (SigningStatus -> f SigningStatus)
-> Maybe SigningStatus -> f (Maybe SigningStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((SigningStatus -> f SigningStatus)
 -> Maybe SigningStatus -> f (Maybe SigningStatus))
-> ((CI Text -> f (CI Text)) -> SigningStatus -> f SigningStatus)
-> (CI Text -> f (CI Text))
-> Maybe SigningStatus
-> f (Maybe SigningStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (SigningStatus -> CI Text)
-> (CI Text -> f (CI Text)) -> SigningStatus -> f SigningStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to SigningStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          ErrorCode -> Accept -> Acceptor DescribeSigningJob
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"ResourceNotFoundException"
            Accept
Core.AcceptFailure
        ]
    }