{-# 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-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.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.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | 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 =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName =
        ByteString
"StreamingDistributionDeployed",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
25,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
60,
      $sel:_waitAcceptors:Wait :: [Acceptor GetStreamingDistribution]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse GetStreamingDistribution) (CI Text)
-> Acceptor GetStreamingDistribution
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Deployed"
            Accept
Core.AcceptSuccess
            ( (Maybe StreamingDistribution -> f (Maybe StreamingDistribution))
-> GetStreamingDistributionResponse
-> f GetStreamingDistributionResponse
Lens'
  GetStreamingDistributionResponse (Maybe StreamingDistribution)
getStreamingDistributionResponse_streamingDistribution
                ((Maybe StreamingDistribution -> f (Maybe StreamingDistribution))
 -> GetStreamingDistributionResponse
 -> f GetStreamingDistributionResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe StreamingDistribution -> f (Maybe StreamingDistribution))
-> (CI Text -> f (CI Text))
-> GetStreamingDistributionResponse
-> f GetStreamingDistributionResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (StreamingDistribution -> f StreamingDistribution)
-> Maybe StreamingDistribution -> f (Maybe StreamingDistribution)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((StreamingDistribution -> f StreamingDistribution)
 -> Maybe StreamingDistribution -> f (Maybe StreamingDistribution))
-> ((CI Text -> f (CI Text))
    -> StreamingDistribution -> f StreamingDistribution)
-> (CI Text -> f (CI Text))
-> Maybe StreamingDistribution
-> f (Maybe StreamingDistribution)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text)
-> StreamingDistribution -> f StreamingDistribution
Lens' StreamingDistribution Text
streamingDistribution_status
                ((Text -> f Text)
 -> StreamingDistribution -> f StreamingDistribution)
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> StreamingDistribution
-> f StreamingDistribution
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | 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 =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"DistributionDeployed",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
35,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
60,
      $sel:_waitAcceptors:Wait :: [Acceptor GetDistribution]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse GetDistribution) (CI Text)
-> Acceptor GetDistribution
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Deployed"
            Accept
Core.AcceptSuccess
            ( (Maybe Distribution -> f (Maybe Distribution))
-> GetDistributionResponse -> f GetDistributionResponse
Lens' GetDistributionResponse (Maybe Distribution)
getDistributionResponse_distribution
                ((Maybe Distribution -> f (Maybe Distribution))
 -> GetDistributionResponse -> f GetDistributionResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe Distribution -> f (Maybe Distribution))
-> (CI Text -> f (CI Text))
-> GetDistributionResponse
-> f GetDistributionResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Distribution -> f Distribution)
-> Maybe Distribution -> f (Maybe Distribution)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((Distribution -> f Distribution)
 -> Maybe Distribution -> f (Maybe Distribution))
-> ((CI Text -> f (CI Text)) -> Distribution -> f Distribution)
-> (CI Text -> f (CI Text))
-> Maybe Distribution
-> f (Maybe Distribution)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Distribution -> f Distribution
Lens' Distribution Text
distribution_status
                ((Text -> f Text) -> Distribution -> f Distribution)
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> Distribution
-> f Distribution
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.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 =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"InvalidationCompleted",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
30,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
20,
      $sel:_waitAcceptors:Wait :: [Acceptor GetInvalidation]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse GetInvalidation) (CI Text)
-> Acceptor GetInvalidation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Completed"
            Accept
Core.AcceptSuccess
            ( (Maybe Invalidation -> f (Maybe Invalidation))
-> GetInvalidationResponse -> f GetInvalidationResponse
Lens' GetInvalidationResponse (Maybe Invalidation)
getInvalidationResponse_invalidation
                ((Maybe Invalidation -> f (Maybe Invalidation))
 -> GetInvalidationResponse -> f GetInvalidationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe Invalidation -> f (Maybe Invalidation))
-> (CI Text -> f (CI Text))
-> GetInvalidationResponse
-> f GetInvalidationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Invalidation -> f Invalidation)
-> Maybe Invalidation -> f (Maybe Invalidation)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((Invalidation -> f Invalidation)
 -> Maybe Invalidation -> f (Maybe Invalidation))
-> ((CI Text -> f (CI Text)) -> Invalidation -> f Invalidation)
-> (CI Text -> f (CI Text))
-> Maybe Invalidation
-> f (Maybe Invalidation)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Invalidation -> f Invalidation
Lens' Invalidation Text
invalidation_status
                ((Text -> f Text) -> Invalidation -> f Invalidation)
-> ((CI Text -> f (CI Text)) -> Text -> f Text)
-> (CI Text -> f (CI Text))
-> Invalidation
-> f Invalidation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> CI Text) -> (CI Text -> f (CI Text)) -> Text -> f Text
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to Text -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }