{-# LANGUAGE DisambiguateRecordFields #-}
{-# 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.CloudWatch.Waiters
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudWatch.Waiters where

import Amazonka.CloudWatch.DescribeAlarms
import Amazonka.CloudWatch.Lens
import Amazonka.CloudWatch.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.CloudWatch.DescribeAlarms' every 5 seconds until a successful state is reached. An error is returned after 40 failed checks.
newAlarmExists :: Core.Wait DescribeAlarms
newAlarmExists :: Wait DescribeAlarms
newAlarmExists =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"AlarmExists",
      $sel:attempts:Wait :: Int
Core.attempts = Int
40,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
5,
      $sel:acceptors:Wait :: [Acceptor DescribeAlarms]
Core.acceptors =
        [ forall a b. Bool -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchNonEmpty
            Bool
Prelude.True
            Accept
Core.AcceptSuccess
            ( forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( Lens' DescribeAlarmsResponse (Maybe [MetricAlarm])
describeAlarmsResponse_metricAlarms
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
            )
        ]
    }

-- | Polls 'Amazonka.CloudWatch.DescribeAlarms' every 5 seconds until a successful state is reached. An error is returned after 40 failed checks.
newCompositeAlarmExists :: Core.Wait DescribeAlarms
newCompositeAlarmExists :: Wait DescribeAlarms
newCompositeAlarmExists =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"CompositeAlarmExists",
      $sel:attempts:Wait :: Int
Core.attempts = Int
40,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
5,
      $sel:acceptors:Wait :: [Acceptor DescribeAlarms]
Core.acceptors =
        [ forall a b. Bool -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchNonEmpty
            Bool
Prelude.True
            Accept
Core.AcceptSuccess
            ( forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( Lens' DescribeAlarmsResponse (Maybe [CompositeAlarm])
describeAlarmsResponse_compositeAlarms
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
            )
        ]
    }