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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ELBV2.DescribeLoadBalancers
import Amazonka.ELBV2.DescribeTargetHealth
import Amazonka.ELBV2.Lens
import Amazonka.ELBV2.Types
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.ELBV2.DescribeLoadBalancers' every 15 seconds until a successful state is reached. An error is returned after 40 failed checks.
newLoadBalancerAvailable :: Core.Wait DescribeLoadBalancers
newLoadBalancerAvailable :: Wait DescribeLoadBalancers
newLoadBalancerAvailable =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"LoadBalancerAvailable",
      $sel:attempts:Wait :: Int
Core.attempts = Int
40,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
15,
      $sel:acceptors:Wait :: [Acceptor DescribeLoadBalancers]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"active"
            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' DescribeLoadBalancersResponse (Maybe [LoadBalancer])
describeLoadBalancersResponse_loadBalancers
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' LoadBalancer (Maybe LoadBalancerState)
loadBalancer_state
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' LoadBalancerState (Maybe LoadBalancerStateEnum)
loadBalancerState_code
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            ),
          forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"provisioning"
            Accept
Core.AcceptRetry
            ( 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' DescribeLoadBalancersResponse (Maybe [LoadBalancer])
describeLoadBalancersResponse_loadBalancers
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' LoadBalancer (Maybe LoadBalancerState)
loadBalancer_state
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' LoadBalancerState (Maybe LoadBalancerStateEnum)
loadBalancerState_code
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            ),
          forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"LoadBalancerNotFound"
            Accept
Core.AcceptRetry
        ]
    }

-- | Polls 'Amazonka.ELBV2.DescribeLoadBalancers' every 15 seconds until a successful state is reached. An error is returned after 40 failed checks.
newLoadBalancerExists :: Core.Wait DescribeLoadBalancers
newLoadBalancerExists :: Wait DescribeLoadBalancers
newLoadBalancerExists =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"LoadBalancerExists",
      $sel:attempts:Wait :: Int
Core.attempts = Int
40,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
15,
      $sel:acceptors:Wait :: [Acceptor DescribeLoadBalancers]
Core.acceptors =
        [ forall a. Int -> Accept -> Acceptor a
Core.matchStatus Int
200 Accept
Core.AcceptSuccess,
          forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"LoadBalancerNotFound"
            Accept
Core.AcceptRetry
        ]
    }

-- | Polls 'Amazonka.ELBV2.DescribeLoadBalancers' every 15 seconds until a successful state is reached. An error is returned after 40 failed checks.
newLoadBalancersDeleted :: Core.Wait DescribeLoadBalancers
newLoadBalancersDeleted :: Wait DescribeLoadBalancers
newLoadBalancersDeleted =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"LoadBalancersDeleted",
      $sel:attempts:Wait :: Int
Core.attempts = Int
40,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
15,
      $sel:acceptors:Wait :: [Acceptor DescribeLoadBalancers]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"active"
            Accept
Core.AcceptRetry
            ( 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' DescribeLoadBalancersResponse (Maybe [LoadBalancer])
describeLoadBalancersResponse_loadBalancers
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' LoadBalancer (Maybe LoadBalancerState)
loadBalancer_state
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' LoadBalancerState (Maybe LoadBalancerStateEnum)
loadBalancerState_code
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            ),
          forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"LoadBalancerNotFound"
            Accept
Core.AcceptSuccess
        ]
    }

-- | Polls 'Amazonka.ELBV2.DescribeTargetHealth' every 15 seconds until a successful state is reached. An error is returned after 40 failed checks.
newTargetDeregistered :: Core.Wait DescribeTargetHealth
newTargetDeregistered :: Wait DescribeTargetHealth
newTargetDeregistered =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"TargetDeregistered",
      $sel:attempts:Wait :: Int
Core.attempts = Int
40,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
15,
      $sel:acceptors:Wait :: [Acceptor DescribeTargetHealth]
Core.acceptors =
        [ forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError ErrorCode
"InvalidTarget" Accept
Core.AcceptSuccess,
          forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"unused"
            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'
  DescribeTargetHealthResponse (Maybe [TargetHealthDescription])
describeTargetHealthResponse_targetHealthDescriptions
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' TargetHealthDescription (Maybe TargetHealth)
targetHealthDescription_targetHealth
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' TargetHealth (Maybe TargetHealthStateEnum)
targetHealth_state
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.ELBV2.DescribeTargetHealth' every 15 seconds until a successful state is reached. An error is returned after 40 failed checks.
newTargetInService :: Core.Wait DescribeTargetHealth
newTargetInService :: Wait DescribeTargetHealth
newTargetInService =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"TargetInService",
      $sel:attempts:Wait :: Int
Core.attempts = Int
40,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
15,
      $sel:acceptors:Wait :: [Acceptor DescribeTargetHealth]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"healthy"
            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'
  DescribeTargetHealthResponse (Maybe [TargetHealthDescription])
describeTargetHealthResponse_targetHealthDescriptions
                        forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' TargetHealthDescription (Maybe TargetHealth)
targetHealthDescription_targetHealth
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Lens' TargetHealth (Maybe TargetHealthStateEnum)
targetHealth_state
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to forall a. ToText a => a -> CI Text
Data.toTextCI
            ),
          forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError ErrorCode
"InvalidInstance" Accept
Core.AcceptRetry
        ]
    }