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

import Amazonka.CodeDeploy.GetDeployment
import Amazonka.CodeDeploy.Lens
import Amazonka.CodeDeploy.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.CodeDeploy.GetDeployment' every 15 seconds until a successful state is reached. An error is returned after 120 failed checks.
newDeploymentSuccessful :: Core.Wait GetDeployment
newDeploymentSuccessful :: Wait GetDeployment
newDeploymentSuccessful =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"DeploymentSuccessful",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
120,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
15,
      $sel:_waitAcceptors:Wait :: [Acceptor GetDeployment]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse GetDeployment) (CI Text)
-> Acceptor GetDeployment
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Succeeded"
            Accept
Core.AcceptSuccess
            ( (Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> GetDeploymentResponse -> f GetDeploymentResponse
Lens' GetDeploymentResponse (Maybe DeploymentInfo)
getDeploymentResponse_deploymentInfo
                ((Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
 -> GetDeploymentResponse -> f GetDeploymentResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> (CI Text -> f (CI Text))
-> GetDeploymentResponse
-> f GetDeploymentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentInfo -> f DeploymentInfo)
-> Maybe DeploymentInfo -> f (Maybe DeploymentInfo)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((DeploymentInfo -> f DeploymentInfo)
 -> Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> ((CI Text -> f (CI Text)) -> DeploymentInfo -> f DeploymentInfo)
-> (CI Text -> f (CI Text))
-> Maybe DeploymentInfo
-> f (Maybe DeploymentInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> DeploymentInfo -> f DeploymentInfo
Lens' DeploymentInfo (Maybe DeploymentStatus)
deploymentInfo_status
                ((Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
 -> DeploymentInfo -> f DeploymentInfo)
-> ((CI Text -> f (CI Text))
    -> Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> (CI Text -> f (CI Text))
-> DeploymentInfo
-> f DeploymentInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentStatus -> f DeploymentStatus)
-> Maybe DeploymentStatus -> f (Maybe DeploymentStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((DeploymentStatus -> f DeploymentStatus)
 -> Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> ((CI Text -> f (CI Text))
    -> DeploymentStatus -> f DeploymentStatus)
-> (CI Text -> f (CI Text))
-> Maybe DeploymentStatus
-> f (Maybe DeploymentStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> DeploymentStatus
-> f DeploymentStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to DeploymentStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetDeployment) (CI Text)
-> Acceptor GetDeployment
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Failed"
            Accept
Core.AcceptFailure
            ( (Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> GetDeploymentResponse -> f GetDeploymentResponse
Lens' GetDeploymentResponse (Maybe DeploymentInfo)
getDeploymentResponse_deploymentInfo
                ((Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
 -> GetDeploymentResponse -> f GetDeploymentResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> (CI Text -> f (CI Text))
-> GetDeploymentResponse
-> f GetDeploymentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentInfo -> f DeploymentInfo)
-> Maybe DeploymentInfo -> f (Maybe DeploymentInfo)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((DeploymentInfo -> f DeploymentInfo)
 -> Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> ((CI Text -> f (CI Text)) -> DeploymentInfo -> f DeploymentInfo)
-> (CI Text -> f (CI Text))
-> Maybe DeploymentInfo
-> f (Maybe DeploymentInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> DeploymentInfo -> f DeploymentInfo
Lens' DeploymentInfo (Maybe DeploymentStatus)
deploymentInfo_status
                ((Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
 -> DeploymentInfo -> f DeploymentInfo)
-> ((CI Text -> f (CI Text))
    -> Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> (CI Text -> f (CI Text))
-> DeploymentInfo
-> f DeploymentInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentStatus -> f DeploymentStatus)
-> Maybe DeploymentStatus -> f (Maybe DeploymentStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((DeploymentStatus -> f DeploymentStatus)
 -> Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> ((CI Text -> f (CI Text))
    -> DeploymentStatus -> f DeploymentStatus)
-> (CI Text -> f (CI Text))
-> Maybe DeploymentStatus
-> f (Maybe DeploymentStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> DeploymentStatus
-> f DeploymentStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to DeploymentStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetDeployment) (CI Text)
-> Acceptor GetDeployment
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Stopped"
            Accept
Core.AcceptFailure
            ( (Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> GetDeploymentResponse -> f GetDeploymentResponse
Lens' GetDeploymentResponse (Maybe DeploymentInfo)
getDeploymentResponse_deploymentInfo
                ((Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
 -> GetDeploymentResponse -> f GetDeploymentResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> (CI Text -> f (CI Text))
-> GetDeploymentResponse
-> f GetDeploymentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentInfo -> f DeploymentInfo)
-> Maybe DeploymentInfo -> f (Maybe DeploymentInfo)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((DeploymentInfo -> f DeploymentInfo)
 -> Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> ((CI Text -> f (CI Text)) -> DeploymentInfo -> f DeploymentInfo)
-> (CI Text -> f (CI Text))
-> Maybe DeploymentInfo
-> f (Maybe DeploymentInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> DeploymentInfo -> f DeploymentInfo
Lens' DeploymentInfo (Maybe DeploymentStatus)
deploymentInfo_status
                ((Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
 -> DeploymentInfo -> f DeploymentInfo)
-> ((CI Text -> f (CI Text))
    -> Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> (CI Text -> f (CI Text))
-> DeploymentInfo
-> f DeploymentInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentStatus -> f DeploymentStatus)
-> Maybe DeploymentStatus -> f (Maybe DeploymentStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((DeploymentStatus -> f DeploymentStatus)
 -> Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> ((CI Text -> f (CI Text))
    -> DeploymentStatus -> f DeploymentStatus)
-> (CI Text -> f (CI Text))
-> Maybe DeploymentStatus
-> f (Maybe DeploymentStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (DeploymentStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> DeploymentStatus
-> f DeploymentStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to DeploymentStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }