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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorksCM.DescribeNodeAssociationStatus
import Amazonka.OpsWorksCM.Lens
import Amazonka.OpsWorksCM.Types
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.OpsWorksCM.DescribeNodeAssociationStatus' every 15 seconds until a successful state is reached. An error is returned after 15 failed checks.
newNodeAssociated :: Core.Wait DescribeNodeAssociationStatus
newNodeAssociated :: Wait DescribeNodeAssociationStatus
newNodeAssociated =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"NodeAssociated",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
15,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
15,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeNodeAssociationStatus]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeNodeAssociationStatus) (CI Text)
-> Acceptor DescribeNodeAssociationStatus
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"SUCCESS"
            Accept
Core.AcceptSuccess
            ( (NodeAssociationStatus -> f NodeAssociationStatus)
-> DescribeNodeAssociationStatusResponse
-> f DescribeNodeAssociationStatusResponse
Lens' DescribeNodeAssociationStatusResponse NodeAssociationStatus
describeNodeAssociationStatusResponse_nodeAssociationStatus
                ((NodeAssociationStatus -> f NodeAssociationStatus)
 -> DescribeNodeAssociationStatusResponse
 -> f DescribeNodeAssociationStatusResponse)
-> ((CI Text -> f (CI Text))
    -> NodeAssociationStatus -> f NodeAssociationStatus)
-> (CI Text -> f (CI Text))
-> DescribeNodeAssociationStatusResponse
-> f DescribeNodeAssociationStatusResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NodeAssociationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> NodeAssociationStatus
-> f NodeAssociationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to NodeAssociationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeNodeAssociationStatus) (CI Text)
-> Acceptor DescribeNodeAssociationStatus
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"FAILED"
            Accept
Core.AcceptFailure
            ( (NodeAssociationStatus -> f NodeAssociationStatus)
-> DescribeNodeAssociationStatusResponse
-> f DescribeNodeAssociationStatusResponse
Lens' DescribeNodeAssociationStatusResponse NodeAssociationStatus
describeNodeAssociationStatusResponse_nodeAssociationStatus
                ((NodeAssociationStatus -> f NodeAssociationStatus)
 -> DescribeNodeAssociationStatusResponse
 -> f DescribeNodeAssociationStatusResponse)
-> ((CI Text -> f (CI Text))
    -> NodeAssociationStatus -> f NodeAssociationStatus)
-> (CI Text -> f (CI Text))
-> DescribeNodeAssociationStatusResponse
-> f DescribeNodeAssociationStatusResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NodeAssociationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> NodeAssociationStatus
-> f NodeAssociationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to NodeAssociationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }