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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.GetCommandInvocation
import Amazonka.SSM.Lens
import Amazonka.SSM.Types

-- | Polls 'Amazonka.SSM.GetCommandInvocation' every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
newCommandExecuted :: Core.Wait GetCommandInvocation
newCommandExecuted :: Wait GetCommandInvocation
newCommandExecuted =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"CommandExecuted",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
5,
      $sel:_waitAcceptors:Wait :: [Acceptor GetCommandInvocation]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse GetCommandInvocation) (CI Text)
-> Acceptor GetCommandInvocation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Pending"
            Accept
Core.AcceptRetry
            ( (Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> GetCommandInvocationResponse -> f GetCommandInvocationResponse
Lens' GetCommandInvocationResponse (Maybe CommandInvocationStatus)
getCommandInvocationResponse_status
                ((Maybe CommandInvocationStatus
  -> f (Maybe CommandInvocationStatus))
 -> GetCommandInvocationResponse -> f GetCommandInvocationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CommandInvocationStatus
    -> f (Maybe CommandInvocationStatus))
-> (CI Text -> f (CI Text))
-> GetCommandInvocationResponse
-> f GetCommandInvocationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> f CommandInvocationStatus)
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CommandInvocationStatus -> f CommandInvocationStatus)
 -> Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> ((CI Text -> f (CI Text))
    -> CommandInvocationStatus -> f CommandInvocationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CommandInvocationStatus
-> f CommandInvocationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CommandInvocationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetCommandInvocation) (CI Text)
-> Acceptor GetCommandInvocation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"InProgress"
            Accept
Core.AcceptRetry
            ( (Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> GetCommandInvocationResponse -> f GetCommandInvocationResponse
Lens' GetCommandInvocationResponse (Maybe CommandInvocationStatus)
getCommandInvocationResponse_status
                ((Maybe CommandInvocationStatus
  -> f (Maybe CommandInvocationStatus))
 -> GetCommandInvocationResponse -> f GetCommandInvocationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CommandInvocationStatus
    -> f (Maybe CommandInvocationStatus))
-> (CI Text -> f (CI Text))
-> GetCommandInvocationResponse
-> f GetCommandInvocationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> f CommandInvocationStatus)
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CommandInvocationStatus -> f CommandInvocationStatus)
 -> Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> ((CI Text -> f (CI Text))
    -> CommandInvocationStatus -> f CommandInvocationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CommandInvocationStatus
-> f CommandInvocationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CommandInvocationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetCommandInvocation) (CI Text)
-> Acceptor GetCommandInvocation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Delayed"
            Accept
Core.AcceptRetry
            ( (Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> GetCommandInvocationResponse -> f GetCommandInvocationResponse
Lens' GetCommandInvocationResponse (Maybe CommandInvocationStatus)
getCommandInvocationResponse_status
                ((Maybe CommandInvocationStatus
  -> f (Maybe CommandInvocationStatus))
 -> GetCommandInvocationResponse -> f GetCommandInvocationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CommandInvocationStatus
    -> f (Maybe CommandInvocationStatus))
-> (CI Text -> f (CI Text))
-> GetCommandInvocationResponse
-> f GetCommandInvocationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> f CommandInvocationStatus)
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CommandInvocationStatus -> f CommandInvocationStatus)
 -> Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> ((CI Text -> f (CI Text))
    -> CommandInvocationStatus -> f CommandInvocationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CommandInvocationStatus
-> f CommandInvocationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CommandInvocationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetCommandInvocation) (CI Text)
-> Acceptor GetCommandInvocation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Success"
            Accept
Core.AcceptSuccess
            ( (Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> GetCommandInvocationResponse -> f GetCommandInvocationResponse
Lens' GetCommandInvocationResponse (Maybe CommandInvocationStatus)
getCommandInvocationResponse_status
                ((Maybe CommandInvocationStatus
  -> f (Maybe CommandInvocationStatus))
 -> GetCommandInvocationResponse -> f GetCommandInvocationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CommandInvocationStatus
    -> f (Maybe CommandInvocationStatus))
-> (CI Text -> f (CI Text))
-> GetCommandInvocationResponse
-> f GetCommandInvocationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> f CommandInvocationStatus)
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CommandInvocationStatus -> f CommandInvocationStatus)
 -> Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> ((CI Text -> f (CI Text))
    -> CommandInvocationStatus -> f CommandInvocationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CommandInvocationStatus
-> f CommandInvocationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CommandInvocationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetCommandInvocation) (CI Text)
-> Acceptor GetCommandInvocation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Cancelled"
            Accept
Core.AcceptFailure
            ( (Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> GetCommandInvocationResponse -> f GetCommandInvocationResponse
Lens' GetCommandInvocationResponse (Maybe CommandInvocationStatus)
getCommandInvocationResponse_status
                ((Maybe CommandInvocationStatus
  -> f (Maybe CommandInvocationStatus))
 -> GetCommandInvocationResponse -> f GetCommandInvocationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CommandInvocationStatus
    -> f (Maybe CommandInvocationStatus))
-> (CI Text -> f (CI Text))
-> GetCommandInvocationResponse
-> f GetCommandInvocationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> f CommandInvocationStatus)
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CommandInvocationStatus -> f CommandInvocationStatus)
 -> Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> ((CI Text -> f (CI Text))
    -> CommandInvocationStatus -> f CommandInvocationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CommandInvocationStatus
-> f CommandInvocationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CommandInvocationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetCommandInvocation) (CI Text)
-> Acceptor GetCommandInvocation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"TimedOut"
            Accept
Core.AcceptFailure
            ( (Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> GetCommandInvocationResponse -> f GetCommandInvocationResponse
Lens' GetCommandInvocationResponse (Maybe CommandInvocationStatus)
getCommandInvocationResponse_status
                ((Maybe CommandInvocationStatus
  -> f (Maybe CommandInvocationStatus))
 -> GetCommandInvocationResponse -> f GetCommandInvocationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CommandInvocationStatus
    -> f (Maybe CommandInvocationStatus))
-> (CI Text -> f (CI Text))
-> GetCommandInvocationResponse
-> f GetCommandInvocationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> f CommandInvocationStatus)
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CommandInvocationStatus -> f CommandInvocationStatus)
 -> Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> ((CI Text -> f (CI Text))
    -> CommandInvocationStatus -> f CommandInvocationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CommandInvocationStatus
-> f CommandInvocationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CommandInvocationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetCommandInvocation) (CI Text)
-> Acceptor GetCommandInvocation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Failed"
            Accept
Core.AcceptFailure
            ( (Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> GetCommandInvocationResponse -> f GetCommandInvocationResponse
Lens' GetCommandInvocationResponse (Maybe CommandInvocationStatus)
getCommandInvocationResponse_status
                ((Maybe CommandInvocationStatus
  -> f (Maybe CommandInvocationStatus))
 -> GetCommandInvocationResponse -> f GetCommandInvocationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CommandInvocationStatus
    -> f (Maybe CommandInvocationStatus))
-> (CI Text -> f (CI Text))
-> GetCommandInvocationResponse
-> f GetCommandInvocationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> f CommandInvocationStatus)
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CommandInvocationStatus -> f CommandInvocationStatus)
 -> Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> ((CI Text -> f (CI Text))
    -> CommandInvocationStatus -> f CommandInvocationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CommandInvocationStatus
-> f CommandInvocationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CommandInvocationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetCommandInvocation) (CI Text)
-> Acceptor GetCommandInvocation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Cancelling"
            Accept
Core.AcceptFailure
            ( (Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> GetCommandInvocationResponse -> f GetCommandInvocationResponse
Lens' GetCommandInvocationResponse (Maybe CommandInvocationStatus)
getCommandInvocationResponse_status
                ((Maybe CommandInvocationStatus
  -> f (Maybe CommandInvocationStatus))
 -> GetCommandInvocationResponse -> f GetCommandInvocationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CommandInvocationStatus
    -> f (Maybe CommandInvocationStatus))
-> (CI Text -> f (CI Text))
-> GetCommandInvocationResponse
-> f GetCommandInvocationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> f CommandInvocationStatus)
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CommandInvocationStatus -> f CommandInvocationStatus)
 -> Maybe CommandInvocationStatus
 -> f (Maybe CommandInvocationStatus))
-> ((CI Text -> f (CI Text))
    -> CommandInvocationStatus -> f CommandInvocationStatus)
-> (CI Text -> f (CI Text))
-> Maybe CommandInvocationStatus
-> f (Maybe CommandInvocationStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CommandInvocationStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> CommandInvocationStatus
-> f CommandInvocationStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to CommandInvocationStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          ErrorCode -> Accept -> Acceptor GetCommandInvocation
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"InvocationDoesNotExist"
            Accept
Core.AcceptRetry
        ]
    }