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

import Amazonka.CertificateManager.DescribeCertificate
import Amazonka.CertificateManager.Lens
import Amazonka.CertificateManager.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.CertificateManager.DescribeCertificate' every 60 seconds until a successful state is reached. An error is returned after 40 failed checks.
newCertificateValidated :: Core.Wait DescribeCertificate
newCertificateValidated :: Wait DescribeCertificate
newCertificateValidated =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"CertificateValidated",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
40,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
60,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeCertificate]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeCertificate) (CI Text)
-> Acceptor DescribeCertificate
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"SUCCESS"
            Accept
Core.AcceptSuccess
            ( (Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> DescribeCertificateResponse -> f DescribeCertificateResponse
Lens' DescribeCertificateResponse (Maybe CertificateDetail)
describeCertificateResponse_certificate
                ((Maybe CertificateDetail -> f (Maybe CertificateDetail))
 -> DescribeCertificateResponse -> f DescribeCertificateResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> (CI Text -> f (CI Text))
-> DescribeCertificateResponse
-> f DescribeCertificateResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CertificateDetail -> f CertificateDetail)
-> Maybe CertificateDetail -> f (Maybe CertificateDetail)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CertificateDetail -> f CertificateDetail)
 -> Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> ((CI Text -> f (CI Text))
    -> CertificateDetail -> f CertificateDetail)
-> (CI Text -> f (CI Text))
-> Maybe CertificateDetail
-> f (Maybe CertificateDetail)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CertificateDetail -> [DomainValidation])
-> Fold CertificateDetail DomainValidation
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                  ( Getting [DomainValidation] CertificateDetail [DomainValidation]
-> CertificateDetail -> [DomainValidation]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                      ( (Maybe (NonEmpty DomainValidation)
 -> Const [DomainValidation] (Maybe (NonEmpty DomainValidation)))
-> CertificateDetail -> Const [DomainValidation] CertificateDetail
Lens' CertificateDetail (Maybe (NonEmpty DomainValidation))
certificateDetail_domainValidationOptions
                          ((Maybe (NonEmpty DomainValidation)
  -> Const [DomainValidation] (Maybe (NonEmpty DomainValidation)))
 -> CertificateDetail -> Const [DomainValidation] CertificateDetail)
-> (([DomainValidation]
     -> Const [DomainValidation] [DomainValidation])
    -> Maybe (NonEmpty DomainValidation)
    -> Const [DomainValidation] (Maybe (NonEmpty DomainValidation)))
-> Getting [DomainValidation] CertificateDetail [DomainValidation]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty DomainValidation
 -> Const [DomainValidation] (NonEmpty DomainValidation))
-> Maybe (NonEmpty DomainValidation)
-> Const [DomainValidation] (Maybe (NonEmpty DomainValidation))
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                          ((NonEmpty DomainValidation
  -> Const [DomainValidation] (NonEmpty DomainValidation))
 -> Maybe (NonEmpty DomainValidation)
 -> Const [DomainValidation] (Maybe (NonEmpty DomainValidation)))
-> (([DomainValidation]
     -> Const [DomainValidation] [DomainValidation])
    -> NonEmpty DomainValidation
    -> Const [DomainValidation] (NonEmpty DomainValidation))
-> ([DomainValidation]
    -> Const [DomainValidation] [DomainValidation])
-> Maybe (NonEmpty DomainValidation)
-> Const [DomainValidation] (Maybe (NonEmpty DomainValidation))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty DomainValidation -> [DomainValidation])
-> ([DomainValidation]
    -> Const [DomainValidation] [DomainValidation])
-> NonEmpty DomainValidation
-> Const [DomainValidation] (NonEmpty DomainValidation)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to NonEmpty DomainValidation -> [DomainValidation]
forall l. IsList l => l -> [Item l]
Prelude.toList
                      )
                  )
                ((DomainValidation -> f DomainValidation)
 -> CertificateDetail -> f CertificateDetail)
-> ((CI Text -> f (CI Text))
    -> DomainValidation -> f DomainValidation)
-> (CI Text -> f (CI Text))
-> CertificateDetail
-> f CertificateDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe DomainStatus -> f (Maybe DomainStatus))
-> DomainValidation -> f DomainValidation
Lens' DomainValidation (Maybe DomainStatus)
domainValidation_validationStatus
                ((Maybe DomainStatus -> f (Maybe DomainStatus))
 -> DomainValidation -> f DomainValidation)
-> ((CI Text -> f (CI Text))
    -> Maybe DomainStatus -> f (Maybe DomainStatus))
-> (CI Text -> f (CI Text))
-> DomainValidation
-> f DomainValidation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DomainStatus -> f DomainStatus)
-> Maybe DomainStatus -> f (Maybe DomainStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((DomainStatus -> f DomainStatus)
 -> Maybe DomainStatus -> f (Maybe DomainStatus))
-> ((CI Text -> f (CI Text)) -> DomainStatus -> f DomainStatus)
-> (CI Text -> f (CI Text))
-> Maybe DomainStatus
-> f (Maybe DomainStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DomainStatus -> CI Text)
-> (CI Text -> f (CI Text)) -> DomainStatus -> f DomainStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to DomainStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeCertificate) (CI Text)
-> Acceptor DescribeCertificate
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"PENDING_VALIDATION"
            Accept
Core.AcceptRetry
            ( (Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> DescribeCertificateResponse -> f DescribeCertificateResponse
Lens' DescribeCertificateResponse (Maybe CertificateDetail)
describeCertificateResponse_certificate
                ((Maybe CertificateDetail -> f (Maybe CertificateDetail))
 -> DescribeCertificateResponse -> f DescribeCertificateResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> (CI Text -> f (CI Text))
-> DescribeCertificateResponse
-> f DescribeCertificateResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CertificateDetail -> f CertificateDetail)
-> Maybe CertificateDetail -> f (Maybe CertificateDetail)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CertificateDetail -> f CertificateDetail)
 -> Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> ((CI Text -> f (CI Text))
    -> CertificateDetail -> f CertificateDetail)
-> (CI Text -> f (CI Text))
-> Maybe CertificateDetail
-> f (Maybe CertificateDetail)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CertificateDetail -> [DomainValidation])
-> Fold CertificateDetail DomainValidation
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                  ( Getting [DomainValidation] CertificateDetail [DomainValidation]
-> CertificateDetail -> [DomainValidation]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                      ( (Maybe (NonEmpty DomainValidation)
 -> Const [DomainValidation] (Maybe (NonEmpty DomainValidation)))
-> CertificateDetail -> Const [DomainValidation] CertificateDetail
Lens' CertificateDetail (Maybe (NonEmpty DomainValidation))
certificateDetail_domainValidationOptions
                          ((Maybe (NonEmpty DomainValidation)
  -> Const [DomainValidation] (Maybe (NonEmpty DomainValidation)))
 -> CertificateDetail -> Const [DomainValidation] CertificateDetail)
-> (([DomainValidation]
     -> Const [DomainValidation] [DomainValidation])
    -> Maybe (NonEmpty DomainValidation)
    -> Const [DomainValidation] (Maybe (NonEmpty DomainValidation)))
-> Getting [DomainValidation] CertificateDetail [DomainValidation]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty DomainValidation
 -> Const [DomainValidation] (NonEmpty DomainValidation))
-> Maybe (NonEmpty DomainValidation)
-> Const [DomainValidation] (Maybe (NonEmpty DomainValidation))
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                          ((NonEmpty DomainValidation
  -> Const [DomainValidation] (NonEmpty DomainValidation))
 -> Maybe (NonEmpty DomainValidation)
 -> Const [DomainValidation] (Maybe (NonEmpty DomainValidation)))
-> (([DomainValidation]
     -> Const [DomainValidation] [DomainValidation])
    -> NonEmpty DomainValidation
    -> Const [DomainValidation] (NonEmpty DomainValidation))
-> ([DomainValidation]
    -> Const [DomainValidation] [DomainValidation])
-> Maybe (NonEmpty DomainValidation)
-> Const [DomainValidation] (Maybe (NonEmpty DomainValidation))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty DomainValidation -> [DomainValidation])
-> ([DomainValidation]
    -> Const [DomainValidation] [DomainValidation])
-> NonEmpty DomainValidation
-> Const [DomainValidation] (NonEmpty DomainValidation)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to NonEmpty DomainValidation -> [DomainValidation]
forall l. IsList l => l -> [Item l]
Prelude.toList
                      )
                  )
                ((DomainValidation -> f DomainValidation)
 -> CertificateDetail -> f CertificateDetail)
-> ((CI Text -> f (CI Text))
    -> DomainValidation -> f DomainValidation)
-> (CI Text -> f (CI Text))
-> CertificateDetail
-> f CertificateDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe DomainStatus -> f (Maybe DomainStatus))
-> DomainValidation -> f DomainValidation
Lens' DomainValidation (Maybe DomainStatus)
domainValidation_validationStatus
                ((Maybe DomainStatus -> f (Maybe DomainStatus))
 -> DomainValidation -> f DomainValidation)
-> ((CI Text -> f (CI Text))
    -> Maybe DomainStatus -> f (Maybe DomainStatus))
-> (CI Text -> f (CI Text))
-> DomainValidation
-> f DomainValidation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DomainStatus -> f DomainStatus)
-> Maybe DomainStatus -> f (Maybe DomainStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((DomainStatus -> f DomainStatus)
 -> Maybe DomainStatus -> f (Maybe DomainStatus))
-> ((CI Text -> f (CI Text)) -> DomainStatus -> f DomainStatus)
-> (CI Text -> f (CI Text))
-> Maybe DomainStatus
-> f (Maybe DomainStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DomainStatus -> CI Text)
-> (CI Text -> f (CI Text)) -> DomainStatus -> f DomainStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to DomainStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeCertificate) (CI Text)
-> Acceptor DescribeCertificate
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"FAILED"
            Accept
Core.AcceptFailure
            ( (Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> DescribeCertificateResponse -> f DescribeCertificateResponse
Lens' DescribeCertificateResponse (Maybe CertificateDetail)
describeCertificateResponse_certificate
                ((Maybe CertificateDetail -> f (Maybe CertificateDetail))
 -> DescribeCertificateResponse -> f DescribeCertificateResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> (CI Text -> f (CI Text))
-> DescribeCertificateResponse
-> f DescribeCertificateResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CertificateDetail -> f CertificateDetail)
-> Maybe CertificateDetail -> f (Maybe CertificateDetail)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CertificateDetail -> f CertificateDetail)
 -> Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> ((CI Text -> f (CI Text))
    -> CertificateDetail -> f CertificateDetail)
-> (CI Text -> f (CI Text))
-> Maybe CertificateDetail
-> f (Maybe CertificateDetail)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe CertificateStatus -> f (Maybe CertificateStatus))
-> CertificateDetail -> f CertificateDetail
Lens' CertificateDetail (Maybe CertificateStatus)
certificateDetail_status
                ((Maybe CertificateStatus -> f (Maybe CertificateStatus))
 -> CertificateDetail -> f CertificateDetail)
-> ((CI Text -> f (CI Text))
    -> Maybe CertificateStatus -> f (Maybe CertificateStatus))
-> (CI Text -> f (CI Text))
-> CertificateDetail
-> f CertificateDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CertificateStatus -> f CertificateStatus)
-> Maybe CertificateStatus -> f (Maybe CertificateStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CertificateStatus -> f CertificateStatus)
 -> Maybe CertificateStatus -> f (Maybe CertificateStatus))
-> ((CI Text -> f (CI Text))
    -> CertificateStatus -> f CertificateStatus)
-> (CI Text -> f (CI Text))
-> Maybe CertificateStatus
-> f (Maybe CertificateStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CertificateStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CertificateStatus
-> f CertificateStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CertificateStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          ErrorCode -> Accept -> Acceptor DescribeCertificate
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"ResourceNotFoundException"
            Accept
Core.AcceptFailure
        ]
    }