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

import Amazonka.AMP.DescribeWorkspace
import Amazonka.AMP.Lens
import Amazonka.AMP.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.AMP.DescribeWorkspace' every 2 seconds until a successful state is reached. An error is returned after 60 failed checks.
newWorkspaceDeleted :: Core.Wait DescribeWorkspace
newWorkspaceDeleted :: Wait DescribeWorkspace
newWorkspaceDeleted =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"WorkspaceDeleted",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
60,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
2,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeWorkspace]
Core._waitAcceptors =
        [ ErrorCode -> Accept -> Acceptor DescribeWorkspace
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"ResourceNotFoundException"
            Accept
Core.AcceptSuccess,
          CI Text
-> Accept
-> Fold (AWSResponse DescribeWorkspace) (CI Text)
-> Acceptor DescribeWorkspace
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"DELETING"
            Accept
Core.AcceptRetry
            ( (WorkspaceDescription -> f WorkspaceDescription)
-> DescribeWorkspaceResponse -> f DescribeWorkspaceResponse
Lens' DescribeWorkspaceResponse WorkspaceDescription
describeWorkspaceResponse_workspace
                ((WorkspaceDescription -> f WorkspaceDescription)
 -> DescribeWorkspaceResponse -> f DescribeWorkspaceResponse)
-> ((CI Text -> f (CI Text))
    -> WorkspaceDescription -> f WorkspaceDescription)
-> (CI Text -> f (CI Text))
-> DescribeWorkspaceResponse
-> f DescribeWorkspaceResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatus -> f WorkspaceStatus)
-> WorkspaceDescription -> f WorkspaceDescription
Lens' WorkspaceDescription WorkspaceStatus
workspaceDescription_status
                ((WorkspaceStatus -> f WorkspaceStatus)
 -> WorkspaceDescription -> f WorkspaceDescription)
-> ((CI Text -> f (CI Text))
    -> WorkspaceStatus -> f WorkspaceStatus)
-> (CI Text -> f (CI Text))
-> WorkspaceDescription
-> f WorkspaceDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatusCode -> f WorkspaceStatusCode)
-> WorkspaceStatus -> f WorkspaceStatus
Lens' WorkspaceStatus WorkspaceStatusCode
workspaceStatus_statusCode
                ((WorkspaceStatusCode -> f WorkspaceStatusCode)
 -> WorkspaceStatus -> f WorkspaceStatus)
-> ((CI Text -> f (CI Text))
    -> WorkspaceStatusCode -> f WorkspaceStatusCode)
-> (CI Text -> f (CI Text))
-> WorkspaceStatus
-> f WorkspaceStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatusCode -> CI Text)
-> (CI Text -> f (CI Text))
-> WorkspaceStatusCode
-> f WorkspaceStatusCode
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to WorkspaceStatusCode -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.AMP.DescribeWorkspace' every 2 seconds until a successful state is reached. An error is returned after 60 failed checks.
newWorkspaceActive :: Core.Wait DescribeWorkspace
newWorkspaceActive :: Wait DescribeWorkspace
newWorkspaceActive =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"WorkspaceActive",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
60,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
2,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeWorkspace]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeWorkspace) (CI Text)
-> Acceptor DescribeWorkspace
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"ACTIVE"
            Accept
Core.AcceptSuccess
            ( (WorkspaceDescription -> f WorkspaceDescription)
-> DescribeWorkspaceResponse -> f DescribeWorkspaceResponse
Lens' DescribeWorkspaceResponse WorkspaceDescription
describeWorkspaceResponse_workspace
                ((WorkspaceDescription -> f WorkspaceDescription)
 -> DescribeWorkspaceResponse -> f DescribeWorkspaceResponse)
-> ((CI Text -> f (CI Text))
    -> WorkspaceDescription -> f WorkspaceDescription)
-> (CI Text -> f (CI Text))
-> DescribeWorkspaceResponse
-> f DescribeWorkspaceResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatus -> f WorkspaceStatus)
-> WorkspaceDescription -> f WorkspaceDescription
Lens' WorkspaceDescription WorkspaceStatus
workspaceDescription_status
                ((WorkspaceStatus -> f WorkspaceStatus)
 -> WorkspaceDescription -> f WorkspaceDescription)
-> ((CI Text -> f (CI Text))
    -> WorkspaceStatus -> f WorkspaceStatus)
-> (CI Text -> f (CI Text))
-> WorkspaceDescription
-> f WorkspaceDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatusCode -> f WorkspaceStatusCode)
-> WorkspaceStatus -> f WorkspaceStatus
Lens' WorkspaceStatus WorkspaceStatusCode
workspaceStatus_statusCode
                ((WorkspaceStatusCode -> f WorkspaceStatusCode)
 -> WorkspaceStatus -> f WorkspaceStatus)
-> ((CI Text -> f (CI Text))
    -> WorkspaceStatusCode -> f WorkspaceStatusCode)
-> (CI Text -> f (CI Text))
-> WorkspaceStatus
-> f WorkspaceStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatusCode -> CI Text)
-> (CI Text -> f (CI Text))
-> WorkspaceStatusCode
-> f WorkspaceStatusCode
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to WorkspaceStatusCode -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeWorkspace) (CI Text)
-> Acceptor DescribeWorkspace
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"UPDATING"
            Accept
Core.AcceptRetry
            ( (WorkspaceDescription -> f WorkspaceDescription)
-> DescribeWorkspaceResponse -> f DescribeWorkspaceResponse
Lens' DescribeWorkspaceResponse WorkspaceDescription
describeWorkspaceResponse_workspace
                ((WorkspaceDescription -> f WorkspaceDescription)
 -> DescribeWorkspaceResponse -> f DescribeWorkspaceResponse)
-> ((CI Text -> f (CI Text))
    -> WorkspaceDescription -> f WorkspaceDescription)
-> (CI Text -> f (CI Text))
-> DescribeWorkspaceResponse
-> f DescribeWorkspaceResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatus -> f WorkspaceStatus)
-> WorkspaceDescription -> f WorkspaceDescription
Lens' WorkspaceDescription WorkspaceStatus
workspaceDescription_status
                ((WorkspaceStatus -> f WorkspaceStatus)
 -> WorkspaceDescription -> f WorkspaceDescription)
-> ((CI Text -> f (CI Text))
    -> WorkspaceStatus -> f WorkspaceStatus)
-> (CI Text -> f (CI Text))
-> WorkspaceDescription
-> f WorkspaceDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatusCode -> f WorkspaceStatusCode)
-> WorkspaceStatus -> f WorkspaceStatus
Lens' WorkspaceStatus WorkspaceStatusCode
workspaceStatus_statusCode
                ((WorkspaceStatusCode -> f WorkspaceStatusCode)
 -> WorkspaceStatus -> f WorkspaceStatus)
-> ((CI Text -> f (CI Text))
    -> WorkspaceStatusCode -> f WorkspaceStatusCode)
-> (CI Text -> f (CI Text))
-> WorkspaceStatus
-> f WorkspaceStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatusCode -> CI Text)
-> (CI Text -> f (CI Text))
-> WorkspaceStatusCode
-> f WorkspaceStatusCode
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to WorkspaceStatusCode -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeWorkspace) (CI Text)
-> Acceptor DescribeWorkspace
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"CREATING"
            Accept
Core.AcceptRetry
            ( (WorkspaceDescription -> f WorkspaceDescription)
-> DescribeWorkspaceResponse -> f DescribeWorkspaceResponse
Lens' DescribeWorkspaceResponse WorkspaceDescription
describeWorkspaceResponse_workspace
                ((WorkspaceDescription -> f WorkspaceDescription)
 -> DescribeWorkspaceResponse -> f DescribeWorkspaceResponse)
-> ((CI Text -> f (CI Text))
    -> WorkspaceDescription -> f WorkspaceDescription)
-> (CI Text -> f (CI Text))
-> DescribeWorkspaceResponse
-> f DescribeWorkspaceResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatus -> f WorkspaceStatus)
-> WorkspaceDescription -> f WorkspaceDescription
Lens' WorkspaceDescription WorkspaceStatus
workspaceDescription_status
                ((WorkspaceStatus -> f WorkspaceStatus)
 -> WorkspaceDescription -> f WorkspaceDescription)
-> ((CI Text -> f (CI Text))
    -> WorkspaceStatus -> f WorkspaceStatus)
-> (CI Text -> f (CI Text))
-> WorkspaceDescription
-> f WorkspaceDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatusCode -> f WorkspaceStatusCode)
-> WorkspaceStatus -> f WorkspaceStatus
Lens' WorkspaceStatus WorkspaceStatusCode
workspaceStatus_statusCode
                ((WorkspaceStatusCode -> f WorkspaceStatusCode)
 -> WorkspaceStatus -> f WorkspaceStatus)
-> ((CI Text -> f (CI Text))
    -> WorkspaceStatusCode -> f WorkspaceStatusCode)
-> (CI Text -> f (CI Text))
-> WorkspaceStatus
-> f WorkspaceStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (WorkspaceStatusCode -> CI Text)
-> (CI Text -> f (CI Text))
-> WorkspaceStatusCode
-> f WorkspaceStatusCode
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to WorkspaceStatusCode -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }