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

import Amazonka.CertificateManagerPCA.DescribeCertificateAuthorityAuditReport
import Amazonka.CertificateManagerPCA.GetCertificate
import Amazonka.CertificateManagerPCA.GetCertificateAuthorityCsr
import Amazonka.CertificateManagerPCA.Lens
import Amazonka.CertificateManagerPCA.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.CertificateManagerPCA.GetCertificate' every 3 seconds until a successful state is reached. An error is returned after 60 failed checks.
newCertificateIssued :: Core.Wait GetCertificate
newCertificateIssued :: Wait GetCertificate
newCertificateIssued =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"CertificateIssued",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
60,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor GetCertificate]
Core._waitAcceptors =
        [ Int -> Accept -> Acceptor GetCertificate
forall a. Int -> Accept -> Acceptor a
Core.matchStatus Int
200 Accept
Core.AcceptSuccess,
          ErrorCode -> Accept -> Acceptor GetCertificate
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"RequestInProgressException"
            Accept
Core.AcceptRetry
        ]
    }

-- | Polls 'Amazonka.CertificateManagerPCA.DescribeCertificateAuthorityAuditReport' every 3 seconds until a successful state is reached. An error is returned after 60 failed checks.
newAuditReportCreated :: Core.Wait DescribeCertificateAuthorityAuditReport
newAuditReportCreated :: Wait DescribeCertificateAuthorityAuditReport
newAuditReportCreated =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"AuditReportCreated",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
60,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeCertificateAuthorityAuditReport]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold
     (AWSResponse DescribeCertificateAuthorityAuditReport) (CI Text)
-> Acceptor DescribeCertificateAuthorityAuditReport
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"SUCCESS"
            Accept
Core.AcceptSuccess
            ( (Maybe AuditReportStatus -> f (Maybe AuditReportStatus))
-> DescribeCertificateAuthorityAuditReportResponse
-> f DescribeCertificateAuthorityAuditReportResponse
Lens'
  DescribeCertificateAuthorityAuditReportResponse
  (Maybe AuditReportStatus)
describeCertificateAuthorityAuditReportResponse_auditReportStatus
                ((Maybe AuditReportStatus -> f (Maybe AuditReportStatus))
 -> DescribeCertificateAuthorityAuditReportResponse
 -> f DescribeCertificateAuthorityAuditReportResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe AuditReportStatus -> f (Maybe AuditReportStatus))
-> (CI Text -> f (CI Text))
-> DescribeCertificateAuthorityAuditReportResponse
-> f DescribeCertificateAuthorityAuditReportResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AuditReportStatus -> f AuditReportStatus)
-> Maybe AuditReportStatus -> f (Maybe AuditReportStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((AuditReportStatus -> f AuditReportStatus)
 -> Maybe AuditReportStatus -> f (Maybe AuditReportStatus))
-> ((CI Text -> f (CI Text))
    -> AuditReportStatus -> f AuditReportStatus)
-> (CI Text -> f (CI Text))
-> Maybe AuditReportStatus
-> f (Maybe AuditReportStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AuditReportStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> AuditReportStatus
-> f AuditReportStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to AuditReportStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold
     (AWSResponse DescribeCertificateAuthorityAuditReport) (CI Text)
-> Acceptor DescribeCertificateAuthorityAuditReport
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"FAILED"
            Accept
Core.AcceptFailure
            ( (Maybe AuditReportStatus -> f (Maybe AuditReportStatus))
-> DescribeCertificateAuthorityAuditReportResponse
-> f DescribeCertificateAuthorityAuditReportResponse
Lens'
  DescribeCertificateAuthorityAuditReportResponse
  (Maybe AuditReportStatus)
describeCertificateAuthorityAuditReportResponse_auditReportStatus
                ((Maybe AuditReportStatus -> f (Maybe AuditReportStatus))
 -> DescribeCertificateAuthorityAuditReportResponse
 -> f DescribeCertificateAuthorityAuditReportResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe AuditReportStatus -> f (Maybe AuditReportStatus))
-> (CI Text -> f (CI Text))
-> DescribeCertificateAuthorityAuditReportResponse
-> f DescribeCertificateAuthorityAuditReportResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AuditReportStatus -> f AuditReportStatus)
-> Maybe AuditReportStatus -> f (Maybe AuditReportStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((AuditReportStatus -> f AuditReportStatus)
 -> Maybe AuditReportStatus -> f (Maybe AuditReportStatus))
-> ((CI Text -> f (CI Text))
    -> AuditReportStatus -> f AuditReportStatus)
-> (CI Text -> f (CI Text))
-> Maybe AuditReportStatus
-> f (Maybe AuditReportStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AuditReportStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> AuditReportStatus
-> f AuditReportStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to AuditReportStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.CertificateManagerPCA.GetCertificateAuthorityCsr' every 3 seconds until a successful state is reached. An error is returned after 60 failed checks.
newCertificateAuthorityCSRCreated :: Core.Wait GetCertificateAuthorityCsr
newCertificateAuthorityCSRCreated :: Wait GetCertificateAuthorityCsr
newCertificateAuthorityCSRCreated =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName =
        ByteString
"CertificateAuthorityCSRCreated",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
60,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor GetCertificateAuthorityCsr]
Core._waitAcceptors =
        [ Int -> Accept -> Acceptor GetCertificateAuthorityCsr
forall a. Int -> Accept -> Acceptor a
Core.matchStatus Int
200 Accept
Core.AcceptSuccess,
          ErrorCode -> Accept -> Acceptor GetCertificateAuthorityCsr
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"RequestInProgressException"
            Accept
Core.AcceptRetry
        ]
    }