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

import Amazonka.CloudFront.GetDistribution
import Amazonka.CloudFront.GetInvalidation
import Amazonka.CloudFront.GetStreamingDistribution
import Amazonka.CloudFront.Lens
import Amazonka.CloudFront.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.CloudFront.GetDistribution' every 60 seconds until a successful state is reached. An error is returned after 35 failed checks.
newDistributionDeployed :: Core.Wait GetDistribution
newDistributionDeployed :: Wait GetDistribution
newDistributionDeployed =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"DistributionDeployed",
      $sel:attempts:Wait :: Int
Core.attempts = Int
35,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
60,
      $sel:acceptors:Wait :: [Acceptor GetDistribution]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Deployed"
            Accept
Core.AcceptSuccess
            ( Lens' GetDistributionResponse (Maybe Distribution)
getDistributionResponse_distribution
                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' Distribution Text
distribution_status
                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.CloudFront.GetInvalidation' every 20 seconds until a successful state is reached. An error is returned after 30 failed checks.
newInvalidationCompleted :: Core.Wait GetInvalidation
newInvalidationCompleted :: Wait GetInvalidation
newInvalidationCompleted =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name = ByteString
"InvalidationCompleted",
      $sel:attempts:Wait :: Int
Core.attempts = Int
30,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
20,
      $sel:acceptors:Wait :: [Acceptor GetInvalidation]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Completed"
            Accept
Core.AcceptSuccess
            ( Lens' GetInvalidationResponse (Maybe Invalidation)
getInvalidationResponse_invalidation
                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' Invalidation Text
invalidation_status
                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.CloudFront.GetStreamingDistribution' every 60 seconds until a successful state is reached. An error is returned after 25 failed checks.
newStreamingDistributionDeployed :: Core.Wait GetStreamingDistribution
newStreamingDistributionDeployed :: Wait GetStreamingDistribution
newStreamingDistributionDeployed =
  Core.Wait
    { $sel:name:Wait :: ByteString
Core.name =
        ByteString
"StreamingDistributionDeployed",
      $sel:attempts:Wait :: Int
Core.attempts = Int
25,
      $sel:delay:Wait :: Seconds
Core.delay = Seconds
60,
      $sel:acceptors:Wait :: [Acceptor GetStreamingDistribution]
Core.acceptors =
        [ forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Deployed"
            Accept
Core.AcceptSuccess
            ( Lens'
  GetStreamingDistributionResponse (Maybe StreamingDistribution)
getStreamingDistributionResponse_streamingDistribution
                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' StreamingDistribution Text
streamingDistribution_status
                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
            )
        ]
    }